1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:18:22 +08:00

Fix dodgy implementation of current bindable in DateTextBox

This commit is contained in:
Dean Herbert 2023-07-24 20:20:52 +09:00
parent 69ba7afda5
commit e0c0797f55

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System;
using osu.Framework.Bindables;
using osu.Game.Graphics.UserInterface;
@ -12,24 +10,21 @@ namespace osu.Game.Tournament.Components
{
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;
set
{
current = value.GetBoundCopy();
current.BindValueChanged(dto =>
base.Current.Value = dto.NewValue.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"), true);
}
set => current.Current = value;
}
// 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()
{
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, _) =>
{
try