Skip to content

Commit

Permalink
v1.3 - Upgraded to StreamDeck-Tools v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BarRaider committed Mar 3, 2019
1 parent 96403ed commit 160659b
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 108 deletions.
10 changes: 9 additions & 1 deletion DelayedText/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Drawing.Common" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
33 changes: 19 additions & 14 deletions DelayedText/DelayedText.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,31 @@
</PropertyGroup>
<ItemGroup>
<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>
<HintPath>..\..\..\DotNet\StreamDeck\packages\CommandLineParser.2.4.3\lib\netstandard2.0\CommandLine.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\..\DotNet\StreamDeck\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="streamdeck-client-csharp, Version=0.1.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\streamdeck-client-csharp.0.1.2-preview\lib\netstandard2.0\streamdeck-client-csharp.dll</HintPath>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="streamdeck-client-csharp, Version=4.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\streamdeck-client-csharp.4.1.0\lib\netstandard2.0\streamdeck-client-csharp.dll</HintPath>
</Reference>
<Reference Include="StreamDeckTools, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\StreamDeck-Tools.2.0.0\lib\net472\StreamDeckTools.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Common, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Drawing.Common.4.6.0-preview.18571.3\lib\net461\System.Drawing.Common.dll</HintPath>
<Reference Include="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\System.Drawing.Common.4.5.1\lib\net461\System.Drawing.Common.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -70,12 +81,6 @@
</None>
<None Include="packages.config" />
</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 Expand Up @@ -104,10 +109,10 @@
<Content Include="PropertyInspector\DelayedText\Index.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="PropertyInspector\Index.js">
<Content Include="PropertyInspector\sdpi.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="PropertyInspector\sdpi.css">
<Content Include="PropertyInspector\sdtools.common.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
44 changes: 17 additions & 27 deletions DelayedText/DelayedTextInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Delayedtext
{
[PluginActionId("com.barraider.delayedtext")]
public class DelayedTextInput : PluginBase
{
private class PluginSettings
Expand Down Expand Up @@ -46,20 +47,22 @@ public static PluginSettings CreateDefaultSettings()

#region Public Methods

public DelayedTextInput(SDConnection connection, JObject settings) : base(connection, settings)
public DelayedTextInput(SDConnection connection, InitialPayload payload) : base(connection, payload)
{
if (settings == null || settings.Count == 0)
if (payload.Settings == null || payload.Settings.Count == 0)
{
this.settings = PluginSettings.CreateDefaultSettings();
Connection.SetSettingsAsync(JObject.FromObject(settings));
}
else
{
this.settings = settings.ToObject<PluginSettings>();
this.settings = payload.Settings.ToObject<PluginSettings>();
}
}

public override void KeyPressed()
public override void KeyPressed(KeyPayload payload)
{
Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed");
if (inputRunning)
{
return;
Expand All @@ -68,7 +71,7 @@ public override void KeyPressed()
SendInput();
}

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

Expand All @@ -78,32 +81,20 @@ public override void OnTick()

public override void Dispose()
{
Logger.Instance.LogMessage(TracingLevel.INFO, "Destructor called");
}

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

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

case "updatesettings":
settings.Delay = (int)payload["delay"];
settings.InputText = (string)payload["inputText"];
settings.EnterMode = (bool)payload["enterMode"];
Connection.SetSettingsAsync(JObject.FromObject(settings));
break;
}
}
// New in StreamDeck-Tools v2.0:
Tools.AutoPopulateSettings(settings, payload.Settings);
Logger.Instance.LogMessage(TracingLevel.INFO, $"Settings loaded: {payload.Settings}");
}

public override void ReceivedGlobalSettings(ReceivedGlobalSettingsPayload payload)
{ }


#endregion

#region Private Methods
Expand Down Expand Up @@ -137,7 +128,6 @@ await Task.Run(() =>
});
inputRunning = false;
}

#endregion
}
}
4 changes: 1 addition & 3 deletions DelayedText/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ static void Main(string[] args)
// Uncomment this line of code to allow for debugging
//while (!System.Diagnostics.Debugger.IsAttached) { System.Threading.Thread.Sleep(100); }

List<PluginActionId> supportedActionIds = new List<PluginActionId>();
supportedActionIds.Add(new PluginActionId("com.barraider.delayedtext", typeof(DelayedTextInput)));
SDWrapper.Run(args, supportedActionIds.ToArray());
SDWrapper.Run(args);
}
}
}
10 changes: 5 additions & 5 deletions DelayedText/PropertyInspector/DelayedText/Index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
<body>
<div class="sdpi-wrapper">
<details class="message info">
<summary>For feedback/suggestions contact me at <a href="https://BarRaider.github.io" target="_blank" onclick="openWebsite()">https://BarRaider.github.io</a> </summary>
<summary>For feedback/suggestions contact me at <span class="linkspan" onclick="openWebsite()">https://BarRaider.github.io</span> </summary>
</details>
<div type="textarea" class="sdpi-item" id="inputText_div">
<div class="sdpi-item-label">Text</div>
<span class="sdpi-item-value textarea">
<textarea type="textarea" oninput="updateSettings()" id="inputText"></textarea>
<textarea type="textarea" oninput="setSettings()" class="sdProperty" id="inputText"></textarea>
</span>
</div>
<div type="checkbox" class="sdpi-item" id="RealEnter">
<div class="sdpi-item-label">Enter key</div>
<div class="sdpi-item-value">
<input id="enterMode" type="checkbox" value="" oninput="updateSettings()">
<input id="enterMode" type="checkbox" value="" class="sdProperty sdCheckbox" oninput="setSettings()">
<label for="enterMode" class="sdpi-item-label"><span></span>Secondary behaviour for ENTER key</label>
</div>
</div>
<div type="range" class="sdpi-item" id="delay_div">
<div class="sdpi-item-label">Delay (ms)</div>
<div class="sdpi-item-value">
<input type="range" min="1" max="2000" value="1" oninput="updateSettings()" id="delay">
<input type="range" min="1" max="2000" value="1" class="sdProperty" oninput="setSettings()" id="delay">
</div>
</div>
<div type="range" class="sdpi-item">
Expand All @@ -40,6 +40,6 @@
</div>


<script src="../Index.js"></script>
<script src="../sdtools.common.js"></script>
</body>
</html>
6 changes: 6 additions & 0 deletions DelayedText/PropertyInspector/sdpi.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.linkspan {
cursor: pointer;
color: #7397d2;
text-decoration: underline;
}

html {
--sdpi-bgcolor: #2D2D2D;
--sdpi-background: #3D3D3D;
Expand Down
Loading

0 comments on commit 160659b

Please sign in to comment.