From 81f7174b588f34c2514481a9b603629d58bad5d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Sun, 16 Jul 2017 19:55:38 +0200 Subject: [PATCH] map: Fixed refresh triggers (for displayed fleet mainly) --- src/ui/character/CharacterSheet.ts | 2 +- src/ui/map/ActiveMissionsDisplay.ts | 2 ++ src/ui/map/FleetDisplay.ts | 1 - src/ui/map/UniverseMapView.ts | 26 ++++++++++++++------------ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/ui/character/CharacterSheet.ts b/src/ui/character/CharacterSheet.ts index 0f77942..24b0053 100644 --- a/src/ui/character/CharacterSheet.ts +++ b/src/ui/character/CharacterSheet.ts @@ -192,7 +192,7 @@ module TS.SpaceTac.UI { * Update the fleet sidebar */ updateFleet(fleet: Fleet) { - if (fleet != this.fleet) { + if (fleet != this.fleet || fleet.ships.length != this.portraits.children.length) { this.portraits.removeAll(true); this.fleet = fleet; } diff --git a/src/ui/map/ActiveMissionsDisplay.ts b/src/ui/map/ActiveMissionsDisplay.ts index 27a8c9b..cf1bc0b 100644 --- a/src/ui/map/ActiveMissionsDisplay.ts +++ b/src/ui/map/ActiveMissionsDisplay.ts @@ -22,6 +22,8 @@ module TS.SpaceTac.UI { * Check if the active missions' status changed */ checkUpdate(): boolean { + this.missions.checkStatus(); + let new_hash = this.missions.getHash(); if (new_hash != this.hash) { this.hash = new_hash; diff --git a/src/ui/map/FleetDisplay.ts b/src/ui/map/FleetDisplay.ts index a564ca6..ae0a540 100644 --- a/src/ui/map/FleetDisplay.ts +++ b/src/ui/map/FleetDisplay.ts @@ -107,7 +107,6 @@ module TS.SpaceTac.UI { this.game.state.start("router"); } else { this.map.current_location.setFleetMoving(false); - this.map.updateInfo(location.star); this.loopOrbit(); } diff --git a/src/ui/map/UniverseMapView.ts b/src/ui/map/UniverseMapView.ts index d497ee3..6d978e3 100644 --- a/src/ui/map/UniverseMapView.ts +++ b/src/ui/map/UniverseMapView.ts @@ -47,6 +47,9 @@ module TS.SpaceTac.UI { zoom_in: Phaser.Button zoom_out: Phaser.Button + // Options button + button_options: Phaser.Button + /** * Init the view, binding it to a universe */ @@ -110,11 +113,11 @@ module TS.SpaceTac.UI { this.zoom_out.anchor.set(0.5, 0.5); this.layer_overlay.add(this.zoom_out); this.tooltip.bindStaticText(this.zoom_out, "Zoom out"); - let options = new Phaser.Button(this.game, 1436, 69, "map-buttons", () => this.showOptions(), undefined, 5, 2); - options.angle = -90; - options.anchor.set(0.5, 0.5); - this.layer_overlay.add(options); - this.tooltip.bindStaticText(options, "Game options"); + this.button_options = new Phaser.Button(this.game, 1436, 69, "map-buttons", () => this.showOptions(), undefined, 5, 2); + this.button_options.angle = -90; + this.button_options.anchor.set(0.5, 0.5); + this.layer_overlay.add(this.button_options); + this.tooltip.bindStaticText(this.button_options, "Game options"); this.character_sheet = new CharacterSheet(this, this.getWidth() - 307); this.character_sheet.show(this.player.fleet.ships[0], false); @@ -192,12 +195,7 @@ module TS.SpaceTac.UI { this.actions.setFromLocation(this.player.fleet.location, this); this.missions.checkUpdate(); - this.conversation.updateFromMissions(this.player.missions, () => { - this.player.missions.checkStatus(); - if (this.missions.checkUpdate()) { - this.refresh(); - } - }); + this.conversation.updateFromMissions(this.player.missions, () => this.checkMissionsUpdate()); if (interactive) { this.setInteractionEnabled(true); @@ -319,7 +317,10 @@ module TS.SpaceTac.UI { moveToLocation(dest: StarLocation): void { if (this.interactive && dest != this.player.fleet.location) { this.setInteractionEnabled(false); - this.player_fleet.moveToLocation(dest, 1, null, () => this.refresh()); + this.player_fleet.moveToLocation(dest, 1, null, () => { + this.setInteractionEnabled(true); + this.refresh(); + }); } } @@ -332,6 +333,7 @@ module TS.SpaceTac.UI { this.missions.setVisible(enabled && this.zoom == 2, 300); this.animations.setVisible(this.zoom_in, enabled && this.zoom < 2, 300); this.animations.setVisible(this.zoom_out, enabled && this.zoom > 0, 300); + this.animations.setVisible(this.button_options, enabled, 300); this.animations.setVisible(this.character_sheet, enabled, 300); } }