1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 18:23:04 +08:00

Add support for localisation where it was missing

This commit is contained in:
ansel 2023-01-15 01:46:11 +03:00
parent 43c0f8b95f
commit 76eefc7573
5 changed files with 15 additions and 23 deletions

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.Graphics.UserInterface;
using osu.Framework.Localisation;
@ -13,12 +11,12 @@ namespace osu.Game.Graphics.UserInterface
{
public readonly MenuItemType Type;
public OsuMenuItem(string text, MenuItemType type = MenuItemType.Standard)
public OsuMenuItem(LocalisableString text, MenuItemType type = MenuItemType.Standard)
: this(text, type, null)
{
}
public OsuMenuItem(LocalisableString text, MenuItemType type, Action action)
public OsuMenuItem(LocalisableString text, MenuItemType type, Action? action)
: base(text, action)
{
Type = type;

View File

@ -1,11 +1,10 @@
// 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.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
namespace osu.Game.Graphics.UserInterface
{
@ -25,7 +24,7 @@ namespace osu.Game.Graphics.UserInterface
/// <param name="text">The text to display.</param>
/// <param name="changeStateFunc">A function that mutates a state to another state after this <see cref="StatefulMenuItem"/> is pressed.</param>
/// <param name="type">The type of action which this <see cref="StatefulMenuItem"/> performs.</param>
protected StatefulMenuItem(string text, Func<object, object> changeStateFunc, MenuItemType type = MenuItemType.Standard)
protected StatefulMenuItem(LocalisableString text, Func<object, object> changeStateFunc, MenuItemType type = MenuItemType.Standard)
: this(text, changeStateFunc, type, null)
{
}
@ -37,7 +36,7 @@ namespace osu.Game.Graphics.UserInterface
/// <param name="changeStateFunc">A function that mutates a state to another state after this <see cref="StatefulMenuItem"/> is pressed.</param>
/// <param name="type">The type of action which this <see cref="StatefulMenuItem"/> performs.</param>
/// <param name="action">A delegate to be invoked when this <see cref="StatefulMenuItem"/> is pressed.</param>
protected StatefulMenuItem(string text, Func<object, object> changeStateFunc, MenuItemType type, Action<object> action)
protected StatefulMenuItem(LocalisableString text, Func<object, object>? changeStateFunc, MenuItemType type, Action<object>? action)
: base(text, type)
{
Action.Value = () =>
@ -69,7 +68,7 @@ namespace osu.Game.Graphics.UserInterface
/// <param name="text">The text to display.</param>
/// <param name="changeStateFunc">A function that mutates a state to another state after this <see cref="StatefulMenuItem"/> is pressed.</param>
/// <param name="type">The type of action which this <see cref="StatefulMenuItem"/> performs.</param>
protected StatefulMenuItem(string text, Func<T, T> changeStateFunc, MenuItemType type = MenuItemType.Standard)
protected StatefulMenuItem(LocalisableString text, Func<T, T>? changeStateFunc, MenuItemType type = MenuItemType.Standard)
: this(text, changeStateFunc, type, null)
{
}
@ -81,7 +80,7 @@ namespace osu.Game.Graphics.UserInterface
/// <param name="changeStateFunc">A function that mutates a state to another state after this <see cref="StatefulMenuItem"/> is pressed.</param>
/// <param name="type">The type of action which this <see cref="StatefulMenuItem"/> performs.</param>
/// <param name="action">A delegate to be invoked when this <see cref="StatefulMenuItem"/> is pressed.</param>
protected StatefulMenuItem(string text, Func<T, T> changeStateFunc, MenuItemType type, Action<T> action)
protected StatefulMenuItem(LocalisableString text, Func<T, T>? changeStateFunc, MenuItemType type, Action<T>? action)
: base(text, o => changeStateFunc?.Invoke((T)o) ?? o, type, o => action?.Invoke((T)o))
{
base.State.BindValueChanged(state =>

View File

@ -1,10 +1,9 @@
// 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.Graphics.Sprites;
using osu.Framework.Localisation;
namespace osu.Game.Graphics.UserInterface
{
@ -18,7 +17,7 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
/// <param name="text">The text to display.</param>
/// <param name="type">The type of action which this <see cref="ToggleMenuItem"/> performs.</param>
public ToggleMenuItem(string text, MenuItemType type = MenuItemType.Standard)
public ToggleMenuItem(LocalisableString text, MenuItemType type = MenuItemType.Standard)
: this(text, type, null)
{
}
@ -29,7 +28,7 @@ namespace osu.Game.Graphics.UserInterface
/// <param name="text">The text to display.</param>
/// <param name="type">The type of action which this <see cref="ToggleMenuItem"/> performs.</param>
/// <param name="action">A delegate to be invoked when this <see cref="ToggleMenuItem"/> is pressed.</param>
public ToggleMenuItem(string text, MenuItemType type, Action<bool> action)
public ToggleMenuItem(LocalisableString text, MenuItemType type, Action<bool>? action)
: base(text, value => !value, type, action)
{
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Edit.Components.Menus
@ -10,13 +11,13 @@ namespace osu.Game.Screens.Edit.Components.Menus
{
private const int min_text_length = 40;
public EditorMenuItem(string text, MenuItemType type = MenuItemType.Standard)
: base(text.PadRight(min_text_length), type)
public EditorMenuItem(LocalisableString text, MenuItemType type = MenuItemType.Standard)
: base(LocalisableString.Interpolate($"{text,-min_text_length}"), type)
{
}
public EditorMenuItem(string text, MenuItemType type, Action action)
: base(text.PadRight(min_text_length), type, action)
public EditorMenuItem(LocalisableString text, MenuItemType type, Action action)
: base(LocalisableString.Interpolate($"{text,-min_text_length}"), type, action)
{
}
}

View File

@ -56,11 +56,6 @@ namespace osu.Game.Screens.Edit.Components.Menus
Bar.Expire();
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
}
protected override void OnActivated()
{
base.OnActivated();