From 9a62388e5718060b3c3279f9a922c5e60251fa72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Wed, 4 Feb 2015 01:00:00 +0100 Subject: [PATCH] Added hover indicator in ship list --- src/scripts/view/battle/BattleView.ts | 1 + src/scripts/view/battle/ShipList.ts | 15 +++++++++++++++ src/scripts/view/battle/ShipListItem.ts | 14 ++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/scripts/view/battle/BattleView.ts b/src/scripts/view/battle/BattleView.ts index bac436f..35cea10 100644 --- a/src/scripts/view/battle/BattleView.ts +++ b/src/scripts/view/battle/BattleView.ts @@ -143,6 +143,7 @@ module SpaceTac.View { this.ship_hovered = ship; this.card_hovered.setShip(ship); this.arena.setShipHovered(ship); + this.ship_list.setHovered(ship); if (this.targetting) { if (ship) { this.targetting.setTargetShip(ship); diff --git a/src/scripts/view/battle/ShipList.ts b/src/scripts/view/battle/ShipList.ts index 6f423c5..c92340d 100644 --- a/src/scripts/view/battle/ShipList.ts +++ b/src/scripts/view/battle/ShipList.ts @@ -12,11 +12,15 @@ module SpaceTac.View { // Playing ship playing: ShipListItem; + // Hovered ship + hovered: ShipListItem; + // Create an empty action bar constructor(battleview: BattleView) { this.battleview = battleview; this.ships = []; this.playing = null; + this.hovered = null; super(battleview.game, battleview.ui); battleview.ui.add(this); @@ -81,5 +85,16 @@ module SpaceTac.View { this.playing.setPlaying(true); } } + + // Set the currently hovered ship + setHovered(ship: Game.Ship): void { + if (this.hovered) { + this.hovered.setHovered(false); + } + this.hovered = this.findItem(ship); + if (this.hovered) { + this.hovered.setHovered(true); + } + } } } diff --git a/src/scripts/view/battle/ShipListItem.ts b/src/scripts/view/battle/ShipListItem.ts index f7835ea..38958d0 100644 --- a/src/scripts/view/battle/ShipListItem.ts +++ b/src/scripts/view/battle/ShipListItem.ts @@ -12,6 +12,9 @@ module SpaceTac.View { // Shield display shield: ValueBar; + // Hover indicator + layer_hover: Phaser.Image; + // Playing indicator layer_playing: Phaser.Image; @@ -45,6 +48,12 @@ module SpaceTac.View { this.layer_enemy = new Phaser.Image(this.game, 0, 0, owned ? "battle-shiplist-own" : "battle-shiplist-enemy", 0); this.addChild(this.layer_enemy); + this.layer_hover = new Phaser.Image(this.game, 0, 0, "battle-arena-shipspritehover", 0); + this.layer_hover.visible = false; + this.layer_hover.scale.set(0.5, 0.5); + this.layer_hover.position.set(8, 5); + this.addChild(this.layer_hover); + this.hull = ValueBar.newStandard(list.battleview.game, 85, 28); this.hull.scale.set(0.1, 0.1); this.addChild(this.hull); @@ -72,5 +81,10 @@ module SpaceTac.View { tween2.to({alpha: playing ? 0 : 1}); tween2.start(); } + + // Set the hovered status + setHovered(hovered: boolean) { + this.layer_hover.visible = hovered; + } } }