File size: 9,224 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
// *************************************************************************************
// ! PluginDayzPlayerDebugUI 
// *************************************************************************************
class HudDebugEventHandler extends ScriptedWidgetEventHandler
{
	HudDebug m_HudDebug;
	
	void HudDebugEventHandler( HudDebug hud_debug )
	{
		m_HudDebug = hud_debug;
	}
	
	HudDebug GetHudDebug()
	{
		return m_HudDebug;
	}
	
	override bool OnClick( Widget w, int x, int y, int button )
	{
		super.OnClick( w, x, y, button );
		return GetHudDebug().OnClick( w, x, y, button );
	}
	
	override bool OnFocus(Widget w, int x, int y)
	{
		//Print("OnFocus");
		return true;
	}
	
	override bool OnFocusLost(Widget w, int x, int y)
	{
		//Print("OnFocusLost");
		return true;
	}
	/*
	override bool OnMouseEnter(Widget w, int x, int y)
	{
		Print("OnMouseEnter");
		return true;
	}
	
	override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
	{
		Print("OnMouseLeaves");
		return true;
	}*/
	
	override bool OnMouseButtonDown(Widget w, int x, int y, int button)
	{
		//Print("OnMouseButtonDown");
		return true;
	}
	
	
	override bool OnSelect(Widget w, int x, int y)
	{
		//Print("OnSelect");
		return true;
	}
	override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
	{
		//Print("OnItemSelected");
		return true;
	}
	
	override bool OnModalResult(Widget w, int x, int y, int code, int result)
	{
		//Print("OnModalResult");
		return true;
	}
	
	override bool OnChange(Widget w, int x, int y, bool finished)
	{
		//Print("OnChange " + finished);
		super.OnChange( w, x, y, finished );
		return GetHudDebug().OnChange( w, x, y, finished );
	}
}

class HudDebug extends Hud
{
	static const int HUD_WIN_UNDEFINED			= 0;
	static const int HUD_WIN_CHAR_STATS			= 1;
	static const int HUD_WIN_CHAR_MODIFIERS		= 2;
	static const int HUD_WIN_CHAR_AGENTS		= 3;
	static const int HUD_WIN_CHAR_DEBUG			= 4;
	static const int HUD_WIN_CHAR_LEVELS		= 5;
	static const int HUD_WIN_CHAR_STOMACH		= 6;
	static const int HUD_WIN_VERSION			= 7;
	static const int HUD_WIN_TEMPERATURE		= 8;
	
	Widget							m_WgtRoot;
	Widget							m_Crosshair;
	ref array<ref HudDebugWinBase>	m_Panels;
	ref Timer						m_TimerUpdate;
	ref HudDebugEventHandler 		m_HudDebugHandler;
	ref HudDebugWinCharModifiers 	m_WinCharModifiers;
	ref HudDebugWinCharStats		m_WinCharStats;
	ref HudDebugWinCharAgents 		m_WinCharAgents;
	
	//============================================
	// HudDebug
	//============================================
	void HudDebug()
	{
	}

	//============================================
	// ~HudDebug
	//============================================
	void ~HudDebug()
	{
		delete m_WgtRoot;
		m_TimerUpdate.Stop();
	}
	
	//============================================
	// Init
	//============================================
	override void Init( Widget hud_panel_widget )
	{
		m_WgtRoot = hud_panel_widget;
		m_WgtRoot.Show( true );
		
		// Crosshair widget root
		m_Crosshair = m_WgtRoot.FindAnyWidget( "wdw_Crosshair" );
		
		m_Panels = new array<ref HudDebugWinBase>;
		
		// Register Window Character Stats
		m_WinCharStats = new HudDebugWinCharStats( m_WgtRoot.FindAnyWidget( "wdw_CharacterStats" ) );
		m_Panels.Insert( m_WinCharStats );
		
		// Register Window Character Stats
		HudDebugWinCharLevels win_char_levels = new HudDebugWinCharLevels( m_WgtRoot.FindAnyWidget( "wdw_CharacterLevels" ) );
		m_Panels.Insert( win_char_levels );
		
		// Register Window Chracter Modifiers
		m_WinCharModifiers = new HudDebugWinCharModifiers( m_WgtRoot.FindAnyWidget( "wdw_CharacterModifiers" ) );
		m_Panels.Insert( m_WinCharModifiers );
		
		// Register Window Chracter Agents
		m_WinCharAgents = new HudDebugWinCharAgents( m_WgtRoot.FindAnyWidget( "wdw_CharacterAgents" ) );
		m_Panels.Insert( m_WinCharAgents );
		
		// Register Window Chracter Debug
		HudDebugWinCharDebug win_char_debug = new HudDebugWinCharDebug( m_WgtRoot.FindAnyWidget( "wdw_CharacterDebug" ) );
		m_Panels.Insert( win_char_debug );
				
		// Register Window Chracter Debug
		HudDebugWinCharStomach win_char_stomach = new HudDebugWinCharStomach( m_WgtRoot.FindAnyWidget( "wdw_CharacterStomach" ) );
		m_Panels.Insert( win_char_stomach );
		
		// Register Window Version
		HudDebugWinVersion win_version = new HudDebugWinVersion( m_WgtRoot.FindAnyWidget( "wdw_Version" ) );
		m_Panels.Insert( win_version );
		
		// Register Window Temperature
		HudDebugWinTemperature win_temp = new HudDebugWinTemperature( m_WgtRoot.FindAnyWidget( "wdw_Temp" ) );
		m_Panels.Insert( win_temp );
		
		
		RefreshByLocalProfile();
		RefreshCrosshairVisibility();
		
		m_TimerUpdate = new Timer();
		m_TimerUpdate.Run( 1.0, this, "Update", NULL, true );
		
		//set ui event handler
		m_HudDebugHandler = new HudDebugEventHandler( this );
		m_WgtRoot.SetHandler( m_HudDebugHandler );
	}
	
	//============================================
	// Update
	//============================================
	override void Update( float timeslice )
	{
		for ( int i = 0; i < m_Panels.Count(); ++i )
		{
			if ( m_Panels.Get( i ).IsVisible() )
			{
				m_Panels.Get( i ).Update();
			}
		}
	}

	//============================================
	// SetPanetVisible
	//============================================
	void SetPanelVisible(int panel_type, bool visible)
	{
		if ( visible )
		{
			PanelShow( panel_type );
		}
		else
		{
			PanelHide( panel_type );
		}
	}
	
	//============================================
	// PanelShow
	//============================================
	void PanelShow(int panel_type)
	{
		for ( int i = 0; i < m_Panels.Count(); ++i )
		{
			HudDebugWinBase panel = m_Panels.Get( i );
			
			if ( panel.GetType() == panel_type )
			{
				panel.Show();
			}
		}
	}

	//============================================
	// PanelHide
	//============================================
	void PanelHide(int panel_type)
	{
		for ( int i = 0; i < m_Panels.Count(); ++i )
		{
			HudDebugWinBase panel = m_Panels.Get( i );
			
			if ( panel.GetType() == panel_type )
			{
				panel.Hide();
			}
		}
	}

	//============================================
	// RefreshCrosshairVisibility
	//============================================
	void RefreshCrosshairVisibility()
	{
		PluginConfigDebugProfile module_cfg_profile = PluginConfigDebugProfile.Cast( GetPlugin( PluginConfigDebugProfile ) );
		
		if ( module_cfg_profile )
		{
			PluginDeveloper modul_dev = PluginDeveloper.Cast( GetPlugin( PluginDeveloper ) );

			if ( modul_dev.IsEnabledFreeCamera() )
			{
				m_Crosshair.Show( module_cfg_profile.GetFreeCameraCrosshairVisible() );
			}
			else
			{
				m_Crosshair.Show( false );
			}
		}
	}

	
	//============================================
	// HideCrosshairVisibility
	//============================================
	void HideCrosshairVisibility()
	{
		PluginConfigDebugProfile module_cfg_profile = PluginConfigDebugProfile.Cast( GetPlugin( PluginConfigDebugProfile ) );
		
		if ( module_cfg_profile )
		{
			PluginDeveloper modul_dev = PluginDeveloper.Cast( GetPlugin( PluginDeveloper ) );

			if ( modul_dev.IsEnabledFreeCamera() )
			{
				m_Crosshair.Show( false );
			}
		}
	}

	//============================================
	// RefreshByLocalProfile
	//============================================
	void RefreshByLocalProfile()
	{
		PluginConfigDebugProfile module_cfg_profile = PluginConfigDebugProfile.Cast( GetPlugin( PluginConfigDebugProfile ) );
		
		if ( module_cfg_profile )
		{
			SetPanelVisible( HudDebug.HUD_WIN_CHAR_STATS, 		module_cfg_profile.GetCharacterStatsVisible() );
			SetPanelVisible( HudDebug.HUD_WIN_CHAR_LEVELS, 		module_cfg_profile.GetCharacterLevelsVisible() );
			SetPanelVisible( HudDebug.HUD_WIN_CHAR_MODIFIERS, 	module_cfg_profile.GetCharacterModifiersVisible() );
			SetPanelVisible( HudDebug.HUD_WIN_CHAR_AGENTS,	 	module_cfg_profile.GetCharacterAgentsVisible() );
			SetPanelVisible( HudDebug.HUD_WIN_CHAR_DEBUG, 		module_cfg_profile.GetCharacterDebugVisible() );
			SetPanelVisible( HudDebug.HUD_WIN_CHAR_STOMACH, 	module_cfg_profile.GetCharacterStomachVisible() );
			SetPanelVisible( HudDebug.HUD_WIN_VERSION, 			module_cfg_profile.GetVersionVisible() );
			SetPanelVisible( HudDebug.HUD_WIN_TEMPERATURE, 		module_cfg_profile.GetTempVisible() );
		}
	}
	
	//============================================
	// IsInitialized
	//============================================
	bool IsInitialized()
	{
		if ( m_WgtRoot == NULL )
		{
			return false;
		}
		
		return false;
	}	
	
	//============================================
	// OnClick
	//============================================
	bool OnClick( Widget w, int x, int y, int button )
	{	
		//send OnClick to HudDebugWinCharModifiers
		if ( m_WinCharModifiers )
		{
			if (m_WinCharModifiers.OnClick( w, x, y, button ))
				return true;
		}
		
		if ( m_WinCharAgents )
		{
			if (m_WinCharAgents.OnClick( w, x, y, button ))
				return true;
		}
		
		if ( m_WinCharStats )
		{
			if (m_WinCharStats.OnClick( w, x, y, button ))
				return true;
		}
		
		return false;
	}
	
	bool OnChange(Widget w, int x, int y, bool finished)
	{

		if ( m_WinCharStats )
		{
			if (m_WinCharStats.OnChange( w, x, y, finished ))
				return true;
		}
		return false;
	}
	
}