From 6dffa948d449872b7810684b4686e1aa127c3a08 Mon Sep 17 00:00:00 2001 From: CloneWith Date: Sat, 28 Sep 2024 23:43:37 +0800 Subject: [PATCH 1/4] Hide restore button for Seeding dropdown --- osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs b/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs index 899d462e4e..777909f3ac 100644 --- a/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs +++ b/osu.Game.Tournament/Screens/TeamIntro/SeedingScreen.cs @@ -63,6 +63,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro { LabelText = "Show specific team", Current = currentTeam, + ShowsDefaultIndicator = false, } } } From c07e7da40f96406fa42e877c5300ab8d6e9de412 Mon Sep 17 00:00:00 2001 From: CloneWith Date: Wed, 2 Oct 2024 12:07:24 +0800 Subject: [PATCH 2/4] Add default value for input boxes in tournament editor screens --- .../Screens/Editors/RoundEditorScreen.cs | 10 ++++++++-- .../Screens/Editors/SeedingEditorScreen.cs | 2 +- .../Screens/Editors/TeamEditorScreen.cs | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs index 253cca8c98..8e3b28eebe 100644 --- a/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs @@ -38,6 +38,12 @@ namespace osu.Game.Tournament.Screens.Editors { Model = round; + Model.Name.Default = Model.Name.Value; + Model.Description.Default = Model.Description.Value; + Model.StartDate.Default = Model.StartDate.Value; + Model.BanCount.Default = Model.BanCount.Value; + Model.BestOf.Default = Model.BestOf.Value; + Masking = true; CornerRadius = 10; @@ -232,7 +238,7 @@ namespace osu.Game.Tournament.Screens.Editors [BackgroundDependencyLoader] private void load() { - beatmapId.Value = Model.ID; + beatmapId.Default = beatmapId.Value = Model.ID; beatmapId.BindValueChanged(id => { Model.ID = id.NewValue ?? 0; @@ -263,7 +269,7 @@ namespace osu.Game.Tournament.Screens.Editors API.Queue(req); }, true); - mods.Value = Model.Mods; + mods.Default = mods.Value = Model.Mods; mods.BindValueChanged(modString => Model.Mods = modString.NewValue); } diff --git a/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs index 9927dd56a0..b2a5643b7e 100644 --- a/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs @@ -221,7 +221,7 @@ namespace osu.Game.Tournament.Screens.Editors [BackgroundDependencyLoader] private void load() { - beatmapId.Value = Model.ID; + beatmapId.Default = beatmapId.Value = Model.ID; beatmapId.BindValueChanged(id => { Model.ID = id.NewValue ?? 0; diff --git a/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs index 250d5acaae..65fcdd3f75 100644 --- a/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs @@ -283,7 +283,7 @@ namespace osu.Game.Tournament.Screens.Editors [BackgroundDependencyLoader] private void load() { - playerId.Value = user.OnlineID; + playerId.Default = playerId.Value = user.OnlineID; playerId.BindValueChanged(id => { user.OnlineID = id.NewValue ?? 0; From 5c7ceedd06675bc2ba13adc231284d456903399b Mon Sep 17 00:00:00 2001 From: CloneWith Date: Sat, 5 Oct 2024 16:07:02 +0800 Subject: [PATCH 3/4] Update default values on tournament saving --- .../Screens/Editors/RoundEditorScreen.cs | 30 +++++++++++++++++ .../Screens/Editors/TeamEditorScreen.cs | 32 +++++++++++++++++++ osu.Game.Tournament/TournamentGameBase.cs | 5 +++ 3 files changed, 67 insertions(+) diff --git a/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs index 8e3b28eebe..d733a2a8ab 100644 --- a/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs @@ -26,6 +26,9 @@ namespace osu.Game.Tournament.Screens.Editors public partial class RoundRow : CompositeDrawable, IModelBacked { + [Resolved] + private TournamentGameBase? game { get; set; } + public TournamentRound Model { get; } [Resolved] @@ -128,6 +131,22 @@ namespace osu.Game.Tournament.Screens.Editors AutoSizeAxes = Axes.Y; } + [BackgroundDependencyLoader] + private void load() + { + // TournamentGameBase won't be loaded so early, probably binding the event here + game?.IsSaveTriggered.BindValueChanged(state => + { + if (!state.NewValue) return; + + Model.Name.Default = Model.Name.Value; + Model.Description.Default = Model.Description.Value; + Model.StartDate.Default = Model.StartDate.Value; + Model.BanCount.Default = Model.BanCount.Value; + Model.BestOf.Default = Model.BestOf.Value; + }); + } + public partial class RoundBeatmapEditor : CompositeDrawable { private readonly TournamentRound round; @@ -160,6 +179,9 @@ namespace osu.Game.Tournament.Screens.Editors public partial class RoundBeatmapRow : CompositeDrawable { + [Resolved] + private TournamentGameBase? game { get; set; } + public RoundBeatmap Model { get; } [Resolved] @@ -271,6 +293,14 @@ namespace osu.Game.Tournament.Screens.Editors mods.Default = mods.Value = Model.Mods; mods.BindValueChanged(modString => Model.Mods = modString.NewValue); + + game?.IsSaveTriggered.BindValueChanged(state => + { + if (!state.NewValue) return; + + beatmapId.Default = beatmapId.Value; + mods.Default = mods.Value; + }); } private void updatePanel() => Schedule(() => diff --git a/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs index 65fcdd3f75..8686d624fc 100644 --- a/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs @@ -71,10 +71,19 @@ namespace osu.Game.Tournament.Screens.Editors [Resolved] private LadderInfo ladderInfo { get; set; } = null!; + [Resolved] + private TournamentGameBase? game { get; set; } + public TeamRow(TournamentTeam team, TournamentScreen parent) { Model = team; + Model.FullName.Default = Model.FullName.Value; + Model.Acronym.Default = Model.Acronym.Value; + Model.FlagName.Default = Model.FlagName.Value; + Model.LastYearPlacing.Default = Model.LastYearPlacing.Value; + Model.Seed.Default = Model.Seed.Value; + Masking = true; CornerRadius = 10; @@ -177,6 +186,22 @@ namespace osu.Game.Tournament.Screens.Editors }; } + [BackgroundDependencyLoader] + private void load() + { + // TournamentGameBase won't be loaded so early, probably binding the event here + game?.IsSaveTriggered.BindValueChanged(state => + { + if (!state.NewValue) return; + + Model.FullName.Default = Model.FullName.Value; + Model.Acronym.Default = Model.Acronym.Value; + Model.FlagName.Default = Model.FlagName.Value; + Model.LastYearPlacing.Default = Model.LastYearPlacing.Value; + Model.Seed.Default = Model.Seed.Value; + }); + } + private partial class LastYearPlacementSlider : RoundedSliderBar { public override LocalisableString TooltipText => Current.Value == 0 ? "N/A" : base.TooltipText; @@ -299,6 +324,13 @@ namespace osu.Game.Tournament.Screens.Editors game.PopulatePlayer(user, updatePanel, updatePanel); }, true); + + game.IsSaveTriggered.BindValueChanged(state => + { + if (!state.NewValue) return; + + playerId.Default = playerId.Value; + }); } private void updatePanel() => Scheduler.AddOnce(() => diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs index eecd097a97..4fe4bef116 100644 --- a/osu.Game.Tournament/TournamentGameBase.cs +++ b/osu.Game.Tournament/TournamentGameBase.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; @@ -36,6 +37,8 @@ namespace osu.Game.Tournament private FileBasedIPC ipc = null!; private BeatmapLookupCache beatmapCache = null!; + public BindableBool IsSaveTriggered = new BindableBool(false); + protected Task BracketLoadTask => bracketLoadTaskCompletionSource.Task; private readonly TaskCompletionSource bracketLoadTaskCompletionSource = new TaskCompletionSource(); @@ -329,7 +332,9 @@ namespace osu.Game.Tournament return; } + IsSaveTriggered.Value = true; saveChanges(); + IsSaveTriggered.Value = false; } private void saveChanges() From 2787d7416933aefaa7fccdbdf52132a74976028e Mon Sep 17 00:00:00 2001 From: CloneWith Date: Sat, 5 Oct 2024 16:07:45 +0800 Subject: [PATCH 4/4] Add missing revert default value handling for SeedingEditorScreen --- .../Screens/Editors/SeedingEditorScreen.cs | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs index b2a5643b7e..7c2d9d446b 100644 --- a/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs @@ -34,10 +34,16 @@ namespace osu.Game.Tournament.Screens.Editors { public SeedingResult Model { get; } + [Resolved] + private TournamentGameBase? game { get; set; } + public SeedingResultRow(TournamentTeam team, SeedingResult round) { Model = round; + Model.Mod.Default = Model.Mod.Value; + Model.Seed.Default = Model.Seed.Value; + Masking = true; CornerRadius = 10; @@ -104,6 +110,18 @@ namespace osu.Game.Tournament.Screens.Editors AutoSizeAxes = Axes.Y; } + [BackgroundDependencyLoader] + private void load() + { + game?.IsSaveTriggered.BindValueChanged(state => + { + if (!state.NewValue) return; + + Model.Mod.Default = Model.Mod.Value; + Model.Seed.Default = Model.Seed.Value; + }); + } + public partial class SeedingBeatmapEditor : CompositeDrawable { private readonly SeedingResult round; @@ -137,6 +155,9 @@ namespace osu.Game.Tournament.Screens.Editors private readonly SeedingResult result; public SeedingBeatmap Model { get; } + [Resolved] + private TournamentGameBase? game { get; set; } + [Resolved] protected IAPIProvider API { get; private set; } = null!; @@ -252,8 +273,19 @@ namespace osu.Game.Tournament.Screens.Editors API.Queue(req); }, true); - score.Value = Model.Score.ToString(); + Model.Seed.Default = Model.Seed.Value; + + score.Default = score.Value = Model.Score.ToString(); score.BindValueChanged(str => long.TryParse(str.NewValue, out Model.Score)); + + game?.IsSaveTriggered.BindValueChanged(state => + { + if (!state.NewValue) return; + + beatmapId.Default = beatmapId.Value; + Model.Seed.Default = Model.Seed.Value; + score.Default = score.Value; + }); } private void updatePanel()