2011-09-28 17:55:01 +00:00
|
|
|
/**
|
2009-12-29 13:44:16 +00:00
|
|
|
HUD Adapter
|
2011-09-28 17:55:01 +00:00
|
|
|
|
2009-12-29 13:44:16 +00:00
|
|
|
Clonk-side scripts for the HUD. This object basically redirects the
|
|
|
|
engine callbacks for the clonk to the HUD. All crew members that
|
|
|
|
are to be shown in the HUD have to include this object and return
|
|
|
|
_inherited(); if they overload one of the callbacks used here.
|
|
|
|
|
2011-09-28 17:55:01 +00:00
|
|
|
This adapter redirects to the per player HUD controller and also
|
|
|
|
directly to the per clonk HUD selector.
|
|
|
|
|
2011-03-13 15:55:00 +00:00
|
|
|
Requires the ClonkControl.ocd to be included in the clonk too.
|
2011-09-28 17:55:01 +00:00
|
|
|
|
|
|
|
@authors Newton
|
2009-12-29 13:44:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
local HUDselector, HUDcontroller;
|
|
|
|
|
|
|
|
public func SetSelector(object sel) { HUDselector = sel; }
|
2010-05-04 16:10:42 +00:00
|
|
|
public func GetSelector() { return HUDselector; }
|
2009-12-29 13:44:16 +00:00
|
|
|
|
|
|
|
public func HUDAdapter()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// hotkey control
|
|
|
|
public func ControlHotkey(int hotindex)
|
|
|
|
{
|
2010-09-13 15:27:48 +00:00
|
|
|
if (HUDcontroller)
|
2010-05-04 16:10:42 +00:00
|
|
|
return HUDcontroller->ControlHotkey(hotindex);
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Engine callbacks */
|
|
|
|
|
|
|
|
// bootstrap the hud
|
2010-05-04 16:10:42 +00:00
|
|
|
protected func Recruitment(int plr)
|
2009-12-29 13:44:16 +00:00
|
|
|
{
|
2010-05-04 16:10:42 +00:00
|
|
|
HUDcontroller = FindObject(Find_ID(GUI_Controller), Find_Owner(plr));
|
|
|
|
if (!HUDcontroller)
|
|
|
|
HUDcontroller = CreateObject(GUI_Controller, 10, 10, plr);
|
2011-09-18 17:15:31 +00:00
|
|
|
|
2012-04-23 19:07:11 +00:00
|
|
|
HUDcontroller->ScheduleUpdateInventory();
|
2011-09-18 17:15:31 +00:00
|
|
|
|
2010-09-13 15:27:48 +00:00
|
|
|
return _inherited(plr, ...);
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
|
|
|
|
2010-08-01 15:02:09 +00:00
|
|
|
public func OnDisplayInfoMessage()
|
|
|
|
{
|
2011-09-22 15:18:37 +00:00
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->ClearButtonMessages();
|
2010-08-01 15:02:09 +00:00
|
|
|
}
|
|
|
|
|
2009-12-29 13:44:16 +00:00
|
|
|
// calls to the crew selector hud
|
2011-09-28 17:55:01 +00:00
|
|
|
protected func OnPromotion()
|
|
|
|
{
|
|
|
|
if (HUDselector)
|
|
|
|
HUDselector->UpdateRank();
|
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected func OnEnergyChange()
|
|
|
|
{
|
|
|
|
if (HUDselector)
|
|
|
|
HUDselector->UpdateHealthBar();
|
|
|
|
return _inherited(...);
|
|
|
|
|
|
|
|
}
|
|
|
|
protected func OnBreathChange() {
|
|
|
|
if (HUDselector)
|
|
|
|
HUDselector->UpdateBreathBar();
|
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected func OnMagicEnergyChange() {
|
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected func OnNameChanged()
|
|
|
|
{
|
|
|
|
if (HUDselector)
|
|
|
|
HUDselector->UpdateName();
|
|
|
|
return _inherited(...);
|
|
|
|
}
|
2009-12-29 13:44:16 +00:00
|
|
|
|
2010-12-10 00:06:38 +00:00
|
|
|
protected func OnPhysicalChange(string physical, int change)
|
2009-12-29 13:44:16 +00:00
|
|
|
{
|
2010-05-04 16:10:42 +00:00
|
|
|
if (HUDselector)
|
|
|
|
{
|
2009-12-29 13:44:16 +00:00
|
|
|
// all physicals are resetted
|
2010-05-04 16:10:42 +00:00
|
|
|
if (!physical)
|
2009-12-29 13:44:16 +00:00
|
|
|
{
|
|
|
|
HUDselector->UpdateHealthBar();
|
|
|
|
HUDselector->UpdateBreathBar();
|
|
|
|
HUDselector->UpdateMagicBar();
|
|
|
|
}
|
2010-05-04 16:10:42 +00:00
|
|
|
else if (physical == "Energy") HUDselector->UpdateHealthBar();
|
|
|
|
else if (physical == "Breath") HUDselector->UpdateBreathBar();
|
|
|
|
else if (physical == "Magic") HUDselector->UpdateMagicBar();
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
2010-12-10 00:06:38 +00:00
|
|
|
return _inherited(physical, change, ...);
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// calls to both crew selector and controller
|
|
|
|
protected func CrewSelection(bool unselect)
|
|
|
|
{
|
2010-09-13 15:27:48 +00:00
|
|
|
if (HUDselector)
|
2010-05-04 16:10:42 +00:00
|
|
|
HUDselector->UpdateSelectionStatus();
|
2010-09-13 15:27:48 +00:00
|
|
|
if (HUDcontroller)
|
2010-05-04 16:10:42 +00:00
|
|
|
HUDcontroller->OnCrewSelection(this,unselect);
|
2010-09-13 15:27:48 +00:00
|
|
|
return _inherited(unselect, ...);
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// calls to controller
|
|
|
|
protected func OnCrewEnabled()
|
|
|
|
{
|
2010-09-13 15:27:48 +00:00
|
|
|
if (HUDcontroller)
|
2010-05-04 16:10:42 +00:00
|
|
|
HUDcontroller->OnCrewEnabled(this);
|
2009-12-29 13:44:16 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected func OnCrewDisabled()
|
|
|
|
{
|
2010-09-13 15:27:48 +00:00
|
|
|
if (HUDcontroller)
|
2010-05-04 16:10:42 +00:00
|
|
|
HUDcontroller->OnCrewDisabled(this);
|
2009-12-29 13:44:16 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
2011-03-13 15:55:00 +00:00
|
|
|
// from ClonkControl.ocd
|
2009-12-29 13:44:16 +00:00
|
|
|
protected func OnSlotFull(int slot)
|
|
|
|
{
|
2010-05-04 16:10:42 +00:00
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->OnSlotObjectChanged(slot);
|
2012-03-09 22:00:05 +00:00
|
|
|
|
2010-05-04 16:10:42 +00:00
|
|
|
return _inherited(slot, ...);
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected func OnSlotEmpty(int slot)
|
|
|
|
{
|
2010-05-04 16:10:42 +00:00
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->OnSlotObjectChanged(slot);
|
2012-03-09 22:00:05 +00:00
|
|
|
|
2010-05-04 16:10:42 +00:00
|
|
|
return _inherited(slot, ...);
|
|
|
|
}
|
2011-09-18 17:15:31 +00:00
|
|
|
|
2012-07-05 18:09:32 +00:00
|
|
|
// used to add a progress bar to an inventory slot
|
|
|
|
// "effect" refers to an effect with the properties "max" and "current" that is used to keep the progress bar state up-to-date
|
|
|
|
func SetProgressBarLinkForObject(object what, proplist effect)
|
|
|
|
{
|
|
|
|
if(HUDcontroller)
|
|
|
|
HUDcontroller->SetProgressBarLinkForObject(what, effect);
|
|
|
|
return _inherited(what, effect, ...);
|
|
|
|
}
|
2012-02-26 00:48:58 +00:00
|
|
|
|
|
|
|
protected func OnHandSelectionChange(int old, int new, int handslot)
|
|
|
|
{
|
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->OnHandSelectionChange(old, new, handslot);
|
|
|
|
return _inherited(old, new, handslot, ...);
|
|
|
|
}
|
|
|
|
|
2012-02-26 15:19:52 +00:00
|
|
|
protected func OnInventoryHotkeyPress(int slot)
|
|
|
|
{
|
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->OnInventoryHotkeyPress(slot);
|
|
|
|
return _inherited(slot, ...);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected func OnInventoryHotkeyRelease(int slot)
|
|
|
|
{
|
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->OnInventoryHotkeyRelease(slot);
|
|
|
|
return _inherited(slot, ...);
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:34 +00:00
|
|
|
// when something in the inventory changed
|
|
|
|
protected func OnInventoryChange()
|
2012-02-26 00:48:58 +00:00
|
|
|
{
|
|
|
|
if (HUDcontroller)
|
2012-04-23 19:07:11 +00:00
|
|
|
HUDcontroller->ScheduleUpdateInventory();
|
2012-03-21 20:55:34 +00:00
|
|
|
return _inherited(...);
|
2012-02-26 00:48:58 +00:00
|
|
|
}
|
|
|
|
|
2012-04-07 21:31:59 +00:00
|
|
|
// when a carryheavy object is picked up/dropped
|
2012-04-13 17:14:55 +00:00
|
|
|
protected func OnCarryHeavyChange(object carried)
|
2012-04-07 21:31:59 +00:00
|
|
|
{
|
|
|
|
if(HUDcontroller)
|
2012-04-13 17:14:55 +00:00
|
|
|
if(GetCursor(GetOwner()) == this)
|
|
|
|
HUDcontroller->OnCarryHeavyChange(carried);
|
2012-04-07 21:31:59 +00:00
|
|
|
|
|
|
|
return _inherited(carried, ...);
|
|
|
|
}
|
|
|
|
|
2011-09-18 17:15:31 +00:00
|
|
|
func Collection2()
|
|
|
|
{
|
2011-09-18 20:03:08 +00:00
|
|
|
if (HUDcontroller)
|
2012-04-23 19:07:11 +00:00
|
|
|
HUDcontroller->ScheduleUpdateInventory();
|
2011-09-18 17:15:31 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
|
|
|
func Ejection()
|
|
|
|
{
|
2011-09-18 20:03:08 +00:00
|
|
|
if (HUDcontroller)
|
2012-04-23 19:07:11 +00:00
|
|
|
HUDcontroller->ScheduleUpdateInventory();
|
2011-09-18 17:15:31 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
|
|
|
func ControlContents()
|
|
|
|
{
|
2011-09-18 20:03:08 +00:00
|
|
|
if (HUDcontroller)
|
2012-04-23 19:07:11 +00:00
|
|
|
HUDcontroller->ScheduleUpdateInventory();
|
2011-09-18 17:15:31 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|