Opened 11 years ago

Closed 11 years ago

Last modified 5 years ago

#1802 closed enhancement (fixed)

[PATCH] Hero button

Reported by: historic_bruno Owned by:
Priority: Nice to Have Milestone: Alpha 14
Component: UI & Simulation Keywords: simple patch
Cc: Patch:

Description (last modified by historic_bruno)

The session UI should have a hero button. When the player has a living hero, it will show the portrait and any useful stats (e.g. health). When the button is pressed, the camera should focus on the hero. The button should appear consistent with the session UI style.

Here's an old mockup as an example:
Old mockup from Michael

Attachments (6)

herobutton.jpg (37.3 KB ) - added by historic_bruno 11 years ago.
Old mockup from Michael
hero_button.patch (6.5 KB ) - added by Manuel Núñez 11 years ago.
hero_button.2.patch (8.7 KB ) - added by alpha123 11 years ago.
Fixes a bug and adds a hotkey.
hero_button.3.patch (9.0 KB ) - added by alpha123 11 years ago.
Fix a couple of little bugs with the hotkey. Should be very solid now.
hero_button.4.patch (6.7 KB ) - added by alpha123 11 years ago.
Removed hotkey (moved to another ticket)
hero-button-fix-garrisoned.patch (459 bytes ) - added by alpha123 11 years ago.
Fix errors when attempting to center on a garrisoned hero

Download all attachments as: .zip

Change History (29)

by historic_bruno, 11 years ago

Attachment: herobutton.jpg added

Old mockup from Michael

comment:1 by historic_bruno, 11 years ago

Description: modified (diff)

comment:2 by michael, 11 years ago

Note, we'll probably have to move the framerate counter to somewhere else, which shouldn't be much of a hassle, except deciding where to put it.

comment:3 by Kieran P, 11 years ago

Milestone: BacklogAlpha 13
Priority: Should HaveNice to Have

comment:4 by Manuel Núñez, 11 years ago

I have a wip patch but I'm wondering two issues:

  • Where should I move the framerate counter?
  • Should the portrait include a health bar?

comment:5 by Manuel Núñez, 11 years ago

Keywords: review patch added
Summary: Hero button[PATCH] Hero button

comment:6 by Manuel Núñez, 11 years ago

The patch moves the framerate counter to the right top of the screen and do not include a health bar in the hero button.

The button behaves as the group buttons. Single clic to select and double clic to select and center camera.

The tooltip is quite similar to the one proposed in the mockup.

by Manuel Núñez, 11 years ago

Attachment: hero_button.patch added

comment:7 by Manuel Núñez, 11 years ago

Fps counter moved slightly down, just below time counter.

Removed unnecessary Select function.

comment:8 by Yves, 11 years ago

I think it should support displaying multiple heros. Normal games are restricted to one hero but there could be multiple heros in screnarios or campaigns.

comment:9 by Manuel Núñez, 11 years ago

The patch keeps track of multiple heroes in Player component, however the changes purposed for the session.xml file add only one button object. Nevertheless, It would be very easy to extend it to show several heroes.

Assuming we have to support multiple heroes... how many should be supported?

Last edited 11 years ago by Manuel Núñez (previous) (diff)

comment:10 by Yves, 11 years ago

I think it should display all heroes but do something smart if there are so many heroes that it would cover too much of the screen (like making it scrollable or scaling the images down). But I think for the moment it's fine to just add all heroes and don't cover the case where there are too many (if you don't want to do that work now to cover such a special case). I think the UI has to become more flexible in the future anyway and such cases can be covered once the UI offers more features.

comment:11 by Yves, 11 years ago

If you place a Mill you get this error:

ERROR: Script message handler OnGlobalOwnershipChanged failed
ERROR: JavaScript error: simulation/components/Player.js line 513 TypeError: cmpIdentity is null ([object Object])@simulation/components/Player.js:513 GetFormationUnitAIs([object Array],1)@simulation/helpers/Commands.js:1146 ProcessCommand(1,[object Object])@simulation/helpers/Commands.js:136 TryConstructBuilding(1,[object Object],false,[object Object])@simulation/helpers/Commands.js:800 ProcessCommand(1,[object Object])@simulation/helpers/Commands.js:262
ERROR: Failed to call ProcessCommand() global script function
Last edited 11 years ago by Yves (previous) (diff)

comment:12 by Kieran P, 11 years ago

Milestone: Alpha 13Alpha 14

comment:13 by alpha123, 11 years ago

This does seem to break building placement with the above error for all buildings (not just mills) over here.

But the button looks great. :D

Last edited 11 years ago by alpha123 (previous) (diff)

comment:14 by alpha123, 11 years ago

Turns out it was a pretty trivial fix; you simply forgot to check if cmpIdentity was undefined a few times.

I fixed that, and also took the liberty of adding a hotkey for it, currently bound to ' (it's near the , and . hotkeys, which select all idle warriors/workers).

' cycles through living heroes, Shift+' adds them to the selection, and Alt+' selects all heroes.

by alpha123, 11 years ago

Attachment: hero_button.2.patch added

Fixes a bug and adds a hotkey.

by alpha123, 11 years ago

Attachment: hero_button.3.patch added

Fix a couple of little bugs with the hotkey. Should be very solid now.

comment:15 by alpha123, 11 years ago

I opted to remove the hotkey, because I ended up refactoring the code so that I could use it for cycling any entity. I'll put the hero hotkey along with some building cycling hotkeys in another patch.

by alpha123, 11 years ago

Attachment: hero_button.4.patch added

Removed hotkey (moved to another ticket)

comment:16 by leper, 11 years ago

Keywords: review removed
Resolution: fixed
Status: newclosed

Fixed in r13339.

Thanks for the patches.

comment:17 by historic_bruno, 11 years ago

comment:18 by alpha123, 11 years ago

Figures. The one thing I didn't test.... :P

Trivial fix though.

by alpha123, 11 years ago

Fix errors when attempting to center on a garrisoned hero

comment:19 by fabio, 11 years ago

It would be nice to have the hero icon become reddish when his healt is low. Similar to the building icon when you have not enough resources to build them. Let me know if you want a new ticket for this.

comment:20 by leper, 11 years ago

In 13346:

Fix errors when the hero is garrisoned. Patch by alpha123. Refs #1802.

comment:21 by leper, 11 years ago

A new ticket for that would be nice, maybe add something like centering on the building the hero is garrisoned in too. (Could be a simple ticket for someone new to our codebase)

comment:22 by fabio, 11 years ago

See #1902.

comment:23 by elexis, 5 years ago

In 23089:

Decouple panel entities code from session code and use class notation, refs #5387, #3000, #1902, #1802, rP18361.

Change the logic to only insert/delete buttonhandlers on ownershipchange and update only the entitystate dependent part on simulation update.

Differential Revision: https://code.wildfiregames.com/D2387

Note: See TracTickets for help on using tickets.