-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
111 lines (95 loc) · 4.33 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using ArcNET.Utilities;
using Spectre.Console;
using System;
using System.IO;
using System.Linq;
using Utils.Console;
using Utils.Device;
using Utils.Process;
namespace ArcNET.Terminal
{
internal static class Program
{
private static string GetHighResDir()
{
string pathToArcDir = AnsiConsole.Ask<string>("[green]Insert path to Arcanum dir[/]:");
string pathToHighResDir = Path.Combine(pathToArcDir + "\\HighRes");
while (!Directory.Exists(pathToHighResDir))
{
ConsoleExtensions.Log("HighRes dir not found!", "error");
pathToArcDir = AnsiConsole.Ask<string>("[green]Insert path to Arcanum dir again[/]:");
pathToHighResDir = Path.Combine(pathToArcDir + "\\HighRes");
}
return pathToHighResDir;
}
private static void LaunchWeidu(string launchArgs, string pathToDir = "")
{
string dirPath = string.IsNullOrEmpty(pathToDir) ? GetHighResDir() : pathToDir;
string procPath = Path.Combine(dirPath + "\\weidu.exe");
if (!File.Exists(procPath))
throw new InvalidOperationException($"weidu.exe file not found at path: {procPath}");
Launcher launcher;
switch (launchArgs)
{
case CmdArgs.Weidu.InstallHighResPatch:
launcher = new Launcher(procPath, CmdArgs.Weidu.InstallHighResPatch);
launcher.Launch();
break;
case CmdArgs.Weidu.UninstallHighResPatch:
launcher = new Launcher(procPath, CmdArgs.Weidu.UninstallHighResPatch);
launcher.Launch();
break;
default:
throw new InvalidOperationException($"Unknown launch arguments: {launchArgs}");
}
}
private static void Main()
{
Terminal.RenderLogo();
string choice = Terminal.GetMainMenuChoice();
ConsoleExtensions.Log($"Selected choice: {choice}", "info");
switch (choice)
{
case "Extract game data":
ConsoleExtensions.Log($"Choice: {choice} is currently unsupported!", "error");
break;
case "Parse extracted game data":
Parser.ParseExtractedData();
break;
case "Install High-Res patch":
string pathToHighResDir = GetHighResDir();
var files = Directory.EnumerateFiles(
pathToHighResDir, "*.*", SearchOption.AllDirectories).ToList();
if (files.Count == 0)
{
ConsoleExtensions.Log("HighResFolder empty proceeding to clone latest version", "info");
GitHub.CloneHighResPatch(pathToHighResDir);
}
string configPath = Path.Combine(pathToHighResDir + "\\config.ini");
if (!File.Exists(configPath))
throw new InvalidOperationException($"Config file not found at path: {configPath}");
ConsoleExtensions.Log("Gathering environment info", "info");
var envInfo = new EnvironmentInfo();
envInfo.Print();
ConsoleExtensions.Log("Auto-config according to environment info", "info");
HighResConfig.AutoConfigure(envInfo);
ConsoleExtensions.Log("Summary of config.ini:", "info");
AnsiConsole.Write(Terminal.ConfigTable());
if (AnsiConsole.Confirm("Would you like to change config?"))
{
AnsiConsole.WriteException(new NotImplementedException());
return;
}
HighResConfig.Write(configPath);
LaunchWeidu(CmdArgs.Weidu.InstallHighResPatch, pathToHighResDir);
break;
case "Uninstall High-Res patch":
LaunchWeidu(CmdArgs.Weidu.UninstallHighResPatch);
break;
default:
ConsoleExtensions.Log($"Choice: {choice} is currently unsupported!", "error");
break;
}
}
}
}