diff --git a/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs index 253cca8c98..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] @@ -38,6 +41,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; @@ -122,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; @@ -154,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] @@ -232,7 +260,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,8 +291,16 @@ 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); + + 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/SeedingEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/SeedingEditorScreen.cs index 9927dd56a0..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!; @@ -221,7 +242,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; @@ -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() diff --git a/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs index 250d5acaae..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; @@ -283,7 +308,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; @@ -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/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, } } } 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()