Skip to content

Commit

Permalink
Fixed debug argument check causing a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
BitesizedLion committed Dec 21, 2022
1 parent d3115dd commit 3788ba1
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 6 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal static class Program
[STAThread]
static void Main(string[] args)
{
if (args[0].ToLower() == "--debug") AttachConsole(ATTACH_PARENT_PROCESS);
if (args.Length != 0 && args[0]?.ToLower() == "--debug") AttachConsole(ATTACH_PARENT_PROCESS);

Console.SetOut(new PrefixedWriter());
Console.WriteLine("\n Init"); // Lazy fix to ensure it logs on new line
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.2")]
[assembly: AssemblyFileVersion("1.1.1.2")]
[assembly: AssemblyVersion("1.1.2.3")]
[assembly: AssemblyFileVersion("1.1.2.3")]
75 changes: 72 additions & 3 deletions Utils.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TidalRPC
{
Expand Down Expand Up @@ -73,5 +70,77 @@ public override void Write(string message)
originalOut.Write(string.Format("[{0}] {1}", DateTime.Now, message));
}
}

public static class RegistryManager // i know technically they arent keys
{
//public static object GetKeyValue(string valueName)
//{
// string keyName = "SOFTWARE\\TidalRPC\\Settings";

// using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName))
// {
// if (key == null) return null;

// return key.GetValue(valueName, 0);
// }
//}

//public static void SetKeyValue(string valueName, object value, RegistryValueKind type)
//{
// string keyName = "SOFTWARE\\TidalRPC\\Settings";

// RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName, true);
// if (key == null)
// {
// // Create the registry key if it does not exist
// key = Registry.CurrentUser.CreateSubKey(keyName);
// }

// key.SetValue(valueName, value, type);
//}

//// This method fetches the value of a registry key and returns true if the value is 1, and false if the value is 0
//public static bool IsRegistryKeyEnabled(string valueName, bool fallback)
//{
// string keyName = "SOFTWARE\\TidalRPC\\Settings";

// using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName))
// {
// if (key == null)
// {
// ToggleRegistryKey(fallback);
// return fallback;
// }

// return (int)key.GetValue(valueName, 0) != 0;
// }
//}
//public static bool IsRegistryKeyEnabled(string valueName)
//{
// string keyName = "SOFTWARE\\TidalRPC\\Settings";

// using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName))
// {
// if (key != null) return true;

// return (int)key.GetValue(valueName, 0) != 0;
// }
//}

//// This method sets a specified registry key to the provided boolean value (but as 0 or 1)
//public static void ToggleRegistryKey(string valueName)
//{
// string keyName = "SOFTWARE\\TidalRPC\\Settings";

// RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName, true);
// if (key == null)
// {
// // Create the registry key if it does not exist
// key = Registry.CurrentUser.CreateSubKey(keyName);
// }

// key.SetValue(valueName, Convert.ToInt32(!IsRegistryKeyEnabled(valueName)), RegistryValueKind.DWord);
//}
}
}
}

0 comments on commit 3788ba1

Please sign in to comment.