Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
huddebugwincharstats.c
Go to the documentation of this file.
1
class
HudDebugWinCharStats
extends
HudDebugWinBase
2
{
3
TextListboxWidget m_WgtValues;
4
Widget
m_WgtPanel
;
5
ref
array<ref Widget>
m_StatWidgets
=
new
array<ref Widget>
;
6
ref map <ref SliderWidget, string>
m_SliderWidgets
=
new
map<ref SliderWidget, string>
;
7
ref
array<ref TextWidget>
m_StatValues
=
new
array<ref TextWidget>
;
8
ref
map<ref EditBoxWidget, string>
m_StatValuesInput
=
new
map<ref EditBoxWidget, string>
;
9
bool
m_Populated
;
10
bool
m_ChangingSlider
;
11
12
//============================================
13
// Constructor
14
//============================================
15
void
HudDebugWinCharStats
(
Widget
widget_root)
16
{
17
m_WgtRoot
= widget_root;
18
m_WgtPanel
=
Widget
.Cast(
m_WgtRoot
.FindAnyWidget(
"Stats"
) );
19
//FitWindow();
20
}
21
22
//============================================
23
// Destructor
24
//============================================
25
void
~HudDebugWinCharStats
()
26
{
27
SetUpdate
(
false
);
28
}
29
30
31
//============================================
32
// GetWinType
33
//============================================
34
override
int
GetType
()
35
{
36
return
HudDebug
.HUD_WIN_CHAR_STATS;
37
}
38
39
//============================================
40
// Show
41
//============================================
42
override
void
Show
()
43
{
44
super.Show();
45
46
//Print("Show()");
47
48
SetUpdate
(
true
);
49
}
50
51
//============================================
52
// Hide
53
//============================================
54
override
void
Hide
()
55
{
56
super.Hide();
57
58
//Print("Hide()");
59
60
SetUpdate
(
false
);
61
}
62
63
//============================================
64
// SetUpdate
65
//============================================
66
override
void
SetUpdate
(
bool
state )
67
{
68
//Disable update on server (PluginDeveloperSync)
69
PlayerBase
player =
PlayerBase
.Cast(
g_Game
.GetPlayer() );
70
71
PluginDeveloperSync developer_sync = PluginDeveloperSync.Cast(
GetPlugin
( PluginDeveloperSync ) );
72
73
//if client, send RPC
74
if
(
g_Game
.IsClient() )
75
{
76
ref Param1<bool> params =
new
Param1<bool>( state );
77
if
( player )
78
{
79
player.RPCSingleParam(
ERPCs
.DEV_STATS_UPDATE, params,
true
);
80
SetRPCSent
();
81
}
82
}
83
//else set directly
84
else
85
{
86
if
( developer_sync )
87
{
88
developer_sync.EnableUpdate( state,
ERPCs
.DEV_STATS_UPDATE, player );
89
}
90
}
91
}
92
93
94
override
void
Update
()
95
{
96
super.Update();
97
98
if
(!
m_Populated
)
99
SetupValues
();
100
101
UpdateValues
();
102
}
103
104
void
SetupValues
()
105
{
106
PluginDeveloperSync developerSync = PluginDeveloperSync.Cast(
GetPlugin
(PluginDeveloperSync));
107
108
//clear window
109
//ClearValues();
110
111
if
( developerSync.m_PlayerStatsSynced.Count() > 0 )
112
{
113
foreach
(
SyncedValue
syncedValue : developerSync.m_PlayerStatsSynced)
114
{
115
string
name
= syncedValue.
GetName
();
116
string
value = syncedValue.
GetValue
().
ToString
();
117
118
AddValue
(
name
, value);
119
}
120
121
FitWindow
();
122
m_Populated
=
true
;
123
}
124
}
125
126
127
void
UpdateValues
()
128
{
129
PluginDeveloperSync developerSync = PluginDeveloperSync.Cast(
GetPlugin
( PluginDeveloperSync ) );
130
if
( developerSync.m_PlayerStatsSynced.Count() > 0 )
131
{
132
foreach
(
int
i,
SyncedValue
syncedValue : developerSync.m_PlayerStatsSynced)
133
{
134
string
statName = syncedValue.
GetName
();
135
float
valueNormalized = syncedValue.
GetValueNorm
();
136
float
value = syncedValue.
GetValue
();
137
138
if
( statName ==
"BloodType"
)
139
{
140
string
type,
name
;
141
bool
positive;
142
143
name
= value.
ToString
();
144
name
+=
"("
+
BloodTypes
.
GetBloodTypeName
(
Math
.
Round
(value), type, positive)+
")"
;
145
m_StatValues
.Get(i).SetText(
name
);
146
}
147
else
148
{
149
if
(statName ==
"HeatBuffer"
)
150
{
151
float
heatBufferNormalized =
Math
.
Round
(
Math
.
Lerp
(-1, 1, valueNormalized) * 1000) * 0.001;
152
m_StatValues
.Get(i).SetText(
string
.Format(
"%1 (%2)"
, heatBufferNormalized.
ToString
(), value.
ToString
()));
153
}
154
else
155
m_StatValues
.Get(i).SetText(value.
ToString
());
156
157
}
158
159
if
(!
m_ChangingSlider
)
160
m_SliderWidgets
.GetKeyByValue(statName).SetCurrent(valueNormalized * 100);
161
}
162
}
163
164
}
165
166
void
AddValue
(
string
title,
string
value)
167
{
168
Widget
widget =
g_Game
.GetWorkspace().CreateWidgets(
"gui/layouts/debug/day_z_hud_debug_stat.layout"
,
m_WgtPanel
);
169
170
TextWidget
tw =
TextWidget
.Cast(widget.FindAnyWidget(
"StatName"
));
171
tw.SetText(title);
172
m_StatWidgets
.Insert(widget);
173
174
TextWidget
tw_output =
TextWidget
.Cast(widget.FindAnyWidget(
"OutputValue"
));
175
m_StatValues
.Insert(tw_output);
176
177
EditBoxWidget
ebw_input =
EditBoxWidget
.Cast(widget.FindAnyWidget(
"InputValue"
));
178
m_StatValuesInput
.Insert(ebw_input, title );
179
180
SliderWidget sw = SliderWidget.Cast(widget.FindAnyWidget(
"StatSlider"
));
181
m_SliderWidgets
.Insert(sw,title );
182
183
AutoHeightSpacer
WgtModifiersContent_panel_script;
184
m_WgtPanel
.GetScript( WgtModifiersContent_panel_script );
185
WgtModifiersContent_panel_script.
Update
();
186
}
187
188
void
ClearValues
()
189
{
190
m_StatWidgets
.Clear();
191
}
192
193
void
FitWindow
()
194
{
195
TextListboxWidget wgt = TextListboxWidget.Cast(
m_WgtPanel
);
196
if
(wgt)
197
FitWindowByContent
( wgt );
198
}
199
200
bool
OnClick
(
Widget
w,
int
x
,
int
y
,
int
button )
201
{
202
if
( w.GetName() ==
"ResetStats"
)
203
{
204
ResetStats
();
205
return
true
;
206
}
207
208
return
false
;
209
}
210
211
bool
OnChange
(
Widget
w,
int
x
,
int
y
,
bool
finished)
212
{
213
if
(
m_StatValuesInput
.Contains(
EditBoxWidget
.Cast(w)) && finished )
214
{
215
EditBoxWidget
ebw =
EditBoxWidget
.Cast(w);
216
RPCChangeStat
(
m_StatValuesInput
.Get(
EditBoxWidget
.Cast(w)), ebw.GetText().ToFloat());
217
return
true
;
218
}
219
if
(
m_SliderWidgets
.Contains(SliderWidget.Cast(w)))
220
{
221
m_ChangingSlider
=
true
;
222
string
stat_name =
m_SliderWidgets
.Get(SliderWidget.Cast(w));
223
SliderWidget sw = SliderWidget.Cast(w);
224
PlayerBase
player =
PlayerBase
.Cast(
g_Game
.GetPlayer());
225
for
(
int
i = 0; i < player.m_PlayerStats.GetPCO().
Get
().
Count
(); i++ )
226
{
227
string
label = player.m_PlayerStats.GetPCO().Get().Get( i ).GetLabel();
228
if
(label == stat_name)
229
{
230
float
stat_min = player.m_PlayerStats.GetPCO().Get().Get( i ).GetMin();
231
float
stat_max = player.m_PlayerStats.GetPCO().Get().Get( i ).GetMax();
232
float
current_value_norm = sw.GetCurrent() / 100;
233
float
current_value_abs = stat_min + (stat_max - stat_min) * current_value_norm;
234
235
RPCChangeStat
(label, current_value_abs);
236
}
237
}
238
//Print("OnChange " + finished);
239
if
(finished)
240
m_ChangingSlider
=
false
;
241
}
242
243
return
false
;
244
}
245
246
247
void
ResetStats
()
248
{
249
PlayerBase
player =
PlayerBase
.Cast(
g_Game
.GetPlayer() );
250
251
//if client, send RPC
252
253
ref Param1<bool> params =
new
Param1<bool>(
false
);
254
if
( player )
255
{
256
player.RPCSingleParam(
ERPCs
.DEV_RPC_STATS_RESET, params,
true
);
257
}
258
}
259
260
void
RPCChangeStat
(
string
stat,
float
value)
261
{
262
PlayerBase
player =
PlayerBase
.Cast(
g_Game
.GetPlayer() );
263
264
//if client, send RPC
265
266
ref
Param2<string, float>
params =
new
Param2<string, float>
( stat, value );
267
if
( player )
268
{
269
player.RPCSingleParam(
ERPCs
.DEV_RPC_STAT_SET, params,
true
);
270
}
271
}
272
273
274
}
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
AutoHeightSpacer
Definition
autoheightspacer.c:3
AutoHeightSpacer::Update
void Update()
Definition
autoheightspacer.c:11
BloodTypes
Definition
bloodtype.c:2
BloodTypes::GetBloodTypeName
static string GetBloodTypeName(int bloodtype, out string type, out bool positive)
Definition
bloodtype.c:89
EditBoxWidget
Definition
enwidgets.c:354
HudDebugWinBase
Definition
huddebugwinbase.c:2
HudDebugWinBase::Hide
override void Hide()
Definition
huddebugwincharstats.c:54
HudDebugWinBase::m_WgtPanel
Widget m_WgtPanel
Definition
huddebugwincharstats.c:4
HudDebugWinBase::m_SliderWidgets
ref map< ref SliderWidget, string > m_SliderWidgets
Definition
huddebugwincharstats.c:6
HudDebugWinBase::m_StatValues
ref array< ref TextWidget > m_StatValues
Definition
huddebugwincharstats.c:7
HudDebugWinBase::SetUpdate
override void SetUpdate(bool state)
Definition
huddebugwincharstats.c:66
HudDebugWinBase::m_Populated
bool m_Populated
Definition
huddebugwincharstats.c:9
HudDebugWinBase::UpdateValues
void UpdateValues()
Definition
huddebugwincharstats.c:127
HudDebugWinBase::SetRPCSent
void SetRPCSent()
Definition
huddebugwinbase.c:39
HudDebugWinBase::FitWindow
void FitWindow()
Definition
huddebugwincharlevels.c:130
HudDebugWinBase::HudDebugWinCharStats
void HudDebugWinCharStats(Widget widget_root)
Definition
huddebugwincharstats.c:15
HudDebugWinBase::AddValue
void AddValue(string title, string value)
Definition
huddebugwincharstats.c:166
HudDebugWinBase::AddValue
void AddValue(string title, string value, string value2)
Definition
huddebugwincharlevels.c:118
HudDebugWinBase::m_StatValuesInput
ref map< ref EditBoxWidget, string > m_StatValuesInput
Definition
huddebugwincharstats.c:8
HudDebugWinBase::Update
override void Update()
Definition
huddebugwincharstats.c:94
HudDebugWinBase::GetType
override int GetType()
Definition
huddebugwincharstats.c:34
HudDebugWinBase::m_ChangingSlider
bool m_ChangingSlider
Definition
huddebugwincharstats.c:10
HudDebugWinBase::SetUpdate
void SetUpdate(bool state)
HudDebugWinBase::~HudDebugWinCharStats
void ~HudDebugWinCharStats()
Definition
huddebugwincharstats.c:25
HudDebugWinBase::OnClick
bool OnClick(Widget w, int x, int y, int button)
Definition
huddebugwincharstats.c:200
HudDebugWinBase::ClearValues
void ClearValues()
Definition
huddebugwincharstats.c:188
HudDebugWinBase::Show
override void Show()
Definition
huddebugwincharstats.c:42
HudDebugWinBase::RPCChangeStat
void RPCChangeStat(string stat, float value)
Definition
huddebugwincharstats.c:260
HudDebugWinBase::OnChange
bool OnChange(Widget w, int x, int y, bool finished)
Definition
huddebugwincharstats.c:211
HudDebugWinBase::ResetStats
void ResetStats()
Definition
huddebugwincharstats.c:247
HudDebugWinBase::m_StatWidgets
ref array< ref Widget > m_StatWidgets
Definition
huddebugwincharstats.c:5
HudDebugWinBase::FitWindowByContent
void FitWindowByContent(TextListboxWidget wgt)
Definition
huddebugwinbase.c:74
HudDebugWinBase::SetupValues
void SetupValues()
Definition
huddebugwincharstats.c:104
HudDebugWinBase::m_WgtRoot
Widget m_WgtRoot
Definition
huddebugwinbase.c:3
Math
Definition
enmath.c:7
Param2
Definition
ppeconstants.c:68
PlayerBase
Definition
playerbaseclient.c:2
SyncedValue
Definition
syncedvalue.c:2
SyncedValue::GetValue
float GetValue()
Definition
syncedvalue.c:21
SyncedValue::GetValueNorm
float GetValueNorm()
Definition
syncedvalue.c:26
SyncedValue::GetName
string GetName()
Definition
syncedvalue.c:16
TextWidget
Definition
enwidgets.c:220
Widget
Definition
enwidgets.c:190
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
float::ToString
proto string ToString(bool simple=true)
map
Definition
cachedequipmentstorage.c:4
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
ERPCs
ERPCs
Definition
erpcs.c:2
Math::Round
static proto float Round(float f)
Returns mathematical round of value.
Math::Lerp
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
HudDebug
void HudDebug()
Definition
huddebug.c:108
x
Icon x
y
Icon y
Get
override float Get()
Definition
playerstatbase.c:134
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition
pluginmanager.c:325
Count
@ Count
Definition
randomgeneratorsyncmanager.c:8
Games
Dayz
scripts
5_mission
gui
scriptshuddebug
huddebugwincharstats.c
Generated by
1.17.0