Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/app/mods/monsterTooltip/monsterTooltip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Mod } from "../mod";
import {ShortcutsHelper} from "@helpers/shortcuts.helper";

type TooltipData = {
id: number;
Expand All @@ -21,9 +22,11 @@ const toInt = (e: number) => {
}

export class MonsterTooltip extends Mod {


private shortcutsHelper: ShortcutsHelper;
private visible = false;
private monsterGroups = [];
private active = false

public startMod(): void {
this.params = this.settings.option.vip.general;
Expand All @@ -32,8 +35,8 @@ export class MonsterTooltip extends Mod {

Logger.info('- Enabled MonsterTooltip');

this.wGame.addEventListener("keydown", e => this.onKeyEvent(e));
this.wGame.addEventListener("keyup", e => this.onKeyEvent(e));
this.shortcutsHelper = new ShortcutsHelper(this.wGame);
this.shortcutsHelper.bind(this.params.monster_tooltip_shortcut, () => this.onKeyEvent());

const monsterTooltipCss = document.createElement('style');
monsterTooltipCss.id = 'monsterTooltipCss';
Expand Down Expand Up @@ -86,8 +89,6 @@ export class MonsterTooltip extends Mod {
}

public reset() {
this.wGame.removeEventListener("keydown", this.onKeyEvent);
this.wGame.removeEventListener("keyup", this.onKeyEvent);
this.hide();
super.reset();
}
Expand Down Expand Up @@ -328,10 +329,14 @@ export class MonsterTooltip extends Mod {
this.show();
}

private onKeyEvent(event: any) {
if (event.key == this.params.monster_tooltip_shortcut) {
if (event.type === "keydown") this.show();
else if (event.type === "keyup") this.hide();
private onKeyEvent() {
if (!this.active) {
this.show()
this.active = true
}
else {
this.active = false
this.hide();
}
}

Expand Down Expand Up @@ -368,4 +373,4 @@ export interface Monster {
level: number;
quantity: number;
isBoss: boolean;
}
}