-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
43 lines (40 loc) · 1.58 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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows;
namespace CitiesSkylinesLauncher
{
class Program
{
static void Main(string[] args)
{
var gameDirIndex = Array.IndexOf(args, "--gameDir");
if (gameDirIndex == -1)
{
var pathFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Paradox Interactive\launcherpath");
Directory.CreateDirectory(Path.GetDirectoryName(pathFile));
File.WriteAllText(pathFile, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\\n");
MessageBox.Show("Launcher path set.\n\nStart the game as usual.", "", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
var gameDir = args[gameDirIndex + 1];
var json = new JavaScriptSerializer();
var settings = json.Deserialize<LauncherSettings>(File.ReadAllText(Path.Combine(gameDir, "launcher-settings.json")));
var argList = new List<string>(args);
argList.RemoveRange(gameDirIndex, 2);
Process.Start(Path.Combine(gameDir, settings.exePath), string.Join(" ", argList));
}
}
}
class LauncherSettings
{
public string exePath { get; set; }
}
}