Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AddonLineDSConfigComponent.c
Go to the documentation of this file.
1 //----------------------------------------------------------------------------------------------
3 {
4  protected const string BUTTON_UP = "m_UpButton";
5  protected const string BUTTON_DOWN = "m_DownButton";
6  protected const string BUTTON_SORT_CONFIRM = "m_SortConfirmButton";
7 
8  protected bool m_bWidgetEnabled = false; // Doesn't reflect enable state of item
9 
10  // Sort buttons
11  protected SCR_ModularButtonComponent m_ButtonUp;
12  protected SCR_ModularButtonComponent m_ButtonDown;
13  protected SCR_ModularButtonComponent m_ButtonSortConfirm;
14 
15  protected bool m_bOnBottom;
16  protected bool m_bIsSorting;
17 
18  protected ref ScriptInvokerScriptedWidgetComponent Event_OnButtonUp;
19  protected ref ScriptInvokerScriptedWidgetComponent Event_OnButtonDown;
20  protected ref ScriptInvokerScriptedWidgetComponent m_OnSortConfirm;
21 
22  //----------------------------------------------------------------------------------------------
23  override void Init(SCR_WorkshopItem item)
24  {
25  // Sorting buttons
26  // Up
27  Widget wButtonUp = m_wRoot.FindAnyWidget(BUTTON_UP);
28  if (wButtonUp)
29  m_ButtonUp = SCR_ModularButtonComponent.FindComponent(wButtonUp);
30 
31  if (m_ButtonUp)
32  {
33  m_ButtonUp.m_OnClicked.Insert(InvokeEventOnButtonUp);
34  m_aMouseButtons.Insert(m_ButtonUp);
35  }
36 
37  // Down
38  Widget wButtonDown = m_wRoot.FindAnyWidget(BUTTON_DOWN);
39  if (wButtonDown)
40  m_ButtonDown = SCR_ModularButtonComponent.FindComponent(wButtonDown);
41 
42  if (m_ButtonDown)
43  {
44  m_ButtonDown.m_OnClicked.Insert(InvokeEventOnButtonDown);
45  m_aMouseButtons.Insert(m_ButtonDown);
46  }
47 
48  // Confirm
49  Widget sortConfirm = m_wRoot.FindAnyWidget(BUTTON_SORT_CONFIRM);
50  if (sortConfirm)
51  m_ButtonSortConfirm = SCR_ModularButtonComponent.FindComponent(sortConfirm);
52 
53  if (m_ButtonSortConfirm)
54  {
55  m_ButtonSortConfirm.m_OnClicked.Insert(OnSortConfirm);
56  m_aMouseButtons.Insert(m_ButtonSortConfirm);
57  }
58 
59  // Setup rest
60  super.Init(item);
61 
62  HandleEnableButtons(m_bWidgetEnabled, m_bIsSorting);
63  }
64 
65  //----------------------------------------------------------------------------------------------
66  override void UpdateAllWidgets()
67  {
68  super.UpdateAllWidgets();
69 
70  HandleEnableButtons(m_bWidgetEnabled, m_bIsSorting);
71  HandleSortingButtons();
72 
73  // Hide action buttons
74  m_Widgets.m_wDeleteButton.SetVisible(false);
75 
76  m_Widgets.m_wHorizontalState.SetVisible(false);
77  m_Widgets.m_wUpdateButton.SetVisible(false);
78  }
79 
80  // Display oredering buttons if enabled
81  //------------------------------------------------------------------------------------------------
82  protected void HandleSortingButtons()
83  {
84  bool onTop = m_wRoot.GetZOrder() == 0;
85  bool visible = m_bIsSorting || (m_bFocused && GetGame().GetInputManager().GetLastUsedInputDevice() == EInputDeviceType.MOUSE);
86 
87  if (m_ButtonUp)
88  m_ButtonUp.SetVisible(!onTop && m_bWidgetEnabled && visible);
89 
90  if (m_ButtonDown)
91  m_ButtonDown.SetVisible(!m_bOnBottom && m_bWidgetEnabled && visible);
92 
93  if (m_ButtonSortConfirm)
94  m_ButtonSortConfirm.SetVisible(m_bIsSorting);
95  }
96 
97  //------------------------------------------------------------------------------------------------
98  protected void OnSortConfirm()
99  {
100  if (m_OnSortConfirm)
101  m_OnSortConfirm.Invoke(this);
102  }
103 
104  //------------------------------------------------------------------------------------------------
105  protected void InvokeEventOnButtonUp()
106  {
107  if (Event_OnButtonUp)
108  Event_OnButtonUp.Invoke(this);
109  }
110 
111  //------------------------------------------------------------------------------------------------
112  protected void InvokeEventOnButtonDown()
113  {
114  if (Event_OnButtonDown)
115  Event_OnButtonDown.Invoke(this);
116  }
117 
118  //----------------------------------------------------------------------------------------------
119  // API
120  //----------------------------------------------------------------------------------------------
121  //----------------------------------------------------------------------------------------------
122  void SetWidgetEnabled(bool enabled)
123  {
124  m_bWidgetEnabled = enabled;
125  UpdateAllWidgets();
126  }
127 
128  //----------------------------------------------------------------------------------------------
129  bool GetWidgetEnabled()
130  {
131  return m_bWidgetEnabled;
132  }
133 
134  //----------------------------------------------------------------------------------------------
135  void SetOnBottom(bool onBottom)
136  {
137  m_bOnBottom = onBottom;
138  }
139 
140  //----------------------------------------------------------------------------------------------
141  void NotifySorting(bool sorting)
142  {
143  m_bIsSorting = sorting;
144  HandleSortingButtons();
145  HandleEnableButtons(m_bWidgetEnabled, sorting);
146  }
147 
148  //------------------------------------------------------------------------------------------------
149  ScriptInvokerScriptedWidgetComponent GetEventOnButtonUp()
150  {
151  if (!Event_OnButtonUp)
152  Event_OnButtonUp = new ScriptInvokerScriptedWidgetComponent();
153 
154  return Event_OnButtonUp;
155  }
156 
157  //------------------------------------------------------------------------------------------------
158  ScriptInvokerScriptedWidgetComponent GetEventOnButtonDown()
159  {
160  if (!Event_OnButtonDown)
161  Event_OnButtonDown = new ScriptInvokerScriptedWidgetComponent();
162 
163  return Event_OnButtonDown;
164  }
165 
166  //------------------------------------------------------------------------------------------------
167  ScriptInvokerScriptedWidgetComponent GetOnSortConfirm()
168  {
169  if (!m_OnSortConfirm)
170  m_OnSortConfirm = new ScriptInvokerScriptedWidgetComponent();
171 
172  return m_OnSortConfirm;
173  }
174 }
SCR_AddonLineBaseComponent
Definition: SCR_AddonLineBaseComponent.c:7
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_AddonLineDSConfigComponent
Definition: SCR_AddonLineDSConfigComponent.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_Widgets
ref SCR_VoNOverlay_ElementWidgets m_Widgets
Definition: SCR_VonDisplay.c:3
SCR_WorkshopItem
Definition: SCR_WorkshopItem.c:21
ScriptInvokerScriptedWidgetComponent
ScriptInvokerBase< ScriptInvokerScriptedWidgetComponentMethod > ScriptInvokerScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:4