Add named save export to settings page
This commit is contained in:
@@ -5624,7 +5624,7 @@
|
|||||||
() => {
|
() => {
|
||||||
E.exportSavegamePrivateBin();
|
E.exportSavegamePrivateBin();
|
||||||
},
|
},
|
||||||
)}"><i class="fas fa-file-export"></i> ${e.T("settings-share-save-button", "Export save without file")}</button>\n <div id="savegameQR"></div>\n --\x3e\n </div>\n </div>\n </div>`;
|
)}"><i class="fas fa-file-export"></i> ${e.T("settings-share-save-button", "Export save without file")}</button>\n <div id="savegameQR"></div>\n --\x3e\n </div>\n <div class="form-group">\n <h5 class="py-2 text-warning">Named Save</h5>\n <div class="input-group">\n <input type="text" class="form-control bg-dark text-white" id="named-save-input" placeholder="Save name...">\n <div class="input-group-append">\n <button class="btn btn-outline-success" onclick="${wi.register(() => { E.exportNamedSave(); })}"><i class="fas fa-save"></i> Save</button>\n </div>\n </div>\n <small class="form-text text-muted">Save a complete export with a custom name.</small>\n </div>\n </div>\n </div>`;
|
||||||
}
|
}
|
||||||
static mapManagementFormView() {
|
static mapManagementFormView() {
|
||||||
const e = s.getInstance();
|
const e = s.getInstance();
|
||||||
@@ -5863,6 +5863,30 @@
|
|||||||
};
|
};
|
||||||
await _.runExport("pu_save", await _.getSavegameData(t));
|
await _.runExport("pu_save", await _.getSavegameData(t));
|
||||||
}
|
}
|
||||||
|
static async exportNamedSave() {
|
||||||
|
const save_name = $("#named-save-input").val().trim();
|
||||||
|
if (!save_name) return;
|
||||||
|
const error_obj = {
|
||||||
|
title: s.getInstance().T("settings-save-export-maps-failed-header", "Save export interrupted"),
|
||||||
|
text: s.getInstance().T("settings-save-export-maps-failed-content", "During the export an error occured while loading the active maps for a full export."),
|
||||||
|
};
|
||||||
|
const orig_complete = n.getSetting("completeExports");
|
||||||
|
const orig_compress = n.getSetting("compressExports");
|
||||||
|
n.setSetting("completeExports", true);
|
||||||
|
n.setSetting("compressExports", true);
|
||||||
|
try {
|
||||||
|
const data = await _.getSavegameData(error_obj);
|
||||||
|
const compressed = n.compressJSObjectToString(data);
|
||||||
|
const blob = new Blob([compressed], { type: "application/octet-stream" });
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
const a = $(`<a style="display: none" download="${save_name}.puC" href="${url}"></a>`);
|
||||||
|
$("body").append(a);
|
||||||
|
a[0].click();
|
||||||
|
setTimeout(() => { window.URL.revokeObjectURL(url); a.remove(); }, 5000);
|
||||||
|
} catch (e) {}
|
||||||
|
n.setSetting("completeExports", orig_complete);
|
||||||
|
n.setSetting("compressExports", orig_compress);
|
||||||
|
}
|
||||||
static async importSaveGameClipboard() {
|
static async importSaveGameClipboard() {
|
||||||
const e = s.getInstance(),
|
const e = s.getInstance(),
|
||||||
t = {
|
t = {
|
||||||
|
|||||||
Reference in New Issue
Block a user