Added hotgroups ui and basic functions

User interaction still TBD
This commit is contained in:
Pax1601
2023-05-15 17:37:20 +02:00
parent 1ca2c66b45
commit 493c75b6e7
8 changed files with 167 additions and 69 deletions

View File

@@ -0,0 +1,25 @@
import { getUnitsManager } from "..";
import { Panel } from "./panel";
export class HotgroupPanel extends Panel {
addHotgroup(hotgroup: number) {
this.removeHotgroup(hotgroup);
const hotgroupHtml = `<div class="unit-hotgroup">
<div class="unit-hotgroup-id">${hotgroup}</div>
</div>
x${getUnitsManager().getUnitsByHotgroup(hotgroup).length}`
var el = document.createElement("div");
el.classList.add("hotgroup-selector");
el.innerHTML = hotgroupHtml;
el.toggleAttribute(`data-hotgroup-${hotgroup}`, true)
this.getElement().appendChild(el);
el.addEventListener("click", () => {
getUnitsManager().selectUnitsByHotgroup(hotgroup);
});
}
removeHotgroup(hotgroup: number) {
const el = this.getElement().querySelector(`[data-hotgroup-${hotgroup}]`) as HTMLElement;
if (el) el.remove();
}
}