crew HUD now shows selected crew member

Controls
Maikel de Vries 2015-06-07 10:16:56 +02:00
parent 3ba41e36d9
commit 1054bd55de
3 changed files with 34 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -7,7 +7,6 @@
// TODO: static const for bar margins.
// TODO: Use old bars.
// TODO: Show the selected clonk in some way.
// HUD margin and size in tenths of em.
static const GUI_Controller_CrewBar_IconSize = 80;
@ -82,6 +81,12 @@ public func OnCrewEnabled(object clonk)
return _inherited(clonk, ...);
}
public func OnCrewSelection(object clonk, bool unselect)
{
CrewHUDMenuUpdateSelection(clonk, unselect);
return _inherited(clonk, unselect, ...);
}
public func OnCrewNameChange(object clonk)
{
CrewHUDMenuUpdateName(clonk);
@ -213,6 +218,11 @@ private func AddCrewHUDMenuMember(object crew, int index, int margin, int size)
damage_dummy->SetGraphics("Hurt", GUI_Controller_CrewBar, GFX_Overlay, GFXOV_MODE_Picture);
damage_dummy->SetClrModulation(0x0, GFX_Overlay);
// Selection.
var selected = nil;
if (GetCursor(GetOwner()) == crew)
selected = "Selected";
var crew_menu =
{
// This part of the crew menu contains the background.
@ -237,7 +247,7 @@ private func AddCrewHUDMenuMember(object crew, int index, int margin, int size)
Target = crew_gui_target,
ID = 100 * (index + 1) + 2,
Symbol = GUI_Controller_CrewBar,
GraphicsName = { Std = nil, OnHover = "Focussed" },
GraphicsName = { Std = selected, OnHover = "Focussed" },
OnMouseIn = GuiAction_SetTag("OnHover"),
OnMouseOut = GuiAction_SetTag("Std"),
OnClick = GuiAction_Call(this, "CrewHUDMenuOnSelection", crew),
@ -410,6 +420,28 @@ private func CrewHUDMenuUpdateRank(object clonk)
return;
}
private func CrewHUDMenuUpdateSelection(object clonk, bool unselect)
{
// Disable all previous selections.
/*var index = 0, crew_menu;
while ((crew_menu = crew_gui_menu[Format("crew%d", index)]))
{
crew_menu.frame.GraphicsName = nil;
GuiUpdate(crew_menu.frame, crew_gui_id, crew_menu.frame.ID, crew_menu.frame.Target);
index++;
}*/
// Update the selection of the given clonk.
var crew_menu = CrewHUDMenuFindCrewMenu(clonk);
if (!crew_menu)
return;
var frame_menu = crew_menu[0].frame;
frame_menu.GraphicsName = "Selected";
if (unselect)
frame_menu.GraphicsName = nil;
GuiUpdate(frame_menu, crew_gui_id, frame_menu.ID, frame_menu.Target);
return;
}
private func CrewHUDMenuUpdateHealth(object clonk, int health, int health_ratio)
{
var crew_menu = CrewHUDMenuFindCrewMenu(clonk);