diff --git a/TODO.md b/TODO.md index 334d130..2ea4322 100644 --- a/TODO.md +++ b/TODO.md @@ -8,7 +8,6 @@ Phaser 3 migration * Fit the game in window size * Fix top-right messages positions * Fix valuebar requiring to be in root display list -* Fix tactical mode button not working * Restore unit tests about boundaries (in UITools) Menu/settings/saves diff --git a/src/ui/battle/BattleView.ts b/src/ui/battle/BattleView.ts index 9f75d19..e169664 100644 --- a/src/ui/battle/BattleView.ts +++ b/src/ui/battle/BattleView.ts @@ -129,7 +129,7 @@ module TK.SpaceTac.UI { this.audio.startMusic("mechanolith", 0.2); // Key mapping - this.inputs.bind("t", "Show tactical view", () => this.toggle_tactical_mode.manipulate("keyboard")(3000)); + this.inputs.bind("t", "Show tactical view", () => this.ship_list.info_button.toggle()); this.inputs.bind("Enter", "Validate action", () => this.validationPressed()); this.inputs.bind(" ", "Validate action", () => this.validationPressed()); this.inputs.bind("Escape", "Cancel action", () => this.action_bar.actionEnded()); diff --git a/src/ui/battle/ShipList.ts b/src/ui/battle/ShipList.ts index a5be6c9..cd25863 100644 --- a/src/ui/battle/ShipList.ts +++ b/src/ui/battle/ShipList.ts @@ -43,7 +43,7 @@ module TK.SpaceTac.UI { this.hovered = null; // FIXME - this.info_button = builder.button("battle-shiplist-info-button", 0, 0, () => null, "Tactical display", on => tactical_mode.manipulate("shiplist")(on)); + this.info_button = builder.button("battle-shiplist-info-button", 0, 0, undefined, "Tactical display", on => tactical_mode.manipulate("shiplist")(on)); this.setShipsFromBattle(battle); } diff --git a/src/ui/common/UIButton.spec.ts b/src/ui/common/UIButton.spec.ts index a8f211c..8ea1e75 100644 --- a/src/ui/common/UIButton.spec.ts +++ b/src/ui/common/UIButton.spec.ts @@ -110,6 +110,11 @@ module TK.SpaceTac.UI.Specs { button2.toggle(true, UIButtonUnicity.EXCLUSIVE_MIN); verify("toggle off unicity min", false, true, false, 0, 0, 0); + + button1.toggle(); + verify("toggle auto on", true, true, false, 1, 0, 0); + button1.toggle(); + verify("toggle auto off", false, true, false, 1, 0, 0); }); }); } diff --git a/src/ui/common/UIButton.ts b/src/ui/common/UIButton.ts index fe5fc10..21060e8 100644 --- a/src/ui/common/UIButton.ts +++ b/src/ui/common/UIButton.ts @@ -192,7 +192,11 @@ module TK.SpaceTac.UI { * * Returns the final state of this button */ - toggle(on: boolean, unicity?: UIButtonUnicity): boolean { + toggle(on?: boolean, unicity?: UIButtonUnicity): boolean { + if (typeof on == "undefined") { + on = !this.state_on; + } + if (on && unicity && this.parentContainer) { this.parentContainer.list.forEach(child => { if (child instanceof UIButton && child != this) {