Allow buttons to be displayed on more than one state (and share the back button)

This commit is contained in:
Dean Herbert 2023-11-24 11:15:18 +09:00
parent 1d1b3ca982
commit a069a673fa
No known key found for this signature in database
2 changed files with 16 additions and 10 deletions

View File

@ -107,12 +107,8 @@ public ButtonSystem()
backButton = new MainMenuButton(ButtonSystemStrings.Back, @"back-to-top", OsuIcon.LeftCircle, new Color4(51, 58, 94, 255), () => State = ButtonSystemState.TopLevel,
-WEDGE_WIDTH)
{
VisibleState = ButtonSystemState.Edit,
},
backButton = new MainMenuButton(ButtonSystemStrings.Back, @"back-to-top", OsuIcon.LeftCircle, new Color4(51, 58, 94, 255), () => State = ButtonSystemState.TopLevel,
-WEDGE_WIDTH)
{
VisibleState = ButtonSystemState.Play,
VisibleStateMin = ButtonSystemState.Play,
VisibleStateMax = ButtonSystemState.Edit,
},
logoTrackingContainer.LogoFacade.With(d => d.Scale = new Vector2(0.74f))
});

View File

@ -42,9 +42,19 @@ public partial class MainMenuButton : BeatSyncedContainer, IStateful<ButtonState
private readonly string sampleName;
/// <summary>
/// The menu state for which we are visible for.
/// The menu state for which we are visible for (assuming only one).
/// </summary>
public ButtonSystemState VisibleState = ButtonSystemState.TopLevel;
public ButtonSystemState VisibleState
{
set
{
VisibleStateMin = value;
VisibleStateMax = value;
}
}
public ButtonSystemState VisibleStateMin = ButtonSystemState.TopLevel;
public ButtonSystemState VisibleStateMax = ButtonSystemState.TopLevel;
private readonly Action? clickAction;
private Sample? sampleClick;
@ -313,9 +323,9 @@ public ButtonSystemState ButtonSystemState
break;
default:
if (value == VisibleState)
if (value <= VisibleStateMax && value >= VisibleStateMin)
State = ButtonState.Expanded;
else if (value < VisibleState)
else if (value < VisibleStateMin)
State = ButtonState.Contracted;
else
State = ButtonState.Exploded;