Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TaskManagerUIComponent.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/Tasks", description: "This is a task manager related component that allows you to display the available tasks.", color: "0 0 255 255")]
5
8typedef ScriptInvokerBase<TaskAssigned> SCR_TaskAssignedInvoker;
9
12typedef ScriptInvokerBase<TaskSelected> SCR_TaskSelectedInvoker;
13
16typedef ScriptInvokerBase<TaskHovered> SCR_TaskHoveredInvoker;
17
18void TaskColorsUpdated(Color backgroundColor, Color iconColor, Color outlineColor);
20typedef ScriptInvokerBase<TaskColorsUpdated> SCR_TaskColorsUpdatedInvoker;
21
22void TaskBackgroundUpdated(ResourceName imageset, string name);
24typedef ScriptInvokerBase<TaskBackgroundUpdated> SCR_TaskBackgroundUpdatedInvoker;
25
27{
28 [Attribute("{EE9497AB43F556F9}UI/layouts/Tasks/CurrentTask.layout")]
30
31 [Attribute("5", UIWidgets.EditBox, "Defines duration of current task display (in seconds)")]
32 protected float m_fCurrentTaskShowTime;
33
34 [Attribute("{10C0A9A305E8B3A4}UI/Imagesets/Tasks/Task_Icons.imageset")]
36
37 [Attribute("Icon_M_Task_Seize")]
38 protected string m_sDefaultIcon;
39
40 [Attribute("1", desc: "Defines whether number of people assigned to task should be displayed on map task marker")]
42
43 [Attribute("0")]
45
46 [Attribute("{C9D32771B2166F77}Configs/Task/TasksTabConfig_Base.conf", UIWidgets.ResourceNamePicker, params: "conf class=SCR_TasksTabConfig")]
48
49 [Attribute(desc:"Task UI color preset list")]
50 protected ref array<ref SCR_TaskUIColorPresetList> m_aTaskUIColorPresetList;
51
53
61 protected bool m_bIsUnconscious; //Character is unconscious --> Task menu control is disabled
62 protected bool m_bCurrentTaskVisible;
63
68
71 protected SCR_TaskListUIComponent m_TaskListComponent;
73
74 protected const string CONTENT_TASK_LIST_MAP = "TaskListMapContext";
75 protected const string ACTION_CLOSE_TASK_LIST = "TasksClose";
76
77 //------------------------------------------------------------------------------------------------
78 // constructor
83 {
84 SetEventMask(GetOwner(), EntityEvent.INIT | EntityEvent.FRAME);
85
86 if (!s_Instance)
87 s_Instance = this;
88 }
89
90 //------------------------------------------------------------------------------------------------
91 // destructor
93 {
94 s_Instance = null;
95
97 if (mapEntity)
98 {
99 mapEntity.GetOnMapOpen().Remove(OnMapOpen);
100 mapEntity.GetOnMapClose().Remove(OnMapClose);
101 }
102 }
103
104 //------------------------------------------------------------------------------------------------
105 override void EOnInit(IEntity owner)
106 {
108
109 m_TaskSystem = SCR_TaskSystem.GetInstance();
110
111 GetGame().GetInputManager().AddActionListener("TasksShowHint", EActionTrigger.DOWN, ToggleCurrentTask);
112
114 if (!gameMode)
115 return;
116
117 gameMode.GetOnPlayerConnected().Insert(OnPlayerConnected);
118
119 if (System.IsConsoleApp())
120 return;
121
123
125 if (mapEntity)
126 {
127 mapEntity.GetOnMapOpen().Insert(OnMapOpen);
128 mapEntity.GetOnMapClose().Insert(OnMapClose);
129 }
130 }
131
132 //------------------------------------------------------------------------------------------------
133 override void EOnFrame(IEntity owner, float timeSlice)
134 {
135 if (m_MapEntity && m_MapEntity.IsOpen() && IsTaskListOpen())
136 GetGame().GetInputManager().ActivateContext(CONTENT_TASK_LIST_MAP);
137 }
138
139 //------------------------------------------------------------------------------------------------
142 {
144 return;
145
146 GetGame().GetCallqueue().Remove(ToggleCurrentTask);
147
148 int playerID = SCR_PlayerController.GetLocalPlayerId();
149 SCR_Faction faction = SCR_Faction.Cast(SCR_FactionManager.SGetPlayerFaction(playerID));
150 if (playerID <= 0 || !faction)
151 return;
152
154
155 if (!m_wTaskHint)
156 m_wTaskHint = GetGame().GetWorkspace().CreateWidgets(m_sTaskHintLayout);
157
158 if (!m_wTaskHint)
159 return;
160
162 {
164 if (!currentTaskComp)
165 return;
166
167 SCR_TaskExecutor player = SCR_TaskExecutor.FromPlayerID(playerID);
168 if (!player)
169 return;
170
171 m_AssignedTask = m_TaskSystem.GetTaskAssignedTo(player);
172 currentTaskComp.UpdateTask(m_AssignedTask);
173
175 GetGame().GetCallqueue().CallLater(ToggleCurrentTask, m_fCurrentTaskShowTime * 1000);
176 }
177 else
178 {
180 }
181 }
182
183 //------------------------------------------------------------------------------------------------
186 {
187 if (!m_MapEntity)
188 return;
189
190 if (!m_MapEntity.IsOpen())
191 {
193 if (!player)
194 return;
195
197 if (!gadgetManager)
198 return;
199
200 IEntity mapGadget = gadgetManager.GetGadgetByType(EGadgetType.MAP);
201 if (!mapGadget)
202 return;
203
204 gadgetManager.SetGadgetMode(mapGadget, EGadgetMode.IN_HAND);
205
206 GetGame().GetCallqueue().CallLater(PanMapToTask, 1000, false, m_SelectedTask.GetTaskID(), m_SelectedTask);
207 }
208 else
209 {
211 }
212 }
213
214 //------------------------------------------------------------------------------------------------
218 protected void PanMapToTask(string taskID = string.Empty, SCR_Task task = null)
219 {
220 if (!m_MapEntity || !m_MapEntity.IsOpen())
221 return;
222
223 if (!task)
224 {
225 task = m_TaskSystem.GetTaskFromTaskID(taskID);
226 if (!task)
227 return;
228 }
229
230 vector taskPos = task.GetOrigin();
231 float screenX, screenY;
232 m_MapEntity.WorldToScreen(taskPos[0], taskPos[2], screenX, screenY);
233 m_MapEntity.PanSmooth(screenX, screenY);
234 }
235
236 //------------------------------------------------------------------------------------------------
240 {
241 PlayerController localPlayerController = GetGame().GetPlayerController();
242 if (!localPlayerController)
243 return;
244
245 SCR_TaskSystemNetworkComponent networkComponent = SCR_TaskSystemNetworkComponent.Cast(localPlayerController.FindComponent(SCR_TaskSystemNetworkComponent));
246 if (!networkComponent)
247 return;
248
249 int playerID = localPlayerController.GetPlayerId();
250 SCR_TaskExecutor executor = SCR_TaskExecutor.FromPlayerID(playerID);
251 if (!executor)
252 return;
253
254 if (!task)
255 {
256 if (!m_SelectedTask)
257 return;
258
260 }
261
262 if (task == m_AssignedTask)
263 {
264 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.TASK_CANCELED);
265 networkComponent.UnassignTask(m_AssignedTask, executor, playerID);
266
267 m_AssignedTask = null;
268 }
269 else
270 {
271 if (m_AssignedTask)
272 networkComponent.UnassignTask(m_AssignedTask, executor);
273
274 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.TASK_ACCEPT);
275 networkComponent.AssignTask(task, executor, true, playerID);
276
278 }
279
281 m_OnTaskAssigned.Invoke(task);
282 }
283
284 //------------------------------------------------------------------------------------------------
286 protected void CloseTaskList()
287 {
289 }
290
291 //------------------------------------------------------------------------------------------------
293 void TaskHUDVisibilityChanged(bool newVisibility)
294 {
296 m_OnTaskHUDVisible.Invoke(newVisibility);
297 }
298
299 //------------------------------------------------------------------------------------------------
308
309 //------------------------------------------------------------------------------------------------
313 {
315 if (m_OnTaskHovered)
316 m_OnTaskHovered.Invoke(task);
317 }
318
319 //------------------------------------------------------------------------------------------------
323 {
324 if (from)
325 {
326 ChimeraCharacter character = ChimeraCharacter.Cast(from);
327 if (!character)
328 return;
329
330 SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
331 if (controller)
332 controller.m_OnLifeStateChanged.Remove(LifeStateChanged);
333 }
334
335 ChimeraCharacter character = ChimeraCharacter.Cast(to);
336 if (!character)
337 return;
338
339 SCR_CharacterControllerComponent characterController = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
340 if (!characterController)
341 return;
342
343 m_bIsUnconscious = characterController.IsUnconscious();
344 characterController.m_OnLifeStateChanged.Insert(LifeStateChanged);
345 }
346
347 //------------------------------------------------------------------------------------------------
348 protected void LifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
349 {
350 m_bIsUnconscious = newLifeState == ECharacterLifeState.INCAPACITATED;
351 }
352
353 //------------------------------------------------------------------------------------------------
354 override void OnPlayerConnected(int playerId)
355 {
357 if (!playerController)
358 return;
359
360 int localPlayerID = playerController.GetLocalPlayerId();
361 if (playerId != localPlayerID)
362 return;
363
365
366 SCR_PlayerControllerGroupComponent groupComponent = SCR_PlayerControllerGroupComponent.Cast(playerController.FindComponent(SCR_PlayerControllerGroupComponent));
367 if (groupComponent)
368 groupComponent.GetOnGroupChanged().Insert(OnGroupChanged);
369 }
370
371 //------------------------------------------------------------------------------------------------
372 protected void OnClientPlayerRegistered(int playerId)
373 {
375 if (!playerController)
376 return;
377
378 if (playerId != playerController.GetLocalPlayerId())
379 return;
380
382 }
383
384 //------------------------------------------------------------------------------------------------
386 {
387 // show current task on respawn
390 }
391
392 //------------------------------------------------------------------------------------------------
393 protected void OnGroupChanged(int groupID)
394 {
395 m_SelectedTask = null;
396 m_AssignedTask = null;
397 }
398
399 //------------------------------------------------------------------------------------------------
402 protected void OnMapOpen(MapConfiguration config)
403 {
404 m_SelectedTask = null;
405 }
406
407 //------------------------------------------------------------------------------------------------
410 protected void OnMapClose(MapConfiguration config)
411 {
412 m_SelectedTask = null;
413 }
414
415 //------------------------------------------------------------------------------------------------
420 void UpdateTaskColors(Color backgroundColor, Color iconColor, Color outlineColor)
421 {
422 m_OnTaskColorsUpdate.Invoke(backgroundColor, iconColor, outlineColor);
423 }
424
425 //------------------------------------------------------------------------------------------------
429 void UpdateTaskBackground(ResourceName imageset, string name)
430 {
431 m_OnTaskBackgroundUpdate.Invoke(imageset, name);
432 }
433
434 //------------------------------------------------------------------------------------------------
437 {
438 return s_Instance;
439 }
440
441 //------------------------------------------------------------------------------------------------
444 {
445 return m_SelectedTask;
446 }
447
448 //------------------------------------------------------------------------------------------------
451 {
452 return m_AssignedTask;
453 }
454
455 //------------------------------------------------------------------------------------------------
458 {
460 return false;
461
462 return m_TaskListComponent.GetTaskListVisibility();
463 }
464
465 //------------------------------------------------------------------------------------------------
468 void RegisterTaskList(SCR_TaskListUIComponent component)
469 {
470 m_TaskListComponent = component;
471 }
472
473 //------------------------------------------------------------------------------------------------
477 {
479 return false;
480
481 m_TaskListComponent.RefreshTaskList();
482
483 return true;
484 }
485
486 //------------------------------------------------------------------------------------------------
488 bool SetTaskDescriptionVisiblity(bool newVisibility)
489 {
491 return false;
492
493 m_TaskListComponent.SetTaskDescriptionVisiblity(newVisibility);
494
495 return true;
496 }
497
498 //------------------------------------------------------------------------------------------------
501 void SetJournalVisibility(bool newVisibility)
502 {
504 if (!mapEntity)
505 return;
506
508 if (!journalUI)
509 return;
510
511 journalUI.SetJournalVisibility(newVisibility);
512
514 if (!taskUI)
515 return;
516
517 taskUI.ToggleTaskList(false);
518 }
519
520 //------------------------------------------------------------------------------------------------
523 void SetTaskListVisibility(bool newVisibility)
524 {
526 if (!mapEntity)
527 return;
528
530 if (!taskUI)
531 return;
532
533 taskUI.ToggleTaskList(newVisibility);
534
537
539 if (!journalUI)
540 return;
541
542 journalUI.SetJournalVisibility(false);
543 }
544
545 //------------------------------------------------------------------------------------------------
547 SCR_TaskListUIComponent GetTaskListComponent()
548 {
550 return null;
551
552 return m_TaskListComponent;
553 }
554
555 //------------------------------------------------------------------------------------------------
558 {
560 return null;
561
563 if (desc)
564 return desc;
565
566 return null;
567 }
568
569 //------------------------------------------------------------------------------------------------
575
576 //------------------------------------------------------------------------------------------------
579 {
580 return m_sDefaultIcon;
581 }
582
583 //------------------------------------------------------------------------------------------------
589
590 //------------------------------------------------------------------------------------------------
592 array<SCR_ETaskTabType> GetTaskTabs()
593 {
594 if (!m_TaskTabConfig)
596
597 return m_TaskTabConfig.GetTaskTabs();
598 }
599
600 //------------------------------------------------------------------------------------------------
603 {
604 if (!m_TaskTabConfig)
606
607 if (!m_TaskTabConfig)
608 return SCR_ETaskTabType.AVAILABLE;
609
610 return m_TaskTabConfig.GetDefaultTab();
611 }
612
613 //------------------------------------------------------------------------------------------------
615 array<ref SCR_TaskUIColorPresetList> GetTaskUIColorPresetList()
616 {
618 }
619
620 //------------------------------------------------------------------------------------------------
628
629 //------------------------------------------------------------------------------------------------
637
638 //------------------------------------------------------------------------------------------------
646
647 //------------------------------------------------------------------------------------------------
655
656 //------------------------------------------------------------------------------------------------
664
665 //------------------------------------------------------------------------------------------------
673}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
void SCR_FactionManager(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ScriptInvokerBase< ScriptInvokerBoolMethod > ScriptInvokerBool
void SCR_Task(IEntitySource src, IEntity parent)
Definition SCR_Task.c:1938
ScriptInvokerBase< TaskSelected > SCR_TaskSelectedInvoker
ScriptInvokerBase< TaskBackgroundUpdated > SCR_TaskBackgroundUpdatedInvoker
func TaskAssigned
func TaskBackgroundUpdated
ScriptInvokerBase< TaskColorsUpdated > SCR_TaskColorsUpdatedInvoker
ScriptInvokerBase< TaskAssigned > SCR_TaskAssignedInvoker
func TaskColorsUpdated
ScriptInvokerBase< TaskHovered > SCR_TaskHoveredInvoker
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Definition Color.c:13
ScriptInvokerBase< SCR_BaseGameMode_PlayerId > GetOnPlayerConnected()
ScriptInvokerBase< SCR_BaseGameMode_PlayerId > GetOnPlayerRegistered()
ref OnLifeStateChangedInvoker m_OnLifeStateChanged
void SetGadgetMode(IEntity gadget, EGadgetMode targetMode, bool doFocus=false)
IEntity GetGadgetByType(EGadgetType type)
static SCR_GadgetManagerComponent GetGadgetManager(IEntity entity)
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapClose()
Get on map close invoker.
SCR_MapUIBaseComponent GetMapUIComponent(typename componentType)
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapOpen()
Get on map open invoker.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
void SetJournalVisibility(bool visibility)
void ToggleTaskList(bool visibility)
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
ref OnControlledEntityChangedPlayerControllerInvoker m_OnControlledEntityChanged
static IEntity GetLocalControlledEntity()
override void EOnFrame(IEntity owner, float timeSlice)
void OnClientControlledEntityChanged(IEntity from, IEntity to)
void OnMapOpen(MapConfiguration config)
SCR_TaskListEntryDescriptionUIComponent GetTaskDescriptionComponent()
SCR_TaskBackgroundUpdatedInvoker GetOnTaskBackgroundUpdated()
ref SCR_TaskSelectedInvoker m_OnTaskSelected
void TaskHUDVisibilityChanged(bool newVisibility)
Invokes whenever task list on HUD is shown.
ref SCR_TaskBackgroundUpdatedInvoker m_OnTaskBackgroundUpdate
override void EOnInit(IEntity owner)
SCR_TaskListUIComponent GetTaskListComponent()
void ToggleCurrentTask()
Displays a hint with currently selected task.
bool SetTaskDescriptionVisiblity(bool newVisibility)
void SetTaskListVisibility(bool newVisibility)
void UpdateTaskColors(Color backgroundColor, Color iconColor, Color outlineColor)
array< ref SCR_TaskUIColorPresetList > GetTaskUIColorPresetList()
SCR_TaskListUIComponent m_TaskListComponent
void SetJournalVisibility(bool newVisibility)
void PanMapToTask(string taskID=string.Empty, SCR_Task task=null)
SCR_TaskAssignedInvoker GetOnTaskAssigned()
static SCR_TaskManagerUIComponent GetInstance()
ref SCR_TaskHoveredInvoker m_OnTaskHovered
SCR_TaskSelectedInvoker GetOnTaskSelected()
array< SCR_ETaskTabType > GetTaskTabs()
SCR_TaskColorsUpdatedInvoker GetOnTaskColorsUpdated()
ref SCR_TaskAssignedInvoker m_OnTaskAssigned
void ShowTaskOnMap()
Requests panning map to task. If map is not opened - opens it.
static SCR_TaskManagerUIComponent s_Instance
void UpdateTaskBackground(ResourceName imageset, string name)
void RegisterTaskList(SCR_TaskListUIComponent component)
void OnMapClose(MapConfiguration config)
void SCR_TaskManagerUIComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_TaskHoveredInvoker GetOnTaskHovered()
ref array< ref SCR_TaskUIColorPresetList > m_aTaskUIColorPresetList
void LifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
void OnControlledEntityChanged(IEntity from, IEntity to)
ref SCR_TaskColorsUpdatedInvoker m_OnTaskColorsUpdate
override void OnPlayerConnected(int playerId)
IEntity GetOwner()
Owner entity of the fuel tank.
ECharacterLifeState
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
proto external PlayerController GetPlayerController()
EActionTrigger