Skip to content

Commit 2291e57

Browse files
committed
Restore "Merge pull request #890 from SnipUndercover/reload-vanillla-portraits-on-map-exit"
This reverts commit 2cc15b9.
1 parent 948d9b3 commit 2291e57

1 file changed

Lines changed: 32 additions & 26 deletions

File tree

Celeste.Mod.mm/Patches/Level.cs

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Collections;
2121
using System.Collections.Generic;
2222
using System.Collections.ObjectModel;
23+
using System.IO;
2324
using System.Linq;
2425
using System.Runtime.CompilerServices;
2526

@@ -29,12 +30,12 @@ class patch_Level : Level {
2930
// We're effectively in GameLoader, but still need to "expose" private fields to our mod.
3031
private float flash;
3132

32-
private Color flashColor = Color.White;
33-
33+
private Color flashColor = Color.White;
34+
3435
private bool doFlash;
3536

36-
private bool flashDrawPlayer;
37-
37+
private bool flashDrawPlayer;
38+
3839
private static EventInstance PauseSnapshot;
3940
public static EventInstance _PauseSnapshot => PauseSnapshot;
4041

@@ -102,19 +103,19 @@ public static void RegisterLoadOverride(Level level, LoadOverride loadOverride)
102103
[PatchLevelUpdate] // ... except for manually manipulating the method via MonoModRules
103104
public extern new void Update();
104105

105-
/// <summary>
106-
/// Flash the screen a solid color. Respects the user's advanced photosensitivity settings.
107-
/// </summary>
108-
/// <param name="color"></param>
106+
/// <summary>
107+
/// Flash the screen a solid color. Respects the user's advanced photosensitivity settings.
108+
/// </summary>
109+
/// <param name="color"></param>
109110
/// <param name="drawPlayerOver">Whether the player should render over the flash.</param>
110111
[MonoModReplace] // We copy the entirety of this method instead of doing an IL patch because it's 5 lines of code.
111-
public new void Flash(Color color, bool drawPlayerOver = false) {
112-
if (CoreModule.Settings.AllowScreenFlash) {
113-
doFlash = true;
114-
flashDrawPlayer = drawPlayerOver;
115-
flash = 1f;
116-
flashColor = color;
117-
}
112+
public new void Flash(Color color, bool drawPlayerOver = false) {
113+
if (CoreModule.Settings.AllowScreenFlash) {
114+
doFlash = true;
115+
flashDrawPlayer = drawPlayerOver;
116+
flash = 1f;
117+
flashColor = color;
118+
}
118119
}
119120

120121
[MonoModReplace]
@@ -200,19 +201,19 @@ void Unpause() {
200201
}
201202

202203
Everest.Events.Level.Pause(this, startIndex, minimal, quickReset);
203-
}
204-
204+
}
205+
205206
/// <summary>
206207
/// Forcefully close the pause menu; resume from paused.
207-
/// </summary>
208+
/// </summary>
208209
public void Unpause() {
209-
if (Paused) {
210-
PauseMainMenuOpen = false;
211-
if (Entities.FindFirst<TextMenu>() is patch_TextMenu menu)
212-
menu.CloseAndRun(Everest.SaveSettings(), null);
213-
Paused = false;
214-
Audio.Play("event:/ui/game/unpause");
215-
unpauseTimer = 0.15f;
210+
if (Paused) {
211+
PauseMainMenuOpen = false;
212+
if (Entities.FindFirst<TextMenu>() is patch_TextMenu menu)
213+
menu.CloseAndRun(Everest.SaveSettings(), null);
214+
Paused = false;
215+
Audio.Play("event:/ui/game/unpause");
216+
unpauseTimer = 0.15f;
216217
}
217218
}
218219

@@ -589,8 +590,13 @@ private static void _GCCollect() {
589590
public override void End() {
590591
orig_End();
591592

593+
// reload the vanilla Portraits.xml in case it was overridden by a map
594+
// else, if the Portraits.xml doesn't have portrait_madeline defined,
595+
// the game will crash when trying to load a save file (since it shows madeline's portrait)
596+
GFX.PortraitsSpriteBank = new SpriteBank(GFX.Portraits, Path.Combine("Graphics", "Portraits.xml"));
597+
592598
// if we are not entering PICO-8 or the Reflection Fall cutscene...
593-
if (!(patch_Engine.NextScene is Pico8.Emulator) && !(patch_Engine.NextScene is OverworldReflectionsFall)) {
599+
if (patch_Engine.NextScene is not (Pico8.Emulator or OverworldReflectionsFall)) {
594600
// break all links between this level and its entities.
595601
foreach (Entity entity in Entities) {
596602
((patch_Entity) entity).DissociateFromScene();

0 commit comments

Comments
 (0)