Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CycleWaypointEditorUIComponent.c
Go to the documentation of this file.
1class SCR_CycleWaypointEditorUIComponent : SCR_ModularButtonComponent
2{
4
5 [Attribute()]
7
8 [Attribute()]
9 protected string m_sSeparatorWidgetName;
10
11 [Attribute()]
12 protected string m_sRadialActionName;
13
14 [Attribute("0.8")]
15 protected float m_fGamepadScale;
16
17 [Attribute("8.0")]
18 protected float m_fMKBottomPadding;
19
21 protected SCR_ModularButtonComponent m_ModularButtonToggleComponent;
24
25 protected bool m_bIsGamepad;
26
27 //------------------------------------------------------------------------------------------------
28 protected void OnInputDeviceIsGamepad(bool isGamepad)
29 {
30 m_bIsGamepad = isGamepad;
32 }
33
34
35 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
36 //------------------------------------------------------------------------------------------------
38 protected void UpdateInputVisuals()
39 {
40 if (m_wSeparator)
41 m_wSeparator.SetVisible(!m_bIsGamepad);
42
43 float scale = 1.0;
44 float bottomPadding = m_fMKBottomPadding;
45 if (m_bIsGamepad)
46 {
48 bottomPadding = 0;
49 }
50
51 ScaleWidget scaleWidget = ScaleWidget.Cast(m_wCycleWaypointsToggle.GetParent());
52 if (scaleWidget)
53 scaleWidget.SetScale(scale);
54
55 }
56 //---- REFACTOR NOTE END ----
57
58 //------------------------------------------------------------------------------------------------
60 protected void OnSelectedEntitiesChange(EEditableEntityState state, set<SCR_EditableEntityComponent> entitiesInsert, set<SCR_EditableEntityComponent> entitiesRemove)
61 {
62 Widget container = GetRootWidget();
63 bool isVisible = CanShowToggleCycleWaypoint();
64 if (container)
65 container.SetVisible(isVisible);
66
69 }
70
71 //------------------------------------------------------------------------------------------------
72 override void HandlerAttached(Widget w)
73 {
74 super.HandlerAttached(w);
75
77 if (entitiesManager)
79
82
83 //++ Initializes toggle on
86 return;
87
88 m_ModularButtonToggleComponent = SCR_ModularButtonComponent.FindComponent(m_wCycleWaypointsToggle);
90 {
92
93 //++ Style toggle
95 }
96
98
99 //++ Initializes the separator
101
102 GetGame().GetInputManager().AddActionListener(m_sRadialActionName, EActionTrigger.PRESSED, ToggleCycleWaypoints);
103
104 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
106 }
107
108 //------------------------------------------------------------------------------------------------
109 override void HandlerDeattached(Widget w)
110 {
111 super.HandlerDeattached(w);
112
115
116 GetGame().GetInputManager().RemoveActionListener(m_sRadialActionName, EActionTrigger.PRESSED, ToggleCycleWaypoints);
117 }
118
119
120 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
121 //------------------------------------------------------------------------------------------------
123 protected void ToggleCycleWaypoints()
124 {
125 set<SCR_EditableGroupComponent> selectedGroups = new set<SCR_EditableGroupComponent>();
126 if (!GetSelectedGroups(selectedGroups))
127 return;
128
129 bool isEnabled = !selectedGroups.Get(0).AreCycledWaypointsEnabled();
130 if (isEnabled)
132 else
134 }
135 //---- REFACTOR NOTE END ----
136
137 //------------------------------------------------------------------------------------------------
139 protected void EnableCycleWaypoints()
140 {
141 set<SCR_EditableGroupComponent> selectedGroups = new set<SCR_EditableGroupComponent>();
142 if (!GetSelectedGroups(selectedGroups))
143 return;
144
145 if(!m_PlacingEditor)
146 return;
147
148 m_PlacingEditor.SetCycleWaypoints(selectedGroups, true);
149
151 m_ModularButtonToggleComponent.SetToggled(true);
152 }
153
154 //------------------------------------------------------------------------------------------------
156 protected void DisableCycleWaypoints()
157 {
158 set<SCR_EditableGroupComponent> selectedGroups = new set<SCR_EditableGroupComponent>();
159 if (!GetSelectedGroups(selectedGroups))
160 return;
161
162 if(!m_PlacingEditor)
163 return;
164
165 m_PlacingEditor.SetCycleWaypoints(selectedGroups, false);
166
168 m_ModularButtonToggleComponent.SetToggled(false);
169 }
170
171 //------------------------------------------------------------------------------------------------
175 protected bool GetSelectedGroups(notnull out set<SCR_EditableGroupComponent> selectedGroups)
176 {
177 set<SCR_EditableEntityComponent> selectedEntities = new set<SCR_EditableEntityComponent>();
178 m_SelectedEntitiesManager.GetEntities(selectedEntities);
179
181 foreach (SCR_EditableEntityComponent entity : selectedEntities)
182 {
183 group = SCR_EditableGroupComponent.Cast(entity.GetAIGroup());
184 if (group)
185 selectedGroups.Insert(group);
186 }
187
188 return !selectedGroups.IsEmpty();
189 }
190
191 //------------------------------------------------------------------------------------------------
195 {
196 set<SCR_EditableEntityComponent> selectedEntities = new set<SCR_EditableEntityComponent>();
198 m_SelectedEntitiesManager.GetEntities(selectedEntities);
199
201 foreach (SCR_EditableEntityComponent entity : selectedEntities)
202 {
203 group = SCR_EditableGroupComponent.Cast(entity.GetAIGroup());
204 if (group && group.AreCycledWaypointsEnabled())
205 return true;
206 }
207
208 return false;
209 }
210
211 //------------------------------------------------------------------------------------------------
214 {
215 set<SCR_EditableEntityComponent> selectedEntities = new set<SCR_EditableEntityComponent>();
216 m_SelectedEntitiesManager.GetEntities(selectedEntities);
217
218 foreach (SCR_EditableEntityComponent entity : selectedEntities)
219 {
220 if (SCR_EditableGroupComponent.Cast(entity.GetAIGroup()))
221 return true;
222 }
223
224 return false;
225 }
226}
vector scale
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_EditableGroupComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Widget GetRootWidget()
bool GetSelectedGroups(notnull out set< SCR_EditableGroupComponent > selectedGroups)
void ToggleCycleWaypoints()
Toggle cycle waypoints for selected groups, based on the status of the first group.
void EnableCycleWaypoints()
Enable cycle waypoints for selected groups.
void DisableCycleWaypoints()
Disable cycle waypoints for selected groups.
bool CanShowToggleCycleWaypoint()
Returns if toggle cycle waypoint button can be shown.
void UpdateInputVisuals()
Styles the widget according to the current input device.
void OnSelectedEntitiesChange(EEditableEntityState state, set< SCR_EditableEntityComponent > entitiesInsert, set< SCR_EditableEntityComponent > entitiesRemove)
Runs when selected entities from entities manager change. Used to update visibility of toggle.
SCR_BaseEditableEntityFilter GetFilter(EEditableEntityState state, bool showError=false)
EEditableEntityState
SCR_FieldOfViewSettings Attribute
EActionTrigger