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.js35
1 files changed, 22 insertions, 13 deletions
diff --git a/resources/js/ui.js b/resources/js/ui.js
index 3275835..ee33a64 100644
--- a/resources/js/ui.js
+++ b/resources/js/ui.js
@@ -532,17 +532,12 @@ const UI = {
drawArea () {
if (Game.isTown(Memory.state.currentArea)) {
UI.drawTown();
-
UI.closeLog();
-
- UI.elements.sceneBattle.classList.add('hidden');
- UI.elements.sceneTown.classList.remove('hidden');
+ UI.showMap();
} else {
UI.elements.battle.style.backgroundImage = `url(/modules/tuxemon/mods/tuxemon/gfx/ui/combat/${Memory.state.currentArea.environment.battle_graphics.background})`;
- UI.elements.sceneTown.classList.add('hidden');
- UI.elements.sceneBattle.classList.remove('hidden');
-
+ UI.showBattle();
UI.drawOpponentMonster();
UI.drawActiveMonster();
UI.drawActiveTechniques();
@@ -690,7 +685,7 @@ const UI = {
/* Town */
drawTown () {
- UI.elements.sceneTown.querySelector('[data-template-slot="map"]').replaceChildren(UI.createMap());
+ UI.elements.sceneTown.querySelector('[data-template-slot="map"]').replaceChildren(UI.createMap());
},
@@ -736,6 +731,7 @@ const UI = {
Game.encounterMonster(monster);
Memory.state.Game.isInBattle = true;
+ UI.showBattle();
UI.closeAllPopups();
}
})));
@@ -790,11 +786,11 @@ const UI = {
template.querySelector('[data-template-slot="box.withdraw"]').addEventListener('click', UI.wrapCallback(() => {
if (Memory.state.monsters.length === 0) {
- alert('No Tuxemon to withdraw in Box!');
+ alert(translate('ui:healing_center:box:withdraw:no_tuxemon_in_box', true));
return;
}
if (Memory.state.player.monsters.length === 6) {
- alert('Not enough space in party!');
+ alert(translate('ui:healing_center:box:withdraw:no_space_in_party', true));
return;
}
@@ -816,7 +812,7 @@ const UI = {
template.querySelector('[data-template-slot="box.deposit"]').addEventListener('click', UI.wrapCallback(() => {
if (Memory.state.player.monsters.length === 1) {
- alert('Can\'t deposit last Tuxemon!');
+ alert(translate('ui:healing_center:box:deposit:last_tuxemon', true));
return;
}
@@ -1100,16 +1096,29 @@ const UI = {
return template;
},
- openMap () {
+ showMap () {
+ UI.elements.sceneBattle.classList.add('hidden');
+ UI.elements.sceneTown.classList.remove('hidden');
+ },
+
+ toggleMap () {
if (Memory.state.Game.isInBattle || Game.isTown(Memory.state.currentArea)) {
return;
}
+ UI.drawOpponentMonster();
+ UI.drawActiveMonster();
+ UI.drawActiveTechniques();
UI.drawTown();
UI.elements.sceneBattle.classList.toggle('hidden');
UI.elements.sceneTown.classList.toggle('hidden');
},
+ showBattle () {
+ UI.elements.sceneBattle.classList.remove('hidden');
+ UI.elements.sceneTown.classList.add('hidden');
+ },
+
openAreaSelection () {
const popup = UI.createPopup();
const template = UI.createTemplate(Template.areaSelection);
@@ -1849,7 +1858,7 @@ const UI = {
};
// UI element click bindings
-UI.elements.showMap.addEventListener('click', UI.wrapCallback(UI.openMap));
+UI.elements.showMap.addEventListener('click', UI.wrapCallback(UI.toggleMap));
UI.elements.changeArea.addEventListener('click', UI.wrapCallback(UI.openAreaSelection));
UI.elements.menuParty.addEventListener('click', UI.wrapCallback(UI.openPartyMenu));
UI.elements.menuInventory.addEventListener('click', UI.wrapCallback(UI.openInventoryMenu));