DayZ 1.24
Loading...
Searching...
No Matches
HudDebugWinCharStomach.c
Go to the documentation of this file.
1class HudDebugWinCharStomach extends HudDebugWinBase
2{
5
6 //============================================
7 // Constructor
8 //============================================
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 //============================================
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)
64
65 PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast(GetPlugin(PluginDeveloperSync));
66
67 //if client, send RPC
68 if (GetGame().IsClient())
69 {
71 if (player)
72 {
73 player.RPCSingleParam(ERPCs.DEV_STOMACH_UPDATE, params, true);
74 SetRPCSent();
75 }
76 }
77 //else set directly
78 else
79 {
81 developer_sync.EnableUpdate(state, ERPCs.DEV_STOMACH_UPDATE, player);
82 }
83 }
84
85
86 override void Update()
87 {
88 super.Update();
89
90 //Print("Update()");
91
92 //refresh notifiers
94 }
95
96
98 {
99 PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast(GetPlugin(PluginDeveloperSync));
100
101 //clear window
102 ClearValues();
103
104 for (int i = 0; i < developer_sync.m_PlayerStomachSynced.Count() - 1; i++)
105 {
106 //new Param4<int,int,int,float>(id, food_stage, agents, amount);
108 AddValue(PlayerStomach.GetClassnameFromID(p4.param1), p4.param2, p4.param3, p4.param4);
109 }
110
111 if (developer_sync.m_PlayerStomachSynced.Count())
112 {
113 int last_index = developer_sync.m_PlayerStomachSynced.Count() - 1;
114 Param1<float> p1 = Param1<float>.Cast(developer_sync.m_PlayerStomachSynced.Get(last_index));
115 m_WgtOverall.SetText("Overall volume:" + p1.param1.ToString());
116 }
117 else
118 m_WgtOverall.SetText("");
119
120
121 //fit to screen
122 //FitWindow();
123 }
124
125 void AddValue(string classname, int food_stage, int agents, float amount)
126 {
127 int index = m_WgtValues.AddItem(classname, NULL, 0);
128 string stage = typename.EnumToString(FoodStageType, food_stage) + "(" + food_stage.ToString() + ")";;
129 m_WgtValues.SetItem(index, amount.ToString(), NULL, 1);
130 m_WgtValues.SetItem(index, stage, NULL, 2);
132 string agent_line = "(" + agents.ToString() + ") ";
133
134 for (int i = 0; i < agent_list.Count(); i++)
135 agent_line += "," + agent_list.Get(i);
136
137 m_WgtValues.SetItem(index, agent_line, NULL, 3);
138 }
139
141 {
143 for (int i = 0; i < 32; i++)
144 {
145 int agent = agents & (1 << i);
146 if (agent)
147 list.Insert(PluginTransmissionAgents.GetNameByID(agent));
148 }
149 return list;
150 }
151
153 {
154 m_WgtValues.ClearItems();
155 }
156
158 {
159 FitWindowByContent(m_WgtValues);
160 }
161}
ERPCs
Definition ERPCs.c:2
FoodStageType
Definition FoodStage.c:2
void HudDebug()
Definition HudDebug.c:104
PlayerBase GetPlayer()
void PlayerStomach(PlayerBase player)
PluginBase GetPlugin(typename plugin_type)
void HudDebugWinCharStomach(Widget widget_root)
void AddValue(string classname, int food_stage, int agents, float amount)
void AddValue(string title, string value, string value2)
void FitWindowByContent(TextListboxWidget wgt)
void SetUpdate(bool state)
TextListboxWidget m_WgtValues
array< string > GetAgentsArray(int agents)
override void SetUpdate(bool state)
proto string ToString()
proto native CGame GetGame()