mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Completed hotgroups
Single hotgroup per unit
This commit is contained in:
@@ -1,9 +1,23 @@
|
||||
import { getUnitsManager } from "..";
|
||||
import { Unit } from "../units/unit";
|
||||
import { Panel } from "./panel";
|
||||
|
||||
export class HotgroupPanel extends Panel {
|
||||
constructor(ID: string) {
|
||||
super(ID);
|
||||
document.addEventListener("unitDeath", () => this.refreshHotgroups());
|
||||
}
|
||||
|
||||
refreshHotgroups() {
|
||||
for (let hotgroup = 1; hotgroup <= 9; hotgroup++){
|
||||
this.removeHotgroup(hotgroup);
|
||||
if (getUnitsManager().getUnitsByHotgroup(hotgroup).length > 0)
|
||||
this.addHotgroup(hotgroup);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
addHotgroup(hotgroup: number) {
|
||||
this.removeHotgroup(hotgroup);
|
||||
const hotgroupHtml = `<div class="unit-hotgroup">
|
||||
<div class="unit-hotgroup-id">${hotgroup}</div>
|
||||
</div>
|
||||
@@ -13,9 +27,18 @@ export class HotgroupPanel extends Panel {
|
||||
el.innerHTML = hotgroupHtml;
|
||||
el.toggleAttribute(`data-hotgroup-${hotgroup}`, true)
|
||||
this.getElement().appendChild(el);
|
||||
|
||||
el.addEventListener("click", () => {
|
||||
getUnitsManager().selectUnitsByHotgroup(hotgroup);
|
||||
});
|
||||
|
||||
el.addEventListener("mouseover", () => {
|
||||
getUnitsManager().getUnitsByHotgroup(hotgroup).forEach((unit: Unit) => unit.setHighlighted(true));
|
||||
});
|
||||
|
||||
el.addEventListener("mouseout", () => {
|
||||
getUnitsManager().getUnitsByHotgroup(hotgroup).forEach((unit: Unit) => unit.setHighlighted(false));
|
||||
});
|
||||
}
|
||||
|
||||
removeHotgroup(hotgroup: number) {
|
||||
|
||||
Reference in New Issue
Block a user