Skip to content

Commit 9760574

Browse files
committed
Make lobby skull icon match the levels' skull icons in the overworld
1 parent ff7a609 commit 9760574

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

DOCUMENTATION.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ If you don't define those images, they will use A-side skulls instead.
255255

256256
You can take the skulls that ship with the collab utils as a reference.
257257

258+
You can change the chapter panel skull icon for **any** campaign using this feature: if the maps are in `Maps/foldername`, put the skull icon at `Graphics/Atlases/Gui/CollabUtils2/skulls/foldername`.
259+
258260
### Journal Trigger
259261

260262
This trigger allows you to bring up a journal similar to the overworld, but showing your progress on a particular level set. This journal will also include speed berry PBs.

UI/InGameOverworldHelper.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -571,18 +571,24 @@ private static void OnChapterPanelUpdateStats(On.Celeste.OuiChapterPanel.orig_Up
571571
bool? overrideStrawberryWiggle, bool? overrideDeathWiggle, bool? overrideHeartWiggle) {
572572

573573
orig(self, wiggle, overrideStrawberryWiggle, overrideDeathWiggle, overrideHeartWiggle);
574-
574+
575+
DeathsCounter deathsCounter = new DynData<OuiChapterPanel>(self).Get<DeathsCounter>("deaths");
576+
575577
if (Engine.Scene == overworldWrapper?.Scene) {
578+
// within lobbies, death counts always show up, even if you didn't beat the map yet.
576579
AreaModeStats areaModeStats = self.DisplayedStats.Modes[(int) self.Area.Mode];
577-
DeathsCounter deathsCounter = new DynData<OuiChapterPanel>(self).Get<DeathsCounter>("deaths");
578580
deathsCounter.Visible = areaModeStats.Deaths > 0 && !AreaData.Get(self.Area).Interlude_Safe;
581+
}
579582

580-
// mod the death icon
581-
string pathToSkull = "CollabUtils2/skulls/" + self.Area.GetLevelSet();
582-
if (GFX.Gui.Has(pathToSkull)) {
583-
new DynData<DeathsCounter>(deathsCounter)["icon"] = GFX.Gui[pathToSkull];
584-
}
583+
// mod the death icon: for the path, use the current level set, or for lobbies, the lobby's matching level set.
584+
string pathToSkull = "CollabUtils2/skulls/" + self.Area.GetLevelSet();
585+
if (LobbyHelper.GetLobbyLevelSet(self.Area.GetSID()) != null) {
586+
pathToSkull = "CollabUtils2/skulls/" + LobbyHelper.GetLobbyLevelSet(self.Area.GetSID());
587+
}
588+
if (GFX.Gui.Has(pathToSkull)) {
589+
new DynData<DeathsCounter>(deathsCounter)["icon"] = GFX.Gui[pathToSkull];
585590
}
591+
new DynData<DeathsCounter>(deathsCounter)["modifiedByCollabUtils"] = GFX.Gui.Has(pathToSkull);
586592

587593

588594
if (isPanelShowingLobby(self) || Engine.Scene == overworldWrapper?.Scene) {
@@ -602,9 +608,11 @@ private static void ModDeathsCounterRender(ILContext il) {
602608
while (cursor.TryGotoNext(MoveType.After, instr => instr.MatchLdcR4(62f))) {
603609
Logger.Log("CollabUtils2/InGameOverworldHelper", $"Unhardcoding death icon width at {cursor.Index} in IL for DeathsCounter.Render");
604610
cursor.Emit(OpCodes.Ldarg_0);
611+
cursor.Emit(OpCodes.Ldarg_0);
605612
cursor.Emit(OpCodes.Ldfld, typeof(DeathsCounter).GetField("icon", BindingFlags.NonPublic | BindingFlags.Instance));
606-
cursor.EmitDelegate<Func<float, MTexture, float>>((orig, icon) => {
607-
if (Engine.Scene == overworldWrapper?.Scene) {
613+
cursor.EmitDelegate<Func<float, DeathsCounter, MTexture, float>>((orig, self, icon) => {
614+
DynData<DeathsCounter> data = new DynData<DeathsCounter>(self);
615+
if (data.Data.ContainsKey("modifiedByCollabUtils") && data.Get<bool>("modifiedByCollabUtils")) {
608616
return icon.Width - 4; // vanilla icons are 66px wide.
609617
}
610618
return orig;

0 commit comments

Comments
 (0)