Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ContextMenuActionsEditorUIComponent.c
Go to the documentation of this file.
2 {
3  [Attribute(SCR_SoundEvent.FOCUS, UIWidgets.EditBox)]
4  protected string m_sSoundOnOpen;
5 
6  [Attribute(SCR_SoundEvent.SOUND_E_TRAN_CANCEL, UIWidgets.EditBox)]
7  protected string m_sSoundOnCancelClose;
8 
9  //~ Makes sure context action is never opened if not selection state
10  protected bool m_bEditorIsSelectingState = true;
11 
12  protected SCR_EditableEntityComponent m_HoveredEntityReference;
13 
14  //------------------------------------------------------------------------------------------------
15  protected void OnHoveredEntityCheck(float tDelta)
16  {
17  if (!m_HoveredEntityReference)
18  {
19  CloseContextMenu();
20  GetMenu().GetOnMenuUpdate().Remove(OnHoveredEntityCheck);
21  }
22  }
23 
24  //------------------------------------------------------------------------------------------------
25  override protected void PopulateContextMenu(vector cursorWorldPosition)
26  {
27  super.PopulateContextMenu(cursorWorldPosition);
28  m_HoveredEntityReference = m_EditorActionsComponent.GetHoveredEntity();
29  if (m_HoveredEntityReference)
30  {
31  GetMenu().GetOnMenuUpdate().Insert(OnHoveredEntityCheck);
32 
33  //--- Close the menu when UI of hovered entity changed, as it implies major change in its state (e.g., character died)
34  if (m_HoveredEntityReference.GetOnUIRefresh())
35  m_HoveredEntityReference.GetOnUIRefresh().Insert(CloseContextMenu);
36  }
37  }
38 
39  //------------------------------------------------------------------------------------------------
40  override protected void OnEditorModeChanged()
41  {
43  }
44 
45  //------------------------------------------------------------------------------------------------
46  protected override void OpenContextMenu()
47  {
48  super.OpenContextMenu();
49 
50  if (m_ContextMenu && m_ContextMenu.IsVisible())
51  SCR_UISoundEntity.SoundEvent(m_sSoundOnOpen);
52  }
53 
54  //------------------------------------------------------------------------------------------------
55  override void CloseContextMenu()
56  {
57  if (m_ContextMenu && m_ContextMenu.IsVisible())
58  GetGame().GetCallqueue().CallLater(DelayedCloseSound, 100);
59 
60  if (m_HoveredEntityReference)
61  {
62  GetMenu().GetOnMenuUpdate().Remove(OnHoveredEntityCheck);
63  m_HoveredEntityReference = null;
64  }
65 
66  super.CloseContextMenu();
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  protected void DelayedCloseSound()
71  {
72  if (!IsContextMenuOpen())
73  SCR_UISoundEntity.SoundEvent(m_sSoundOnCancelClose);
74  }
75 
76  //------------------------------------------------------------------------------------------------
77  protected void OnOpenActionsMenuUp()
78  {
79  //~ Check if can open
80  if (!OnCancelUp() || IsContextMenuOpen() || !m_bEditorIsSelectingState)
81  {
82  //~ Reset the state
83  m_bEditorIsSelectingState = true;
84  return;
85  }
86 
87  //~ Open
88  OpenContextMenu();
89  }
90 
91  //------------------------------------------------------------------------------------------------
92  protected override void OnOpenActionsMenuDown()
93  {
94  super.OnOpenActionsMenuDown();
95 
96  //~ Is not selecting state so make sure on up context menu is not opened
98  if (statesManager && statesManager.GetState() != EEditorState.SELECTING)
99  m_bEditorIsSelectingState = false;
100  }
101 
102  //------------------------------------------------------------------------------------------------
103  override void HandlerAttachedScripted(Widget w)
104  {
105  super.HandlerAttachedScripted(w);
106 
107  if (m_InputManager)
108  {
109  m_InputManager.AddActionListener("EditorActionsMenu", EActionTrigger.DOWN, OnOpenActionsMenuDown);
110  m_InputManager.AddActionListener("EditorActionsMenu", EActionTrigger.UP, OnOpenActionsMenuUp);
111  }
112 
113  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_EDITOR_ACTIONS_MENU_SHOWDISABLED, string.Empty, "Show disabled actions", "Actions Menu");
114  }
115 
116  //------------------------------------------------------------------------------------------------
117  override void HandlerDeattached(Widget w)
118  {
119  super.HandlerDeattached(w);
120 
121  if (m_InputManager)
122  {
123  m_InputManager.RemoveActionListener("EditorActionsMenu", EActionTrigger.DOWN, OnOpenActionsMenuDown);
124  m_InputManager.RemoveActionListener("EditorActionsMenu", EActionTrigger.UP, OnOpenActionsMenuUp);
125  }
126 
127  DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_EDITOR_ACTIONS_MENU_SHOWDISABLED);
128  }
129 }
m_InputManager
protected InputManager m_InputManager
Definition: SCR_BaseManualCameraComponent.c:15
SCR_UISoundEntity
Definition: SCR_UISoundEntity.c:7
EEditorState
EEditorState
Unique editor state.
Definition: EEditorState.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_SoundEvent
Definition: SCR_SoundEvent.c:1
GetMenu
SCR_RadialMenu GetMenu()
Definition: SCR_RadialMenuGameModeComponent.c:41
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_BaseContextMenuEditorUIComponent
Definition: SCR_BaseContextMenuEditorUIComponent.c:2
SCR_ContextActionsEditorComponent
Definition: SCR_ContextActionsEditorComponent.c:15
SCR_ContextMenuActionsEditorUIComponent
Definition: SCR_ContextMenuActionsEditorUIComponent.c:1
m_EditorActionsComponent
protected SCR_ToolbarActionsEditorComponent m_EditorActionsComponent
Definition: SCR_ActionsToolbarEditorUIComponent.c:22
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_StatesEditorComponent
Definition: SCR_StatesEditorComponent.c:9
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3
m_ContextMenu
protected SCR_BaseContextMenuEditorUIComponent m_ContextMenu
Definition: SCR_TooltipManagerEditorUIComponent.c:24