mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-26 17:29:30 +02:00
Autosaves
Game will create a duplicate of your save on waves 1, 11, 21, 31, 41, and 50
This commit is contained in:
parent
ff7e215d6c
commit
3af044de2b
@ -414,20 +414,24 @@ export function generateEditOption(scene: BattleScene, i: integer, saves: any, p
|
||||
],
|
||||
buttonActions: [
|
||||
() => {
|
||||
console.log("Rename")
|
||||
scene.ui.playSelect();
|
||||
phase.callEnd()
|
||||
},
|
||||
() => {
|
||||
console.log("Export")
|
||||
scene.ui.playSelect();
|
||||
downloadLogByID(i)
|
||||
phase.callEnd()
|
||||
},
|
||||
() => {
|
||||
console.log("Export to Sheets")
|
||||
scene.ui.playSelect();
|
||||
downloadLogByIDToSheet(i)
|
||||
phase.callEnd()
|
||||
},,
|
||||
},
|
||||
() => {
|
||||
console.log("Delete")
|
||||
scene.ui.playSelect();
|
||||
localStorage.removeItem(logs[i][1])
|
||||
phase.callEnd()
|
||||
@ -438,7 +442,7 @@ export function generateEditOption(scene: BattleScene, i: integer, saves: any, p
|
||||
}
|
||||
}
|
||||
for (var j = 0; j < saves.length; j++) {
|
||||
console.log(saves[j].seed, logs[i][2], saves[j].seed == logs[i][2])
|
||||
//console.log(saves[j].seed, logs[i][2], saves[j].seed == logs[i][2])
|
||||
if (saves[j].seed == logs[i][2]) {
|
||||
op.label = "[Slot " + (saves[j].slot + 1) + "]" + op.label.substring(6)
|
||||
}
|
||||
@ -498,6 +502,7 @@ export function clearLog(keyword: string) {
|
||||
localStorage.setItem(logs[logKeys.indexOf(keyword)][1], "---- " + logs[logKeys.indexOf(keyword)][3] + " ----" + logs[logKeys.indexOf(keyword)][5])
|
||||
}
|
||||
export function setFileInfo(title: string, authors: string[]) {
|
||||
console.log("Setting file " + rarityslot[1] + " to " + title + " / [" + authors.join(", ") + "]")
|
||||
var fileID = rarityslot[1] as string
|
||||
var drpd = JSON.parse(localStorage.getItem(fileID)) as DRPD;
|
||||
drpd.title = title;
|
||||
@ -1045,6 +1050,7 @@ export function flagResetIfExists(scene: BattleScene, floor: integer = undefined
|
||||
* @see printWave
|
||||
*/
|
||||
export function printDRPD(inData: string, indent: string, drpd: DRPD): string {
|
||||
console.log("Printing for sheet?: " + SheetsMode.value)
|
||||
inData += indent + "{"
|
||||
inData += "\n" + indent + " \"version\": \"" + drpd.version + "\""
|
||||
inData += ",\n" + indent + " \"title\": \"" + drpd.title + "\""
|
||||
@ -1087,7 +1093,19 @@ function printWave(inData: string, indent: string, wave: Wave): string {
|
||||
var isFirst = true
|
||||
if (wave.actions.length > 0) {
|
||||
if (SheetsMode.value) {
|
||||
inData += ",\n" + indent + " \"actions\": [" + wave.actions.join("CHAR(10)") + "]"
|
||||
inData += ",\n" + indent + " \"actions\": \""
|
||||
var isFirst = true
|
||||
for (var i = 0; i < wave.actions.length; i++) {
|
||||
if (wave.actions[i] != undefined) {
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
} else {
|
||||
inData += "CHAR(10)"
|
||||
}
|
||||
inData += wave.actions[i]
|
||||
}
|
||||
}
|
||||
inData += "\""
|
||||
} else {
|
||||
inData += ",\n" + indent + " \"actions\": ["
|
||||
for (var i = 0; i < wave.actions.length; i++) {
|
||||
@ -1156,7 +1174,21 @@ function printPoke(inData: string, indent: string, pokemon: PokeData) {
|
||||
inData += ",\n" + indent + " \"rarity\": \"" + pokemon.rarity + "\""
|
||||
inData += ",\n" + indent + " \"captured\": " + pokemon.captured
|
||||
inData += ",\n" + indent + " \"level\": " + pokemon.level
|
||||
if (!SheetsMode.value)
|
||||
if (SheetsMode.value) {
|
||||
inData += ",\n" + indent + " \"items\": \""
|
||||
var isFirst = true
|
||||
for (var i = 0; i < pokemon.items.length; i++) {
|
||||
if (pokemon.items[i] != undefined) {
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
} else {
|
||||
inData += "CHAR(10)"
|
||||
}
|
||||
inData += printItemNoNewline(inData, "", pokemon.items[i])
|
||||
}
|
||||
}
|
||||
inData += "\""
|
||||
} else {
|
||||
if (pokemon.items.length > 0) {
|
||||
inData += ",\n" + indent + " \"items\": [\n"
|
||||
var isFirst = true
|
||||
@ -1175,6 +1207,7 @@ function printPoke(inData: string, indent: string, pokemon: PokeData) {
|
||||
} else {
|
||||
inData += ",\n" + indent + " \"items\": []"
|
||||
}
|
||||
}
|
||||
inData += ",\n" + indent + " \"ivs\": "
|
||||
inData = printIV(inData, indent + " ", pokemon.ivs)
|
||||
//inData += ",\n" + indent + " \"rarity\": " + pokemon.rarity
|
||||
@ -1252,6 +1285,19 @@ function printItem(inData: string, indent: string, item: ItemData) {
|
||||
inData += "\n" + indent + "}"
|
||||
return inData;
|
||||
}
|
||||
/**
|
||||
* Prints an item as a string, for saving a DRPD to your device.
|
||||
* @param inData The data to add on to.
|
||||
* @param indent The indent string (just a bunch of spaces).
|
||||
* @param wave The `ItemData` to export.
|
||||
* @returns `inData`, with all the Item's data appended to it.
|
||||
*
|
||||
* @see printDRPD
|
||||
*/
|
||||
function printItemNoNewline(inData: string, indent: string, item: ItemData) {
|
||||
inData = "{\\\"id\\\": \\\"" + item.id + "\\\", \\\"name\\\": \\\"" + item.name + "\\\", \\\"quantity\\\": " + item.quantity + "}"
|
||||
return inData;
|
||||
}
|
||||
|
||||
|
||||
function updateLog(drpd: DRPD): DRPD {
|
||||
|
@ -1366,6 +1366,10 @@ export class EncounterPhase extends BattlePhase {
|
||||
}
|
||||
LoggerTools.resetWaveActions(this.scene)
|
||||
|
||||
if (LoggerTools.autoCheckpoints.includes(this.scene.currentBattle.waveIndex)) {
|
||||
this.scene.gameData.saveGameToAuto(this.scene)
|
||||
}
|
||||
|
||||
if (this.scene.currentBattle.battleType === BattleType.WILD) {
|
||||
enemyField.forEach(enemyPokemon => {
|
||||
enemyPokemon.untint(100, "Sine.easeOut");
|
||||
|
@ -40,6 +40,7 @@ import { GameDataType } from "#enums/game-data-type";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { PlayerGender } from "#enums/player-gender";
|
||||
import { Species } from "#enums/species";
|
||||
import * as LoggerTools from "../logger"
|
||||
|
||||
export const defaultStarterSpecies: Species[] = [
|
||||
Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE,
|
||||
@ -877,7 +878,7 @@ export class GameData {
|
||||
});
|
||||
} else {
|
||||
const sessionData = localStorage.getItem(`sessionData${slotId ? slotId : ""}_${loggedInUser.username}${autokey}`);
|
||||
console.log(`sessionData${slotId ? slotId : ""}_${loggedInUser.username}${autokey}`, sessionData)
|
||||
//console.log(`sessionData${slotId ? slotId : ""}_${loggedInUser.username}${autokey}`, sessionData)
|
||||
if (sessionData) {
|
||||
await handleSessionData(decrypt(sessionData, bypassLogin));
|
||||
} else {
|
||||
@ -1157,6 +1158,13 @@ export class GameData {
|
||||
}) as SessionSaveData;
|
||||
}
|
||||
|
||||
saveGameToAuto(scene: BattleScene) {
|
||||
var autoSlot = LoggerTools.autoCheckpoints.indexOf(scene.currentBattle.waveIndex)
|
||||
var dat = this.getSessionSaveData(scene)
|
||||
console.log(`Stored autosave as sessionData${scene.sessionSlotId ? scene.sessionSlotId : ""}_${loggedInUser.username}_auto${autoSlot}`)
|
||||
localStorage.setItem(`sessionData${scene.sessionSlotId ? scene.sessionSlotId : ""}_${loggedInUser.username}_auto${autoSlot}`, encrypt(JSON.stringify(dat), bypassLogin));
|
||||
}
|
||||
|
||||
saveAll(scene: BattleScene, skipVerification: boolean = false, sync: boolean = false, useCachedSession: boolean = false, useCachedSystem: boolean = false): Promise<boolean> {
|
||||
return new Promise<boolean>(resolve => {
|
||||
Utils.executeIf(!skipVerification, updateUserInfo).then(success => {
|
||||
|
@ -7,8 +7,10 @@ import * as LoggerTools from "../logger";
|
||||
import { addTextObject, TextStyle } from "./text";
|
||||
|
||||
export default class LogNameFormUiHandler extends FormModalUiHandler {
|
||||
name: string;
|
||||
|
||||
getModalTitle(config?: ModalConfig): string {
|
||||
return "New Log";
|
||||
return "Manage " + (this.name ? this.name : "Log");
|
||||
}
|
||||
|
||||
getFields(config?: ModalConfig): string[] {
|
||||
@ -49,8 +51,7 @@ export default class LogNameFormUiHandler extends FormModalUiHandler {
|
||||
setup(): void {
|
||||
super.setup();
|
||||
|
||||
//const label = addTextObject(this.scene, 10, 87, "Text", TextStyle.TOOLTIP_CONTENT, { fontSize: "42px" });
|
||||
|
||||
//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
|
||||
@ -58,14 +59,16 @@ export default class LogNameFormUiHandler extends FormModalUiHandler {
|
||||
}
|
||||
|
||||
show(args: any[]): boolean {
|
||||
console.error("Shown")
|
||||
this.name = args[0].autofillfields[0]
|
||||
if (super.show(args)) {
|
||||
const config = args[0] as ModalConfig;
|
||||
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.submitAction = (_) => {
|
||||
console.log("submitAction")
|
||||
// Prevent overlapping overrides on action modification
|
||||
this.submitAction = originalLoginAction;
|
||||
this.sanitizeInputs();
|
||||
@ -77,9 +80,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()
|
||||
};
|
||||
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]
|
||||
config.buttonActions[2] = (_) => {
|
||||
LoggerTools.setFileInfo(this.inputs[0].text, this.inputs[1].text.split(","))
|
||||
exportaction2()
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import { TextStyle, addTextObject } from "./text";
|
||||
import { Mode } from "./ui";
|
||||
import { addWindow } from "./ui-theme";
|
||||
import * as LoggerTools from "../logger"
|
||||
import { loggedInUser } from "#app/account.js";
|
||||
|
||||
const sessionSlotCount = 5;
|
||||
|
||||
@ -113,6 +114,11 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
|
||||
const saveAndCallback = () => {
|
||||
const originalCallback = this.saveSlotSelectCallback;
|
||||
this.saveSlotSelectCallback = null;
|
||||
var dataslot = this.sessionSlots[cursor].slotId
|
||||
for (var i = 0; i < LoggerTools.autoCheckpoints.length; i++) {
|
||||
// Delete any autosaves associated with this slot
|
||||
localStorage.removeItem(`sessionData${dataslot ? dataslot : ""}_${loggedInUser.username}_auto${i}`)
|
||||
}
|
||||
ui.revertMode();
|
||||
ui.showText(null, 0);
|
||||
ui.setMode(Mode.MESSAGE);
|
||||
|
Loading…
Reference in New Issue
Block a user