Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
huddebugwincharmodifiers.c
Go to the documentation of this file.
1
class
DebugModifierData
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
23
class
HudDebugWinCharModifiers
extends
HudDebugWinBase
24
{
25
protected
Widget
m_WgtModifiersContent
;
26
protected
ref
map<int, Widget>
m_ModifierWidgets
;
27
protected
ref
map<Widget, ref DebugModifierData>
m_ModifierWidgetData
;
28
protected
PluginDeveloperSync
m_PluginDeveloperSync
;
29
protected
Widget
m_WgtDetailedInfo
;
30
protected
TextWidget
m_WgtDetailedInfoText
;
31
protected
int
m_DetailedInfoIndex
;
32
33
//============================================
34
// HudDebugWinCharModifiers
35
//============================================
36
void
HudDebugWinCharModifiers
(
Widget
widget_root )
37
{
38
m_WgtRoot
= widget_root;
39
m_WgtModifiersContent
=
Widget
.Cast(
m_WgtRoot
.FindAnyWidget(
"pnl_CharModifiers_Values"
) );
40
m_ModifierWidgets
=
new
map<int, Widget>
();
41
m_ModifierWidgetData
=
new
map<Widget, ref DebugModifierData>
;
42
m_PluginDeveloperSync
= PluginDeveloperSync.Cast(
GetPlugin
( PluginDeveloperSync ) );
43
}
44
45
void
~HudDebugWinCharModifiers
()
46
{
47
SetUpdate
(
false
);
48
}
49
50
//============================================
51
// GetWinType
52
//============================================
53
override
int
GetType
()
54
{
55
return
HudDebug
.HUD_WIN_CHAR_MODIFIERS;
56
}
57
58
//============================================
59
// Update
60
//============================================
61
override
void
SetUpdate
(
bool
state )
62
{
63
//Disable update on server (PluginDeveloperSync)
64
PlayerBase
player =
PlayerBase
.Cast(
g_Game
.GetPlayer() );
65
66
//if client, send RPC
67
if
(
g_Game
.IsClient() )
68
{
69
ref Param1<bool> params =
new
Param1<bool>( state );
70
if
( player )
71
{
72
player.RPCSingleParam(
ERPCs
.DEV_MODS_UPDATE, params,
true
);
73
SetRPCSent
();
74
}
75
}
76
//else set directly
77
else
78
{
79
if
(
m_PluginDeveloperSync
)
80
{
81
m_PluginDeveloperSync
.EnableUpdate( state,
ERPCs
.DEV_MODS_UPDATE, player );
82
}
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
foreach
(
Widget
widget :
m_ModifierWidgets
)
114
{
115
delete
widget;
116
}
117
118
m_ModifierWidgets
.Clear();
119
}
120
121
void
Refresh
()
122
{
123
SetModifiers
();
124
if
(
m_WgtDetailedInfo
&&
m_WgtDetailedInfo
.IsVisible())
125
{
126
if
(!
m_WgtDetailedInfoText
)
127
m_WgtDetailedInfoText
=
TextWidget
.Cast(
m_WgtDetailedInfo
.FindAnyWidget(
"TextWidget"
));
128
m_WgtDetailedInfoText
.SetText(
m_PluginDeveloperSync
.m_PlayerModsDetailedSynced);
129
}
130
}
131
132
//============================================
133
// FitWindow
134
//============================================
135
void
FitWindow
()
136
{
137
float
title_size = 20;
138
float
spacing = 20;
139
140
//get wgt content size values
141
float
wgt_content_size_x;
142
float
wgt_content_size_y;
143
m_WgtModifiersContent
.GetSize( wgt_content_size_x, wgt_content_size_y );
144
145
//get wgt root size values
146
float
wgt_root_size_x;
147
float
wgt_root_size_y;
148
m_WgtRoot
.GetSize( wgt_root_size_x, wgt_root_size_y );
149
150
//calculate new Y size
151
float
new_size_y = title_size + wgt_content_size_y + spacing;
152
153
//set size
154
m_WgtRoot
.SetSize( wgt_root_size_x, new_size_y );
155
}
156
157
//============================================
158
// Display Modifiers
159
//============================================
160
void
SetModifiers
()
161
{
162
//clear window
163
ClearModifiers
();
164
165
if
(
m_PluginDeveloperSync
.m_PlayerModsSynced.Count() > 0)
166
{
167
//set active mods
168
foreach
(
SyncedValueModifier
modifier :
m_PluginDeveloperSync
.m_PlayerModsSynced)
169
{
170
AddModifier
(
171
modifier.
GetName
(),
172
modifier.
GetID
(),
173
modifier.
GetActive
(),
174
modifier.
GetLocked
(),
175
);
176
}
177
}
178
179
FitWindow
();
180
}
181
182
void
AddModifier
(
string
name
,
int
id
,
bool
active,
bool
locked )
183
{
184
Widget
widget =
m_ModifierWidgets
.Get(
id
);
185
if
(!widget)
186
{
187
//create widget
188
widget =
g_Game
.GetWorkspace().CreateWidgets(
"gui/layouts/debug/day_z_hud_debug_modifier.layout"
,
m_WgtModifiersContent
);
189
190
//add to widget array (for clearing purposes)
191
m_ModifierWidgets
.Insert(
id
, widget );
192
}
193
194
//set widget name
195
ButtonWidget mod_name_text = ButtonWidget.Cast( widget.FindAnyWidget(
"TextModifierName"
) );
196
mod_name_text.SetText(
name
);
197
if
( active )
198
{
199
mod_name_text.SetTextColor(
ARGB
( 255, 0, 255, 0 ) );
200
}
201
else
202
{
203
mod_name_text.SetTextColor(
ARGB
( 255, 255, 0, 0 ) );
204
}
205
206
//set set data for interactive parts (modifier ID should be enough)
207
DebugModifierData
data =
new
DebugModifierData
(
name
,
id
);
208
209
Widget
modifier_button = widget.FindAnyWidget(
"TextModifierName"
);
210
m_ModifierWidgetData
.Insert( modifier_button, data );
211
//Activate button
212
Widget
activate_button = widget.FindAnyWidget(
"ButtonModifierActivate"
);
213
m_ModifierWidgetData
.Insert( activate_button, data );
214
215
//Deactivate button
216
Widget
deactivate_button = widget.FindAnyWidget(
"ButtonModifierDeactivate"
);
217
m_ModifierWidgetData
.Insert( deactivate_button, data );
218
219
//Lock checkbox
220
Widget
checkbox_widget = widget.FindAnyWidget(
"CheckBoxLock"
);
221
m_ModifierWidgetData
.Insert( checkbox_widget, data );
222
//set lock based on checkbox value
223
CheckBoxWidget checkbox = CheckBoxWidget.Cast( checkbox_widget );
224
checkbox.SetChecked( locked );
225
226
AutoHeightSpacer
WgtModifiersContent_panel_script;
227
m_WgtModifiersContent
.GetScript( WgtModifiersContent_panel_script );
228
WgtModifiersContent_panel_script.
Update
();
229
}
230
231
void
ClearModifiers
()
232
{
233
//clear widget data
234
m_ModifierWidgetData
.Clear();
235
}
236
237
//============================================
238
// OnClick
239
//============================================
240
bool
OnClick
(
Widget
w,
int
x
,
int
y
,
int
button )
241
{
242
if
( w )
243
{
244
if
( w.GetName() ==
"TextModifierName"
)
245
{
246
//Print("clicked");
247
DebugModifierData
bc_data =
m_ModifierWidgetData
.Get( w );
248
249
//Print( bc_data.GetID() );
250
251
if
(bc_data.
GetID
() ==
m_DetailedInfoIndex
)
//repeated request --> hide
252
{
253
if
(
m_WgtDetailedInfo
&&
m_WgtDetailedInfo
.IsVisible())
254
{
255
m_WgtDetailedInfo
.Show(
false
);
256
}
257
m_DetailedInfoIndex
= 0;
258
}
259
else
260
{
261
if
(!
m_WgtDetailedInfo
)
262
m_WgtDetailedInfo
=
g_Game
.GetWorkspace().CreateWidgets(
"gui/layouts/debug/day_z_hud_debug_modifier_detailed.layout"
);
263
if
(!
m_WgtDetailedInfo
.IsVisible())
264
{
265
m_WgtDetailedInfo
.Show(
true
);
266
}
267
m_DetailedInfoIndex
= bc_data.
GetID
();
268
}
269
if
(
m_WgtDetailedInfoText
)
270
m_WgtDetailedInfoText
.SetText(
""
);
271
m_PluginDeveloperSync
.m_PlayerModsDetailedSynced =
""
;
272
RequestDetailedInfo
( bc_data.
GetID
());
273
return
true
;
274
}
275
//Button activate
276
if
( w.GetName() ==
"ButtonModifierActivate"
)
277
{
278
DebugModifierData
ba_data =
m_ModifierWidgetData
.Get( w );
279
280
//activate
281
ActivateModifier
( ba_data.
GetID
() );
282
283
//force update
284
m_PluginDeveloperSync
.Update();
285
286
return
true
;
287
}
288
//Button deactivate
289
else
if
( w.GetName() ==
"ButtonModifierDeactivate"
)
290
{
291
DebugModifierData
bd_data =
m_ModifierWidgetData
.Get( w );
292
293
//deactivate
294
DeactivateModifier
( bd_data.
GetID
() );
295
296
//force update
297
m_PluginDeveloperSync
.Update();
298
299
return
true
;
300
}
301
//Lock checkbox
302
else
if
( w.GetName() ==
"CheckBoxLock"
)
303
{
304
DebugModifierData
lcb_data =
m_ModifierWidgetData
.Get( w );
305
CheckBoxWidget checkbox = CheckBoxWidget.Cast( w );
306
307
//set lock
308
LockModifier
( lcb_data.
GetID
(), checkbox.IsChecked() );
309
310
//force update
311
m_PluginDeveloperSync
.Update();
312
313
return
true
;
314
}
315
else
if
( w.GetName() ==
"ResetModifiers"
)
316
{
317
318
ResetModifiers
();
319
return
true
;
320
}
321
}
322
323
return
false
;
324
}
325
326
//============================================
327
// Actions
328
//============================================
329
330
void
ResetModifiers
()
331
{
332
PlayerBase
player =
PlayerBase
.Cast(
g_Game
.GetPlayer() );
333
334
//if client, send RPC
335
336
ref Param1<bool> params =
new
Param1<bool>(
false
);
337
if
( player )
338
{
339
player.RPCSingleParam(
ERPCs
.DEV_RPC_MODS_RESET, params,
true
);
340
}
341
342
343
}
344
345
346
void
RequestDetailedInfo
(
int
id
)
347
{
348
//Disable update on server (PluginDeveloperSync)
349
PlayerBase
player =
PlayerBase
.Cast(
g_Game
.GetPlayer() );
350
351
//if client, send RPC
352
if
(
g_Game
.IsClient() )
353
{
354
ref Param1<int> params =
new
Param1<int>(
id
);
355
if
( player )
356
{
357
player.RPCSingleParam(
ERPCs
.DEV_RPC_MODS_DETAILED, params,
true
);
358
}
359
}
360
//else set directly
361
else
362
{
363
m_PluginDeveloperSync
.RequestDetailedInfo(
id
, player);
364
}
365
}
366
367
void
ActivateModifier
(
int
id
)
368
{
369
//Disable update on server (PluginDeveloperSync)
370
PlayerBase
player =
PlayerBase
.Cast(
g_Game
.GetPlayer() );
371
372
//if client, send RPC
373
if
(
g_Game
.IsClient() )
374
{
375
ref Param1<int> params =
new
Param1<int>(
id
);
376
if
( player )
377
{
378
player.RPCSingleParam(
ERPCs
.DEV_RPC_MODS_ACTIVATE, params,
true
);
379
}
380
}
381
//else set directly
382
else
383
{
384
m_PluginDeveloperSync
.ActivateModifier(
id
);
385
}
386
}
387
388
void
DeactivateModifier
(
int
id
)
389
{
390
//Disable update on server (PluginDeveloperSync)
391
PlayerBase
player =
PlayerBase
.Cast(
g_Game
.GetPlayer() );
392
393
//if client, send RPC
394
if
(
g_Game
.IsClient() )
395
{
396
ref Param1<int> params =
new
Param1<int>(
id
);
397
if
( player )
398
{
399
player.RPCSingleParam(
ERPCs
.DEV_RPC_MODS_DEACTIVATE, params,
true
);
400
}
401
}
402
//else set directly
403
else
404
{
405
m_PluginDeveloperSync
.DeactivateModifier(
id
);
406
}
407
}
408
409
void
LockModifier
(
int
id
,
bool
state )
410
{
411
//Disable update on server (PluginDeveloperSync)
412
PlayerBase
player =
PlayerBase
.Cast(
g_Game
.GetPlayer() );
413
414
//if client, send RPC
415
if
(
g_Game
.IsClient() )
416
{
417
ref
Param2<int, bool>
params =
new
Param2<int, bool>
(
id
, state );
418
if
( player )
419
{
420
player.RPCSingleParam(
ERPCs
.DEV_RPC_MODS_LOCK, params,
true
);
421
}
422
}
423
//else set directly
424
else
425
{
426
m_PluginDeveloperSync
.LockModifier(
id
, state );
427
}
428
}
429
}
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
AutoHeightSpacer
Definition
autoheightspacer.c:3
AutoHeightSpacer::Update
void Update()
Definition
autoheightspacer.c:11
DebugModifierData
Definition
huddebugwincharmodifiers.c:2
DebugModifierData::GetID
int GetID()
Definition
huddebugwincharmodifiers.c:17
DebugModifierData::m_Name
string m_Name
Definition
huddebugwincharmodifiers.c:3
DebugModifierData::m_ID
int m_ID
Definition
huddebugwincharmodifiers.c:4
DebugModifierData::DebugModifierData
void DebugModifierData(string name, int id)
Definition
huddebugwincharmodifiers.c:6
DebugModifierData::GetName
string GetName()
Definition
huddebugwincharmodifiers.c:12
HudDebugWinBase
Definition
huddebugwinbase.c:2
HudDebugWinBase::GetType
int GetType()
Definition
huddebugwinbase.c:18
HudDebugWinBase::Hide
void Hide()
Definition
huddebugwinbase.c:57
HudDebugWinBase::SetRPCSent
void SetRPCSent()
Definition
huddebugwinbase.c:39
HudDebugWinBase::FitWindow
void FitWindow()
Definition
huddebugwincharlevels.c:130
HudDebugWinBase::SetUpdate
void SetUpdate(bool state)
HudDebugWinBase::OnClick
bool OnClick(Widget w, int x, int y, int button)
Definition
huddebugwincharstats.c:200
HudDebugWinBase::Show
void Show()
Definition
huddebugwinbase.c:48
HudDebugWinBase::Update
void Update()
Definition
huddebugwinbase.c:27
Param2
Definition
ppeconstants.c:68
PlayerBase
Definition
playerbaseclient.c:2
SyncedValueModifier
Definition
syncedvalue.c:68
SyncedValueModifier::GetID
int GetID()
Definition
syncedvalue.c:87
SyncedValueModifier::GetLocked
bool GetLocked()
Definition
syncedvalue.c:92
SyncedValueModifier::GetActive
bool GetActive()
Definition
syncedvalue.c:97
SyncedValueModifier::GetName
string GetName()
Definition
syncedvalue.c:82
TextWidget
Definition
enwidgets.c:220
Widget
Definition
enwidgets.c:190
map
Definition
cachedequipmentstorage.c:4
map
map
Definition
controlsxboxnew.c:4
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
ERPCs
ERPCs
Definition
erpcs.c:2
HudDebug
void HudDebug()
Definition
huddebug.c:108
m_WgtRoot
Widget m_WgtRoot
Definition
huddebug.c:94
HudDebugWinCharModifiers
void HudDebugWinCharModifiers(Widget widget_root)
Definition
huddebugwincharmodifiers.c:36
ClearModifiers
void ClearModifiers()
Definition
huddebugwincharmodifiers.c:231
m_ModifierWidgetData
ref map< Widget, ref DebugModifierData > m_ModifierWidgetData
Definition
huddebugwincharmodifiers.c:27
ResetModifiers
void ResetModifiers()
Definition
huddebugwincharmodifiers.c:330
m_WgtDetailedInfoText
TextWidget m_WgtDetailedInfoText
Definition
huddebugwincharmodifiers.c:30
m_WgtModifiersContent
class DebugModifierData m_WgtModifiersContent
~HudDebugWinCharModifiers
void ~HudDebugWinCharModifiers()
Definition
huddebugwincharmodifiers.c:45
m_PluginDeveloperSync
PluginDeveloperSync m_PluginDeveloperSync
Definition
huddebugwincharmodifiers.c:28
RequestDetailedInfo
void RequestDetailedInfo(int id)
Definition
huddebugwincharmodifiers.c:346
SetModifiers
void SetModifiers()
Definition
huddebugwincharmodifiers.c:160
m_DetailedInfoIndex
int m_DetailedInfoIndex
Definition
huddebugwincharmodifiers.c:31
m_WgtDetailedInfo
Widget m_WgtDetailedInfo
Definition
huddebugwincharmodifiers.c:29
m_ModifierWidgets
ref map< int, Widget > m_ModifierWidgets
Definition
huddebugwincharmodifiers.c:26
LockModifier
void LockModifier(int id, bool state)
Definition
huddebugwincharmodifiers.c:409
x
Icon x
y
Icon y
DeactivateModifier
void DeactivateModifier(int modifier_id, bool triggerEvent=true)
Definition
modifiersmanager.c:224
ActivateModifier
void ActivateModifier(int modifier_id, bool triggerEvent=EActivationType.TRIGGER_EVENT_ON_ACTIVATION)
Definition
modifiersmanager.c:219
AddModifier
void AddModifier(ModifierBase modifier)
Definition
modifiersmanager.c:180
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition
pluginmanager.c:325
ARGB
int ARGB(int a, int r, int g, int b)
Definition
proto.c:322
Refresh
void Refresh()
Definition
sizetochild.c:108
Games
Dayz
scripts
5_mission
gui
scriptshuddebug
huddebugwincharmodifiers.c
Generated by
1.17.0