1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-17 22:17:25 +08:00

Merge pull request #14935 from Susko3/fix-SettingsTextBox-using-null-as-default

Fix usages of `SettingsTextBox` having `null` as the default
This commit is contained in:
Dan Balasescu 2021-10-08 18:36:02 +09:00 committed by GitHub
commit 9be56829c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 7 deletions

View File

@ -53,7 +53,11 @@ namespace osu.Game.Tests.Visual.Settings
};
[SettingSource("Sample string", "Change something for a mod")]
public Bindable<string> StringBindable { get; } = new Bindable<string>();
public Bindable<string> StringBindable { get; } = new Bindable<string>
{
Default = string.Empty,
Value = "Sample text"
};
}
private enum TestEnum

View File

@ -26,7 +26,7 @@ namespace osu.Game.Tournament.Components
public DateTextBox()
{
base.Current = new Bindable<string>();
base.Current = new Bindable<string>(string.Empty);
((OsuTextBox)Control).OnCommit += (sender, newText) =>
{

View File

@ -10,7 +10,7 @@ namespace osu.Game.Tournament.Models
{
public List<SeedingBeatmap> Beatmaps = new List<SeedingBeatmap>();
public Bindable<string> Mod = new Bindable<string>();
public Bindable<string> Mod = new Bindable<string>(string.Empty);
public Bindable<int> Seed = new BindableInt
{

View File

@ -14,8 +14,8 @@ namespace osu.Game.Tournament.Models
[Serializable]
public class TournamentRound
{
public readonly Bindable<string> Name = new Bindable<string>();
public readonly Bindable<string> Description = new Bindable<string>();
public readonly Bindable<string> Name = new Bindable<string>(string.Empty);
public readonly Bindable<string> Description = new Bindable<string>(string.Empty);
public readonly BindableInt BestOf = new BindableInt(9) { Default = 9, MinValue = 3, MaxValue = 23 };

View File

@ -149,7 +149,7 @@ namespace osu.Game.Tournament.Screens.Editors
private readonly Bindable<int?> beatmapId = new Bindable<int?>();
private readonly Bindable<string> mods = new Bindable<string>();
private readonly Bindable<string> mods = new Bindable<string>(string.Empty);
private readonly Container drawableContainer;

View File

@ -149,7 +149,7 @@ namespace osu.Game.Tournament.Screens.Editors
private readonly Bindable<int?> beatmapId = new Bindable<int?>();
private readonly Bindable<string> score = new Bindable<string>();
private readonly Bindable<string> score = new Bindable<string>(string.Empty);
private readonly Container drawableContainer;

View File

@ -1,6 +1,8 @@
// 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.
using System;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
namespace osu.Game.Overlays.Settings
@ -13,5 +15,17 @@ namespace osu.Game.Overlays.Settings
RelativeSizeAxes = Axes.X,
CommitOnFocusLost = true
};
public override Bindable<string> Current
{
get => base.Current;
set
{
if (value.Default == null)
throw new InvalidOperationException($"Bindable settings of type {nameof(Bindable<string>)} should have a non-null default value.");
base.Current = value;
}
}
}
}