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
|
|
|
*/
|
|
|
|
|
2015-06-06 13:40:17 +00:00
|
|
|
local HUDcontroller;
|
2009-12-29 13:44:16 +00:00
|
|
|
|
2014-09-11 00:48:00 +00:00
|
|
|
|
2015-06-06 13:40:17 +00:00
|
|
|
public func IsHUDAdapter()
|
2009-12-29 13:44:16 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-06 13:40:17 +00:00
|
|
|
/*-- Engine callbacks --*/
|
2009-12-29 13:44:16 +00:00
|
|
|
|
2015-06-06 13:40:17 +00:00
|
|
|
// Bootstrap the HUD on the recruitement of a crew member.
|
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)
|
2015-06-06 13:40:17 +00:00
|
|
|
HUDcontroller = CreateObject(GUI_Controller, 0, 0, plr);
|
|
|
|
HUDcontroller->~OnCrewRecruitment(this, plr, ...);
|
|
|
|
HUDcontroller->~ScheduleUpdateInventory();
|
2010-09-13 15:27:48 +00:00
|
|
|
return _inherited(plr, ...);
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
|
|
|
|
2014-01-04 13:21:44 +00:00
|
|
|
protected func DeRecruitment(int plr)
|
|
|
|
{
|
2015-06-06 13:40:17 +00:00
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->~OnCrewDeRecruitment(this, plr, ...);
|
2014-01-04 13:21:44 +00:00
|
|
|
return _inherited(plr, ...);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected func Death(int killed_by)
|
|
|
|
{
|
2015-06-06 13:40:17 +00:00
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->~OnCrewDeath(this, killed_by, ...);
|
|
|
|
return _inherited(killed_by, ...);
|
2014-01-04 13:21:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected func Destruction()
|
|
|
|
{
|
2015-06-06 13:40:17 +00:00
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->~OnCrewDestruction(this, ...);
|
2014-01-04 13:21:44 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
2015-06-06 13:40:17 +00:00
|
|
|
public func ControlHotkey(int hotindex)
|
|
|
|
{
|
|
|
|
if (HUDcontroller)
|
|
|
|
return HUDcontroller->~ControlHotkey(hotindex);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-01 15:02:09 +00:00
|
|
|
public func OnDisplayInfoMessage()
|
|
|
|
{
|
2013-05-26 01:24:46 +00:00
|
|
|
|
2010-08-01 15:02:09 +00:00
|
|
|
}
|
2015-06-06 13:40:17 +00:00
|
|
|
|
2011-09-28 17:55:01 +00:00
|
|
|
protected func OnPromotion()
|
|
|
|
{
|
2015-06-06 13:40:17 +00:00
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->~OnCrewRankChange(this);
|
2011-09-28 17:55:01 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected func OnEnergyChange()
|
|
|
|
{
|
2015-06-06 13:40:17 +00:00
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->~OnCrewHealthChange(this);
|
2011-09-28 17:55:01 +00:00
|
|
|
return _inherited(...);
|
|
|
|
|
|
|
|
}
|
2015-06-06 13:40:17 +00:00
|
|
|
protected func OnBreathChange()
|
|
|
|
{
|
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->~OnCrewBreathChange(this);
|
2011-09-28 17:55:01 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected func OnNameChanged()
|
|
|
|
{
|
2015-06-06 13:40:17 +00:00
|
|
|
if (HUDcontroller)
|
|
|
|
HUDcontroller->~OnCrewNameChange(this);
|
2011-09-28 17:55:01 +00:00
|
|
|
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
|
|
|
{
|
2015-06-06 13:40:17 +00:00
|
|
|
if (HUDcontroller)
|
|
|
|
{
|
2010-05-04 16:10:42 +00:00
|
|
|
if (!physical)
|
2009-12-29 13:44:16 +00:00
|
|
|
{
|
2015-06-06 13:40:17 +00:00
|
|
|
HUDcontroller->~OnCrewHealthChange(this);
|
|
|
|
HUDcontroller->~OnCrewBreathChange(this);
|
2009-12-29 13:44:16 +00:00
|
|
|
}
|
2015-06-06 13:40:17 +00:00
|
|
|
else if (physical == "Energy") HUDcontroller->~OnCrewHealthChange(this);
|
|
|
|
else if (physical == "Breath") HUDcontroller->~OnCrewBreathChange(this);
|
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 (HUDcontroller)
|
2015-06-06 13:40:17 +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)
|
2015-06-06 13:40:17 +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)
|
2015-06-06 13:40:17 +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)
|
2015-06-06 13:40:17 +00:00
|
|
|
HUDcontroller->~OnSlotObjectChanged(slot);
|
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)
|
2015-06-06 13:40:17 +00:00
|
|
|
HUDcontroller->~OnSlotObjectChanged(slot);
|
2010-05-04 16:10:42 +00:00
|
|
|
return _inherited(slot, ...);
|
|
|
|
}
|
2011-09-18 17:15:31 +00:00
|
|
|
|
2012-02-26 00:48:58 +00:00
|
|
|
protected func OnHandSelectionChange(int old, int new, int handslot)
|
|
|
|
{
|
|
|
|
if (HUDcontroller)
|
2015-06-06 13:40:17 +00:00
|
|
|
HUDcontroller->~OnHandSelectionChange(old, new, handslot);
|
2012-02-26 00:48:58 +00:00
|
|
|
return _inherited(old, new, handslot, ...);
|
|
|
|
}
|
|
|
|
|
2013-05-26 01:24:46 +00:00
|
|
|
// handled by GUI_Controller_ActionBars
|
|
|
|
func StartInteractionCheck(object clonk)
|
|
|
|
{
|
|
|
|
if (HUDcontroller)
|
|
|
|
return HUDcontroller->~StartInteractionCheck(clonk, ...);
|
|
|
|
}
|
|
|
|
|
|
|
|
// handled by GUI_Controller_ActionBars
|
|
|
|
func StopInteractionCheck()
|
|
|
|
{
|
|
|
|
if (HUDcontroller)
|
|
|
|
return HUDcontroller->~StopInteractionCheck(...);
|
|
|
|
}
|
|
|
|
|
2012-02-26 15:19:52 +00:00
|
|
|
protected func OnInventoryHotkeyPress(int slot)
|
|
|
|
{
|
|
|
|
if (HUDcontroller)
|
2015-06-06 13:40:17 +00:00
|
|
|
HUDcontroller->~OnInventoryHotkeyPress(slot);
|
2012-02-26 15:19:52 +00:00
|
|
|
return _inherited(slot, ...);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected func OnInventoryHotkeyRelease(int slot)
|
|
|
|
{
|
|
|
|
if (HUDcontroller)
|
2015-06-06 13:40:17 +00:00
|
|
|
HUDcontroller->~OnInventoryHotkeyRelease(slot);
|
2012-02-26 15:19:52 +00:00
|
|
|
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)
|
2015-06-06 13:40:17 +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
|
|
|
{
|
2015-06-06 13:40:17 +00:00
|
|
|
if (HUDcontroller)
|
|
|
|
if (GetCursor(GetOwner()) == this)
|
|
|
|
HUDcontroller->~OnCarryHeavyChange(carried);
|
2012-04-07 21:31:59 +00:00
|
|
|
return _inherited(carried, ...);
|
|
|
|
}
|
|
|
|
|
2015-06-06 13:40:17 +00:00
|
|
|
public func Collection2()
|
2011-09-18 17:15:31 +00:00
|
|
|
{
|
2011-09-18 20:03:08 +00:00
|
|
|
if (HUDcontroller)
|
2015-06-06 13:40:17 +00:00
|
|
|
HUDcontroller->~ScheduleUpdateInventory();
|
2011-09-18 17:15:31 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
2015-06-06 13:40:17 +00:00
|
|
|
public func Ejection()
|
2011-09-18 17:15:31 +00:00
|
|
|
{
|
2011-09-18 20:03:08 +00:00
|
|
|
if (HUDcontroller)
|
2015-06-06 13:40:17 +00:00
|
|
|
HUDcontroller->~ScheduleUpdateInventory();
|
2011-09-18 17:15:31 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|
|
|
|
|
2015-06-06 13:40:17 +00:00
|
|
|
public func ControlContents()
|
2011-09-18 17:15:31 +00:00
|
|
|
{
|
2011-09-18 20:03:08 +00:00
|
|
|
if (HUDcontroller)
|
2015-06-06 13:40:17 +00:00
|
|
|
HUDcontroller->~ScheduleUpdateInventory();
|
2011-09-18 17:15:31 +00:00
|
|
|
return _inherited(...);
|
|
|
|
}
|