mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Use enum for debug overlay
This commit is contained in:
parent
2d83994771
commit
6769e9c9b8
@ -4,6 +4,8 @@ import { DynamicDomAttach } from "../dynamic_dom_attach";
|
|||||||
import { KEYMAPPINGS } from "../../key_action_mapper";
|
import { KEYMAPPINGS } from "../../key_action_mapper";
|
||||||
import { Vector } from "../../../core/vector";
|
import { Vector } from "../../../core/vector";
|
||||||
|
|
||||||
|
export const enumDebugOverlayMode = { disabled: 'disabled', regular: 'regular', detailed: 'detailed'};
|
||||||
|
|
||||||
export class HUDDebugInfo extends BaseHUDPart {
|
export class HUDDebugInfo extends BaseHUDPart {
|
||||||
createElements(parent) {
|
createElements(parent) {
|
||||||
this.element = makeDiv(parent, "ingame_HUD_DebugInfo", []);
|
this.element = makeDiv(parent, "ingame_HUD_DebugInfo", []);
|
||||||
@ -19,8 +21,7 @@ export class HUDDebugInfo extends BaseHUDPart {
|
|||||||
initialize() {
|
initialize() {
|
||||||
this.lastTick = 0;
|
this.lastTick = 0;
|
||||||
|
|
||||||
this.visible = false;
|
this.mode = enumDebugOverlayMode.disabled;
|
||||||
this.full = false;
|
|
||||||
this.domAttach = new DynamicDomAttach(this.root, this.element);
|
this.domAttach = new DynamicDomAttach(this.root, this.element);
|
||||||
|
|
||||||
this.root.keyMapper.getBinding(KEYMAPPINGS.ingame.toggleFPSInfo).add(() => this.toggle());
|
this.root.keyMapper.getBinding(KEYMAPPINGS.ingame.toggleFPSInfo).add(() => this.toggle());
|
||||||
@ -47,18 +48,19 @@ export class HUDDebugInfo extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
if (this.visible) {
|
switch (this.mode) {
|
||||||
if (this.full) {
|
case enumDebugOverlayMode.detailed:
|
||||||
this.visible = false;
|
this.mode = enumDebugOverlayMode.disabled;
|
||||||
this.full = false;
|
break;
|
||||||
} else {
|
case enumDebugOverlayMode.regular:
|
||||||
this.full = true;
|
this.mode = enumDebugOverlayMode.detailed;
|
||||||
}
|
break;
|
||||||
} else {
|
default:
|
||||||
this.visible = true;
|
this.mode = enumDebugOverlayMode.regular;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
this.updateFullText();
|
this.updateFullText();
|
||||||
this.domAttach.update(this.visible);
|
this.domAttach.update(this.mode != enumDebugOverlayMode.disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
|
Loading…
Reference in New Issue
Block a user