1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-05 09:42:54 +08:00

Update default values on tournament saving

This commit is contained in:
CloneWith 2024-10-05 16:07:02 +08:00
parent c07e7da40f
commit 5c7ceedd06
No known key found for this signature in database
GPG Key ID: F4FC0D1E91D7FFD5
3 changed files with 67 additions and 0 deletions

View File

@ -26,6 +26,9 @@ namespace osu.Game.Tournament.Screens.Editors
public partial class RoundRow : CompositeDrawable, IModelBacked<TournamentRound>
{
[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(() =>

View File

@ -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<int>
{
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(() =>

View File

@ -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<bool> bracketLoadTaskCompletionSource = new TaskCompletionSource<bool>();
@ -329,7 +332,9 @@ namespace osu.Game.Tournament
return;
}
IsSaveTriggered.Value = true;
saveChanges();
IsSaveTriggered.Value = false;
}
private void saveChanges()