Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ContextActionsEditorComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Editor", description: "Manager of editor context actions", icon: "WBData/ComponentEditorProps/componentEditor.png")]
3 {
4 };
5 
15 class SCR_ContextActionsEditorComponent : SCR_BaseActionsEditorComponent
16 {
17  protected ref ScriptInvoker m_OnMenuOpen = new ScriptInvoker();
18  protected SCR_LayersEditorComponent m_LayerManager;
19  protected SCR_StatesEditorComponent m_StateManager;
20 
25  ScriptInvoker GetOnMenuOpen()
26  {
27  return m_OnMenuOpen;
28  }
29 
30  override protected int ValidateSelection(bool isInstant)
31  {
32  //--- Evaluate selected/hovered-on entities only when selecting, not when placing or transforming
33  if (!m_StateManager || m_StateManager.GetState() == EEditorState.SELECTING)
34  {
35 
36  if (m_HoverManager)
37  {
38  m_HoveredEntity = m_HoverManager.GetFirstEntity();
39 
40  //--- If the entity is inside a composition, make the composition the hovered entity
41  if (m_LayerManager)
42  m_HoveredEntity = m_LayerManager.GetParentBelowCurrentLayer(m_HoveredEntity);
43 
44  //--- Update selection
46  {
47  if (m_HoveredEntity)
48  {
49  //--- Open menu over entity outside of the current selection - select it instead
50  if (!m_SelectedManager.Contains(m_HoveredEntity))
52  }
53  else if (!isInstant)
54  {
55  //--- Opened menu without any entity under cursor - clear the selection
56  //--- (not when the action was activated instantly, i.e., by a shortcut; it would prevent. e.g., deleting selected entity when cursor is on empty space)
57  m_SelectedManager.Clear();
58  }
59  }
60  }
61  else
62  {
63  m_HoveredEntity = null;
64  }
65 
66  //--- Clear previously cached entities
67  m_SelectedEntities.Clear();
68 
69  //--- Get selected entities
72 
73  //--- No entities selected, use the entity under cursor (needed for example when deleting composition while hovering over one of its child entities)
74  if (m_HoveredEntity && m_SelectedEntities.IsEmpty())
76  }
77  else
78  {
79  m_HoveredEntity = null;
80  m_SelectedEntities.Clear();
81  }
82 
83  //--- Cache flags
85  if (GetManager().IsLimited())
86  {
87  flags |= EEditorContextActionFlags.LIMITED;
88  }
89  if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
90  {
91  flags |= EEditorContextActionFlags.USING_MOUSE_AND_KEYBOARD;
92  }
93  return flags;
94  }
95  override void EvaluateActions(notnull array<SCR_BaseEditorAction> actions, vector cursorWorldPosition, out notnull array<ref SCR_EditorActionData> filteredActions, out int flags = 0)
96  {
97  super.EvaluateActions(actions, cursorWorldPosition, filteredActions, flags);
98  m_OnMenuOpen.Invoke(actions, cursorWorldPosition, filteredActions, flags);
99  }
100 
101  override protected bool ActionCanBeShown(SCR_BaseEditorAction action, vector cursorWorldPosition, int flags)
102  {
103  return action.GetInfo() && action.CanBeShown(m_HoveredEntity, m_SelectedEntities, cursorWorldPosition, flags);
104  }
105 
106  override protected bool ActionCanBePerformed(SCR_BaseEditorAction action, vector cursorWorldPosition, int flags)
107  {
108  return action.CanBePerformed(m_HoveredEntity, m_SelectedEntities, cursorWorldPosition, flags);
109  }
110 
111  override void EOnEditorActivate()
112  {
113  super.EOnEditorActivate();
114  DiagMenu.RegisterMenu(SCR_DebugMenuID.DEBUGUI_EDITOR_ACTIONS_MENU, "Actions Menu", "Editor");
115 
118  }
119 
120  override void EOnEditorDeactivate()
121  {
122  super.EOnEditorDeactivate();
123  DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_EDITOR_ACTIONS_MENU);
124  }
125 };
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SCR_BaseEditorAction
Definition: SCR_BaseEditorAction.c:24
EEditorState
EEditorState
Unique editor state.
Definition: EEditorState.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_BaseActionsEditorComponentClass
Definition: SCR_BaseActionsEditorComponent.c:20
m_HoverManager
SCR_BaseActionsEditorComponentClass m_HoverManager
m_HoveredEntity
protected SCR_EditableEntityComponent m_HoveredEntity
Definition: SCR_BaseActionsEditorComponent.c:154
SCR_ContextActionsEditorComponent
Definition: SCR_ContextActionsEditorComponent.c:15
m_SelectedManager
protected SCR_BaseEditableEntityFilter m_SelectedManager
Definition: SCR_BaseActionsEditorComponent.c:151
EEditorContextActionFlags
EEditorContextActionFlags
Definition: EEditorContextActionFlags.c:1
SCR_LayersEditorComponent
Definition: SCR_LayersEditorManager.c:11
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
SCR_StatesEditorComponent
Definition: SCR_StatesEditorComponent.c:9
m_SelectedEntities
protected ref set< SCR_EditableEntityComponent > m_SelectedEntities
Definition: SCR_BaseActionsEditorComponent.c:155
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3
SCR_ContextActionsEditorComponentClass
Definition: SCR_ContextActionsEditorComponent.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180