-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModOptions.cs
More file actions
150 lines (145 loc) · 7.4 KB
/
Copy pathModOptions.cs
File metadata and controls
150 lines (145 loc) · 7.4 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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using Fasterflect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TABModLoader;
namespace TABHelperMod
{
internal class ModOptions
{
public enum FuncConfigList
{
KeepDisplayAllLifeMeters,
AutoGoWatchTower,
AutoGoWatchTowerRadius,
NumpadFilterVeteran,
GameSpeedChange,
FilterVeteranUnit,
AutoFindBonusItem,
AutoDisperse,
FastAttack,
OptimizeTrainingSequence,
DestroyAllSelectedUnits,
GameMenuEnhancer,
OptimizeAttackPriority,
CancelResearchAnytime,
DisableAutoSave,
AutoSaveInterval,
MaxSaveBackup,
AutoDeleteBackups,
EnhancedSelection,
DeselectUnitsAfterTowerSearch,
BatchCancelCommand,
QuickBuyResource,
QuickBuyResourceDelay
}
public bool KeepDisplayAllLifeMeters { get; set; } = true;
public bool AutoGoWatchTower { get; set; } = true;
public int AutoGoWatchTowerRadius { get; set; } = 10;
public bool NumpadFilterVeteran { get; set; } = true;
public bool GameSpeedChange { get; set; } = true;
public bool FilterVeteranUnit { get; set; } = true;
public bool AutoFindBonusItem { get; set; } = true;
public bool AutoDisperse { get; set; } = false;
public bool FastAttack { get; set; } = false;
public bool OptimizeTrainingSequence { get; set; } = true;
public bool DestroyAllSelectedUnits { get; set; } = true;
public bool GameMenuEnhancer { get; set; } = true;
public bool OptimizeAttackPriority { get; set; } = false;
public bool CancelResearchAnytime { get; set; } = false;
public bool DisableAutoSave { get; set; } = false;
public int AutoSaveInterval { get; set; } = 1200;
public int MaxSaveBackup { get; set; } = 5;
public bool AutoDeleteBackups { get; set; } = true;
public bool EnhancedSelection { get; set; } = true;
public bool DeselectUnitsAfterTowerSearch { get; set; } = true;
public bool BatchCancelCommand { get; set; } = true;
public bool QuickBuyResource { get; set; } = true;
public int QuickBuyResourceDelay { get; set; } = 100;
public static ModOptions Instance { get; } = new ModOptions();
private bool IsLoaded = false;
public void Load(ModInfos modInfos)
{
if (IsLoaded)
return;
IsLoaded = true;
EasySharpIni.IniFile ini;
//判断路径和文件是否存在,不存在则创建
string path;
if (modInfos.SteamID > 0)
path = "Mods/ModData/" + modInfos.SteamID + "/TABHelperMod.ini";
else
path = "Mods/ModData/TAB Helper/TABHelperMod.ini";
if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(path)))
{
System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path));
}
ini = new EasySharpIni.IniFile(path);
ini.AddField("KeepDisplayAllLifeMeters", "true", "true");
ini.AddField("AutoGoWatchTower", "true", "true");
ini.AddField("AutoGoWatchTowerRadius", "10", "10");
ini.AddField("NumpadFilterVeteran", "true", "true");
ini.AddField("GameSpeedChange", "true", "true");
ini.AddField("FilterVeteranUnit", "true", "true");
ini.AddField("AutoFindBonusItem", "true", "true");
ini.AddField("AutoDisperse", "false", "false");
ini.AddField("FastAttack", "false", "false");
ini.AddField("OptimizeTrainingSequence", "true", "true");
ini.AddField("DestroyAllSelectedUnits", "true", "true");
ini.AddField("GameMenuEnhancer", "true", "true");
ini.AddField("OptimizeAttackPriority", "false", "false");
ini.AddField("CancelResearchAnytime", "false", "false");
ini.AddField("DisableAutoSave", "false", "false");
ini.AddField("AutoSaveInterval", "1200", "1200");
ini.AddField("MaxSaveBackup", "5", "5");
ini.AddField("AutoDeleteBackups", "true", "true");
ini.AddField("EnhancedSelection", "true", "true");
ini.AddField("DeselectUnitsAfterTowerSearch", "true", "true");
ini.AddField("BatchCancelCommand", "true", "true");
ini.AddField("QuickBuyResource", "true", "true");
ini.AddField("QuickBuyResourceDelay", "100", "100");
if (!System.IO.File.Exists(path))
{
ini.Write();
}
else
{
var ini2 = new EasySharpIni.IniFile(path).Parse();
foreach (var fieldName in Enum.GetNames(typeof(FuncConfigList)))
{
if (ini2.GetField(fieldName) == "")
{
ini2.AddField(fieldName, ini.GetField(fieldName).Get(), ini.GetField(fieldName).Get());
}
}
ini2.Write();
ini = new EasySharpIni.IniFile(path).Parse();
}
KeepDisplayAllLifeMeters = bool.Parse(ini.GetField("KeepDisplayAllLifeMeters", "true").Get());
AutoGoWatchTower = bool.Parse(ini.GetField("AutoGoWatchTower", "true").Get());
AutoGoWatchTowerRadius = int.Parse(ini.GetField("AutoGoWatchTowerRadius", "10").Get());
NumpadFilterVeteran = bool.Parse(ini.GetField("NumpadFilterVeteran", "true").Get());
GameSpeedChange = bool.Parse(ini.GetField("GameSpeedChange", "true").Get());
FilterVeteranUnit = bool.Parse(ini.GetField("FilterVeteranUnit", "true").Get());
AutoFindBonusItem = bool.Parse(ini.GetField("AutoFindBonusItem", "true").Get());
AutoDisperse = bool.Parse(ini.GetField("AutoDisperse", "false").Get());
FastAttack = bool.Parse(ini.GetField("FastAttack", "false").Get());
OptimizeTrainingSequence = bool.Parse(ini.GetField("OptimizeTrainingSequence", "true").Get());
DestroyAllSelectedUnits = bool.Parse(ini.GetField("DestroyAllSelectedUnits", "true").Get());
GameMenuEnhancer = bool.Parse(ini.GetField("GameMenuEnhancer", "true").Get());
OptimizeAttackPriority = bool.Parse(ini.GetField("OptimizeAttackPriority", "false").Get());
CancelResearchAnytime = bool.Parse(ini.GetField("CancelResearchAnytime", "false").Get());
DisableAutoSave = bool.Parse(ini.GetField("DisableAutoSave", "false").Get());
AutoSaveInterval = int.Parse(ini.GetField("AutoSaveInterval", "1200").Get());
MaxSaveBackup = int.Parse(ini.GetField("MaxSaveBackup", "5").Get());
AutoDeleteBackups = bool.Parse(ini.GetField("AutoDeleteBackups", "true").Get());
EnhancedSelection = bool.Parse(ini.GetField("EnhancedSelection", "true").Get());
DeselectUnitsAfterTowerSearch = bool.Parse(ini.GetField("DeselectUnitsAfterTowerSearch", "true").Get());
BatchCancelCommand = bool.Parse(ini.GetField("BatchCancelCommand", "true").Get());
QuickBuyResource = bool.Parse(ini.GetField("QuickBuyResource", "true").Get());
QuickBuyResourceDelay = int.Parse(ini.GetField("QuickBuyResourceDelay", "100").Get());
}
}
}