summaryrefslogtreecommitdiff
path: root/resources/js/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/js/ui.js')
-rw-r--r--resources/js/ui.js24
1 files changed, 19 insertions, 5 deletions
diff --git a/resources/js/ui.js b/resources/js/ui.js
index 7c0c064..006e6fc 100644
--- a/resources/js/ui.js
+++ b/resources/js/ui.js
@@ -188,6 +188,10 @@ const UI = {
document.body.appendChild(popup);
},
+ closeAllPopups () {
+ document.querySelectorAll('.popup__overlay').forEach((popup) => popup.remove());
+ },
+
/* Battle */
@@ -927,7 +931,7 @@ const UI = {
Memory.state.opponent.type === 'monster' &&
currentArea.monsterProgress >= currentArea.requiredEncounters &&
currentArea.trainerProgress < currentArea.trainers.length &&
- !Game.isInBattle
+ !Memory.state.Game.isInBattle
) {
nextTrainerButton.disabled = false;
} else {
@@ -940,7 +944,7 @@ const UI = {
const changeAreaButton = UI.elements.changeArea;
if (!Game.isTown(currentArea)) {
if (
- Game.isInBattle ||
+ Memory.state.Game.isInBattle ||
(Memory.state.opponent && Memory.state.opponent.type === 'trainer')
) {
changeAreaButton.disabled = true;
@@ -991,7 +995,7 @@ const UI = {
},
openMap () {
- if (Game.isInBattle || Game.isTown(Memory.state.currentArea)) {
+ if (Memory.state.Game.isInBattle || Game.isTown(Memory.state.currentArea)) {
return;
}
@@ -1353,6 +1357,16 @@ const UI = {
});
+ // Clear save data
+
+ template.querySelector('[data-template-slot="clearLocalSaveData"]').addEventListener('click', UI.createEventListener(() => {
+ if (confirm(translate('ui:settings:clear_local_save_data:confirm', true))) {
+ localStorage.removeItem('state');
+ window.location.reload();
+ }
+ }));
+
+
popup.querySelector('.popup').appendChild(template);
UI.drawPopup(popup);
},
@@ -1639,7 +1653,7 @@ const UI = {
const popup = UI.createPopup();
const dialog = UI.createTemplate(Template.dialogSave);
- const saveData = Memory.save();
+ const saveData = Memory.saveToString();
dialog.querySelector('[data-template-slot="saveData"]').value = saveData;
dialog.querySelector('[data-template-slot="saveClipboard"]').addEventListener('click', UI.createEventListener(async () => {
@@ -1660,7 +1674,7 @@ const UI = {
const dialog = UI.createTemplate(Template.dialogLoad);
dialog.querySelector('[data-template-slot="load"]').addEventListener('click', UI.createEventListener(() => {
- Memory.load(
+ Memory.loadFromString(
dialog.querySelector('[data-template-slot="saveData"]').value.trim()
);