mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-17 04:01:51 +00:00
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
|
|
import { BaseHUDPart } from "../base_hud_part";
|
||
|
|
import { makeDiv } from "../../../core/utils";
|
||
|
|
|
||
|
|
export class HUDGameMenu extends BaseHUDPart {
|
||
|
|
initialize() {}
|
||
|
|
createElements(parent) {
|
||
|
|
this.element = makeDiv(parent, "ingame_HUD_GameMenu");
|
||
|
|
|
||
|
|
const buttons = [
|
||
|
|
{
|
||
|
|
id: "shop",
|
||
|
|
label: "Upgrades",
|
||
|
|
handler: () => this.root.hud.parts.shop.show(),
|
||
|
|
keybinding: "menu_open_shop",
|
||
|
|
},
|
||
|
|
{
|
||
|
|
id: "stats",
|
||
|
|
label: "Stats",
|
||
|
|
handler: () => null,
|
||
|
|
keybinding: "menu_open_stats",
|
||
|
|
},
|
||
|
|
];
|
||
|
|
|
||
|
|
buttons.forEach(({ id, label, handler, keybinding }) => {
|
||
|
|
const button = document.createElement("button");
|
||
|
|
button.setAttribute("data-button-id", id);
|
||
|
|
this.element.appendChild(button);
|
||
|
|
this.trackClicks(button, handler);
|
||
|
|
|
||
|
|
if (keybinding) {
|
||
|
|
const binding = this.root.gameState.keyActionMapper.getBinding(keybinding);
|
||
|
|
binding.add(handler);
|
||
|
|
binding.appendLabelToElement(button);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|