Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ServerSortingComponent.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  [Attribute()]
5  ref array<string> m_aElementsFilters;
6 
7  protected SCR_SelectableButtonComponent m_wLastFocused;
8 
9  protected ref array<ref Widget> m_aWidgetCells = new array<ref Widget>();
10  protected ref array<ref SCR_SelectableButtonComponent> m_aButtons = new array<ref SCR_SelectableButtonComponent>();
11 
12  protected bool m_bIsFocused = false;
13  protected bool m_bIsAscendent;
14 
15  ref ScriptInvoker m_OnFocus = new ScriptInvoker();
16 
17  //------------------------------------------------------------------------------------------------
18  override void HandlerAttached(Widget w)
19  {
20  m_wRoot = w;
21 
22  // Get widgets cells
23  AddWidgetCells();
24 
25  // Disabling buttons
26  if (!w.IsEnabled())
27  {
28  foreach (SCR_SelectableButtonComponent button : m_aButtons)
29  {
30  button.SetSelected(false);
31  }
32 
33  m_iSelectedItem = -1;
34  }
35 
36  // Set initial selection
37  if(m_iSelectedItem > -1)
38  {
39  if(m_aButtons.Count() > 0 && m_iSelectedItem < m_aButtons.Count())
40  {
41  //m_wLastFocused = m_aButtons[m_iSelectedItem];
42  m_aButtons[m_iSelectedItem].SetSelected(true);
43  }
44  }
45  }
46 
47  //------------------------------------------------------------------------------------------------
48  protected void AddWidgetCells()
49  {
50  foreach (string str : m_aElementNames)
51  {
52  Widget w = m_wRoot.FindAnyWidget(str);
53  if(!w)
54  return;
55 
57  if(button)
58  {
59  button.m_OnClicked.Insert(OnElementClicked);
60  m_aButtons.Insert(button);
61  }
62  }
63  }
64 
65  //------------------------------------------------------------------------------------------------
66  protected void OnElementClicked(Widget w)
67  {
68  GetGame().GetWorkspace().SetFocusedWidget(m_wRoot);
70 
71  if (!button)
72  return;
73 
74  if (!m_aButtons || m_aButtons.Count() < 1)
75  return;
76 
77  int buttonId = m_aButtons.Find(button);
78 
79  // Call focus
80  m_OnFocus.Invoke(w);
81 
82  button.SetSelected(false);
83 
84  if (buttonId >= 0)
85  SetCurrentItem(buttonId, true, true);
86 
87  for (int x = 0; x < m_aButtons.Count(); x++)
88  {
89  m_aButtons[x].SetSelected(false);
90  }
91 
92  // Order ascendence - switch or default false
93  if (m_wLastFocused == button)
94  m_bIsAscendent = !m_bIsAscendent;
95  else
96  m_bIsAscendent = false;
97 
98  m_wLastFocused = button;
99 
100  if(m_aElementsFilters && buttonId < m_aElementsFilters.Count())
101  m_OnChanged.Invoke(m_aElementsFilters[buttonId], m_bIsAscendent);
102  }
103 
104  //------------------------------------------------------------------------------------------------
105  Widget GetLastFocusedButton()
106  {
107  if(!m_wLastFocused)
108  return null;
109  return m_wLastFocused.m_wRoot;
110  }
111 };
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_SelectableButtonComponent
Definition: SCR_SelectableButtonComponent.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_OnChanged
protected ref ScriptInvokerTabViewIndex m_OnChanged
Definition: SCR_TabViewComponent.c:64
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_ServerSortingComponent
Definition: SCR_ServerSortingComponent.c:2
m_OnFocus
ref ScriptInvoker m_OnFocus
Definition: SCR_ModularButtonComponent.c:63
SCR_SelectionWidgetComponent
Definition: SCR_SelectionWidgetComponent.c:1
m_aButtons
protected ref array< ref SCR_BrowserTooltipButtonPresetData > m_aButtons
Definition: SCR_BrowserHoverTooltipComponent.c:9