File size: 21,690 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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
class ScriptConsoleGeneralTab : ScriptConsoleTabBase
{
	static int 		m_ObjectsScope = 2;
	
	protected static float 	DEBUG_MAP_ZOOM = 1;
	protected static bool 	SHOW_OTHERS = 0;
	
	protected const string  	DEFAULT_POS_XYZ = "<1,2,3>";
	protected vector 			m_MapPos;
	protected bool 				m_PlayerPosRefreshBlocked;

	protected ref array<ref RemotePlayerStatDebug> m_PlayerDebugStats = new array<ref RemotePlayerStatDebug>;

	protected MissionGameplay		m_MissionGameplay;
	protected PluginDeveloper 		m_Developer;

	protected SliderWidget 			m_TimeSlider;
	protected ref Timer 			m_LateInit = new Timer();
	
	protected bool 					m_UpdatePlayerPositions;
	
	//-------------------------------- WIDGETS ---------------------------------------
	protected EditBoxWidget 		m_TeleportX;
	protected EditBoxWidget 		m_TeleportY;
	protected EditBoxWidget 		m_TeleportXYZ;
	protected EditBoxWidget 		m_DateYear;
	protected EditBoxWidget 		m_DateMonth;
	protected EditBoxWidget 		m_DateDay;
	protected EditBoxWidget 		m_DateHour;
	protected EditBoxWidget 		m_DateMinute;

	protected ButtonWidget 		m_LocationAddButton;
	protected ButtonWidget 		m_LocationRemoveButton;
	protected ButtonWidget 		m_TeleportButton;
	protected ButtonWidget 		m_ButtonCopyPos;
	protected ButtonWidget 		m_DiagDrawButton;
	protected ButtonWidget 		m_DiagToggleButton;

	protected CheckBoxWidget		m_LogsEnabled;
	protected CheckBoxWidget		m_HudDCharStats;
	protected CheckBoxWidget		m_HudDCharLevels;
	protected CheckBoxWidget		m_HudDCharStomach;
	protected CheckBoxWidget		m_HudDCharModifiers;
	protected CheckBoxWidget		m_HudDCharAgents;
	protected CheckBoxWidget		m_HudDCharDebug;
	protected CheckBoxWidget		m_HudDFreeCamCross;
	protected CheckBoxWidget		m_HudDVersion;
	
	protected CheckBoxWidget		m_ShowOthers;
	
	protected CheckBoxWidget		m_HudDTemperature;
	protected MapWidget 			m_DebugMapWidget;
	
	protected TextWidget	 		m_PlayerCurPos;
	protected TextWidget	 		m_MouseCurPos;
	protected TextWidget	 		m_PlayerMouseDiff;

	protected TextListboxWidget 	m_DiagToggleTextListbox;
	protected TextListboxWidget	m_PositionsListbox;
	protected TextListboxWidget 	m_DiagDrawmodeTextListbox;
	protected TextListboxWidget 	m_HelpTextListboxWidget;
	//-----------------------------------------------------------------------------------
	
	void ScriptConsoleGeneralTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
	{
		m_MissionGameplay			= MissionGameplay.Cast(GetGame().GetMission());
		
		m_DiagToggleTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("DiagToggle"));
		m_DiagToggleButton = ButtonWidget.Cast(root.FindAnyWidget("DiagToggleButton"));

		m_DiagDrawmodeTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("DiagDrawmode"));
		m_DiagDrawButton = ButtonWidget.Cast(root.FindAnyWidget("DiagDrawButton"));

		m_DebugMapWidget = MapWidget.Cast(root.FindAnyWidget("MapWidget"));
		
		m_PositionsListbox	= TextListboxWidget.Cast(root.FindAnyWidget("PositionsList"));
		m_TeleportButton	= ButtonWidget.Cast(root.FindAnyWidget("ButtonTeleport"));
		m_ButtonCopyPos		= ButtonWidget.Cast(root.FindAnyWidget("Button_CopyPos"));

		m_TeleportX			= EditBoxWidget.Cast(root.FindAnyWidget("TeleportX"));
		m_TeleportY			= EditBoxWidget.Cast(root.FindAnyWidget("TeleportY"));
		m_TeleportXYZ		= EditBoxWidget.Cast(root.FindAnyWidget("TeleportXYZ"));
		m_PlayerCurPos		= TextWidget.Cast(root.FindAnyWidget("PlayerPosLabel"));
		m_PlayerMouseDiff	= TextWidget.Cast(root.FindAnyWidget("PlayerMouseDiff"));
		m_MouseCurPos		= TextWidget.Cast(root.FindAnyWidget("MousePosLabel"));
		m_LogsEnabled		= CheckBoxWidget.Cast(root.FindAnyWidget("cbx_LogsEnabled"));
		m_HudDCharStats		= CheckBoxWidget.Cast(root.FindAnyWidget("cbx_CharacterStats"));
		m_HudDCharLevels	= CheckBoxWidget.Cast(root.FindAnyWidget("cbx_CharacterLevels"));
		m_HudDCharStomach	= CheckBoxWidget.Cast(root.FindAnyWidget("cbx_CharacterStomach"));
		m_HudDCharModifiers	= CheckBoxWidget.Cast(root.FindAnyWidget("cbx_CharacterModifiers"));
		m_HudDCharAgents	= CheckBoxWidget.Cast(root.FindAnyWidget("cbx_CharacterAgents"));
		m_HudDCharDebug		= CheckBoxWidget.Cast(root.FindAnyWidget("cbx_CharacterDebug"));
		m_HudDFreeCamCross	= CheckBoxWidget.Cast(root.FindAnyWidget("cbx_FreeCamCross"));
		m_HudDTemperature	= CheckBoxWidget.Cast(root.FindAnyWidget("cbx_Temp"));
		m_HudDVersion		= CheckBoxWidget.Cast(root.FindAnyWidget("cbx_Version"));
		
		m_LocationAddButton	= ButtonWidget.Cast(root.FindAnyWidget("AddButton"));
		//m_LocationAddButton.SetHandler(ToolTipEventHandler.GetInstance());
		m_LocationRemoveButton	= ButtonWidget.Cast(root.FindAnyWidget("RemoveButton"));

		m_TimeSlider		= SliderWidget.Cast(root.FindAnyWidget("TimeSlider"));
		m_DateYear			= EditBoxWidget.Cast(root.FindAnyWidget("DateYear"));
		m_DateMonth			= EditBoxWidget.Cast(root.FindAnyWidget("DateMonth"));
		m_DateDay			= EditBoxWidget.Cast(root.FindAnyWidget("DateDay"));
		m_DateHour			= EditBoxWidget.Cast(root.FindAnyWidget("DateHour"));
		m_DateMinute		= EditBoxWidget.Cast(root.FindAnyWidget("DateMinute"));
		
		
		m_ShowOthers		= CheckBoxWidget.Cast(root.FindAnyWidget("ShowOthersCheckbox"));

		m_HelpTextListboxWidget = TextListboxWidget.Cast(root.FindAnyWidget("HelpTextListboxWidget"));
		m_Developer					= PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
		
		Init();
		LateInit();
		
	}
	
	void ~ScriptConsoleGeneralTab()
	{
		DEBUG_MAP_ZOOM = m_DebugMapWidget.GetScale();

		PluginRemotePlayerDebugClient plugin_remote_client = PluginRemotePlayerDebugClient.Cast(GetPlugin(PluginRemotePlayerDebugClient));
		if (SHOW_OTHERS && plugin_remote_client && GetGame().GetPlayer())
			plugin_remote_client.RequestPlayerInfo(PlayerBase.Cast(GetGame().GetPlayer()), 0);
	}

	protected void Init()
	{
		
		
		
		// Update checkbox Character Values
		m_HudDCharStats.SetChecked(m_ConfigDebugProfile.GetCharacterStatsVisible());
		m_HudDCharLevels.SetChecked(m_ConfigDebugProfile.GetCharacterLevelsVisible());
		m_HudDCharStomach.SetChecked(m_ConfigDebugProfile.GetCharacterStomachVisible());
		m_HudDCharModifiers.SetChecked(m_ConfigDebugProfile.GetCharacterModifiersVisible());
		m_HudDCharAgents.SetChecked(m_ConfigDebugProfile.GetCharacterAgentsVisible());
		m_HudDCharDebug.SetChecked(m_ConfigDebugProfile.GetCharacterDebugVisible());
		m_HudDFreeCamCross.SetChecked(m_ConfigDebugProfile.GetFreeCameraCrosshairVisible());
		m_HudDVersion.SetChecked(m_ConfigDebugProfile.GetVersionVisible());
		m_HudDTemperature.SetChecked(m_ConfigDebugProfile.GetTempVisible());
		

		m_LogsEnabled.SetChecked(m_ConfigDebugProfile.GetLogsEnabled());
		
		TStringArray diag_names = new TStringArray;
		GetGame().GetDiagModeNames(diag_names);
		int i;
		for (i = 0; i < diag_names.Count(); i++)
		{
			m_DiagToggleTextListbox.AddItem(diag_names.Get(i), NULL, 0);
		}

		GetGame().GetDiagDrawModeNames(diag_names);
		for (i = 0; i < diag_names.Count(); i++)
		{
			m_DiagDrawmodeTextListbox.AddItem(diag_names.Get(i), NULL, 0);
		}
		RefreshLocations();
		
		UpdateHudDebugSetting();

		if (GetGame().GetPlayer())
		{
			m_DebugMapWidget.SetScale(DEBUG_MAP_ZOOM);
			m_DebugMapWidget.SetMapPos(GetGame().GetPlayer().GetWorldPosition());
		}
		m_TeleportXYZ.SetText(DEFAULT_POS_XYZ);
		
		m_LateInit.Run(0.05, this, "LateInit", null, false);
		
		int year,month,day,hour,minute;
		GetGame().GetWorld().GetDate(year,month, day, hour, minute);
		RefreshDateWidgets(year,month, day, hour, minute);
	}
	
	
	void RefreshDateWidgets(int year, int month, int day, int hour, int minute)
	{
		float time01 = Math.InverseLerp(0,60*24 - 1, (hour * 60) + minute);
		m_DateYear.SetText(year.ToString());
		m_DateMonth.SetText(month.ToString());
		m_DateDay.SetText(day.ToString());
		m_DateHour.SetText(hour.ToString());
		m_DateMinute.SetText(minute.ToString());
		m_TimeSlider.SetCurrent(time01 * 100);
	}
	
	bool IsLocationNameAvailable(string name)
	{
		int count = m_PositionsListbox.GetNumItems();
		for (int i = 0; i < count; i++)
		{
			LocationParams data;
			m_PositionsListbox.GetItemData(i,0,data);
			if (data.param1 == name)
				return false;
		}
		return true;
	}

	
	
	
	void LateInit()
	{
		m_ShowOthers.SetChecked(SHOW_OTHERS);
		
		if (m_ConfigDebugProfile)
		{
			int prevRow = m_ConfigDebugProfile.GetSpawnLocIndex();
			if (prevRow < m_PositionsListbox.GetNumItems())
				m_PositionsListbox.SelectRow(prevRow);
			
		}
		PluginRemotePlayerDebugClient plugin_remote_client = PluginRemotePlayerDebugClient.Cast(GetPlugin(PluginRemotePlayerDebugClient));
		if (SHOW_OTHERS && plugin_remote_client && GetGame().GetPlayer())
		{
			plugin_remote_client.RequestPlayerInfo(PlayerBase.Cast(GetGame().GetPlayer()), 1);
			m_UpdatePlayerPositions = 1;
		}
		
	}
	
	void Teleport(PlayerBase player, vector position)
	{
		if (position[1] == 0)
			position[1] = GetGame().SurfaceY(position[0], position[2]);
		m_Developer.Teleport(player, position);
	}
	
	void RefreshLocations()
	{
		m_PositionsListbox.ClearItems();
		
		array<ref LocationParams> locData = new array<ref LocationParams>;
		m_ConfigDebugProfile.GetLocationsData(locData,true);
		m_ConfigDebugProfileFixed.GetLocationsData(locData,false);
		foreach (LocationParams dta: locData)
		{
			string name = dta.param1;
			if (!dta.param2)
			{
				name = "[" + name + "]";
			}
			m_PositionsListbox.AddItem(name,dta,0);
		}
	}

	
	string GetCurrentLocationName()
	{
		string name;
		LocationParams prms;
		GetCurrentPositionData(prms);
		if (prms)
			name =prms.param1;
		return name;
	}
	vector GetCurrentLocationPos()
	{
		LocationParams prms;
		GetCurrentPositionData(prms);
		if (prms)
			return prms.param3;
		else 
			return vector.Zero;
	}
	
	void GetCurrentPositionData(out LocationParams data)
	{
		if (m_PositionsListbox.GetSelectedRow() != -1)
		{
			m_PositionsListbox.GetItemData(m_PositionsListbox.GetSelectedRow(), 0, data);
		}
	}
	
	bool IsCurrentPositionCustom()
	{
		LocationParams prms;
		GetCurrentPositionData(prms);
		if (prms)
			return prms.param2;
		else 
			return false;
	}
	
	int GetCurrentPositionIndex()
	{
		return m_PositionsListbox.GetSelectedRow();
	}
	
	bool IsCurrentPositionValid()
	{
		return (m_PositionsListbox.GetSelectedRow() != -1);
	}
	
	void UpdateHudDebugSetting();
	
	void RefreshPlayerPosEditBoxes()
	{
		if (!GetGame().GetPlayer())
		{
			return;
		}

		vector playerPos = GetGame().GetPlayer().GetPosition();
		SetMapPos(playerPos);
	}

	void UpdateTime(bool slider_used)
	{
		Param5<int,int,int,int,int> p5 = new Param5<int,int,int,int,int>(0,0,0,0,0);
		int year, month, day, hour, minute;
		
		year = m_DateYear.GetText().ToInt();
		month = m_DateMonth.GetText().ToInt();
		day = m_DateDay.GetText().ToInt();
		
		if (slider_used)
		{
			int time_minutes = Math.Lerp(0, (24*60) - 1, m_TimeSlider.GetCurrent()/100);
			hour = time_minutes / 60;
			minute = time_minutes % 60;
		}
		else
		{
			hour = m_DateHour.GetText().ToInt();
			minute = m_DateMinute.GetText().ToInt();
		}

		p5.param1 = year;
		p5.param2 = month;
		p5.param3 = day;
		p5.param4 = hour;
		p5.param5 = minute;
		
		RefreshDateWidgets(year, month, day, hour, minute);
		GetGame().GetWorld().SetDate(year, month, day, hour, minute);

		if (GetGame().GetPlayer())
		{
			GetGame().GetPlayer().RPCSingleParam(ERPCs.DEV_RPC_SET_TIME, p5, true);
		}
	}
	
	
	void UpdateMousePos()
	{
		int x,y;
		GetMousePos(x,y);
		vector mousePos, worldPos;
		mousePos[0] = x;
		mousePos[1] = y;
		worldPos = m_DebugMapWidget.ScreenToMap(mousePos);
		worldPos[1] = GetGame().SurfaceY(worldPos[0], worldPos[2]);
		
		if (m_MouseCurPos)
		{
			m_MouseCurPos.SetText("Mouse: "+ MiscGameplayFunctions.TruncateToS(worldPos[0]) +", "+ MiscGameplayFunctions.TruncateToS(worldPos[1]) +", "+ MiscGameplayFunctions.TruncateToS(worldPos[2]));
		}
		if (m_PlayerMouseDiff && GetGame().GetPlayer())
		{
			vector playerPos = GetGame().GetPlayer().GetWorldPosition();
			//playerPos[1] = 0;
			float dst = (worldPos - playerPos).Length();

			m_PlayerMouseDiff.SetText("Distance: " + MiscGameplayFunctions.TruncateToS(dst));
		}
	}


	void SetMapPos(vector pos)
	{
		m_MapPos = pos;
		m_PlayerCurPos.SetText("Pos: "+  MiscGameplayFunctions.TruncateToS(pos[0]) +", "+ MiscGameplayFunctions.TruncateToS(pos[1]) +", "+ MiscGameplayFunctions.TruncateToS(pos[2]));
	}
	
	vector GetMapPos()
	{
		return m_MapPos;
	}
	
	override bool OnMouseButtonDown(Widget w, int x, int y, int button)
	{
		super.OnMouseButtonDown(w,x,y,button);
		
		if (w ==  m_DebugMapWidget)
		{
			if (button == 0)
			{
				m_PlayerPosRefreshBlocked = true;
				int mouseX, mouseY;
				GetMousePos(mouseX,mouseY);
				vector mousePos, worldPos;
				mousePos[0] = mouseX;
				mousePos[1] = mouseY;
				worldPos = m_DebugMapWidget.ScreenToMap(mousePos);
				worldPos[1] = GetGame().SurfaceY(worldPos[0], worldPos[2]);
				
				SetMapPos(worldPos);
			}
			else if (button == 1 && GetGame().GetPlayer())
			{
				SetMapPos(GetGame().GetPlayer().GetWorldPosition());
			}
		}
		return true;
	}
	

	override bool OnKeyDown(Widget w, int x, int y, int key)
	{
		super.OnKeyDown(w, x, y, key);
		return false;
	}
	
	override bool OnChange(Widget w, int x, int y, bool finished)
	{
		super.OnChange(w, x, y, finished);
		
		if (w == m_ShowOthers && GetGame().GetPlayer())
		{
			PluginRemotePlayerDebugClient plugin_remote_client = PluginRemotePlayerDebugClient.Cast(GetPlugin(PluginRemotePlayerDebugClient));
			if (m_ShowOthers.IsChecked())
			{
				plugin_remote_client.RequestPlayerInfo(PlayerBase.Cast(GetGame().GetPlayer()), 1);
				m_UpdatePlayerPositions = 1;
				SHOW_OTHERS = true;
			}
			else
			{
				plugin_remote_client.RequestPlayerInfo(PlayerBase.Cast(GetGame().GetPlayer()), 0);
				m_UpdatePlayerPositions = 0;
				SHOW_OTHERS = false;
			}
			return true;
		}
		else if (w == m_TimeSlider || w == m_DateDay || w == m_DateYear || w == m_DateMonth || w == m_DateHour || w == m_DateMinute)
		{
			UpdateTime(w == m_TimeSlider);
			return true;
		}
		return false;
	}
	
	override bool OnItemSelected(Widget w, int x, int y, int row, int  column,	int  oldRow, int  oldColumn)
	{
		super.OnItemSelected(w, x, y, row, column, oldRow, oldColumn);
		if (w == m_PositionsListbox)
		{
			vector position = GetCurrentLocationPos();
			m_TeleportX.SetText(position[0].ToString());
			m_TeleportY.SetText(position[2].ToString());
			m_TeleportXYZ.SetText(position.ToString());
			if (IsCurrentPositionValid())
			{
				m_ConfigDebugProfile.SetSpawnLocIndex(GetCurrentPositionIndex());
			}
			
			return true;
		}
		return false;
	}
	
	override bool OnDoubleClick(Widget w, int x, int y, int button)
	{
		super.OnDoubleClick(w, x, y, button);
		PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
		
		if (w ==  m_DebugMapWidget)
		{
			vector screen_to_map = m_DebugMapWidget.ScreenToMap(Vector(x,y, 0));
			float pos_y_a = GetGame().SurfaceY(screen_to_map[0], screen_to_map[2]);
			float pos_y_b = GetGame().SurfaceRoadY(screen_to_map[0], screen_to_map[2]);
			float pos_y = Math.Max(pos_y_a, pos_y_b);
			screen_to_map[1] = pos_y;
			m_Developer.Teleport(player, screen_to_map);
			return true;
		}
		
		if (w == m_PositionsListbox)
		{
			vector position = GetCurrentLocationPos();
			Teleport(player, position);
			return true;
		}
		
		if (w == m_TeleportXYZ)
		{
			EditBoxWidget.Cast(w).SetText("");
			return true;
		}
		return false;
	}
	
	override bool OnClick(Widget w, int x, int y, int button)
	{
		super.OnClick(w, x, y, button);
		
		int i;
		PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());

		PluginDeveloper module_dev = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));

		if (w == m_PositionsListbox)
		{
			
			vector position = GetCurrentLocationPos();
			
			m_TeleportX.SetText(position[0].ToString());
			m_TeleportY.SetText(position[2].ToString());
			
			if (IsCurrentPositionValid())
			{
				m_ConfigDebugProfile.SetSpawnLocIndex(GetCurrentPositionIndex());
			}
			
			return true;
		}
		else if (w == m_TeleportButton)
		{
			float pos_x = m_TeleportX.GetText().ToFloat();
			float pos_z = m_TeleportY.GetText().ToFloat();
			float pos_y = GetGame().SurfaceY(pos_x, pos_z);
			vector v = Vector(pos_x, pos_y, pos_z);
			if (m_TeleportXYZ.GetText() != "" && m_TeleportXYZ.GetText() != DEFAULT_POS_XYZ)
			{
				string pos = m_TeleportXYZ.GetText();
				v = pos.BeautifiedToVector();
			}
			Teleport(player, v);
			return true;
		}
		else if (w == m_ButtonCopyPos)
		{
			GetGame().CopyToClipboard(GetMapPos().ToString());
			return true;
		}
		else if (w == m_LogsEnabled)
		{
			//Log("m_LogsEnabled: "+ToString(m_LogsEnabled.IsChecked()));

			if (m_ConfigDebugProfile)
			{
				m_ConfigDebugProfile.SetLogsEnabled(m_LogsEnabled.IsChecked());
				LogManager.SetLogsEnabled(m_LogsEnabled.IsChecked());
			}

			return true;
		}
		else if (w == m_HudDCharStats)
		{
			if (m_ConfigDebugProfile)
			{
				m_ConfigDebugProfile.SetCharacterStatsVisible(m_HudDCharStats.IsChecked());
			}

			// Refresh UI by new settings
			m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();

			return true;
		}
		else if (w == m_HudDCharLevels)
		{
			if (m_ConfigDebugProfile)
			{
				m_ConfigDebugProfile.SetCharacterLevelsVisible(m_HudDCharLevels.IsChecked());
			}

			// Refresh UI by new settings
			m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();

			return true;
		}
		else if (w == m_HudDCharStomach)
		{
			if (m_ConfigDebugProfile)
			{
				m_ConfigDebugProfile.SetCharacterStomachVisible(m_HudDCharStomach.IsChecked());
			}

			// Refresh UI by new settings
			m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();

			return true;
		}
		else if (w == m_HudDVersion)
		{
			if (m_ConfigDebugProfile)
			{
				m_ConfigDebugProfile.SetVersionVisible(m_HudDVersion.IsChecked());
			}

			// Refresh UI by new settings
			m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();

			return true;
		}
		else if (w == m_HudDTemperature)
		{
			if (m_ConfigDebugProfile)
			{
				m_ConfigDebugProfile.SetTempVisible(m_HudDTemperature.IsChecked());
			}

			// Refresh UI by new settings
			m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();

			return true;
		}
		else if (w == m_HudDCharModifiers)
		{
			if (m_ConfigDebugProfile)
			{
				m_ConfigDebugProfile.SetCharacterModifiersVisible(m_HudDCharModifiers.IsChecked());
			}

			// Refresh UI by new settings
			m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();

			return true;
		}
		else if (w == m_HudDCharAgents)
		{
			if (m_ConfigDebugProfile)
			{
				m_ConfigDebugProfile.SetCharacterAgentsVisible(m_HudDCharAgents.IsChecked());
			}

			// Refresh UI by new settings
			m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();

			return true;
		}
		else if (w == m_HudDCharDebug)
		{
			if (m_ConfigDebugProfile)
			{
				m_ConfigDebugProfile.SetCharacterDebugVisible(m_HudDCharDebug.IsChecked());
			}

			// Refresh UI by new settings
			m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();

			return true;
		}
		else if (w == m_HudDFreeCamCross)
		{
			if (m_ConfigDebugProfile)
			{
				m_ConfigDebugProfile.SetFreeCameraCrosshairVisible(m_HudDFreeCamCross.IsChecked());
			}

			// Refresh UI by new settings
			m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();

			GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(GetGame().GetMission().RefreshCrosshairVisibility);

			return true;
		}
		
		else if (w == m_DiagToggleButton)
		{
			int toggle_row_index = m_DiagToggleTextListbox.GetSelectedRow();
			bool toggle_state = GetGame().GetDiagModeEnable(toggle_row_index);
			GetGame().SetDiagModeEnable(toggle_row_index, !toggle_state);
			return true;
		}
		else if (w == m_DiagDrawButton)
		{
			int draw_row_index = m_DiagDrawmodeTextListbox.GetSelectedRow();
			GetGame().SetDiagDrawMode(draw_row_index);
			return true;
		}
		// TOUCHED THIS
		else if (w == m_LocationAddButton)
		{
			ScriptConsoleAddLocation menu = ScriptConsoleAddLocation.Cast(g_Game.GetUIManager().EnterScriptedMenu(MENU_LOC_ADD, m_ScriptConsole));
			menu.SetPosition(GetMapPos());
			return true;
		}
		else if (w == m_LocationRemoveButton)
		{
			m_ConfigDebugProfile.CustomLocationsRemove(GetCurrentLocationName());
			RefreshLocations();
			return true;
		}
		return false;
	}
	
	override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
	{
		super.OnRPCEx(rpc_type, ctx);
		#ifdef DIAG_DEVELOPER
		switch (rpc_type)
		{
			case ERPCs.DEV_PLAYER_DEBUG_DATA:
			{
				ctx.Read(m_PlayerDebugStats);
				break;
			}
		}
		#endif
	}
	
	override void Update(float timeslice)
	{
		super.Update(timeslice);
		
		PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
		
		m_DebugMapWidget.ClearUserMarks();

		if (m_UpdatePlayerPositions)
		{
			foreach (RemotePlayerStatDebug rpd: m_PlayerDebugStats)
			{
				if (rpd.m_Player != player)
				{
					vector dir = rpd.m_Pos - player.GetWorldPosition();
					dir[1] = 0;
					string dist = ((int)dir.Length()).ToString();
					string text = rpd.m_Name + " " +dist +"m.";
					m_DebugMapWidget.AddUserMark(rpd.m_Pos, text , COLOR_BLUE,"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
				}
			}
		}
		if (player)
		{
			vector playerPos = player.GetWorldPosition();
			m_DebugMapWidget.AddUserMark(playerPos,"You", COLOR_RED,"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
			if (playerPos != GetMapPos())
				m_DebugMapWidget.AddUserMark(GetMapPos(),"Pos", COLOR_BLUE,"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
		}
		UpdateMousePos();
		if (!m_PlayerPosRefreshBlocked)
			RefreshPlayerPosEditBoxes();
		
		
		foreach (MapMarker marker: ScriptConsole.m_MarkedEntities)
		{
			m_DebugMapWidget.AddUserMark(marker.GetMarkerPos(),marker.GetMarkerText(), marker.GetMarkerColor(), MapMarkerTypes.GetMarkerTypeFromID(marker.GetMarkerIcon()));
		}
	}
}