mirror of
https://github.com/ppy/osu.git
synced 2025-03-04 04:42:55 +08:00
Merge pull request #24349 from peppy/tournament-bindable-fixes
Fix tournament client crashing occasionally when editing bracket
This commit is contained in:
commit
3af5c2b4f3
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -12,24 +10,21 @@ namespace osu.Game.Tournament.Components
|
|||||||
{
|
{
|
||||||
public partial class DateTextBox : SettingsTextBox
|
public partial class DateTextBox : SettingsTextBox
|
||||||
{
|
{
|
||||||
public new Bindable<DateTimeOffset> Current
|
private readonly BindableWithCurrent<DateTimeOffset> current = new BindableWithCurrent<DateTimeOffset>();
|
||||||
|
|
||||||
|
public new Bindable<DateTimeOffset>? Current
|
||||||
{
|
{
|
||||||
get => current;
|
get => current;
|
||||||
set
|
set => current.Current = value;
|
||||||
{
|
|
||||||
current = value.GetBoundCopy();
|
|
||||||
current.BindValueChanged(dto =>
|
|
||||||
base.Current.Value = dto.NewValue.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// hold a reference to the provided bindable so we don't have to in every settings section.
|
|
||||||
private Bindable<DateTimeOffset> current = new Bindable<DateTimeOffset>();
|
|
||||||
|
|
||||||
public DateTextBox()
|
public DateTextBox()
|
||||||
{
|
{
|
||||||
base.Current = new Bindable<string>(string.Empty);
|
base.Current = new Bindable<string>(string.Empty);
|
||||||
|
|
||||||
|
current.BindValueChanged(dto =>
|
||||||
|
base.Current.Value = dto.NewValue.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"), true);
|
||||||
|
|
||||||
((OsuTextBox)Control).OnCommit += (sender, _) =>
|
((OsuTextBox)Control).OnCommit += (sender, _) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -62,22 +62,28 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
|
|||||||
// ensure any ongoing edits are committed out to the *current* selection before changing to a new one.
|
// ensure any ongoing edits are committed out to the *current* selection before changing to a new one.
|
||||||
GetContainingInputManager().TriggerFocusContention(null);
|
GetContainingInputManager().TriggerFocusContention(null);
|
||||||
|
|
||||||
roundDropdown.Current = selection.NewValue?.Round;
|
// Required to avoid cyclic failure in BindableWithCurrent (TriggerChange called during the Current_Set process).
|
||||||
losersCheckbox.Current = selection.NewValue?.Losers;
|
// Arguable a framework issue but since we haven't hit it anywhere else a local workaround seems best.
|
||||||
dateTimeBox.Current = selection.NewValue?.Date;
|
roundDropdown.Current.ValueChanged -= roundDropdownChanged;
|
||||||
|
|
||||||
team1Dropdown.Current = selection.NewValue?.Team1;
|
roundDropdown.Current = selection.NewValue.Round;
|
||||||
team2Dropdown.Current = selection.NewValue?.Team2;
|
losersCheckbox.Current = selection.NewValue.Losers;
|
||||||
|
dateTimeBox.Current = selection.NewValue.Date;
|
||||||
|
|
||||||
|
team1Dropdown.Current = selection.NewValue.Team1;
|
||||||
|
team2Dropdown.Current = selection.NewValue.Team2;
|
||||||
|
|
||||||
|
roundDropdown.Current.ValueChanged += roundDropdownChanged;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
roundDropdown.Current.ValueChanged += round =>
|
private void roundDropdownChanged(ValueChangedEvent<TournamentRound> round)
|
||||||
|
{
|
||||||
|
if (editorInfo.Selected.Value?.Date.Value < round.NewValue?.StartDate.Value)
|
||||||
{
|
{
|
||||||
if (editorInfo.Selected.Value?.Date.Value < round.NewValue?.StartDate.Value)
|
editorInfo.Selected.Value.Date.Value = round.NewValue.StartDate.Value;
|
||||||
{
|
editorInfo.Selected.TriggerChange();
|
||||||
editorInfo.Selected.Value.Date.Value = round.NewValue.StartDate.Value;
|
}
|
||||||
editorInfo.Selected.TriggerChange();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
Loading…
Reference in New Issue
Block a user