DayZ 1.24
Loading...
Searching...
No Matches
HudDebugWinCharAgents.c
Go to the documentation of this file.
2{
3 string m_Name;
4 int m_ID;
5
6 void DebugAgentData(string name, int id)
7 {
8 m_Name = name;
9 m_ID = id;
10 }
11
12 string GetName()
13 {
14 return m_Name;
15 }
16
17 int GetID()
18 {
19 return m_ID;
20 }
21}
22
23
25{
29 //============================================
30 // HudDebugWinCharAgents
31 //============================================
33 {
35 //m_WgtAgents = TextListboxWidget.Cast( m_WgtRoot.FindAnyWidget( "txl_CharAgents_Values" ) );
36 m_WgtAgents = m_WgtRoot.FindAnyWidget("AgentList");
37
38 //FitWindowByContent( m_WgtAgents );
39 }
40
42 {
43 SetUpdate(false);
44 }
45
46 //============================================
47 // GetWinType
48 //============================================
49 override int GetType()
50 {
51 return HudDebug.HUD_WIN_CHAR_AGENTS;
52 }
53
54 //============================================
55 // Update
56 //============================================
57 override void SetUpdate(bool state)
58 {
59 //Disable update on server (PluginDeveloperSync)
61 PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast(GetPlugin(PluginDeveloperSync));
62
63 //if client, send RPC
64 if (GetGame().IsClient())
65 {
67 if (player)
68 {
69 player.RPCSingleParam(ERPCs.DEV_AGENTS_UPDATE, params, true);
70 SetRPCSent();
71 }
72 }
73 //else set directly
74 else
75 {
77 developer_sync.EnableUpdate(state, ERPCs.DEV_AGENTS_UPDATE, player);
78 }
79 }
80
81 override void Update()
82 {
83 super.Update();
84
85 //Print("Update()");
86
87 //refresh notifiers
88 SetAgents();
89 }
90
91 //============================================
92 // Show / Hide
93 //============================================
94 override void Show()
95 {
96 super.Show();
97
98 //Print("Show()");
99
100 SetUpdate(true);
101 }
102
103 override void Hide()
104 {
105 super.Hide();
106
107 //Print("Hide()");
108
109 SetUpdate(false);
110 }
111
113 {
114 PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast(GetPlugin(PluginDeveloperSync));
115
116 //clear window
117 ClearAgents();
118
119 //set agents
120 if (developer_sync.m_PlayerAgentsSynced.Count() > 0)
121 {
122 for (int i = 0; i < developer_sync.m_PlayerAgentsSynced.Count(); i++)
123 AddAgent(developer_sync.m_PlayerAgentsSynced.Get(i).GetName(), developer_sync.m_PlayerAgentsSynced.Get(i).GetValue(), developer_sync.m_PlayerAgentsSynced.Get(i).GetID());
124 }
125
126 //fit to screen
127 //FitWindow();
128 }
129
130 /*
131 void AddAgent( string title, string value )
132 {
133 int index = m_WgtAgents.AddItem( title, NULL, 0 );
134 m_WgtAgents.SetItem( index, value, NULL, 1 );
135 }
136 */
137 bool OnClick(Widget w, int x, int y, int button)
138 {
139 //Button activate
141 if (w.GetName() == "ButtonAgentActivate")
142 {
143 data = m_AgentWidgetData.Get(w);
144 DebugGrowAgentsRequest(data.GetID(), true);
145 //Print("activate" + data.GetID().ToString());
146 return true;
147 }
148 //Button deactivate
149 else if (w.GetName() == "ButtonAgentDeactivate")
150 {
151 data = m_AgentWidgetData.Get(w);
152 DebugGrowAgentsRequest(data.GetID(), false);
153 //Print("deactivate" + data.GetID().ToString());
154 return true;
155 }
156 else if (w.GetName() == "ResetAgents")
157 {
159 return true;
160 }
161
162
163 return false;
164 }
165
167 {
168 if (!should_grow) //id is minus value to mark killing instead of growing
169 agent_id *= -1;
170
172 Man man = GetGame().GetPlayer();
173 man.RPCSingleParam(ERPCs.DEV_AGENT_GROW, p1, true, man.GetIdentity());
174 }
175
177 {
178 ref Param1<bool> p1 = new Param1<bool>(false);
179 Man man = GetGame().GetPlayer();
180 man.RPCSingleParam(ERPCs.DEV_RPC_AGENT_RESET, p1, true, man.GetIdentity());
181 }
182
183 void AddAgent(string title, string value, int id)
184 {
185 Widget widget = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_hud_debug_agent.layout", m_WgtAgents);
186 ButtonWidget btn = ButtonWidget.Cast(widget.FindAnyWidget("TextAgentName"));
187
188
189 DebugAgentData data = new DebugAgentData("", id);
190 m_AgentWidgetData.Insert(btn, data);
191
192 Widget activate_button = widget.FindAnyWidget("ButtonAgentActivate");
194
195 TextWidget count_widget = TextWidget.Cast(widget.FindAnyWidget("TextWidgetAgentCount"));
197 count_widget.SetText(value);
198
199 //Deactivate button
200 Widget deactivate_button = widget.FindAnyWidget("ButtonAgentDeactivate");
202
203 btn.SetText(title);
204 m_AgentWidgets.Insert(widget);
205
209 }
210
212 {
213 m_AgentWidgetData.Clear();
214 for (int i = 0; i < m_AgentWidgets.Count(); i++)
215 delete m_AgentWidgets.Get(i);
216
217 m_AgentWidgets.Clear();
218 }
219
224}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
ERPCs
Definition ERPCs.c:2
void HudDebug()
Definition HudDebug.c:104
Widget m_WgtRoot
Definition HudDebug.c:92
ref map< Widget, ref DebugAgentData > m_AgentWidgetData
void HudDebugWinCharAgents(Widget widget_root)
void ClearAgents()
void ~HudDebugWinCharAgents()
void SetAgents()
ref array< ref Widget > m_AgentWidgets
void AddAgent(string title, string value, int id)
void DebugGrowAgentsRequest(int agent_id, bool should_grow)
class DebugAgentData m_WgtAgents
void DebugRemoveAgentsRequest()
Icon x
Icon y
PlayerBase GetPlayer()
PluginBase GetPlugin(typename plugin_type)
void DebugAgentData(string name, int id)
bool OnClick(Widget w, int x, int y, int button)
void FitWindowByContent(TextListboxWidget wgt)
void SetUpdate(bool state)
proto native CGame GetGame()