forked from dexyfex/CodeWalker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSettingsFile.cs
More file actions
73 lines (66 loc) · 2.16 KB
/
SettingsFile.cs
File metadata and controls
73 lines (66 loc) · 2.16 KB
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace CodeWalker.ModManager
{
public class SettingsFile : SimpleKvpFile
{
public string GameFolder;
public bool IsGen9;
public string AESKey;
public string GameName => GameFolderOk ? IsGen9 ? "GTAV (Enhanced)" : "GTAV (Legacy)" : "(None selected)";
public string GameTitle => IsGen9 ? "GTAV Enhanced" : "GTAV Legacy";
public string GameExeName => IsGen9 ? "gta5_enhanced.exe" : "gta5.exe";
public string GameExePath => $"{GameFolder}\\{GameExeName}";
public string GameModCache => IsGen9 ? "GTAVEnhanced" : "GTAVLegacy";
public bool GameFolderOk
{
get
{
if (Directory.Exists(GameFolder) == false) return false;
if (File.Exists(GameExePath) == false) return false;
return true;
}
}
public SettingsFile()
{
FileName = "CodeWalker.ModManager.ini";
OnlySaveIfFileExists = true;//only try and overwrite an existing settings file, as it is used to check if the exe is running in the correct directory!
try
{
FilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), FileName);
Load();
}
catch (Exception ex)
{
FileError = ex;
}
}
public override void Load()
{
base.Load();
GameFolder = GetItem("GameFolder");
bool.TryParse(GetItem("IsGen9"), out IsGen9);
AESKey = GetItem("AESKey");
}
public override void Save()
{
Items.Clear();
SetItem("GameFolder", GameFolder);
SetItem("IsGen9", IsGen9.ToString());
SetItem("AESKey", AESKey);
base.Save();
}
public void Reset()
{
GameFolder = null;
IsGen9 = false;
AESKey = null;
Save();
}
}
}