private void OuiFileSelectSlotOnEnterFirstArea(On.Celeste.OuiFileSelectSlot.orig_EnterFirstArea orig, OuiFileSelectSlot self) { orig(self); if (!Enabled) { return; } lastTime = 0; }
public new IEnumerator Enter(Oui from) { if (!Loaded) { int maxSaveFile; if (CoreModule.Settings.MaxSaveSlots != null) { maxSaveFile = Math.Max(3, CoreModule.Settings.MaxSaveSlots.Value); } else { // first load: we want to check how many slots there are by checking which files exist in the Saves folder. maxSaveFile = 1; // we're adding 2 later, so there will be at least 3 slots. string saveFilePath = patch_UserIO.GetSaveFilePath(); if (Directory.Exists(saveFilePath)) { foreach (string filePath in Directory.GetFiles(saveFilePath)) { string fileName = Path.GetFileName(filePath); // is the file named [number].celeste? if (fileName.EndsWith(".celeste") && int.TryParse(fileName.Substring(0, fileName.Length - 8), out int fileIndex)) { maxSaveFile = Math.Max(maxSaveFile, fileIndex); } } } // if 2.celeste exists, slot 3 is the last slot filled, therefore we want 4 slots (2 + 2) to always have the latest one empty. maxSaveFile += 2; } Slots = new OuiFileSelectSlot[maxSaveFile]; } int slotIndex = 0; IEnumerator orig = orig_Enter(from); while (orig.MoveNext()) { if (orig.Current is float f && f == 0.02f) { // only apply the delay if the slot is on-screen (less than 2 slots away from the selected one). if (Math.Abs(SlotIndex - slotIndex) <= 2) { yield return(orig.Current); } slotIndex++; }
public OuiFileSelectSlotLevelSetPicker(OuiFileSelectSlot selectSlot) { this.selectSlot = selectSlot; Label = DialogExt.CleanLevelSet(NewGameLevelSet ?? "Celeste"); Scale = 0.5f; Action = () => changeStartingLevelSet(1); // find out what is the width of the biggest level set out there. float levelSetNameWidth = 0; foreach (AreaData areaData in AreaData.Areas) { levelSetNameWidth = Math.Max(levelSetNameWidth, ActiveFont.Measure(DialogExt.CleanLevelSet(areaData.GetLevelSet())).X); } arrowOffset = new Vector2(20f + levelSetNameWidth / 2 * Scale, 0f); }
public OuiFileSelectSlotLevelSetPicker(OuiFileSelectSlot selectSlot) { this.selectSlot = selectSlot; // if the default starting level set still exists, set it by default. if (AreaData.Areas.Any(area => area.GetLevelSet() == CoreModule.Settings.DefaultStartingLevelSet)) { NewGameLevelSet = CoreModule.Settings.DefaultStartingLevelSet; } Label = DialogExt.CleanLevelSet(NewGameLevelSet ?? "Celeste"); Scale = 0.5f; Action = () => changeStartingLevelSet(1); // find out what is the width of the biggest level set out there. float levelSetNameWidth = 0; foreach (AreaData areaData in AreaData.Areas) { levelSetNameWidth = Math.Max(levelSetNameWidth, ActiveFont.Measure(DialogExt.CleanLevelSet(areaData.GetLevelSet())).X); } arrowOffset = new Vector2(20f + levelSetNameWidth / 2 * Scale, 0f); }
internal static void HandleCreateButtons(List <patch_OuiFileSelectSlot.Button> buttons, OuiFileSelectSlot slot, bool fileExists) { if (OnCreateButtons == null) { return; } foreach (Delegate del in OnCreateButtons.GetInvocationList()) { // find the Everest module this delegate belongs to, and load the mod save data from it for the current slot. EverestModule matchingModule = _Modules.Find(module => module.GetType().Assembly == del.Method.DeclaringType.Assembly); EverestModuleSaveData modSaveData = null; if (matchingModule != null) { modSaveData = matchingModule._SaveData; } // call the delegate. del.DynamicInvoke(new object[] { buttons, slot, modSaveData, fileExists }); } }
private static void onOuiFileSelectSlotShow(On.Celeste.OuiFileSelectSlot.orig_Show orig, OuiFileSelectSlot self) { // If we are currently in a collab map, display the lobby level set stats instead. AreaKey?savedLastArea = null; string collab = collabNames.FirstOrDefault(collabName => self.SaveData?.LevelSet != null && self.SaveData.LevelSet.StartsWith($"{collabName}/") && self.SaveData.LevelSet != $"{collabName}/0-Lobbies"); if (collab != null) { AreaData firstMapFromCollab = AreaData.Areas.FirstOrDefault(area => area.GetLevelSet() == $"{collab}/0-Lobbies"); if (firstMapFromCollab != null) { savedLastArea = self.SaveData.LastArea_Safe; self.SaveData.LastArea_Safe = firstMapFromCollab.ToKey(); self.Strawberries.CanWiggle = false; // prevent the strawberry collect sound from playing. } } orig(self); string collab2 = collabNames.FirstOrDefault(collabName => self.SaveData?.LevelSet == $"{collabName}/0-Lobbies"); if (collab2 != null) { // recompute the stats for the collab. int totalStrawberries = 0; int totalGoldenStrawberries = 0; int totalHeartGems = 0; int totalCassettes = 0; int maxStrawberryCount = 0; int maxGoldenStrawberryCount = 0; int maxStrawberryCountIncludingUntracked = 0; int maxCassettes = 0; int maxCrystalHearts = 0; int maxCrystalHeartsExcludingCSides = 0; // aggregate all stats for the collab level sets. foreach (LevelSetStats stats in self.SaveData.LevelSets) { if (stats.Name.StartsWith($"{collab2}/")) { totalStrawberries += stats.TotalStrawberries; totalGoldenStrawberries += stats.TotalGoldenStrawberries; totalHeartGems += countTotalHeartGemsForMapsThatHaveHearts(stats); totalCassettes += stats.TotalCassettes; maxStrawberryCount += stats.MaxStrawberries; maxGoldenStrawberryCount += stats.MaxGoldenStrawberries; maxStrawberryCountIncludingUntracked += stats.MaxStrawberriesIncludingUntracked; maxCassettes += stats.MaxCassettes; maxCrystalHearts += stats.MaxHeartGems; maxCrystalHeartsExcludingCSides += stats.MaxHeartGemsExcludingCSides; } } DynData <OuiFileSelectSlot> slotData = new DynData <OuiFileSelectSlot>(self); slotData["totalGoldenStrawberries"] = totalGoldenStrawberries; slotData["totalHeartGems"] = totalHeartGems; slotData["totalCassettes"] = totalCassettes; slotData["maxStrawberryCount"] = maxStrawberryCount; slotData["maxGoldenStrawberryCount"] = maxGoldenStrawberryCount; slotData["maxStrawberryCountIncludingUntracked"] = maxStrawberryCountIncludingUntracked; slotData["maxCassettes"] = maxCassettes; slotData["maxCrystalHearts"] = maxCrystalHearts; slotData["maxCrystalHeartsExcludingCSides"] = maxCrystalHeartsExcludingCSides; slotData["summitStamp"] = false; slotData["farewellStamp"] = false; self.Strawberries.Amount = totalStrawberries; self.Strawberries.OutOf = maxStrawberryCount; } // figure out if some hearts are customized, and store it in DynData so that a IL hook can access it later. SaveData oldInstance = SaveData.Instance; SaveData.Instance = self.SaveData; List <string> customJournalHearts = new List <string>(); if (self.SaveData != null) { foreach (AreaStats item in self.SaveData.Areas_Safe) { if (item.ID_Safe > self.SaveData.UnlockedAreas_Safe) { break; } if (!AreaData.Areas[item.ID_Safe].Interlude_Safe && AreaData.Areas[item.ID_Safe].CanFullClear) { string lobbyLevelSetName = GetLobbyLevelSet(item.GetSID()); if (lobbyLevelSetName != null && MTN.Journal.Has("CollabUtils2Hearts/" + lobbyLevelSetName)) { customJournalHearts.Add("CollabUtils2Hearts/" + lobbyLevelSetName); } else { customJournalHearts.Add(null); } } } } new DynData <OuiFileSelectSlot>(self)["collabutils2_customhearts"] = customJournalHearts; SaveData.Instance = oldInstance; // Restore the last area if it was replaced at the beginning of this method. if (savedLastArea != null) { self.SaveData.LastArea_Safe = savedLastArea.Value; } }
public static void Goto <T>(OuiFileSelectSlot slot, EverestModuleSaveData modSaveData, bool fileExists) where T : OuiFileSelectSlotSubmenu { slot.Assisting = true; // same animation as assist mode. Goto <T>(overworld => overworld.Goto <OuiFileSelect>(), slot, modSaveData, fileExists); }
protected abstract void addOptionsToMenu(TextMenu menu, OuiFileSelectSlot slot, EverestModuleSaveData modSaveData, bool fileExists);
private static void OuiFileSelectSlotOnOnNewGameSelected(On.Celeste.OuiFileSelectSlot.orig_OnNewGameSelected orig, OuiFileSelectSlot self) { orig(self); if (Manager.Running) { tasStartFileTime = 0; } }
private void CreateBingoButton(On.Celeste.OuiFileSelectSlot.orig_CreateButtons orig, OuiFileSelectSlot self) { orig(self); if (!self.Exists) { var bingoButton = new OuiFileSelectSlot.Button { Action = () => { var contents = TextInput.GetClipboardText(); if (contents.StartsWith("http") && contents.Contains("bingosync.com/room/")) { this.Password = "******"; (self.Scene as Overworld).Goto <OuiTextEntry>().Init <OuiBingoConnecting>("password", s => { this.Password = s; }, 100); this.Username = this.ModSettings.PlayerName.Length == 0 ? self.Name : this.ModSettings.PlayerName; this.RoomUrl = contents; } else { this.LogChat(Dialog.Clean("BINGOCLIENT_BAD_PASTE")); } }, Label = Dialog.Clean("BINGOCLIENT_START_BUTTON"), Scale = 0.7f, }; var buttons = (List <OuiFileSelectSlot.Button>) typeof(OuiFileSelectSlot).GetField("buttons", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self); buttons.Add(bingoButton); } }
private static void onOuiFileSelectSlotShow(On.Celeste.OuiFileSelectSlot.orig_Show orig, OuiFileSelectSlot self) { // If we are currently in a collab map, display the lobby level set stats instead. AreaKey?savedLastArea = null; string collab = collabNames.FirstOrDefault(collabName => self.SaveData?.LevelSet != null && self.SaveData.LevelSet.StartsWith($"{collabName}/") && self.SaveData.LevelSet != $"{collabName}/0-Lobbies"); if (collab != null) { AreaData firstMapFromCollab = AreaData.Areas.FirstOrDefault(area => area.GetLevelSet() == $"{collab}/0-Lobbies"); if (firstMapFromCollab != null) { savedLastArea = self.SaveData.LastArea_Safe; self.SaveData.LastArea_Safe = firstMapFromCollab.ToKey(); self.Strawberries.CanWiggle = false; // prevent the strawberry collect sound from playing. } } orig(self); string collab2 = collabNames.FirstOrDefault(collabName => self.SaveData?.LevelSet == $"{collabName}/0-Lobbies"); if (collab2 != null) { // recompute the stats for the collab. int totalStrawberries = 0; int totalGoldenStrawberries = 0; int totalHeartGems = 0; int totalCassettes = 0; int maxStrawberryCount = 0; int maxGoldenStrawberryCount = 0; int maxStrawberryCountIncludingUntracked = 0; int maxCassettes = 0; int maxCrystalHearts = 0; int maxCrystalHeartsExcludingCSides = 0; // aggregate all stats for the collab level sets. foreach (LevelSetStats stats in self.SaveData.LevelSets) { if (stats.Name.StartsWith($"{collab2}/")) { totalStrawberries += stats.TotalStrawberries; totalGoldenStrawberries += stats.TotalGoldenStrawberries; totalHeartGems += countTotalHeartGemsForMapsThatHaveHearts(stats); totalCassettes += stats.TotalCassettes; maxStrawberryCount += stats.MaxStrawberries; maxGoldenStrawberryCount += stats.MaxGoldenStrawberries; maxStrawberryCountIncludingUntracked += stats.MaxStrawberriesIncludingUntracked; maxCassettes += stats.MaxCassettes; maxCrystalHearts += stats.MaxHeartGems; maxCrystalHeartsExcludingCSides += stats.MaxHeartGemsExcludingCSides; } } DynData <OuiFileSelectSlot> slotData = new DynData <OuiFileSelectSlot>(self); slotData["totalGoldenStrawberries"] = totalGoldenStrawberries; slotData["totalHeartGems"] = totalHeartGems; slotData["totalCassettes"] = totalCassettes; slotData["maxStrawberryCount"] = maxStrawberryCount; slotData["maxGoldenStrawberryCount"] = maxGoldenStrawberryCount; slotData["maxStrawberryCountIncludingUntracked"] = maxStrawberryCountIncludingUntracked; slotData["maxCassettes"] = maxCassettes; slotData["maxCrystalHearts"] = maxCrystalHearts; slotData["maxCrystalHeartsExcludingCSides"] = maxCrystalHeartsExcludingCSides; slotData["summitStamp"] = false; slotData["farewellStamp"] = false; self.Strawberries.Amount = totalStrawberries; self.Strawberries.OutOf = maxStrawberryCount; } // Restore the last area if it was replaced at the beginning of this method. if (savedLastArea != null) { self.SaveData.LastArea_Safe = savedLastArea.Value; } }