1
0
Fork 0

Fixed tactical mode button

This commit is contained in:
Michaël Lemaire 2018-06-11 18:22:56 +02:00
parent ade6b8068d
commit 7a7649e8a9
5 changed files with 12 additions and 4 deletions

View File

@ -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

View File

@ -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());

View File

@ -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);
}

View File

@ -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);
});
});
}

View File

@ -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) {