Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ServerHostingModSubMenu.c
Go to the documentation of this file.
1 /*
2 Server hosting dialog sub menu for setting up mods
3 */
4 
6 {
7  protected const string NAV_ENABLE = "#AR-Workshop_ButtonEnable";
8  protected const string NAV_DISABLE = "#AR-Workshop_ButtonDisable";
9  protected const string NAV_ENABLE_ALL = "#AR-ServerHosting_EnableAll";
10  protected const string NAV_DISABLE_ALL = "#AR-Workshop_DisableAll";
11 
12  protected const string SORT_BTN_SORT_LABEL = "#AR-Editor_TooltipDetail_WaypointIndex_Name";
13  protected const string SORT_BTN_SORT_ACTION = "MenuFilter";
14  protected const string SORT_BTN_PLACE_LABEL = "#AR-Button_Confirm-UC";
15  protected const string SORT_BTN_PLACE_ACTION = "MenuSelect";
16 
17  // Attributes
18  [Attribute("", UIWidgets.ResourceNamePicker, "Used layout for mod enabling", "layout")]
19  protected ResourceName m_EntryLayout;
20 
21  [Attribute()]
22  protected ref SCR_WidgetListEntry m_AddonEntryTemplate;
23 
24  // Fields
25  protected ref SCR_ServerHostingModsWidgets m_Widgets = new SCR_ServerHostingModsWidgets();
26 
27  protected SCR_ListBoxComponent m_DisabledList;
28  protected SCR_ListBoxComponent m_EnabledList;
29 
30  protected ScrollLayoutWidget m_wDisableScroll;
31  protected ScrollLayoutWidget m_wEnableScroll;
32  protected SCR_GamepadScrollComponent m_DisableScroll;
33  protected SCR_GamepadScrollComponent m_EnableScroll;
34 
35  protected ref array<ref Widget> m_aEnabled = {};
36  protected ref array<ref Widget> m_aDisabled = {};
37 
38  // Navigation buttons
39  protected SCR_InputButtonComponent m_NavWorkshop;
40  protected SCR_InputButtonComponent m_NavEnable;
41  protected SCR_InputButtonComponent m_NavEnableAll;
42  protected SCR_InputButtonComponent m_NavSelectSort;
43  protected SCR_InputButtonComponent m_NavChangeSortOrder;
44  protected SCR_InputButtonComponent m_NavDownloadDependencies;
45 
46  protected SCR_AddonLineDSConfigComponent m_FocusedLine;
47  protected SCR_AddonLineDSConfigComponent m_OrderedLine;
48 
49  protected ref map<ref SCR_WorkshopItem, ref SCR_AddonLineDSConfigComponent> m_aEnabledMods = new map<ref SCR_WorkshopItem, ref SCR_AddonLineDSConfigComponent>();
50 
51  protected bool m_bIsListeningForCommStatus;
52  protected bool m_bIsSorting;
53 
54  protected ref ScriptInvokerVoid Event_OnWorkshopButtonActivate;
55 
56  // --- Overrides ---
57  //------------------------------------------------------------------------------------------------
58  override void HandlerAttached(Widget w)
59  {
60  super.HandlerAttached(w);
61 
62  m_Widgets.Init(w);
63 
64  // Find scroll components
65  m_wDisableScroll = ScrollLayoutWidget.Cast(m_Widgets.m_wDisabledAddonsList.GetParent());
66  m_wEnableScroll = ScrollLayoutWidget.Cast(m_Widgets.m_wEnabledAddonsList.GetParent());
67 
68  m_DisableScroll = SCR_GamepadScrollComponent.Cast(m_wDisableScroll.FindHandler(SCR_GamepadScrollComponent));
69  m_EnableScroll = SCR_GamepadScrollComponent.Cast(m_wEnableScroll.FindHandler(SCR_GamepadScrollComponent));
70 
71  // Setup action all buttons
72  m_Widgets.m_ButtonEnableAllComponent0.m_OnClicked.Insert(OnEnableAllClicked);
73  m_Widgets.m_ButtonEnableAllComponent0.m_OnClicked.Insert(OnDisableAllClicked);
74 
75  // Disable Delete All buttons
76  m_Widgets.m_wDeleteAllEnabled.SetVisible(false);
77  m_Widgets.m_wDeleteAllDisabled.SetVisible(false);
78 
79  CreateAddonList();
80 
81  SetupDownloadingCallbacks();
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  override void HandlerDeattached(Widget w)
86  {
87  super.HandlerDeattached(w);
88  ClearDownloadingCallbacks();
89 
90  SCR_ServicesStatusHelper.GetOnCommStatusCheckFinished().Remove(OnCommStatusCheckFinished);
91  m_bIsListeningForCommStatus = false;
92  }
93 
94  //------------------------------------------------------------------------------------------------
95  override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
96  {
97  super.OnTabCreate(menuRoot, buttonsLayout, index);
98 
99  m_NavWorkshop = CreateNavigationButton("MenuDownloadManager", "#AR-Workshop_WorkshopPageName", false);
100  if (m_NavWorkshop)
101  m_NavWorkshop.m_OnActivated.Insert(OnOpenWorkshopButton);
102 
103  m_NavSelectSort = CreateNavigationButton(SORT_BTN_SORT_ACTION, SORT_BTN_SORT_LABEL, true);
104  if (m_NavSelectSort)
105  m_NavSelectSort.m_OnActivated.Insert(OnNavSelectSortActivate);
106 
107  m_NavChangeSortOrder = CreateNavigationButton("MenuVertical", SORT_BTN_SORT_LABEL, true);
108  if (m_NavChangeSortOrder)
109  FlagNavigationButtonVisibility(m_NavChangeSortOrder, false);
110 
111  m_NavEnableAll = CreateNavigationButton("MenuEnableAll", NAV_ENABLE_ALL, true);
112  if (m_NavEnableAll)
113  m_NavEnableAll.m_OnActivated.Insert(OnNavEnableAllActivated);
114 
115  m_NavEnable = CreateNavigationButton("MenuEnable", NAV_ENABLE, true);
116  if (m_NavEnable)
117  m_NavEnable.m_OnActivated.Insert(OnNavEnableActivated);
118 
119  ShowNavigationButtons(false);
120  }
121 
122  //------------------------------------------------------------------------------------------------
123  override void OnTabShow()
124  {
125  // Focus fist entry next frame to ensure focus will happend
126  GetGame().GetCallqueue().Call(FocusFirstEntry);
127 
128  SCR_ServicesStatusHelper.RefreshPing();
129 
130  if (!m_bIsListeningForCommStatus)
131  SCR_ServicesStatusHelper.GetOnCommStatusCheckFinished().Insert(OnCommStatusCheckFinished);
132 
133  m_bIsListeningForCommStatus = true;
134  UpdateWorkshopButton();
135 
136  super.OnTabShow();
137  }
138 
139  //------------------------------------------------------------------------------------------------
140  override void OnTabHide()
141  {
142  super.OnTabHide();
143 
144  ReleaseSort();
145 
146  SCR_ServicesStatusHelper.GetOnCommStatusCheckFinished().Remove(OnCommStatusCheckFinished);
147  m_bIsListeningForCommStatus = false;
148  }
149 
150  //------------------------------------------------------------------------------------------------
151  protected void UpdateWorkshopButton()
152  {
153  if (!m_NavWorkshop)
154  return;
155 
156  SCR_InputButtonComponent.SetConnectionButtonEnabled(m_NavWorkshop, SCR_ServicesStatusHelper.SERVICE_WORKSHOP);
157  }
158 
159  //------------------------------------------------------------------------------------------------
160  protected void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
161  {
162  UpdateWorkshopButton();
163  }
164 
165  //------------------------------------------------------------------------------------------------
166  override void ShowNavigationButtons(bool show)
167  {
168  super.ShowNavigationButtons(show && !m_aEnabledMods.IsEmpty());
169  }
170 
171  //------------------------------------------------------------------------------------------------
172  // Protected
173  //------------------------------------------------------------------------------------------------
174  //------------------------------------------------------------------------------------------------
175  protected void FocusFirstEntry()
176  {
177  if (!m_aDisabled.IsEmpty())
178  {
179  if (m_aDisabled[0])
180  GetGame().GetWorkspace().SetFocusedWidget(m_aDisabled[0]);
181  }
182  else
183  {
184  if (!m_aEnabled.IsEmpty() && m_aEnabled[0])
185  GetGame().GetWorkspace().SetFocusedWidget(m_aEnabled[0]);
186  }
187  }
188 
189  //------------------------------------------------------------------------------------------------
191  protected void CreateAddonList()
192  {
193  if (!SCR_AddonManager.GetInstance())
194  return;
195 
196  array<ref SCR_WorkshopItem> addons = SCR_AddonManager.GetInstance().GetOfflineAddons();
197 
198  for (int i = 0, count = addons.Count(); i < count; i++)
199  {
200  SCR_ERevisionAvailability availability = SCR_AddonManager.ItemAvailability(addons[i].Internal_GetWorkshopItem());
201 
202  if (availability == SCR_ERevisionAvailability.ERA_AVAILABLE)
203  AddLineEntry(addons[i], i);
204  }
205  }
206 
207  //------------------------------------------------------------------------------------------------
208  protected void AddLineEntry(SCR_WorkshopItem item, int id)
209  {
210  // Line setup
211  Widget w = GetGame().GetWorkspace().CreateWidgets(m_EntryLayout, m_Widgets.m_wDisabledAddonsList);
213  w.FindHandler(SCR_AddonLineDSConfigComponent));
214 
215  if (!line)
216  return;
217 
218  // Callbacks
219  line.GetOnEnableButton().Insert(OnAddonEnabled);
220  line.GetOnDisableButton().Insert(OnAddonDisabled);
221  line.GetOnSortConfirm().Insert(OnSortConfirm);
222  line.GetEventOnButtonUp().Insert(OnLineButtonUp);
223  line.GetEventOnButtonDown().Insert(OnLineButtonDown);
224  line.GetOnFocus().Insert(OnLineFocus);
225  line.GetOnFocusLost().Insert(OnLineFocusLost);
226 
227  line.Init(item);
228  m_aDisabled.Insert(w);
229  w.SetZOrder(id);
230 
231  // Enable map
232  m_aEnabledMods.Insert(item, line);
233  }
234 
235  //------------------------------------------------------------------------------------------------
237  protected int FindLineId(SCR_AddonLineDSConfigComponent line)
238  {
239  for (int i = 0, count = m_aEnabledMods.Count(); i < count; i++)
240  {
241  if (m_aEnabledMods.GetElement(i) == line)
242  return i;
243  }
244 
245  return -1;
246  }
247 
248  //------------------------------------------------------------------------------------------------
249  protected int LastFocusedId(Widget line, bool enabled)
250  {
251  array<ref Widget> list = {};
252 
253  if (enabled)
254  list = m_aDisabled;
255  else
256  list = m_aEnabled;
257 
258  // Single entry?
259  if (list.Count() == 1)
260  return -1;
261 
262  return list.Find(line);
263  }
264 
265  //------------------------------------------------------------------------------------------------
267  protected Widget ClosestAddonLine(int lineId, bool enabled)
268  {
269  array<ref Widget> list = {};
270 
271  if (enabled)
272  list = m_aDisabled;
273  else
274  list = m_aEnabled;
275 
276  // Not found?
277  if (lineId == -1)
278  return null;
279 
280  //Widget closestLine = list[lineId];
281 
282  // Check if last line
283  // This is hack for current implemenation
284  // ideally there should be unified logic with SCR_WorkshopListAddonsSubmenu.ClosestAddonLine
285  Widget closestLine;
286 
287  if (lineId < list.Count())
288  closestLine = list[lineId];
289  else
290  closestLine = list[lineId - 1];
291 
292  return closestLine;
293  }
294 
295  //-------------------------------------------------------------------------------------------
297  void EnableModsFromDSConfig(notnull SCR_DSConfig config)
298  {
299  array<ref DSMod> mods = config.game.mods;
300  array<ref SCR_WorkshopItem> items = {};
301 
302  for (int i = 0, count = mods.Count(); i < count; i++)
303  {
304  SCR_AddonLineDSConfigComponent line = FindLineByModId(mods[i].modId);
305  if (line)
306  {
307  // Do not restore corrupted mod
308  if (line.HasItemAnyIssue())
309  continue;
310 
311  items.Insert(line.GetWorkshopItem());
312  }
313  }
314 
315  EnableItems(true, items);
316  }
317 
318  //-------------------------------------------------------------------------------------------
319  protected SCR_AddonLineDSConfigComponent FindLineByModId(string id)
320  {
321  for (int i = 0, count = m_aEnabledMods.Count(); i < count; i++)
322  {
323  SCR_AddonLineDSConfigComponent line = m_aEnabledMods.GetElement(i);
324  if (!line)
325  continue;
326 
327  SCR_WorkshopItem item = line.GetWorkshopItem();
328  if (!item)
329  return null;
330 
331  if (id == item.GetId())
332  return line;
333  }
334 
335  return null;
336  }
337 
338  //------------------------------------------------------------------------------------------------
340  protected void SetupDownloadingCallbacks()
341  {
342  SCR_DownloadManager downloadManager = SCR_DownloadManager.GetInstance();
343  if (!downloadManager)
344  return;
345 
346  array<ref SCR_WorkshopItemActionDownload> actions = downloadManager.GetDownloadQueue();
347 
348  for (int i = 0, count = actions.Count(); i < count; i++)
349  {
350  actions[i].m_OnCompleted.Insert(OnDownloadComplete);
351  }
352  }
353 
354  //------------------------------------------------------------------------------------------------
355  protected void ClearDownloadingCallbacks()
356  {
357  array<ref SCR_WorkshopItemActionDownload> actions = {};
358 
359  if (!SCR_DownloadManager.GetInstance() || !SCR_DownloadManager.GetInstance().GetDownloadQueue())
360  return;
361 
362  actions = SCR_DownloadManager.GetInstance().GetDownloadQueue();
363 
364  for (int i = 0, count = actions.Count(); i < count; i++)
365  {
366  actions[i].m_OnCompleted.Remove(OnDownloadComplete);
367  }
368  }
369 
370  //------------------------------------------------------------------------------------------------
371  protected void UpdateNavigationButtons(SCR_AddonLineDSConfigComponent line, bool forceDisabled = false)
372  {
373  if (!line)
374  forceDisabled = true;
375 
376  bool enabled = line && line.GetWidgetEnabled();
377 
378  if (m_NavEnable)
379  {
380  bool issues = line && line.HasItemAnyIssue();
381 
382  m_NavEnable.SetEnabled(!m_OrderedLine && !issues && !forceDisabled, false);
383 
384  if (enabled)
385  m_NavEnable.SetLabel(NAV_DISABLE);
386  else
387  m_NavEnable.SetLabel(NAV_ENABLE);
388 
389  if (issues)
390  m_NavEnable.SetTexture(UIConstants.ICONS_IMAGE_SET, "dependencies", Color.FromInt(UIColors.WARNING_DISABLED.PackToInt()));
391  else
392  m_NavEnable.ResetTexture();
393  }
394 
395  if (m_NavEnableAll)
396  {
397  m_NavEnableAll.SetEnabled(!m_OrderedLine && !forceDisabled, false);
398 
399  if (enabled)
400  m_NavEnableAll.SetLabel(NAV_DISABLE_ALL);
401  else
402  m_NavEnableAll.SetLabel(NAV_ENABLE_ALL);
403  }
404 
405  if (m_NavSelectSort)
406  m_NavSelectSort.SetEnabled(!forceDisabled && enabled, false);
407 
408  SCR_WorkshopItem item;
409  if (line)
410  item = line.GetWorkshopItem();
411 
412  bool dependenciesRequired;
413  if (item)
414  dependenciesRequired = item.GetAnyDependencyMissing() || item.GetAnyDependencyUpdateAvailable();
415  }
416 
417  //------------------------------------------------------------------------------------------------
418  // Callbacks
419  //------------------------------------------------------------------------------------------------
420  //------------------------------------------------------------------------------------------------
421  protected void OnAddonEnabled(SCR_ScriptedWidgetComponent component)
422  {
424  if (!line)
425  return;
426 
427  SCR_WorkshopItem item = line.GetWorkshopItem();
428  if (!item)
429  return;
430 
431  // Enable dependencies
432  array<ref SCR_WorkshopItem> dependencies = item.GetLatestDependencies();
433  dependencies.Insert(item);
434 
435  EnableItems(!line.GetWidgetEnabled(), dependencies);
436  }
437 
438  //------------------------------------------------------------------------------------------------
439  protected void OnAddonDisabled(SCR_ScriptedWidgetComponent component)
440  {
442  if (!line)
443  return;
444 
445  SCR_WorkshopItem item = line.GetWorkshopItem();
446  if (!item)
447  return;
448 
449  // Unselect dependent mods
450  array<ref SCR_WorkshopItem> dependent = item.GetDependentAddons();
451 
452  // Add item
453  dependent.Insert(item);
454 
455  EnableItems(false, dependent);
456  }
457 
458  //------------------------------------------------------------------------------------------------
459  protected void OnLineFocus(SCR_ScriptedWidgetComponent component)
460  {
462  if (!line)
463  return;
464 
465  m_FocusedLine = line;
466 
467  UpdateNavigationButtons(line);
468  }
469 
470  //------------------------------------------------------------------------------------------------
471  protected void OnLineFocusLost(SCR_ScriptedWidgetComponent component)
472  {
473  m_FocusedLine = null;
474 
476  UpdateNavigationButtons(line, true);
477 
478  // Prevent move between list when ordering
479  if (m_OrderedLine && m_OrderedLine != m_FocusedLine)
480  GetGame().GetCallqueue().Call(FocusLine, m_OrderedLine);
481  }
482 
483  //----------------------------------------------------------------------------------------------
484  protected void OnDownloadComplete(SCR_WorkshopItemAction action)
485  {
486  // Add mod to mod list
487  AddLineEntry(action.GetWorkshopItem(), m_aDisabled.Count());
488  action.m_OnCompleted.Remove(OnDownloadComplete);
489  }
490 
491  //------------------------------------------------------------------------------------------------
493  protected void EnableItems(bool enable, array<ref SCR_WorkshopItem> items)
494  {
495  if (items.IsEmpty())
496  return;
497 
498  SCR_WorkshopItem item = items[0];
499 
500  SCR_AddonLineDSConfigComponent line = SCR_AddonLineDSConfigComponent.Cast(m_aEnabledMods.Get(item));
501 
502  if (line)
503  {
504  Widget lineRoot = line.GetRootWidget();
505 
506  // Enable
507  if (enable && !line.GetWidgetEnabled())
508  {
509  // Move to enabled
510  m_Widgets.m_wEnabledAddonsList.AddChild(lineRoot);
511  m_aEnabled.Insert(lineRoot);
512  m_aDisabled.RemoveItem(lineRoot);
513 
514  lineRoot.SetZOrder(m_aEnabled.Count() - 1);
515  }
516  else if (!enable && line.GetWidgetEnabled())
517  {
518  // Move to disabled
519  m_Widgets.m_wDisabledAddonsList.AddChild(lineRoot);
520  m_aDisabled.Insert(lineRoot);
521  m_aEnabled.RemoveItem(lineRoot);
522 
523  lineRoot.SetZOrder(m_aDisabled.Count() - 1);
524  }
525 
526  line.SetWidgetEnabled(enable);
527  }
528 
529  // Order disabled mods
530  for (int i = 0, count = m_aDisabled.Count(); i < count; i++)
531  {
532  m_aDisabled[i].SetZOrder(i);
533  }
534 
535  // Order enabled mods
536  for (int i = 0, count = m_aEnabled.Count(); i < count; i++)
537  {
538  m_aEnabled[i].SetZOrder(i);
539 
541  if (lineCmp)
542  lineCmp.SetOnBottom(i == m_aEnabled.Count() - 1);
543  }
544 
545  // Call next
546  items.Remove(0);
547  if (!items.IsEmpty())
548  {
549  GetGame().GetCallqueue().Call(EnableItems, enable, items);
550  }
551  else
552  {
553  // On finished fix list scrolls
554  float x,y;
555  m_wDisableScroll.GetSliderPos(x, y);
556 
557  if (y > 1)
558  m_wDisableScroll.SetSliderPos(0, 1, true);
559 
560  m_wEnableScroll.GetSliderPos(x, y);
561 
562  if (y > 1)
563  m_wEnableScroll.SetSliderPos(0, 1, true);
564 
565  // Check focus
566  if (m_FocusedLine)
567  OnLineFocus(m_FocusedLine);
568  }
569  }
570 
571  //------------------------------------------------------------------------------------------------
572  protected void OnLineButtonUp(SCR_ScriptedWidgetComponent component)
573  {
575  if (!line)
576  return;
577 
578  // Check if not on top
579  int id = line.GetRootWidget().GetZOrder();
580 
581  if (id == -1 || id == 0)
582  return;
583 
584  // Enter sorting mode
585  if (!m_bIsSorting)
586  StartSort(line);
587 
588  // Move up
589  m_aEnabled[id] = m_aEnabled[id-1];
590  m_aEnabled[id].SetZOrder(id);
591 
592  m_aEnabled[id-1] = line.GetRootWidget();
593  m_aEnabled[id-1].SetZOrder(id-1);
594 
595  // Set line is on bottom
596  if (id == m_aEnabled.Count() - 1)
597  {
599  if (otherLine)
600  otherLine.SetOnBottom(true);
601  }
602 
603  line.SetOnBottom(false);
604  }
605 
606  //------------------------------------------------------------------------------------------------
607  protected void OnLineButtonDown(SCR_ScriptedWidgetComponent component)
608  {
610  if (!line)
611  return;
612 
613  // Check if not on bottom
614  int id = line.GetRootWidget().GetZOrder();
615 
616  if (id == -1 || id >= m_aEnabled.Count() - 1)
617  return;
618 
619  // Enter sorting mode
620  if (!m_bIsSorting)
621  StartSort(line);
622 
623  // Move down
624  m_aEnabled[id] = m_aEnabled[id+1];
625  m_aEnabled[id].SetZOrder(id);
626 
627  m_aEnabled[id+1] = line.GetRootWidget();
628  m_aEnabled[id+1].SetZOrder(id+1);
629 
630  // Set line is on bottom
632  if (otherLine)
633  otherLine.SetOnBottom(false);
634 
635  if (id + 1 == m_aEnabled.Count() - 1)
636  line.SetOnBottom(true);
637  }
638 
639  //------------------------------------------------------------------------------------------------
640  protected void OnSortConfirm(SCR_ScriptedWidgetComponent component)
641  {
643  if (line)
644  Sort(line);
645  }
646 
647  //------------------------------------------------------------------------------------------------
648  protected void OnEnableAllClicked()
649  {
650  array<ref SCR_WorkshopItem> enable = {};
651 
652  for (int i = 0, count = m_aEnabledMods.Count(); i < count; i++)
653  {
654  SCR_WorkshopItem item = m_aEnabledMods.GetKey(i);
655  SCR_AddonLineDSConfigComponent line = m_aEnabledMods.GetElement(i);
656  if (!line)
657  continue;
658 
659  if (!line.HasItemAnyIssue())
660  enable.Insert(item);
661  }
662 
663  EnableItems(true, enable);
664  }
665 
666  //------------------------------------------------------------------------------------------------
667  protected void OnDisableAllClicked()
668  {
669  array<ref SCR_WorkshopItem> disable = {};
670 
671  for (int i = 0, count = m_aEnabledMods.Count(); i < count; i++)
672  {
673  disable.Insert(m_aEnabledMods.GetKey(i));
674  }
675 
676  EnableItems(false, disable);
677  }
678 
679  //------------------------------------------------------------------------------------------------
680  protected void OnOpenWorkshopButton()
681  {
682  if (Event_OnWorkshopButtonActivate)
683  Event_OnWorkshopButtonActivate.Invoke();
684  }
685 
686  //------------------------------------------------------------------------------------------------
687  protected void OnNavEnableActivated(SCR_InputButtonComponent button, string action)
688  {
689  if (!m_FocusedLine)
690  return;
691 
692  bool enabled = m_FocusedLine.GetWidgetEnabled();
693 
694  // TODO: temporary hacky fix for this method being called multiple times in a row. It's the only button posing this problem, and the invoker is bound only once...
695  GetGame().GetCallqueue().Call(SetLineEnabled, enabled);
696  }
697 
698  //------------------------------------------------------------------------------------------------
699  protected void SetLineEnabled(bool enabled)
700  {
701  GetGame().GetCallqueue().Remove(SetLineEnabled);
702 
703  if (enabled)
704  m_FocusedLine.OnDisableButton();
705  else
706  m_FocusedLine.OnEnableButton();
707  }
708 
709  //------------------------------------------------------------------------------------------------
710  protected void OnNavEnableAllActivated()
711  {
712  if (!m_FocusedLine)
713  return;
714 
715  bool enabled = m_FocusedLine.GetWidgetEnabled();
716 
717  if (enabled)
718  OnDisableAllClicked();
719  else
720  OnEnableAllClicked();
721  }
722 
723  //------------------------------------------------------------------------------------------------
724  protected void OnNavSelectSortActivate(SCR_InputButtonComponent button, string action)
725  {
726  Sort(m_FocusedLine);
727  }
728 
729  //------------------------------------------------------------------------------------------------
730  protected void Sort(SCR_AddonLineDSConfigComponent line)
731  {
732  if (m_OrderedLine)
733  {
734  ReleaseSort();
735  return;
736  }
737 
738  StartSort(line);
739  }
740 
741  //------------------------------------------------------------------------------------------------
742  protected void StartSort(SCR_AddonLineDSConfigComponent line)
743  {
744  if (!line || !line.GetWidgetEnabled())
745  return;
746 
747  m_OrderedLine = line;
748 
749  m_OrderedLine.NotifySorting(true);
750 
751  GetGame().GetInputManager().AddActionListener("MenuDown", EActionTrigger.DOWN, OnDownSort);
752  GetGame().GetInputManager().AddActionListener("MenuUp", EActionTrigger.DOWN, OnUpSort);
753 
754  if (m_NavChangeSortOrder)
755  SetNavigationButtonVisibile(m_NavChangeSortOrder, true);
756 
757  if (m_NavSelectSort)
758  {
759  // Place and stop ordering
760  m_NavSelectSort.SetLabel(SORT_BTN_PLACE_LABEL);
761  m_NavSelectSort.SetAction(SORT_BTN_PLACE_ACTION);
762  }
763 
764  if (m_NavEnable)
765  SetNavigationButtonVisibile(m_NavEnable, false);
766 
767  if (m_NavEnableAll)
768  SetNavigationButtonVisibile(m_NavEnableAll, false);
769 
770  // Panel buttons
771  m_Widgets.m_ButtonEnableAllComponent0.SetEnabled(false);
772  m_Widgets.m_ButtonDisableAllComponent0.SetEnabled(false);
773 
774  m_bIsSorting = true;
775  }
776 
777  //------------------------------------------------------------------------------------------------
778  protected void ReleaseSort()
779  {
780  if (!m_OrderedLine)
781  return;
782 
783  m_OrderedLine.NotifySorting(false);
784  m_OrderedLine = null;
785 
786  GetGame().GetInputManager().RemoveActionListener("MenuDown", EActionTrigger.DOWN, OnDownSort);
787  GetGame().GetInputManager().RemoveActionListener("MenuUp", EActionTrigger.DOWN, OnUpSort);
788 
789  if (m_NavChangeSortOrder)
790  SetNavigationButtonVisibile(m_NavChangeSortOrder, false);
791 
792  if (m_NavSelectSort)
793  {
794  // Start ordering
795  m_NavSelectSort.SetLabel(SORT_BTN_SORT_LABEL);
796  m_NavSelectSort.SetAction(SORT_BTN_SORT_ACTION);
797  }
798 
799  if (m_NavEnable)
800  SetNavigationButtonVisibile(m_NavEnable, true);
801 
802  if (m_NavEnableAll)
803  SetNavigationButtonVisibile(m_NavEnableAll, true);
804 
805  // Panel buttons
806  m_Widgets.m_ButtonEnableAllComponent0.SetEnabled(true);
807  m_Widgets.m_ButtonDisableAllComponent0.SetEnabled(true);
808 
809  // Refocus
810  OnLineFocus(m_FocusedLine);
811 
812  m_bIsSorting = false;
813  }
814 
815  //------------------------------------------------------------------------------------------------
816  protected void OnDownSort()
817  {
818  if (!m_OrderedLine)
819  return;
820 
821  OnLineButtonDown(m_OrderedLine);
822  GetGame().GetCallqueue().Call(FocusLine, m_OrderedLine);
823  }
824 
825  //------------------------------------------------------------------------------------------------
826  protected void OnUpSort()
827  {
828  if (!m_OrderedLine)
829  return;
830 
831  OnLineButtonUp(m_OrderedLine);
832  GetGame().GetCallqueue().Call(FocusLine, m_OrderedLine);
833  }
834 
835  //------------------------------------------------------------------------------------------------
836  protected void FocusLine(SCR_AddonLineDSConfigComponent line)
837  {
838  GetGame().GetWorkspace().SetFocusedWidget(line.GetRootWidget());
839  }
840 
841  //------------------------------------------------------------------------------------------------
842  // API
843  //------------------------------------------------------------------------------------------------
844  //------------------------------------------------------------------------------------------------
846  array<ref DSMod> SelectedModsList()
847  {
848  array<ref DSMod> mods = {};
849 
850  for (int i = 0, count = m_aEnabled.Count(); i < count; i++)
851  {
853  if (!line)
854  continue;
855 
856  // Save all enabled
857  if (line.GetWidgetEnabled())
858  {
859  SCR_WorkshopItem item = line.GetWorkshopItem();
860  if (!item)
861  continue;
862 
863  DSMod mod = new DSMod();
864 
865  mod.modId = item.GetId();
866  mod.name = item.GetName();
867  mod.version = item.GetCurrentLocalRevision().GetVersion();
868 
869  mods.Insert(mod);
870  }
871  }
872 
873  return mods;
874  }
875 
876  //------------------------------------------------------------------------------------------------
877  ScriptInvokerVoid GetEventOnWorkshopButtonActivate()
878  {
879  if (!Event_OnWorkshopButtonActivate)
880  Event_OnWorkshopButtonActivate = new ScriptInvokerVoid();
881 
882  return Event_OnWorkshopButtonActivate;
883  }
884 }
885 
886 //------------------------------------------------------------------------------------------------
887 class SCR_EntryDSMod
888 {
889  ref Widget m_Root;
891  ref DSMod m_Mod;
892 
893  void SCR_EntryDSMod(SCR_WidgetListEntry entry, DSMod mod)
894  {
895  m_Entry = entry;
896  m_Mod = mod;
897  }
898 };
SCR_AddonLineBaseComponent
Definition: SCR_AddonLineBaseComponent.c:7
SCR_ERevisionAvailability
SCR_ERevisionAvailability
Definition: SCR_AddonManager.c:1090
SCR_ECommStatus
SCR_ECommStatus
This class may become obsolete on BackendAPI update.
Definition: SCR_ServicesStatusHelper.c:2
m_Root
SCR_ServerHostingModSubMenu m_Root
SCR_ServerHostingModsWidgets
Definition: SCR_ServerHostingModsWidgets.c:3
SCR_AddonLineDSConfigComponent
Definition: SCR_AddonLineDSConfigComponent.c:2
UIConstants
Definition: Constants.c:130
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_SubMenuBase
Definition: SCR_SubMenuBase.c:6
SCR_GamepadScrollComponent
Definition: SCR_GamepadScroll.c:10
m_Widgets
ref SCR_VoNOverlay_ElementWidgets m_Widgets
Definition: SCR_VonDisplay.c:3
SCR_WorkshopItem
Definition: SCR_WorkshopItem.c:21
m_Mod
ref DSMod m_Mod
Definition: SCR_ServerHostingModSubMenu.c:891
m_NavEnable
protected SCR_InputButtonComponent m_NavEnable
Definition: SCR_ContentBrowser_AddonsSubMenu.c:82
SCR_ListBoxComponent
Definition: SCR_ListBoxComponent.c:4
m_Entry
ref SCR_WidgetListEntry m_Entry
Definition: SCR_ServerHostingModSubMenu.c:890
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_ServerHostingModSubMenu
Definition: SCR_ServerHostingModSubMenu.c:5
UIColors
Definition: Constants.c:16
SCR_DSConfig
Definition: SCR_DSConfig.c:5
SCR_WorkshopItemAction
Definition: SCR_WorkshopItemAction.c:16
SCR_EntryDSMod
void SCR_EntryDSMod(SCR_WidgetListEntry entry, DSMod mod)
Definition: SCR_ServerHostingModSubMenu.c:893
SCR_ServicesStatusHelper
Definition: SCR_ServicesStatusHelper.c:15
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
ScriptInvokerVoid
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
Definition: SCR_ScriptInvokerHelper.c:9
SCR_AddonManager
Definition: SCR_AddonManager.c:72
SCR_WidgetListEntry
Configurable class for widget.
Definition: SCR_WidgetListEntry.c:115
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7
SCR_DownloadManager
Definition: SCR_DownloadManager.c:20
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1