1
0
Fork 0

Added action tooltips on character sheet

This commit is contained in:
Michaël Lemaire 2018-06-06 23:06:04 +02:00
parent 513e82b487
commit 821900abc6
3 changed files with 17 additions and 14 deletions

View File

@ -34,7 +34,7 @@ Map/story
Character sheet Character sheet
--------------- ---------------
* Improve action and attribute tooltips * Improve attribute tooltips
* Implement sliders for personality traits * Implement sliders for personality traits
* Center the portraits when there are less than 5 * Center the portraits when there are less than 5

View File

@ -6,7 +6,7 @@ module TK.SpaceTac.UI {
/** /**
* Fill the tooltip * Fill the tooltip
*/ */
static fill(filler: TooltipBuilder, ship: Ship, action: BaseAction, position: number) { static fill(filler: TooltipBuilder, ship: Ship, action: BaseAction, position?: number): boolean {
let builder = filler.styled({ size: 20 }); let builder = filler.styled({ size: 20 });
let icon = builder.image(`action-${action.code}`); let icon = builder.image(`action-${action.code}`);
@ -49,17 +49,21 @@ module TK.SpaceTac.UI {
builder.text(description, 30, 170, { size: 16 }); builder.text(description, 30, 170, { size: 16 });
} }
let shortcut = ""; if (typeof position != "undefined") {
if (action instanceof EndTurnAction) { let shortcut = "";
shortcut = "[ space ]"; if (action instanceof EndTurnAction) {
} else if (position == 9) { shortcut = "[ space ]";
shortcut = "[ 0 ]"; } else if (position == 9) {
} else if (position >= 0 && position < 9) { shortcut = "[ 0 ]";
shortcut = `[ ${position + 1} ]`; } else if (position >= 0 && position < 9) {
} shortcut = `[ ${position + 1} ]`;
if (shortcut) { }
builder.text(shortcut, 150, 120, { color: "#aaaaaa", size: 12 }); if (shortcut) {
builder.text(shortcut, 150, 120, { color: "#aaaaaa", size: 12 });
}
} }
return true;
} }
} }
} }

View File

@ -306,8 +306,7 @@ module TK.SpaceTac.UI {
builder.in(builder.container("items"), builder => { builder.in(builder.container("items"), builder => {
let actions = ship.actions.listAll().filter(action => !(action instanceof EndTurnAction)); let actions = ship.actions.listAll().filter(action => !(action instanceof EndTurnAction));
actions.forEach(action => { actions.forEach(action => {
let button = builder.button(`action-${action.code}`, 24, 0, undefined, let button = builder.button(`action-${action.code}`, 24, 0, undefined, filler => ActionTooltip.fill(filler, ship, action));
action.getEffectsDescription());
button.setScale(0.375); button.setScale(0.375);
}); });
builder.distribute("y", 40, 688); builder.distribute("y", 40, 688);