1
0
Fork 0
spacetac/src/ui/battle/ShipTooltip.ts

72 lines
2.9 KiB
TypeScript
Raw Normal View History

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-05-14 23:00:36 +00:00
* Set the current ship to display
*/
2017-05-14 23:00:36 +00:00
setShip(ship: Ship): void {
this.hide();
2017-05-14 23:00:36 +00:00
let filler = this.getFiller();
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-10-10 22:32:46 +00:00
let portrait = filler.image(`ship-${ship.model.code}-portrait`);
portrait.scale.set(0.5);
let enemy = !ship.getPlayer().is(this.battleview.player);
2017-10-10 22:32:46 +00:00
filler.text(ship.getFullName(), 140, 0, { color: enemy ? "#cc0d00" : "#ffffff", size: 22, bold: true });
2017-05-14 23:00:36 +00:00
if (ship.alive) {
2017-10-25 22:45:53 +00:00
let turns = this.battleview.battle.getPlayOrder(ship);
2017-10-10 22:32:46 +00:00
filler.text((turns == 0) ? "Playing" : ((turns == 1) ? "Plays next" : `Plays in ${turns} turns`), 140, 36, { color: "#cccccc", size: 18 });
2017-05-14 23:00:36 +00:00
2017-10-10 22:32:46 +00:00
let hsp_builder = filler.styled({ color: "#eb4e4a", size: 20, center: true, vcenter: true, bold: true });
hsp_builder.text(`Hull\n${ship.getValue("hull")}/${ship.getAttribute("hull_capacity")}`, 200, 106, { color: "#eb4e4a" });
hsp_builder.text(`Shield\n${ship.getValue("shield")}/${ship.getAttribute("shield_capacity")}`, 340, 106, { color: "#2ad8dc" });
hsp_builder.text(`Power\n${ship.getValue("power")}/${ship.getAttribute("power_capacity")}`, 480, 106, { color: "#ffdd4b" });
2017-05-14 23:00:36 +00:00
let iy = 148;
let effects = ship.active_effects.list();
if (effects.length > 0) {
filler.text("Active effects", 0, iy, { color: "#ffffff", size: 18, bold: true });
iy += 30;
effects.forEach(effect => {
filler.text(`${effect.getDescription()}`, 0, iy, { color: effect.isBeneficial() ? "#afe9c6" : "#e9afaf" });
iy += 26;
});
2017-05-14 23:00:36 +00:00
}
2017-05-14 23:00:36 +00:00
let weapons = ship.listEquipment(SlotType.Weapon);
if (weapons.length > 0) {
2017-10-10 22:32:46 +00:00
filler.text("Weapons", 0, iy, { size: 18, bold: true });
2017-05-14 23:00:36 +00:00
iy += 30;
weapons.forEach(weapon => {
2017-10-10 22:32:46 +00:00
filler.text(`${weapon.getFullName()}`, 0, iy);
2017-05-14 23:00:36 +00:00
iy += 26;
});
}
} else {
2017-10-10 22:32:46 +00:00
filler.text("Emergency Stasis Protocol\nship disabled", 140, 36, { color: "#a899db", size: 20, center: true, vcenter: true });
2017-05-14 23:00:36 +00:00
}
let sprite = this.battleview.arena.findShipSprite(ship);
2017-05-15 23:20:35 +00:00
if (sprite) {
this.container.show(sprite.frame.getBounds());
2017-05-15 23:20:35 +00:00
}
}
2017-01-09 23:24:33 +00:00
}
}