DayZ 1.24
Loading...
Searching...
No Matches
HudDebugWinCharModifiers.c
Go to the documentation of this file.
2{
3 string m_Name;
4 int m_ID;
5
6 void DebugModifierData(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
24{
28 protected PluginDeveloperSync m_PluginDeveloperSync;
31 protected int m_DetailedInfoIndex;
32
33 //m_RPCSent
34
35 //============================================
36 // HudDebugWinCharModifiers
37 //============================================
39 {
41 m_WgtModifiersContent = Widget.Cast(m_WgtRoot.FindAnyWidget("pnl_CharModifiers_Values"));
44 m_PluginDeveloperSync = PluginDeveloperSync.Cast(GetPlugin(PluginDeveloperSync));
45 }
46
48 {
49 SetUpdate(false);
50 }
51
52 //============================================
53 // GetWinType
54 //============================================
55 override int GetType()
56 {
57 return HudDebug.HUD_WIN_CHAR_MODIFIERS;
58 }
59
60 //============================================
61 // Update
62 //============================================
63 override void SetUpdate(bool state)
64 {
65 //Disable update on server (PluginDeveloperSync)
67
68 //if client, send RPC
69 if (GetGame().IsClient())
70 {
72 if (player)
73 {
74 player.RPCSingleParam(ERPCs.DEV_MODS_UPDATE, params, true);
75 SetRPCSent();
76 }
77 }
78 //else set directly
79 else
80 {
82 m_PluginDeveloperSync.EnableUpdate(state, ERPCs.DEV_MODS_UPDATE, player);
83 }
84 }
85
86 override void Update()
87 {
88 super.Update();
89
90 Refresh();
91 }
92
93 //============================================
94 // Show / Hide
95 //============================================
96 override void Show()
97 {
98 super.Show();
99
100 //Print("Show()");
101
102 SetUpdate(true);
103 }
104
105 override void Hide()
106 {
107 super.Hide();
108
109 //Print("Hide()");
110
111 SetUpdate(false);
112 }
113
114 void Refresh()
115 {
116 SetModifiers();
117 if (m_WgtDetailedInfo && m_WgtDetailedInfo.IsVisible())
118 {
120 m_WgtDetailedInfoText = TextWidget.Cast(m_WgtDetailedInfo.FindAnyWidget("TextWidget"));
121 m_WgtDetailedInfoText.SetText(m_PluginDeveloperSync.m_PlayerModsDetailedSynced);
122 }
123 }
124
125 //============================================
126 // FitWindow
127 //============================================
129 {
130 float title_size = 20;
131 float spacing = 20;
132
133 //get wgt content size values
134 float wgt_content_size_x;
135 float wgt_content_size_y;
137
138 //get wgt root size values
139 float wgt_root_size_x;
140 float wgt_root_size_y;
142
143 //calculate new Y size
145
146 //set size
148 }
149
150 //============================================
151 // Display Modifiers
152 //============================================
154 {
155 //clear window
157
158 if (m_PluginDeveloperSync.m_PlayerModsSynced.Count() > 0)
159 {
160 //set active mods
161 for (int i = 0; i < m_PluginDeveloperSync.m_PlayerModsSynced.Count(); ++i)
162 {
164 AddModifier(synced_value.GetName(), synced_value.GetID(), synced_value.GetActive(), synced_value.GetLocked());
165 }
166 }
167
168 FitWindow();
169 }
170
171 void AddModifier(string name, int id, bool active, bool locked)
172 {
173 //create widget
174 Widget widget = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_hud_debug_modifier.layout", m_WgtModifiersContent);
175
176 //add to widget array (for clearing purposes)
178
179 //set widget name
180 ButtonWidget mod_name_text = ButtonWidget.Cast(widget.FindAnyWidget("TextModifierName"));
181 mod_name_text.SetText(name);
182 if (active)
183 mod_name_text.SetTextColor(ARGB(255, 0, 255, 0));
184 else
185 mod_name_text.SetTextColor(ARGB(255, 255, 0, 0));
186
187 //set set data for interactive parts (modifier ID should be enough)
189
190 Widget modifier_button = widget.FindAnyWidget("TextModifierName");
192 //Activate button
193 Widget activate_button = widget.FindAnyWidget("ButtonModifierActivate");
195
196 //Deactivate button
197 Widget deactivate_button = widget.FindAnyWidget("ButtonModifierDeactivate");
199
200 //Lock checkbox
201 Widget checkbox_widget = widget.FindAnyWidget("CheckBoxLock");
203 //set lock based on checkbox value
205 checkbox.SetChecked(locked);
206
210 }
211
213 {
214 //clear widget data
215 m_ModifierWidgetData.Clear();
216
217 //destroy all modifier widgets
218 for (int i = 0; i < m_ModifierWidgets.Count(); ++i)
219 delete m_ModifierWidgets.Get(i);
220 m_ModifierWidgets.Clear();
221 }
222
223 //============================================
224 // OnClick
225 //============================================
226 bool OnClick(Widget w, int x, int y, int button)
227 {
228 if (w)
229 {
230 if (w.GetName() == "TextModifierName")
231 {
232 //Print("clicked");
234
235 //Print( bc_data.GetID() );
236
237 if (bc_data.GetID() == m_DetailedInfoIndex) //repeated request --> hide
238 {
239 if (m_WgtDetailedInfo && m_WgtDetailedInfo.IsVisible())
240 m_WgtDetailedInfo.Show(false);
242 }
243 else
244 {
246 m_WgtDetailedInfo = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_hud_debug_modifier_detailed.layout");
247 if (!m_WgtDetailedInfo.IsVisible())
248 m_WgtDetailedInfo.Show(true);
250 }
252 m_WgtDetailedInfoText.SetText("");
253 m_PluginDeveloperSync.m_PlayerModsDetailedSynced = "";
255 return true;
256 }
257 //Button activate
258 if (w.GetName() == "ButtonModifierActivate")
259 {
261
262 //activate
263 ActivateModifier(ba_data.GetID());
264
265 //force update
266 m_PluginDeveloperSync.Update();
267
268 return true;
269 }
270 //Button deactivate
271 else if (w.GetName() == "ButtonModifierDeactivate")
272 {
274
275 //deactivate
277
278 //force update
279 m_PluginDeveloperSync.Update();
280
281 return true;
282 }
283 //Lock checkbox
284 else if (w.GetName() == "CheckBoxLock")
285 {
288
289 //set lock
290 LockModifier(lcb_data.GetID(), checkbox.IsChecked());
291
292 //force update
293 m_PluginDeveloperSync.Update();
294
295 return true;
296 }
297 else if (w.GetName() == "ResetModifiers")
298 {
299
301 return true;
302 }
303 }
304
305 return false;
306 }
307
308 //============================================
309 // Actions
310 //============================================
311
313 {
315
316 //if client, send RPC
317
318 ref Param1<bool> params = new Param1<bool>(false);
319 if (player)
320 player.RPCSingleParam(ERPCs.DEV_RPC_MODS_RESET, params, true);
321
322
323 }
324
325
327 {
328 //Disable update on server (PluginDeveloperSync)
330
331 //if client, send RPC
332 if (GetGame().IsClient())
333 {
335 if (player)
336 player.RPCSingleParam(ERPCs.DEV_RPC_MODS_DETAILED, params, true);
337 }
338 //else set directly
339 else
340 m_PluginDeveloperSync.RequestDetailedInfo(id, player);
341 }
342
343 void ActivateModifier(int id)
344 {
345 //Disable update on server (PluginDeveloperSync)
347
348 //if client, send RPC
349 if (GetGame().IsClient())
350 {
352 if (player)
353 player.RPCSingleParam(ERPCs.DEV_RPC_MODS_ACTIVATE, params, true);
354 }
355 //else set directly
356 else
357 m_PluginDeveloperSync.ActivateModifier(id);
358 }
359
361 {
362 //Disable update on server (PluginDeveloperSync)
364
365 //if client, send RPC
366 if (GetGame().IsClient())
367 {
369 if (player)
370 player.RPCSingleParam(ERPCs.DEV_RPC_MODS_DEACTIVATE, params, true);
371 }
372 //else set directly
373 else
374 m_PluginDeveloperSync.DeactivateModifier(id);
375 }
376
377 void LockModifier(int id, bool state)
378 {
379 //Disable update on server (PluginDeveloperSync)
381
382 //if client, send RPC
383 if (GetGame().IsClient())
384 {
386 if (player)
387 player.RPCSingleParam(ERPCs.DEV_RPC_MODS_LOCK, params, true);
388 }
389 //else set directly
390 else
391 m_PluginDeveloperSync.LockModifier(id, state);
392 }
393}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
ERPCs
Definition ERPCs.c:2
void HudDebug()
Definition HudDebug.c:104
Widget m_WgtRoot
Definition HudDebug.c:92
void HudDebugWinCharModifiers(Widget widget_root)
void ClearModifiers()
ref map< Widget, ref DebugModifierData > m_ModifierWidgetData
void ResetModifiers()
TextWidget m_WgtDetailedInfoText
class DebugModifierData m_WgtModifiersContent
void ~HudDebugWinCharModifiers()
PluginDeveloperSync m_PluginDeveloperSync
void RequestDetailedInfo(int id)
void SetModifiers()
int m_DetailedInfoIndex
ref array< ref Widget > m_ModifierWidgets
Widget m_WgtDetailedInfo
void LockModifier(int id, bool state)
Icon x
Icon y
PlayerBase GetPlayer()
void DeactivateModifier(int modifier_id, bool triggerEvent=true)
void ActivateModifier(int modifier_id, bool triggerEvent=EActivationType.TRIGGER_EVENT_ON_ACTIVATION)
void AddModifier(ModifierBase modifier)
PluginBase GetPlugin(typename plugin_type)
void Refresh()
void DebugModifierData(string name, int id)
bool OnClick(Widget w, int x, int y, int button)
PluginDeveloperSync m_PluginDeveloperSync
void SetUpdate(bool state)
proto native CGame GetGame()
int ARGB(int a, int r, int g, int b)
Definition proto.c:322