DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
DebugMonitor.c
См. документацию.
2{
3 protected bool m_IsUsingKBM;
4
7
15
20
22
24 {
25 m_WidgetRoot = GetGame().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
42 }
43
44 void Init()
45 {
46 string version;
47 g_Game.GetVersion(version);
48 m_VersionValue.SetText(" " + version);
49
51 if (GetGame().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 {
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 GetGame().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
149 {
150 string tile;
151 float worldSize = GetGame().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
175 {
176 if (pInputDeviceType == EInputDeviceType.MOUSE_AND_KEYBOARD)
177 m_IsUsingKBM = true;
178 else
179 m_IsUsingKBM = false;
180 }
181
183 {
184 return m_WidgetRoot.IsVisible();
185 }
186};
187
DayZGame g_Game
Определения DayZGame.c:3868
proto string ToString()
proto native UAInputAPI GetUApi()
proto native void CopyToClipboard(string text)
proto native World GetWorld()
proto native WorkspaceWidget GetWorkspace()
proto native Mission GetMission()
TextWidget m_PositionValue
Определения DebugMonitor.c:13
void SetLastDamage(string value)
Определения DebugMonitor.c:69
TextWidget m_WindowLabelText
Определения DebugMonitor.c:6
void SetBlood(float value)
Определения DebugMonitor.c:63
void Init()
Определения DebugMonitor.c:44
void SetFramerate(float current, float min, float max, float avg)
Определения DebugMonitor.c:80
void SetHealth(float value)
Определения DebugMonitor.c:57
bool m_IsUsingKBM
Определения DebugMonitor.c:3
int m_FPSTextDefaultColor
Определения DebugMonitor.c:21
TextWidget m_FPSAvgValue
Определения DebugMonitor.c:19
TextWidget m_FPSMinValue
Определения DebugMonitor.c:17
TextWidget m_BloodValue
Определения DebugMonitor.c:10
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Определения DebugMonitor.c:174
void Show()
Определения DebugMonitor.c:138
TextWidget m_VersionValue
Определения DebugMonitor.c:8
bool IsVisible()
Определения DebugMonitor.c:182
Widget m_WidgetRoot
Определения DebugMonitor.c:5
void Hide()
Определения DebugMonitor.c:143
int GetTileFomFraction(float fraction)
Определения DebugMonitor.c:161
TextWidget m_FPSValue
Определения DebugMonitor.c:16
TextWidget m_DmgSourceValue
Определения DebugMonitor.c:11
void SetPosition(vector value)
Определения DebugMonitor.c:120
TextWidget m_CopyPositionInfo
Определения DebugMonitor.c:14
string CalculateMapTile(vector pos)
Определения DebugMonitor.c:148
TextWidget m_MapTileValue
Определения DebugMonitor.c:12
TextWidget m_HealthValue
Определения DebugMonitor.c:9
void DebugMonitor()
Определения DebugMonitor.c:23
TextWidget m_FPSMaxValue
Определения DebugMonitor.c:18
void SetFramerateText(TextWidget widget, float value)
Определения DebugMonitor.c:92
Определения EnMath.c:7
ScriptInvoker GetOnInputDeviceChanged()
Определения gameplay.c:851
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
Определения EnWidgets.c:220
Определения EnWidgets.c:190
proto int GetWorldSize()
proto string ToString(bool simple=true)
proto string ToString(bool beautify=true)
Vector to string.
Определения EnConvert.c:106
proto native CGame GetGame()
const int COLOR_RED
Определения constants.c:64
const int COLOR_YELLOW
Определения 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,...
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.
EInputDeviceType
Определения input.c:3