Skip to content

Commit

Permalink
Add GUI toggling with keypress
Browse files Browse the repository at this point in the history
  • Loading branch information
EntityPlantt committed Nov 22, 2022
1 parent 92247af commit f5deef0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,12 @@ onload = () => {
if (GUI[i].shortcut.alt != undefined && GUI[i].shortcut.alt != event.altKey) {
continue;
}
openGUI(i);
if (GUI[i]?.opened) {
closeGUI(i);
}
else {
openGUI(i);
}
}
}
}
Expand Down Expand Up @@ -558,12 +563,20 @@ function generatePlanetGemImage(gem) {
}
function openGUI(name, ...data) {
document.querySelector(`[gui-name="${name}"]`).classList.add("gui-opened");
if (!GUI[name]) {
GUI[name] = {};
}
GUI[name].opened = true;
document.body.appendChild(document.querySelector(`[gui-name="${name}"]`));
return ((GUI[name] || {}).open || new Function)(document.querySelector(`[gui-name="${name}"]`), ...data);
return (GUI[name].open || new Function)(document.querySelector(`[gui-name="${name}"]`), ...data);
}
function closeGUI(name, ...data) {
if (!GUI[name]) {
GUI[name] = {};
}
GUI[name].opened = false;
document.querySelector(`[gui-name="${name}"]`).classList.remove("gui-opened");
return ((GUI[name] || {}).close || new Function)(document.querySelector(`[gui-name="${name}"]`), ...data);
return (GUI[name].close || new Function)(document.querySelector(`[gui-name="${name}"]`), ...data);
}
function sellBackpack() {
for (var gem of Object.keys(data.backpack.items)) {
Expand Down

0 comments on commit f5deef0

Please sign in to comment.