From 20bce1205f44991ba5121fed3dbfc9f33ee9598b Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:53:55 -0400 Subject: [PATCH] Add import shortcut in New Game Adds a button to the "New Game" menu that opens the Import Session box. This functions exactly like the "Import Session" button in Manage Data, except it also lists what's in each slot. --- src/phases.ts | 58 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 0ae72d3926d..fb23ce3039e 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -389,6 +389,36 @@ export class TitlePhase extends Phase { this.scene.arenaBg.setTexture(`${getBiomeKey(sessionData.arena.biome)}_bg`); } + confirmSlot = (message: string, slotFilter: (i: integer) => boolean, callback: (i: integer) => void) => { + const p = this; + this.scene.ui.revertMode(); + this.scene.ui.showText(message, null, () => { + const config: OptionSelectConfig = { + options: new Array(5).fill(null).map((_, i) => i).filter(slotFilter).map(i => { + var data = parseSlotData(i) + return { + //label: `${i18next.t("menuUiHandler:slot", {slotNumber: i+1})}`, + label: (data ? data.description : `${i+1}`), + handler: () => { + callback(i); + this.scene.ui.revertMode(); + this.scene.ui.showText(null, 0); + return true; + } + }; + }).concat([{ + label: i18next.t("menuUiHandler:cancel"), + handler: () => { + p.callEnd() + return true + } + }]), + //xOffset: 98 + }; + this.scene.ui.setOverlayMode(Mode.MENU_OPTION_SELECT, config); + }); + }; + start(): void { super.start(); //console.log(LoggerTools.importDocument(JSON.stringify(LoggerTools.newDocument()))) @@ -682,6 +712,14 @@ export class TitlePhase extends Phase { } } ]; + options.push({ + label: i18next.t("menuUiHandler:importSession"), + handler: () => { + this.confirmSlot(i18next.t("menuUiHandler:importSlotSelect"), () => true, slotId => this.scene.gameData.importData(GameDataType.SESSION, slotId)); + return true; + }, + keepOpen: true + }) if (this.scene.gameData.unlocks[Unlockables.SPLICED_ENDLESS_MODE]) { options.push({ label: GameMode.getModeName(GameModes.SPLICED_ENDLESS), @@ -741,16 +779,18 @@ export class TitlePhase extends Phase { return true; } }) + if (false) { + options.push({ + label: i18next.t("menu:dailyRun"), + handler: () => { + this.scene.biomeChangeMode = false + this.setupDaily(); + return true; + }, + keepOpen: true + }) + } options.push({ - label: i18next.t("menu:dailyRun"), - handler: () => { - this.scene.biomeChangeMode = false - this.setupDaily(); - return true; - }, - keepOpen: true - }, - { label: i18next.t("menu:settings"), handler: () => { this.scene.biomeChangeMode = false