-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKeybindManager.cs
More file actions
283 lines (262 loc) · 9.24 KB
/
Copy pathKeybindManager.cs
File metadata and controls
283 lines (262 loc) · 9.24 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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MarsClientLauncher
{
public class KeybindManager
{
public const string INTERN_GUI = "{INTERNAL_TOGGLEGUI}";
public List<KeybindGame> availableKeybinds = new List<KeybindGame>();
public List<Keybind> keybinds = new List<Keybind>();
public KeybindManager()
{
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = INTERN_GUI,
gameName = "TOGGLE IN-GAME GUI"
});
availableKeybinds.Add(new KeybindGame() {
gameInternalName = "play solo_normal",
gameName = "Skywars - Solo Normal"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play solo_insane",
gameName = "Skywars - Solo Insane"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play teams_normal",
gameName = "Skywars - Teams Normal"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play teams_insane",
gameName = "Skywars - Teams Insane"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play blitz_solo_normal",
gameName = "Blitz SG - Solo"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play blitz_teams_normal",
gameName = "Blitz SG - Teams"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play bedwars_eight_one",
gameName = "Bed Wars - Solo"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play bedwars_eight_one",
gameName = "Bed Wars - Doubles"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play bedwars_four_three",
gameName = "Bed Wars - 3v3v3v3"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play bedwars_four_four",
gameName = "Bed Wars - 4v4v4v4"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play sb",
gameName = "Skyblock"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play duels_classic_duel",
gameName = "Duels - Solo Classic"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play duels_sw_duel",
gameName = "Duels - Solo Skywars"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play duels_uhc_duel",
gameName = "Duels - Solo UHC"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play duels_op_duel",
gameName = "Duels - Solo OP"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play duels_sumo_duel",
gameName = "Duels - Sumo"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play duels_bridge_duel",
gameName = "Duels - Solo The Bridge"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play duels_classic_doubles",
gameName = "Duels - Doubles Classic"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play duels_sw_doubles",
gameName = "Duels - Doubles Skywars"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play duels_uhc_doubles",
gameName = "Duels - Doubles UHC"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play duels_op_doubles",
gameName = "Duels - Doubles OP"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play duels_bridge_doubles",
gameName = "Duels - Doubles The Bridge"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play murder_classic",
gameName = "Murder Mystery - Classic"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play murder_assassins",
gameName = "Murder Mystery - Assassins"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "play murder_infection",
gameName = "Murder Mystery - Infection"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "tipall",
gameName = "GENERAL KEYBINDS - Tip All"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "pl",
gameName = "GENERAL KEYBINDS - Party List"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "fl",
gameName = "GENERAL KEYBINDS - Friends List"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "fl",
gameName = "GENERAL KEYBINDS - Friends List"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "fl",
gameName = "GENERAL KEYBINDS - Friends List"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "chat a",
gameName = "GENERAL KEYBINDS - All Chat Mode"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "chat p",
gameName = "GENERAL KEYBINDS - Party Chat Mode"
});
availableKeybinds.Add(new KeybindGame()
{
gameInternalName = "p warp",
gameName = "GENERAL KEYBINDS - Warp Party"
});
}
public void AddKeybind(string gameName, Keys key)
{
KeybindGame game = null;
foreach(var test in availableKeybinds)
{
if (test.gameName.Equals(gameName))
{
game = test; break;
}
}
if (game == null) return;
keybinds.Add(new Keybind()
{
game = game,
key = key
});
}
public void AddKeybind(Keybind kb)
{
keybinds.Add(kb);
}
public void ReplaceKeybind(Keybind a, Keybind b)
{
Keybind[] arr = keybinds.ToArray();
for(int i = 0; i < arr.Length; i++)
{
Keybind current = arr[i];
if(current.Equals(a))
arr[i] = b;
}
keybinds = arr.ToList();
}
public void DeleteKeybind(Keybind k)
{
keybinds.Remove(k);
}
public string Serialize()
{
List<string> serialized = new List<string>();
foreach(Keybind kb in keybinds)
serialized.Add(kb.game.gameName + "|" + ((int)kb.key));
return string.Join("#", serialized);
}
public static KeybindManager Deserialize(string input)
{
KeybindManager mgr = new KeybindManager();
string[] kbs = input.Split(new char[]{ '#' },
StringSplitOptions.RemoveEmptyEntries);
foreach(string kb in kbs)
{
string[] parts = kb.Split('|');
string gameName = parts[0];
Keys key = (Keys)int.Parse(parts[1]);
mgr.AddKeybind(gameName, key);
}
return mgr;
}
}
public class KeybindGame
{
public string gameName;
public string gameInternalName;
public override string ToString()
{
return gameName;
}
}
public class Keybind
{
public Keys key;
public KeybindGame game;
public override string ToString()
{
return "(" + game.ToString() + "), CTRL+" + key.ToString();
}
}
}