Added ship tooltip
This commit is contained in:
parent
f80ab3350c
commit
166557c0d6
|
@ -85,14 +85,14 @@
|
|||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="5.6568542"
|
||||
inkscape:cx="101.91241"
|
||||
inkscape:cy="877.88947"
|
||||
inkscape:zoom="4"
|
||||
inkscape:cx="752.60811"
|
||||
inkscape:cy="207.999"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer16"
|
||||
inkscape:current-layer="layer17"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
showguides="true"
|
||||
showguides="false"
|
||||
inkscape:snap-bbox="false"
|
||||
inkscape:bbox-nodes="true"
|
||||
inkscape:bbox-paths="true"
|
||||
|
@ -134,6 +134,47 @@
|
|||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer17"
|
||||
inkscape:label="Arena">
|
||||
<g
|
||||
id="g4273">
|
||||
<rect
|
||||
y="821.71985"
|
||||
x="675.19873"
|
||||
height="112.25"
|
||||
width="112.75"
|
||||
id="rect4417"
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3.5999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="rect4375"
|
||||
d="m 680.39685,830.2035 47.64132,47.64132 -47.64132,47.64132 3.53553,3.53553 47.64132,-47.64132 47.64132,47.64132 3.53553,-3.53553 -47.64132,-47.64132 47.64132,-47.64132 -3.53553,-3.53553 -47.64132,47.64132 -47.64132,-47.64132 -3.53553,3.53553 z"
|
||||
style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3.5999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</g>
|
||||
<path
|
||||
style="opacity:1;fill:#cbe6ed;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3.5999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 696.57273,842.84286 0,70.00391 70.00195,0 0,-70.00391 -70.00195,0 z m 3.35741,3.35937 63.28711,0 0,63.28516 -63.28711,0 0,-63.28516 z"
|
||||
id="path4438"
|
||||
inkscape:connector-curvature="0" />
|
||||
<use
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#g4184"
|
||||
id="use4320"
|
||||
transform="matrix(0.06661534,0.18302414,-0.18302414,0.06661534,775.18857,930.22583)"
|
||||
width="100%"
|
||||
height="100%" />
|
||||
<use
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#use4320"
|
||||
id="use4429"
|
||||
transform="matrix(-0.96592583,0.25881905,-0.25881905,-0.96592583,2076.4223,1439.5912)"
|
||||
width="100%"
|
||||
height="100%" />
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer13"
|
||||
|
@ -279,7 +320,10 @@
|
|||
inkscape:rounded="0"
|
||||
inkscape:randomized="0"
|
||||
d="m 54.25,161.88109 -4.443658,-7.69664 8.887316,0 z"
|
||||
inkscape:transform-center-y="1.2827735" />
|
||||
inkscape:transform-center-y="1.2827735"
|
||||
inkscape:export-filename="/tmp/export.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<use
|
||||
x="0"
|
||||
y="0"
|
||||
|
@ -288,7 +332,10 @@
|
|||
id="use4314"
|
||||
transform="matrix(1,0,0,-1,0,375.61555)"
|
||||
width="100%"
|
||||
height="100%" />
|
||||
height="100%"
|
||||
inkscape:export-filename="/tmp/export.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<use
|
||||
x="0"
|
||||
y="0"
|
||||
|
@ -297,7 +344,10 @@
|
|||
transform="matrix(0,-1,1,0,-133.125,242.13379)"
|
||||
width="100%"
|
||||
height="100%"
|
||||
inkscape:transform-center-x="-1.2827735" />
|
||||
inkscape:transform-center-x="-1.2827735"
|
||||
inkscape:export-filename="/tmp/export.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
<use
|
||||
x="0"
|
||||
y="0"
|
||||
|
@ -306,7 +356,10 @@
|
|||
transform="matrix(0,1,-1,0,241.5,133.63379)"
|
||||
width="100%"
|
||||
height="100%"
|
||||
inkscape:transform-center-x="1.2827734" />
|
||||
inkscape:transform-center-x="1.2827734"
|
||||
inkscape:export-filename="/tmp/export.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
|
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 36 KiB |
BIN
out/assets/images/battle/ship-tooltip.png
Normal file
BIN
out/assets/images/battle/ship-tooltip.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
|
@ -37,6 +37,7 @@ module SpaceTac.View {
|
|||
this.loadImage("battle/actionpointsempty.png");
|
||||
this.loadImage("battle/actionpointsfull.png");
|
||||
this.loadImage("battle/actionpointspart.png");
|
||||
this.loadImage("battle/ship-tooltip.png");
|
||||
this.loadImage("battle/arena/shipspritehover.png");
|
||||
this.loadImage("battle/arena/shipspriteplaying.png");
|
||||
this.loadImage("battle/actions/move.png");
|
||||
|
|
|
@ -31,6 +31,9 @@ module SpaceTac.View {
|
|||
// Currently hovered ship
|
||||
ship_hovered: Game.Ship;
|
||||
|
||||
// Ship tooltip
|
||||
ship_tooltip: ShipTooltip;
|
||||
|
||||
// Subscription to the battle log
|
||||
log_processor: LogProcessor;
|
||||
|
||||
|
@ -74,6 +77,7 @@ module SpaceTac.View {
|
|||
// Add UI elements
|
||||
this.action_bar = new ActionBar(this);
|
||||
this.ship_list = new ShipList(this);
|
||||
this.ship_tooltip = new ShipTooltip(this);
|
||||
|
||||
this.icon_waiting = new Phaser.Image(this.game, this.getWidth() / 2, 50, "battle-waiting", 0);
|
||||
this.icon_waiting.anchor.set(0.5, 0.5);
|
||||
|
@ -174,6 +178,7 @@ module SpaceTac.View {
|
|||
this.ship_hovered = ship;
|
||||
this.arena.setShipHovered(ship);
|
||||
this.ship_list.setHovered(ship);
|
||||
this.ship_tooltip.setShip(ship);
|
||||
if (this.targetting) {
|
||||
if (ship) {
|
||||
this.targetting.setTargetShip(ship);
|
||||
|
|
51
src/view/battle/ShipTooltip.ts
Normal file
51
src/view/battle/ShipTooltip.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
module SpaceTac.View {
|
||||
// Tooltip to display ship information
|
||||
export class ShipTooltip extends Phaser.Sprite {
|
||||
battleview: BattleView;
|
||||
title: Phaser.Text;
|
||||
|
||||
constructor(parent: BattleView) {
|
||||
super(parent.game, 0, 0, "battle-ship-tooltip");
|
||||
this.visible = false;
|
||||
this.battleview = parent;
|
||||
|
||||
this.title = new Phaser.Text(this.game, 247, 10, "", { font: "24px Arial", fill: "#ffffff" });
|
||||
this.title.anchor.set(0.5, 0);
|
||||
this.addChild(this.title);
|
||||
|
||||
parent.ui.add(this);
|
||||
}
|
||||
|
||||
// Set current ship to display, null to hide
|
||||
setShip(ship: Game.Ship | null): void {
|
||||
console.log(ship);
|
||||
if (ship) {
|
||||
// Find ship sprite to position next to it
|
||||
var sprite = this.battleview.arena.findShipSprite(ship);
|
||||
if (sprite) {
|
||||
var x = sprite.worldPosition.x + sprite.width * 0.5;
|
||||
var y = sprite.worldPosition.y - sprite.height * 0.5;
|
||||
if (y + this.height > this.battleview.getHeight()) {
|
||||
y = this.battleview.getHeight() - this.height;
|
||||
}
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
if (x + this.width > this.battleview.getWidth()) {
|
||||
x = sprite.worldPosition.x - sprite.width * 0.5 - this.width;
|
||||
}
|
||||
this.position.set(x, y);
|
||||
} else {
|
||||
this.position.set(0, 0);
|
||||
}
|
||||
|
||||
// Fill info
|
||||
this.title.setText(ship.name);
|
||||
|
||||
Animation.fadeIn(this.game, this, 200, 0.9);
|
||||
} else {
|
||||
Animation.fadeOut(this.game, this, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue