3 static int m_ObjectsScope = 2;
5 protected static float DEBUG_MAP_ZOOM = 1;
6 protected static bool SHOW_OTHERS = 0;
8 protected const string DEFAULT_POS_XYZ =
"<1,2,3>";
10 protected bool m_PlayerPosRefreshBlocked;
14 protected MissionGameplay m_MissionGameplay;
15 protected PluginDeveloper m_Developer;
17 protected SliderWidget m_TimeSlider;
20 protected bool m_UpdatePlayerPositions;
32 protected ButtonWidget m_LocationAddButton;
33 protected ButtonWidget m_LocationRemoveButton;
34 protected ButtonWidget m_TeleportButton;
35 protected ButtonWidget m_ButtonCopyPos;
36 protected ButtonWidget m_DiagDrawButton;
37 protected ButtonWidget m_DiagToggleButton;
39 protected CheckBoxWidget m_LogsEnabled;
40 protected CheckBoxWidget m_HudDCharStats;
41 protected CheckBoxWidget m_HudDCharLevels;
42 protected CheckBoxWidget m_HudDCharStomach;
43 protected CheckBoxWidget m_HudDCharModifiers;
44 protected CheckBoxWidget m_HudDCharAgents;
45 protected CheckBoxWidget m_HudDCharDebug;
46 protected CheckBoxWidget m_HudDFreeCamCross;
47 protected CheckBoxWidget m_HudDVersion;
49 protected CheckBoxWidget m_ShowOthers;
51 protected CheckBoxWidget m_HudDTemperature;
58 protected TextListboxWidget m_DiagToggleTextListbox;
59 protected TextListboxWidget m_PositionsListbox;
60 protected TextListboxWidget m_DiagDrawmodeTextListbox;
61 protected TextListboxWidget m_HelpTextListboxWidget;
66 m_MissionGameplay = MissionGameplay.Cast(
GetGame().GetMission());
68 m_DiagToggleTextListbox = TextListboxWidget.Cast(root.FindAnyWidget(
"DiagToggle"));
69 m_DiagToggleButton = ButtonWidget.Cast(root.FindAnyWidget(
"DiagToggleButton"));
71 m_DiagDrawmodeTextListbox = TextListboxWidget.Cast(root.FindAnyWidget(
"DiagDrawmode"));
72 m_DiagDrawButton = ButtonWidget.Cast(root.FindAnyWidget(
"DiagDrawButton"));
74 m_DebugMapWidget =
MapWidget.Cast(root.FindAnyWidget(
"MapWidget"));
76 m_PositionsListbox = TextListboxWidget.Cast(root.FindAnyWidget(
"PositionsList"));
77 m_TeleportButton = ButtonWidget.Cast(root.FindAnyWidget(
"ButtonTeleport"));
78 m_ButtonCopyPos = ButtonWidget.Cast(root.FindAnyWidget(
"Button_CopyPos"));
80 m_TeleportX =
EditBoxWidget.Cast(root.FindAnyWidget(
"TeleportX"));
81 m_TeleportY =
EditBoxWidget.Cast(root.FindAnyWidget(
"TeleportY"));
82 m_TeleportXYZ =
EditBoxWidget.Cast(root.FindAnyWidget(
"TeleportXYZ"));
83 m_PlayerCurPos =
TextWidget.Cast(root.FindAnyWidget(
"PlayerPosLabel"));
84 m_PlayerMouseDiff =
TextWidget.Cast(root.FindAnyWidget(
"PlayerMouseDiff"));
85 m_MouseCurPos =
TextWidget.Cast(root.FindAnyWidget(
"MousePosLabel"));
86 m_LogsEnabled = CheckBoxWidget.Cast(root.FindAnyWidget(
"cbx_LogsEnabled"));
87 m_HudDCharStats = CheckBoxWidget.Cast(root.FindAnyWidget(
"cbx_CharacterStats"));
88 m_HudDCharLevels = CheckBoxWidget.Cast(root.FindAnyWidget(
"cbx_CharacterLevels"));
89 m_HudDCharStomach = CheckBoxWidget.Cast(root.FindAnyWidget(
"cbx_CharacterStomach"));
90 m_HudDCharModifiers = CheckBoxWidget.Cast(root.FindAnyWidget(
"cbx_CharacterModifiers"));
91 m_HudDCharAgents = CheckBoxWidget.Cast(root.FindAnyWidget(
"cbx_CharacterAgents"));
92 m_HudDCharDebug = CheckBoxWidget.Cast(root.FindAnyWidget(
"cbx_CharacterDebug"));
93 m_HudDFreeCamCross = CheckBoxWidget.Cast(root.FindAnyWidget(
"cbx_FreeCamCross"));
94 m_HudDTemperature = CheckBoxWidget.Cast(root.FindAnyWidget(
"cbx_Temp"));
95 m_HudDVersion = CheckBoxWidget.Cast(root.FindAnyWidget(
"cbx_Version"));
97 m_LocationAddButton = ButtonWidget.Cast(root.FindAnyWidget(
"AddButton"));
99 m_LocationRemoveButton = ButtonWidget.Cast(root.FindAnyWidget(
"RemoveButton"));
101 m_TimeSlider = SliderWidget.Cast(root.FindAnyWidget(
"TimeSlider"));
102 m_DateYear =
EditBoxWidget.Cast(root.FindAnyWidget(
"DateYear"));
103 m_DateMonth =
EditBoxWidget.Cast(root.FindAnyWidget(
"DateMonth"));
104 m_DateDay =
EditBoxWidget.Cast(root.FindAnyWidget(
"DateDay"));
105 m_DateHour =
EditBoxWidget.Cast(root.FindAnyWidget(
"DateHour"));
106 m_DateMinute =
EditBoxWidget.Cast(root.FindAnyWidget(
"DateMinute"));
109 m_ShowOthers = CheckBoxWidget.Cast(root.FindAnyWidget(
"ShowOthersCheckbox"));
111 m_HelpTextListboxWidget = TextListboxWidget.Cast(root.FindAnyWidget(
"HelpTextListboxWidget"));
112 m_Developer = PluginDeveloper.Cast(
GetPlugin(PluginDeveloper));
121 DEBUG_MAP_ZOOM = m_DebugMapWidget.GetScale();
123 PluginRemotePlayerDebugClient plugin_remote_client = PluginRemotePlayerDebugClient.Cast(
GetPlugin(PluginRemotePlayerDebugClient));
128 protected void Init()
148 GetGame().GetDiagModeNames(diag_names);
150 for (i = 0; i < diag_names.Count(); i++)
152 m_DiagToggleTextListbox.AddItem(diag_names.Get(i), NULL, 0);
155 GetGame().GetDiagDrawModeNames(diag_names);
156 for (i = 0; i < diag_names.Count(); i++)
158 m_DiagDrawmodeTextListbox.AddItem(diag_names.Get(i), NULL, 0);
162 UpdateHudDebugSetting();
166 m_DebugMapWidget.SetScale(DEBUG_MAP_ZOOM);
169 m_TeleportXYZ.SetText(DEFAULT_POS_XYZ);
171 m_LateInit.Run(0.05,
this,
"LateInit",
null,
false);
173 int year,month,day,hour,minute;
174 GetGame().GetWorld().GetDate(year,month, day, hour, minute);
175 RefreshDateWidgets(year,month, day, hour, minute);
179 void RefreshDateWidgets(
int year,
int month,
int day,
int hour,
int minute)
181 float time01 =
Math.InverseLerp(0,60*24 - 1, (hour * 60) + minute);
182 m_DateYear.SetText(year.ToString());
183 m_DateMonth.SetText(month.ToString());
184 m_DateDay.SetText(day.ToString());
185 m_DateHour.SetText(hour.ToString());
186 m_DateMinute.SetText(minute.ToString());
187 m_TimeSlider.SetCurrent(time01 * 100);
190 bool IsLocationNameAvailable(
string name)
192 int count = m_PositionsListbox.GetNumItems();
193 for (
int i = 0; i < count; i++)
196 m_PositionsListbox.GetItemData(i,0,data);
197 if (data.param1 ==
name)
208 m_ShowOthers.SetChecked(SHOW_OTHERS);
213 if (prevRow < m_PositionsListbox.GetNumItems())
214 m_PositionsListbox.SelectRow(prevRow);
217 PluginRemotePlayerDebugClient plugin_remote_client = PluginRemotePlayerDebugClient.Cast(
GetPlugin(PluginRemotePlayerDebugClient));
221 m_UpdatePlayerPositions = 1;
228 if (position[1] == 0)
229 position[1] =
GetGame().SurfaceY(position[0], position[2]);
230 m_Developer.Teleport(player, position);
233 void RefreshLocations()
235 m_PositionsListbox.ClearItems();
239 m_ConfigDebugProfileFixed.GetLocationsData(locData,
false);
242 string name = dta.param1;
247 m_PositionsListbox.AddItem(
name,dta,0);
252 string GetCurrentLocationName()
256 GetCurrentPositionData(prms);
261 vector GetCurrentLocationPos()
264 GetCurrentPositionData(prms);
273 if (m_PositionsListbox.GetSelectedRow() != -1)
275 m_PositionsListbox.GetItemData(m_PositionsListbox.GetSelectedRow(), 0, data);
279 bool IsCurrentPositionCustom()
282 GetCurrentPositionData(prms);
289 int GetCurrentPositionIndex()
291 return m_PositionsListbox.GetSelectedRow();
294 bool IsCurrentPositionValid()
296 return (m_PositionsListbox.GetSelectedRow() != -1);
299 void UpdateHudDebugSetting();
301 void RefreshPlayerPosEditBoxes()
309 SetMapPos(playerPos);
312 void UpdateTime(
bool slider_used)
314 Param5<int,int,int,int,int> p5 =
new Param5<int,int,int,int,int>(0,0,0,0,0);
315 int year, month, day, hour, minute;
317 year = m_DateYear.GetText().ToInt();
318 month = m_DateMonth.GetText().ToInt();
319 day = m_DateDay.GetText().ToInt();
323 int time_minutes =
Math.Lerp(0, (24*60) - 1, m_TimeSlider.GetCurrent()/100);
324 hour = time_minutes / 60;
325 minute = time_minutes % 60;
329 hour = m_DateHour.GetText().ToInt();
330 minute = m_DateMinute.GetText().ToInt();
339 RefreshDateWidgets(year, month, day, hour, minute);
340 GetGame().GetWorld().SetDate(year, month, day, hour, minute);
344 GetGame().GetPlayer().RPCSingleParam(
ERPCs.DEV_RPC_SET_TIME, p5,
true);
349 void UpdateMousePos()
353 vector mousePos, worldPos;
356 worldPos = m_DebugMapWidget.ScreenToMap(mousePos);
357 worldPos[1] =
GetGame().SurfaceY(worldPos[0], worldPos[2]);
361 m_MouseCurPos.SetText(
"Mouse: "+ MiscGameplayFunctions.TruncateToS(worldPos[0]) +
", "+ MiscGameplayFunctions.TruncateToS(worldPos[1]) +
", "+ MiscGameplayFunctions.TruncateToS(worldPos[2]));
367 float dst = (worldPos - playerPos).Length();
369 m_PlayerMouseDiff.SetText(
"Distance: " + MiscGameplayFunctions.TruncateToS(dst));
374 void SetMapPos(
vector pos)
377 m_PlayerCurPos.SetText(
"Pos: "+ MiscGameplayFunctions.TruncateToS(pos[0]) +
", "+ MiscGameplayFunctions.TruncateToS(pos[1]) +
", "+ MiscGameplayFunctions.TruncateToS(pos[2]));
385 override bool OnMouseButtonDown(
Widget w,
int x,
int y,
int button)
387 super.OnMouseButtonDown(w,
x,
y,button);
389 if (w == m_DebugMapWidget)
393 m_PlayerPosRefreshBlocked =
true;
396 vector mousePos, worldPos;
397 mousePos[0] = mouseX;
398 mousePos[1] = mouseY;
399 worldPos = m_DebugMapWidget.ScreenToMap(mousePos);
400 worldPos[1] =
GetGame().SurfaceY(worldPos[0], worldPos[2]);
413 override bool OnKeyDown(
Widget w,
int x,
int y,
int key)
415 super.OnKeyDown(w,
x,
y, key);
419 override bool OnChange(
Widget w,
int x,
int y,
bool finished)
421 super.OnChange(w,
x,
y, finished);
425 PluginRemotePlayerDebugClient plugin_remote_client = PluginRemotePlayerDebugClient.Cast(
GetPlugin(PluginRemotePlayerDebugClient));
426 if (m_ShowOthers.IsChecked())
429 m_UpdatePlayerPositions = 1;
435 m_UpdatePlayerPositions = 0;
440 else if (w == m_TimeSlider || w == m_DateDay || w == m_DateYear || w == m_DateMonth || w == m_DateHour || w == m_DateMinute)
442 UpdateTime(w == m_TimeSlider);
448 override bool OnItemSelected(
Widget w,
int x,
int y,
int row,
int column,
int oldRow,
int oldColumn)
450 super.OnItemSelected(w,
x,
y, row, column, oldRow, oldColumn);
451 if (w == m_PositionsListbox)
453 vector position = GetCurrentLocationPos();
454 m_TeleportX.SetText(position[0].
ToString());
455 m_TeleportY.SetText(position[2].
ToString());
456 m_TeleportXYZ.SetText(position.ToString());
457 if (IsCurrentPositionValid())
467 override bool OnDoubleClick(
Widget w,
int x,
int y,
int button)
469 super.OnDoubleClick(w,
x,
y, button);
472 if (w == m_DebugMapWidget)
474 vector screen_to_map = m_DebugMapWidget.ScreenToMap(
Vector(
x,
y, 0));
475 float pos_y_a =
GetGame().SurfaceY(screen_to_map[0], screen_to_map[2]);
476 float pos_y_b =
GetGame().SurfaceRoadY(screen_to_map[0], screen_to_map[2]);
477 float pos_y =
Math.Max(pos_y_a, pos_y_b);
478 screen_to_map[1] = pos_y;
479 m_Developer.Teleport(player, screen_to_map);
483 if (w == m_PositionsListbox)
485 vector position = GetCurrentLocationPos();
486 Teleport(player, position);
490 if (w == m_TeleportXYZ)
498 override bool OnClick(
Widget w,
int x,
int y,
int button)
500 super.OnClick(w,
x,
y, button);
505 PluginDeveloper module_dev = PluginDeveloper.Cast(
GetPlugin(PluginDeveloper));
507 if (w == m_PositionsListbox)
510 vector position = GetCurrentLocationPos();
512 m_TeleportX.SetText(position[0].
ToString());
513 m_TeleportY.SetText(position[2].
ToString());
515 if (IsCurrentPositionValid())
522 else if (w == m_TeleportButton)
524 float pos_x = m_TeleportX.GetText().ToFloat();
525 float pos_z = m_TeleportY.GetText().ToFloat();
526 float pos_y =
GetGame().SurfaceY(pos_x, pos_z);
528 if (m_TeleportXYZ.GetText() !=
"" && m_TeleportXYZ.GetText() != DEFAULT_POS_XYZ)
530 string pos = m_TeleportXYZ.GetText();
531 v = pos.BeautifiedToVector();
536 else if (w == m_ButtonCopyPos)
541 else if (w == m_LogsEnabled)
548 LogManager.SetLogsEnabled(m_LogsEnabled.IsChecked());
553 else if (w == m_HudDCharStats)
561 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
565 else if (w == m_HudDCharLevels)
573 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
577 else if (w == m_HudDCharStomach)
585 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
589 else if (w == m_HudDVersion)
597 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
601 else if (w == m_HudDTemperature)
609 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
613 else if (w == m_HudDCharModifiers)
621 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
625 else if (w == m_HudDCharAgents)
633 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
637 else if (w == m_HudDCharDebug)
645 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
649 else if (w == m_HudDFreeCamCross)
657 m_MissionGameplay.GetHudDebug().RefreshByLocalProfile();
664 else if (w == m_DiagToggleButton)
666 int toggle_row_index = m_DiagToggleTextListbox.GetSelectedRow();
667 bool toggle_state =
GetGame().GetDiagModeEnable(toggle_row_index);
668 GetGame().SetDiagModeEnable(toggle_row_index, !toggle_state);
671 else if (w == m_DiagDrawButton)
673 int draw_row_index = m_DiagDrawmodeTextListbox.GetSelectedRow();
674 GetGame().SetDiagDrawMode(draw_row_index);
678 else if (w == m_LocationAddButton)
680 ScriptConsoleAddLocation menu = ScriptConsoleAddLocation.Cast(
g_Game.GetUIManager().EnterScriptedMenu(
MENU_LOC_ADD, m_ScriptConsole));
681 menu.SetPosition(GetMapPos());
684 else if (w == m_LocationRemoveButton)
695 super.OnRPCEx(rpc_type, ctx);
696 #ifdef DIAG_DEVELOPER
699 case ERPCs.DEV_PLAYER_DEBUG_DATA:
708 override void Update(
float timeslice)
710 super.Update(timeslice);
714 m_DebugMapWidget.ClearUserMarks();
716 if (m_UpdatePlayerPositions)
720 if (rpd.m_Player != player)
722 vector dir = rpd.m_Pos - player.GetWorldPosition();
725 string text = rpd.m_Name +
" " +dist +
"m.";
726 m_DebugMapWidget.AddUserMark(rpd.m_Pos, text ,
COLOR_BLUE,
"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
732 vector playerPos = player.GetWorldPosition();
733 m_DebugMapWidget.AddUserMark(playerPos,
"You",
COLOR_RED,
"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
734 if (playerPos != GetMapPos())
735 m_DebugMapWidget.AddUserMark(GetMapPos(),
"Pos",
COLOR_BLUE,
"\\dz\\gear\\navigation\\data\\map_tree_ca.paa");
738 if (!m_PlayerPosRefreshBlocked)
739 RefreshPlayerPosEditBoxes();
742 foreach (
MapMarker marker: ScriptConsole.m_MarkedEntities)
744 m_DebugMapWidget.AddUserMark(marker.GetMarkerPos(),marker.GetMarkerText(), marker.GetMarkerColor(),
MapMarkerTypes.GetMarkerTypeFromID(marker.GetMarkerIcon()));