Skip to content

Commit

Permalink
Adding manual paste support, also adding standalone version of exe
Browse files Browse the repository at this point in the history
  • Loading branch information
NotBoogie committed Jul 7, 2021
1 parent 30398bb commit ee00db4
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions SaiThemeColorChanger/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace SaiThemeColorChanger
{
Expand All @@ -24,18 +22,24 @@ public ReplacerHelper(string search, string replace)
static void Main(string[] args)
{
string inputPath = "";
if(args.Length>0)
if (args.Length > 0)
inputPath = args[0];

if (inputPath.Length == 0)
{
Console.Out.WriteLine("Drag the sai2.exe file onto this exe, don't forget to make a backup of the sai executable!");
Console.ReadKey();
return;
System.Console.Out.WriteLine("Drag the sai2.exe file onto this exe, or just paste its full path into here: ");
inputPath = System.Console.ReadLine();
while (!Directory.Exists(Path.GetDirectoryName(inputPath)))
{
System.Console.Out.WriteLine("Not a valid path: " + inputPath);
inputPath = System.Console.ReadLine();
}
}

if (!Directory.Exists(Path.GetDirectoryName(inputPath)))
{
Console.Out.WriteLine("Not a valid path: " + inputPath);
Console.ReadKey();
System.Console.Out.WriteLine("Not a valid path: " + inputPath);
System.Console.ReadKey();
return;
}

Expand All @@ -56,13 +60,13 @@ static void Main(string[] args)
toReplace.Add(new ReplacerHelper("b0b0b0", "646464")); //Active canvas background
toReplace.Add(new ReplacerHelper("E0E0E0", "646464")); //Tools panel background

Console.Out.WriteLine("Making a backup copy of: " + inputPath);
System.Console.Out.WriteLine("Making a backup copy of: " + inputPath);
makeCopy(inputPath);
Console.Out.WriteLine("Replacing stuff in: " + inputPath);
System.Console.Out.WriteLine("Replacing stuff in: " + inputPath);
replaceHex(inputPath, outputPath, toReplace);
Console.Out.WriteLine("Replaced file saved to: " + outputPath);
Console.Out.WriteLine("Finished");
Console.ReadKey();
System.Console.Out.WriteLine("Replaced file saved to: " + outputPath);
System.Console.Out.WriteLine("Finished");
System.Console.ReadKey();
}

//Fuggin fug fug
Expand All @@ -72,7 +76,7 @@ public static byte[] GetByteArray(string str)
//https://stackoverflow.com/questions/321370/how-can-i-convert-a-hex-string-to-a-byte-array
return Enumerable.Range(0, str.Length)
.Where(x => x % 2 == 0)
.Select(x => Convert.ToByte(str.Substring(x, 2), 16))
.Select(x => System.Convert.ToByte(str.Substring(x, 2), 16))
.ToArray();
}

Expand All @@ -82,11 +86,11 @@ public static void makeCopy(string path)
if (!File.Exists(targetPath))
{
File.Copy(path, targetPath);
Console.Out.WriteLine("Backup copy generated in " + targetPath);
System.Console.Out.WriteLine("Backup copy generated in " + targetPath);
}
else
{
Console.Out.WriteLine("Backup copy already exists in " + targetPath);
System.Console.Out.WriteLine("Backup copy already exists in " + targetPath);
}
}

Expand Down

0 comments on commit ee00db4

Please sign in to comment.