-
Notifications
You must be signed in to change notification settings - Fork 3
/
Main.cs
110 lines (84 loc) · 3.8 KB
/
Main.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
using System.Reflection;
namespace PhValheim
{
public class PhValheim
{
static void Main(string[] args)
{
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
var phvalheimLauncherVersion = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute> ().InformationalVersion;
string[] argumentsPassed = Array.Empty<string>();
string command = "";
string worldName = "";
string worldPassword = "";
string worldHost = "";
string worldPort = "";
string texturePack = "";
string phvalheimHost = "";
string phvalheimURL = "";
string httpScheme = "";
string phvalheimHostNoPort;
//take in and process all arguments from our URL handler
if (!Arguments.PhValheim.argHandler(ref args, ref argumentsPassed, ref command, ref worldName, ref worldPassword, ref worldHost, ref worldPort, ref texturePack, ref phvalheimHost, ref httpScheme))
{
Console.WriteLine("\n");
Console.WriteLine("Press Enter key to exit.");
Console.ReadLine();
return;
}
else
{
phvalheimURL = httpScheme + "://" + phvalheimHost;
string[] phvalheimHostNoPortArr = phvalheimHost.Split(':', StringSplitOptions.TrimEntries);
phvalheimHostNoPort = phvalheimHostNoPortArr[0];
Console.WriteLine("\n## PhValheim Launcher " + phvalheimLauncherVersion + " ##\n");
Console.WriteLine("PhValheim Remote Server: " + phvalheimURL);
if (!Platform.State.init(worldName, phvalheimHostNoPort)) {
Console.WriteLine("\n");
Console.WriteLine("Press Enter key to exit.");
Console.ReadLine();
return;
}
}
//we're launching
if (command == "launch")
{
//check client version
Ver.PhValheim.VersionCheck(phvalheimLauncherVersion);
//run through the PhValheim prep logic, exit if fails
if (!Prep.PhValheim.PhValheimPrep())
{
Console.WriteLine("\n");
Console.WriteLine("Press the Enter key to exit.");
Console.ReadLine();
return;
}
//get our Valheim installation directory, exit if fails
if (!Steam.PhValheim.ValheimGetter())
{
Console.WriteLine("\n");
Console.WriteLine("Press the Enter key to exit.");
Console.ReadLine();
return;
}
//sync world to local disk
if (!Syncer.PhValheim.Sync(phvalheimURL))
{
Console.WriteLine("\n");
Console.WriteLine("Press the Enter key to exit.");
Console.ReadLine();
return;
}
//write backend info to local file
Prep.PhValheim.WriteBackendFile(worldName, phvalheimHostNoPort, phvalheimURL);
//launch the game in the world context
Launcher.PhValheim.Launch(ref worldPassword, ref worldHost, ref worldPort);
//keep everything on the screen allowing you to read what just happend
Console.WriteLine("\n");
Console.WriteLine("This window will automatically close in 10 seconds...");
Thread.Sleep(10000);
return;
}
}
}
}