Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PlayMenuComponent.c
Go to the documentation of this file.
2{
3 [Attribute("3")]
4 protected int m_iColumns;
5 [Attribute("1")]
6 protected int m_iRows;
7
8 protected int m_iItems;
9 protected int m_iSelectedItem;
10
11 [Attribute("2")]
12 protected int m_iPaddingHorizontal;
13 [Attribute("2")]
14 protected int m_iPaddingVertical;
15
16 [Attribute("{4FFBD0D5E9A5ED50}UI/layouts/Menus/PlayMenu/PlayMenuTile_Recent.layout", UIWidgets.ResourceNamePicker, "", "layout")]
18
19 [Attribute("0.2")]
20 protected float m_fAnimationTime;
21
22 protected ref array<Widget> m_aWidgets = {};
24 protected Widget m_wRoot;
26
27 //------------------------------------------------------------------------------------------------
28 override void HandlerAttached(Widget w)
29 {
30 m_wRoot = w;
31 m_wContentRoot = GridLayoutWidget.Cast(w.FindAnyWidget("Content"));
32
33 if (!m_wContentRoot)
34 return;
35
37
38 if (m_iItems == 0)
39 return;
40
41 // Convert time to animation speed
43
45
48 }
49
50 //------------------------------------------------------------------------------------------------
51 protected void CreateWidgets(int columns, int rows)
52 {
53 if (!m_wContentRoot)
54 return;
55
56 // Delete old widgets
57 foreach (Widget w: m_aWidgets)
58 {
59 if (w)
60 w.RemoveFromHierarchy();
61 }
62 m_aWidgets.Clear();
63
64 // Create new grid tile widgets
65 for (int r = 0; r < rows; r++)
66 {
67 for (int c = 0; c < columns; c++)
68 {
69 CreateWidget(c, r);
70 }
71 }
72 }
73
74 //------------------------------------------------------------------------------------------------
75 protected Widget CreateWidget(int column, int row)
76 {
77 if (!m_wContentRoot)
78 return null;
79
80 Widget w = GetGame().GetWorkspace().CreateWidgets(m_sItemLayout, m_wContentRoot);
81 if (!w)
82 return null;
83
84 GridSlot.SetColumn(w, column);
85 GridSlot.SetRow(w, row);
86 m_wContentRoot.SetRowFillWeight(row, 1);
87 m_wContentRoot.SetColumnFillWeight(column, 1);
88
89 // Listen on focus event
91 if (!comp)
92 {
93 comp = new SCR_EventHandlerComponent();
94 w.AddHandler(comp);
95 }
96 comp.GetOnFocus().Insert(OnItemFocused);
97
98 // Check if root is actually a button
99 ButtonWidget button = ButtonWidget.Cast(w);
100
101 if (!button)
102 Print("Gallery element root has to be a button, otherwise interactivity will not work", LogLevel.WARNING);
103
104 // Apply spacing
105 int left, top, right, bottom;
106
107 if (column > 0)
109
110 if (column < m_iColumns - 1)
111 right = m_iPaddingHorizontal;
112
113 if (row > 0)
114 top = m_iPaddingVertical;
115
116 if (row < m_iRows - 1)
117 bottom = m_iPaddingVertical;
118
119 AlignableSlot.SetPadding(w, left, top, right, bottom);
120
121 m_aWidgets.Insert(w);
122
123 return w;
124 }
125
126 //------------------------------------------------------------------------------------------------
127 protected void SetAnimationRate()
128 {
129 if (m_fAnimationTime <= 0)
130 m_fAnimationRate = 1000;
131 else
133 }
134
135 //------------------------------------------------------------------------------------------------
137 {
138 m_iSelectedItem = m_aWidgets.Find(w);
139 }
140
141 //------------------------------------------------------------------------------------------------
143 {
144 if (!m_aWidgets.IsIndexValid(index))
145 return;
146
148
149 if (!w.IsEnabled())
150 return;
151
152 GetGame().GetWorkspace().SetFocusedWidget(w);
154 }
155
156 //------------------------------------------------------------------------------------------------
157 array<Widget> GetWidgets()
158 {
159 return m_aWidgets;
160 }
161
162 //------------------------------------------------------------------------------------------------
165 static SCR_PlayMenuComponent GetComponent(string name, Widget parent, bool searchAllChildren = true)
166 {
167 if (!parent || name == string.Empty)
168 return null;
169
170 Widget w;
171 if (searchAllChildren)
172 w = parent.FindAnyWidget(name);
173 else
174 w = parent.FindWidget(name);
175
176 if (!w)
177 return null;
178
179 return SCR_PlayMenuComponent.Cast(w.FindHandler(SCR_PlayMenuComponent));
180 }
181};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
ref array< Widget > m_aWidgets
GridLayoutWidget m_wContentRoot
Widget CreateWidget(int column, int row)
void CreateWidgets(int columns, int rows)
override void HandlerAttached(Widget w)
static SCR_PlayMenuComponent GetComponent(string name, Widget parent, bool searchAllChildren=true)
Base class for all final Reforger interactive elements.
static const float START_ANIMATION_PERIOD
static const float START_ANIMATION_RATE
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute