Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ActionsRadialMenuEditorComponent.c
Go to the documentation of this file.
1 
4 [ComponentEditorProps(category: "GameScripted/Editor", description: "Responsible for controlling radial menus used within GameMaster", icon: "WBData/ComponentEditorProps/componentEditor.png")]
6 {
7 }
8 
10 class SCR_ActionsRadialMenuEditorComponent : SCR_BaseEditorComponent
11 {
12  [Attribute()]
13  protected ref SCR_RadialMenuController m_ActionsMenuController;
14 
15  [Attribute()]
17 
18  [Attribute()]
20 
21  // Action names
22 
23  [Attribute()]
24  protected string m_sActionName;
25 
26  [Attribute()]
27  protected string m_sCommandActionName;
28 
29  [Attribute()]
30  protected string m_sAddCommandActionName;
31 
32  //------------------------------------------------------------------------------------------------
35  void OnInputDeviceChanged(bool isGamepad)
36  {
37  // Clearup and close radial menu if not using gamepad
38  if (!isGamepad)
39  {
40  CleanMenu();
41 
42  if (m_ActionsMenuController)
43  {
44  m_ActionsMenuController.SetEnableControl(false);
45  m_ActionsMenuController.StopControl(true);
46  }
47 
49  {
50  m_CommandsMenuController.SetEnableControl(false);
51  m_CommandsMenuController.StopControl(true);
52  }
53 
55  {
56  m_AddCommandsMenuController.SetEnableControl(false);
57  m_AddCommandsMenuController.StopControl(true);
58  }
59 
60  return;
61  }
62 
63  // Gamepad
64  if (m_ActionsMenuController)
65  m_ActionsMenuController.SetEnableControl(true);
66 
68  m_CommandsMenuController.SetEnableControl(true);
69 
71  m_AddCommandsMenuController.SetEnableControl(true);
72  }
73 
74  //------------------------------------------------------------------------------------------------
75  protected void OnBeforeMenuOpen(notnull SCR_RadialMenuController menuController, notnull SCR_BaseActionsEditorComponent actionsComponent, int flags = 0)
76  {
77  CleanMenu();
78 
79  if (GetGame().GetInputManager().GetLastUsedInputDevice() != EInputDeviceType.GAMEPAD)
80  return;
81 
83  if (!editorMenuLayout)
84  return;
85 
86  SCR_RadialMenu radialMenu = menuController.GetRadialMenu();
87  if (!radialMenu)
88  return;
89 
90  vector cursorWorldPosition;
91  if (!editorMenuLayout.GetCursorWorldPos(cursorWorldPosition))
92  return;
93 
94  array<ref SCR_EditorActionData> filteredActions = {};
95  actionsComponent.GetAndEvaluateActions(cursorWorldPosition, filteredActions, flags);
96 
97  // Close menu if there is nothing to display.
98  if (filteredActions.IsEmpty())
99  {
100  CleanMenu();
101  return;
102  }
103 
104  array<ref SCR_SelectionMenuEntry> radialMenuEntries = {};
105  foreach (SCR_EditorActionData actionData : filteredActions)
106  {
107  SCR_BaseEditorAction action = actionData.GetAction();
108  if (!action)
109  continue;
110 
111  SCR_UIInfo info = action.GetInfo();
112  if (!info)
113  continue;
114 
115  SCR_EditorActionSelectionMenuEntry menuEntry = new SCR_EditorActionSelectionMenuEntry(action, actionsComponent, cursorWorldPosition, flags);
116 
117  menuEntry.Enable(true);
118  menuEntry.SetName(info.GetName());
119  menuEntry.SetIcon(info.GetIconPath());
120  menuEntry.SetDescription(info.GetDescription());
121  menuEntry.SetInputAction(action.GetShortcut());
122 
123  radialMenuEntries.Insert(menuEntry);
124  }
125 
126  radialMenu.GetOnClose().Insert(CleanMenu);
127  radialMenu.AddEntries(radialMenuEntries, true);
128 
129  menuController.OnInputOpen();
130  }
131 
132  //------------------------------------------------------------------------------------------------
133  protected void CleanMenu()
134  {
135  SCR_RadialMenu radialMenu = null;
136 
137  if (m_ActionsMenuController)
138  radialMenu = m_ActionsMenuController.GetRadialMenu();
139 
140  if (radialMenu)
141  {
142  radialMenu.ClearEntries();
143  radialMenu = null;
144  }
145 
147  radialMenu = m_CommandsMenuController.GetRadialMenu();
148 
149  if (radialMenu)
150  {
151  radialMenu.ClearEntries();
152  radialMenu = null;
153  }
154 
156  radialMenu = m_AddCommandsMenuController.GetRadialMenu();
157 
158  if (radialMenu)
159  {
160  radialMenu.ClearEntries();
161  radialMenu = null;
162  }
163  }
164 
165  //------------------------------------------------------------------------------------------------
166  protected void OnActionRadialMenuOpen()
167  {
168  if (!m_ActionsMenuController)
169  return;
170 
171  m_ActionsMenuController.Control(GetOwner());
172 
174  if (!editorActionsComponent)
175  return;
176 
177  OnBeforeMenuOpen(m_ActionsMenuController, editorActionsComponent);
178  }
179 
180  //------------------------------------------------------------------------------------------------
181  protected void OnCommandsRadialMenu()
182  {
184  return;
185 
187 
189  if (!editorCommandsComponent)
190  return;
191 
192  OnBeforeMenuOpen(m_CommandsMenuController, editorCommandsComponent, 0);
193  }
194 
195  //------------------------------------------------------------------------------------------------
196  protected void OnAddCommandsRadialMenu()
197  {
199  return;
200 
202 
204  if (!editorCommandsComponent)
205  return;
206 
207  OnBeforeMenuOpen(m_AddCommandsMenuController, editorCommandsComponent, EEditorCommandActionFlags.IS_QUEUE);
208  }
209 
210  //------------------------------------------------------------------------------------------------
211  protected override void EOnEditorActivate()
212  {
213 #ifdef WORKBENCH
214  if (SCR_Global.IsEditMode())
215  return;
216 #endif
217 
218  GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceChanged);
219 
220  InputManager inputManager = GetGame().GetInputManager();
221 
222  // Clearup
223  inputManager.RemoveActionListener(m_sActionName, EActionTrigger.DOWN, OnActionRadialMenuOpen);
224  inputManager.RemoveActionListener(m_sCommandActionName, EActionTrigger.DOWN, OnCommandsRadialMenu);
225  inputManager.RemoveActionListener(m_sAddCommandActionName, EActionTrigger.DOWN, OnAddCommandsRadialMenu);
226 
227  // Setup
228  inputManager.AddActionListener(m_sActionName, EActionTrigger.DOWN, OnActionRadialMenuOpen);
229  inputManager.AddActionListener(m_sCommandActionName, EActionTrigger.DOWN, OnCommandsRadialMenu);
230  inputManager.AddActionListener(m_sAddCommandActionName, EActionTrigger.DOWN, OnAddCommandsRadialMenu);
231  }
232 
233  //------------------------------------------------------------------------------------------------
234  protected override void EOnEditorDelete()
235  {
236 #ifdef WORKBENCH
237  if (SCR_Global.IsEditMode())
238  return;
239 #endif
240  }
241 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SCR_BaseEditorAction
Definition: SCR_BaseEditorAction.c:24
OnBeforeMenuOpen
protected void OnBeforeMenuOpen(notnull SCR_RadialMenuController menuController, notnull SCR_BaseActionsEditorComponent actionsComponent, int flags=0)
Definition: SCR_ActionsRadialMenuEditorComponent.c:75
SCR_RadialMenuController
Definition: SCR_RadialMenuController.c:8
m_CommandsMenuController
protected ref SCR_RadialMenuController m_CommandsMenuController
Definition: SCR_ActionsRadialMenuEditorComponent.c:16
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
CleanMenu
protected void CleanMenu()
Definition: SCR_ActionsRadialMenuEditorComponent.c:133
m_sActionName
protected string m_sActionName
Definition: SCR_ActionsRadialMenuEditorComponent.c:24
SCR_EditorActionSelectionMenuEntry
Definition: SCR_EditorActionSelectionMenuEntry.c:9
SCR_EditorActionData
Definition: SCR_BaseEditorAction.c:280
EOnEditorDelete
protected override void EOnEditorDelete()
Definition: SCR_ActionsRadialMenuEditorComponent.c:234
SCR_BaseEditorComponent
Definition: SCR_BaseEditorComponent.c:119
OnAddCommandsRadialMenu
protected void OnAddCommandsRadialMenu()
Definition: SCR_ActionsRadialMenuEditorComponent.c:196
SCR_MenuLayoutEditorComponent
Definition: SCR_MenuLayoutEditorComponent.c:15
SCR_ContextActionsEditorComponent
Definition: SCR_ContextActionsEditorComponent.c:15
EEditorCommandActionFlags
EEditorCommandActionFlags
Simplified action conditions.
Definition: EEditorCommandActionFlags.c:5
OnCommandsRadialMenu
protected void OnCommandsRadialMenu()
Definition: SCR_ActionsRadialMenuEditorComponent.c:181
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_ActionsRadialMenuEditorComponentClass
Definition: SCR_ActionsRadialMenuEditorComponent.c:5
SCR_UIInfo
Definition: SCR_UIInfo.c:7
SCR_BaseEditorComponentClass
Definition: SCR_BaseEditorComponent.c:2
EOnEditorActivate
protected override void EOnEditorActivate()
Definition: SCR_ActionsRadialMenuEditorComponent.c:211
m_AddCommandsMenuController
protected ref SCR_RadialMenuController m_AddCommandsMenuController
Definition: SCR_ActionsRadialMenuEditorComponent.c:19
SCR_Global
Definition: Functions.c:6
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
m_sCommandActionName
protected string m_sCommandActionName
Definition: SCR_ActionsRadialMenuEditorComponent.c:27
OnActionRadialMenuOpen
protected void OnActionRadialMenuOpen()
Definition: SCR_ActionsRadialMenuEditorComponent.c:166
m_sAddCommandActionName
protected string m_sAddCommandActionName
Definition: SCR_ActionsRadialMenuEditorComponent.c:30
OnInputDeviceChanged
void OnInputDeviceChanged(bool isGamepad)
Definition: SCR_ActionsRadialMenuEditorComponent.c:35
SCR_CommandActionsEditorComponent
Definition: SCR_CommandActionsEditorComponent.c:10
SCR_RadialMenu
Definition: SCR_RadialMenu.c:8
Attribute
SCR_ActionsRadialMenuEditorComponentClass SCR_BaseEditorComponentClass Attribute()] protected ref SCR_RadialMenuController m_ActionsMenuController
Responsible for controlling and managing radial menus used within GameMaster.
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180