mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-26 17:29:30 +02:00
New log handler UI
Created a new UI for selecting logs to modify, since using a text box wouldn't work if you had many logs It displays the date, name, starters (if stored), and a bit of other info
This commit is contained in:
parent
4e3fbe0c01
commit
898a153104
@ -888,7 +888,7 @@ export interface PokeData {
|
||||
*/
|
||||
export function exportPokemon(pokemon: Pokemon, encounterRarity?: string): PokeData {
|
||||
return {
|
||||
id: pokemon.species.speciesId,
|
||||
id: Utils.getEnumValues(Species).indexOf(pokemon.species.speciesId),
|
||||
name: pokemon.species.getName(),
|
||||
ability: pokemon.getAbility().name,
|
||||
isHiddenAbility: pokemon.hasAbility(pokemon.species.abilityHidden),
|
||||
@ -1388,6 +1388,51 @@ export function generateEditHandler(scene: BattleScene, logId: string, callback:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Generates a UI option to save a log to your device.
|
||||
* @param i The slot number. Corresponds to an index in `logs`.
|
||||
* @param saves Your session data. Used to label logs if they match one of your save slots.
|
||||
* @returns A UI option.
|
||||
*/
|
||||
export function generateEditHandlerForLog(scene: BattleScene, i: integer, callback: Function) {
|
||||
return (): boolean => {
|
||||
rarityslot[1] = logs[i][1]
|
||||
//scene.phaseQueue[0].end()
|
||||
scene.ui.setMode(Mode.NAME_LOG, {
|
||||
autofillfields: [
|
||||
(JSON.parse(localStorage.getItem(logs[i][1])) as DRPD).title,
|
||||
(JSON.parse(localStorage.getItem(logs[i][1])) as DRPD).authors.join(", "),
|
||||
(JSON.parse(localStorage.getItem(logs[i][1])) as DRPD).label,
|
||||
],
|
||||
buttonActions: [
|
||||
() => {
|
||||
console.log("Rename")
|
||||
scene.ui.playSelect();
|
||||
callback()
|
||||
},
|
||||
() => {
|
||||
console.log("Export")
|
||||
scene.ui.playSelect();
|
||||
downloadLogByID(i)
|
||||
callback()
|
||||
},
|
||||
() => {
|
||||
console.log("Export to Sheets")
|
||||
scene.ui.playSelect();
|
||||
downloadLogByIDToSheet(i)
|
||||
callback()
|
||||
},
|
||||
() => {
|
||||
console.log("Delete")
|
||||
scene.ui.playSelect();
|
||||
localStorage.removeItem(logs[i][1])
|
||||
callback()
|
||||
}
|
||||
]
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
|
@ -702,19 +702,20 @@ export class TitlePhase extends Phase {
|
||||
label: "Manage Logs",
|
||||
handler: () => {
|
||||
this.scene.biomeChangeMode = false
|
||||
return this.logRenameMenu()
|
||||
/*
|
||||
//return this.logRenameMenu()
|
||||
//
|
||||
this.scene.ui.setOverlayMode(Mode.LOG_HANDLER,
|
||||
(k: string) => {
|
||||
if (k === undefined) {
|
||||
return this.showOptions();
|
||||
}
|
||||
console.log(k)
|
||||
this.showOptions();
|
||||
}, () => {
|
||||
this.showOptions();
|
||||
});
|
||||
return true;
|
||||
*/
|
||||
//
|
||||
}
|
||||
})
|
||||
options.push({
|
||||
|
@ -54,22 +54,23 @@ export default class LogNameFormUiHandler extends FormModalUiHandler {
|
||||
//const label = addTextObject(this.scene, 10, 87, "Clicking Export or ExSheets does NOT save any text you entered\nPress \"Rename\", then reopen this menu and click Export", TextStyle.TOOLTIP_CONTENT, { fontSize: "42px" });
|
||||
//this.modalContainer.add(label);
|
||||
|
||||
this.inputs[0].maxLength = 99
|
||||
this.inputs[1].maxLength = 200
|
||||
this.inputs[0].maxLength = 99;
|
||||
this.inputs[1].maxLength = 200;
|
||||
}
|
||||
|
||||
show(args: any[]): boolean {
|
||||
this.name = args[0].autofillfields[0]
|
||||
console.log(args)
|
||||
this.name = args[0].autofillfields[0];
|
||||
if (super.show(args)) {
|
||||
const config = args[0] as ModalConfig;
|
||||
console.log("Shown", args)
|
||||
console.log("Shown", args);
|
||||
|
||||
const originalLoginAction = this.submitAction;
|
||||
this.inputs[0].setText(args[0].autofillfields[0])
|
||||
this.inputs[1].setText(args[0].autofillfields[1])
|
||||
this.inputs[2].setText(args[0].autofillfields[2])
|
||||
this.inputs[0].setText(args[0].autofillfields[0]);
|
||||
this.inputs[1].setText(args[0].autofillfields[1]);
|
||||
this.inputs[2].setText(args[0].autofillfields[2]);
|
||||
this.submitAction = (_) => {
|
||||
console.log("submitAction")
|
||||
console.log("submitAction");
|
||||
// Prevent overlapping overrides on action modification
|
||||
this.submitAction = originalLoginAction;
|
||||
this.sanitizeInputs();
|
||||
@ -81,21 +82,21 @@ export default class LogNameFormUiHandler extends FormModalUiHandler {
|
||||
if (!this.inputs[0].text) {
|
||||
//return onFail(i18next.t("menu:emptyUsername"));
|
||||
}
|
||||
console.log(`Calling LoggerTools.setFileInfo(${this.inputs[0].text}, ${this.inputs[1].text.split(",")})`)
|
||||
LoggerTools.setFileInfo(this.inputs[0].text, this.inputs[1].text.split(","))
|
||||
console.log(`Calling originalLoginAction()`)
|
||||
originalLoginAction()
|
||||
console.log(`Calling LoggerTools.setFileInfo(${this.inputs[0].text}, ${this.inputs[1].text.split(",")})`);
|
||||
LoggerTools.setFileInfo(this.inputs[0].text, this.inputs[1].text.split(","));
|
||||
console.log("Calling originalLoginAction()");
|
||||
originalLoginAction();
|
||||
};
|
||||
const exportaction1 = config.buttonActions[1]
|
||||
const exportaction1 = config.buttonActions[1];
|
||||
config.buttonActions[1] = (_) => {
|
||||
LoggerTools.setFileInfo(this.inputs[0].text, this.inputs[1].text.split(","))
|
||||
exportaction1()
|
||||
}
|
||||
const exportaction2 = config.buttonActions[2]
|
||||
LoggerTools.setFileInfo(this.inputs[0].text, this.inputs[1].text.split(","));
|
||||
exportaction1();
|
||||
};
|
||||
const exportaction2 = config.buttonActions[2];
|
||||
config.buttonActions[2] = (_) => {
|
||||
LoggerTools.setFileInfo(this.inputs[0].text, this.inputs[1].text.split(","))
|
||||
exportaction2()
|
||||
}
|
||||
LoggerTools.setFileInfo(this.inputs[0].text, this.inputs[1].text.split(","));
|
||||
exportaction2();
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -15,9 +15,10 @@ import { loggedInUser } from "#app/account.js";
|
||||
import { allpanels, biomePanelIDs } from "../loading-scene"
|
||||
import { getBiomeName } from "#app/data/biomes.js";
|
||||
import { Species } from "#app/enums/species.js";
|
||||
import { getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species.js";
|
||||
import { allSpecies, getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species.js";
|
||||
|
||||
const sessionSlotCount = 5;
|
||||
const gap = 20;
|
||||
|
||||
export type LogSelectCallback = (key: string) => void;
|
||||
|
||||
@ -30,6 +31,7 @@ export default class LogSelectUiHandler extends MessageUiHandler {
|
||||
private sessionSlots: SessionSlot[];
|
||||
|
||||
private selectCallback: LogSelectCallback;
|
||||
private quitCallback: LogSelectCallback;
|
||||
|
||||
private scrollCursor: integer = 0;
|
||||
|
||||
@ -37,6 +39,8 @@ export default class LogSelectUiHandler extends MessageUiHandler {
|
||||
|
||||
private sessionSlotsContainerInitialY: number;
|
||||
|
||||
private extrasLabel: Phaser.GameObjects.Text
|
||||
|
||||
constructor(scene: BattleScene) {
|
||||
super(scene, Mode.LOG_HANDLER);
|
||||
}
|
||||
@ -69,6 +73,10 @@ export default class LogSelectUiHandler extends MessageUiHandler {
|
||||
this.message.setOrigin(0, 0);
|
||||
this.saveSlotSelectMessageBoxContainer.add(this.message);
|
||||
|
||||
this.extrasLabel = addTextObject(this.scene, 40, 56 * 5 + 5, "Other Files", TextStyle.WINDOW);
|
||||
this.extrasLabel.setAlign("center");
|
||||
this.sessionSlotsContainer.add(this.extrasLabel);
|
||||
|
||||
this.sessionSlots = [];
|
||||
}
|
||||
|
||||
@ -80,6 +88,9 @@ export default class LogSelectUiHandler extends MessageUiHandler {
|
||||
super.show(args);
|
||||
|
||||
this.selectCallback = args[0] as LogSelectCallback;
|
||||
this.quitCallback = args[1] as LogSelectCallback;
|
||||
|
||||
console.log(this.selectCallback)
|
||||
|
||||
this.saveSlotSelectContainer.setVisible(true);
|
||||
this.populateSessionSlots();
|
||||
@ -95,18 +106,19 @@ export default class LogSelectUiHandler extends MessageUiHandler {
|
||||
let success = false;
|
||||
let error = false;
|
||||
|
||||
if (button === Button.ACTION || button === Button.CANCEL) {
|
||||
if (button === Button.ACTION) {
|
||||
const originalCallback = this.selectCallback;
|
||||
if (button === Button.ACTION) {
|
||||
const cursor = this.cursor + this.scrollCursor;
|
||||
const cursor = this.cursor + this.scrollCursor;
|
||||
var k = this.sessionSlots[cursor].key
|
||||
var file = JSON.parse(localStorage.getItem(k)) as LoggerTools.DRPD;
|
||||
console.log(k, file)
|
||||
LoggerTools.generateEditHandlerForLog(this.scene, this.sessionSlots[cursor].logIndex, () => {
|
||||
this.selectCallback = null;
|
||||
originalCallback(this.sessionSlots[cursor].key);
|
||||
success = true;
|
||||
} else {
|
||||
this.selectCallback = null;
|
||||
originalCallback(undefined);
|
||||
success = true;
|
||||
}
|
||||
originalCallback(k)
|
||||
})()
|
||||
success = true;
|
||||
} else if (button === Button.CANCEL) {
|
||||
this.quitCallback(undefined);
|
||||
} else {
|
||||
switch (button) {
|
||||
case Button.UP:
|
||||
@ -147,6 +159,7 @@ export default class LogSelectUiHandler extends MessageUiHandler {
|
||||
const sessionSlot = new SessionSlot(this.scene, s, ypos);
|
||||
ypos++
|
||||
sessionSlot.load(LoggerTools.logs[i][1]);
|
||||
sessionSlot.logIndex = i
|
||||
this.scene.add.existing(sessionSlot);
|
||||
this.sessionSlotsContainer.add(sessionSlot);
|
||||
this.sessionSlots.push(sessionSlot);
|
||||
@ -154,11 +167,11 @@ export default class LogSelectUiHandler extends MessageUiHandler {
|
||||
}
|
||||
if (!found) {
|
||||
const sessionSlot = new SessionSlot(this.scene, s, ypos);
|
||||
ypos++
|
||||
sessionSlot.load(undefined);
|
||||
this.scene.add.existing(sessionSlot);
|
||||
this.sessionSlotsContainer.add(sessionSlot);
|
||||
this.sessionSlots.push(sessionSlot);
|
||||
ypos++
|
||||
sessionSlot.load(undefined);
|
||||
this.scene.add.existing(sessionSlot);
|
||||
this.sessionSlotsContainer.add(sessionSlot);
|
||||
this.sessionSlots.push(sessionSlot);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < LoggerTools.logs.length; i++) {
|
||||
@ -166,6 +179,7 @@ export default class LogSelectUiHandler extends MessageUiHandler {
|
||||
const sessionSlot = new SessionSlot(this.scene, undefined, ypos);
|
||||
ypos++
|
||||
sessionSlot.load(LoggerTools.logs[i][1]);
|
||||
sessionSlot.logIndex = i
|
||||
this.scene.add.existing(sessionSlot);
|
||||
this.sessionSlotsContainer.add(sessionSlot);
|
||||
this.sessionSlots.push(sessionSlot);
|
||||
@ -195,7 +209,7 @@ export default class LogSelectUiHandler extends MessageUiHandler {
|
||||
this.cursorObj.setOrigin(0, 0);
|
||||
this.sessionSlotsContainer.add(this.cursorObj);
|
||||
}
|
||||
this.cursorObj.setPosition(4, 4 + (cursor + this.scrollCursor) * 56);
|
||||
this.cursorObj.setPosition(4, 4 + (cursor + this.scrollCursor) * 56 + ((cursor + this.scrollCursor) > 4 ? gap : 0));
|
||||
|
||||
return changed;
|
||||
}
|
||||
@ -208,7 +222,7 @@ export default class LogSelectUiHandler extends MessageUiHandler {
|
||||
this.setCursor(this.cursor);
|
||||
this.scene.tweens.add({
|
||||
targets: this.sessionSlotsContainer,
|
||||
y: this.sessionSlotsContainerInitialY - 56 * scrollCursor,
|
||||
y: this.sessionSlotsContainerInitialY - 56 * scrollCursor - ((this.cursor + this.scrollCursor) > 4 ? gap : 0),
|
||||
duration: Utils.fixedInt(325),
|
||||
ease: "Sine.easeInOut"
|
||||
});
|
||||
@ -245,9 +259,10 @@ class SessionSlot extends Phaser.GameObjects.Container {
|
||||
public wv: integer;
|
||||
public key: string;
|
||||
private loadingLabel: Phaser.GameObjects.Text;
|
||||
public logIndex: integer;
|
||||
|
||||
constructor(scene: BattleScene, slotId: integer = undefined, ypos: integer, autoSlot?: integer) {
|
||||
super(scene, 0, ypos * 56);
|
||||
super(scene, 0, ypos * 56 + (ypos > 4 ? gap : 0));
|
||||
|
||||
this.slotId = slotId;
|
||||
this.autoSlot = autoSlot
|
||||
@ -269,7 +284,7 @@ class SessionSlot extends Phaser.GameObjects.Container {
|
||||
var lbl = `???`
|
||||
lbl = data.title
|
||||
if (this.slotId) {
|
||||
lbl = `[${this.slotId}] ${lbl}`
|
||||
lbl = `[${this.slotId + 1}] ${lbl}`
|
||||
}
|
||||
console.log(data, this.slotId, this.autoSlot, lbl)
|
||||
const gameModeLabel = addTextObject(this.scene, 8, 5, lbl, TextStyle.WINDOW);
|
||||
@ -278,9 +293,14 @@ class SessionSlot extends Phaser.GameObjects.Container {
|
||||
const timestampLabel = addTextObject(this.scene, 8, 19, data.date, TextStyle.WINDOW);
|
||||
this.add(timestampLabel);
|
||||
|
||||
const playTimeLabel = addTextObject(this.scene, 8, 33, data.version + " / " + (data.label || "") + " / " + (data.uuid || ""), TextStyle.WINDOW);
|
||||
const playTimeLabel = addTextObject(this.scene, 8, 33, data.version + " / Path: " + (data.label || ""), TextStyle.WINDOW);
|
||||
this.add(playTimeLabel);
|
||||
|
||||
if (data.starters[0] == null) {
|
||||
const timestampLabel = addTextObject(this.scene, 144, 10, "No Starter data", TextStyle.WINDOW);
|
||||
this.add(timestampLabel);
|
||||
}
|
||||
|
||||
const pokemonIconsContainer = this.scene.add.container(144, 4);
|
||||
if (false || data.starters)
|
||||
data.starters.forEach((p: LoggerTools.PokeData, i: integer) => {
|
||||
@ -288,16 +308,17 @@ class SessionSlot extends Phaser.GameObjects.Container {
|
||||
return;
|
||||
const iconContainer = this.scene.add.container(26 * i, 0);
|
||||
iconContainer.setScale(0.75);
|
||||
console.log(p.id, Utils.getEnumKeys(Species)[Utils.getEnumValues(Species).indexOf(p.id)])
|
||||
|
||||
if (Utils.getEnumValues(Species)[p.id] == undefined)
|
||||
return;
|
||||
//if (Utils.getEnumValues(Species)[p.id] == undefined)
|
||||
//return;
|
||||
|
||||
if (getPokemonSpecies(Utils.getEnumValues(Species)[p.id]) == undefined)
|
||||
return;
|
||||
//if (getPokemonSpecies(Utils.getEnumValues(Species)[p.id]) == undefined)
|
||||
//return;
|
||||
|
||||
const icon = this.scene.addPkIcon(getPokemonSpecies(Utils.getEnumValues(Species)[p.id]), 0, 0, 0, 0, 0);
|
||||
const icon = this.scene.addPkIcon(allSpecies[Utils.getEnumValues(Species).indexOf(p.id)], 0, 0, 0, 0, 0);
|
||||
|
||||
const text = addTextObject(this.scene, 32, 20, `${i18next.t("saveSlotSelectUiHandler:lv")}${Utils.formatLargeNumber(p.level, 1000)}`, TextStyle.PARTY, { fontSize: "54px", color: "#f8f8f8" });
|
||||
const text = addTextObject(this.scene, 32, 20, ``, TextStyle.PARTY, { fontSize: "54px", color: "#f8f8f8" });
|
||||
text.setShadow(0, 0, null);
|
||||
text.setStroke("#424242", 14);
|
||||
text.setOrigin(1, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user