diff options
Diffstat (limited to 'AnodyneArchipelago/Menu/MenuState.cs')
-rw-r--r-- | AnodyneArchipelago/Menu/MenuState.cs | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/AnodyneArchipelago/Menu/MenuState.cs b/AnodyneArchipelago/Menu/MenuState.cs index 898eb94..59a4fdf 100644 --- a/AnodyneArchipelago/Menu/MenuState.cs +++ b/AnodyneArchipelago/Menu/MenuState.cs | |||
@@ -31,6 +31,9 @@ namespace AnodyneArchipelago.Menu | |||
31 | private string _apSlot = ""; | 31 | private string _apSlot = ""; |
32 | private string _apPassword = ""; | 32 | private string _apPassword = ""; |
33 | 33 | ||
34 | private ArchipelagoSettings _archipelagoSettings; | ||
35 | private int _curPage; | ||
36 | |||
34 | private int _selectorIndex = 0; | 37 | private int _selectorIndex = 0; |
35 | 38 | ||
36 | private bool _fadingOut = false; | 39 | private bool _fadingOut = false; |
@@ -44,6 +47,12 @@ namespace AnodyneArchipelago.Menu | |||
44 | Plugin.ArchipelagoManager = null; | 47 | Plugin.ArchipelagoManager = null; |
45 | } | 48 | } |
46 | 49 | ||
50 | _archipelagoSettings = ArchipelagoSettings.Load(); | ||
51 | if (_archipelagoSettings == null) | ||
52 | { | ||
53 | _archipelagoSettings = new(); | ||
54 | } | ||
55 | |||
47 | _selector = new(); | 56 | _selector = new(); |
48 | _selector.Play("enabledRight"); | 57 | _selector.Play("enabledRight"); |
49 | 58 | ||
@@ -59,12 +68,19 @@ namespace AnodyneArchipelago.Menu | |||
59 | _settingsLabel = new(new Vector2(60f, 131f), false, $"Config", new Color(116, 140, 144)); | 68 | _settingsLabel = new(new Vector2(60f, 131f), false, $"Config", new Color(116, 140, 144)); |
60 | _quitLabel = new(new Vector2(60f, 147f), false, $"Quit", new Color(116, 140, 144)); | 69 | _quitLabel = new(new Vector2(60f, 147f), false, $"Quit", new Color(116, 140, 144)); |
61 | 70 | ||
62 | _connectionSwitcher = new(new Vector2(60f, 95f), 32f, 0, true, new string[1] { "1/1" }); | 71 | string[] selectorValues = new string[_archipelagoSettings.ConnectionDetails.Count + 1]; |
72 | for (int i= 0; i < selectorValues.Length; i++) | ||
73 | { | ||
74 | selectorValues[i] = $"{i+1}/{selectorValues.Length}"; | ||
75 | } | ||
76 | |||
77 | _connectionSwitcher = new(new Vector2(60f, 95f), 32f, 0, true, selectorValues); | ||
63 | _connectionSwitcher.noConfirm = true; | 78 | _connectionSwitcher.noConfirm = true; |
64 | _connectionSwitcher.noLoop = true; | 79 | _connectionSwitcher.noLoop = true; |
65 | _connectionSwitcher.ValueChangedEvent = PageValueChanged; | 80 | _connectionSwitcher.ValueChangedEvent = PageValueChanged; |
66 | 81 | ||
67 | SetCursorPosition(0); | 82 | SetCursorPosition(0); |
83 | SetPage(_archipelagoSettings.ConnectionDetails.Count == 0 ? 0 : 1); | ||
68 | UpdateLabels(); | 84 | UpdateLabels(); |
69 | } | 85 | } |
70 | 86 | ||
@@ -249,15 +265,63 @@ namespace AnodyneArchipelago.Menu | |||
249 | break; | 265 | break; |
250 | } | 266 | } |
251 | } | 267 | } |
268 | else if (KeyInput.JustPressedRebindableKey(KeyFunctions.Left)) | ||
269 | { | ||
270 | if (_selectorIndex < 3 && _curPage > 0) | ||
271 | { | ||
272 | SoundManager.PlaySoundEffect("menu_move"); | ||
273 | |||
274 | SetPage(_curPage - 1); | ||
275 | } | ||
276 | } | ||
277 | else if (KeyInput.JustPressedRebindableKey(KeyFunctions.Right)) | ||
278 | { | ||
279 | if (_selectorIndex < 3 && _curPage < _archipelagoSettings.ConnectionDetails.Count) | ||
280 | { | ||
281 | SoundManager.PlaySoundEffect("menu_move"); | ||
282 | |||
283 | SetPage(_curPage + 1); | ||
284 | } | ||
285 | } | ||
252 | } | 286 | } |
253 | 287 | ||
254 | private void PageValueChanged(string value, int index) | 288 | private void SetPage(int index) |
255 | { | 289 | { |
290 | _curPage = index; | ||
291 | |||
292 | if (index == 0) | ||
293 | { | ||
294 | _apServer = ""; | ||
295 | _apSlot = ""; | ||
296 | _apPassword = ""; | ||
297 | } | ||
298 | else | ||
299 | { | ||
300 | ConnectionDetails details = _archipelagoSettings.ConnectionDetails[index - 1]; | ||
301 | _apServer = details.ApServer; | ||
302 | _apSlot = details.ApSlot; | ||
303 | _apPassword = details.ApPassword; | ||
304 | } | ||
256 | 305 | ||
306 | _connectionSwitcher.SetValue(index); | ||
307 | UpdateLabels(); | ||
308 | } | ||
309 | |||
310 | private void PageValueChanged(string value, int index) | ||
311 | { | ||
312 | SetPage(index); | ||
257 | } | 313 | } |
258 | 314 | ||
259 | private void OnConnected(ArchipelagoManager archipelagoManager) | 315 | private void OnConnected(ArchipelagoManager archipelagoManager) |
260 | { | 316 | { |
317 | _archipelagoSettings.AddConnection(new() | ||
318 | { | ||
319 | ApServer = _apServer, | ||
320 | ApSlot = _apSlot, | ||
321 | ApPassword = _apPassword | ||
322 | }); | ||
323 | _archipelagoSettings.Save(); | ||
324 | |||
261 | Plugin.ArchipelagoManager = archipelagoManager; | 325 | Plugin.ArchipelagoManager = archipelagoManager; |
262 | 326 | ||
263 | GlobalState.Save saveFile = GlobalState.Save.GetSave(string.Format("{0}Saves/Save_zzAP{1}_{2}.dat", GameConstants.SavePath, Plugin.ArchipelagoManager.GetSeed(), Plugin.ArchipelagoManager.GetPlayer())); | 327 | GlobalState.Save saveFile = GlobalState.Save.GetSave(string.Format("{0}Saves/Save_zzAP{1}_{2}.dat", GameConstants.SavePath, Plugin.ArchipelagoManager.GetSeed(), Plugin.ArchipelagoManager.GetPlayer())); |