diff --git a/src/field/trainer.ts b/src/field/trainer.ts index a543568fbc7..24fa56f6b55 100644 --- a/src/field/trainer.ts +++ b/src/field/trainer.ts @@ -229,6 +229,7 @@ export default class Trainer extends Phaser.GameObjects.Container { let title = true && this.config.title ? this.config.title : null; if (this.name === "" && name.toLowerCase().includes("grunt")) { + return "Grunt"; // This is a evil team grunt so we localize it by only using the "name" as the title title = i18next.t(`trainerClasses:${name.toLowerCase().replace(/\s/g, "_")}`); console.log("Localized grunt name: " + title); diff --git a/src/phases.ts b/src/phases.ts index 60a9b99303d..e034a9ed88b 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -403,12 +403,12 @@ export class TitlePhase extends Phase { }); } - getLastSave(log?: boolean, dailyOnly?: boolean): SessionSaveData { + getLastSave(log?: boolean, dailyOnly?: boolean, noDaily?: boolean): SessionSaveData { var saves: Array> = []; for (var i = 0; i < 5; i++) { var s = parseSlotData(i); if (s != undefined) { - if (!dailyOnly || s.gameMode == GameModes.DAILY) { + if ((!noDaily && !dailyOnly) || (s.gameMode == GameModes.DAILY && dailyOnly) || (s.gameMode != GameModes.DAILY && noDaily)) { saves.push([i, s, s.timestamp]); } } @@ -419,6 +419,36 @@ export class TitlePhase extends Phase { if (saves[0] == undefined) return undefined; return saves[0][1] } + getLastSavesOfEach(log?: boolean): SessionSaveData[] { + var saves: Array> = []; + for (var i = 0; i < 5; i++) { + var s = parseSlotData(i); + if (s != undefined) { + saves.push([i, s, s.timestamp]); + } + } + saves.sort((a, b): integer => {return b[2] - a[2]}) + if (log) console.log(saves) + if (saves == undefined) return undefined; + if (saves[0] == undefined) return undefined; + var validSaves = [] + var hasNormal = false; + var hasDaily = false; + for (var i = 0; i < saves.length; i++) { + if (saves[i][1].gameMode == GameModes.DAILY && !hasDaily) { + hasDaily = true; + validSaves.push(saves[i]) + } + if (saves[i][1].gameMode != GameModes.DAILY && !hasNormal) { + hasNormal = true; + validSaves.push(saves[i]) + } + } + console.log(saves, validSaves) + if (validSaves.length == 0) + return undefined; + return validSaves.map(f => f[1]); + } getSaves(log?: boolean, dailyOnly?: boolean): SessionSaveData[] { var saves: Array> = []; for (var i = 0; i < 5; i++) { @@ -549,10 +579,32 @@ export class TitlePhase extends Phase { // Replaces 'Continue' with all Daily Run saves, sorted by when they last saved // If there are no daily runs, it instead shows the most recently saved run // If this fails too, there are no saves, and the option does not appear - var lastsaves = this.getSaves(false, true); - //lastsaves = this.getSavesUnsorted() - if (lastsaves != undefined && lastsaves.length > 0) { - lastsaves.forEach(lastsave => { + var lastsaves = this.getSaves(false, true); // Gets all Daily Runs sorted by last play time + var lastsave = this.getLastSave(); // Gets the last save you played + var ls1 = this.getLastSave(false, true) + var ls2 = this.getLastSavesOfEach() + switch (true) { + case (this.scene.quickloadDisplayMode == "Daily" && this.getLastSave(false, true) != undefined): + options.push({ + label: (ls1.description ? ls1.description : "[???]"), + handler: () => { + this.loadSaveSlot(ls1.slot); + return true; + } + }) + break; + case this.scene.quickloadDisplayMode == "Dailies" && this.getLastSave(false, true) != undefined: + lastsaves.forEach(lastsave1 => { + options.push({ + label: (lastsave1.description ? lastsave1.description : "[???]"), + handler: () => { + this.loadSaveSlot(lastsave1.slot); + return true; + } + }) + }) + break; + case lastsave != undefined && (this.scene.quickloadDisplayMode == "Latest" || ((this.scene.quickloadDisplayMode == "Daily" || this.scene.quickloadDisplayMode == "Dailies") && this.getLastSave(false, true) == undefined)): options.push({ label: (lastsave.description ? lastsave.description : "[???]"), handler: () => { @@ -560,20 +612,19 @@ export class TitlePhase extends Phase { return true; } }) - }) - } else { - var lastsave = this.getLastSave(false); - if (lastsave != undefined) { - options.push({ - label: (lastsave.description ? lastsave.description : "[???]"), - handler: () => { - this.loadSaveSlot(lastsave.slot); - return true; - } + break; + case this.scene.quickloadDisplayMode == "Both" && ls2 != undefined: + ls2.forEach(lastsave2 => { + options.push({ + label: (lastsave2.description ? lastsave2.description : "[???]"), + handler: () => { + this.loadSaveSlot(lastsave2.slot); + return true; + } + }) }) - } else { - console.log("Failed to get last save") - this.getLastSave(true) + break; + default: // If set to "Off" or all above conditions failed if (loggedInUser.lastSessionSlot > -1) { options.push({ label: i18next.t("continue", null, { ns: "menu"}), @@ -583,7 +634,7 @@ export class TitlePhase extends Phase { } }); } - } + break; } options.push({ label: i18next.t("menu:newGame"), diff --git a/src/system/settings/settings.ts b/src/system/settings/settings.ts index 5bf04301dfc..53f4ee66c79 100644 --- a/src/system/settings/settings.ts +++ b/src/system/settings/settings.ts @@ -105,8 +105,7 @@ export const SettingKeys = { ShowAutosaves: "SHOW_AUTOSAVES", TitleScreenContinueMode: "TITLE_SCREEN_QUICKLOAD", BiomePanels: "BIOME_PANELS", - DailyShinyLuck: "DAILY_LUCK", - QuickloadDisplay: "QUICKLOAD_MODE" + DailyShinyLuck: "DAILY_LUCK" }; /** @@ -214,7 +213,7 @@ export const Setting: Array = [ label: "Both", value: "Both" // Shows the last run and the last Daily Run, or only the last played game if it is a Daily Run }], - default: 2, + default: 1, type: SettingType.GENERAL, }, { @@ -722,7 +721,7 @@ export function setSetting(scene: BattleScene, setting: string, value: integer): scene.doBiomePanels = Setting[index].options[value].value == "On" case SettingKeys.DailyShinyLuck: scene.disableDailyShinies = Setting[index].options[value].value == "Off" - case SettingKeys.QuickloadDisplay: + case SettingKeys.TitleScreenContinueMode: scene.quickloadDisplayMode = Setting[index].options[value].value; case SettingKeys.Skip_Seen_Dialogues: scene.skipSeenDialogues = Setting[index].options[value].value === "On";