Add button to main menu

This commit is contained in:
smoogipoo 2020-12-21 18:38:44 +09:00
parent 9fa1f60b7d
commit 0566ed1a9b
2 changed files with 8 additions and 8 deletions

View File

@ -42,8 +42,7 @@ public class ButtonSystem : Container, IStateful<ButtonSystemState>, IKeyBinding
public Action OnBeatmapListing;
public Action OnSolo;
public Action OnSettings;
public Action OnMulti;
public Action OnChart;
public Action<bool> OnMulti;
public const float BUTTON_WIDTH = 140f;
public const float WEDGE_WIDTH = 20;
@ -124,8 +123,8 @@ public ButtonSystem()
private void load(AudioManager audio, IdleTracker idleTracker, GameHost host)
{
buttonsPlay.Add(new Button(@"solo", @"button-solo-select", FontAwesome.Solid.User, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
buttonsPlay.Add(new Button(@"multi", @"button-generic-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), onMulti, 0, Key.M));
buttonsPlay.Add(new Button(@"chart", @"button-generic-select", OsuIcon.Charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke()));
buttonsPlay.Add(new Button(@"multi", @"button-generic-select", OsuIcon.Charts, new Color4(94, 63, 186, 255), () => onMulti(true), 0, Key.M));
buttonsPlay.Add(new Button(@"timeshift", @"button-generic-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), () => onMulti(false), 0, Key.L));
buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play);
buttonsTopLevel.Add(new Button(@"play", @"button-play-select", OsuIcon.Logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH, Key.P));
@ -154,7 +153,7 @@ private void load(AudioManager audio, IdleTracker idleTracker, GameHost host)
sampleBack = audio.Samples.Get(@"Menu/button-back-select");
}
private void onMulti()
private void onMulti(bool realtime)
{
if (!api.IsLoggedIn)
{
@ -172,7 +171,7 @@ private void onMulti()
return;
}
OnMulti?.Invoke();
OnMulti?.Invoke(realtime);
}
private void updateIdleState(bool isIdle)

View File

@ -17,6 +17,8 @@
using osu.Game.Overlays;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Multi;
using osu.Game.Screens.Multi.RealtimeMultiplayer;
using osu.Game.Screens.Multi.Timeshift;
using osu.Game.Screens.Select;
@ -104,7 +106,7 @@ private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings
this.Push(new Editor());
},
OnSolo = onSolo,
OnMulti = delegate { this.Push(new TimeshiftMultiplayer()); },
OnMulti = realtime => this.Push(realtime ? (Multiplayer)new RealtimeMultiplayer() : new TimeshiftMultiplayer()),
OnExit = confirmAndExit,
}
}
@ -136,7 +138,6 @@ private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings
buttons.OnSettings = () => settings?.ToggleVisibility();
buttons.OnBeatmapListing = () => beatmapListing?.ToggleVisibility();
buttons.OnChart = () => rankings?.ShowSpotlights();
LoadComponentAsync(background = new BackgroundScreenDefault());
preloadSongSelect();