From f0f6ee4fb5633f212fcb6ac98ebf193a16c4eb6f Mon Sep 17 00:00:00 2001 From: Mike Oliphant Date: Tue, 24 Sep 2024 09:40:28 -0700 Subject: [PATCH] Options menu with interface type switching and shutdown. --- Dependencies/stompbox | 2 +- StompboxShared/Interface/DAWInterface.cs | 8 ++- StompboxShared/Interface/InterfaceBase.cs | 62 +++++++++++++++++++ StompboxShared/Interface/MobileInterface.cs | 20 +++--- .../Interface/PedalboardInterface.cs | 15 ++++- StompboxShared/StompboxShared.projitems | 1 + 6 files changed, 98 insertions(+), 10 deletions(-) create mode 100644 StompboxShared/Interface/InterfaceBase.cs diff --git a/Dependencies/stompbox b/Dependencies/stompbox index f8d2392..6aa1438 160000 --- a/Dependencies/stompbox +++ b/Dependencies/stompbox @@ -1 +1 @@ -Subproject commit f8d23920815e9d5a5f5d48f0be4920cae9710923 +Subproject commit 6aa1438c21dbd060952ca4da6cc5e0cb66725745 diff --git a/StompboxShared/Interface/DAWInterface.cs b/StompboxShared/Interface/DAWInterface.cs index 6bea4c2..fc9c7b5 100644 --- a/StompboxShared/Interface/DAWInterface.cs +++ b/StompboxShared/Interface/DAWInterface.cs @@ -7,7 +7,7 @@ namespace Stompbox { - public class DAWInterface : Dock + public class DAWInterface : InterfaceBase { PluginChainDisplay inputChainDisplay; PluginChainDisplay fxLoopDisplay; @@ -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, + }); } } diff --git a/StompboxShared/Interface/InterfaceBase.cs b/StompboxShared/Interface/InterfaceBase.cs new file mode 100644 index 0000000..d05715c --- /dev/null +++ b/StompboxShared/Interface/InterfaceBase.cs @@ -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 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); + } + } +} diff --git a/StompboxShared/Interface/MobileInterface.cs b/StompboxShared/Interface/MobileInterface.cs index 99cbcab..cf6946b 100644 --- a/StompboxShared/Interface/MobileInterface.cs +++ b/StompboxShared/Interface/MobileInterface.cs @@ -7,7 +7,7 @@ namespace Stompbox { - public class MobileInterface : Dock + public class MobileInterface : InterfaceBase { public static DAWInterface Instance { get; private set; } @@ -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; - } }); } diff --git a/StompboxShared/Interface/PedalboardInterface.cs b/StompboxShared/Interface/PedalboardInterface.cs index 379ceef..0769a50 100644 --- a/StompboxShared/Interface/PedalboardInterface.cs +++ b/StompboxShared/Interface/PedalboardInterface.cs @@ -6,7 +6,7 @@ namespace Stompbox { - public class PedalboardInterface : Dock + public class PedalboardInterface : InterfaceBase { TextBlock presetText; HorizontalStack stompStack; @@ -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; + } } } diff --git a/StompboxShared/StompboxShared.projitems b/StompboxShared/StompboxShared.projitems index a2eb565..950f528 100644 --- a/StompboxShared/StompboxShared.projitems +++ b/StompboxShared/StompboxShared.projitems @@ -17,6 +17,7 @@ +