Skip to content

Commit 3599e22

Browse files
committed
feat: updated to the new ui update
1 parent acf1164 commit 3599e22

6 files changed

Lines changed: 243 additions & 217 deletions

File tree

PolyMod.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
</RestoreAdditionalProjectSources>
1212
<Configurations>IL2CPP</Configurations>
1313
<RootNamespace>PolyMod</RootNamespace>
14-
<Version>1.2.13</Version>
15-
<PolytopiaVersion>2.16.8.15757</PolytopiaVersion>
14+
<Version>1.2.14</Version>
15+
<PolytopiaVersion>2.17.0.16256</PolytopiaVersion>
1616
<Authors>PolyModdingTeam</Authors>
1717
<Description>The Battle of Polytopia's mod loader.</Description>
1818
<NoWarn>IDE0130</NoWarn>

src/Managers/AutoUpdate.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Text.Json;
44
using HarmonyLib;
55
using UnityEngine;
6+
using static PopupManager;
67

78
namespace PolyMod.Managers;
89

@@ -15,8 +16,8 @@ internal static class AutoUpdate
1516
/// Checks for updates when the start screen is shown.
1617
/// </summary>
1718
[HarmonyPostfix]
18-
[HarmonyPatch(typeof(StartScreen), nameof(StartScreen.Start))]
19-
private static void StartScreen_Start()
19+
[HarmonyPatch(typeof(StartScreen_UI2), nameof(StartScreen_UI2.OnShow))]
20+
private static void StartScreen_UI2_OnShow()
2021
{
2122
if (!Plugin.config.autoUpdate) return;
2223
if (Environment.GetEnvironmentVariable("WINEPREFIX") != null)
@@ -154,17 +155,19 @@ exit 0
154155
}
155156

156157
// Show a popup to the user asking if they want to update
157-
PopupManager.GetBasicPopup(new(
158-
Localization.Get("polymod.autoupdate"),
159-
Localization.Get("polymod.autoupdate.description"),
160-
new(new PopupBase.PopupButtonData[] {
158+
BasicPopup popup = PopupManager.GetBasicPopup();
159+
popup.Header = Localization.Get("polymod.autoupdate");
160+
popup.Description = Localization.Get("polymod.autoupdate.description");
161+
popup.buttonData = new PopupBase.PopupButtonData[] {
161162
new(
162163
"polymod.autoupdate.update",
163164
PopupBase.PopupButtonData.States.None,
164165
(Il2CppSystem.Action)Update
165166
)
166-
}))
167-
).Show();
167+
};
168+
169+
popup.Show();
170+
168171
}
169172
catch (Exception e)
170173
{

src/Managers/Compatibility.cs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static void HashSignatures(StringBuilder checksumString)
3434
/// Checks the signature of a saved game to ensure it is compatible with the current mods.
3535
/// </summary>
3636
/// <returns>True if the signatures match or if the check is ignored, false otherwise.</returns>
37-
private static bool CheckSignatures(Action<int, BaseEventData> action, int id, BaseEventData eventData, Il2CppSystem.Guid gameId)
37+
private static bool CheckSignatures(Action action, Il2CppSystem.Guid gameId)
3838
{
3939
if (sawSignatureWarning)
4040
{
@@ -67,13 +67,15 @@ private static bool CheckSignatures(Action<int, BaseEventData> action, int id, B
6767
}
6868
if (!doChecksumsMatch)
6969
{
70-
PopupManager.GetBasicPopup(new(
71-
Localization.Get("polymod.signature.mismatch"),
72-
Localization.Get("polymod.signature.incompatible"),
73-
new(new PopupBase.PopupButtonData[] {
74-
new("OK")
75-
})
76-
)).Show();
70+
BasicPopup popup = PopupManager.GetBasicPopup();
71+
popup.Header = Localization.Get("polymod.signature.mismatch");
72+
popup.Description = Localization.Get("polymod.signature.incompatible");
73+
popup.buttonData = new PopupBase.PopupButtonData[] {
74+
new("OK")
75+
};
76+
77+
popup.Show();
78+
7779
return false;
7880
}
7981
return true;
@@ -83,8 +85,8 @@ private static bool CheckSignatures(Action<int, BaseEventData> action, int id, B
8385
/// Performs compatibility checks when the start screen is shown.
8486
/// </summary>
8587
[HarmonyPostfix]
86-
[HarmonyPatch(typeof(StartScreen), nameof(StartScreen.Start))]
87-
private static void StartScreen_Start()
88+
[HarmonyPatch(typeof(StartScreen_UI2), nameof(StartScreen_UI2.OnShow))]
89+
private static void StartScreen_UI2_OnShow()
8890
{
8991
string lastChecksum = checksum;
9092
try
@@ -113,19 +115,21 @@ private static void StartScreen_Start()
113115
VersionManager.SemanticVersion.Cast().CutRevision().ToString()
114116
);
115117
PlayerPrefs.Save();
116-
PopupManager.GetBasicPopup(new(
117-
Localization.Get("polymod.version.mismatch"),
118-
Localization.Get("polymod.version.mismatch.description"),
119-
new(new PopupBase.PopupButtonData[] {
118+
119+
BasicPopup popup = PopupManager.GetBasicPopup();
120+
popup.Header = Localization.Get("polymod.version.mismatch");
121+
popup.Description = Localization.Get("polymod.version.mismatch.description");
122+
popup.buttonData = new PopupBase.PopupButtonData[] {
120123
new("buttons.stay", customColorStates: ColorConstants.redButtonColorStates),
121124
new(
122125
"buttons.exitgame",
123126
PopupBase.PopupButtonData.States.None,
124127
(Il2CppSystem.Action)Application.Quit,
125128
closesPopup: false
126129
)
127-
}))
128-
).Show();
130+
};
131+
132+
popup.Show();
129133
}
130134
}
131135

@@ -134,19 +138,19 @@ private static void StartScreen_Start()
134138
/// </summary>
135139
[HarmonyPrefix]
136140
[HarmonyPatch(typeof(GameInfoPopup), nameof(GameInfoPopup.OnMainButtonClicked))]
137-
private static bool GameInfoPopup_OnMainButtonClicked(GameInfoPopup __instance, int id, BaseEventData eventData)
141+
private static bool GameInfoPopup_OnMainButtonClicked(GameInfoPopup __instance)
138142
{
139-
return CheckSignatures(__instance.OnMainButtonClicked, id, eventData, __instance.gameId);
143+
return CheckSignatures(__instance.OnMainButtonClicked, __instance.gameId);
140144
}
141145

142146
/// <summary>
143147
/// Checks the signature of a single-player game before resuming it.
144148
/// </summary>
145149
[HarmonyPrefix]
146-
[HarmonyPatch(typeof(StartScreen), nameof(StartScreen.OnResumeButtonClick))]
147-
private static bool StartScreen_OnResumeButtonClick(StartScreen __instance, int id, BaseEventData eventData)
150+
[HarmonyPatch(typeof(StartScreen_UI2), nameof(StartScreen_UI2.OnResumeButtonLongPress))]
151+
private static bool StartScreen_OnResumeButtonClick(StartScreen_UI2 __instance)
148152
{
149-
return CheckSignatures(__instance.OnResumeButtonClick, id, eventData, LocalSaveFileUtils.GetSaveFiles(PolytopiaBackendBase.Game.GameType.SinglePlayer)[0]);
153+
return CheckSignatures(__instance.OnResumeButtonLongPress, LocalSaveFileUtils.GetSaveFiles(PolytopiaBackendBase.Game.GameType.SinglePlayer)[0]);
150154
}
151155

152156
/// <summary>

0 commit comments

Comments
 (0)