Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
LumKitty committed Jan 18, 2025
1 parent 1b87c63 commit ec2a80b
Show file tree
Hide file tree
Showing 7 changed files with 362 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Debug-Console/Debug-Console.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
string Version = "0.1-alpha";
Console.Title = "LumKitty's Debug console v" + Version;
Console.WriteLine("LumKitty's Debug console v"+Version+" - https://github.com/LumKitty - https://twitch.tv/LumKitty");
String LineInput;
while (true)
{
LineInput = Console.ReadLine();
if (LineInput != null)
{
if (LineInput.Length >= 4)
{
switch (LineInput.Substring(0,4))
{
case "LOG:":
Console.ForegroundColor = ConsoleColor.Yellow;
break;
case "ERR:":
Console.ForegroundColor = ConsoleColor.Red;
break;
case "TRG:":
Console.ForegroundColor = ConsoleColor.Cyan;
break;
}
}
Console.WriteLine(LineInput);
Console.ForegroundColor = ConsoleColor.White;
}
}
15 changes: 15 additions & 0 deletions Debug-Console/Debug-Console.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Debug_Console</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Platforms>x64</Platforms>
</PropertyGroup>

</Project>
215 changes: 215 additions & 0 deletions Debug-Plugin/Debug-Plugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.NetworkInformation;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine;
using UnityEngine.XR;
using static UnityEngine.Networking.UnityWebRequest;

namespace Debug_Plugin
{
public class Debug_Plugin : MonoBehaviour, VNyanInterface.IButtonClickedHandler, VNyanInterface.ITriggerHandler
{
private string ErrorFile = "";
string TriggersFile = VNyanInterface.VNyanInterface.VNyanSettings.getProfilePath() + "Lum-Debug-Triggers.txt";
private string LogFile = "";
private string Version = "0.1-alpha";
private string ConsolePath = "";
private StreamWriter DebugStreamWriter = null;
private Process DebugProcess = null;
dynamic SettingsJSON;
List<String> MonitorTriggers;
private void Log(string message)
{
if (LogFile.ToString().Length > 0)
{
System.IO.File.AppendAllText(LogFile, message + "\r\n");
}
if (DebugStreamWriter != null)
{
DebugStreamWriter.WriteLine(message);
}
}

private void LoadPluginSettings()
{
// Get settings in dictionary
Dictionary<string, string> settings = VNyanInterface.VNyanInterface.VNyanSettings.loadSettings("Lum-Debug.cfg");
if (settings != null)
{
string temp_ErrorFile;
string temp_LogFile;
settings.TryGetValue("ErrorFile", out temp_ErrorFile);
settings.TryGetValue("LogFile", out temp_LogFile);
if (temp_ErrorFile != null)
{
ErrorFile = temp_ErrorFile;
}
else
{
ErrorFile = System.IO.Path.GetTempPath() + "\\Lum_DBG_Error.txt";
}
if (temp_LogFile != null)
{
LogFile = temp_LogFile;
}
else
{
LogFile = System.IO.Path.GetTempPath() + "\\Lum_DBG_Log.txt";
}
}
/*if (File.Exists(TriggersFile))
{
String[] Triggers = File.ReadLines(TriggersFile).ToString().Split('\n');
foreach (string Trigger in Triggers) {
MonitorTriggers.Add(Trigger.ToString());
}
}*/

}
private void OnApplicationQuit()
{
// Save settings
SavePluginSettings();
}
private void SavePluginSettings()
{
Dictionary<string, string> settings = new Dictionary<string, string>();
settings["ErrorFile"] = ErrorFile;
settings["LogFile"] = LogFile;
// settings["SomeValue2"] = someValue2.ToString(CultureInfo.InvariantCulture); // Make sure to use InvariantCulture to avoid decimal delimeter errors

VNyanInterface.VNyanInterface.VNyanSettings.saveSettings("Lum-Debug.cfg", settings);
//File.WriteAllText(JsonFile, SettingsJSON.ToString());
}

void ErrorHandler(Exception e)
{
System.IO.File.WriteAllText(ErrorFile, e.ToString());
CallVNyan("_lum_miu_error", 0, 0, 0, e.ToString(), "", "");
}
void CallVNyan(string TriggerName, int int1, int int2, int int3, string Text1, string Text2, string Text3)
{
if (TriggerName.Length > 0)
{
Log("Calling " + TriggerName + " with " + int1.ToString() + ", " + int2.ToString() + ", " + int3.ToString() + ", " + Text1 + ", " + Text2 + ", " + Text3);
VNyanInterface.VNyanInterface.VNyanTrigger.callTrigger(TriggerName, int1, int2, int3, Text1, Text2, Text3);
}
else
{
Log("Invalid trigger name");
}
}
public void Awake()
{
try
{
VNyanInterface.VNyanInterface.VNyanTrigger.registerTriggerListener(this);
VNyanInterface.VNyanInterface.VNyanUI.registerPluginButton("LumKitty's Debug Tool", this);
LoadPluginSettings();
System.IO.File.WriteAllText(LogFile, "Started v"+Version+"\r\n");
string CommandLine = Environment.CommandLine;
if (CommandLine[0] == '"')
{
int n = CommandLine.IndexOf('"', 1);
CommandLine = CommandLine.Substring(1, n - 1);
} else
{
CommandLine = CommandLine.Substring(0,CommandLine.IndexOf(" "));
}
Log("VNyan path: " + CommandLine);
ConsolePath = Path.GetDirectoryName(CommandLine) + "\\Items\\Assemblies\\Debug-Console.exe";
if (File.Exists(ConsolePath))
{
Log("Debug Console found at: " + ConsolePath);
} else
{
Log("Debug Console not found should be at: " + ConsolePath);
}
}
catch (Exception e)
{
ErrorHandler(e);
}
}
public void triggerCalled(string name, int int1, int int2, int int3, string text1, string text2, string text3)
{
try
{
if (name.Length > 10)
{
if (name.Substring(0, 9) == "_lum_dbg_")
{
//Log("Detected trigger: " + name + " with " + int1.ToString() + ", " + SessionID.ToString() + ", " + PlatformID.ToString() + ", " + text1 + ", " + text2 + ", " + Callback);
switch (name.Substring(8))
{
case "_log":
Log("LOG: " + int1.ToString() + ", " + int2.ToString() + ", " + int3.ToString() + "|" + text1 + "|" + text2 + "|" + text3);
break;
case "_err":
Log("ERR: " + int1.ToString() + ", " + int2.ToString() + ", " + int3.ToString() + "|" + text1 + "|" + text2 + "|" + text3);
break;
// Log("Detected: " + name + " with " + int1.ToString() + ", " + int2.ToString() + ", " + int3.ToString() + ", " + text1 + ", " + text2 + ", " + text3);
}
}
}
/*if (MonitorTriggers.Contains(name)) {
Log("TRG: " +name+"|"+ int1.ToString() + ", " + int2.ToString() + ", " + int3.ToString() + "|" + text1 + "|" + text2 + "|" + text3);
}*/
}
catch (Exception e)
{
ErrorHandler(e);
}
}
async Task RunDebugProcess()
{
using (DebugProcess = new Process())
{
DebugProcess.StartInfo.FileName = ConsolePath;
DebugProcess.StartInfo.UseShellExecute = false;
DebugProcess.StartInfo.RedirectStandardInput = true;
DebugProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
DebugProcess.StartInfo.CreateNoWindow = false;
DebugProcess.EnableRaisingEvents = true;
DebugProcess.Start();
DebugStreamWriter = DebugProcess.StandardInput;
DebugStreamWriter.WriteLine("Connected to plugin v"+Version);
DebugStreamWriter.WriteLine("Checking for triggers: " + MonitorTriggers.ToString());
DebugProcess.WaitForExit();
DebugStreamWriter.Close();
DebugStreamWriter.Dispose();
DebugStreamWriter = null;
DebugProcess.Dispose();
DebugProcess = null;
Log("Monitoring process terminated");
}
}

public void pluginButtonClicked()
{
if (DebugProcess == null)
{
Log("The button was pressed!");
Task.Run(() => RunDebugProcess());

} else
{
Log("The button was pressed again!");
}
}
}
}
23 changes: 23 additions & 0 deletions Debug-Plugin/Debug-Plugin.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Debug_Plugin</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Linq" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<Reference Include="UnityEngine">
<HintPath>C:\Program Files\Unity\Hub\Editor\2020.3.40f1\Editor\Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="VNyanInterface">
<HintPath>..\..\..\Twitch\Software\VNyan\VNyan_Data\Managed\VNyanInterface.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions Test-Plugin/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// See https://aka.ms/new-console-template for more information
using System.Diagnostics;


StreamWriter DebugStreamWriter = null;
string ConsolePath = "D:\\Twitch\\Software\\VNyan\\Items\\Assemblies\\Debug-Console.exe";
using (Process DebugProcess = new Process())
{
DebugProcess.StartInfo.FileName = ConsolePath;
DebugProcess.StartInfo.UseShellExecute = false;
DebugProcess.StartInfo.RedirectStandardInput = true;
DebugProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
DebugProcess.StartInfo.CreateNoWindow = false;
Console.WriteLine("Starting Process");
DebugProcess.Start();

DebugStreamWriter = DebugProcess.StandardInput;

string text = "lemon";
DebugStreamWriter.WriteLine(text);
text = Console.ReadLine();
}
11 changes: 11 additions & 0 deletions Test-Plugin/Test-Plugin.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Test_Plugin</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
48 changes: 48 additions & 0 deletions VNyan-Debug.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debug-Plugin", "Debug-Plugin\Debug-Plugin.csproj", "{10E13F85-9E2E-4333-A996-A917787B0963}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debug-Console", "Debug-Console\Debug-Console.csproj", "{851A4C34-27C6-4C4B-8A60-FFCBD7A15D80}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test-Plugin", "Test-Plugin\Test-Plugin.csproj", "{34DA4F60-F0C4-4AC5-AE60-C5623BA6E46C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{10E13F85-9E2E-4333-A996-A917787B0963}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10E13F85-9E2E-4333-A996-A917787B0963}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10E13F85-9E2E-4333-A996-A917787B0963}.Debug|x64.ActiveCfg = Debug|Any CPU
{10E13F85-9E2E-4333-A996-A917787B0963}.Debug|x64.Build.0 = Debug|Any CPU
{10E13F85-9E2E-4333-A996-A917787B0963}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10E13F85-9E2E-4333-A996-A917787B0963}.Release|Any CPU.Build.0 = Release|Any CPU
{10E13F85-9E2E-4333-A996-A917787B0963}.Release|x64.ActiveCfg = Release|Any CPU
{10E13F85-9E2E-4333-A996-A917787B0963}.Release|x64.Build.0 = Release|Any CPU
{851A4C34-27C6-4C4B-8A60-FFCBD7A15D80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{851A4C34-27C6-4C4B-8A60-FFCBD7A15D80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{851A4C34-27C6-4C4B-8A60-FFCBD7A15D80}.Debug|x64.ActiveCfg = Release|x64
{851A4C34-27C6-4C4B-8A60-FFCBD7A15D80}.Debug|x64.Build.0 = Release|x64
{851A4C34-27C6-4C4B-8A60-FFCBD7A15D80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{851A4C34-27C6-4C4B-8A60-FFCBD7A15D80}.Release|Any CPU.Build.0 = Release|Any CPU
{851A4C34-27C6-4C4B-8A60-FFCBD7A15D80}.Release|x64.ActiveCfg = Release|x64
{851A4C34-27C6-4C4B-8A60-FFCBD7A15D80}.Release|x64.Build.0 = Release|x64
{34DA4F60-F0C4-4AC5-AE60-C5623BA6E46C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34DA4F60-F0C4-4AC5-AE60-C5623BA6E46C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34DA4F60-F0C4-4AC5-AE60-C5623BA6E46C}.Debug|x64.ActiveCfg = Debug|Any CPU
{34DA4F60-F0C4-4AC5-AE60-C5623BA6E46C}.Debug|x64.Build.0 = Debug|Any CPU
{34DA4F60-F0C4-4AC5-AE60-C5623BA6E46C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34DA4F60-F0C4-4AC5-AE60-C5623BA6E46C}.Release|Any CPU.Build.0 = Release|Any CPU
{34DA4F60-F0C4-4AC5-AE60-C5623BA6E46C}.Release|x64.ActiveCfg = Release|Any CPU
{34DA4F60-F0C4-4AC5-AE60-C5623BA6E46C}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

0 comments on commit ec2a80b

Please sign in to comment.