forked from Mirrors/openclonk
Moved HUD proplist definitions to separate, overloadable functions.
See http://forum.openclonk.org/topic_show.pl?pid=32552#pid32552 for more information.directional-lights
parent
ddb34ab5cb
commit
f37eda9508
|
@ -20,9 +20,11 @@ local current_interaction;
|
|||
local actionbar_gui_menu;
|
||||
local actionbar_gui_id;
|
||||
|
||||
/* Creation / Destruction */
|
||||
/* GUI creation */
|
||||
|
||||
private func Construction()
|
||||
// For custom HUD graphics overload the following function as deemed fit.
|
||||
|
||||
func AssembleActionBar()
|
||||
{
|
||||
// Calculate margin + width of crew portraits
|
||||
var icon_margin = GUI_Controller_CrewBar_CursorMargin +
|
||||
|
@ -32,7 +34,7 @@ private func Construction()
|
|||
GUI_Controller_CrewBar_IconMargin;
|
||||
var icon_size = icon_margin + GUI_Controller_CrewBar_IconSize;
|
||||
|
||||
actionbar_gui_menu =
|
||||
return
|
||||
{
|
||||
Target = this,
|
||||
Player = NO_OWNER, // will be shown only if there is an interaction possible, e.g. standing in front of a vehicle
|
||||
|
@ -94,6 +96,15 @@ private func Construction()
|
|||
Priority = 6
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* Creation / Destruction */
|
||||
|
||||
private func Construction()
|
||||
{
|
||||
|
||||
actionbar_gui_menu = AssembleActionBar();
|
||||
|
||||
actionbar_gui_id = GuiOpen(actionbar_gui_menu);
|
||||
|
||||
EnableInteractionUpdating(true);
|
||||
|
|
|
@ -60,14 +60,12 @@ local crew_plus_id;
|
|||
local crew_info_menu;
|
||||
local crew_info_id;
|
||||
|
||||
/* Creation / Destruction */
|
||||
/* GUI creation */
|
||||
|
||||
private func Construction()
|
||||
// For custom HUD graphics overload the following function as deemed fit.
|
||||
|
||||
func AssembleCrewBar()
|
||||
{
|
||||
crew_bars = [];
|
||||
crew_warnings = [];
|
||||
// crew_displays = [];
|
||||
|
||||
var cursor_margin = GUI_Controller_CrewBar_CursorMargin;
|
||||
var cursor_size = cursor_margin + GUI_Controller_CrewBar_CursorSize;
|
||||
|
||||
|
@ -80,7 +78,39 @@ private func Construction()
|
|||
crew_next_id = 10;
|
||||
crew_warning_id = 20;
|
||||
|
||||
crew_gui_menu =
|
||||
// --- WARNING ---
|
||||
// Crew plus menu and crew info menu will probably be removed!
|
||||
// Hereby marked deprecated!
|
||||
|
||||
crew_plus_menu =
|
||||
{
|
||||
Target = this,
|
||||
Player = GetOwner(),
|
||||
Style = GUI_NoCrop | GUI_Multiple,
|
||||
Left = ToEmString(next_margin + GUI_Controller_CrewBar_IconSize / 2),
|
||||
Right = ToEmString(next_margin + GUI_Controller_CrewBar_IconSize * 3 / 2),
|
||||
Top = ToEmString(next_y_margin),
|
||||
Bottom = ToEmString(next_y_size - GUI_Controller_CrewBar_IconSize / 2),
|
||||
Symbol = Icon_Number,
|
||||
GraphicsName = "PlusGreen",
|
||||
Priority = 10,
|
||||
OnClick = GuiAction_Call(this, "OpenCrewInfo")
|
||||
};
|
||||
|
||||
crew_info_menu =
|
||||
{
|
||||
Target = this,
|
||||
Style = GUI_NoCrop | GUI_Multiple | GUI_FitChildren,
|
||||
Left = ToEmString(next_margin),
|
||||
Right = ToEmString(next_margin + GUI_Controller_CrewBar_IconSize),
|
||||
Top = ToEmString(next_y_size + GUI_Controller_CrewBar_IconMargin*2),
|
||||
Decoration = GUI_MenuDecoInventoryHeader,
|
||||
Priority = 11
|
||||
};
|
||||
|
||||
// --- SEE WARNING ABOVE ---
|
||||
|
||||
return
|
||||
{
|
||||
Target = this,
|
||||
ID = 1,
|
||||
|
@ -140,7 +170,8 @@ private func Construction()
|
|||
Player = NO_OWNER,
|
||||
ID = crew_cursor_id + 1,
|
||||
Margin = ["5%"],
|
||||
Symbol = Icon_Heart,
|
||||
Symbol = CrewHealIcon().Symbol,
|
||||
GraphicsName = CrewHealIcon().GraphicsName,
|
||||
Priority = 7
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +227,8 @@ private func Construction()
|
|||
Player = NO_OWNER,
|
||||
ID = crew_next_id + 1,
|
||||
Margin = ["5%"],
|
||||
Symbol = Icon_Heart,
|
||||
Symbol = CrewHealIcon().Symbol,
|
||||
GraphicsName = CrewHealIcon().GraphicsName,
|
||||
Priority = 7
|
||||
}
|
||||
},
|
||||
|
@ -259,39 +291,61 @@ private func Construction()
|
|||
Priority = 10
|
||||
}
|
||||
};
|
||||
crew_gui_id = GuiOpen(crew_gui_menu);
|
||||
}
|
||||
|
||||
func AddCrewBars()
|
||||
{
|
||||
// Health bar
|
||||
crew_health_bar = AddCrewBar(RGB(160, 0, 0));
|
||||
// Magic bar
|
||||
crew_magic_bar = AddCrewBar(RGB(75, 75, 160));
|
||||
// Breath bar
|
||||
crew_breath_bar = AddCrewBar(RGB(0, 160, 160));
|
||||
}
|
||||
|
||||
crew_plus_menu =
|
||||
{
|
||||
Target = this,
|
||||
Player = GetOwner(),
|
||||
Style = GUI_NoCrop | GUI_Multiple,
|
||||
Left = ToEmString(next_margin + GUI_Controller_CrewBar_IconSize / 2),
|
||||
Right = ToEmString(next_margin + GUI_Controller_CrewBar_IconSize * 3 / 2),
|
||||
Top = ToEmString(next_y_margin),
|
||||
Bottom = ToEmString(next_y_size - GUI_Controller_CrewBar_IconSize / 2),
|
||||
Symbol = Icon_Number,
|
||||
GraphicsName = "PlusGreen",
|
||||
Priority = 10,
|
||||
OnClick = GuiAction_Call(this, "OpenCrewInfo")
|
||||
};
|
||||
func CrewRecruitmentIcon()
|
||||
{
|
||||
return Icon_Arrow;
|
||||
}
|
||||
|
||||
crew_info_menu =
|
||||
{
|
||||
Target = this,
|
||||
Style = GUI_NoCrop | GUI_Multiple | GUI_FitChildren,
|
||||
Left = ToEmString(next_margin),
|
||||
Right = ToEmString(next_margin + GUI_Controller_CrewBar_IconSize),
|
||||
Top = ToEmString(next_y_size + GUI_Controller_CrewBar_IconMargin*2),
|
||||
Decoration = GUI_MenuDecoInventoryHeader,
|
||||
Priority = 11
|
||||
};
|
||||
func CrewDeathIcon()
|
||||
{
|
||||
return Icon_Skull;
|
||||
}
|
||||
|
||||
func CrewHealIcon()
|
||||
{
|
||||
return { Symbol = Icon_Heart, GraphicsName = "" };
|
||||
}
|
||||
|
||||
func CrewFireDamageIcon()
|
||||
{
|
||||
return { Symbol = Icon_Heart, GraphicsName = "OnFire" };
|
||||
}
|
||||
|
||||
func CrewDamageIcon()
|
||||
{
|
||||
return { Symbol = Icon_Heart, GraphicsName = "Broken" };
|
||||
}
|
||||
|
||||
func CrewBreathIcon()
|
||||
{
|
||||
return Icon_Bubbles;
|
||||
}
|
||||
|
||||
/* Creation / Destruction */
|
||||
|
||||
private func Construction()
|
||||
{
|
||||
crew_bars = [];
|
||||
crew_warnings = [];
|
||||
// crew_displays = [];
|
||||
|
||||
crew_gui_menu = AssembleCrewBar();
|
||||
|
||||
crew_gui_id = GuiOpen(crew_gui_menu);
|
||||
|
||||
AddCrewBars();
|
||||
|
||||
return _inherited(...);
|
||||
}
|
||||
|
@ -334,7 +388,7 @@ public func OnCrewDeath(object clonk, int killer)
|
|||
|
||||
var next_index = GetNextCrewIndex(GetCursorIndex());
|
||||
if (GetCursor(GetOwner()) != clonk && GetCrew(GetOwner(), next_index) != clonk)
|
||||
IssueWarning(this, Icon_Skull, "", clonk->GetName()); // this for target because Clonk might get deleted
|
||||
IssueWarning(this, CrewDeathIcon(), "", clonk->GetName()); // this for target because Clonk might get deleted
|
||||
|
||||
return _inherited(clonk, killer, ...);
|
||||
}
|
||||
|
@ -415,12 +469,12 @@ public func OnCrewHealthChange(object clonk, int change, int cause, int caused_b
|
|||
}
|
||||
else // Show a warning
|
||||
{
|
||||
var graphics = "";
|
||||
var graphics = CrewHealIcon();
|
||||
if (change < 0)
|
||||
graphics = "Broken";
|
||||
graphics = CrewDamageIcon();
|
||||
if (clonk->OnFire())
|
||||
graphics = "OnFire";
|
||||
IssueWarning(clonk, Icon_Heart, graphics);
|
||||
graphics = CrewFireDamageIcon();
|
||||
IssueWarning(clonk, graphics.Symbol, graphics.GraphicsName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1154,7 +1208,8 @@ private func OpenCrewInfo()
|
|||
},
|
||||
heart =
|
||||
{
|
||||
Symbol = Icon_Heart,
|
||||
Symbol = CrewHealIcon().Symbol,
|
||||
GraphicsName = CrewHealIcon().GraphicsName,
|
||||
Left = "21%",
|
||||
Right = ToEmString(10),
|
||||
Top = ToEmString(10),
|
||||
|
|
|
@ -23,6 +23,71 @@ local inventory_slots;
|
|||
local inventory_gui_menu;
|
||||
local inventory_gui_id;
|
||||
|
||||
/* GUI creation */
|
||||
|
||||
// For custom HUD graphics overload the following function as deemed fit.
|
||||
|
||||
func AssembleInventoryButton(int max_slots, int slot_number, proplist slot_info)
|
||||
{
|
||||
// The gui already exists, only update it with a new submenu
|
||||
var pos = CalculateButtonPosition(slot_number, max_slots);
|
||||
|
||||
return
|
||||
{
|
||||
Target = this,
|
||||
slot_number =
|
||||
{
|
||||
Priority = 3, // Make sure the slot number is drawn above the icon.
|
||||
Style = GUI_TextTop,
|
||||
Text = Format("%2d", slot_info.slot + 1)
|
||||
},
|
||||
quick_switch = // Shows quick switch control key if this is the quick switch slot
|
||||
{
|
||||
Priority = 3,
|
||||
Style = GUI_NoCrop | GUI_TextHCenter | GUI_TextBottom,
|
||||
Left = "-50%",
|
||||
Right = "150%",
|
||||
Top = Format(" %s%s", "20%", ToEmString(-2)),
|
||||
Bottom = "20%",
|
||||
Text = { Std = "", Quick = Format("<c dddd00>[%s]</c>", GetPlayerControlAssignment(GetOwner(), CON_QuickSwitch, true)), Selected = "" }
|
||||
},
|
||||
Style = GUI_NoCrop,
|
||||
ID = slot_info.ID,
|
||||
Symbol = {Std = Icon_Menu_Circle, Quick = Icon_Menu_Circle, Selected = Icon_Menu_CircleHighlight},
|
||||
Left = pos.Left, Top = pos.Top, Right = pos.Right, Bottom = pos.Bottom,
|
||||
count =
|
||||
{
|
||||
ID = 1000 + slot_info.ID,
|
||||
Style = GUI_TextRight | GUI_TextBottom,
|
||||
Text = nil,
|
||||
Priority = 2
|
||||
},
|
||||
// Prepare (invisible) extra-slot display circle.
|
||||
extra_slot =
|
||||
{
|
||||
Top = ToEmString(GUI_Controller_InventoryBar_IconSize),
|
||||
Bottom = ToEmString(GUI_Controller_InventoryBar_IconSize + GUI_Controller_InventoryBar_IconSize/2),
|
||||
Style = GUI_TextLeft,
|
||||
Text = nil,
|
||||
symbol =// used to display an infinity sign if necessary (Icon_Number)
|
||||
{
|
||||
Right = ToEmString(GUI_Controller_InventoryBar_IconSize/2),
|
||||
GraphicsName = "Inf",
|
||||
},
|
||||
circle =// shows the item in the extra slot
|
||||
{
|
||||
Left = ToEmString(GUI_Controller_InventoryBar_IconSize/2),
|
||||
Symbol = nil,
|
||||
symbol = {}
|
||||
}
|
||||
},
|
||||
overlay = // Custom inventory overlays can be shown here.
|
||||
{
|
||||
ID = 2000 + slot_info.ID
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* Creation / Destruction */
|
||||
|
||||
private func Construction()
|
||||
|
@ -286,63 +351,8 @@ private func CreateNewInventoryButton(int max_slots)
|
|||
};
|
||||
PushBack(inventory_slots, slot_info);
|
||||
|
||||
// The gui already exists, only update it with a new submenu
|
||||
var pos = CalculateButtonPosition(slot_number, max_slots);
|
||||
var slot = AssembleInventoryButton(max_slots, slot_number, slot_info);
|
||||
|
||||
var slot =
|
||||
{
|
||||
Target = this,
|
||||
slot_number =
|
||||
{
|
||||
Priority = 3, // Make sure the slot number is drawn above the icon.
|
||||
Style = GUI_TextTop,
|
||||
Text = Format("%2d", slot_info.slot + 1)
|
||||
},
|
||||
quick_switch = // Shows quick switch control key if this is the quick switch slot
|
||||
{
|
||||
Priority = 3,
|
||||
Style = GUI_NoCrop | GUI_TextHCenter | GUI_TextBottom,
|
||||
Left = "-50%",
|
||||
Right = "150%",
|
||||
Top = Format(" %s%s", "20%", ToEmString(-2)),
|
||||
Bottom = "20%",
|
||||
Text = { Std = "", Quick = Format("<c dddd00>[%s]</c>", GetPlayerControlAssignment(GetOwner(), CON_QuickSwitch, true)), Selected = "" }
|
||||
},
|
||||
Style = GUI_NoCrop,
|
||||
ID = slot_info.ID,
|
||||
Symbol = {Std = Icon_Menu_Circle, Quick = Icon_Menu_Circle, Selected = Icon_Menu_CircleHighlight},
|
||||
Left = pos.Left, Top = pos.Top, Right = pos.Right, Bottom = pos.Bottom,
|
||||
count =
|
||||
{
|
||||
ID = 1000 + slot_info.ID,
|
||||
Style = GUI_TextRight | GUI_TextBottom,
|
||||
Text = nil,
|
||||
Priority = 2
|
||||
},
|
||||
// Prepare (invisible) extra-slot display circle.
|
||||
extra_slot =
|
||||
{
|
||||
Top = ToEmString(GUI_Controller_InventoryBar_IconSize),
|
||||
Bottom = ToEmString(GUI_Controller_InventoryBar_IconSize + GUI_Controller_InventoryBar_IconSize/2),
|
||||
Style = GUI_TextLeft,
|
||||
Text = nil,
|
||||
symbol =// used to display an infinity sign if necessary (Icon_Number)
|
||||
{
|
||||
Right = ToEmString(GUI_Controller_InventoryBar_IconSize/2),
|
||||
GraphicsName = "Inf",
|
||||
},
|
||||
circle =// shows the item in the extra slot
|
||||
{
|
||||
Left = ToEmString(GUI_Controller_InventoryBar_IconSize/2),
|
||||
Symbol = nil,
|
||||
symbol = {}
|
||||
}
|
||||
},
|
||||
overlay = // Custom inventory overlays can be shown here.
|
||||
{
|
||||
ID = 2000 + slot_info.ID
|
||||
}
|
||||
};
|
||||
GuiUpdate({_new_icon = slot}, inventory_gui_id);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue