Skip to content

Commit 51f0db9

Browse files
committed
Fix warnings on latest Everest versions
1 parent ca8356c commit 51f0db9

10 files changed

+130
-96
lines changed

LazyLoadingHandler.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ public class PrefixesExcludedFromLazyLoading {
4444
private static string latestMapSID = null;
4545
private static bool preloadingTextures = false;
4646
private static ILHook hookOnTextureSafe;
47+
private static ILHook hookOnContentCrawl;
4748

4849
public static void Load() {
49-
IL.Celeste.Mod.Everest.Content.Crawl += registerLazyLoadingModsOnLoad;
50+
hookOnContentCrawl = new ILHook(typeof(Everest.Content).GetMethod("Crawl"), registerLazyLoadingModsOnLoad);
5051
IL.Monocle.VirtualTexture.Preload += turnOnLazyLoadingSelectively;
5152
On.Celeste.LevelLoader.ctor += lazilyLoadTextures;
5253
On.Monocle.VirtualTexture.Reload += onTextureLazyLoad;
@@ -61,7 +62,9 @@ public static void Load() {
6162
}
6263

6364
public static void Unload() {
64-
IL.Celeste.Mod.Everest.Content.Crawl -= registerLazyLoadingModsOnLoad;
65+
hookOnContentCrawl?.Dispose();
66+
hookOnContentCrawl = null;
67+
6568
IL.Monocle.VirtualTexture.Preload -= turnOnLazyLoadingSelectively;
6669
On.Celeste.LevelLoader.ctor -= lazilyLoadTextures;
6770
On.Monocle.VirtualTexture.Reload -= onTextureLazyLoad;

LobbyHelper.cs

Lines changed: 60 additions & 42 deletions
Large diffs are not rendered by default.

Triggers/JournalTrigger.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ private static void onJournalEnter(OuiJournal journal, Oui from) {
3131
journal.Pages.Add(new OuiJournalCoverWithStickers(journal));
3232

3333
// then, fill in the journal with our custom pages.
34-
journal.Pages.AddRange(OuiJournalCollabProgressInLobby.GeneratePages(journal, forceArea.GetLevelSet(), showOnlyDiscovered));
34+
journal.Pages.AddRange(OuiJournalCollabProgressInLobby.GeneratePages(journal, forceArea.LevelSet, showOnlyDiscovered));
3535

3636
// and add the map if we have it as well.
37-
if (MTN.Journal.Has("collabLobbyMaps/" + forceArea.GetLevelSet())) {
38-
journal.Pages.Add(new OuiJournalLobbyMap(journal, MTN.Journal["collabLobbyMaps/" + forceArea.GetLevelSet()]));
37+
if (MTN.Journal.Has("collabLobbyMaps/" + forceArea.LevelSet)) {
38+
journal.Pages.Add(new OuiJournalLobbyMap(journal, MTN.Journal["collabLobbyMaps/" + forceArea.LevelSet]));
3939
}
4040

4141
// redraw the first page to include the stickers

Triggers/MiniHeartDoorUnlockCutsceneTrigger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private static void addOpenHeartGateToMenu(Level self) {
3838

3939
if (trigger != null) {
4040
MiniHeartDoor gate = trigger.findHeartGate();
41-
TextMenu menu = self.Entities.GetToAdd().OfType<TextMenu>().FirstOrDefault();
41+
TextMenu menu = self.Entities.ToAdd.OfType<TextMenu>().FirstOrDefault();
4242

4343
// check that we have what we need, and that the gate can't open yet.
4444
if (menu != null && gate != null && !gate.Opened && gate.HeartGems < gate.Requires) {

UI/InGameOverworldHelper.cs

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ public static List<CreditsTag> Parse(string dialog) {
109109

110110
private static bool presenceLock = false;
111111

112+
private static Hook onReloadLevelHook;
113+
private static Hook onChangePresenceHook;
114+
112115
internal static void Load() {
113116
Everest.Events.Level.OnPause += OnPause;
114117
On.Celeste.Audio.SetMusic += OnSetMusic;
@@ -125,11 +128,17 @@ internal static void Load() {
125128
IL.Celeste.StrawberriesCounter.Render += ModStrawberriesCounterRender;
126129
On.Celeste.OuiChapterPanel.Start += OnOuiChapterPanelStart;
127130
On.Celeste.Player.Die += OnPlayerDie;
128-
On.Celeste.Mod.AssetReloadHelper.ReloadLevel += OnReloadLevel;
131+
132+
onReloadLevelHook = new Hook(
133+
typeof(AssetReloadHelper).GetMethod("ReloadLevel", new Type[0]),
134+
typeof(InGameOverworldHelper).GetMethod("OnReloadLevel", BindingFlags.NonPublic | BindingFlags.Static));
135+
129136
IL.Celeste.OuiChapterPanel._FixTitleLength += ModFixTitleLength;
130137
On.Celeste.OuiMainMenu.CreateButtons += OnOuiMainMenuCreateButtons;
131138

132-
On.Celeste.Mod.Everest.DiscordSDK.UpdatePresence += OnDiscordChangePresence;
139+
onChangePresenceHook = new Hook(
140+
typeof(Everest.DiscordSDK).GetMethod("UpdatePresence", BindingFlags.NonPublic | BindingFlags.Instance),
141+
typeof(InGameOverworldHelper).GetMethod("OnDiscordChangePresence", BindingFlags.NonPublic | BindingFlags.Static));
133142

134143
hookOnMapDataOrigLoad = new Hook(
135144
typeof(MapData).GetMethod("orig_Load", BindingFlags.NonPublic | BindingFlags.Instance),
@@ -168,7 +177,10 @@ internal static void Unload() {
168177
IL.Celeste.StrawberriesCounter.Render -= ModStrawberriesCounterRender;
169178
On.Celeste.OuiChapterPanel.Start -= OnOuiChapterPanelStart;
170179
On.Celeste.Player.Die -= OnPlayerDie;
171-
On.Celeste.Mod.AssetReloadHelper.ReloadLevel -= OnReloadLevel;
180+
181+
onReloadLevelHook?.Dispose();
182+
onReloadLevelHook = null;
183+
172184
IL.Celeste.OuiChapterPanel._FixTitleLength -= ModFixTitleLength;
173185
On.Celeste.OuiMainMenu.CreateButtons -= OnOuiMainMenuCreateButtons;
174186

@@ -180,7 +192,8 @@ internal static void Unload() {
180192
hookOnMapDataOrigLoad?.Dispose();
181193
hookOnMapDataOrigLoad = null;
182194

183-
On.Celeste.Mod.Everest.DiscordSDK.UpdatePresence -= OnDiscordChangePresence;
195+
onChangePresenceHook?.Dispose();
196+
onChangePresenceHook = null;
184197
}
185198

186199
private static void OnOuiChapterPanelStart(On.Celeste.OuiChapterPanel.orig_Start orig, OuiChapterPanel self, string checkpoint) {
@@ -192,7 +205,7 @@ private static void OnOuiChapterPanelStart(On.Celeste.OuiChapterPanel.orig_Start
192205
if (gymSubmenuSelected(self)) {
193206
// We picked a map in the second menu: this is a gym.
194207
self.Area.Mode = AreaMode.Normal;
195-
overworldData["gymExitMapSID"] = overworldData.Get<AreaData>("collabInGameForcedArea").GetSID();
208+
overworldData["gymExitMapSID"] = overworldData.Get<AreaData>("collabInGameForcedArea").SID;
196209
overworldData["gymExitSaveAllowed"] = overworldData.Get<bool>("saveAndReturnToLobbyAllowed");
197210
overworldData["saveAndReturnToLobbyAllowed"] = false;
198211
} else if (returnToLobbySelected(self)) {
@@ -204,9 +217,9 @@ private static void OnOuiChapterPanelStart(On.Celeste.OuiChapterPanel.orig_Start
204217
return;
205218
} else if (checkpoint != "collabutils_continue") {
206219
// "continue" was not selected, so drop the saved state to start over.
207-
CollabModule.Instance.SaveData.SessionsPerLevel.Remove(self.Area.GetSID());
208-
CollabModule.Instance.SaveData.ModSessionsPerLevel.Remove(self.Area.GetSID());
209-
CollabModule.Instance.SaveData.ModSessionsPerLevelBinary.Remove(self.Area.GetSID());
220+
CollabModule.Instance.SaveData.SessionsPerLevel.Remove(self.Area.SID);
221+
CollabModule.Instance.SaveData.ModSessionsPerLevel.Remove(self.Area.SID);
222+
CollabModule.Instance.SaveData.ModSessionsPerLevelBinary.Remove(self.Area.SID);
210223
}
211224
}
212225

@@ -248,7 +261,7 @@ private static PlayerDeadBody OnPlayerDie(On.Celeste.Player.orig_Die orig, Playe
248261
return result;
249262
}
250263

251-
private static void OnReloadLevel(On.Celeste.Mod.AssetReloadHelper.orig_ReloadLevel orig) {
264+
private static void OnReloadLevel(Action orig) {
252265
if (overworldWrapper != null) {
253266
if (!(Engine.Scene is Level level)) {
254267
level = AssetReloadHelper.ReturnToScene as Level;
@@ -268,7 +281,7 @@ private static void OnReloadLevel(On.Celeste.Mod.AssetReloadHelper.orig_ReloadLe
268281
}
269282

270283

271-
private static void OnDiscordChangePresence(On.Celeste.Mod.Everest.DiscordSDK.orig_UpdatePresence orig, Everest.DiscordSDK self, Session session) {
284+
private static void OnDiscordChangePresence(Action<Everest.DiscordSDK, Session> orig, Everest.DiscordSDK self, Session session) {
272285
if (!presenceLock) {
273286
orig(self, session);
274287
}
@@ -328,8 +341,8 @@ private static void OnChapterPanelReset(On.Celeste.OuiChapterPanel.orig_Reset or
328341
if (!isPanelShowingLobby()) {
329342
data["chapter"] = (new DynData<Overworld>(self.Overworld).Get<AreaData>("collabInGameForcedArea").Name + "_author").DialogCleanOrNull() ?? "";
330343

331-
if (CollabMapDataProcessor.GymLevels.ContainsKey(forceArea.GetSID())) {
332-
CollabMapDataProcessor.GymLevelInfo info = CollabMapDataProcessor.GymLevels[forceArea.GetSID()];
344+
if (CollabMapDataProcessor.GymLevels.ContainsKey(forceArea.SID)) {
345+
CollabMapDataProcessor.GymLevelInfo info = CollabMapDataProcessor.GymLevels[forceArea.SID];
333346

334347
if (info.Tech.Any(name => CollabMapDataProcessor.GymTech.ContainsKey(name))) {
335348
// some of the tech used here exists in gyms! be sure to display the "tech" tab.
@@ -368,7 +381,7 @@ private static void ChapterPanelSwapToGym(OuiChapterPanel self, DynData<OuiChapt
368381
data["contentOffset"] = new Vector2(440f, data.Get<Vector2>("contentOffset").Y);
369382
data["height"] = 730f;
370383
data["option"] = 0;
371-
data["gymTech"] = CollabMapDataProcessor.GymLevels[new DynData<Overworld>(self.Overworld).Get<AreaData>("collabInGameForcedArea").GetSID()].Tech;
384+
data["gymTech"] = CollabMapDataProcessor.GymLevels[new DynData<Overworld>(self.Overworld).Get<AreaData>("collabInGameForcedArea").SID].Tech;
372385

373386
IList checkpoints = data.Get<IList>("checkpoints");
374387
checkpoints.Clear();
@@ -390,7 +403,7 @@ private static void ChapterPanelSwapToGym(OuiChapterPanel self, DynData<OuiChapt
390403
new DynamicData(checkpoint).Set("gymTechDifficulty", techInfo.Difficulty);
391404
checkpoints.Add(checkpoint);
392405

393-
string currentSid = SaveData.Instance.CurrentSession_Safe.Area.GetSID();
406+
string currentSid = SaveData.Instance.CurrentSession_Safe.Area.SID;
394407
string currentRoom = SaveData.Instance.CurrentSession_Safe.Level;
395408

396409
if (techInfo.AreaSID == currentSid && techInfo.Level == currentRoom) {
@@ -428,7 +441,7 @@ private static void resetCrystalHeart(OuiChapterPanel panel) {
428441

429442
private static void customizeCrystalHeart(OuiChapterPanel panel) {
430443
// customize heart gem icon
431-
string sid = panel.Area.GetSID();
444+
string sid = panel.Area.SID;
432445

433446
Sprite[] heartSprites = new DynData<OuiChapterPanel>(panel).Get<HeartGemDisplay>("heart").Sprites;
434447
for (int side = 0; side < 3; side++) {
@@ -452,7 +465,7 @@ private static void customizeCrystalHeart(OuiChapterPanel panel) {
452465
/// <param name="side">The side to get the heart sprite for</param>
453466
/// <returns>The sprite ID to pass to HeartSpriteBank.Create to get the custom heart sprite, or null if none was found</returns>
454467
public static string GetGuiHeartSpriteId(string mapSID, AreaMode side) {
455-
string mapLevelSet = AreaData.Get(mapSID)?.GetLevelSet().DialogKeyify();
468+
string mapLevelSet = AreaData.Get(mapSID)?.LevelSet.DialogKeyify();
456469

457470
string sideName = mapSID.DialogKeyify();
458471
if (side == AreaMode.BSide) {
@@ -499,7 +512,7 @@ private static bool OnSaveDataFoundAnyCheckpoints(On.Celeste.SaveData.orig_Found
499512
return orig(self, area) ||
500513
Dialog.Has(new DynData<Overworld>(overworldWrapper.WrappedScene).Get<AreaData>("collabInGameForcedArea").Name + "_collabcredits") ||
501514
Dialog.Has(new DynData<Overworld>(overworldWrapper.WrappedScene).Get<AreaData>("collabInGameForcedArea").Name + "_collabcreditstags") ||
502-
CollabModule.Instance.SaveData.SessionsPerLevel.ContainsKey(area.GetSID());
515+
CollabModule.Instance.SaveData.SessionsPerLevel.ContainsKey(area.SID);
503516
}
504517

505518
return orig(self, area);
@@ -510,7 +523,7 @@ private static int OnChapterPanelGetModeHeight(On.Celeste.OuiChapterPanel.orig_G
510523
// because in these cases we have stuff to display in the chapter panel, and vanilla wouldn't display anything.
511524
AreaModeStats areaModeStats = self.RealStats.Modes[(int) self.Area.Mode];
512525
if (Engine.Scene == overworldWrapper?.Scene && !AreaData.Get(self.Area).Interlude_Safe
513-
&& (areaModeStats.Deaths > 0 || CollabModule.Instance.SaveData.SpeedBerryPBs.ContainsKey(self.Area.GetSID()))) {
526+
&& (areaModeStats.Deaths > 0 || CollabModule.Instance.SaveData.SpeedBerryPBs.ContainsKey(self.Area.SID))) {
514527

515528
return 540;
516529
}
@@ -522,7 +535,7 @@ private static void OnChapterPanelSwap(On.Celeste.OuiChapterPanel.orig_Swap orig
522535
if (Engine.Scene != overworldWrapper?.Scene || (!gymSubmenuSelected(self)
523536
&& !Dialog.Has(new DynData<Overworld>(overworldWrapper.WrappedScene).Get<AreaData>("collabInGameForcedArea").Name + "_collabcredits")
524537
&& !Dialog.Has(new DynData<Overworld>(overworldWrapper.WrappedScene).Get<AreaData>("collabInGameForcedArea").Name + "_collabcreditstags")
525-
&& !CollabModule.Instance.SaveData.SessionsPerLevel.ContainsKey(self.Area.GetSID()))) {
538+
&& !CollabModule.Instance.SaveData.SessionsPerLevel.ContainsKey(self.Area.SID))) {
526539

527540
// this isn't an in-game chapter panel, or there is no custom second page (no credits, no saved state, no gyms) => use vanilla
528541
orig(self);
@@ -538,7 +551,7 @@ private static void OnChapterPanelSwap(On.Celeste.OuiChapterPanel.orig_Swap orig
538551
}
539552

540553
if (gymSubmenuSelected(self)) {
541-
data["gymTech"] = CollabMapDataProcessor.GymLevels[new DynData<Overworld>(self.Overworld).Get<AreaData>("collabInGameForcedArea").GetSID()].Tech;
554+
data["gymTech"] = CollabMapDataProcessor.GymLevels[new DynData<Overworld>(self.Overworld).Get<AreaData>("collabInGameForcedArea").SID].Tech;
542555

543556
self.Focused = false;
544557
self.Overworld.ShowInputUI = !selectingMode;
@@ -579,7 +592,7 @@ private static IEnumerator ChapterPanelSwapRoutine(OuiChapterPanel self, DynData
579592
IList checkpoints = data.Get<IList>("checkpoints");
580593
checkpoints.Clear();
581594

582-
bool hasContinueOption = CollabModule.Instance.SaveData.SessionsPerLevel.ContainsKey(self.Area.GetSID());
595+
bool hasContinueOption = CollabModule.Instance.SaveData.SessionsPerLevel.ContainsKey(self.Area.SID);
583596

584597
checkpoints.Add(DynamicData.New(t_OuiChapterPanelOption)(new {
585598
Label = Dialog.Clean(hasContinueOption ? "collabutils2_chapterpanel_start" : "overworld_start", null),
@@ -809,7 +822,7 @@ private static void OnChapterPanelDrawGymCheckpoint(OuiChapterPanel self, Vector
809822
if (CollabMapDataProcessor.GymTech.ContainsKey(collabTech[checkpointIndex])) {
810823
CollabMapDataProcessor.GymTechInfo techInfo = CollabMapDataProcessor.GymTech[collabTech[checkpointIndex]];
811824

812-
string imageName = $"{LobbyHelper.GetCollabNameForSID(forcedArea.GetSID())}/Gyms/{collabTech[checkpointIndex]}";
825+
string imageName = $"{LobbyHelper.GetCollabNameForSID(forcedArea.SID)}/Gyms/{collabTech[checkpointIndex]}";
813826
MTexture imagePreview = MTN.Checkpoints.Has(imageName) ? MTN.Checkpoints[imageName] : null;
814827
if (imagePreview != null) {
815828
var optionData = new DynamicData(option);
@@ -977,7 +990,7 @@ private static void OnChapterPanelUpdateStats(On.Celeste.OuiChapterPanel.orig_Up
977990

978991
// mod the death icon: for the path, use the current level set, or for lobbies, the lobby's matching level set.
979992
string pathToSkull = "CollabUtils2/skulls/" + self.Area.GetLevelSet();
980-
string lobbyLevelSet = LobbyHelper.GetLobbyLevelSet(self.Area.GetSID());
993+
string lobbyLevelSet = LobbyHelper.GetLobbyLevelSet(self.Area.SID);
981994
if (lobbyLevelSet != null) {
982995
pathToSkull = "CollabUtils2/skulls/" + lobbyLevelSet;
983996
}
@@ -990,7 +1003,7 @@ private static void OnChapterPanelUpdateStats(On.Celeste.OuiChapterPanel.orig_Up
9901003
if (isPanelShowingLobby(self) || Engine.Scene == overworldWrapper?.Scene) {
9911004
// turn strawberry counter into golden if there only are golden berries in the map
9921005
MapData mapData = AreaData.Get(self.Area).Mode[0].MapData;
993-
if (mapData.GetDetectedStrawberriesIncludingUntracked() == mapData.Goldenberries.Count) {
1006+
if (mapData.DetectedStrawberriesIncludingUntracked == mapData.Goldenberries.Count) {
9941007
StrawberriesCounter strawberriesCounter = new DynData<OuiChapterPanel>(self).Get<StrawberriesCounter>("strawberries");
9951008
strawberriesCounter.Golden = true;
9961009
strawberriesCounter.ShowOutOf = false;
@@ -1186,7 +1199,7 @@ private static string getCurrentPanelMapSID() {
11861199
if (panel == null) {
11871200
panel = (AssetReloadHelper.ReturnToScene as Overworld).GetUI<OuiChapterPanel>();
11881201
}
1189-
string sid = panel.Area.GetSID();
1202+
string sid = panel.Area.SID;
11901203
return sid;
11911204
}
11921205

@@ -1206,14 +1219,14 @@ private static OuiChapterPanel getChapterPanel() {
12061219

12071220
private static bool isPanelShowingLobby(OuiChapterPanel panel = null) {
12081221
panel = panel ?? getChapterPanel();
1209-
return LobbyHelper.IsCollabLobby(panel?.Area.GetSID() ?? "");
1222+
return LobbyHelper.IsCollabLobby(panel?.Area.SID ?? "");
12101223
}
12111224

12121225
private static bool gymSubmenuSelected(OuiChapterPanel panel = null) {
12131226
panel = panel ?? getChapterPanel();
12141227
return panel != null && (new DynData<Overworld>(panel.Overworld).Data.ContainsKey("gymExitMapSID") ||
12151228
(panel.Area.Mode == AreaMode.BSide && CollabMapDataProcessor.GymLevels.ContainsKey(
1216-
new DynData<Overworld>(panel.Overworld).Get<AreaData>("collabInGameForcedArea").GetSID())));
1229+
new DynData<Overworld>(panel.Overworld).Get<AreaData>("collabInGameForcedArea").SID)));
12171230
}
12181231

12191232
private static bool returnToLobbySelected(OuiChapterPanel panel = null) {

UI/LobbyMapUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ public bool updateSelectedLobby(bool first = false) {
616616
heartSprite.JustifyOrigin(Vector2.Zero);
617617
Add(heartSprite);
618618

619-
var levelSetStats = SaveData.Instance.GetLevelSets().FirstOrDefault(ls => ls.Name == lobbyMapInfo.LevelSet);
619+
var levelSetStats = SaveData.Instance.LevelSets.FirstOrDefault(ls => ls.Name == lobbyMapInfo.LevelSet);
620620
heartCount = levelSetStats?.TotalHeartGems ?? 0;
621621
}
622622

0 commit comments

Comments
 (0)