Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
debugmonitor.c
Go to the documentation of this file.
1
class
DebugMonitor
2
{
3
protected
bool
m_IsUsingKBM
;
4
5
private
Widget
m_WidgetRoot
;
6
private
TextWidget
m_WindowLabelText
;
7
8
private
TextWidget
m_VersionValue
;
9
private
TextWidget
m_HealthValue
;
10
private
TextWidget
m_BloodValue
;
11
private
TextWidget
m_DmgSourceValue
;
12
private
TextWidget
m_MapTileValue
;
13
private
TextWidget
m_PositionValue
;
14
private
TextWidget
m_CopyPositionInfo
;
15
16
private
TextWidget
m_FPSValue
;
17
private
TextWidget
m_FPSMinValue
;
18
private
TextWidget
m_FPSMaxValue
;
19
private
TextWidget
m_FPSAvgValue
;
20
21
private
int
m_FPSTextDefaultColor
;
22
23
void
DebugMonitor
()
24
{
25
m_WidgetRoot
=
g_Game
.GetWorkspace().CreateWidgets(
"gui/layouts/debug/day_z_debug_monitor.layout"
);
26
m_WidgetRoot
.Show(
false
);
27
28
m_VersionValue
=
TextWidget
.Cast(
m_WidgetRoot
.FindAnyWidget(
"VersionValue"
));
29
m_HealthValue
=
TextWidget
.Cast(
m_WidgetRoot
.FindAnyWidget(
"HealthValue"
));
30
m_BloodValue
=
TextWidget
.Cast(
m_WidgetRoot
.FindAnyWidget(
"BloodValue"
));
31
m_DmgSourceValue
=
TextWidget
.Cast(
m_WidgetRoot
.FindAnyWidget(
"DmgSourceValue"
));
32
m_MapTileValue
=
TextWidget
.Cast(
m_WidgetRoot
.FindAnyWidget(
"MapTileValue"
));
33
m_PositionValue
=
TextWidget
.Cast(
m_WidgetRoot
.FindAnyWidget(
"PositionValue"
));
34
m_CopyPositionInfo
=
TextWidget
.Cast(
m_WidgetRoot
.FindAnyWidget(
"CopyPositionInfo"
));
35
36
m_FPSValue
=
TextWidget
.Cast(
m_WidgetRoot
.FindAnyWidget(
"FPSCurrentValue"
));
37
m_FPSMinValue
=
TextWidget
.Cast(
m_WidgetRoot
.FindAnyWidget(
"FPSMinValue"
));
38
m_FPSMaxValue
=
TextWidget
.Cast(
m_WidgetRoot
.FindAnyWidget(
"FPSMaxValue"
));
39
m_FPSAvgValue
=
TextWidget
.Cast(
m_WidgetRoot
.FindAnyWidget(
"FPSAvgValue"
));
40
41
m_FPSTextDefaultColor
=
m_FPSValue
.GetColor();
42
}
43
44
void
Init
()
45
{
46
string
version;
47
g_Game
.GetVersion(version);
48
m_VersionValue
.SetText(
" "
+ version);
49
50
g_Game
.GetMission().GetOnInputDeviceChanged().Insert(
OnInputDeviceChanged
);
51
if
(
g_Game
.GetInput().IsKeyboardConnected())
52
m_IsUsingKBM
=
true
;
53
54
m_WidgetRoot
.Show(
true
);
55
}
56
57
void
SetHealth
(
float
value)
58
{
59
string
health =
string
.Format(
" %1"
, value.
ToString
());
60
m_HealthValue
.SetText(health);
61
}
62
63
void
SetBlood
(
float
value)
64
{
65
string
blood =
string
.Format(
" %1"
, value.
ToString
());
66
m_BloodValue
.SetText(blood);
67
}
68
69
void
SetLastDamage
(
string
value)
70
{
71
if
(value !=
""
)
72
m_DmgSourceValue
.SetText(
" "
+ value);
73
else
74
m_DmgSourceValue
.SetText(
" -"
);
75
}
76
80
void
SetFramerate
(
float
current,
float
min,
float
max,
float
avg)
81
{
82
SetFramerateText
(
m_FPSValue
, current);
83
SetFramerateText
(
m_FPSMinValue
, min);
84
SetFramerateText
(
m_FPSMaxValue
, max);
85
SetFramerateText
(
m_FPSAvgValue
, avg);
86
}
87
92
protected
void
SetFramerateText
(
TextWidget
widget,
float
value)
93
{
94
// Ideally we would poll the refresh rate and base the values as
95
// percentage thereof, but there is no such API in scripts.
96
97
#ifdef PLATFORM_CONSOLE
98
// default [30, inf] ; orange [20, 29] ; red [0, 19]
99
if
(value > 29)
100
widget.SetColor(
m_FPSTextDefaultColor
);
101
else
if
(value > 19)
102
widget.SetColor(0xFFFF8000);
// COLOR_ORANGE
103
else
104
widget.SetColor(
COLOR_RED
);
105
#else
106
// default [60, inf] ; yellow [40, 59] ; orange [30, 39] ; red [0, 29]
107
if
(value > 59)
108
widget.SetColor(
m_FPSTextDefaultColor
);
109
else
if
(value > 39)
110
widget.SetColor(
COLOR_YELLOW
);
111
else
if
(value > 29)
112
widget.SetColor(0xFFFF8000);
// COLOR_ORANGE
113
else
114
widget.SetColor(
COLOR_RED
);
115
#endif
116
117
widget.SetTextFormat(
"%1"
,
Math
.
Round
(value));
118
}
119
120
void
SetPosition
(
vector
value)
121
{
122
m_MapTileValue
.SetText(
" "
+
CalculateMapTile
(value));
123
string
position =
string
.Format(
" %1 %2 %3"
, value[0].
ToString
(), value[1].
ToString
(), value[2].
ToString
());
124
m_PositionValue
.SetText(position);
125
126
if
(
GetUApi
().GetInputByID(UAUICopyDebugMonitorPos).LocalPress())
127
{
128
string
adjusted = (value[0] + 200000).
ToString
() +
" "
+ value[2].
ToString
();
129
g_Game
.CopyToClipboard(adjusted);
130
}
131
132
if
(
m_IsUsingKBM
)
133
m_CopyPositionInfo
.SetText(
" (P to clipboard)"
);
134
else
135
m_CopyPositionInfo
.SetText(
""
);
136
}
137
138
void
Show
()
139
{
140
m_WidgetRoot
.Show(
true
);
141
}
142
143
void
Hide
()
144
{
145
m_WidgetRoot
.Show(
false
);
146
}
147
148
string
CalculateMapTile
(
vector
pos)
149
{
150
string
tile;
151
float
worldSize =
g_Game
.GetWorld().GetWorldSize();
152
153
float
tileX =
Math
.
InverseLerp
(0, worldSize, pos[0]);
154
float
tileY =
Math
.
InverseLerp
(0, worldSize, pos[2]);
155
156
tile =
GetTileFomFraction
(tileX).ToString() +
GetTileFomFraction
(tileY).ToString();
157
158
return
tile;
159
}
160
161
int
GetTileFomFraction
(
float
fraction)
162
{
163
if
(fraction < 0.25)
164
return
0;
165
else
if
(fraction < 0.5)
166
return
1;
167
else
if
(fraction < 0.75)
168
return
2;
169
else
170
return
3;
171
172
}
173
174
void
OnInputDeviceChanged
(
EInputDeviceType
pInputDeviceType)
175
{
176
if
(pInputDeviceType ==
EInputDeviceType
.MOUSE_AND_KEYBOARD)
177
m_IsUsingKBM
=
true
;
178
else
179
m_IsUsingKBM
=
false
;
180
}
181
182
bool
IsVisible
()
183
{
184
return
m_WidgetRoot
.IsVisible();
185
}
186
};
187
DebugMonitor::m_PositionValue
TextWidget m_PositionValue
Definition
debugmonitor.c:13
DebugMonitor::Hide
void Hide()
Definition
debugmonitor.c:143
DebugMonitor::m_MapTileValue
TextWidget m_MapTileValue
Definition
debugmonitor.c:12
DebugMonitor::Init
void Init()
Definition
debugmonitor.c:44
DebugMonitor::m_FPSTextDefaultColor
int m_FPSTextDefaultColor
Definition
debugmonitor.c:21
DebugMonitor::m_CopyPositionInfo
TextWidget m_CopyPositionInfo
Definition
debugmonitor.c:14
DebugMonitor::m_FPSValue
TextWidget m_FPSValue
Definition
debugmonitor.c:16
DebugMonitor::m_BloodValue
TextWidget m_BloodValue
Definition
debugmonitor.c:10
DebugMonitor::m_VersionValue
TextWidget m_VersionValue
Definition
debugmonitor.c:8
DebugMonitor::m_DmgSourceValue
TextWidget m_DmgSourceValue
Definition
debugmonitor.c:11
DebugMonitor::m_FPSMaxValue
TextWidget m_FPSMaxValue
Definition
debugmonitor.c:18
DebugMonitor::m_FPSMinValue
TextWidget m_FPSMinValue
Definition
debugmonitor.c:17
DebugMonitor::DebugMonitor
void DebugMonitor()
Definition
debugmonitor.c:23
DebugMonitor::SetLastDamage
void SetLastDamage(string value)
Definition
debugmonitor.c:69
DebugMonitor::SetPosition
void SetPosition(vector value)
Definition
debugmonitor.c:120
DebugMonitor::GetTileFomFraction
int GetTileFomFraction(float fraction)
Definition
debugmonitor.c:161
DebugMonitor::m_WidgetRoot
Widget m_WidgetRoot
Definition
debugmonitor.c:5
DebugMonitor::SetFramerate
void SetFramerate(float current, float min, float max, float avg)
Update the framerate values displayed within the debug monitor with new ones.
Definition
debugmonitor.c:80
DebugMonitor::OnInputDeviceChanged
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition
debugmonitor.c:174
DebugMonitor::SetBlood
void SetBlood(float value)
Definition
debugmonitor.c:63
DebugMonitor::CalculateMapTile
string CalculateMapTile(vector pos)
Definition
debugmonitor.c:148
DebugMonitor::Show
void Show()
Definition
debugmonitor.c:138
DebugMonitor::m_WindowLabelText
TextWidget m_WindowLabelText
Definition
debugmonitor.c:6
DebugMonitor::m_HealthValue
TextWidget m_HealthValue
Definition
debugmonitor.c:9
DebugMonitor::m_FPSAvgValue
TextWidget m_FPSAvgValue
Definition
debugmonitor.c:19
DebugMonitor::SetHealth
void SetHealth(float value)
Definition
debugmonitor.c:57
DebugMonitor::SetFramerateText
void SetFramerateText(TextWidget widget, float value)
Sets the provided text widget to display framerate value.
Definition
debugmonitor.c:92
DebugMonitor::m_IsUsingKBM
bool m_IsUsingKBM
Definition
debugmonitor.c:3
DebugMonitor::IsVisible
bool IsVisible()
Definition
debugmonitor.c:182
Math
Definition
enmath.c:7
TextWidget
Definition
enwidgets.c:220
Widget
Definition
enwidgets.c:190
float::ToString
proto string ToString(bool simple=true)
vector
Definition
enconvert.c:119
vector::ToString
proto string ToString(bool beautify=true)
Vector to string.
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
ToString
proto string ToString()
COLOR_RED
const int COLOR_RED
Definition
constants.c:64
COLOR_YELLOW
const int COLOR_YELLOW
Definition
constants.c:67
Math::Round
static proto float Round(float f)
Returns mathematical round of value.
Math::InverseLerp
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
EInputDeviceType
EInputDeviceType
Definition
input.c:3
GetUApi
proto native UAInputAPI GetUApi()
Games
Dayz
scripts
5_mission
gui
debugmonitor.c
Generated by
1.17.0