10 protected Widget m_wMainWidget;
12 protected static const string ACCEPT_TASK =
"#AR-CampaignTasks_ButtonAccept";
13 protected static const string ABANDON_TASK =
"#AR-CampaignTasks_ButtonAbandon";
14 protected static const string CANCEL_TASK =
"#AR-CampaignTasks_ButtonCancel";
15 protected static const string LOCAL_EXECUTOR_IS_ASSIGNED_TEXT =
"#AR-CampaignTasks_ButtonBusy";
16 protected static const string ASSIGNEE_TIMEOUT_TEXT =
"#AR-CampaignTasks_ButtonWait";
17 protected static const string TASK_ABANDONED_TEXT =
"#AR-CampaignTasks_ButtonWait";
19 protected static const float ANIM_SPEED =
UIConstants.FADE_RATE_SUPER_FAST;
21 protected string m_sAssignees =
"AssigneesLayout";
22 protected Widget m_wAssignees;
23 protected Widget m_wRootWidget;
26 protected ref Color m_AssignedTaskColor;
28 [
Attribute(
"{10C0A9A305E8B3A4}UI/Imagesets/Tasks/Task_Icons.imageset",
category:
"Task icon",
params:
"imageset")]
29 protected ResourceName m_sIconImageset;
44 void SetAssigneeCount(
int count)
46 TextWidget text = TextWidget.Cast(m_wAssignees.FindAnyWidget(
"Text"));
48 text.SetText(count.ToString());
49 m_wAssignees.SetVisible(count > 0);
53 void SetTaskTextColor()
56 RichTextWidget textWidget = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(
"TaskTitle"));
60 textWidget.SetColor(Color.FromInt(Color.WHITE));
64 void SetTaskIconColor()
67 ImageWidget outline = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"Icon_Outline"));
68 ImageWidget symbol = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"Icon_Symbol"));
69 ImageWidget background = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"Icon_Background"));
71 if (!outline || !symbol || !background || !
m_Task)
80 background.SetColor(faction.GetFactionColor());
82 else if (
m_Task.IsPriority())
84 background.LoadImageFromSet(0,m_sIconImageset,
SCR_BaseTask.TASK_BG_M);
85 background.SetColor(Color.FromInt(Color.WHITE));
86 outline.LoadImageFromSet(0,m_sIconImageset,
SCR_BaseTask.TASK_O_M);
90 background.LoadImageFromSet(0,m_sIconImageset,
SCR_BaseTask.TASK_BG);
91 background.SetColor(Color.FromInt(Color.WHITE));
92 outline.LoadImageFromSet(0,m_sIconImageset,
SCR_BaseTask.TASK_O);
95 symbol.LoadImageFromSet(0,
m_Task.GetIconImageset(),
m_Task.GetTaskListIconName() +
m_Task.GetIconSuffix());
96 outline.SetColor(faction.GetOutlineFactionColor());
97 symbol.SetColor(faction.GetOutlineFactionColor());
103 ImageWidget outline = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"Icon_Outline"));
104 ImageWidget symbol = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"Icon_Symbol"));
105 ImageWidget background = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"Icon_Background"));
107 if (!outline || !symbol || !background || !
m_Task)
112 SetAssigneeCount(task.GetAssigneeCount());
113 UpdateAssignButtonText(task);
117 TextWidget textWidget = TextWidget.Cast(
m_wRoot.FindAnyWidget(
"TaskTitle"));
119 task.SetTitleWidgetText(textWidget, task.GetTaskListTaskTitle());
121 textWidget = TextWidget.Cast(
m_wRoot.FindAnyWidget(
"TaskDescription"));
123 task.SetTitleWidgetText(textWidget, task.GetTaskListTaskText());
128 background.LoadImageFromSet(0,m_sIconImageset,
SCR_BaseTask.TASK_BG_M);
129 outline.LoadImageFromSet(0,m_sIconImageset,
SCR_BaseTask.TASK_O_M);
133 background.LoadImageFromSet(0,m_sIconImageset,
SCR_BaseTask.TASK_BG);
134 outline.LoadImageFromSet(0,m_sIconImageset,
SCR_BaseTask.TASK_O);
139 protected void UpdateAssignButtonText(
SCR_BaseTask task)
142 if (task.CanBeAssigned(reason))
145 m_AssignButton.SetLabel(ACCEPT_TASK);
169 m_AssignButton.SetLabel(ACCEPT_TASK);
176 void Expand(
bool expand)
178 float targetOpacity = 0;
182 m_AssignButton.SetEnabled(expand);
183 Widget assignBtn =
m_wRoot.FindAnyWidget(
"AcceptButton");
184 AnimateWidget.Opacity(assignBtn, targetOpacity, ANIM_SPEED);
186 Widget mapBtn =
m_wRoot.FindAnyWidget(
"MapButton");
187 AnimateWidget.Opacity(mapBtn, targetOpacity, ANIM_SPEED);
191 override bool OnClick(Widget w,
int x,
int y,
int button)
193 super.OnClick(w, x, y, button);
195 InputManager im =
GetGame().GetInputManager();
196 if (!im.IsUsingMouseAndKeyboard() || !IsAnyButtonHovered())
206 void ExpandTaskLayout()
208 if (!m_CollapseHandler)
211 m_CollapseHandler.SetCollapsed(!m_CollapseHandler.IsCollapsed());
212 Expand(!m_CollapseHandler.IsCollapsed());
218 foreach (Widget task : uiTaskManager.GetWidgetsArray())
221 if (collapse && collapse !=
this && !collapse.IsCollapsed())
223 collapse.Expand(
false);
224 collapse.SetCollapsed(
true);
230 override bool OnFocusLost(Widget w,
int x,
int y)
232 super.OnFocusLost(w, x, y);
239 tm.SetSelectedWidget(w);
245 override bool OnFocus(Widget w,
int x,
int y)
247 super.OnFocus(w, x, y);
258 void SetCollapsed(
bool collapse,
bool anim =
true)
264 m_CollapseHandler.SetCollapsed(collapse, anim);
265 Widget assignBtns =
m_wRoot.FindAnyWidget(
"AcceptButton");
268 assignBtns.SetOpacity(opacity);
269 assignBtns.SetEnabled(opacity);
271 Widget mapBtn =
m_wRoot.FindAnyWidget(
"MapButton");
274 mapBtn.SetOpacity(opacity);
275 mapBtn.SetEnabled(opacity);
281 protected bool IsAnyButtonHovered()
283 return (!m_ShowOnMapButton.IsHovering() &&
284 !m_AssignButton.IsHovering());
288 protected bool IsCollapsed()
290 return m_CollapseHandler.IsCollapsed();
294 protected void AcceptTask()
298 utm.Action_AssignTask(
m_Task);
302 protected void PickAssignee()
306 utm.Action_PickAssignee();
310 protected void ShowOnMap()
314 utm.Action_ShowOnMap();
318 override void HandlerAttached(Widget w)
320 super.HandlerAttached(w);
324 m_wAssignees = w.FindAnyWidget(m_sAssignees);
329 m_AssignButton.SetEnabled(
false);
330 m_AssignButton.m_OnActivated.Insert(AcceptTask);
334 if (m_ShowOnMapButton)
335 m_ShowOnMapButton.m_OnActivated.Insert(ShowOnMap);
337 Widget collapse = w.FindAnyWidget(
"Description");
346 Widget assignBtn =
m_wRoot.FindAnyWidget(
"AcceptButton");
348 assignBtn.SetOpacity(0);
350 Widget mapBtn =
m_wRoot.FindAnyWidget(
"MapButton");
352 mapBtn.SetOpacity(0);
356 override void HandlerDeattached(Widget w)
358 super.HandlerDeattached(w);