Skip to content

Commit c6d35da

Browse files
committed
Merge branch 'stable' into dev
2 parents 72da0f9 + 92cf4df commit c6d35da

4 files changed

Lines changed: 6 additions & 92 deletions

File tree

Celeste.Mod.mm/Content/Dialog/English.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@
187187
LEVELSET_CELESTE= Celeste
188188
LEVELSET_= Uncategorized
189189

190-
MISSING_VANILLA_DATA= Missing Vanilla data :(
191-
192190
# Updater
193191
UPDATER_TITLE= UPDATER
194192
UPDATER_LEGACYREF_TITLE= LEGACYREF SETUP

Celeste.Mod.mm/Patches/OuiFileSelect.cs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,12 @@
88
using Mono.Cecil;
99
using Mono.Cecil.Cil;
1010
using MonoMod.Cil;
11-
using Celeste.Mod;
1211

1312
namespace Celeste {
1413
class patch_OuiFileSelect : OuiFileSelect {
1514

1615
internal bool startingNewFile;
1716

18-
public extern void orig_LoadThread();
19-
public new void LoadThread() {
20-
orig_LoadThread();
21-
22-
string saveFilePath = patch_UserIO.GetSaveFilePath();
23-
if (!Directory.Exists(saveFilePath))
24-
return;
25-
26-
for (int i = 0; i < Slots.Count() - 1; i++) { // - 1, last slot is always empty
27-
if (!Slots[i].Exists && Directory.GetFiles(saveFilePath, $"{i}-mod*.celeste").Length > 0) {
28-
Logger.Warn("OuiFileSelect", $"Save slot {i} has modded data but no vanilla save data, flagging as corrupted");
29-
((patch_OuiFileSelectSlot) Slots[i]).MissingVanillaData = true;
30-
Slots[i].Corrupted = true;
31-
Slots[i].Exists = true; // both `Corrupted` and `Exists` flags must be set
32-
}
33-
}
34-
}
35-
3617
[PatchOuiFileSelectSubmenuChecks] // we want to manipulate the orig method with MonoModRules
3718
public extern IEnumerator orig_Enter(Oui from);
3819
public new IEnumerator Enter(Oui from) {
@@ -47,16 +28,12 @@ class patch_OuiFileSelect : OuiFileSelect {
4728
maxSaveFile = 1; // we're adding 2 later, so there will be at least 3 slots.
4829
string saveFilePath = patch_UserIO.GetSaveFilePath();
4930
if (Directory.Exists(saveFilePath)) {
50-
foreach (string filePath in Directory.GetFiles(saveFilePath, "*.celeste")) {
31+
foreach (string filePath in Directory.GetFiles(saveFilePath)) {
5132
string fileName = Path.GetFileName(filePath);
5233
// is the file named [number].celeste?
53-
if (int.TryParse(fileName.Substring(0, fileName.Length - 8), out int fileIndex)) {
34+
if (fileName.EndsWith(".celeste") && int.TryParse(fileName.Substring(0, fileName.Length - 8), out int fileIndex)) {
5435
maxSaveFile = Math.Max(maxSaveFile, fileIndex);
5536
}
56-
// or is the file mod data named [number]-mod[save|session]-[modname].celeste?
57-
if (fileName.Contains("-mod") && int.TryParse(fileName.Substring(0, fileName.IndexOf('-')), out int modFileIndex)) {
58-
maxSaveFile = Math.Max(maxSaveFile, modFileIndex);
59-
}
6037
}
6138
}
6239

Celeste.Mod.mm/Patches/OuiFileSelectSlot.cs

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ public interface ISubmenu { }
4444

4545
private OuiFileSelectSlotLevelSetPicker newGameLevelSetPicker;
4646

47-
public bool MissingVanillaData;
48-
4947
// computed maximums for stamp rendering
5048
private int maxStrawberryCount;
5149
private int maxGoldenStrawberryCount;
@@ -206,6 +204,8 @@ private void OnExistingFileRenameSelected() {
206204

207205
public extern void orig_OnNewGameSelected();
208206
public void OnNewGameSelected() {
207+
patch_SaveData.TryDeleteModSaveData(FileSlot);
208+
209209
orig_OnNewGameSelected();
210210

211211
string newGameLevelSet = newGameLevelSetPicker?.NewGameLevelSet;
@@ -291,7 +291,6 @@ public class Button {
291291
public float Scale = 1f;
292292
}
293293

294-
[PatchFileSelectSlotRenderMissingVanillaDataDialog]
295294
[PatchFileSelectSlotRender] // manually manipulate the method via MonoModRules
296295
public extern void orig_Render();
297296
public override void Render() {
@@ -355,12 +354,6 @@ class PatchFileSelectSlotRenderAttribute : Attribute { }
355354
[MonoModCustomMethodAttribute(nameof(MonoModRules.PatchOuiFileSelectSlotOnContinueSelected))]
356355
class PatchOuiFileSelectSlotOnContinueSelectedAttribute : Attribute { }
357356

358-
/// <summary>
359-
/// Patches the method to differentiate between Corrupted and MissingVanillaData.
360-
/// </summary>
361-
[MonoModCustomMethodAttribute(nameof(MonoModRules.PatchFileSelectSlotRenderMissingVanillaDataDialog))]
362-
class PatchFileSelectSlotRenderMissingVanillaDataDialog : Attribute { }
363-
364357
static partial class MonoModRules {
365358

366359
public static void PatchOuiFileSelectSlotUpdate(ILContext context, CustomAttribute attrib) {
@@ -377,48 +370,6 @@ public static void PatchOuiFileSelectSlotUpdate(ILContext context, CustomAttribu
377370
cursor.Next.OpCode = OpCodes.Brfalse;
378371
}
379372

380-
public static void PatchFileSelectSlotRenderMissingVanillaDataDialog(ILContext context, CustomAttribute attrib) {
381-
TypeDefinition declaringType = context.Method.DeclaringType;
382-
FieldDefinition f_MissingVanillaData = declaringType.FindField("MissingVanillaData");
383-
384-
ILCursor cursor = new ILCursor(context);
385-
386-
// C# change:
387-
// [...]
388-
// else if (Corrupted)
389-
// {
390-
// - ActiveFont.Draw(Dialog.Clean("file_corrupted"), slide2, new Vector2(0.5f, 0.5f), Vector2.One, Color.Black * 0.8f);
391-
// + ActiveFont.Draw(Dialog.Clean((!MissingVanillaData) ? "file_corrupted" : "MISSING_VANILLA_DATA"), vector3, new Vector2(0.5f, 0.5f), Vector2.One, Color.Black * 0.8f);
392-
// }
393-
// [...]
394-
395-
// IL change:
396-
// [...]
397-
// ldfld System.Boolean Celeste.OuiFileSelectSlot::Corrupted
398-
// brfalse.s (...)
399-
// + ldarg.0
400-
// + ldfld bool Celeste.OuiFileSelectSlot::MissingVanillaData
401-
// + brfalse.s ldstr
402-
// + ldstr "MISSING_VANILLA_DATA"
403-
// + br.s ldnull
404-
// ldstr : ldstr "file_corrupted"
405-
// ldnull : ldnull
406-
// call string Celeste.Dialog::Clean(string, class Celeste.Language)
407-
// [...]
408-
409-
cursor.GotoNext(MoveType.Before, instr => instr.MatchLdstr("file_corrupted"));
410-
ILLabel ldstr = cursor.MarkLabel();
411-
cursor.GotoNext();
412-
ILLabel ldnull = cursor.MarkLabel();
413-
414-
cursor.GotoLabel(ldstr, MoveType.Before);
415-
cursor.EmitLdarg0();
416-
cursor.EmitLdfld(f_MissingVanillaData);
417-
cursor.EmitBrfalse(ldstr);
418-
cursor.EmitLdstr("MISSING_VANILLA_DATA");
419-
cursor.EmitBr(ldnull);
420-
}
421-
422373
public static void PatchFileSelectSlotRender(ILContext context, CustomAttribute attrib) {
423374
TypeDefinition declaringType = context.Method.DeclaringType;
424375
FieldDefinition f_maxStrawberryCount = declaringType.FindField("maxStrawberryCount");

Celeste.Mod.mm/Patches/SaveData.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using MonoMod;
77
using System;
88
using System.Collections.Generic;
9-
using System.IO;
109
using System.Linq;
1110
using System.Runtime.CompilerServices;
1211
using System.Xml;
@@ -298,19 +297,8 @@ public static void LoadModSaveData(int slot) {
298297

299298
public static extern bool orig_TryDelete(int slot);
300299
public static new bool TryDelete(int slot) {
301-
bool vanillaExists = false;
302-
string saveFilePath = patch_UserIO.GetSaveFilePath();
303-
if (Directory.Exists(saveFilePath))
304-
vanillaExists = File.Exists(Path.Combine(saveFilePath, $"{slot}.celeste"));
305-
306-
if (vanillaExists) {
307-
if (!orig_TryDelete(slot)) {
308-
return false;
309-
}
310-
}
311-
else
312-
Logger.Warn("SaveData", $"Deleting save data for slot {slot} which has no vanilla data");
313-
300+
if (!orig_TryDelete(slot))
301+
return false;
314302
return TryDeleteModSaveData(slot);
315303
}
316304

0 commit comments

Comments
 (0)