DayZ 1.24
Loading...
Searching...
No Matches
HudDebugWinCharModifiers.c File Reference

Go to the source code of this file.

Classes

class  DebugModifierData
 

Functions

void HudDebugWinCharModifiers (Widget widget_root)
 
void ~HudDebugWinCharModifiers ()
 
override int GetType ()
 
override void SetUpdate (bool state)
 
override void Update ()
 
override void Show ()
 
override void Hide ()
 
void Refresh ()
 
void FitWindow ()
 
void SetModifiers ()
 
void AddModifier (string name, int id, bool active, bool locked)
 
void ClearModifiers ()
 
bool OnClick (Widget w, int x, int y, int button)
 
void ResetModifiers ()
 
void RequestDetailedInfo (int id)
 
void ActivateModifier (int id)
 
void DeactivateModifier (int id)
 
void LockModifier (int id, bool state)
 

Variables

class DebugModifierData m_WgtModifiersContent
 
ref array< ref Widgetm_ModifierWidgets
 
ref map< Widget, ref DebugModifierDatam_ModifierWidgetData
 
PluginDeveloperSync m_PluginDeveloperSync
 
Widget m_WgtDetailedInfo
 
TextWidget m_WgtDetailedInfoText
 
int m_DetailedInfoIndex
 

Function Documentation

◆ ActivateModifier()

void ActivateModifier ( int id)
protected

Definition at line 343 of file HudDebugWinCharModifiers.c.

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 }
ERPCs
Definition ERPCs.c:2
PluginDeveloperSync m_PluginDeveloperSync
PlayerBase GetPlayer()
proto native CGame GetGame()

References GetGame(), GetPlayer(), and m_PluginDeveloperSync.

◆ AddModifier()

void AddModifier ( string name,
int id,
bool active,
bool locked )
protected

Definition at line 171 of file HudDebugWinCharModifiers.c.

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 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
ref map< Widget, ref DebugModifierData > m_ModifierWidgetData
class DebugModifierData m_WgtModifiersContent
ref array< ref Widget > m_ModifierWidgets
int ARGB(int a, int r, int g, int b)
Definition proto.c:322

References ARGB(), GetGame(), m_ModifierWidgetData, m_ModifierWidgets, m_WgtModifiersContent, and name.

◆ ClearModifiers()

void ClearModifiers ( )
protected

Definition at line 212 of file HudDebugWinCharModifiers.c.

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 }

References m_ModifierWidgetData, and m_ModifierWidgets.

Referenced by SetModifiers().

◆ DeactivateModifier()

void DeactivateModifier ( int id)
protected

Definition at line 360 of file HudDebugWinCharModifiers.c.

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 }

References GetGame(), GetPlayer(), and m_PluginDeveloperSync.

◆ FitWindow()

void FitWindow ( )
protected

Definition at line 128 of file HudDebugWinCharModifiers.c.

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 }
Widget m_WgtRoot
Definition HudDebug.c:92

References m_WgtModifiersContent, and m_WgtRoot.

◆ GetType()

override int GetType ( )
protected

Definition at line 55 of file HudDebugWinCharModifiers.c.

56 {
57 return HudDebug.HUD_WIN_CHAR_MODIFIERS;
58 }
void HudDebug()
Definition HudDebug.c:104

References HudDebug().

◆ Hide()

override void Hide ( )
protected

Definition at line 105 of file HudDebugWinCharModifiers.c.

106 {
107 super.Hide();
108
109 //Print("Hide()");
110
111 SetUpdate(false);
112 }
override void SetUpdate(bool state)

References HudDebugWinBase::SetUpdate().

◆ HudDebugWinCharModifiers()

void HudDebugWinCharModifiers ( Widget widget_root)
protected

Definition at line 38 of file HudDebugWinCharModifiers.c.

39 {
41 m_WgtModifiersContent = Widget.Cast(m_WgtRoot.FindAnyWidget("pnl_CharModifiers_Values"));
44 m_PluginDeveloperSync = PluginDeveloperSync.Cast(GetPlugin(PluginDeveloperSync));
45 }
PluginBase GetPlugin(typename plugin_type)

References GetPlugin(), m_ModifierWidgetData, m_ModifierWidgets, m_PluginDeveloperSync, m_WgtModifiersContent, and m_WgtRoot.

Referenced by Init().

◆ LockModifier()

void LockModifier ( int id,
bool state )
protected

Definition at line 377 of file HudDebugWinCharModifiers.c.

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 }

References GetGame(), GetPlayer(), and m_PluginDeveloperSync.

Referenced by OnClick().

◆ OnClick()

bool OnClick ( Widget w,
int x,
int y,
int button )
protected

Definition at line 226 of file HudDebugWinCharModifiers.c.

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 }
void DeactivateModifier(int id)
void ActivateModifier(int id)
void ResetModifiers()
TextWidget m_WgtDetailedInfoText
void RequestDetailedInfo(int id)
int m_DetailedInfoIndex
Widget m_WgtDetailedInfo
void LockModifier(int id, bool state)

References ActivateModifier(), DeactivateModifier(), GetGame(), LockModifier(), m_DetailedInfoIndex, m_ModifierWidgetData, m_PluginDeveloperSync, m_WgtDetailedInfo, m_WgtDetailedInfoText, RequestDetailedInfo(), and ResetModifiers().

◆ Refresh()

void Refresh ( )
protected

Definition at line 114 of file HudDebugWinCharModifiers.c.

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 }
void SetModifiers()

References m_PluginDeveloperSync, m_WgtDetailedInfo, m_WgtDetailedInfoText, and SetModifiers().

◆ RequestDetailedInfo()

void RequestDetailedInfo ( int id)
protected

Definition at line 326 of file HudDebugWinCharModifiers.c.

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 }

References GetGame(), GetPlayer(), and m_PluginDeveloperSync.

Referenced by OnClick().

◆ ResetModifiers()

void ResetModifiers ( )
protected

Definition at line 312 of file HudDebugWinCharModifiers.c.

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 }

References GetGame(), and GetPlayer().

Referenced by OnClick().

◆ SetModifiers()

void SetModifiers ( )
protected

Definition at line 153 of file HudDebugWinCharModifiers.c.

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 }
void ClearModifiers()
void AddModifier(string name, int id, bool active, bool locked)
void FitWindow()

References AddModifier(), ClearModifiers(), HudDebugWinBase::FitWindow(), and m_PluginDeveloperSync.

Referenced by Refresh().

◆ SetUpdate()

override void SetUpdate ( bool state)
protected

Definition at line 63 of file HudDebugWinCharModifiers.c.

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 }

References GetGame(), GetPlayer(), m_PluginDeveloperSync, and HudDebugWinBase::SetRPCSent().

◆ Show()

override void Show ( )
protected

Definition at line 96 of file HudDebugWinCharModifiers.c.

97 {
98 super.Show();
99
100 //Print("Show()");
101
102 SetUpdate(true);
103 }

References HudDebugWinBase::SetUpdate().

◆ ~HudDebugWinCharModifiers()

Definition at line 47 of file HudDebugWinCharModifiers.c.

48 {
49 SetUpdate(false);
50 }

References HudDebugWinBase::SetUpdate().

Variable Documentation

◆ m_DetailedInfoIndex

int m_DetailedInfoIndex
protected

Definition at line 31 of file HudDebugWinCharModifiers.c.

Referenced by OnClick().

◆ m_ModifierWidgetData

ref map<Widget, ref DebugModifierData> m_ModifierWidgetData
protected

◆ m_ModifierWidgets

ref array<ref Widget> m_ModifierWidgets
protected

◆ m_PluginDeveloperSync

◆ m_WgtDetailedInfo

Widget m_WgtDetailedInfo
protected

Definition at line 29 of file HudDebugWinCharModifiers.c.

Referenced by OnClick(), and Refresh().

◆ m_WgtDetailedInfoText

TextWidget m_WgtDetailedInfoText
protected

Definition at line 30 of file HudDebugWinCharModifiers.c.

Referenced by OnClick(), and Refresh().

◆ m_WgtModifiersContent

class DebugModifierData m_WgtModifiersContent