diff --git a/TODO.md b/TODO.md index 84a4148..b3e3486 100644 --- a/TODO.md +++ b/TODO.md @@ -24,8 +24,6 @@ Map/story Character sheet --------------- -* Fix the hover/on not working on fleet members -* Improve tooltip content * Replace the close icon by a validation icon in creation view * Allow to change/buy ship model * Allow to rename a personality (in creation view only) diff --git a/graphics/exported/character/portrait-hover.png b/graphics/exported/character/portrait-hover.png index f2edc46..fd00cb1 100644 Binary files a/graphics/exported/character/portrait-hover.png and b/graphics/exported/character/portrait-hover.png differ diff --git a/graphics/exported/character/portrait-on.png b/graphics/exported/character/portrait-on.png index fd00cb1..b6b24ee 100644 Binary files a/graphics/exported/character/portrait-on.png and b/graphics/exported/character/portrait-on.png differ diff --git a/graphics/ui/character.svg b/graphics/ui/character.svg index c68907e..3dcd9cb 100644 --- a/graphics/ui/character.svg +++ b/graphics/ui/character.svg @@ -23,6 +23,26 @@ enable-background="new"> + + + + + + @@ -791,19 +811,6 @@ result="composite2" id="feComposite15041" /> - - - + + + + Actions - + + + + + + + + + + + { - // FIXME Under hover/on let portrait = builder.image(`ship-${this.ship.model.code}-portrait`, 0, 0, true); portrait.scale.set(0.5); }); diff --git a/src/ui/character/CharacterSheet.ts b/src/ui/character/CharacterSheet.ts index bc5e92e..052dba8 100644 --- a/src/ui/character/CharacterSheet.ts +++ b/src/ui/character/CharacterSheet.ts @@ -256,7 +256,7 @@ module TK.SpaceTac.UI { let builder = this.builder.in(this.group_portraits); fleet.ships.forEach((ship, idx) => { - let button: UIButton + let button: UIButton; button = new CharacterPortrait(ship).draw(builder, 64 + idx * 140, 64, () => { if (button) { builder.select(button); @@ -267,6 +267,10 @@ module TK.SpaceTac.UI { this.refreshUpgrades(); } }); + + if (ship == this.ship) { + builder.switch(button, true); + } }); } } diff --git a/src/ui/common/UIBuilder.ts b/src/ui/common/UIBuilder.ts index 201ca3c..735fcbe 100644 --- a/src/ui/common/UIBuilder.ts +++ b/src/ui/common/UIBuilder.ts @@ -122,6 +122,14 @@ module TK.SpaceTac.UI { private add(child: UIText | UIImage | UIButton | UIContainer): void { if (this.parent instanceof Phaser.Group) { this.parent.add(child); + } else if (this.parent instanceof Phaser.Button) { + // Protect the "on" and "hover" layers + let layer = first(this.parent.children, child => child instanceof Phaser.Image && (child.name == "*on*" || child.name == "*hover*")); + if (layer) { + this.parent.addChildAt(child, this.parent.getChildIndex(layer)); + } else { + this.parent.addChild(child); + } } else { this.parent.addChild(child); } @@ -208,6 +216,7 @@ module TK.SpaceTac.UI { let on_info = this.view.getImageInfo(options.on_name || (name + "-on")); if (on_info.exists) { on_mask = new Phaser.Image(this.game, 0, 0, on_info.key, on_info.frame); + on_mask.name = "*on*"; on_mask.visible = false; result.addChild(on_mask); } @@ -227,6 +236,7 @@ module TK.SpaceTac.UI { let hover_mask: Phaser.Image | null = null; if (hover_info.exists) { hover_mask = new Phaser.Image(this.game, 0, 0, hover_info.key, hover_info.frame); + hover_mask.name = "*hover*"; hover_mask.visible = false; result.addChild(hover_mask); } @@ -252,8 +262,7 @@ module TK.SpaceTac.UI { () => { if (onclick) { onclick(); - } - if (onoffcallback) { + } else if (onoffcallback) { this.switch(result, !onstatus); } }, 100); diff --git a/src/ui/common/UITools.ts b/src/ui/common/UITools.ts index 2dbf1bd..9dee909 100644 --- a/src/ui/common/UITools.ts +++ b/src/ui/common/UITools.ts @@ -147,7 +147,7 @@ module TK.SpaceTac.UI { if (!(background.width && background.data.bg_bounds && UITools.compareRects(background.data.bg_bounds, bounds))) { background.clear(); background.lineStyle(2, 0x404450); - background.beginFill(0x202225, 0.9); + background.beginFill(0x202225); background.drawRect(x, y, width, height); background.endFill();