2017-05-14 23:00:36 +00:00
|
|
|
/// <reference path="../common/Tooltip.ts" />
|
|
|
|
|
2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.UI {
|
2017-05-14 23:00:36 +00:00
|
|
|
/**
|
|
|
|
* Tooltip to display ship information on hover
|
|
|
|
*/
|
|
|
|
export class ShipTooltip extends Tooltip {
|
|
|
|
battleview: BattleView
|
2017-01-09 23:24:33 +00:00
|
|
|
|
|
|
|
constructor(parent: BattleView) {
|
2017-05-14 23:00:36 +00:00
|
|
|
super(parent);
|
2017-01-11 00:38:08 +00:00
|
|
|
|
2017-05-14 23:00:36 +00:00
|
|
|
this.battleview = parent;
|
2017-01-09 23:24:33 +00:00
|
|
|
}
|
|
|
|
|
2017-02-05 21:41:06 +00:00
|
|
|
/**
|
2017-05-14 23:00:36 +00:00
|
|
|
* Set the current ship to display
|
2017-02-05 21:41:06 +00:00
|
|
|
*/
|
2017-05-14 23:00:36 +00:00
|
|
|
setShip(ship: Ship): void {
|
|
|
|
this.hide();
|
2017-02-05 21:41:06 +00:00
|
|
|
|
2017-05-14 23:00:36 +00:00
|
|
|
let filler = this.getFiller();
|
2017-06-13 22:01:39 +00:00
|
|
|
let sprite = this.battleview.arena.findShipSprite(ship);
|
2017-02-05 21:41:06 +00:00
|
|
|
|
2017-05-16 23:12:05 +00:00
|
|
|
filler.configure(10, 6, this.battleview.arena.getBoundaries());
|
2017-05-15 23:20:35 +00:00
|
|
|
|
2017-07-26 22:54:56 +00:00
|
|
|
filler.addImageA(0, 0, `ship-${ship.model.code}-portrait`, 0.5);
|
2017-02-05 21:41:06 +00:00
|
|
|
|
2017-05-14 23:00:36 +00:00
|
|
|
let enemy = ship.getPlayer() != this.battleview.player;
|
2017-07-31 18:17:43 +00:00
|
|
|
filler.addText(140, 0, ship.getFullName(), enemy ? "#cc0d00" : "#ffffff", 22, false, true);
|
2017-02-05 21:41:06 +00:00
|
|
|
|
2017-05-14 23:00:36 +00:00
|
|
|
if (ship.alive) {
|
|
|
|
let turns = this.battleview.battle.getTurnsBefore(ship);
|
|
|
|
filler.addText(140, 36, (turns == 0) ? "Playing" : ((turns == 1) ? "Plays next" : `Plays in ${turns} turns`), "#cccccc", 18);
|
|
|
|
|
2017-08-24 22:47:34 +00:00
|
|
|
filler.addText(140, 72, `Hull\n${ship.getValue("hull")}/${ship.getAttribute("hull_capacity")}`, "#eb4e4a", 20, true, true);
|
|
|
|
filler.addText(288, 72, `Shield\n${ship.getValue("shield")}/${ship.getAttribute("shield_capacity")}`, "#2ad8dc", 20, true, true);
|
|
|
|
filler.addText(408, 72, `Power\n${ship.getValue("power")}/${ship.getAttribute("power_capacity")}`, "#ffdd4b", 20, true, true);
|
2017-05-14 23:00:36 +00:00
|
|
|
|
|
|
|
let iy = 148;
|
|
|
|
|
2017-06-13 22:01:39 +00:00
|
|
|
if (sprite) {
|
|
|
|
let effects = sprite.active_effects.area.concat(sprite.active_effects.sticky);
|
|
|
|
if (effects.length > 0) {
|
|
|
|
filler.addText(0, iy, "Active effects", "#ffffff", 18, false, true);
|
|
|
|
iy += 30;
|
|
|
|
effects.forEach(effect => {
|
|
|
|
filler.addText(0, iy, `• ${effect.getDescription()}`, effect.isBeneficial() ? "#afe9c6" : "#e9afaf", 16);
|
|
|
|
iy += 26;
|
|
|
|
});
|
|
|
|
}
|
2017-05-14 23:00:36 +00:00
|
|
|
}
|
2017-01-16 23:20:33 +00:00
|
|
|
|
2017-05-14 23:00:36 +00:00
|
|
|
let weapons = ship.listEquipment(SlotType.Weapon);
|
|
|
|
if (weapons.length > 0) {
|
|
|
|
filler.addText(0, iy, "Weapons", "#ffffff", 18, false, true);
|
|
|
|
iy += 30;
|
|
|
|
weapons.forEach(weapon => {
|
|
|
|
filler.addText(0, iy, `• ${weapon.getFullName()}`, "#ffffff", 16);
|
|
|
|
iy += 26;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
filler.addText(140, 36, "Emergency Stasis Protocol\nship disabled", "#a899db", 20, true, true);
|
|
|
|
}
|
2017-01-16 23:20:33 +00:00
|
|
|
|
2017-05-15 23:20:35 +00:00
|
|
|
if (sprite) {
|
2017-10-01 21:00:23 +00:00
|
|
|
this.container.show(sprite.frame.getBounds());
|
2017-05-15 23:20:35 +00:00
|
|
|
}
|
2017-01-16 23:20:33 +00:00
|
|
|
}
|
2017-01-09 23:24:33 +00:00
|
|
|
}
|
|
|
|
}
|