Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TutorialFastTravelMapMenuUI.c
Go to the documentation of this file.
1
2//------------------------------------------------------------------------------------------------
5{
9
10 //------------------------------------------------------------------------------------------------
12 {
13 if (!task || !m_MapEntity)
14 return null;
15
17 if (!mapUIElementContainer)
18 return null;
19
20 return SCR_TutorialTaskMapUIComponent.Cast(mapUIElementContainer.GetTaskFromID(task.GetTaskID()));
21 }
22
23 //------------------------------------------------------------------------------------------------
24 protected void ConfirmSelection()
25 {
26 if (!m_SelectedTask)
27 return;
28
29 SCR_TutorialGamemodeComponent tutorial = SCR_TutorialGamemodeComponent.GetInstance();
30 if (!tutorial)
31 return;
32
33 tutorial.FastTravelToCourse(m_SelectedTask.GetTaskID().ToInt());
34
35 MenuManager menuMan = GetGame().GetMenuManager();
36 if (menuMan)
37 menuMan.FindMenuByPreset(ChimeraMenuPreset.TutorialFastTravel).Close();
38 }
39
40 //------------------------------------------------------------------------------------------------
41 protected void SelectTask(SCR_Task task)
42 {
43 if (!task)
44 return;
45
47 {
49 if (taskUI)
50 taskUI.SetSelected(false);
51 }
52
55 if (taskUI)
56 taskUI.SetSelected(true);
57
58 vector position = task.GetOrigin();
59 if (m_MapEntity)
60 m_MapEntity.ZoomPanSmooth(1.5, position[0], position[2]);
61
62 m_SpinboxComp.SetCurrentItem(m_SpinboxComp.GetItemIndex(task));
63 }
64
65 //------------------------------------------------------------------------------------------------
66 override void OnMenuOpen()
67 {
68 if (!m_MapEntity)
69 return;
70
71 MapConfiguration mapConfigFullscreen = m_MapEntity.SetupMapConfig(EMapEntityMode.TUTORIALFASTTRAVEL, "{727AAAACDCBB4EFE}Configs/Map/TutorialFastTravelMap.conf", GetRootWidget());
72 m_MapEntity.OpenMap(mapConfigFullscreen);
73
74 m_MapEntity.GetOnMapOpen().Insert(OnMapOpen);
75
77
79 if (taskManagerUI)
80 taskManagerUI.GetOnTaskSelected().Insert(SelectTask);
81 }
82
83 //------------------------------------------------------------------------------------------------
85 {
86 SCR_TutorialGamemodeComponent tutorial = SCR_TutorialGamemodeComponent.GetInstance();
87 if (!tutorial)
88 return;
89
90 InputManager inputMan = GetGame().GetInputManager();
91 if (!inputMan)
92 return;
93
94 if (inputMan.IsUsingMouseAndKeyboard())
95 {
96 tutorial.FastTravelToCourse(task.GetTaskID().ToInt());
97
98 MenuManager menuMan = GetGame().GetMenuManager();
99 if (menuMan)
100 menuMan.FindMenuByPreset(ChimeraMenuPreset.TutorialFastTravel).Close();
101
102 return;
103 }
104
106 }
107
108 //------------------------------------------------------------------------------------------------
109 protected void SetupSpinbox()
110 {
111 Widget spinBox = GetRootWidget().FindAnyWidget("FastTravelSpinBox");
112 if (!spinBox)
113 return;
114
116 if (!m_SpinboxComp)
117 return;
118
119 SCR_TaskSystem taskSystem = SCR_TaskSystem.GetInstance();
120 if (!taskSystem)
121 return;
122
123 array<SCR_Task> tasks = {};
124 taskSystem.GetTasks(tasks);
125
126 foreach (SCR_Task task : tasks)
127 {
128 if (task.GetTaskVisibility() == SCR_ETaskVisibility.NONE)
129 continue;
130
131 m_SpinboxComp.AddItem(task.GetTaskName(), false, task);
132 }
133
134 m_SpinboxComp.m_OnChanged.Insert(OnSpinboxChanged);
135 }
136
137 //------------------------------------------------------------------------------------------------
139 {
140 SelectTask(SCR_Task.Cast(m_SpinboxComp.GetCurrentItemData()));
141 }
142
143 //------------------------------------------------------------------------------------------------
145 {
146 m_MapEntity.GetOnMapOpen().Remove(OnMapOpen);
147
148 m_MapEntity.ZoomPanSmooth(0.35, m_MapEntity.GetMapSizeX()/ 2, m_MapEntity.GetMapSizeY()* 0.5);
149
150 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_HUD_MAP_OPEN);
151
152 InputManager inputMan = GetGame().GetInputManager();
153 if (inputMan)
154 {
155 inputMan.AddActionListener("TutorialFastTravelMapMenuClose", EActionTrigger.DOWN, Close);
156 inputMan.AddActionListener("TutorialFastTravelMapMenuConfirm", EActionTrigger.DOWN, ConfirmSelection);
157 inputMan.AddActionListener("TutorialFastTravelMapSpinboxLeaveHorizontal", EActionTrigger.DOWN, ResetFocus);
158 inputMan.AddActionListener("TutorialFastTravelMapSpinboxLeaveVertical", EActionTrigger.DOWN, ResetFocus);
159 OnInputDeviceIsGamepad(!inputMan.IsUsingMouseAndKeyboard());
160 }
161
162 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
163 }
164
165 //------------------------------------------------------------------------------------------------
166 override void OnMenuClose()
167 {
169 if (m_MapEntity)
170 {
171 m_MapEntity.CloseMap();
172
173 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_HUD_MAP_CLOSE);
174 }
175
176 InputManager inputMan = GetGame().GetInputManager();
177 if (!inputMan)
178 return;
179
180 inputMan.RemoveActionListener("TutorialFastTravelMapSpinboxLeaveHorizontal", EActionTrigger.DOWN, ResetFocus);
181 inputMan.RemoveActionListener("TutorialFastTravelMapSpinboxLeaveVertical", EActionTrigger.DOWN, ResetFocus);
182 inputMan.RemoveActionListener("TutorialFastTravelMapMenuClose", EActionTrigger.DOWN, Close);
183 inputMan.RemoveActionListener("TutorialFastTravelMapMenuConfirm", EActionTrigger.DOWN, ConfirmSelection);
184
185 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
186 }
187
188 //------------------------------------------------------------------------------------------------
189 override void OnMenuInit()
190 {
191 if (!m_MapEntity)
193 }
194
195 //------------------------------------------------------------------------------------------------
196 protected void TasksIgnoreStandardInputs(bool ignore)
197 {
198 SCR_TaskSystem taskSystem = SCR_TaskSystem.GetInstance();
199 if (!taskSystem)
200 return;
201
202 array<SCR_Task> tasks = {};
203 taskSystem.GetTasks(tasks);
204
206 foreach (SCR_Task task : tasks)
207 {
208 mapUiComp = GetTaskMapUIComponent(task);
209 if (mapUiComp)
210 mapUiComp.IgnoreStandardInputs(ignore);
211 }
212 }
213
214 //------------------------------------------------------------------------------------------------
215 protected void ResetFocus()
216 {
217 GetGame().GetWorkspace().SetFocusedWidget(null);
218 }
219
220 //------------------------------------------------------------------------------------------------
221 protected void OnInputDeviceIsGamepad(bool isGamepad)
222 {
223 if (!m_SpinboxComp)
224 return;
225
226 ScriptInvokerBool invoker = m_SpinboxComp.GetOnFocus();
227 if (!invoker)
228 return;
229
230 if (isGamepad)
231 {
233 invoker.Insert(TasksIgnoreStandardInputs);
234 }
235 else
236 {
238 invoker.Remove(TasksIgnoreStandardInputs);
239 }
240 }
241}
ChimeraMenuPreset
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
vector position
EMapEntityMode
Mode of the map.
Widget GetRootWidget()
ScriptInvokerBase< ScriptInvokerBoolMethod > ScriptInvokerBool
SCR_ETaskVisibility
Definition SCR_Task.c:24
void SCR_Task(IEntitySource src, IEntity parent)
Definition SCR_Task.c:1938
Constant variables used in various menus.
Input management system for user interactions.
proto external MenuBase FindMenuByPreset(ScriptMenuPresetEnum preset)
Finds first menu/dialog with given preset index, or nullptr when there is no such menu opened.
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapOpen()
Get on map open invoker.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
SCR_TaskMapUIComponent GetTaskFromID(string taskID)
static SCR_TaskManagerUIComponent GetInstance()
SCR_TaskSelectedInvoker GetOnTaskSelected()
SCR_TutorialFastTravelSpinBox m_SpinboxComp
SCR_TutorialTaskMapUIComponent GetTaskMapUIComponent(SCR_Task task)
EActionTrigger