DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
DebugMonitor.c
См. документацию.
2{
3 protected bool m_IsUsingKBM;
4
7
18
23
25
27 {
28 m_WidgetRoot = g_Game.GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_debug_monitor.layout");
29 m_WidgetRoot.Show(false);
30
31 m_VersionValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("VersionValue"));
32 m_HealthValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("HealthValue"));
33 m_BloodValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("BloodValue"));
34 m_DmgSourceValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("DmgSourceValue"));
35 m_MapTileValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("MapTileValue"));
36 m_PositionValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("PositionValue"));
37 m_CopyPositionInfo = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("CopyPositionInfo"));
38
39 m_FPSValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("FPSCurrentValue"));
40 m_FPSMinValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("FPSMinValue"));
41 m_FPSMaxValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("FPSMaxValue"));
42 m_FPSAvgValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("FPSAvgValue"));
43
44 m_EnvironmentTemperatureValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("TemperatureValue"));
45
46 m_HeatComfortValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("HeatComfortValue"));
47 m_ThermalBiasValue = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("ThermalBiasValue"));
48
50 }
51
52 void Init()
53 {
54 string version;
55 g_Game.GetVersion(version);
56 m_VersionValue.SetText(" " + version);
57
58 g_Game.GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
59 if (g_Game.GetInput().IsKeyboardConnected())
60 m_IsUsingKBM = true;
61
62 m_WidgetRoot.Show(true);
63 }
64
65 void SetHealth(float value)
66 {
67 string health = string.Format(" %1", value.ToString());
68 m_HealthValue.SetText(health);
69 }
70
71 void SetBlood(float value)
72 {
73 string blood = string.Format(" %1", value.ToString());
74 m_BloodValue.SetText(blood);
75 }
76
77 void SetLastDamage(string value)
78 {
79 if (value != "")
80 m_DmgSourceValue.SetText(" " + value);
81 else
82 m_DmgSourceValue.SetText(" -");
83 }
84
88 void SetFramerate(float current, float min, float max, float avg)
89 {
94 }
95
100 protected void SetFramerateText(TextWidget widget, float value)
101 {
102 // Ideally we would poll the refresh rate and base the values as
103 // percentage thereof, but there is no such API in scripts.
104
105 #ifdef PLATFORM_CONSOLE
106 // default [30, inf] ; orange [20, 29] ; red [0, 19]
107 if (value > 29)
108 widget.SetColor(m_FPSTextDefaultColor);
109 else if (value > 19)
110 widget.SetColor(0xFFFF8000); // COLOR_ORANGE
111 else
112 widget.SetColor(COLOR_RED);
113 #else
114 // default [60, inf] ; yellow [40, 59] ; orange [30, 39] ; red [0, 29]
115 if (value > 59)
116 widget.SetColor(m_FPSTextDefaultColor);
117 else if (value > 39)
118 widget.SetColor(COLOR_YELLOW);
119 else if (value > 29)
120 widget.SetColor(0xFFFF8000); // COLOR_ORANGE
121 else
122 widget.SetColor(COLOR_RED);
123 #endif
124
125 widget.SetTextFormat("%1", Math.Round(value));
126 }
127
128 void SetPosition(vector value)
129 {
130 m_MapTileValue.SetText(" " + CalculateMapTile(value));
131 string position = string.Format(" %1 %2 %3", value[0].ToString(), value[1].ToString(), value[2].ToString());
132 m_PositionValue.SetText(position);
133
134 if (GetUApi().GetInputByID(UAUICopyDebugMonitorPos).LocalPress())
135 {
136 string adjusted = (value[0] + 200000).ToString() + " " + value[2].ToString();
137 g_Game.CopyToClipboard(adjusted);
138 }
139
140 if (m_IsUsingKBM)
141 m_CopyPositionInfo.SetText(" (P to clipboard)");
142 else
143 m_CopyPositionInfo.SetText("");
144 }
145
147 {
149 }
150
151 void SetHeatComfort(float value)
152 {
153 m_HeatComfortValue.SetText(value.ToString());
154 }
155
156 void SetThermalBias(float value)
157 {
158 m_ThermalBiasValue.SetText(value.ToString());
159 }
160
161 void Show()
162 {
163 m_WidgetRoot.Show(true);
164 }
165
166 void Hide()
167 {
168 m_WidgetRoot.Show(false);
169 }
170
172 {
173 string tile;
174 float worldSize = g_Game.GetWorld().GetWorldSize();
175
176 float tileX = Math.InverseLerp(0, worldSize, pos[0]);
177 float tileY = Math.InverseLerp(0, worldSize, pos[2]);
178
179 tile = GetTileFomFraction(tileX).ToString() + GetTileFomFraction(tileY).ToString();
180
181 return tile;
182 }
183
184 int GetTileFomFraction(float fraction)
185 {
186 if (fraction < 0.25)
187 return 0;
188 else if (fraction < 0.5)
189 return 1;
190 else if (fraction < 0.75)
191 return 2;
192 else
193 return 3;
194
195 }
196
198 {
199 if (pInputDeviceType == EInputDeviceType.MOUSE_AND_KEYBOARD)
200 m_IsUsingKBM = true;
201 else
202 m_IsUsingKBM = false;
203 }
204
206 {
207 return m_WidgetRoot.IsVisible();
208 }
209};
210
DayZGame g_Game
Определения DayZGame.c:4074
vector position
Определения DustKickupEffects.c:20
proto string ToString()
proto native UAInputAPI GetUApi()
TextWidget m_PositionValue
Определения DebugMonitor.c:16
void SetLastDamage(string value)
Определения DebugMonitor.c:77
TextWidget m_WindowLabelText
Определения DebugMonitor.c:6
void SetBlood(float value)
Определения DebugMonitor.c:71
void Init()
Определения DebugMonitor.c:52
void SetFramerate(float current, float min, float max, float avg)
Определения DebugMonitor.c:88
void SetHealth(float value)
Определения DebugMonitor.c:65
bool m_IsUsingKBM
Определения DebugMonitor.c:3
TextWidget m_EnvironmentTemperatureValue
Определения DebugMonitor.c:11
int m_FPSTextDefaultColor
Определения DebugMonitor.c:24
TextWidget m_FPSAvgValue
Определения DebugMonitor.c:22
TextWidget m_FPSMinValue
Определения DebugMonitor.c:20
TextWidget m_BloodValue
Определения DebugMonitor.c:10
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Определения DebugMonitor.c:197
void Show()
Определения DebugMonitor.c:161
TextWidget m_VersionValue
Определения DebugMonitor.c:8
bool IsVisible()
Определения DebugMonitor.c:205
void SetEnvironmentTemperature(float value)
Определения DebugMonitor.c:146
Widget m_WidgetRoot
Определения DebugMonitor.c:5
void Hide()
Определения DebugMonitor.c:166
TextWidget m_HeatComfortValue
Определения DebugMonitor.c:12
void SetThermalBias(float value)
Определения DebugMonitor.c:156
int GetTileFomFraction(float fraction)
Определения DebugMonitor.c:184
TextWidget m_FPSValue
Определения DebugMonitor.c:19
TextWidget m_DmgSourceValue
Определения DebugMonitor.c:14
void SetPosition(vector value)
Определения DebugMonitor.c:128
TextWidget m_CopyPositionInfo
Определения DebugMonitor.c:17
string CalculateMapTile(vector pos)
Определения DebugMonitor.c:171
TextWidget m_MapTileValue
Определения DebugMonitor.c:15
TextWidget m_ThermalBiasValue
Определения DebugMonitor.c:13
TextWidget m_HealthValue
Определения DebugMonitor.c:9
void DebugMonitor()
Определения DebugMonitor.c:26
void SetHeatComfort(float value)
Определения DebugMonitor.c:151
TextWidget m_FPSMaxValue
Определения DebugMonitor.c:21
void SetFramerateText(TextWidget widget, float value)
Определения DebugMonitor.c:100
Определения EnMath.c:7
Определения EnWidgets.c:220
Определения EnWidgets.c:190
proto string ToString(bool simple=true)
proto string ToString(bool beautify=true)
Vector to string.
Определения EnConvert.c:119
const int COLOR_RED
Определения 1_Core/DayZ/constants.c:64
const int COLOR_YELLOW
Определения 1_Core/DayZ/constants.c:67
static proto float Round(float f)
Returns mathematical round of value.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.
EInputDeviceType
Определения input.c:3