summaryrefslogtreecommitdiff
path: root/resources/js/ui.js
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-08-24 15:46:33 +0200
committerDaniel Weipert <code@drogueronin.de>2023-08-24 15:47:01 +0200
commitfef59f25ca7dc0df7e4129ff11ee4c9af95eb085 (patch)
treec68bf28dc0e9a978b66b25ab2dc38656ecdb1039 /resources/js/ui.js
parentbde5dc98ad96546b59e91f5a6e552bf80cbf48e4 (diff)
map highlight
Diffstat (limited to 'resources/js/ui.js')
-rw-r--r--resources/js/ui.js47
1 files changed, 40 insertions, 7 deletions
diff --git a/resources/js/ui.js b/resources/js/ui.js
index 77b5b54..a19db2e 100644
--- a/resources/js/ui.js
+++ b/resources/js/ui.js
@@ -14,6 +14,8 @@ const Template = {
techniques: document.querySelector('#tpl___techniques'),
technique: document.querySelector('#tpl___technique'),
+ map: document.querySelector('#tpl___map'),
+
healingCenter: document.querySelector('#tpl___healing-center'),
shop: document.querySelector('#tpl___shop'),
shopItem: document.querySelector('#tpl___shop__item'),
@@ -349,6 +351,9 @@ const UI = {
battleMonsterNode.querySelector('[data-template-slot="sprite"]').addEventListener('click', () => {
UI.openStatsMenu(Memory.state.player.activeMonster);
});
+ if (UI.isHighlighting) {
+ battleMonsterNode.querySelector('[data-template-slot="sprite"]').classList.add(UI.highlightClassName);
+ }
return battleMonsterNode;
},
@@ -686,12 +691,10 @@ const UI = {
* @returns {HTMLElement}
*/
createMap () {
- const template = document.createElement('div');
+ const template = UI.createTemplate(Template.map);
const currentArea = Memory.state.currentArea;
template.innerHTML = currentArea.map;
- template.style.width = '100vw';
- template.style.maxWidth = '750px';
if (currentArea.locations) {
for (const locationId of Object.keys(currentArea.locations)) {
@@ -723,7 +726,10 @@ const UI = {
template.querySelector('[data-template-slot="price"]').innerHTML = formatPrice(price);
template.querySelector('[data-template-slot="heal"]').addEventListener('click', () => {
- const applicableMonsters = Memory.state.player.monsters.filter((monster) => monster.hp < monster.stats.hp || monster.statusEffect);
+ const applicableMonsters = Memory.state.player.monsters.filter((monster) => {
+ return monster.hp < monster.stats.hp || (monster.statusEffect && monster.statusEffect.category === 'negative')
+ });
+
if (applicableMonsters.length === 0) {
alert(translate('ui:no_applicable_monsters', true));
return;
@@ -805,6 +811,7 @@ const UI = {
partySelectionMode: 'select',
inventorySelectionMode: 'use',
isHighlighting: false,
+ highlightClassName: 'setting-highlight',
/**
@@ -1298,7 +1305,6 @@ const UI = {
UI.elements.battleOpponent,
UI.elements.battlePlayer.querySelector('[data-template-slot="sprite"]'),
UI.elements.techniques,
- ...UI.elements.sceneTown.querySelectorAll('[data-location]'),
UI.elements.showMap,
UI.elements.nextTrainer,
UI.elements.changeArea,
@@ -1308,13 +1314,40 @@ const UI = {
UI.elements.menuLog,
UI.elements.menuJournal,
UI.elements.menuSettings,
+
+ Template.technique.content.firstElementChild,
+ Template.healingCenter.content.querySelector('[data-template-slot="heal"]'),
+ Template.shopItem.content.firstElementChild,
+ ...Template.monsterStats.content.querySelectorAll('button'),
+ Template.movesetItem.content.firstElementChild,
+ Template.tabHeading.content.querySelector('[data-template-slot="label"]'),
+ ...Template.party.content.querySelectorAll('[data-template-slot="modes"] button'),
+ Template.partyMonster.content.firstElementChild,
+ Template.inventoryItem.content.firstElementChild,
+ ...Template.inventory.content.querySelectorAll('[data-template-slot="modes"] button'),
+ ...Template.menuSettings.content.querySelectorAll('select, button'),
+
+ ...document.querySelector('.menu__settings').querySelectorAll('select, button'),
];
for (const element of elements) {
if (UI.isHighlighting) {
- element.classList.add('setting-highlight');
+ element.classList.add(UI.highlightClassName);
+ } else {
+ element.classList.remove(UI.highlightClassName);
+ }
+ }
+
+ // map
+ const mapElements = [
+ UI.elements.sceneTown.querySelector('[data-template-slot="map"]').firstElementChild,
+ Template.map.content.firstElementChild,
+ ];
+ for (const element of mapElements) {
+ if (UI.isHighlighting) {
+ element.classList.add(`${UI.highlightClassName}--map`);
} else {
- element.classList.remove('setting-highlight');
+ element.classList.remove(`${UI.highlightClassName}--map`);
}
}
});