mirror of
https://github.com/ppy/osu.git
synced 2025-02-06 04:53:06 +08:00
Make ProgressNotification's status and progress thread-safe
Quite regularly a task will hold a reference to a progress notification and udpate it as progress is made. Therefore these operations should be thread-safe.
This commit is contained in:
parent
120d3fbbec
commit
518e5a2245
@ -25,10 +25,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
public float Progress
|
public float Progress
|
||||||
{
|
{
|
||||||
get { return progressBar.Progress; }
|
get { return progressBar.Progress; }
|
||||||
set
|
set { Schedule(() => progressBar.Progress = value); }
|
||||||
{
|
|
||||||
progressBar.Progress = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -44,41 +41,44 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
get { return state; }
|
get { return state; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
bool stateChanged = state != value;
|
Schedule(() =>
|
||||||
state = value;
|
|
||||||
|
|
||||||
if (IsLoaded)
|
|
||||||
{
|
{
|
||||||
switch (state)
|
bool stateChanged = state != value;
|
||||||
{
|
state = value;
|
||||||
case ProgressNotificationState.Queued:
|
|
||||||
Light.Colour = colourQueued;
|
|
||||||
Light.Pulsate = false;
|
|
||||||
progressBar.Active = false;
|
|
||||||
break;
|
|
||||||
case ProgressNotificationState.Active:
|
|
||||||
Light.Colour = colourActive;
|
|
||||||
Light.Pulsate = true;
|
|
||||||
progressBar.Active = true;
|
|
||||||
break;
|
|
||||||
case ProgressNotificationState.Cancelled:
|
|
||||||
Light.Colour = colourCancelled;
|
|
||||||
Light.Pulsate = false;
|
|
||||||
progressBar.Active = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stateChanged)
|
if (IsLoaded)
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
{
|
||||||
case ProgressNotificationState.Completed:
|
switch (state)
|
||||||
NotificationContent.MoveToY(-DrawSize.Y / 2, 200, Easing.OutQuint);
|
{
|
||||||
this.FadeOut(200).Finally(d => Completed());
|
case ProgressNotificationState.Queued:
|
||||||
break;
|
Light.Colour = colourQueued;
|
||||||
|
Light.Pulsate = false;
|
||||||
|
progressBar.Active = false;
|
||||||
|
break;
|
||||||
|
case ProgressNotificationState.Active:
|
||||||
|
Light.Colour = colourActive;
|
||||||
|
Light.Pulsate = true;
|
||||||
|
progressBar.Active = true;
|
||||||
|
break;
|
||||||
|
case ProgressNotificationState.Cancelled:
|
||||||
|
Light.Colour = colourCancelled;
|
||||||
|
Light.Pulsate = false;
|
||||||
|
progressBar.Active = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (stateChanged)
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case ProgressNotificationState.Completed:
|
||||||
|
NotificationContent.MoveToY(-DrawSize.Y / 2, 200, Easing.OutQuint);
|
||||||
|
this.FadeOut(200).Finally(d => Completed());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user