Skip to content

Commit a13e6b6

Browse files
committed
Made working buttons for enabling autoupdate for releases and prereleases
1 parent b3e0719 commit a13e6b6

3 files changed

Lines changed: 44 additions & 14 deletions

File tree

resources/localization.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,18 @@
161161
"Elyrion": "πȱ∫ỹmȱδ ƒƒƒƒƒƒƒ ŋȱŧ ȱrrȱ #₺rr∑ŋŧ ƒƒƒƒƒƒƒ ỹ maỹ ŋȱŧ ~ȱr§ #ȱrr∑#ŧ∫ỹ!",
162162
"German (Germany)": "Diese Version von PolyMod ist nicht für die aktuelle Version der Anwendung ausgelegt und könnte nicht funktionieren!"
163163
},
164+
"polymod_debug": {
165+
"English": "Debug",
166+
"Russian": "Дебаг"
167+
},
164168
"polymod_autoupdate": {
165169
"English": "Auto-update",
166170
"Russian": "Автообновление"
167171
},
172+
"polymod_autoupdate_alpha": {
173+
"English": "Include alphas",
174+
"Russian": "Include alphas"
175+
},
168176
"polymod_autoupdate_description": {
169177
"English": "New update available!",
170178
"Russian": "Доступно новое обновление!"

src/Managers/Hub.cs

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ internal static void ShowConfigPopup()
298298
polymodPopup.Description = "";
299299

300300
polymodPopup.buttonData = CreateConfigPopupButtonData();
301+
polymodPopup.ShowSetWidth(POPUP_WIDTH);
301302
polymodPopup.Show();
302303
}
303304

@@ -315,41 +316,62 @@ internal static PopupButtonData[] CreateConfigPopupButtonData()
315316
else
316317
{
317318
string debugButtonName = Localization.Get(
318-
"polymod.hub.config.enable",
319-
new Il2CppSystem.Object[] { "DEBUG" }
319+
Plugin.config.debug ? "polymod.hub.config.disable" : "polymod.hub.config.enable",
320+
new Il2CppSystem.Object[] { Localization.Get("polymod.debug",
321+
new Il2CppSystem.Object[]{}).ToUpperInvariant() }
322+
);
323+
string autoUpdateButtonName = Localization.Get(
324+
Plugin.config.autoUpdate ? "polymod.hub.config.disable" : "polymod.hub.config.enable",
325+
new Il2CppSystem.Object[] { Localization.Get("polymod.autoupdate",
326+
new Il2CppSystem.Object[]{}).ToUpperInvariant() }
327+
);
328+
string includeAlphasButtonName = Localization.Get(
329+
Plugin.config.updatePrerelease ? "polymod.hub.config.disable" : "polymod.hub.config.enable",
330+
new Il2CppSystem.Object[] { Localization.Get("polymod.autoupdate.alpha",
331+
new Il2CppSystem.Object[]{}).ToUpperInvariant() }
320332
);
321-
if (Plugin.config.debug)
322-
{
323-
debugButtonName = Localization.Get(
324-
"polymod.hub.config.disable",
325-
new Il2CppSystem.Object[] { "DEBUG" }
326-
);
327-
}
328333
popupButtons.Add(new PopupButtonData(debugButtonName, PopupButtonData.States.None, (UIButtonBase.ButtonAction)OnDebugButtonClicked, -1, true, null));
329-
//popupButtons.Add(new PopupButtonData("", PopupButtonData.States.None, (UIButtonBase.ButtonAction)OnAutoUpdateButtonClicked, -1, true, null));
330-
//popupButtons.Add(new PopupButtonData("", PopupButtonData.States.Disabled, (UIButtonBase.ButtonAction)OnIncludeAlphasButtonClicked, -1, true, null));
334+
popupButtons.Add(new PopupButtonData(autoUpdateButtonName, PopupButtonData.States.None, (UIButtonBase.ButtonAction)OnAutoUpdateButtonClicked, -1, true, null));
335+
popupButtons.Add(new PopupButtonData(includeAlphasButtonName, Plugin.config.autoUpdate ? PopupButtonData.States.None : PopupButtonData.States.Disabled, (UIButtonBase.ButtonAction)OnIncludeAlphasButtonClicked, -1, true, null));
331336
}
332337
return popupButtons.ToArray();
333338

334339
void OnDebugButtonClicked(int buttonId, BaseEventData eventData)
335340
{
336-
Plugin.config = new(debug: !Plugin.config.debug);
341+
Plugin.config = new(debug: !Plugin.config.debug, autoUpdate: Plugin.config.autoUpdate, updatePrerelease: Plugin.config.updatePrerelease);
337342
Plugin.WriteConfig();
338343
Plugin.UpdateConsole();
339344
NotificationManager.Notify(Localization.Get(
340345
"polymod.config.setto",
341-
new Il2CppSystem.Object[] { "Debug", Plugin.config.debug }
346+
new Il2CppSystem.Object[] { Localization.Get("polymod.debug",
347+
new Il2CppSystem.Object[]{}), Plugin.config.debug }
342348
));
343349
isConfigPopupActive = false;
344350
}
345351

346352
void OnAutoUpdateButtonClicked(int buttonId, BaseEventData eventData)
347353
{
354+
Plugin.config = new(debug: Plugin.config.debug, autoUpdate: !Plugin.config.autoUpdate, updatePrerelease: Plugin.config.updatePrerelease);
355+
Plugin.WriteConfig();
356+
Plugin.UpdateConsole();
357+
NotificationManager.Notify(Localization.Get(
358+
"polymod.config.setto",
359+
new Il2CppSystem.Object[] { Localization.Get("polymod.autoupdate",
360+
new Il2CppSystem.Object[]{}), Plugin.config.autoUpdate }
361+
));
348362
isConfigPopupActive = false;
349363
}
350364

351365
void OnIncludeAlphasButtonClicked(int buttonId, BaseEventData eventData)
352366
{
367+
Plugin.config = new(debug: Plugin.config.debug, autoUpdate: Plugin.config.autoUpdate, updatePrerelease: !Plugin.config.updatePrerelease);
368+
Plugin.WriteConfig();
369+
Plugin.UpdateConsole();
370+
NotificationManager.Notify(Localization.Get(
371+
"polymod.config.setto",
372+
new Il2CppSystem.Object[] { Localization.Get("polymod.autoupdate.alpha",
373+
new Il2CppSystem.Object[]{}), Plugin.config.updatePrerelease }
374+
));
353375
isConfigPopupActive = false;
354376
}
355377

src/Plugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public override void Load()
5151
catch
5252
{
5353
config = new();
54-
WriteConfig();
5554
}
55+
WriteConfig();
5656
UpdateConsole();
5757
logger = Log;
5858
ConfigFile.CoreConfig[new("Logging.Disk", "WriteUnityLog")].BoxedValue = true;

0 commit comments

Comments
 (0)