Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SelectionHintComponent.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
3{
4 [Attribute("{73B3D8BBB785B5B9}UI/Textures/Common/circleFull.edds", UIWidgets.ResourceNamePicker, "")]
6
7 [Attribute("", UIWidgets.ResourceNamePicker, "")]
9
10 [Attribute("SelectionHintElement", UIWidgets.EditBox, "Name for generated selection hints widgets")]
12
13 [Attribute("0.760 0.392 0.08 1", UIWidgets.ColorPicker)]
14 protected ref Color m_ColorSelected;
15
16 [Attribute("0.25 0.25 0.25 1", UIWidgets.ColorPicker)]
17 protected ref Color m_ColorDeselected;
18
19 [Attribute("true")]
20 protected bool m_bSetCustomSize;
21
22 [Attribute("16")]
23 protected float m_fItemWidth;
24
25 [Attribute("16")]
26 protected float m_fItemHeight;
27
28 [Attribute("0.2")]
29 protected float m_fAnimationTime;
30
31 [Attribute("8")]
32 protected float m_fItemSpacing;
33
34 [Attribute("0")]
35 protected int m_iCurrent;
36
37 [Attribute("0")]
38 protected int m_iItemCount;
39
41 protected Widget m_wRoot;
42 protected Widget m_wCurrent;
43 protected ref array<Widget> m_aWidgets = {};
44
45 //------------------------------------------------------------------------------------------------
46 override void HandlerAttached(Widget w)
47 {
48 m_wRoot = w;
49
50 // Convert time to animation speed
52
54
55 // Highlight correct item
58 }
59
60 //------------------------------------------------------------------------------------------------
61 protected void CreateWidgets(int count)
62 {
63 int currentCount = m_aWidgets.Count();
64 bool addWidgets;
65
66 if (currentCount == count)
67 return;
68 else if (currentCount < count)
69 addWidgets = true;
70
71 // Add
72 if (addWidgets)
73 {
74 int iterations = count - currentCount;
75 for (int i = 0 ; i < iterations; i++)
76 {
78 }
79 }
80 else
81 {
82 int iterations = currentCount - count;
83 for (int i = 0 ; i < iterations; i++)
84 {
85 // Go from the last
86 m_aWidgets[currentCount - i - 1].RemoveFromHierarchy();
87 }
88 m_aWidgets.Resize(count);
89 }
90 }
91
92 //------------------------------------------------------------------------------------------------
93 protected void CreateWidget()
94 {
95 Widget w = GetGame().GetWorkspace().CreateWidget(WidgetType.ImageWidgetTypeID, WidgetFlags.VISIBLE |
96 WidgetFlags.STRETCH | WidgetFlags.BLEND | WidgetFlags.INHERIT_CLIPPING, m_ColorDeselected, 0, m_wRoot);
97
98 ImageWidget img = ImageWidget.Cast(w);
99 if (!img)
100 return;
101
102 m_aWidgets.Insert(img);
103
104 if (m_sHintElementTexture != string.Empty)
106
108 img.SetSize(m_fItemWidth, m_fItemHeight);
109
110 img.SetName(m_sSelectionHintElementName);
111
112 AlignableSlot.SetPadding(img, m_fItemSpacing * 0.5, 0, m_fItemSpacing * 0.5, 0);
113 AlignableSlot.SetVerticalAlign(img, LayoutVerticalAlign.Center);
114 AlignableSlot.SetHorizontalAlign(img, LayoutHorizontalAlign.Center);
115 }
116
117 //------------------------------------------------------------------------------------------------
118 protected void SetAnimationRate()
119 {
120 if (m_fAnimationTime <= 0)
121 m_fAnimationRate = 1000;
122 else
124 }
125
126 // Public API
127 //------------------------------------------------------------------------------------------------
128 void SetItemCount(int count, bool animate = true)
129 {
130 if (count == m_iItemCount || count == 1) // Do not show for only one item
131 return;
132
133 m_iItemCount = count;
134 CreateWidgets(count);
135 SetCurrentItem(m_iCurrent, animate);
136 }
137
138 //------------------------------------------------------------------------------------------------
140 {
141 return m_iItemCount;
142 }
143
144 //------------------------------------------------------------------------------------------------
146 {
147 return m_iCurrent;
148 }
149
150 //------------------------------------------------------------------------------------------------
151 void SetCurrentItem(int index, bool animate = true)
152 {
153 Widget newWidget;
154
155 if (index >= 0 && index < m_iItemCount)
156 newWidget = m_aWidgets[index];
157
158 //if (m_wCurrent == newWidget)
159 //return;
160
161 Color color;
162 foreach (int i, Widget w : m_aWidgets)
163 {
164 if (i == index)
165 color = m_ColorSelected;
166 else
167 color = m_ColorDeselected;
168
169 ColorizeItem(w, color, animate);
170 }
171
173 m_wCurrent = newWidget;
174 }
175
176 //------------------------------------------------------------------------------------------------
177 void ColorizeItem(Widget w, Color color, bool animate)
178 {
179 if (!color || !w || w.GetColor() == color)
180 return;
181
184 else
185 w.SetColor(color);
186 }
187};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
static WidgetAnimationColor Color(Widget widget, Color color, float speed)
Definition Color.c:13
void SetCurrentItem(int index, bool animate=true)
void SetItemCount(int count, bool animate=true)
override void HandlerAttached(Widget w)
void ColorizeItem(Widget w, Color color, bool animate)
Base class for all final Reforger interactive elements.
static bool SetTexture(ImageWidget widget, ResourceName texture, string image="")
static const float START_ANIMATION_PERIOD
static const float START_ANIMATION_RATE
SCR_FieldOfViewSettings Attribute
WidgetFlags
Widget flags. See enf::Widget::SetFlags().
Definition WidgetFlags.c:14
LayoutHorizontalAlign
LayoutVerticalAlign