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")]
8 protected static const string NO_ASSIGNED_TASK =
"#AR-Tasks_NoAssignedTaskTitle";
9 protected static const string ASSIGN_TASK_HINT =
"#AR-Tasks_NoAssignedTaskDescription";
13 static const ref ScriptInvoker s_OnTaskListVisible =
new ScriptInvoker();
26 ref map<SCR_BaseTask, TextWidget>
m_mTasksTimers =
new map<SCR_BaseTask, TextWidget>();
39 [
Attribute(
"{ACCF501DD69CAF7B}UI/layouts/Tasks/TaskList.layout")]
42 [
Attribute(
"{EE9497AB43F556F9}UI/layouts/Tasks/CurrentTask.layout")]
45 [
Attribute(
"{728FD22A081ABB36}UI/layouts/Tasks/TaskDetail.layout")]
54 [
Attribute(
"{31C4EB3D607069C2}UI/layouts/Tasks/PickAssigneeListEntry.layout")]
87 static void PanMapToTask(
int taskID = -1,
SCR_BaseTask task =
null)
90 if (!mapEntity || !mapEntity.IsOpen())
103 vector taskPos = task.GetOrigin();
104 float screenX, screenY;
105 mapEntity.WorldToScreen(taskPos[0], taskPos[2], screenX, screenY);
106 mapEntity.PanSmooth(screenX, screenY);
116 task.ToggleHUDIcon(
false,
false);
203 TextWidget assigneeNames = TextWidget.Cast(parent.FindAnyWidget(
"TaskAssignees"));
205 TextWidget assigneeTime = TextWidget.Cast(parent.FindAnyWidget(
"AssigneeTime"));
209 if (task.IsIndividual())
214 assigneeTime.SetVisible(task.GetAssignee() && task.IsIndividual());
216 float remainingTime = task.GetAssigneeTimeLeft();
218 assigneeTime.SetText(formattedTimerText);
223 assigneeTime.SetVisible(
false);
229 array<SCR_BaseTaskExecutor> assignees = {};
230 task.GetAssignees(assignees);
232 bool hasAssignees = assignees.Count() > 0;
233 assigneeNames.SetVisible(hasAssignees);
238 string namesText =
"";
240 for (
int i = 0, count = assignees.Count(); i < count; i++)
244 namesText += assignees[i].GetPlayerName();
247 assigneeNames.SetText(namesText);
265 locallyRequestedTask = supportEntity.GetLocallyRequestedTask();
268 if (!localTaskExecutor)
274 faction = factionManager.GetLocalPlayerFaction();
276 array<SCR_BaseTask> tasks = {};
279 if (locallyRequestedTask)
284 locallyRequestedTask.GenerateTaskDescriptionUI(rootWidget,
m_aWidgets);
289 Widget currentTaskUI;
294 Print(
"Null found in task list!", LogLevel.ERROR);
298 if (task == locallyRequestedTask)
301 currentTaskUI = task.GenerateTaskDescriptionUI(rootWidget,
m_aWidgets);
306 if (task == locallyAssignedTask)
308 RichTextWidget textWidget = RichTextWidget.Cast(currentTaskUI.FindAnyWidget(
"TaskTitle"));
312 if (task == taskToFocus)
317 handler.SetCollapsed(
false);
329 array<SCR_BaseTaskSupportEntity> supportedTasks =
GetTaskManager().GetSupportedTasks();
337 for (
int i = supportedTasks.Count() - 1; i >= 0; i--)
339 supportedTasks[i].OnTaskListOpen(
this);
354 widget.RemoveFromHierarchy();
361 override void EOnFrame(IEntity owner,
float timeSlice)
369 GetGame().GetInputManager().ActivateContext(
"TaskListContext");
374 GetGame().GetInputManager().ActivateContext(
"TaskListMapContext");
376 GetGame().GetInputManager().ActivateContext(
"TaskListContext");
396 int minutes = Math.Floor(time / 60);
397 int seconds = Math.Floor(time - (minutes * 60));
399 string minutesString;
402 minutesString += minutes.ToString();
404 string secondsString;
407 secondsString += seconds.ToString();
409 return minutesString +
":" + secondsString;
431 locallyRequestedTask = supportEntity.GetLocallyRequestedTask();
434 if (!localTaskExecutor || !localTaskExecutor.GetAssignedTask())
451 SCR_BaseTask assignedTask = localTaskExecutor.GetAssignedTask();
459 if (localTaskExecutor)
461 TextWidget textWidget = TextWidget.Cast(
m_wCurrentTask.FindAnyWidget(
"TaskTitle"));
464 assignedTask.SetTitleWidgetText(textWidget, assignedTask.GetTaskListTaskTitle());
468 textWidget = TextWidget.Cast(
m_wCurrentTask.FindAnyWidget(
"TaskDescription"));
470 assignedTask.SetTitleWidgetText(textWidget, assignedTask.GetTaskListTaskText());
472 textWidget.SetTextFormat(ASSIGN_TASK_HINT);
474 textWidget = TextWidget.Cast(
m_wCurrentTask.FindAnyWidget(
"CurrentObjectiveText"));
476 textWidget.SetVisible(
true);
478 textWidget.SetVisible(
false);
492 AnimateWidget.StopAnimation(
m_wCurrentTask, WidgetAnimationOpacity);
514 m_wUI.SetVisible(
true);
521 Widget pickAssigneeWidget;
526 MenuBase menu =
GetGame().GetMenuManager().OpenDialog(
ChimeraMenuPreset.PickAssignee, DialogPriority.CRITICAL, 0,
true);
527 pickAssigneeWidget = menu.GetRootWidget();
528 pickAssigneeWidget.SetZOrder(
m_wUI.GetZOrder());
530 Widget playerList = pickAssigneeWidget.FindAnyWidget(
"Players");
534 while (playerList.GetChildren())
536 playerList.RemoveChild(playerList.GetChildren());
542 for (
int i = taskExecutors.Count() - 1; i >= 0; i--)
546 if (executor == localExecutor)
557 Widget playerEntry = playerList.GetWorkspace().CreateWidgets(
m_wPlayerListEntry, playerList);
559 playerEntry.FindAnyWidget(
"IsAssigned").SetVisible(
true);
563 entryHandler.SetExecutor(executor);
565 TextWidget playerName = TextWidget.Cast(playerEntry.FindAnyWidget(
"PlayerName"));
567 playerName.SetText(executor.GetPlayerName());
570 if (entriesCount < 1)
577 if (!pickAssigneeMenu)
587 if (taskNetworkComponent)
590 GetGame().GetMenuManager().CloseMenu(pickAssigneeMenu);
601 if (mapEntity && !mapEntity.IsOpen())
621 if (!mapEntity || !mapEntity.IsOpen())
651 if (!mapEntity.IsOpen())
661 IEntity mapGadget = gadgetManager.GetGadgetByType(EGadgetType.MAP);
666 gadgetManager.SetGadgetMode(mapGadget, EGadgetMode.IN_HAND);
686 if (!taskNetworkComp)
692 int curTaskId = curTask.GetTaskID();
693 taskNetworkComp.AbandonTask(curTaskId);
698 taskId = task.GetTaskID();
705 taskNetworkComp.AbandonTask(taskId);
710 taskNetworkComp.RequestAssignment(taskId);
736 RichTextWidget richTextWidget = RichTextWidget.Cast(
m_wTaskDetail.FindAnyWidget(
"TaskTitle"));
740 richTextWidget = RichTextWidget.Cast(
m_wTaskDetail.FindAnyWidget(
"TaskDescription"));
743 ImageWidget image = ImageWidget.Cast(
m_wTaskDetail.FindAnyWidget(
"TaskIcon"));
744 image.SetEnabled(
false);
763 handler.ExpandTaskLayout();
815 m_wUI = targetWidget;
819 m_wUI.SetVisible(
true);
821 s_OnTaskListVisible.Invoke(
true);
836 m_wUI.SetVisible(
false);
837 s_OnTaskListVisible.Invoke(
false);
856 if (handler && handler.GetTask() == task)
858 GetGame().GetWorkspace().SetFocusedWidget(w);
879 taskListUI.HandleTaskList();
899 if (handler.GetTask() && handler.GetTask() == task)
900 w.RemoveFromHierarchy();
904 task.ClearWidgetIcon();
918 float remainingTime = task.GetAssigneeTimeLeft();
919 if (remainingTime < 0)
924 timer.SetText(formattedTimerText);
949 SetEventMask(owner, EntityEvent.INIT | EntityEvent.FRAME);
967 GetGame().GetInputManager().AddActionListener(
"TasksExpand", EActionTrigger.DOWN,
Action_Expand);
976 GetGame().GetInputManager().RemoveActionListener(
"TasksExpand", EActionTrigger.DOWN,
Action_Expand);
988 ChimeraCharacter character = ChimeraCharacter.Cast(from);
997 ChimeraCharacter character = ChimeraCharacter.Cast(to);
1002 if (!characterController)
1041 if (!playerController)
1044 playerController.m_OnDestroyed.Insert(
OnDestroyed);
1045 int localPlayerID = playerController.GetLocalPlayerId();
1046 if (playerID != localPlayerID)
1088 m_wUI.RemoveFromHierarchy();
1108 m_wUI.RemoveFromHierarchy();