Skip to content

Commit

Permalink
Options menu with interface type switching and shutdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeoliphant committed Sep 24, 2024
1 parent 52aafff commit f0f6ee4
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dependencies/stompbox
8 changes: 7 additions & 1 deletion StompboxShared/Interface/DAWInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Stompbox
{
public class DAWInterface : Dock
public class DAWInterface : InterfaceBase
{
PluginChainDisplay inputChainDisplay;
PluginChainDisplay fxLoopDisplay;
Expand Down Expand Up @@ -155,6 +155,12 @@ public DAWInterface()
{
dspLoadText = new StringBuilderTextBlock("---") { HorizontalAlignment = EHorizontalAlignment.Left, VerticalAlignment = EVerticalAlignment.Bottom };
Children.Add(dspLoadText);

Children.Add(new ExtraOptionsButton(EStompboxInterfaceType.DAW)
{
HorizontalAlignment = EHorizontalAlignment.Right,
VerticalAlignment = EVerticalAlignment.Bottom,
});
}
}

Expand Down
62 changes: 62 additions & 0 deletions StompboxShared/Interface/InterfaceBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Text;
using UILayout;

namespace Stompbox
{
public class InterfaceBase : Dock
{
}

public class ExtraOptionsButton : ImageButton
{
public ExtraOptionsButton(EStompboxInterfaceType currentInterfaceType)
: base("MoreButton")
{
ClickAction = delegate
{
Layout.Current.ShowPopup(new ExtraOptionsMenu(currentInterfaceType), ContentBounds.Center);
};
}
}

public class ExtraOptionsMenu : Menu
{
public ExtraOptionsMenu(EStompboxInterfaceType currentInterfaceType)
{
List<MenuItem> menuItems = new();

foreach (EStompboxInterfaceType type in Enum.GetValues(typeof(EStompboxInterfaceType)))
{
if (type != currentInterfaceType)
{
menuItems.Add(new ContextMenuItem()
{
Text = "Switch to " + type.ToString() + " interface",
AfterCloseAction = delegate
{
StompboxGame.Instance.SetInterfaceType(type);
StompboxClient.Instance.NeedUIReload = true;
}
});
}
}

menuItems.Add(new ContextMenuItem()
{
Text = "Shut down stompbox",
AfterCloseAction = delegate
{
Layout.Current.ShowConfirmationPopup("Shut down!\n\nAre you sure?",
delegate
{
StompboxClient.Instance.SendCommand("Shutdown");
});
}
});

SetMenuItems(menuItems);
}
}
}
20 changes: 13 additions & 7 deletions StompboxShared/Interface/MobileInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Stompbox
{
public class MobileInterface : Dock
public class MobileInterface : InterfaceBase
{
public static DAWInterface Instance { get; private set; }

Expand Down Expand Up @@ -196,15 +196,21 @@ public MobileInterface()
Children.Add(dspLoadText);
}

Children.Add(new TextButton("PB")
//Children.Add(new TextButton("PB")
//{
// HorizontalAlignment = EHorizontalAlignment.Right,
// VerticalAlignment = EVerticalAlignment.Bottom,
// ClickAction = delegate
// {
// StompboxGame.Instance.SetInterfaceType(EStompboxInterfaceType.Pedalboard);
// StompboxClient.Instance.NeedUIReload = true;
// }
//});

Children.Add(new ExtraOptionsButton(EStompboxInterfaceType.Mobile)
{
HorizontalAlignment = EHorizontalAlignment.Right,
VerticalAlignment = EVerticalAlignment.Bottom,
ClickAction = delegate
{
StompboxGame.Instance.SetInterfaceType(EStompboxInterfaceType.Pedalboard);
StompboxClient.Instance.NeedUIReload = true;
}
});
}

Expand Down
15 changes: 14 additions & 1 deletion StompboxShared/Interface/PedalboardInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Stompbox
{
public class PedalboardInterface : Dock
public class PedalboardInterface : InterfaceBase
{
TextBlock presetText;
HorizontalStack stompStack;
Expand Down Expand Up @@ -179,5 +179,18 @@ protected override void DrawContents()
StompboxClient.Instance.NeedUIReload = false;
}
}

public override bool HandleTouch(in Touch touch)
{
if (!base.HandleTouch(touch))
{
if (IsDoubleTap(touch))
{
Layout.Current.ShowPopup(new ExtraOptionsMenu(EStompboxInterfaceType.Pedalboard), ContentBounds.Center);
}
}

return true;
}
}
}
1 change: 1 addition & 0 deletions StompboxShared/StompboxShared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Interface\AudioFilePlayerInterface.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interface\AudioFileRecorderInterface.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interface\DAWInterface.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interface\InterfaceBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interface\MobileInterface.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interface\PedalboardInterface.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interface\PluginInterface.cs" />
Expand Down

0 comments on commit f0f6ee4

Please sign in to comment.