1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 12:47:25 +08:00

Merge pull request #166 from Tom94/various-improvements

Various improvements
This commit is contained in:
Dean Herbert 2016-11-14 15:59:17 +09:00 committed by GitHub
commit c37afd7a81
23 changed files with 167 additions and 197 deletions

@ -1 +1 @@
Subproject commit 5c0e4edbbcdc26ab56c70676856477cd21e7afdc
Subproject commit 1cb936a4fe9e699ee37deb34eed0b04bc06167e3

View File

@ -21,8 +21,7 @@ namespace osu.Desktop.VisualTests.Tests
protected override IFrameBasedClock Clock => ourClock;
[BackgroundDependencyLoader]
private void load()
public TestCaseHitObjects()
{
var swClock = new StopwatchClock(true) { Rate = 1 };
ourClock = new FramedClock(swClock);

View File

@ -25,8 +25,7 @@ namespace osu.Desktop.Tests
protected MusicController mc;
[BackgroundDependencyLoader]
private void load()
public TestCaseMusicController()
{
ourClock = new FramedClock();
}

View File

@ -19,9 +19,12 @@ namespace osu.Desktop.VisualTests
{
class VisualTestGame : OsuGameBase
{
[BackgroundDependencyLoader]
private void load()
protected override void LoadComplete()
{
base.LoadComplete();
// Have to construct this here, rather than in the constructor, because
// we depend on some dependencies to be loaded within OsuGameBase.load().
Add(new TestBrowser());
}
}

View File

@ -43,13 +43,18 @@ namespace osu.Game.GameModes
public override bool Push(GameMode mode)
{
//don't actually push until we've finished loading.
if (!mode.IsLoaded)
// When trying to push a non-loaded GameMode, load it asynchronously and re-invoke Push
// once it's done.
if (mode.LoadState == LoadState.NotLoaded)
{
mode.Preload(game, d => Push((BackgroundMode)d));
return true;
}
// Make sure the in-progress loading is complete before pushing the GameMode.
while (mode.LoadState < LoadState.Loaded)
Thread.Sleep(1);
base.Push(mode);
return true;

View File

@ -1,8 +1,6 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework;
using osu.Framework.Allocation;
using osu.Game.Graphics.Background;
namespace osu.Game.GameModes.Backgrounds
@ -14,11 +12,6 @@ namespace osu.Game.GameModes.Backgrounds
public BackgroundModeCustom(string textureName)
{
this.textureName = textureName;
}
[BackgroundDependencyLoader]
private void load()
{
Add(new Background(textureName));
}

View File

@ -78,65 +78,64 @@ namespace osu.Game.GameModes
Content.FadeIn(transition_time, EasingTypes.OutExpo);
}
[BackgroundDependencyLoader]
private void load()
public GameModeWhiteBox()
{
Children = new Drawable[]
{
box = new Box
box = new Box
{
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.3f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = getColourFor(GetType()),
Alpha = 1,
BlendingMode = BlendingMode.Additive,
},
textContainer = new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new[]
{
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.3f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = getColourFor(GetType()),
Alpha = 1,
BlendingMode = BlendingMode.Additive,
},
textContainer = new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new[]
new SpriteText
{
new SpriteText
{
Text = GetType().Name,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = 50,
},
new SpriteText
{
Text = GetType().Namespace,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Position = new Vector2(0, 30)
},
}
},
popButton = new Button
{
Text = @"Back",
RelativeSizeAxes = Axes.X,
Size = new Vector2(0.1f, 40),
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Colour = new Color4(235, 51, 153, 255),
Alpha = 0,
Action = delegate {
Exit();
}
},
childModeButtons = new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.1f, 1)
Text = GetType().Name,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = 50,
},
new SpriteText
{
Text = GetType().Namespace,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Position = new Vector2(0, 30)
},
}
},
popButton = new Button
{
Text = @"Back",
RelativeSizeAxes = Axes.X,
Size = new Vector2(0.1f, 40),
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Colour = new Color4(235, 51, 153, 255),
Alpha = 0,
Action = delegate {
Exit();
}
},
childModeButtons = new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.1f, 1)
}
};
if (PossibleChildren != null)

View File

@ -47,53 +47,48 @@ namespace osu.Game.GameModes.Menu
this.text = text;
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
Alpha = 0;
Vector2 boxSize = new Vector2(ButtonSystem.button_width + Math.Abs(extraWidth), ButtonSystem.button_area_height);
Children = new Drawable[]
{
box = new Box
box = new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = colour,
Scale = new Vector2(0, 1),
Size = boxSize,
Shear = new Vector2(ButtonSystem.wedge_width / boxSize.Y, 0),
EdgeSmoothness = new Vector2(2, 0),
},
iconText = new Container
{
AutoSizeAxes = Axes.Both,
Position = new Vector2(extraWidth / 2, 0),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = colour,
Scale = new Vector2(0, 1),
Size = boxSize,
Shear = new Vector2(ButtonSystem.wedge_width / boxSize.Y, 0),
EdgeSmoothness = new Vector2(2, 0),
},
iconText = new Container
{
AutoSizeAxes = Axes.Both,
Position = new Vector2(extraWidth / 2, 0),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
icon = new TextAwesome
{
icon = new TextAwesome
{
Anchor = Anchor.Centre,
TextSize = 30,
Position = new Vector2(0, 0),
Icon = symbol
},
new SpriteText
{
Direction = FlowDirection.HorizontalOnly,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = 16,
Position = new Vector2(0, 35),
Text = text
}
Anchor = Anchor.Centre,
TextSize = 30,
Position = new Vector2(0, 0),
Icon = symbol
},
new SpriteText
{
Direction = FlowDirection.HorizontalOnly,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
TextSize = 16,
Position = new Vector2(0, 35),
Text = text
}
}
}
};
}

View File

@ -52,11 +52,7 @@ namespace osu.Game.GameModes.Menu
public ButtonSystem()
{
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
Children = new Drawable[]
{
buttonArea = new Container
@ -105,13 +101,13 @@ namespace osu.Game.GameModes.Menu
buttonFlow.Position = new Vector2(wedge_width * 2 - (button_width + osuLogo.SizeForFlow / 4), 0);
buttonsPlay.Add(new Button(@"solo", @"freeplay", FontAwesome.fa_user, new Color4(102, 68, 204, 255), OnSolo, wedge_width, Key.P));
buttonsPlay.Add(new Button(@"multi", @"multiplayer", FontAwesome.fa_users, new Color4(94, 63, 186, 255), OnMulti, 0, Key.M));
buttonsPlay.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), OnChart));
buttonsPlay.Add(new Button(@"solo", @"freeplay", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), wedge_width, Key.P));
buttonsPlay.Add(new Button(@"multi", @"multiplayer", FontAwesome.fa_users, new Color4(94, 63, 186, 255), () => OnMulti?.Invoke(), 0, Key.M));
buttonsPlay.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke()));
buttonsTopLevel.Add(new Button(@"play", @"play", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), onPlay, wedge_width, Key.P));
buttonsTopLevel.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), OnEdit, 0, Key.E));
buttonsTopLevel.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), OnDirect, 0, Key.D));
buttonsTopLevel.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E));
buttonsTopLevel.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), () => OnDirect?.Invoke(), 0, Key.D));
buttonsTopLevel.Add(new Button(@"exit", @"exit", FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q));
buttonFlow.Add(buttonsPlay);

View File

@ -19,11 +19,7 @@ namespace osu.Game.GameModes.Play.Catch
Size = new Vector2(512, 0.9f);
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
}
[BackgroundDependencyLoader]
private void load()
{
Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f });
}
}

View File

@ -119,11 +119,7 @@ namespace osu.Game.GameModes.Play
};
TextSize = 80;
}
[BackgroundDependencyLoader]
private void load()
{
DisplayedCountSpriteText.Text = FormatCount(Count);
DisplayedCountSpriteText.Anchor = Anchor;
DisplayedCountSpriteText.Origin = Origin;

View File

@ -43,11 +43,14 @@ namespace osu.Game.GameModes.Play
protected virtual List<T> Convert(List<HitObject> objects) => Converter.Convert(objects);
public HitRenderer()
{
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
Playfield = CreatePlayfield()

View File

@ -2,12 +2,9 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Allocation;
namespace osu.Game.GameModes.Play.Mania
{
@ -22,11 +19,7 @@ namespace osu.Game.GameModes.Play.Mania
Size = new Vector2(columns / 20f, 1f);
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
}
[BackgroundDependencyLoader]
private void load()
{
Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f });
for (int i = 0; i < columns; i++)

View File

@ -33,9 +33,8 @@ namespace osu.Game.GameModes.Play.Osu
DisplayedCountSpriteText.Position = value;
}
}
[BackgroundDependencyLoader]
private void load()
public OsuComboCounter()
{
PopOutSpriteText.Origin = Origin;
PopOutSpriteText.Anchor = Anchor;

View File

@ -26,18 +26,19 @@ namespace osu.Game.Graphics.Background
this.textureName = textureName;
RelativeSizeAxes = Axes.Both;
Depth = float.MinValue;
Add(BackgroundSprite = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.DarkGray
});
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Add(BackgroundSprite = new Sprite
{
Texture = textures.Get(textureName),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.DarkGray
});
BackgroundSprite.Texture = textures.Get(textureName);
}
protected override void Update()

View File

@ -118,11 +118,7 @@ namespace osu.Game.Graphics.UserInterface
TextSize = 40;
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
DisplayedCount = Count;
DisplayedCountSpriteText.Text = FormatCount(count);

View File

@ -108,11 +108,7 @@ namespace osu.Game.Graphics.UserInterface
Origin = Anchor.CentreLeft,
}
};
}
[BackgroundDependencyLoader]
private void load()
{
starContainer.Width = MaxStars * StarSize + Math.Max(MaxStars - 1, 0) * StarSpacing;
starContainer.Height = StarSize;

View File

@ -18,6 +18,9 @@ namespace osu.Game.Graphics.UserInterface.Volume
private VolumeMeter volumeMeterMaster;
private FlowContainer content;
protected override Container<Drawable> Content => content;
public override bool Contains(Vector2 screenSpacePos) => true;
private void volumeChanged(object sender, EventArgs e)
@ -31,32 +34,31 @@ namespace osu.Game.Graphics.UserInterface.Volume
AutoSizeAxes = Axes.Both;
Anchor = Anchor.BottomRight;
Origin = Anchor.BottomRight;
AddInternal(content = new FlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Position = new Vector2(10, 30),
Spacing = new Vector2(15, 0),
});
}
[BackgroundDependencyLoader]
private void load()
protected override void LoadComplete()
{
base.LoadComplete();
VolumeGlobal.ValueChanged += volumeChanged;
VolumeSample.ValueChanged += volumeChanged;
VolumeTrack.ValueChanged += volumeChanged;
Children = new Drawable[]
Add(new[]
{
new FlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Position = new Vector2(10, 30),
Spacing = new Vector2(15,0),
Children = new Drawable[]
{
volumeMeterMaster = new VolumeMeter("Master", VolumeGlobal),
new VolumeMeter("Effects", VolumeSample),
new VolumeMeter("Music", VolumeTrack)
}
}
};
volumeMeterMaster = new VolumeMeter("Master", VolumeGlobal),
new VolumeMeter("Effects", VolumeSample),
new VolumeMeter("Music", VolumeTrack)
});
}
protected override void Dispose(bool isDisposing)

View File

@ -20,17 +20,13 @@ namespace osu.Game.Online.Chat.Display
{
public readonly Message Message;
public ChatLine(Message message)
{
this.Message = message;
}
const float padding = 200;
const float text_size = 20;
[BackgroundDependencyLoader]
private void load()
public ChatLine(Message message)
{
this.Message = message;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;

View File

@ -80,8 +80,12 @@ namespace osu.Game
Audio.VolumeTrack.Weld(Config.GetBindable<double>(OsuConfig.VolumeMusic));
PlayMode = Config.GetBindable<PlayMode>(OsuConfig.PlayMode);
}
protected override void LoadComplete()
{
base.LoadComplete();
//todo: move to constructor or LoadComplete.
Add(new Drawable[] {
new VolumeControlReceptor
{

View File

@ -37,10 +37,6 @@ namespace osu.Game
public readonly Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
private void Beatmap_ValueChanged(object sender, EventArgs e)
{
}
[BackgroundDependencyLoader]
private void load()
{
@ -65,15 +61,6 @@ namespace osu.Game
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic"));
AddInternal(ratioContainer = new RatioAdjust());
Children = new Drawable[]
{
Cursor = new OsuCursorContainer { Depth = float.MaxValue }
};
Beatmap.ValueChanged += Beatmap_ValueChanged;
OszArchiveReader.Register();
@ -85,6 +72,19 @@ namespace osu.Game
});
}
protected override void LoadComplete()
{
base.LoadComplete();
AddInternal(ratioContainer = new RatioAdjust
{
Children = new[]
{
Cursor = new OsuCursorContainer { Depth = float.MaxValue }
}
});
}
public override void SetHost(BasicGameHost host)
{
if (Config == null)

View File

@ -44,9 +44,9 @@ namespace osu.Game.Overlays
}
}
[BackgroundDependencyLoader]
private void load()
protected override void LoadComplete()
{
base.LoadComplete();
DrawableIcon.TextSize *= 1.4f;
}
}

View File

@ -29,11 +29,7 @@ namespace osu.Game.Overlays
public ToolbarModeSelector()
{
RelativeSizeAxes = Axes.Y;
}
[BackgroundDependencyLoader]
private void load()
{
Children = new Drawable[]
{
new Box
@ -59,8 +55,11 @@ namespace osu.Game.Overlays
}
};
int amountButtons = 0;
foreach (PlayMode m in Enum.GetValues(typeof(PlayMode)))
{
++amountButtons;
var localMode = m;
modeButtons.Add(new ToolbarModeButton
{
@ -73,8 +72,8 @@ namespace osu.Game.Overlays
});
}
RelativeSizeAxes = Axes.Y;
Size = new Vector2(modeButtons.Children.Count() * ToolbarButton.WIDTH + padding * 2, 1);
// We need to set the size within LoadComplete, because
Size = new Vector2(amountButtons * ToolbarButton.WIDTH + padding * 2, 1);
}
public void SetGameMode(PlayMode mode)