|
class HudDebugWinCharStomach extends HudDebugWinBase |
|
{ |
|
TextListboxWidget m_WgtValues; |
|
TextWidget m_WgtOverall; |
|
|
|
|
|
|
|
|
|
void HudDebugWinCharStomach(Widget widget_root) |
|
{ |
|
m_WgtValues = TextListboxWidget.Cast( widget_root.FindAnyWidget("txl_StomachContents") ); |
|
m_WgtOverall = TextWidget.Cast( widget_root.FindAnyWidget("InfoOverall") ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ~HudDebugWinCharStomach() |
|
{ |
|
SetUpdate( false ); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
override int GetType() |
|
{ |
|
return HudDebug.HUD_WIN_CHAR_STOMACH; |
|
} |
|
|
|
|
|
|
|
|
|
override void Show() |
|
{ |
|
super.Show(); |
|
|
|
|
|
|
|
SetUpdate( true ); |
|
} |
|
|
|
|
|
|
|
|
|
override void Hide() |
|
{ |
|
super.Hide(); |
|
|
|
|
|
|
|
SetUpdate( false ); |
|
} |
|
|
|
|
|
|
|
|
|
override void SetUpdate( bool state ) |
|
{ |
|
|
|
PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() ); |
|
|
|
PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast( GetPlugin( PluginDeveloperSync ) ); |
|
|
|
|
|
if ( GetGame().IsClient() ) |
|
{ |
|
ref Param1<bool> params = new Param1<bool>( state ); |
|
if ( player ) |
|
{ |
|
player.RPCSingleParam( ERPCs.DEV_STOMACH_UPDATE, params, true ); |
|
SetRPCSent(); |
|
} |
|
} |
|
|
|
else |
|
{ |
|
if ( developer_sync ) |
|
{ |
|
developer_sync.EnableUpdate( state, ERPCs.DEV_STOMACH_UPDATE, player ); |
|
} |
|
} |
|
} |
|
|
|
|
|
override void Update() |
|
{ |
|
super.Update(); |
|
|
|
|
|
|
|
|
|
SetContentValues(); |
|
} |
|
|
|
|
|
void SetContentValues() |
|
{ |
|
PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast( GetPlugin( PluginDeveloperSync ) ); |
|
|
|
|
|
ClearValues(); |
|
|
|
for ( int i = 0; i < developer_sync.m_PlayerStomachSynced.Count() - 1; i++ ) |
|
{ |
|
|
|
Param4<int,int,int,float> p4 = Param4<int,int,int,float>.Cast(developer_sync.m_PlayerStomachSynced.Get(i)); |
|
AddValue( PlayerStomach.GetClassnameFromID(p4.param1), p4.param2, p4.param3, p4.param4); |
|
} |
|
|
|
if( developer_sync.m_PlayerStomachSynced.Count() ) |
|
{ |
|
int last_index = developer_sync.m_PlayerStomachSynced.Count() - 1; |
|
Param1<float> p1 = Param1<float>.Cast(developer_sync.m_PlayerStomachSynced.Get(last_index)); |
|
m_WgtOverall.SetText("Overall volume:" + p1.param1.ToString()); |
|
} |
|
else |
|
{ |
|
m_WgtOverall.SetText(""); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
void AddValue( string classname, int food_stage, int agents, float amount) |
|
{ |
|
int index = m_WgtValues.AddItem( classname, NULL, 0 ); |
|
string stage = typename.EnumToString(FoodStageType, food_stage) + "(" + food_stage.ToString()+")";; |
|
m_WgtValues.SetItem( index, amount.ToString(), NULL, 1 ); |
|
m_WgtValues.SetItem( index,stage , NULL, 2 ); |
|
array<string> agent_list = GetAgentsArray(agents); |
|
string agent_line = "("+agents.ToString()+") "; |
|
|
|
for(int i = 0; i < agent_list.Count();i++) |
|
{ |
|
agent_line += "," +agent_list.Get(i); |
|
} |
|
|
|
m_WgtValues.SetItem( index, agent_line , NULL, 3); |
|
} |
|
|
|
array<string> GetAgentsArray(int agents) |
|
{ |
|
array<string> list = new array<string>; |
|
for(int i = 0; i < 32; i++) |
|
{ |
|
int agent = agents & (1 << i); |
|
if(agent) |
|
{ |
|
list.Insert(PluginTransmissionAgents.GetNameByID(agent)); |
|
} |
|
} |
|
return list; |
|
} |
|
|
|
void ClearValues() |
|
{ |
|
m_WgtValues.ClearItems(); |
|
} |
|
|
|
void FitWindow() |
|
{ |
|
FitWindowByContent( m_WgtValues ); |
|
} |
|
} |
|
|