the HUD optimizations now mostly use the old callbacks

David Dormagen 2011-09-18 19:15:31 +02:00
parent c4e4694b61
commit e3a1cdcc3f
6 changed files with 65 additions and 70 deletions

View File

@ -6,14 +6,12 @@
*/
// selectable by HUD
// selectable by HUD and some performance optimizations for the HUD updates
#include Library_HUDAdapter
// standard controls
#include Library_ClonkControl
// manager for aiming
#include Library_AimManager
// performance optimizations for the HUD
#include Library_CrewHUDUser
// un-comment them as soon as the new controls work with context menus etc.^
// Context menu

View File

@ -74,6 +74,17 @@ protected func Construction()
}
private func ScheduleUpdateHealthBar()
{
Schedule(this, "UpdateHUDHealthBar()", 1, 0);
}
private func ScheduleUpdateBackpack()
{
Schedule(this, "UpdateBackpack()", 1, 0);
}
protected func OnWealthChanged(int plr)
{
if(plr != GetOwner()) return;
@ -184,7 +195,7 @@ global func UpdateBackpack(player)
o->UpdateBackpack();
}
private func UpdateBackpack()
func UpdateBackpack()
{
var c = GetCursor(GetOwner());
if(!c) return 1;
@ -257,6 +268,10 @@ protected func OnClonkRecruitment(object clonk, int plr)
// reorder the crew selectors
ReorderCrewSelectors();
// update
ScheduleUpdateBackpack();
ScheduleUpdateHealthBar();
}
protected func OnClonkDeRecruitment(object clonk, int plr)
@ -352,6 +367,10 @@ public func OnCrewDisabled(object clonk)
selector->CrewGone();
ReorderCrewSelectors(clonk);
}
// update
ScheduleUpdateBackpack();
ScheduleUpdateHealthBar();
}
public func OnCrewEnabled(object clonk)
@ -387,6 +406,10 @@ public func OnCrewSelection(object clonk, bool deselect)
RemoveEffect("IntSearchInteractionObjects",clonk,0);
ClearButtons();
}
// update
ScheduleUpdateBackpack();
ScheduleUpdateHealthBar();
}
public func FxIntSearchInteractionObjectsEffect(string newname, object target)
@ -486,6 +509,9 @@ public func OnSlotObjectChanged(int slot)
if(!cursor) return;
var obj = cursor->GetItem(slot);
actionbar[slot]->SetObject(obj, ACTIONTYPE_INVENTORY, slot);
// refresh backpack
ScheduleUpdateBackpack();
}
private func ActionButton(object forClonk, int pos, object interaction, int actiontype, int hotkey)

View File

@ -1,4 +0,0 @@
[DefCore]
id=Library_CrewHUDUser
Version=4,10,0,0
Category=C4D_StaticBack

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 B

View File

@ -1,62 +0,0 @@
/**
CrewHUDUser
Different callbacks.
*/
func Initialize()
{
AddEffect("HUDBarUpdater", this, 1, 0, this);
return _inherited(...);
}
func FxHUDBarUpdaterDamage(target, effect, int damage, int cause)
{
if(effect.last == effect.Time) return damage;
effect.last = effect.Time;
ScheduleUpdateHUDHealthBar();
return damage;
}
private func ScheduleUpdateHUDHealthBar()
{
Schedule(nil, Format("UpdateHUDHealthBar(%d)", GetOwner()), 1, 0);
}
private func ScheduleUpdateBackpack()
{
Schedule(nil, Format("UpdateBackpack(%d)", GetOwner()), 1, 0);
}
func Collection2()
{
ScheduleUpdateBackpack();
return _inherited(...);
}
func Ejection()
{
ScheduleUpdateBackpack();
return _inherited(...);
}
func ControlContents()
{
ScheduleUpdateBackpack();
return _inherited(...);
}
func CrewSelection()
{
ScheduleUpdateBackpack();
ScheduleUpdateHUDHealthBar();
return _inherited(...);
}
func Recruitment()
{
ScheduleUpdateBackpack();
ScheduleUpdateHUDHealthBar();
return _inherited(...);
}

View File

@ -20,6 +20,21 @@ public func HUDAdapter()
return true;
}
func Initialize()
{
AddEffect("HUDBarUpdater", this, 1, 0, this);
return _inherited(...);
}
func FxHUDBarUpdaterDamage(target, effect, int damage, int cause)
{
if(effect.last == effect.Time) return damage;
effect.last = effect.Time;
HUDcontroller->ScheduleUpdateHealthBar();
return damage;
}
// hotkey control
public func ControlHotkey(int hotindex)
{
@ -35,6 +50,10 @@ protected func Recruitment(int plr)
HUDcontroller = FindObject(Find_ID(GUI_Controller), Find_Owner(plr));
if (!HUDcontroller)
HUDcontroller = CreateObject(GUI_Controller, 10, 10, plr);
HUDcontroller->ScheduleUpdateBackpack();
HUDcontroller->ScheduleUpdateHealthBar();
return _inherited(plr, ...);
}
@ -107,3 +126,21 @@ protected func OnSlotEmpty(int slot)
HUDcontroller->OnSlotObjectChanged(slot);
return _inherited(slot, ...);
}
func Collection2()
{
HUDcontroller->ScheduleUpdateBackpack();
return _inherited(...);
}
func Ejection()
{
HUDcontroller->ScheduleUpdateBackpack();
return _inherited(...);
}
func ControlContents()
{
HUDcontroller->ScheduleUpdateBackpack();
return _inherited(...);
}