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]
private void load(OsuColour colours)
public Notification()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;

View File

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

View File

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