Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Commit

Permalink
Import hack_config for Ishiiruka
Browse files Browse the repository at this point in the history
  • Loading branch information
SirMangler committed Dec 1, 2019
1 parent 284987d commit ac52ce0
Showing 1 changed file with 103 additions and 106 deletions.
209 changes: 103 additions & 106 deletions PrimeHack Updater/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace PrimeHack_Updater
{
class Updater
{
static string sysversion = "1.5.5";
static string sysversion = "1.5.6";
static CfgManager cfg = new CfgManager();

[DllImport("kernel32.dll", SetLastError = true)]
Expand All @@ -40,7 +40,7 @@ static void Main(string[] args)
}
}

portableMode();
migrate();

string repo;
if (cfg.isMainBranch())
Expand Down Expand Up @@ -192,129 +192,126 @@ public static DialogResult STAShowDialog(FileDialog dialog)
}

static string DE = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Documents\Dolphin Emulator\");
public static void portableMode()
public static void migrate()
{
string primesettings = "";
bool beam = false;

if (cfg.isMainBranch())
if (File.Exists("hack_config.ini"))
{
if (File.Exists("hack_config.ini"))
Console.WriteLine("Importing PrimeHack settings");
foreach (string line in File.ReadLines("hack_config.ini"))
{
Console.WriteLine("Importing PrimeHack settings");
foreach (string line in File.ReadLines("hack_config.ini"))
if (line.StartsWith("[beam]"))
{
if (line.StartsWith("[beam]"))
{
beam = true;
continue;
}

if (line.StartsWith("[visor]"))
{
beam = false;
continue;
}

if (line.StartsWith("sensitivity"))
{
primesettings += "PrimeHack/Camera Sensitivity = " + line.Replace("sensitivity = ", "") + "\n";
continue;
}

if (line.StartsWith("cursor_sensitivity"))
{
primesettings += "PrimeHack/Cursor Sensitivity = " + line.Replace("cursor_sensitivity = ", "") + "\n";
continue;
}

if (line.StartsWith("fov"))
{
primesettings += "PrimeHack/Field of View = " + line.Replace("fov = ", "") + "\n";
continue;
}

if (line.StartsWith("inverted_y"))
{
primesettings += "PrimeHack/Invert Y axis = " + line.Replace("inverted_y = ", "") + "\n";
continue;
}

String nline;

if (line.StartsWith("index_0"))
{
if (beam)
nline = "PrimeHack/Beam 1 = " + line.Replace("index_0 = ", "");
else
nline = "PrimeHack/Visor 1 = " + line.Replace("index_0 = ", "");

primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n";

continue;
}

if (line.StartsWith("index_1"))
{
if (beam)
nline = "PrimeHack/Beam 2 = " + line.Replace("index_1 = ", "");
else
nline = "PrimeHack/Visor 2 = " + line.Replace("index_1 = ", "");

primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n";

continue;
}

if (line.StartsWith("index_2"))
{
if (beam)
nline = "PrimeHack/Beam 3 = " + line.Replace("index_2 = ", "");
else
nline = "PrimeHack/Visor 3 = " + line.Replace("index_2 = ", "");

primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n";

continue;
}

if (line.StartsWith("index_3"))
{
if (beam)
nline = "PrimeHack/Beam 4 = " + line.Replace("index_3 = ", "");
else
nline = "PrimeHack/Visor 4 = " + line.Replace("index_3 = ", "");

primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n";

continue;
}
beam = true;
continue;
}

String config = DE + "\\Config\\WiimoteNew.ini";
if (!File.Exists(config))
if (line.StartsWith("[visor]"))
{
FileStream f = File.Create(config);
f.Close();
beam = false;
continue;
}

primesettings = "[Wiimote1]\n" + primesettings;
if (line.StartsWith("sensitivity"))
{
primesettings += "PrimeHack/Camera Sensitivity = " + line.Replace("sensitivity = ", "") + "\n";
continue;
}

File.WriteAllLines(config, primesettings.Split('\n'));
if (line.StartsWith("cursor_sensitivity"))
{
primesettings += "PrimeHack/Cursor Sensitivity = " + line.Replace("cursor_sensitivity = ", "") + "\n";
continue;
}
else

if (line.StartsWith("fov"))
{
string[] oldwiimotenew = File.ReadAllLines(config);
List<string> newwiimote = new List<string>();
primesettings += "PrimeHack/Field of View = " + line.Replace("fov = ", "") + "\n";
continue;
}

newwiimote.AddRange(oldwiimotenew);
newwiimote.Insert(2, primesettings.Substring(0, primesettings.Length - 1));
if (line.StartsWith("inverted_y"))
{
primesettings += "PrimeHack/Invert Y axis = " + line.Replace("inverted_y = ", "") + "\n";
continue;
}

String nline;

if (line.StartsWith("index_0"))
{
if (beam)
nline = "PrimeHack/Beam 1 = " + line.Replace("index_0 = ", "");
else
nline = "PrimeHack/Visor 1 = " + line.Replace("index_0 = ", "");

File.WriteAllLines(config, newwiimote.ToArray());
primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n";

continue;
}

File.Delete(".\\hack_config.ini");
if (line.StartsWith("index_1"))
{
if (beam)
nline = "PrimeHack/Beam 2 = " + line.Replace("index_1 = ", "");
else
nline = "PrimeHack/Visor 2 = " + line.Replace("index_1 = ", "");

primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n";

continue;
}

if (line.StartsWith("index_2"))
{
if (beam)
nline = "PrimeHack/Beam 3 = " + line.Replace("index_2 = ", "");
else
nline = "PrimeHack/Visor 3 = " + line.Replace("index_2 = ", "");

primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n";

continue;
}

if (line.StartsWith("index_3"))
{
if (beam)
nline = "PrimeHack/Beam 4 = " + line.Replace("index_3 = ", "");
else
nline = "PrimeHack/Visor 4 = " + line.Replace("index_3 = ", "");

primesettings += Regex.Replace(nline, "\b&\b", " & ") + "\n";

continue;
}
}

String config = DE + "\\Config\\WiimoteNew.ini";
if (!File.Exists(config))
{
FileStream f = File.Create(config);
f.Close();

primesettings = "[Wiimote1]\n" + primesettings;

File.WriteAllLines(config, primesettings.Split('\n'));
}
}
else
{
string[] oldwiimotenew = File.ReadAllLines(config);
List<string> newwiimote = new List<string>();

newwiimote.AddRange(oldwiimotenew);
newwiimote.Insert(2, primesettings.Substring(0, primesettings.Length - 1));

File.WriteAllLines(config, newwiimote.ToArray());
}

File.Delete(".\\hack_config.ini");
}
}

public static void runPrimeHack(string[] args)
Expand Down

0 comments on commit ac52ce0

Please sign in to comment.