Skip to content

Commit

Permalink
Using BarRaider.SDTools v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BarRaider committed Feb 7, 2019
1 parent f5ec91d commit 96403ed
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 219 deletions.
11 changes: 6 additions & 5 deletions DelayedText/DelayedText.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="barraider-sdtools">
<HintPath>..\..\barraider-sdtools\barraider-sdtools\bin\Release\barraider-sdtools.dll</HintPath>
</Reference>
<Reference Include="CommandLine, Version=2.4.3.0, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.4.3\lib\netstandard2.0\CommandLine.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -63,7 +60,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DelayedTextInput.cs" />
<Compile Include="PluginContainer.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand All @@ -74,7 +70,12 @@
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\..\barraider-sdtools\barraider-sdtools\barraider-sdtools.csproj">
<Project>{dabbd97d-6687-4cbd-a19e-ac9ffa3cef03}</Project>
<Name>barraider-sdtools</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Images\bg%402x.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
36 changes: 16 additions & 20 deletions DelayedText/DelayedTextInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

namespace Delayedtext
{
public class DelayedTextInput : IPluginable
public class DelayedTextInput : PluginBase
{
private class InspectorSettings : SettingsBase
private class PluginSettings
{
public static InspectorSettings CreateDefaultSettings()
public static PluginSettings CreateDefaultSettings()
{
InspectorSettings instance = new InspectorSettings();
PluginSettings instance = new PluginSettings();
instance.InputText = String.Empty; ;
instance.Delay = 1;
instance.EnterMode = false;
Expand All @@ -40,29 +40,25 @@ public static InspectorSettings CreateDefaultSettings()
private const int RESET_COUNTER_KEYPRESS_LENGTH = 1;

private bool inputRunning = false;
private InspectorSettings settings;
private PluginSettings settings;

#endregion

#region Public Methods

public DelayedTextInput(streamdeck_client_csharp.StreamDeckConnection connection, string action, string context, JObject settings)
public DelayedTextInput(SDConnection connection, JObject settings) : base(connection, settings)
{
if (settings == null || settings.Count == 0)
{
this.settings = InspectorSettings.CreateDefaultSettings();
this.settings = PluginSettings.CreateDefaultSettings();
}
else
{
this.settings = settings.ToObject<InspectorSettings>();
this.settings = settings.ToObject<PluginSettings>();
}

this.settings.StreamDeckConnection = connection;
this.settings.ActionId = action;
this.settings.ContextId = context;
}

public void KeyPressed()
public override void KeyPressed()
{
if (inputRunning)
{
Expand All @@ -72,37 +68,37 @@ public void KeyPressed()
SendInput();
}

public void KeyReleased()
public override void KeyReleased()
{
}

public void OnTick()
public override void OnTick()
{
}

public void Dispose()
public override void Dispose()
{
}

public void UpdateSettings(JObject payload)
public override void UpdateSettings(JObject payload)
{
if (payload["property_inspector"] != null)
{
switch (payload["property_inspector"].ToString().ToLower())
{
case "propertyinspectorconnected":
settings.SendToPropertyInspectorAsync();
Connection.SendToPropertyInspectorAsync(JObject.FromObject(settings));
break;

case "propertyinspectorwilldisappear":
settings.SetSettingsAsync();
Connection.SetSettingsAsync(JObject.FromObject(settings));
break;

case "updatesettings":
settings.Delay = (int)payload["delay"];
settings.InputText = (string)payload["inputText"];
settings.EnterMode = (bool)payload["enterMode"];
settings.SetSettingsAsync();
Connection.SetSettingsAsync(JObject.FromObject(settings));
break;
}
}
Expand Down
155 changes: 0 additions & 155 deletions DelayedText/PluginContainer.cs

This file was deleted.

42 changes: 4 additions & 38 deletions DelayedText/Program.cs
Original file line number Diff line number Diff line change
@@ -1,54 +1,20 @@
using BarRaider.SdTools;
using CommandLine;
using System;
using System.Collections.Generic;

namespace Delayedtext
{
class Program
{
/************************************************************************
* Initial configuration copied from TyrenDe's streamdeck-client-csharp example:
* https://github.com/TyrenDe/streamdeck-client-csharp
* and SaviorXTanren's MixItUp.StreamDeckPlugin:
* https://github.com/SaviorXTanren/mixer-mixitup/
*************************************************************************/

// Handles all the communication with the plugin
private static PluginContainer container;

// StreamDeck launches the plugin with these details
// -port [number] -pluginUUID [GUID] -registerEvent [string?] -info [json]
static void Main(string[] args)
{
// Uncomment this line of code to allow for debugging
//while (!System.Diagnostics.Debugger.IsAttached) { System.Threading.Thread.Sleep(100); }

// The command line args parser expects all args to use `--`, so, let's append
for (int count = 0; count < args.Length; count++)
{
if (args[count].StartsWith("-") && !args[count].StartsWith("--"))
{
args[count] = $"-{args[count]}";
}
}

Parser parser = new Parser((with) =>
{
with.EnableDashDash = true;
with.CaseInsensitiveEnumValues = true;
with.CaseSensitive = false;
with.IgnoreUnknownArguments = true;
with.HelpWriter = Console.Error;
});

ParserResult<StreamDeckOptions> options = parser.ParseArguments<StreamDeckOptions>(args);
options.WithParsed<StreamDeckOptions>(o => RunPlugin(o));
}

static void RunPlugin(StreamDeckOptions options)
{
container = new PluginContainer();
container.Run(options);
List<PluginActionId> supportedActionIds = new List<PluginActionId>();
supportedActionIds.Add(new PluginActionId("com.barraider.delayedtext", typeof(DelayedTextInput)));
SDWrapper.Run(args, supportedActionIds.ToArray());
}
}
}
2 changes: 1 addition & 1 deletion DelayedText/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"Name": "Delayed Text Input",
"Icon": "Images/pluginIcon",
"URL": "https://barraider.github.io/",
"Version": "1.01",
"Version": "1.2",
"CodePath": "com.barraider.delayedtext",
"Category": "BarRaider",
"CategoryIcon": "Images/categoryIcon",
Expand Down

0 comments on commit 96403ed

Please sign in to comment.