Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CommandActionsEditorUIComponent.c
Go to the documentation of this file.
2 {
3  protected SCR_CommandActionsEditorComponent m_CommandActionsComponent;
4  protected SCR_BaseEditableEntityFilter m_Filter;
5  protected EEditorCommandActionFlags m_State;
6 
7  protected ref ScriptInvoker Event_OnCommandStateChange = new ScriptInvoker();
8 
9  //------------------------------------------------------------------------------------------------
12  EEditorCommandActionFlags GetCommandState()
13  {
14  return m_State;
15  }
16 
17  //------------------------------------------------------------------------------------------------
20  ScriptInvoker GetOnCommandStateChange()
21  {
22  return Event_OnCommandStateChange;
23  }
24 
25  //------------------------------------------------------------------------------------------------
26  protected void PerformDefaultCommand(bool isQueue)
27  {
28  OnOpenActionsMenuDown();
29  if (!OnCancelUp() || IsContextMenuOpen())
30  return;
31 
32  m_CommandActionsComponent.PerformDefaultAction(isQueue);
33  }
34 
35  //------------------------------------------------------------------------------------------------
36  protected void OnEditorSetCommand()
37  {
38  PerformDefaultCommand(false);
39  }
40 
41  //------------------------------------------------------------------------------------------------
42  protected void OnEditorAddCommand()
43  {
44  PerformDefaultCommand(true);
45  }
46 
47  //------------------------------------------------------------------------------------------------
48  protected void OnEditorCommandModifier(float value, EActionTrigger reason)
49  {
50  if (reason == EActionTrigger.DOWN)
51  {
52  UpdateState();
53  m_Filter.GetOnChanged().Insert(OnSelectedChanged);
54  }
55  else
56  {
57  UpdateState(true);
58  m_Filter.GetOnChanged().Remove(OnSelectedChanged);
59  }
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  protected void OnSelectedChanged(EEditableEntityState state, set<SCR_EditableEntityComponent> entitiesInsert, set<SCR_EditableEntityComponent> entitiesRemove)
64  {
65  UpdateState();
66  }
67 
68  //------------------------------------------------------------------------------------------------
69  protected void UpdateState(bool clear = false)
70  {
71 
72  if (clear)
73  m_State = 0;
74  else
75  m_State = m_CommandActionsComponent.ValidateSelection(false);
76 
77  Event_OnCommandStateChange.Invoke(m_State);
78  }
79 
80  //------------------------------------------------------------------------------------------------
81  private void OnMenuUpdate(float tDelta)
82  {
83  m_InputManager.ActivateContext("EditorCommandContext");
84  //m_InputManager.ActivateContext("EditorCommandActionsContext");
85  //m_InputManager.SetContextDebug("EditorCommandActionsContext", true);
86  }
87 
88  //------------------------------------------------------------------------------------------------
89  override void HandlerAttachedScripted(Widget w)
90  {
91  super.HandlerAttachedScripted(w);
92 
94  m_EditorActionsComponent = m_CommandActionsComponent;
95  if (!m_CommandActionsComponent)
96  return;
97 
98  if (m_InputManager)
99  {
100  m_InputManager.AddActionListener("EditorSetCommand", EActionTrigger.DOWN, OnEditorSetCommand);
101  m_InputManager.AddActionListener("EditorAddCommand", EActionTrigger.DOWN, OnEditorAddCommand);
102 
103  m_InputManager.AddActionListener("EditorCommandModifier", EActionTrigger.DOWN, OnEditorCommandModifier);
104  m_InputManager.AddActionListener("EditorCommandModifier", EActionTrigger.UP, OnEditorCommandModifier);
105  }
106 
107  m_Filter = SCR_BaseEditableEntityFilter.GetInstance(EEditableEntityState.COMMANDED, true); //--- ToDo: Don't hardcode
108 
109  MenuRootBase menu = GetMenu();
110  if (!menu)
111  return;
112 
113  menu.GetOnMenuUpdate().Insert(OnMenuUpdate);
114  }
115 
116  //------------------------------------------------------------------------------------------------
117  override void HandlerDeattached(Widget w)
118  {
119  super.HandlerDeattached(w);
120 
121  if (m_InputManager)
122  {
123  m_InputManager.RemoveActionListener("EditorSetCommand", EActionTrigger.DOWN, OnEditorSetCommand);
124  m_InputManager.RemoveActionListener("EditorAddCommand", EActionTrigger.DOWN, OnEditorAddCommand);
125 
126  m_InputManager.RemoveActionListener("EditorCommandModifier", EActionTrigger.DOWN, OnEditorCommandModifier);
127  m_InputManager.RemoveActionListener("EditorCommandModifier", EActionTrigger.UP, OnEditorCommandModifier);
128  }
129 
130  if (m_Filter)
131  m_Filter.GetOnChanged().Remove(OnSelectedChanged);
132 
133  MenuRootBase menu = GetMenu();
134  if (!menu)
135  return;
136 
137  menu.GetOnMenuUpdate().Remove(OnMenuUpdate);
138  }
139 }
EEditableEntityState
EEditableEntityState
Definition: EEditableEntityState.c:37
m_InputManager
protected InputManager m_InputManager
Definition: SCR_BaseManualCameraComponent.c:15
GetMenu
SCR_RadialMenu GetMenu()
Definition: SCR_RadialMenuGameModeComponent.c:41
MenuRootBase
Definition: MenuRootBase.c:6
SCR_BaseContextMenuEditorUIComponent
Definition: SCR_BaseContextMenuEditorUIComponent.c:2
EEditorCommandActionFlags
EEditorCommandActionFlags
Simplified action conditions.
Definition: EEditorCommandActionFlags.c:5
m_EditorActionsComponent
protected SCR_ToolbarActionsEditorComponent m_EditorActionsComponent
Definition: SCR_ActionsToolbarEditorUIComponent.c:22
SCR_BaseEditableEntityFilter
Definition: SCR_BaseEditableEntityFilter.c:13
m_State
private EEditableEntityState m_State
Definition: SCR_BaseEntitiesEditorUIEffect.c:3
SCR_CommandActionsEditorUIComponent
Definition: SCR_CommandActionsEditorUIComponent.c:1
SCR_CommandActionsEditorComponent
Definition: SCR_CommandActionsEditorComponent.c:10