openclonk/planet/Objects.ocd/Libraries.ocd/HUDAdapter.ocd/Script.c

225 lines
4.7 KiB
C
Raw Normal View History

/**
2009-12-29 13:44:16 +00:00
HUD Adapter
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.
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.
@authors Newton
2009-12-29 13:44:16 +00:00
*/
local HUDcontroller;
2009-12-29 13:44:16 +00:00
public func IsHUDAdapter()
2009-12-29 13:44:16 +00:00
{
return true;
}
/*-- Engine callbacks --*/
2009-12-29 13:44:16 +00:00
// Bootstrap the HUD on the recruitement of a crew member.
protected func Recruitment(int plr)
2009-12-29 13:44:16 +00:00
{
HUDcontroller = FindObject(Find_ID(GUI_Controller), Find_Owner(plr));
if (!HUDcontroller)
HUDcontroller = CreateObject(GUI_Controller, 0, 0, plr);
HUDcontroller->~OnCrewRecruitment(this, plr, ...);
HUDcontroller->~ScheduleUpdateInventory();
return _inherited(plr, ...);
2009-12-29 13:44:16 +00:00
}
protected func DeRecruitment(int plr)
{
if (HUDcontroller)
HUDcontroller->~OnCrewDeRecruitment(this, plr, ...);
return _inherited(plr, ...);
}
protected func Death(int killed_by)
{
if (HUDcontroller)
HUDcontroller->~OnCrewDeath(this, killed_by, ...);
return _inherited(killed_by, ...);
}
protected func Destruction()
{
if (HUDcontroller)
HUDcontroller->~OnCrewDestruction(this, ...);
return _inherited(...);
}
public func ControlHotkey(int hotindex)
{
if (HUDcontroller)
return HUDcontroller->~ControlHotkey(hotindex);
}
public func OnDisplayInfoMessage()
{
}
protected func OnPromotion()
{
if (HUDcontroller)
HUDcontroller->~OnCrewRankChange(this);
return _inherited(...);
}
protected func OnEnergyChange()
{
if (HUDcontroller)
HUDcontroller->~OnCrewHealthChange(this);
return _inherited(...);
}
protected func OnBreathChange()
{
if (HUDcontroller)
HUDcontroller->~OnCrewBreathChange(this);
return _inherited(...);
}
protected func OnNameChanged()
{
if (HUDcontroller)
HUDcontroller->~OnCrewNameChange(this);
return _inherited(...);
}
2009-12-29 13:44:16 +00:00
protected func OnPhysicalChange(string physical, int change)
2009-12-29 13:44:16 +00:00
{
if (HUDcontroller)
{
if (!physical)
2009-12-29 13:44:16 +00:00
{
HUDcontroller->~OnCrewHealthChange(this);
HUDcontroller->~OnCrewBreathChange(this);
2009-12-29 13:44:16 +00:00
}
else if (physical == "Energy") HUDcontroller->~OnCrewHealthChange(this);
else if (physical == "Breath") HUDcontroller->~OnCrewBreathChange(this);
2009-12-29 13:44:16 +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)
{
if (HUDcontroller)
HUDcontroller->~OnCrewSelection(this, unselect);
return _inherited(unselect, ...);
2009-12-29 13:44:16 +00:00
}
// calls to controller
protected func OnCrewEnabled()
{
if (HUDcontroller)
HUDcontroller->~OnCrewEnabled(this);
2009-12-29 13:44:16 +00:00
return _inherited(...);
}
protected func OnCrewDisabled()
{
if (HUDcontroller)
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)
{
if (HUDcontroller)
HUDcontroller->~OnSlotObjectChanged(slot);
return _inherited(slot, ...);
2009-12-29 13:44:16 +00:00
}
protected func OnSlotEmpty(int slot)
{
if (HUDcontroller)
HUDcontroller->~OnSlotObjectChanged(slot);
return _inherited(slot, ...);
}
protected func OnHandSelectionChange(int old, int new, int handslot)
{
if (HUDcontroller)
HUDcontroller->~OnHandSelectionChange(old, new, handslot);
return _inherited(old, new, handslot, ...);
}
// 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(...);
}
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, ...);
}
// when something in the inventory changed
protected func OnInventoryChange()
{
if (HUDcontroller)
HUDcontroller->~ScheduleUpdateInventory();
return _inherited(...);
}
// when a carryheavy object is picked up/dropped
2012-04-13 17:14:55 +00:00
protected func OnCarryHeavyChange(object carried)
{
if (HUDcontroller)
if (GetCursor(GetOwner()) == this)
HUDcontroller->~OnCarryHeavyChange(carried);
return _inherited(carried, ...);
}
public func Collection2()
{
if (HUDcontroller)
HUDcontroller->~ScheduleUpdateInventory();
return _inherited(...);
}
public func Ejection()
{
if (HUDcontroller)
HUDcontroller->~ScheduleUpdateInventory();
return _inherited(...);
}
public func ControlContents()
{
if (HUDcontroller)
HUDcontroller->~ScheduleUpdateInventory();
return _inherited(...);
}