Add log buttons

Export for Sheets (ExSheet): Exports a file replacing \n with CHAR(10)

Delete: Deletes the file
This commit is contained in:
RedstonewolfX 2024-07-13 00:00:37 -04:00
parent 7084155186
commit c80c291805
2 changed files with 18 additions and 1 deletions

View File

@ -413,6 +413,11 @@ export function generateEditOption(scene: BattleScene, i: integer, saves: any, p
downloadLogByID(i) downloadLogByID(i)
phase.callEnd() phase.callEnd()
}, },
() => {
scene.ui.playSelect();
downloadLogByIDToSheet(i)
phase.callEnd()
},,
() => { () => {
scene.ui.playSelect(); scene.ui.playSelect();
localStorage.removeItem(logs[i][1]) localStorage.removeItem(logs[i][1])
@ -535,6 +540,18 @@ export function downloadLogByID(i: integer) {
link.click(); link.click();
link.remove(); link.remove();
} }
export function downloadLogByIDToSheet(i: integer) {
console.log(i)
var d = JSON.parse(localStorage.getItem(logs[i][1]))
const blob = new Blob([ printDRPD("", "", d as DRPD).split("\n").join("CHAR(10)") ], {type: "text/json"});
const link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
var date: string = (d as DRPD).date
var filename: string = date[0] + date[1] + "_" + date[3] + date[4] + "_" + date[6] + date[7] + date[8] + date[9] + "_route.json"
link.download = `${filename}`;
link.click();
link.remove();
}
/** /**
* Calls `logPokemon` once for each opponent or, if it's a trainer battle, logs the trainer's data. * Calls `logPokemon` once for each opponent or, if it's a trainer battle, logs the trainer's data.
* @param scene The BattleScene. Used to get the enemy team and whether it's a trainer battle or not. * @param scene The BattleScene. Used to get the enemy team and whether it's a trainer battle or not.

View File

@ -24,7 +24,7 @@ export default class LogNameFormUiHandler extends FormModalUiHandler {
} }
getButtonLabels(config?: ModalConfig): string[] { getButtonLabels(config?: ModalConfig): string[] {
return [ "Rename", "Export" ]; return [ "Rename", "Export", "ExSheet", "Delete" ];
} }
getReadableErrorMessage(error: string): string { getReadableErrorMessage(error: string): string {