mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add xmldocs and cleanup
This commit is contained in:
@ -7,15 +7,34 @@ using osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="OsuMenuItem"/> which contains and displays a state.
|
||||
/// </summary>
|
||||
public abstract class StatefulMenuItem : OsuMenuItem
|
||||
{
|
||||
/// <summary>
|
||||
/// The current state that should be displayed.
|
||||
/// </summary>
|
||||
public readonly Bindable<object> State = new Bindable<object>();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="StatefulMenuItem"/>.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
: this(text, changeStateFunc, type, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="StatefulMenuItem"/>.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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)
|
||||
: base(text, type)
|
||||
{
|
||||
@ -26,19 +45,40 @@ namespace osu.Game.Graphics.UserInterface
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the icon to be displayed for a state.
|
||||
/// </summary>
|
||||
/// <param name="state">The state to retrieve the relevant icon for.</param>
|
||||
/// <returns>The icon to be displayed for <paramref name="state"/>.</returns>
|
||||
public abstract IconUsage? GetIconForState(object state);
|
||||
}
|
||||
|
||||
public abstract class StatefulMenuItem<T> : StatefulMenuItem
|
||||
where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// The current state that should be displayed.
|
||||
/// </summary>
|
||||
public new readonly Bindable<T> State = new Bindable<T>();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="StatefulMenuItem"/>.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
: this(text, changeStateFunc, type, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="StatefulMenuItem"/>.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <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)
|
||||
: base(text, o => changeStateFunc?.Invoke((T)o) ?? o, type, o => action?.Invoke((T)o))
|
||||
{
|
||||
@ -55,6 +95,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public sealed override IconUsage? GetIconForState(object state) => GetIconForState((T)state);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the icon to be displayed for a state.
|
||||
/// </summary>
|
||||
/// <param name="state">The state to retrieve the relevant icon for.</param>
|
||||
/// <returns>The icon to be displayed for <paramref name="state"/>.</returns>
|
||||
public abstract IconUsage? GetIconForState(T state);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user