Skip to content

Commit

Permalink
allow pausing music in a multi lobby
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Aug 27, 2024
1 parent 8168505 commit e51477b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
29 changes: 13 additions & 16 deletions fluXis.Game/FluXisGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,23 +392,20 @@ public bool OnPressed(KeyBindingPressEvent<FluXisGlobalKeybind> e)
return true;
}

if (screenStack.AllowMusicControl)
switch (e.Action)
{
switch (e.Action)
{
case FluXisGlobalKeybind.MusicPause:
if (globalClock.IsRunning) globalClock.Stop();
else globalClock.Start();
return true;

case FluXisGlobalKeybind.MusicPrevious:
PreviousSong();
return true;

case FluXisGlobalKeybind.MusicNext:
NextSong();
return true;
}
case FluXisGlobalKeybind.MusicPause when screenStack.AllowMusicPausing:
if (globalClock.IsRunning) globalClock.Stop();
else globalClock.Start();
return true;

case FluXisGlobalKeybind.MusicPrevious when screenStack.AllowMusicControl:
PreviousSong();
return true;

case FluXisGlobalKeybind.MusicNext when screenStack.AllowMusicControl:
NextSong();
return true;
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion fluXis.Game/Overlay/Music/MusicPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private void load()
Icon = FontAwesome6.Solid.Play,
Action = () =>
{
if (!screens.AllowMusicControl)
if (!screens.AllowMusicPausing)
return;
if (globalClock.IsRunning)
Expand Down
1 change: 1 addition & 0 deletions fluXis.Game/Screens/FluXisScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public partial class FluXisScreen : Screen
public virtual float BackgroundDim => 0.25f;
public virtual float BackgroundBlur => 0f;
public virtual bool AllowMusicControl => true;
public virtual bool AllowMusicPausing => AllowMusicControl;
public virtual bool ShowCursor => true;
public virtual bool ApplyValuesAfterLoad => false;
public virtual bool AllowExit => true;
Expand Down
1 change: 1 addition & 0 deletions fluXis.Game/Screens/FluXisScreenStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public partial class FluXisScreenStack : ScreenStack
private Toolbar toolbar { get; set; }

public bool AllowMusicControl => CurrentScreen is FluXisScreen { AllowMusicControl: true };
public bool AllowMusicPausing => CurrentScreen is FluXisScreen { AllowMusicPausing: true };

private Bindable<UserActivity> activity { get; } = new();
private Bindable<bool> allowOverlays { get; } = new();
Expand Down
1 change: 1 addition & 0 deletions fluXis.Game/Screens/Multiplayer/MultiSubScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public partial class MultiSubScreen : Screen, IKeyBindingHandler<FluXisGlobalKey

public Bindable<UserActivity> Activity => MultiScreen.Activity;
protected virtual UserActivity InitialActivity => new UserActivity.MenuGeneral();
public virtual bool AllowMusicPausing => false;

private Container titleContainer;
private Box titleLine;
Expand Down
1 change: 1 addition & 0 deletions fluXis.Game/Screens/Multiplayer/MultiplayerScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public partial class MultiplayerScreen : FluXisScreen
public override float BackgroundDim => .5f;
public override float BackgroundBlur => .2f;
public override bool AllowMusicControl => false;
public override bool AllowMusicPausing => screenStack?.CurrentScreen is MultiSubScreen { AllowMusicPausing: true };
public override bool AllowExit => canExit();

[Resolved]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public partial class MultiLobby : MultiSubScreen
public override string SubTitle => "Lobby";

protected override UserActivity InitialActivity => new UserActivity.MultiLobby(Room);
public override bool AllowMusicPausing => true;

[Resolved]
private MapStore mapStore { get; set; }
Expand Down Expand Up @@ -216,7 +217,7 @@ protected override void Dispose(bool isDisposing)

private void onDisconnect()
{
if (MultiScreen.IsCurrentScreen())
if (IsCurrentScreen)
{
clock.Stop();
panels.Content = new DisconnectedPanel(() =>
Expand Down

0 comments on commit e51477b

Please sign in to comment.