Move scene graph init to ctors.

This commit is contained in:
Dean Herbert
2017-02-12 19:39:54 +09:00
parent 5d4be35c5e
commit e32ccb6153
3 changed files with 22 additions and 27 deletions

View File

@ -53,8 +53,7 @@ namespace osu.Game.Overlays.Notifications
} }
} }
[BackgroundDependencyLoader] public Notification()
private void load(OsuColour colours)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;

View File

@ -16,27 +16,21 @@ namespace osu.Game.Overlays.Notifications
{ {
public class ProgressNotification : Notification, IHasCompletionTarget public class ProgressNotification : Notification, IHasCompletionTarget
{ {
private string text;
public string Text public string Text
{ {
get { return text; } get { return textDrawable.Text; }
set set
{ {
text = value; textDrawable.Text = value;
if (IsLoaded)
textDrawable.Text = text;
} }
} }
private float progress;
public float Progress public float Progress
{ {
get { return progress; } get { return progressBar.Progress; }
set set
{ {
progress = value; progressBar.Progress = value;
if (IsLoaded)
progressBar.Progress = progress;
} }
} }
@ -46,7 +40,6 @@ namespace osu.Game.Overlays.Notifications
//we may have received changes before we were displayed. //we may have received changes before we were displayed.
State = state; State = state;
Progress = progress;
} }
public virtual ProgressNotificationState State public virtual ProgressNotificationState State
@ -105,6 +98,7 @@ namespace osu.Game.Overlays.Notifications
protected virtual void Completed() protected virtual void Completed()
{ {
Expire();
CompletionTarget?.Invoke(CreateCompletionNotification()); CompletionTarget?.Invoke(CreateCompletionNotification());
} }
@ -117,13 +111,8 @@ namespace osu.Game.Overlays.Notifications
private SpriteText textDrawable; private SpriteText textDrawable;
[BackgroundDependencyLoader] public ProgressNotification()
private void load(OsuColour colours)
{ {
colourQueued = colours.YellowDark;
colourActive = colours.Blue;
colourCancelled = colours.Red;
IconContent.Add(new Box IconContent.Add(new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -135,7 +124,6 @@ namespace osu.Game.Overlays.Notifications
Colour = OsuColour.Gray(128), Colour = OsuColour.Gray(128),
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Text = text
}); });
NotificationContent.Add(progressBar = new ProgressBar NotificationContent.Add(progressBar = new ProgressBar
@ -148,6 +136,14 @@ namespace osu.Game.Overlays.Notifications
State = ProgressNotificationState.Queued; State = ProgressNotificationState.Queued;
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
colourQueued = colours.YellowDark;
colourActive = colours.Blue;
colourCancelled = colours.Red;
}
public override void Close() public override void Close()
{ {
switch (State) switch (State)

View File

@ -18,7 +18,6 @@ namespace osu.Game.Overlays.Notifications
set set
{ {
text = value; text = value;
if (IsLoaded)
textDrawable.Text = text; textDrawable.Text = text;
} }
} }
@ -30,17 +29,14 @@ namespace osu.Game.Overlays.Notifications
set set
{ {
icon = value; icon = value;
if (IsLoaded)
iconDrawable.Icon = icon; iconDrawable.Icon = icon;
} }
} }
private SpriteText textDrawable; private SpriteText textDrawable;
private TextAwesome iconDrawable; private TextAwesome iconDrawable;
[BackgroundDependencyLoader] public SimpleNotification()
private void load(OsuColour colours)
{ {
IconContent.Add(new Drawable[] IconContent.Add(new Drawable[]
{ {
@ -64,7 +60,11 @@ namespace osu.Game.Overlays.Notifications
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Text = text Text = text
}); });
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Light.Colour = colours.Green; Light.Colour = colours.Green;
} }