mirror of
https://github.com/ppy/osu
synced 2024-12-15 03:16:17 +00:00
Merge branch 'improved-loading-animation' into nuget-update
This commit is contained in:
commit
19236dcd1e
@ -1,15 +1,48 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
public class LoadingAnimation : SpriteText
|
public class LoadingAnimation : VisibilityContainer
|
||||||
{
|
{
|
||||||
|
private readonly TextAwesome spinner;
|
||||||
|
|
||||||
public LoadingAnimation()
|
public LoadingAnimation()
|
||||||
{
|
{
|
||||||
Text = "Loading";
|
Size = new Vector2(20);
|
||||||
|
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
spinner = new TextAwesome
|
||||||
|
{
|
||||||
|
TextSize = 20,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Icon = FontAwesome.fa_spinner
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
spinner.RotateTo(360, 2000);
|
||||||
|
using (spinner.BeginDelayedSequence(2000))
|
||||||
|
spinner.Loop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private const float transition_duration = 500;
|
||||||
|
|
||||||
|
protected override void PopIn() => FadeIn(transition_duration * 5, EasingTypes.OutQuint);
|
||||||
|
|
||||||
|
protected override void PopOut() => FadeOut(transition_duration, EasingTypes.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
@ -33,7 +32,9 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private ScheduledDelegate messageRequest;
|
private ScheduledDelegate messageRequest;
|
||||||
|
|
||||||
private readonly Container currentChannelContainer;
|
private readonly Container<DrawableChannel> currentChannelContainer;
|
||||||
|
|
||||||
|
private readonly LoadingAnimation loading;
|
||||||
|
|
||||||
private readonly FocusedTextBox inputTextBox;
|
private readonly FocusedTextBox inputTextBox;
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
currentChannelContainer = new Container
|
currentChannelContainer = new Container<DrawableChannel>
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding
|
Padding = new MarginPadding
|
||||||
@ -138,7 +139,8 @@ namespace osu.Game.Overlays
|
|||||||
HoldFocus = true,
|
HoldFocus = true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
loading = new LoadingAnimation(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
@ -274,14 +276,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private void initializeChannels()
|
private void initializeChannels()
|
||||||
{
|
{
|
||||||
SpriteText loading;
|
loading.Show();
|
||||||
Add(loading = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = @"initialising chat...",
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
TextSize = 40,
|
|
||||||
});
|
|
||||||
|
|
||||||
messageRequest?.Cancel();
|
messageRequest?.Cancel();
|
||||||
|
|
||||||
@ -290,9 +285,6 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
Scheduler.Add(delegate
|
Scheduler.Add(delegate
|
||||||
{
|
{
|
||||||
loading.FadeOut(100);
|
|
||||||
loading.Expire();
|
|
||||||
|
|
||||||
addChannel(channels.Find(c => c.Name == @"#lazer"));
|
addChannel(channels.Find(c => c.Name == @"#lazer"));
|
||||||
addChannel(channels.Find(c => c.Name == @"#osu"));
|
addChannel(channels.Find(c => c.Name == @"#osu"));
|
||||||
addChannel(channels.Find(c => c.Name == @"#lobby"));
|
addChannel(channels.Find(c => c.Name == @"#lobby"));
|
||||||
@ -336,13 +328,17 @@ namespace osu.Game.Overlays
|
|||||||
if (loaded == null)
|
if (loaded == null)
|
||||||
{
|
{
|
||||||
currentChannelContainer.FadeOut(500, EasingTypes.OutQuint);
|
currentChannelContainer.FadeOut(500, EasingTypes.OutQuint);
|
||||||
|
loading.Show();
|
||||||
|
|
||||||
loaded = new DrawableChannel(currentChannel);
|
loaded = new DrawableChannel(currentChannel);
|
||||||
loadedChannels.Add(loaded);
|
loadedChannels.Add(loaded);
|
||||||
LoadComponentAsync(loaded, l =>
|
LoadComponentAsync(loaded, l =>
|
||||||
{
|
{
|
||||||
|
if (currentChannel.Messages.Any())
|
||||||
|
loading.Hide();
|
||||||
|
|
||||||
currentChannelContainer.Clear(false);
|
currentChannelContainer.Clear(false);
|
||||||
currentChannelContainer.Add(l);
|
currentChannelContainer.Add(loaded);
|
||||||
currentChannelContainer.FadeIn(500, EasingTypes.OutQuint);
|
currentChannelContainer.FadeIn(500, EasingTypes.OutQuint);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -386,6 +382,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
req.Success += delegate (List<Message> messages)
|
req.Success += delegate (List<Message> messages)
|
||||||
{
|
{
|
||||||
|
loading.Hide();
|
||||||
channel.AddNewMessages(messages.ToArray());
|
channel.AddNewMessages(messages.ToArray());
|
||||||
Debug.Write("success!");
|
Debug.Write("success!");
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Overlays
|
|||||||
State = Visibility.Visible;
|
State = Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDialogOnStateChanged(OverlayContainer dialog, Visibility v)
|
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
|
||||||
{
|
{
|
||||||
if (v != Visibility.Hidden) return;
|
if (v != Visibility.Hidden) return;
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ using OpenTK.Graphics;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Overlays.SearchableList;
|
using osu.Game.Overlays.SearchableList;
|
||||||
@ -29,6 +30,8 @@ namespace osu.Game.Overlays
|
|||||||
protected override SearchableListFilterControl<SocialSortCriteria, SortDirection> CreateFilterControl() => new FilterControl();
|
protected override SearchableListFilterControl<SocialSortCriteria, SortDirection> CreateFilterControl() => new FilterControl();
|
||||||
|
|
||||||
private IEnumerable<User> users;
|
private IEnumerable<User> users;
|
||||||
|
private readonly LoadingAnimation loading;
|
||||||
|
|
||||||
public IEnumerable<User> Users
|
public IEnumerable<User> Users
|
||||||
{
|
{
|
||||||
get { return users; }
|
get { return users; }
|
||||||
@ -68,6 +71,8 @@ namespace osu.Game.Overlays
|
|||||||
Spacing = new Vector2(10f),
|
Spacing = new Vector2(10f),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Add(loading = new LoadingAnimation());
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -83,8 +88,14 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
// no this is not the correct data source, but it's something.
|
// no this is not the correct data source, but it's something.
|
||||||
var request = new GetUsersRequest();
|
var request = new GetUsersRequest();
|
||||||
request.Success += res => Users = res.Select(e => e.User);
|
request.Success += res =>
|
||||||
|
{
|
||||||
|
Users = res.Select(e => e.User);
|
||||||
|
loading.Hide();
|
||||||
|
};
|
||||||
|
|
||||||
api.Queue(request);
|
api.Queue(request);
|
||||||
|
loading.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void APIStateChanged(APIAccess api, APIState state)
|
public void APIStateChanged(APIAccess api, APIState state)
|
||||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
stateContainer.StateChanged -= stateChanged;
|
stateContainer.StateChanged -= stateChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stateChanged(OverlayContainer c, Visibility state)
|
private void stateChanged(VisibilityContainer c, Visibility state)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
@ -80,8 +80,8 @@ namespace osu.Game.Screens.Select
|
|||||||
lookup.Success += res =>
|
lookup.Success += res =>
|
||||||
{
|
{
|
||||||
if (beatmap != requestedBeatmap)
|
if (beatmap != requestedBeatmap)
|
||||||
//the beatmap has been changed since we started the lookup.
|
//the beatmap has been changed since we started the lookup.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
requestedBeatmap.Metrics = res;
|
requestedBeatmap.Metrics = res;
|
||||||
Schedule(() => updateMetrics(res));
|
Schedule(() => updateMetrics(res));
|
||||||
@ -89,6 +89,7 @@ namespace osu.Game.Screens.Select
|
|||||||
lookup.Failure += e => updateMetrics(null);
|
lookup.Failure += e => updateMetrics(null);
|
||||||
|
|
||||||
api.Queue(lookup);
|
api.Queue(lookup);
|
||||||
|
loading.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMetrics(requestedBeatmap.Metrics, false);
|
updateMetrics(requestedBeatmap.Metrics, false);
|
||||||
@ -104,6 +105,9 @@ namespace osu.Game.Screens.Select
|
|||||||
var hasRatings = metrics?.Ratings.Any() ?? false;
|
var hasRatings = metrics?.Ratings.Any() ?? false;
|
||||||
var hasRetriesFails = (metrics?.Retries.Any() ?? false) && metrics.Fails.Any();
|
var hasRetriesFails = (metrics?.Retries.Any() ?? false) && metrics.Fails.Any();
|
||||||
|
|
||||||
|
if (failOnMissing)
|
||||||
|
loading.Hide();
|
||||||
|
|
||||||
if (hasRatings)
|
if (hasRatings)
|
||||||
{
|
{
|
||||||
var ratings = metrics.Ratings.ToList();
|
var ratings = metrics.Ratings.ToList();
|
||||||
@ -320,11 +324,13 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
loading = new LoadingAnimation()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private APIAccess api;
|
private APIAccess api;
|
||||||
|
private readonly LoadingAnimation loading;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colour, APIAccess api)
|
private void load(OsuColour colour, APIAccess api)
|
||||||
|
@ -12,6 +12,7 @@ using System;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
@ -25,6 +26,8 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
|
|
||||||
public Action<Score> ScoreSelected;
|
public Action<Score> ScoreSelected;
|
||||||
|
|
||||||
|
private LoadingAnimation loading;
|
||||||
|
|
||||||
private IEnumerable<Score> scores;
|
private IEnumerable<Score> scores;
|
||||||
public IEnumerable<Score> Scores
|
public IEnumerable<Score> Scores
|
||||||
{
|
{
|
||||||
@ -86,6 +89,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
loading = new LoadingAnimation()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +121,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GetScoresRequest getScoresRequest;
|
private GetScoresRequest getScoresRequest;
|
||||||
|
|
||||||
private void updateScores()
|
private void updateScores()
|
||||||
{
|
{
|
||||||
if (!IsLoaded) return;
|
if (!IsLoaded) return;
|
||||||
@ -126,8 +131,14 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
|
|
||||||
if (api == null || Beatmap == null) return;
|
if (api == null || Beatmap == null) return;
|
||||||
|
|
||||||
|
loading.Show();
|
||||||
|
|
||||||
getScoresRequest = new GetScoresRequest(Beatmap);
|
getScoresRequest = new GetScoresRequest(Beatmap);
|
||||||
getScoresRequest.Success += r => Scores = r.Scores;
|
getScoresRequest.Success += r =>
|
||||||
|
{
|
||||||
|
Scores = r.Scores;
|
||||||
|
loading.Hide();
|
||||||
|
};
|
||||||
api.Queue(getScoresRequest);
|
api.Queue(getScoresRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user