2017-05-14 23:00:36 +00:00
|
|
|
/// <reference path="../common/Tooltip.ts" />
|
|
|
|
|
2017-02-09 00:00:35 +00:00
|
|
|
module TS.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-02-05 21:41:06 +00:00
|
|
|
|
2017-05-15 23:20:35 +00:00
|
|
|
filler.configure(10, 6, { x: 130, y: 140, width: 1920 - 138, height: 1080 - 148 });
|
|
|
|
|
2017-05-14 23:00:36 +00:00
|
|
|
filler.addImage(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;
|
|
|
|
filler.addText(140, 0, ship.name, 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);
|
|
|
|
|
|
|
|
filler.addText(140, 72, `Hull\n${ship.getValue("hull")}`, "#eb4e4a", 20, true, true);
|
|
|
|
filler.addText(228, 72, `Shield\n${ship.getValue("shield")}`, "#2ad8dc", 20, true, true);
|
|
|
|
filler.addText(328, 72, `Power\n${ship.getValue("power")}`, "#ffdd4b", 20, true, true);
|
|
|
|
|
|
|
|
let iy = 148;
|
|
|
|
|
|
|
|
let effects = ship.sticky_effects;
|
|
|
|
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-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
|
|
|
let sprite = this.battleview.arena.findShipSprite(ship);
|
|
|
|
if (sprite) {
|
|
|
|
let bounds = sprite.getBounds();
|
|
|
|
bounds.x = sprite.worldPosition.x + sprite.width * sprite.worldScale.x * 0.5; // TODO Should not be necessary
|
|
|
|
bounds.y = sprite.worldPosition.y - sprite.height * sprite.worldScale.y * 0.5;
|
|
|
|
this.container.show(sprite.getBounds());
|
|
|
|
}
|
2017-01-16 23:20:33 +00:00
|
|
|
}
|
2017-01-09 23:24:33 +00:00
|
|
|
}
|
|
|
|
}
|