Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
huddebugwincharstomach.c
Go to the documentation of this file.
1 class HudDebugWinCharStomach extends HudDebugWinBase
2 {
3  TextListboxWidget m_WgtValues;
4  TextWidget m_WgtOverall;
5 
6  //============================================
7  // Constructor
8  //============================================
9  void HudDebugWinCharStomach(Widget widget_root)
10  {
11  m_WgtValues = TextListboxWidget.Cast( widget_root.FindAnyWidget("txl_StomachContents") );
12  m_WgtOverall = TextWidget.Cast( widget_root.FindAnyWidget("InfoOverall") );
13  //FitWindow();
14  }
15 
16  //============================================
17  // Destructor
18  //============================================
19  void ~HudDebugWinCharStomach()
20  {
21  SetUpdate( false );
22  }
23 
24 
25  //============================================
26  // GetWinType
27  //============================================
28  override int GetType()
29  {
30  return HudDebug.HUD_WIN_CHAR_STOMACH;
31  }
32 
33  //============================================
34  // Show
35  //============================================
36  override void Show()
37  {
38  super.Show();
39 
40  //Print("Show()");
41 
42  SetUpdate( true );
43  }
44 
45  //============================================
46  // Hide
47  //============================================
48  override void Hide()
49  {
50  super.Hide();
51 
52  //Print("Hide()");
53 
54  SetUpdate( false );
55  }
56 
57  //============================================
58  // SetUpdate
59  //============================================
60  override void SetUpdate( bool state )
61  {
62  //Disable update on server (PluginDeveloperSync)
63  PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
64 
65  PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast( GetPlugin( PluginDeveloperSync ) );
66 
67  //if client, send RPC
68  if ( GetGame().IsClient() )
69  {
70  ref Param1<bool> params = new Param1<bool>( state );
71  if ( player )
72  {
73  player.RPCSingleParam( ERPCs.DEV_STOMACH_UPDATE, params, true );
74  SetRPCSent();
75  }
76  }
77  //else set directly
78  else
79  {
80  if ( developer_sync )
81  {
82  developer_sync.EnableUpdate( state, ERPCs.DEV_STOMACH_UPDATE, player );
83  }
84  }
85  }
86 
87 
88  override void Update()
89  {
90  super.Update();
91 
92  //Print("Update()");
93 
94  //refresh notifiers
95  SetContentValues();
96  }
97 
98 
99  void SetContentValues()
100  {
101  PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast( GetPlugin( PluginDeveloperSync ) );
102 
103  //clear window
104  ClearValues();
105 
106  for ( int i = 0; i < developer_sync.m_PlayerStomachSynced.Count() - 1; i++ )
107  {
108  //new Param4<int,int,int,float>(id, food_stage, agents, amount);
109  Param4<int,int,int,float> p4 = Param4<int,int,int,float>.Cast(developer_sync.m_PlayerStomachSynced.Get(i));
110  AddValue( PlayerStomach.GetClassnameFromID(p4.param1), p4.param2, p4.param3, p4.param4);
111  }
112 
113  if( developer_sync.m_PlayerStomachSynced.Count() )
114  {
115  int last_index = developer_sync.m_PlayerStomachSynced.Count() - 1;
116  Param1<float> p1 = Param1<float>.Cast(developer_sync.m_PlayerStomachSynced.Get(last_index));
117  m_WgtOverall.SetText("Overall volume:" + p1.param1.ToString());
118  }
119  else
120  {
121  m_WgtOverall.SetText("");
122  }
123 
124 
125 
126  //fit to screen
127  //FitWindow();
128  }
129 
130  void AddValue( string classname, int food_stage, int agents, float amount)
131  {
132  int index = m_WgtValues.AddItem( classname, NULL, 0 );
133  string stage = typename.EnumToString(FoodStageType, food_stage) + "(" + food_stage.ToString()+")";;
134  m_WgtValues.SetItem( index, amount.ToString(), NULL, 1 );
135  m_WgtValues.SetItem( index,stage , NULL, 2 );
136  array<string> agent_list = GetAgentsArray(agents);
137  string agent_line = "("+agents.ToString()+") ";
138 
139  for(int i = 0; i < agent_list.Count();i++)
140  {
141  agent_line += "," +agent_list.Get(i);
142  }
143 
144  m_WgtValues.SetItem( index, agent_line , NULL, 3);
145  }
146 
147  array<string> GetAgentsArray(int agents)
148  {
149  array<string> list = new array<string>;
150  for(int i = 0; i < 32; i++)
151  {
152  int agent = agents & (1 << i);
153  if(agent)
154  {
155  list.Insert(PluginTransmissionAgents.GetNameByID(agent));
156  }
157  }
158  return list;
159  }
160 
161  void ClearValues()
162  {
163  m_WgtValues.ClearItems();
164  }
165 
166  void FitWindow()
167  {
168  FitWindowByContent( m_WgtValues );
169  }
170 }
GetGame
proto native CGame GetGame()
FitWindow
void FitWindow()
Definition: huddebugwincharagents.c:228
Show
proto native void Show(bool show, bool immedUpdate=true)
SetUpdate
override void SetUpdate(bool state)
Definition: huddebugwincharagents.c:57
HudDebugWinBase
Definition: huddebugwinbase.c:1
PlayerStomach
void PlayerStomach(PlayerBase player)
Definition: playerstomach.c:127
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
PlayerBase
Definition: playerbaseclient.c:1
TextWidget
Definition: enwidgets.c:219
FoodStageType
FoodStageType
Definition: foodstage.c:1
array< string >
Update
proto native volatile void Update()
Definition: playersoundmanager.c:125
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
HudDebug
void HudDebug()
Definition: huddebug.c:104
ERPCs
ERPCs
Definition: erpcs.c:1
Widget
Definition: enwidgets.c:189
Hide
void Hide()
Definition: dayzgame.c:165
GetType
override int GetType()
Definition: huddebugwincharagents.c:49