DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ScriptConsole.c
См. документацию.
16
18{
19 int m_ID;
22 typename m_TabClass;
23
24 void ScriptConsoleTabRegistryEntry(int id, string displayName, string panelWidgetName, typename tabClass)
25 {
26 m_ID = id;
27 m_DisplayName = displayName;
28 m_PanelWidgetName = panelWidgetName;
29 m_TabClass = tabClass;
30 }
31}
32
34{
36
37 static void Register(int id, string displayName, string widgetName, typename tabClass)
38 {
39 if (!s_Entries)
41
42 s_Entries.Insert(new ScriptConsoleTabRegistryEntry(id, displayName, widgetName, tabClass));
43 }
44
49
50 static void InitializeRegistry()
51 {
52 if (s_Entries && s_Entries.Count() > 0)
53 s_Entries.Clear();
54
55 // Register new tabs here
56 Register(ScriptConsoleTabID.GENERAL, "General", "GeneralPanel", ScriptConsoleGeneralTab);
57 Register(ScriptConsoleTabID.ITEMS, "Items", "ItemsPanel", ScriptConsoleItemsTab);
58 Register(ScriptConsoleTabID.CAMERA, "Camera", "CameraPanel", ScriptConsoleCameraTab);
59 Register(ScriptConsoleTabID.CONFIGS, "Configs", "ConfigsPanel", ScriptConsoleConfigTab);
60 Register(ScriptConsoleTabID.OUTPUT, "Prints", "OutputPanel", ScriptConsoleOutputTab);
61 Register(ScriptConsoleTabID.SCRIPT_CLIENT, "EnfScript Client", "EnScriptPanel", ScriptConsoleEnfScriptTab);
62 Register(ScriptConsoleTabID.SCRIPT_SERVER, "EnfScript Server", "EnScriptPanel", ScriptConsoleEnfScriptServerTab);
63 Register(ScriptConsoleTabID.SOUNDS, "Sounds", "SoundsPanel", ScriptConsoleSoundsTab);
64 Register(ScriptConsoleTabID.VICINITY, "Vicinity", "VicinityPanel", ScriptConsoleVicinityTab);
65 Register(ScriptConsoleTabID.WEATHER, "Weather", "WeatherPanel", ScriptConsoleWeatherTab);
66 }
67}
68
69class ScriptConsole extends UIScriptedMenu
70{
71 protected static const string HINTS_PATH_DEFAULT = "scripts/data/internal/script_console_hints.json";
72 protected static const string HINTS_PATH_OPTIONAL = "$mission:script_console_hints.json";
73 const string NO_HINT_TEXT = "No hint";
74
75 // Widgets
78 protected ImageWidget m_HintWidgetBackground;
81 protected ButtonWidget m_HintOkButton;
82 protected ButtonWidget m_HintCancelButton;
83 protected ButtonWidget m_HintClearButton;
85
87 protected GridSpacerWidget m_ButtonsMenu;
88 protected ButtonWidget m_CloseConsoleButton;
89 protected GridSpacerWidget m_ContextMenuGrid;
90 protected ButtonWidget m_ContextMenuButton;
92 #ifdef PLATFORM_CONSOLE
93 protected Widget m_HeaderPanelConsole;
94 protected GridSpacerWidget m_ConsoleButtonsMenuGrid;
95 #endif
96
97 // Member variables
98 protected bool m_HintEditMode;
99 protected float m_HoverTime;
101 protected float m_PrevMouseX;
102 protected float m_PrevMouseY;
104 protected int m_SelectedTab = ScriptConsoleTabID.GENERAL;
105
108
109 static ref JsonHintsData m_JsonData;
110
113
115 {
116 #ifndef SERVER
117 #ifndef NO_GUI
118 if (g_Game && g_Game.GetMission() && g_Game.GetMission().GetHud())
119 {
120 g_Game.GetMission().GetHud().ShowHudPlayer(false);
121 g_Game.GetMission().GetHud().ShowQuickbarPlayer(false);
122 g_Game.GetMission().GetHud().HideVehicleInfo();
123 }
124 #endif
125 #endif
127 if (plugin)
128 plugin.OnScriptMenuOpened(true);
129 }
130
132 {
133 #ifndef SERVER
134 #ifndef NO_GUI
135 if (g_Game && g_Game.GetMission() && g_Game.GetMission().GetHud())
136 {
137
138 g_Game.GetMission().GetHud().ShowHudPlayer(true);
139 g_Game.GetMission().GetHud().ShowQuickbarPlayer(true);
140 g_Game.GetMission().GetHud().ShowVehicleInfo();
141 g_Game.GetMission().EnableAllInputs(true);
142
143 }
145 m_HintWidgetRoot.Unlink();
146 #endif
147 #endif
149 if (plugin)
150 plugin.OnScriptMenuOpened(false);
151 }
152
153
158
159 static void SaveData()
160 {
161 string errorMessage;
162 if (!JsonFileLoader<JsonHintsData>.SaveFile(HINTS_PATH_OPTIONAL, m_JsonData, errorMessage))
163 ErrorEx(errorMessage);
164 }
165
166 protected static JsonHintsData GetData()
167 {
168 string path = HINTS_PATH_OPTIONAL;
169 if (!FileExist(path))
170 {
172 //ErrorEx(string.Format("Using default hints file: %1", path), ErrorExSeverity.INFO);
173 }
174
175 string errorMessage;
176 JsonHintsData data;
177 if (!JsonFileLoader<JsonHintsData>.LoadFile(path, data, errorMessage))
178 ErrorEx(errorMessage);
179
180 return data;
181 }
182
183 void SetHintText(string text, Widget w)
184 {
185 if (m_JsonData && m_JsonData.WidgetHintBindings && w)
186 {
187 int hash = GetWidgetCombinedHash(w);
188 m_JsonData.WidgetHintBindings.Set(hash, text);
189 }
191 }
192
193 void RegisterTab(int id, ScriptConsoleTabBase handler)
194 {
195 handler.Init(id);
196 m_TabHandlersByID.Insert(id, handler);
197 }
198
199 override Widget Init()
200 {
202
203 layoutRoot = g_Game.GetWorkspace().CreateWidgets("gui/layouts/script_console/script_console.layout");
204 m_EditTooltipRoot = g_Game.GetWorkspace().CreateWidgets("gui/layouts/script_console/script_console_tooltip_edit.layout", layoutRoot);
205 m_EditTooltipRoot.Show(false);
206 m_HintOkButton = ButtonWidget.Cast(m_EditTooltipRoot.FindAnyWidget("ButtonOk"));
207 m_HintCancelButton = ButtonWidget.Cast(m_EditTooltipRoot.FindAnyWidget("ButtonCancel"));
208 m_HintClearButton = ButtonWidget.Cast(m_EditTooltipRoot.FindAnyWidget("ButtonClear"));
209 m_HintInputText = EditBoxWidget.Cast(m_EditTooltipRoot.FindAnyWidget("InputText"));
210
211 m_HeaderPanelPC = layoutRoot.FindAnyWidget("HeaderBarPC");
212 m_ButtonsMenu = GridSpacerWidget.Cast(layoutRoot.FindAnyWidget("ButtonsContextMenu"));
213 m_ContextMenuGrid = GridSpacerWidget.Cast(layoutRoot.FindAnyWidget("ContextMenuGrid"));
214 m_ContextMenuButton = ButtonWidget.Cast(layoutRoot.FindAnyWidget("ButtonContextMenu"));
215 m_ContectMenuButtonLabel = TextWidget.Cast(layoutRoot.FindAnyWidget("ButtonContextMenuLabel"));
216 m_CloseConsoleButton = ButtonWidget.Cast(layoutRoot.FindAnyWidget("CloseConsoleButton"));
217 #ifdef PLATFORM_CONSOLE
218 m_HeaderPanelPC.Show(false);
219 m_ButtonsMenu.Show(false);
220
221 m_HeaderPanelConsole = layoutRoot.FindAnyWidget("HeaderBarConsole");
222 m_ConsoleButtonsMenuGrid = GridSpacerWidget.Cast(layoutRoot.FindAnyWidget("TabButtonsGrid"));
223
224 m_HeaderPanelConsole.Show(true);
225 #endif
226
228
229 // load data from profile
230 int lastOpenedTab = m_ConfigDebugProfile.GetTabSelected();
231 if (lastOpenedTab >= 0 && lastOpenedTab < ScriptConsoleTabID.COUNT)
232 m_SelectedTab = m_ConfigDebugProfile.GetTabSelected();
234
236
237 #ifdef PLATFORM_CONSOLE
238 g_Game.GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
239 OnInputDeviceChanged(g_Game.GetInput().GetCurrentInputDevice());
240 #endif
241
242 return layoutRoot;
243 }
244
245 #ifdef PLATFORM_CONSOLE
246 protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
247 {
248 m_CurrentInputDevice = pInputDeviceType;
250
251 switch (pInputDeviceType)
252 {
253 case EInputDeviceType.CONTROLLER:
254 {
255 m_HeaderPanelPC.Show(false);
256 m_ButtonsMenu.Show(false);
257 m_HeaderPanelConsole.Show(true);
258 g_Game.GetUIManager().ShowUICursor(false);
259 g_Game.GetMission().RemoveActiveInputExcludes({"menu_move"});
260 break;
261 }
262 default: // Mouse & Keyboard
263 {
264 m_HeaderPanelConsole.Show(false);
265 m_HeaderPanelPC.Show(true);
266 m_ButtonsMenu.Show(true);
267 g_Game.GetUIManager().ShowUICursor(true);
268 g_Game.GetMission().AddActiveInputExcludes({"menu_move"});
269 break;
270 }
271 }
272
273 // Notify current tab of input change
275 m_SelectedHandler.OnInputDeviceChanged(pInputDeviceType);
276 }
277 #endif
278
279 protected void BuildContextMenu()
280 {
282 {
284 {
285 element.GetRoot().Unlink();
286 delete element.GetRoot();
287 }
288
289 m_ContextMenuElements.Clear();
291 }
292
294
296 foreach (ScriptConsoleTabRegistryEntry entry : tabEntries)
297 {
298 RegisterContextMenuElement(entry.m_ID, entry.m_DisplayName);
299 }
300 }
301
302 protected void RegisterContextMenuElement(int id, string name)
303 {
304 GridSpacerWidget buttonsGrid = m_ContextMenuGrid;
305 #ifdef PLATFORM_CONSOLE
306 if (m_CurrentInputDevice == EInputDeviceType.CONTROLLER)
307 buttonsGrid = m_ConsoleButtonsMenuGrid;
308 else
309 buttonsGrid = m_ContextMenuGrid;
310 #endif
311 ScriptConsoleMenuElement menuElement = new ScriptConsoleMenuElement(id, buttonsGrid, name, this);
312 m_ContextMenuElements.Insert(id, menuElement);
313 if (m_SelectedHandler && m_SelectedHandler.GetID() == id)
314 menuElement.Select();
315 }
316
317 protected void HideContextSubElements()
318 {
320 {
321 if (element.HasSubElements())
322 {
323 element.HideGrid();
324 }
325 }
326 }
327
329 {
330 if (w == m_ContextMenuButton)
331 return true;
332
334 {
335 if (w == element.GetButton())
336 return true;
337 // Also check sub-elements
338 if (element.IsSubElementButton(w))
339 return true;
340 }
341
342 return false;
343 }
344
345 protected void HideHint()
346 {
348 m_HintWidgetRoot.Unlink();
349 }
350
352 {
353 string nameThis = w.GetName();
354 string nameParent = "";
355
356 if (w.GetParent())
357 {
358 nameParent = w.GetParent().GetName();
359 }
360
361 string namesCombined = nameThis + nameParent;
362 return namesCombined.Hash();
363 }
364
365 protected string GetMessage()
366 {
368
369 if (m_JsonData && m_JsonData.WidgetHintBindings)
370 {
371 if (m_JsonData.WidgetHintBindings.Contains(hash))
372 {
373 return m_JsonData.WidgetHintBindings.Get(hash);
374 }
375 }
376 //return "";
377 //return "No hint" + hash.ToString();
378 return NO_HINT_TEXT;
379 }
380
381 protected void HoverSuccess()
382 {
385 }
386
387 protected void HoverInterrupt()
388 {
390
391 m_HoverTime = 0;
392 m_HintEditMode = false;
393 HideHint();
394 }
395
396 override void OnShow()
397 {
398 super.OnShow();
399
400 if (g_Game && g_Game.GetMission())
401 {
402 // Inputs excluded when in script console menu
403 array<string> inputExcludes = {
404 // Menu
405 "movement",
406 "aiming",
407 "gestures",
408 "stances",
409 "optics",
410 "actions",
411 "hotkey",
412 "UAGear",
413 "UAVoiceLevel",
414 "UAVoiceModifierHelper",
415 "UAVoiceDistanceUp",
416 "UAVoiceDistanceDown",
417 "UAVoiceOverNet",
418 "UAVoiceOverNetToggle",
419 "UAVoiceOverNetMute",
420 // Inventory
421 "gestures",
422 "stances",
423 "optics",
424 "actions",
425 // Buldozer
426 "UABuldResetCamera",
427 "UABuldTurbo",
428 "UABuldSlow",
429 "UABuldRunScript",
430 "UABuldSelectToggle",
431 "UABuldFreeLook",
432 "UABuldSelect",
433 "UABuldSelectAddMod",
434 "UABuldSelectRemoveMod",
435 "UABuldModifySelected",
436 "UABuldCycleMod",
437 "UABuldRotationXAxisMod",
438 "UABuldRotationZAxisMod",
439 "UABuldCoordModCycle",
440 "UABuldSampleTerrainHeight",
441 "UABuldSetTerrainHeight",
442 "UABuldScaleMod",
443 "UABuldElevateMod",
444 "UABuldSmoothMod",
445 "UABuldFlattenMod",
446 "UABuldBrushRatioUp",
447 "UABuldBrushRatioDown",
448 "UABuldBrushOuterUp",
449 "UABuldBrushOuterDown",
450 "UABuldBrushStrengthUp",
451 "UABuldBrushStrengthDown",
452 "UABuldToggleNearestObjectArrow",
453 "UABuldCycleBrushMod",
454 "UABuldSelectionType",
455 "UABuldCreateLastSelectedObject",
456 "UABuldDuplicateSelection",
457 "UABuldDeleteSelection",
458 "UABuldUndo",
459 "UABuldRedo",
460 "UABuldMoveLeft",
461 "UABuldMoveRight",
462 "UABuldMoveForward",
463 "UABuldMoveBack",
464 "UABuldMoveUp",
465 "UABuldMoveDown",
466 "UABuldLeft",
467 "UABuldRight",
468 "UABuldForward",
469 "UABuldBack",
470 "UABuldLookLeft",
471 "UABuldLookRight",
472 "UABuldLookUp",
473 "UABuldLookDown",
474 "UABuldZoomIn",
475 "UABuldZoomOut",
476 "UABuldTextureInfo",
477 "UABuldViewerMoveForward",
478 "UABuldViewerMoveBack",
479 "UABuldViewerMoveLeft",
480 "UABuldViewerMoveRight",
481 "UABuldViewerMoveUp",
482 "UABuldViewerMoveDown",
483 "UABuldObjectRotateLeft",
484 "UABuldObjectRotateRight",
485 "UABuldObjectRotateForward",
486 "UABuldObjectRotateBack",
487 "UABuldPreviousAnimation",
488 "UABuldNextAnimation",
489 "UABuldRecedeAnimation",
490 "UABuldAdvanceAnimation",
491 "UABuldLinkCamToTerrain",
492 "UABuldCopyTileCoord",
493 "UABuldMarkUnderground",
494 "UABuldRemoveUnderground"
495 };
496
498 {
499 inputExcludes.Remove(0);
500 }
501
502 g_Game.GetMission().AddActiveInputExcludes(inputExcludes);
503 }
504 }
505
506 override void OnHide()
507 {
508 super.OnHide();
509
511 }
512
513 override bool OnKeyPress(Widget w, int x, int y, int key)
514 {
515 super.OnKeyPress(w, x, y, key);
516
517 if (m_SelectedHandler && m_SelectedHandler.OnKeyPress(w,x,y,key))
518 return true;
519 return false;
520
521 }
522
523 override bool OnKeyDown(Widget w, int x, int y, int key)
524 {
525 super.OnKeyDown(w, x, y, key);
526
527 if (m_SelectedHandler && m_SelectedHandler.OnKeyDown(w,x,y,key))
528 return true;
529 return false;
530
531 }
532
533 override void Update(float timeslice)
534 {
535 super.Update(timeslice);
536
537 int mouseX, mouseY;
538 GetMousePos(mouseX,mouseY);
539 float dist = Math.Sqrt(Math.AbsFloat(mouseX - m_PrevMouseX) + Math.AbsFloat(mouseY - m_PrevMouseY));
540 m_PrevMouseX = mouseX;
541 m_PrevMouseY = mouseY;
542
544 {
545 m_HoverTime += timeslice;
546 if (m_HoverTime > 1)
547 {
548 HoverSuccess();
549 }
550 }
551
552 if(dist > 1 && m_HoverSuccessTriggered)
554
555 if (!g_Game.IsMultiplayer() && KeyState(KeyCode.KC_RCONTROL) && KeyState(KeyCode.KC_NUMPAD0) && m_HintWidgetRoot && m_HintWidgetRoot.IsVisible())
556 {
557 ClearKey(KeyCode.KC_NUMPAD0);
558 m_EditTooltipRoot.Show(true);
559 string text = GetMessage();
560 if (text == NO_HINT_TEXT)
561 text = "";
562 m_HintInputText.SetText(text);
563 }
564
565 foreach (ScriptConsoleTabBase handler : m_TabHandlersByID)
566 {
567 if (handler.IsSelected())
568 {
569 handler.Update(timeslice);
570 }
571 }
572
573 UAInputAPI inputAPI = GetUApi();
574 if (g_Game && inputAPI.GetInputByID(UAUIBack).LocalPress())
575 {
576 g_Game.GetUIManager().Back();
577 return;
578 }
579 if (inputAPI.GetInputByID(UAUITabRight).LocalPress())
580 {
583 m_SelectedTab = 0;
584
586 }
587 else if (inputAPI.GetInputByID(UAUITabLeft).LocalPress())
588 {
590 if (m_SelectedTab < 0)
592
594 }
595 }
596
597 override bool OnMouseButtonDown(Widget w, int x, int y, int button)
598 {
599 super.OnMouseButtonDown(w,x,y,button);
600
601 if (m_SelectedHandler && m_SelectedHandler.OnMouseButtonDown(w,x,y,button))
602 return true;
603
604 return false;
605 }
606
607 override bool OnClick(Widget w, int x, int y, int button)
608 {
609 super.OnClick(w, x, y, button);
610
611 if (w == m_HintOkButton)
612 {
615 m_EditTooltipRoot.Show(false);
616 SaveData();
617 }
618 else if (w == m_HintCancelButton)
619 {
621 m_EditTooltipRoot.Show(false);
622
623 }
624 else if (w == m_HintClearButton)
625 {
626 m_HintInputText.SetText("");
627 }
628 #ifndef PLATFORM_CONSOLE
629 else if (w == m_CloseConsoleButton)
630 {
631 Close();
632 g_Game.GetMission().EnableAllInputs(true);
633 return true;
634 }
635 #endif
636
637 if (m_SelectedHandler && m_SelectedHandler.OnClick(w,x,y,button))
638 return true;
639 return false;
640 }
641
642 override bool OnDoubleClick(Widget w, int x, int y, int button)
643 {
644 super.OnDoubleClick(w, x, y, button);
645
646 if (m_SelectedHandler && m_SelectedHandler.OnDoubleClick(w,x,y,button))
647 return true;
648
649 return false;
650 }
651
652 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
653 {
654 super.OnMouseLeave(w, enterW, x, y);
655
656 if (!m_EditTooltipRoot.IsVisible())
658
659 // Close context menu if we're not entering any context menu related widget
660 if (enterW && !IsContextElementButton(enterW) && !IsChildOfWidget(enterW, m_ButtonsMenu) && w && !IsContextElementButton(w) && !IsChildOfWidget(w, m_ButtonsMenu) && enterW != m_ContextMenuGrid && w != m_ContextMenuGrid)
661 {
662 m_ContextMenuGrid.Show(false);
664 m_ContectMenuButtonLabel.SetColor(ARGB(255, 255, 255, 255));
665 }
666 else if (w == m_ContextMenuButton)
667 {
668 m_ContectMenuButtonLabel.SetColor(ARGB(255, 255, 255, 255));
669 }
670
671 if (m_SelectedHandler && m_SelectedHandler.OnMouseLeave(w, enterW, x, y))
672 return true;
673
674 return false;
675 }
676
677 override bool OnMouseEnter(Widget w, int x, int y)
678 {
679 super.OnMouseEnter(w, x, y);
680
681 if (!m_EditTooltipRoot.IsVisible())
683
684 // Close context menu if we're not entering any context menu related widget
686 {
687 m_ContextMenuGrid.Show(false);
689 m_ContectMenuButtonLabel.SetColor(ARGB(255, 255, 255, 255));
690 }
691 else if (w == m_ContextMenuButton)
692 {
693 m_ContextMenuGrid.Show(true);
694 m_ContectMenuButtonLabel.SetColor(ARGB(255, 0, 0, 0));
695 }
696
697 if (m_SelectedHandler && m_SelectedHandler.OnMouseEnter(w ,x, y))
698 return true;
699
700 #ifdef PLATFORM_CONSOLE
701 return false;
702 #endif
703 return true;
704 }
705
706 override bool OnChange(Widget w, int x, int y, bool finished)
707 {
708 super.OnChange(w, x, y, finished);
709
710 if (m_SelectedHandler && m_SelectedHandler.OnChange(w,x,y,finished))
711 return true;
712
713 return false;
714 }
715
716 override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
717 {
718 super.OnItemSelected(w, x, y, row, column, oldRow, oldColumn);
719
720 if (m_SelectedHandler && m_SelectedHandler.OnItemSelected(w, x, y, row, column,oldRow, oldColumn))
721 return true;
722
723 return false;
724 }
725
727 {
728 foreach (ScriptConsoleTabBase handler : m_TabHandlersByID)
729 {
730 if (tabType == handler.Type())
731 {
732 return handler;
733 }
734 }
735 return null;
736 }
737
738 void SelectTabByID(int tabId)
739 {
741
742 if (!tab)
743 {
744 // Find the tab entry in registry
745 ScriptConsoleTabRegistryEntry foundEntry = null;
747 foreach (ScriptConsoleTabRegistryEntry entry : tabEntries)
748 {
749 if (entry.m_ID == tabId)
750 {
751 foundEntry = entry;
752 break;
753 }
754 }
755
756 if (foundEntry)
757 {
758 // Get the button and panel widget
759 ButtonWidget elementButton = GetContextElementButton(tabId);
760 Widget panel = layoutRoot.FindAnyWidget(foundEntry.m_PanelWidgetName);
761 if (panel && elementButton)
762 {
763 // Instantiate the tab using typename
764 tab = ScriptConsoleTabBase.Cast(foundEntry.m_TabClass.Spawn());
765 tab.InitializeTab(panel, this, elementButton);
766
767 // Register tab
768 RegisterTab(foundEntry.m_ID, tab);
769 }
770 }
771 }
772
773 if (tab)
774 {
775 SelectTab(tab);
776
777 foreach (int elementID, ScriptConsoleMenuElement element : m_ContextMenuElements)
778 {
779 element.SetTextAlignment(m_CurrentInputDevice);
780
781 if (elementID == tabId)
782 {
783 element.Select();
784 }
785 else
786 {
787 element.Deselect();
788 }
789 }
790 }
791 }
792
793 void SelectTab(ScriptConsoleTabBase selectedHandler)
794 {
795 foreach (ScriptConsoleTabBase handler: m_TabHandlersByID)
796 {
797 handler.Select(handler == selectedHandler, selectedHandler);
798 }
799
800 ScriptConsoleCameraTab cameraTab;
801 ScriptConsoleWeatherTab weatherTab;
802 bool isCameraTab = Class.CastTo(cameraTab, selectedHandler);
803 bool isWeatherTab = Class.CastTo(weatherTab, selectedHandler);
804
805 if (isCameraTab || isWeatherTab)
806 {
807 // Remove alpha background for camera tab
808 ShowMenuBackground(false);
809 if (isCameraTab)
810 g_Game.GetMission().RemoveActiveInputExcludes({"movement"}, true);
811 }
812 else
813 {
814 // Add back alpha background
815 ShowMenuBackground(true);
816 g_Game.GetMission().AddActiveInputExcludes({"movement"});
817 }
818
819 m_SelectedHandler = selectedHandler;
820 m_ConfigDebugProfile.SetTabSelected(selectedHandler.GetID());
821 }
822
823 ButtonWidget GetContextElementButton(int tabID)
824 {
825 ButtonWidget buttonW;
827 if (element)
828 buttonW = element.GetButton();
829
830 return buttonW;
831 }
832
833 void ShowMenuBackground(bool state)
834 {
835 if (!state)
836 {
837 GetLayoutRoot().FindAnyWidget("MenuWindow").SetColor(ARGB(0, 0, 0, 0));
838 }
839 else
840 {
841 GetLayoutRoot().FindAnyWidget("MenuWindow").SetColor(ARGB(128, 0, 0, 0));
842 }
843 }
844
845 protected bool IsChildOfWidget(Widget child, Widget parent)
846 {
847 if (!child || !parent)
848 return false;
849
850 Widget currentChild = parent.GetChildren();
851 while (currentChild)
852 {
853 if (currentChild == child)
854 return true;
855 currentChild = currentChild.GetSibling();
856 }
857 return false;
858 }
859
860 protected void DisplayHint(string message)
861 {
862 if (message)
863 {
864 m_HintWidgetRoot = g_Game.GetWorkspace().CreateWidgets("gui/layouts/script_console/script_console_hint.layout");
865 m_HintWidgetBackground = ImageWidget.Cast(m_HintWidgetRoot.FindAnyWidget("Background"));
866 m_HintWidget = RichTextWidget.Cast(m_HintWidgetRoot.FindAnyWidget("HintText"));
867
868 m_HintWidgetRoot.Show(true);
869 m_HintWidget.SetText(message);
870
871 int offsetX = 0;
872 int offsetY = 10;
873
874 int screenW, screenH;
875 GetScreenSize(screenW, screenH);
876
877 int mouseX, mouseY;
878 GetMousePos(mouseX,mouseY);
879
880 float relativeX = mouseX / screenW;
881 float relativeY = mouseY / screenH;
882
883 int width, height;
884 m_HintWidget.GetTextSize(width, height);
885 if (relativeX > 0.8)
886 offsetX = -width - offsetX;
887 if (relativeY > 0.8)
888 offsetY = -height - offsetY;
889
890 m_HintWidgetRoot.SetPos(mouseX + offsetX ,mouseY + offsetY);
891 m_HintWidgetBackground.SetScreenSize(width + 5, height + 5);
892
893 }
894 }
895
896 override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
897 {
898 super.OnRPCEx(rpc_type, ctx);
899 #ifdef DIAG_DEVELOPER
900
901 foreach (ScriptConsoleTabBase handler : m_TabHandlersByID)
902 {
903 handler.OnRPCEx(rpc_type,ctx);
904 }
905 #endif
906
907 }
908
910}
911
913{
914 reference string HintMessage;
915 protected Widget m_Root;
916
917
918 protected float m_HoverTime;
922 protected ImageWidget m_HintWidgetBackground;
924
925 protected ref Timer m_Timer;
926
928 {
929 m_Root = w;
930 m_Root.SetHandler(this);
931 m_Root.SetFlags(WidgetFlags.VEXACTPOS);
932 }
933
934 override bool OnMouseEnter(Widget w, int x, int y)
935 {
936 m_Timer = new Timer();
937 m_Timer.Run(0.1, this, "Tick", NULL, true);
938
940 return true;
941 }
942
943 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
944 {
946 return true;
947 }
948
949 protected bool Tick()
950 {
951 if (!m_Root.IsVisibleHierarchy())
954 {
955 m_HoverTime += 0.1;
956 if (m_HoverTime > 1)
957 {
958 HoverSuccess();
959 }
960 }
961 return true;
962 }
963
964 protected void DisplayHint(string message)
965 {
966 if (message)
967 {
968 m_HintWidgetRoot = g_Game.GetWorkspace().CreateWidgets("gui/layouts/script_console/script_console_hint.layout");
969 m_HintWidgetBackground = ImageWidget.Cast(m_HintWidgetRoot.FindAnyWidget("Background"));
970 m_HintWidget = RichTextWidget.Cast(m_HintWidgetRoot.FindAnyWidget("HintText"));
971
972 m_HintWidgetRoot.Show(true);
973 m_HintWidget.SetText(message);
974
975 int offsetX = 0;
976 int offsetY = 10;
977
978 int screenW, screenH;
979 GetScreenSize(screenW, screenH);
980
981 int mouseX, mouseY;
982 GetMousePos(mouseX,mouseY);
983
984 float relativeX = mouseX / screenW;
985 float relativeY = mouseY / screenH;
986
987 int width, height;
988 m_HintWidget.GetTextSize(width, height);
989 if (relativeX > 0.8)
990 offsetX = -width - offsetX;
991 if (relativeY > 0.8)
992 offsetY = -height - offsetY;
993
994 m_HintWidgetRoot.SetPos(mouseX + offsetX ,mouseY + offsetY);
995 m_HintWidgetBackground.SetScreenSize(width + 5, height + 5);
996
997 }
998 }
999
1000 protected void HideHint()
1001 {
1002 if (m_HintWidgetRoot)
1003 m_HintWidgetRoot.Show(false);
1004 }
1005
1006
1007 protected string GetMessage()
1008 {
1009 return HintMessage;
1010 }
1011
1012 protected void HoverSuccess()
1013 {
1016 }
1017
1018 protected void HoverInterrupt()
1019 {
1020 m_Timer = null;
1022 m_CurrentHoverWidget = null;
1023 m_HoverTime = 0;
1024 HideHint();
1025 }
1026}
1027
1028class JsonHintsData
1029{
1031}
1032
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
map
Определения ControlsXboxNew.c:4
DayZGame g_Game
Определения DayZGame.c:4074
@ CAMERA
Определения DayZPhysics.c:40
int m_ID
Определения DustKickupEffects.c:26
@ COUNT
Определения EGameStateIcons.c:7
Icon x
Icon y
@ GENERAL
Определения InfectedSoundEventBase.c:3
void Close()
string path
Определения OptionSelectorMultistate.c:142
PluginConfigDebugProfile m_ConfigDebugProfile
Определения PluginItemDiagnostic.c:58
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
ButtonWidget GetContextElementButton(int tabID)
Определения ScriptConsole.c:823
class ScriptConsoleTabRegistry HINTS_PATH_DEFAULT
GridSpacerWidget m_ContextMenuGrid
Определения ScriptConsole.c:89
ButtonWidget m_HintCancelButton
Определения ScriptConsole.c:82
EditBoxWidget m_HintInputText
Определения ScriptConsole.c:84
override bool OnKeyDown(Widget w, int x, int y, int key)
Определения ScriptConsole.c:523
void HideContextSubElements()
Определения ScriptConsole.c:317
ImageWidget m_HintWidgetBackground
Определения ScriptConsole.c:78
string GetMessage()
Определения ScriptConsole.c:365
void ScriptConsole()
Определения ScriptConsole.c:114
void ~ScriptConsole()
Определения ScriptConsole.c:131
ScriptConsoleToolTipEventHandler WidgetHintBindings
ScriptConsoleTabID
Определения ScriptConsole.c:2
@ OUTPUT
Определения ScriptConsole.c:7
@ SOUNDS
Определения ScriptConsole.c:10
@ CONFIGS
Определения ScriptConsole.c:6
@ SCRIPT_CLIENT
Определения ScriptConsole.c:8
@ ITEMS
Определения ScriptConsole.c:4
@ WEATHER
Определения ScriptConsole.c:12
@ VICINITY
Определения ScriptConsole.c:11
@ SCRIPT_SERVER
Определения ScriptConsole.c:9
ButtonWidget m_CloseConsoleButton
Определения ScriptConsole.c:88
ButtonWidget m_HintOkButton
Определения ScriptConsole.c:81
void BuildContextMenu()
Определения ScriptConsole.c:279
static JsonHintsData GetData()
Определения ScriptConsole.c:166
string m_PanelWidgetName
Определения ScriptConsole.c:21
float m_PrevMouseY
Определения ScriptConsole.c:102
TextWidget m_ContectMenuButtonLabel
Определения ScriptConsole.c:91
Widget m_CurrentHoverWidget
Определения ScriptConsole.c:76
float m_HoverTime
Определения ScriptConsole.c:99
ButtonWidget m_HintClearButton
Определения ScriptConsole.c:83
override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
Определения ScriptConsole.c:896
ref map< int, ref ScriptConsoleTabBase > m_TabHandlersByID
Определения ScriptConsole.c:107
Widget m_HeaderPanelPC
Определения ScriptConsole.c:86
int m_SelectedTab
Определения ScriptConsole.c:104
void HoverSuccess()
Определения ScriptConsole.c:381
static const string HINTS_PATH_OPTIONAL
Определения ScriptConsole.c:72
bool IsContextElementButton(Widget w)
Определения ScriptConsole.c:328
GridSpacerWidget m_ButtonsMenu
Определения ScriptConsole.c:87
void ShowMenuBackground(bool state)
Определения ScriptConsole.c:833
RichTextWidget m_HintWidget
Определения ScriptConsole.c:80
float m_PrevMouseX
Определения ScriptConsole.c:101
ButtonWidget m_ContextMenuButton
Определения ScriptConsole.c:90
bool IsChildOfWidget(Widget child, Widget parent)
Определения ScriptConsole.c:845
ref map< int, ref ScriptConsoleMenuElement > m_ContextMenuElements
Определения ScriptConsole.c:111
void ScriptConsoleTabRegistryEntry(int id, string displayName, string panelWidgetName, typename tabClass)
Определения ScriptConsole.c:24
string m_DisplayName
Определения ScriptConsole.c:20
bool m_HintEditMode
Определения ScriptConsole.c:98
m_TabClass
Определения ScriptConsole.c:22
void HoverInterrupt()
Определения ScriptConsole.c:387
Widget m_EditTooltipRoot
Определения ScriptConsole.c:79
static ref array< ref MapMarker > m_MarkedEntities
Определения ScriptConsole.c:106
static ref JsonHintsData m_JsonData
Определения ScriptConsole.c:109
int GetWidgetCombinedHash(Widget w)
Определения ScriptConsole.c:351
bool m_HoverSuccessTriggered
Определения ScriptConsole.c:100
void SetHintText(string text, Widget w)
Определения ScriptConsole.c:183
ScriptConsoleTabBase GetTabHandler(typename tabType)
Определения ScriptConsole.c:726
Widget m_HintWidgetRoot
Определения ScriptConsole.c:77
ScriptConsoleTabBase GetSelectedHandler()
Определения ScriptConsole.c:154
void DisplayHint(string message)
Определения ScriptConsole.c:860
void RegisterContextMenuElement(int id, string name)
Определения ScriptConsole.c:302
void RegisterTab(int id, ScriptConsoleTabBase handler)
Определения ScriptConsole.c:193
void HideHint()
Определения ScriptConsole.c:345
void SelectTabByID(int tabId)
Определения ScriptConsole.c:738
ScriptConsoleTabBase m_SelectedHandler
Определения ScriptConsole.c:103
const string NO_HINT_TEXT
Определения ScriptConsole.c:73
void SelectTab(ScriptConsoleTabBase selectedHandler)
Определения ScriptConsole.c:793
proto native UAInputAPI GetUApi()
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения EnWidgets.c:354
Определения EnMath.c:7
Определения gameplay.c:317
ButtonWidget GetButton()
Определения ScriptConsoleMenuElement.c:32
void InitializeTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleTabBase.c:19
void Init(int id)
Определения ScriptConsoleTabBase.c:14
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
static void InitializeRegistry()
Определения ScriptConsole.c:50
static void Register(int id, string displayName, string widgetName, typename tabClass)
Определения ScriptConsole.c:37
static ref array< ref ScriptConsoleTabRegistryEntry > s_Entries
Определения ScriptConsole.c:35
static array< ref ScriptConsoleTabRegistryEntry > GetAll()
Определения ScriptConsole.c:45
void DisplayHint(string message)
Определения ScriptConsole.c:964
Widget m_HintWidgetRoot
Определения ScriptConsole.c:921
reference string HintMessage
Определения ScriptConsole.c:914
ImageWidget m_HintWidgetBackground
Определения ScriptConsole.c:922
ref Timer m_Timer
Определения ScriptConsole.c:925
bool m_HoverSuccessTriggered
Определения ScriptConsole.c:919
override bool OnMouseEnter(Widget w, int x, int y)
Определения ScriptConsole.c:934
Widget m_CurrentHoverWidget
Определения ScriptConsole.c:920
void OnWidgetScriptInit(Widget w)
Определения ScriptConsole.c:927
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения ScriptConsole.c:943
RichTextWidget m_HintWidget
Определения ScriptConsole.c:923
Deprecated.
Определения EnWidgets.c:657
Определения EnWidgets.c:220
Определения DayZPlayerImplement.c:39
proto native UAInput GetInputByID(int iID)
returns list of all bindable (i.e. visible) inputs from the active group ('core' by default)
Определения UAInput.c:206
proto native bool LocalPress()
override bool OnMouseEnter(Widget w, int x, int y)
Определения CameraToolsMenu.c:928
override void OnShow()
Определения CameraToolsMenu.c:99
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Определения ControlsXboxNew.c:71
override bool OnDoubleClick(Widget w, int x, int y, int button)
Определения SceneEditorMenu.c:487
override bool OnKeyPress(Widget w, int x, int y, int key)
Определения CameraToolsMenu.c:969
override void OnHide()
Определения CameraToolsMenu.c:109
override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
Определения InGameMenuXbox.c:667
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения CameraToolsMenu.c:935
override bool OnChange(Widget w, int x, int y, bool finished)
Определения ChatInputMenu.c:29
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
Определения CameraToolsMenu.c:793
override Widget Init()
Определения BookMenu.c:11
override bool OnClick(Widget w, int x, int y, int button)
Определения BookMenu.c:34
void SaveData()
Определения CameraToolsMenu.c:267
Определения DayZGame.c:64
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения Transport.c:70
Serializer ParamsReadContext
Определения gameplay.c:15
enum ShapeType ErrorEx
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto bool FileExist(string name)
Check existence of file.
proto native void ClearKey(KeyCode key)
KeyCode
Определения EnSystem.c:157
proto native int KeyState(KeyCode key)
static proto float Sqrt(float val)
Returns square root.
static proto float AbsFloat(float f)
Returns absolute value.
proto void GetScreenSize(out int x, out int y)
proto void GetMousePos(out int x, out int y)
proto native int Hash()
Returns hash of string.
WidgetFlags
Определения EnWidgets.c:58
proto native volatile void Update()
Определения PlayerSoundManager.c:125
EInputDeviceType
Определения input.c:3
int ARGB(int a, int r, int g, int b)
Определения proto.c:322