forked from tukasa0001/TownOfHost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptionController.cs
216 lines (209 loc) · 9.65 KB
/
OptionController.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
using BepInEx;
using BepInEx.Configuration;
using BepInEx.IL2CPP;
using System;
using HarmonyLib;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnhollowerBaseLib;
using TownOfHost;
namespace TownOfHost {
static class CustomOptionController {
public static Dictionary<OptionPages, PageObject> PageObjects = new Dictionary<OptionPages, PageObject>(){
{OptionPages.basepage, new PageObject(
"Town Of Host Options",
false,
() => {},
new List<OptionPages>(){OptionPages.roles, OptionPages.modes},
OptionPages.basepage
)},
{OptionPages.roles, new PageObject(
"Role Options",
false,
() => {SetPage(OptionPages.roles);},
new List<OptionPages>(){
OptionPages.Sidekick,
OptionPages.Vampire,
OptionPages.Madmate,
OptionPages.Jester,
OptionPages.Terrorist,
OptionPages.Bait
},
OptionPages.basepage
)},
{OptionPages.Madmate, new PageObject(
"<color=#ff0000>Madmate</color>: $MadmateEnabled",
true,
() => {main.ToggleRole(EngineerRole.Madmate);},
new List<OptionPages>(){},
OptionPages.roles
)},
{OptionPages.Sidekick, new PageObject(
"<color=#ff0000>Sidekick</color>: $SidekickEnabled",
true,
() => {main.ToggleRole(ShapeshifterRoles.Sidekick);},
new List<OptionPages>(){},
OptionPages.roles
)},
{OptionPages.Vampire, new PageObject(
"<color=#a757a8>Vampire</color>: $VampireEnabled",
true,
() => {main.ToggleRole(ImpostorRoles.Vampire);},
new List<OptionPages>(){},
OptionPages.roles
)},
{OptionPages.Jester, new PageObject(
"<color=#d161a4>Jester</color>: $JesterEnabled",
true,
() => {main.ToggleRole(ScientistRole.Jester);},
new List<OptionPages>(){},
OptionPages.roles
)},
{OptionPages.Terrorist, new PageObject(
"<color=#00ff00>Terrorist</color>: $TerroristEnabled",
true,
() => {main.ToggleRole(EngineerRole.Terrorist);},
new List<OptionPages>(){},
OptionPages.roles
)},
{OptionPages.Bait, new PageObject(
"<color=#00bfff>Bait</color>: $BaitEnabled",
true,
() => {main.ToggleRole(ScientistRole.Bait);},
new List<OptionPages>(){},
OptionPages.roles
)},
{OptionPages.modes, new PageObject(
"Mode Options",
false,
() => {SetPage(OptionPages.modes);},
new List<OptionPages>(){OptionPages.HideAndSeek, OptionPages.DisableTasks, OptionPages.NoGameEnd},
OptionPages.basepage
)},
{OptionPages.HideAndSeek, new PageObject(
"HideAndSeek<BETA>: $HideAndSeekEnabled",
true,
() => {main.IsHideAndSeek = !main.IsHideAndSeek;},
new List<OptionPages>(){},
OptionPages.modes
)},
{OptionPages.DisableTasks, new PageObject(
"Disable Tasks",
false,
() => {SetPage(OptionPages.DisableTasks);},
new List<OptionPages>(){OptionPages.SwipeCard, OptionPages.SubmitScan, OptionPages.UnlockSafe},
OptionPages.modes
)},
{OptionPages.SwipeCard, new PageObject(
"Disable SwipeCard Task: $DisableSwipeCard",
true,
() => {main.DisableSwipeCard = !main.DisableSwipeCard;},
new List<OptionPages>(){},
OptionPages.modes
)},
{OptionPages.SubmitScan, new PageObject(
"Disable SubmitScan Task: $DisableSubmitScan",
true,
() => {main.DisableSubmitScan = !main.DisableSubmitScan;},
new List<OptionPages>(){},
OptionPages.modes
)},
{OptionPages.UnlockSafe, new PageObject(
"Disable UnlockSafe Task: $DisableUnlockSafe",
true,
() => {main.DisableUnlockSafe = !main.DisableUnlockSafe;},
new List<OptionPages>(){},
OptionPages.modes
)},
{OptionPages.NoGameEnd, new PageObject(
"NoGameEnd<DEBUG>: $NoGameEndEnabled",
true,
() => {main.NoGameEnd = !main.NoGameEnd;},
new List<OptionPages>(){},
OptionPages.modes
)}
};
public static OptionPages currentPage = OptionPages.basepage;
public static int currentCursor = 0;
public static void SetPage(OptionPages page) {
currentCursor = 0;
currentPage = page;
}
public static void Up() {
var currentPageObj = PageObjects[currentPage];
if(currentCursor <= 0) currentCursor = 0;
else currentCursor--;
}
public static void Down() {
var currentPageObj = PageObjects[currentPage];
if(currentCursor >= currentPageObj.PagesInThis.Count - 1) currentCursor = currentPageObj.PagesInThis.Count - 1;
else currentCursor++;
}
public static void Enter() {
var currentPageObj = PageObjects[currentPage];
var selectingObj = PageObjects[currentPageObj.PagesInThis[currentCursor]];
if(selectingObj.isHostOnly && !AmongUsClient.Instance.AmHost) return;
selectingObj.onEnter();
main.SyncCustomSettingsRPC();
}
public static void Return() {
var currentPageObj = PageObjects[currentPage];
SetPage(currentPageObj.pageToReturn);
}
public static string GetOptionText() {
string text;
var currentPageObj = PageObjects[currentPage];
text = "==" + currentPageObj.name + "==" + "\r\n";
for(var i = 0; i < currentPageObj.PagesInThis.Count; i++) {
var obj = PageObjects[currentPageObj.PagesInThis[i]];
text += currentCursor == i ? ">" : "";
text += obj.name + "\r\n";
}
//置き換え
text = text.Replace("$JesterEnabled", ChatCommands.getOnOff(main.currentScientist == ScientistRole.Jester));
text = text.Replace("$MadmateEnabled", ChatCommands.getOnOff(main.currentEngineer == EngineerRole.Madmate));
text = text.Replace("$BaitEnabled", ChatCommands.getOnOff(main.currentScientist == ScientistRole.Bait));
text = text.Replace("$TerroristEnabled", ChatCommands.getOnOff(main.currentEngineer == EngineerRole.Terrorist));
text = text.Replace("$SidekickEnabled", ChatCommands.getOnOff(main.currentShapeshifter == ShapeshifterRoles.Sidekick));
text = text.Replace("$VampireEnabled", ChatCommands.getOnOff(main.currentImpostor == ImpostorRoles.Vampire));
text = text.Replace("$HideAndSeekEnabled", ChatCommands.getOnOff(main.IsHideAndSeek));
text = text.Replace("$NoGameEndEnabled", ChatCommands.getOnOff(main.NoGameEnd));
text = text.Replace("$DisableSwipeCard", ChatCommands.getOnOff(main.DisableSwipeCard));
text = text.Replace("$DisableSubmitScan", ChatCommands.getOnOff(main.DisableSubmitScan));
text = text.Replace("$DisableUnlockSafe", ChatCommands.getOnOff(main.DisableUnlockSafe));
return text;
}
}
class PageObject {
public string name;
public bool isHostOnly;
public Action onEnter;
public List<OptionPages> PagesInThis;
public OptionPages pageToReturn;
public PageObject(string name, bool isHostOnly, Action onEnter, List<OptionPages> PageInThis, OptionPages PageToReturn) {
this.name = name;
this.isHostOnly = isHostOnly;
this.onEnter = onEnter;
this.PagesInThis = PageInThis;
this.pageToReturn = PageToReturn;
}
}
public enum OptionPages {
basepage = 0,
roles,
Jester,
Madmate,
Bait,
Terrorist,
Sidekick,
Vampire,
modes,
HideAndSeek,
DisableTasks,
SwipeCard,
SubmitScan,
UnlockSafe,
NoGameEnd
}
}