Skip to content

Commit

Permalink
Plugin/parameter info display
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeoliphant committed Aug 9, 2024
1 parent b69bb0d commit 9e9e9f0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dependencies/stompbox
3 changes: 3 additions & 0 deletions StompboxShared/AudioPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class PluginParameter
{
public IAudioPlugin Plugin { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string ValueFormat { get; set; }
public double MinValue { get; set; }
public double MaxValue { get; set; }
Expand Down Expand Up @@ -119,6 +120,7 @@ public interface IAudioPlugin
StompboxClient StompboxClient { get; set; }
String Name { get; set; }
String ID { get; }
String Description { get; set; }
bool Enabled { get; set; }
double OutputValue { get; set; }
bool EnabledIsSwitchable { get; set; }
Expand All @@ -140,6 +142,7 @@ public class AudioPluginBase : IAudioPlugin
public StompboxClient StompboxClient { get; set; }
public String Name { get; set; }
public String ID { get; set; }
public String Description { get; set; }
public virtual bool Enabled
{
get
Expand Down
17 changes: 16 additions & 1 deletion StompboxShared/Interface/PluginInterface.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Drawing;
using System.Collections.Generic;
using System.Numerics;
using UILayout;

namespace Stompbox
Expand Down Expand Up @@ -646,6 +645,22 @@ protected override void AddControls(Dock dock)
});
}

AddMenuItem(new ContextMenuItem
{
Text = "Plugin Info",
AfterCloseAction = delegate
{
string info = Plugin.Name + ": " + Plugin.Description + "\n\n\n";

foreach (PluginParameter param in Plugin.Parameters)
{
info += param.Name + ": " + param.Description + "\n\n";
}

Layout.Current.ShowContinuePopup(new TextBlock(info) { Margin = new LayoutPadding(20) });
}
});

VerticalStack vStack = new VerticalStack { HorizontalAlignment = EHorizontalAlignment.Stretch, VerticalAlignment = EVerticalAlignment.Stretch, ChildSpacing = 5 };
dock.Children.Add(vStack);

Expand Down
21 changes: 20 additions & 1 deletion StompboxShared/ProtocolClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;

namespace Stompbox
{
Expand Down Expand Up @@ -123,6 +125,7 @@ public IAudioPlugin CreateNewPlugin(string pluginName, string pluginID)
{
IAudioPlugin pluginDef = pluginDefs[plugin.Name];

plugin.Description = pluginDef.Description;
plugin.BackgroundColor = pluginDef.BackgroundColor;
plugin.ForegroundColor = pluginDef.ForegroundColor;
plugin.IsUserSelectable = pluginDef.IsUserSelectable;
Expand Down Expand Up @@ -182,7 +185,16 @@ public void HandleCommand(string cmd)

try
{
string[] cmdWords = cmd.Split(split, StringSplitOptions.RemoveEmptyEntries);
string[] cmdWords = Regex.Matches(cmd, @"(['\""])(?<value>.+?)\1|(?<value>[^ ]+)")
.Cast<Match>()
.Select(m => m.Groups["value"].Value)
.ToArray();


//Regex.Matches(cmd, @"[\""].+?[\""]|[^ ]+")
//.Cast<Match>()
//.Select(m => m.Value)
//.ToArray();

if (cmdWords.Length > 0)
{
Expand Down Expand Up @@ -404,6 +416,10 @@ public void HandleCommand(string cmd)

pluginDef.IsUserSelectable = (isSelectable == 1);
break;

case "Description":
pluginDef.Description = propValue;
break;
}
}

Expand Down Expand Up @@ -469,6 +485,9 @@ public void HandleCommand(string cmd)
int.TryParse(propValue, out isAdvanced);
newParameter.IsAdvanced = (isAdvanced == 1);
break;
case "Description":
newParameter.Description = propValue;
break;
}
}
pluginDef.Parameters.Add(newParameter);
Expand Down

0 comments on commit 9e9e9f0

Please sign in to comment.