From eb0f0aefba7bdd76a66ed5c25c50c3f1d8622f48 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jun 2019 17:04:57 +0900 Subject: [PATCH] Apply review changes --- .../Components/ControlPanel.cs | 4 ---- osu.Game.Tournament/Components/DateTextBox.cs | 3 ++- .../Components/MatchChatDisplay.cs | 4 ++-- osu.Game.Tournament/Components/SongBar.cs | 15 ++++++------- .../Components/TournamentBeatmapPanel.cs | 6 ++---- .../Ladder/Components/DrawableMatchTeam.cs | 5 ++--- .../Components/TournamentProgression.cs | 21 ++++++++++++++----- .../Screens/Ladder/LadderEditorScreen.cs | 10 ++++----- .../Screens/Ladder/LadderScreen.cs | 4 +++- osu.Game.Tournament/TournamentGameBase.cs | 4 ++-- 10 files changed, 42 insertions(+), 34 deletions(-) diff --git a/osu.Game.Tournament/Components/ControlPanel.cs b/osu.Game.Tournament/Components/ControlPanel.cs index 0d228fb3b4..a9bb1bf42f 100644 --- a/osu.Game.Tournament/Components/ControlPanel.cs +++ b/osu.Game.Tournament/Components/ControlPanel.cs @@ -39,7 +39,6 @@ namespace osu.Game.Tournament.Components { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Text = "Control Panel", Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 22) }, @@ -47,13 +46,10 @@ namespace osu.Game.Tournament.Components { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Width = 0.75f, - Position = new Vector2(0, 35f), - Direction = FillDirection.Vertical, Spacing = new Vector2(0, 5f), }, diff --git a/osu.Game.Tournament/Components/DateTextBox.cs b/osu.Game.Tournament/Components/DateTextBox.cs index f25c4b6e78..ee7e350970 100644 --- a/osu.Game.Tournament/Components/DateTextBox.cs +++ b/osu.Game.Tournament/Components/DateTextBox.cs @@ -15,7 +15,7 @@ namespace osu.Game.Tournament.Components get => bindable; set { - bindable = value; + bindable = value.GetBoundCopy(); bindable.BindValueChanged(dto => base.Bindable.Value = dto.NewValue.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"), true); } @@ -35,6 +35,7 @@ namespace osu.Game.Tournament.Components } catch { + // reset textbox content to its last valid state on a parse failure. bindable.TriggerChange(); } }; diff --git a/osu.Game.Tournament/Components/MatchChatDisplay.cs b/osu.Game.Tournament/Components/MatchChatDisplay.cs index dd567ed290..174b215732 100644 --- a/osu.Game.Tournament/Components/MatchChatDisplay.cs +++ b/osu.Game.Tournament/Components/MatchChatDisplay.cs @@ -15,8 +15,6 @@ namespace osu.Game.Tournament.Components { private readonly Bindable chatChannel = new Bindable(); - protected override ChatLine CreateMessage(Message message) => new MatchMessage(message); - private ChannelManager manager; [BackgroundDependencyLoader(true)] @@ -55,6 +53,8 @@ namespace osu.Game.Tournament.Components } } + protected override ChatLine CreateMessage(Message message) => new MatchMessage(message); + protected class MatchMessage : StandAloneMessage { public MatchMessage(Message message) diff --git a/osu.Game.Tournament/Components/SongBar.cs b/osu.Game.Tournament/Components/SongBar.cs index a08333571b..c07882ddd0 100644 --- a/osu.Game.Tournament/Components/SongBar.cs +++ b/osu.Game.Tournament/Components/SongBar.cs @@ -228,21 +228,22 @@ namespace osu.Game.Tournament.Components s.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 15); } - bool first = true; - - foreach (var t in tuples) + for (var i = 0; i < tuples.Length; i++) { - if (!first) + var tuple = tuples[i]; + + if (i > 0) + { AddText(" / ", s => { cp(s, OsuColour.Gray(0.33f)); s.Spacing = new Vector2(-2, 0); }); + } - AddText(new OsuSpriteText { Text = t.heading }, s => cp(s, OsuColour.Gray(0.33f))); + AddText(new OsuSpriteText { Text = tuple.heading }, s => cp(s, OsuColour.Gray(0.33f))); AddText(" ", s => cp(s, OsuColour.Gray(0.33f))); - AddText(new OsuSpriteText { Text = t.content }, s => cp(s, OsuColour.Gray(0.5f))); - first = false; + AddText(new OsuSpriteText { Text = tuple.content }, s => cp(s, OsuColour.Gray(0.5f))); } } } diff --git a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs index 818d25d559..cf826ee2c7 100644 --- a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs +++ b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs @@ -11,9 +11,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Framework.IO.Stores; using osu.Framework.Localisation; -using osu.Framework.Platform; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; @@ -48,7 +46,7 @@ namespace osu.Game.Tournament.Components } [BackgroundDependencyLoader] - private void load(LadderInfo ladder, Storage storage) + private void load(LadderInfo ladder, TextureStore textures) { currentMatch.BindValueChanged(matchChanged); currentMatch.BindTo(ladder.CurrentMatch); @@ -135,7 +133,7 @@ namespace osu.Game.Tournament.Components if (!string.IsNullOrEmpty(mods)) AddInternal(new Sprite { - Texture = new LargeTextureStore(new TextureLoaderStore(new StorageBackedResourceStore(storage))).Get($"mods/{mods}"), + Texture = textures.Get($"mods/{mods}"), Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, Margin = new MarginPadding(20), diff --git a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs index 35b6dfb606..6d5ac74267 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs @@ -138,7 +138,6 @@ namespace osu.Game.Tournament.Screens.Ladder.Components }, true); } - //TODO: use OnClick instead once we have per-button clicks. protected override bool OnClick(ClickEvent e) { if (Team == null || editorInfo != null) return false; @@ -196,8 +195,8 @@ namespace osu.Game.Tournament.Screens.Ladder.Components return new MenuItem[] { new OsuMenuItem("Set as current", MenuItemType.Standard, setCurrent), - new OsuMenuItem("Join with", MenuItemType.Standard, () => ladderEditor.RequestJoin(pairing, false)), - new OsuMenuItem("Join with (loser)", MenuItemType.Standard, () => ladderEditor.RequestJoin(pairing, true)), + new OsuMenuItem("Join with", MenuItemType.Standard, () => ladderEditor.BeginJoin(pairing, false)), + new OsuMenuItem("Join with (loser)", MenuItemType.Standard, () => ladderEditor.BeginJoin(pairing, true)), new OsuMenuItem("Remove", MenuItemType.Destructive, () => ladderEditor.Remove(pairing)), }; } diff --git a/osu.Game.Tournament/Screens/Ladder/Components/TournamentProgression.cs b/osu.Game.Tournament/Screens/Ladder/Components/TournamentProgression.cs index 241e1d1d0b..0019dc8d79 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/TournamentProgression.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/TournamentProgression.cs @@ -5,15 +5,26 @@ namespace osu.Game.Tournament.Screens.Ladder.Components { public class TournamentProgression { - public int Item1; - public int Item2; + public int SourceID; + public int TargetID; + + // migration + public int Item1 + { + set => SourceID = value; + } + + public int Item2 + { + set => TargetID = value; + } public bool Losers; - public TournamentProgression(int item1, int item2, bool losers = false) + public TournamentProgression(int sourceID, int targetID, bool losers = false) { - Item1 = item1; - Item2 = item2; + SourceID = sourceID; + TargetID = targetID; Losers = losers; } } diff --git a/osu.Game.Tournament/Screens/Ladder/LadderEditorScreen.cs b/osu.Game.Tournament/Screens/Ladder/LadderEditorScreen.cs index e605de9a7c..4a35f1ad30 100644 --- a/osu.Game.Tournament/Screens/Ladder/LadderEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Ladder/LadderEditorScreen.cs @@ -27,7 +27,7 @@ namespace osu.Game.Tournament.Screens.Ladder [BackgroundDependencyLoader] private void load() { - ((Container)InternalChild).Add(new LadderEditorSettings + Content.Add(new LadderEditorSettings { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -58,9 +58,9 @@ namespace osu.Game.Tournament.Screens.Ladder updateInfo(); } - public void RequestJoin(MatchPairing pairing, bool losers) + public void BeginJoin(MatchPairing pairing, bool losers) { - ScrollContent.Add(new JoinRequestHandler(PairingsContainer, pairing, losers, updateInfo)); + ScrollContent.Add(new JoinVisualiser(PairingsContainer, pairing, losers, updateInfo)); } public MenuItem[] ContextMenuItems @@ -91,7 +91,7 @@ namespace osu.Game.Tournament.Screens.Ladder PairingsContainer.FirstOrDefault(p => p.Pairing == pairing)?.Remove(); } - private class JoinRequestHandler : CompositeDrawable + private class JoinVisualiser : CompositeDrawable { private readonly Container pairingsContainer; public readonly MatchPairing Source; @@ -100,7 +100,7 @@ namespace osu.Game.Tournament.Screens.Ladder private ProgressionPath path; - public JoinRequestHandler(Container pairingsContainer, MatchPairing source, bool losers, Action complete) + public JoinVisualiser(Container pairingsContainer, MatchPairing source, bool losers, Action complete) { this.pairingsContainer = pairingsContainer; RelativeSizeAxes = Axes.Both; diff --git a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs index e54bcffe2e..f2d4ebbb71 100644 --- a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs +++ b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs @@ -24,6 +24,8 @@ namespace osu.Game.Tournament.Screens.Ladder protected LadderDragContainer ScrollContent; + protected Container Content; + [BackgroundDependencyLoader] private void load(OsuColour colours, Storage storage) { @@ -32,7 +34,7 @@ namespace osu.Game.Tournament.Screens.Ladder RelativeSizeAxes = Axes.Both; - InternalChild = new Container + InternalChild = Content = new Container { RelativeSizeAxes = Axes.Both, Children = new Drawable[] diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs index 4f54da2723..739fabca9d 100644 --- a/osu.Game.Tournament/TournamentGameBase.cs +++ b/osu.Game.Tournament/TournamentGameBase.cs @@ -110,8 +110,8 @@ namespace osu.Game.Tournament // assign progressions foreach (var pair in ladder.Progressions) { - var src = ladder.Pairings.FirstOrDefault(p => p.ID == pair.Item1); - var dest = ladder.Pairings.FirstOrDefault(p => p.ID == pair.Item2); + var src = ladder.Pairings.FirstOrDefault(p => p.ID == pair.SourceID); + var dest = ladder.Pairings.FirstOrDefault(p => p.ID == pair.TargetID); if (src == null) throw new InvalidOperationException();