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.
This commit is contained in:
RedstonewolfX 2024-07-30 14:53:55 -04:00
parent 2459d2035f
commit 20bce1205f

View File

@ -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,6 +779,7 @@ export class TitlePhase extends Phase {
return true;
}
})
if (false) {
options.push({
label: i18next.t("menu:dailyRun"),
handler: () => {
@ -749,8 +788,9 @@ export class TitlePhase extends Phase {
return true;
},
keepOpen: true
},
{
})
}
options.push({
label: i18next.t("menu:settings"),
handler: () => {
this.scene.biomeChangeMode = false