DayZ 1.24
Loading...
Searching...
No Matches
SlotsContainer.c
Go to the documentation of this file.
2{
5
7 {
9 for (int i = 0; i < ITEMS_IN_ROW; i++)
10 {
11 if (GetRootWidget().FindAnyWidget("Icon" + i))
12 m_Icons.Insert(new SlotsIcon(this, GetRootWidget().FindAnyWidget("Icon" + i), i, slot_parent));
13 else
14 {
15 Widget child = GetRootWidget().GetChildren();
16 while (child)
17 child = child.GetSibling();
18 }
19 }
20 }
21
22 override void SetDefaultFocus(bool while_micromanagment_mode = false)
23 {
24 m_FocusedColumn = 0;
25 for (int i = 0; i < GetColumnCount(); i++)
26 {
28 if (icon.IsVisible())
29 {
30 m_FocusedColumn = i;
31 break;
32 }
33 }
34
35 SetFocus(m_FocusedColumn);
36 }
37
38 override void SetLastFocus()
39 {
41 }
42
43 void SetFocus(int index)
44 {
45 if (index >= 0 && index < m_Icons.Count())
46 m_Icons.Get(index).GetSelectedPanel().Show(true);
47 UpdateIcon();
48 }
49
51 {
52 Unfocus();
53 int visible_icons_count = 0;
54
55 m_FocusedColumn = 0;
56 for (int i = 0; i < GetColumnCount(); i++)
57 {
59 if (icon.IsVisible())
60 {
61 m_FocusedColumn = i;
63 break;
65 }
66 }
67
68 SetFocus(m_FocusedColumn);
69 }
70
72 {
73 int visible_icons_count = 0;
74 for (int i = 0; i < GetColumnCount(); i++)
75 {
76 if (m_FocusedColumn == i)
79 if (icon.IsVisible())
81 }
82 return visible_icons_count - 1;
83 }
84
85 override void SetNextRightActive()
86 {
87 Unfocus();
88
89 int index = m_FocusedColumn + 1;
90 for (int i = 0; i < GetColumnCount(); i++)
91 {
92 if (index >= GetColumnCount())
93 index = 0;
95 if (icon.IsVisible())
96 {
97 m_FocusedColumn = index;
98 break;
99 }
100 index++;
101 }
102
103 UpdateIcon();
104 }
105
106 override void SetNextLeftActive()
107 {
108 Unfocus();
109
110 int index = m_FocusedColumn - 1;
111 for (int i = 0; i < GetColumnCount(); i++)
112 {
113 if (index < 0)
114 index = GetColumnCount() - 1;
116 if (icon.IsVisible())
117 {
118 m_FocusedColumn = index;
119 break;
120 }
121 index--;
122 }
123
124 UpdateIcon();
125 }
126
128 {
129 float x, y;
130 SlotsIcon icon = GetSlotIcon(m_FocusedColumn);
131
132 icon.GetSelectedPanel().Show(true);
133 icon.GetSelectedPanel().GetScreenPos(x, y);
134
136 if (focused_item)
137 {
138 PrepareOwnedTooltip(focused_item, -1, y); //custom positioning for the controller
139 }
140 else
141 PrepareOwnedSlotsTooltip(icon.GetSelectedPanel(), icon.GetSlotDisplayName(), icon.GetSlotDesc(), x, y);
142 }
143
144 override void UnfocusAll()
145 {
146 for (int i = 0; i < m_Icons.Count(); i++)
147 m_Icons.Get(i).GetSelectedPanel().Show(false);
148 }
149
150 override void Unfocus()
151 {
152 Widget w = m_Icons.Get(m_FocusedColumn).GetSelectedPanel();
153 if (w)
154 w.Show(false);
155 }
156
157 override bool SelectItem()
158 {
161
162 if (item && !item.IsLockedInSlot() && !icon.IsOutOfReach() && !icon.IsReserved() && item.IsTakeable() && item.CanPutIntoHands(null))
163 {
164 ItemManager.GetInstance().SetSelectedItemEx(item, null, icon);
165 return true;
166 }
167 return false;
168 }
169
170 override bool IsEmpty()
171 {
172 return false;
173 }
174
175 override bool IsDisplayable()
176 {
177 if (m_ForcedShow)
178 return true;
179 for (int i = 0; i < m_ColumnCount; i++)
180 {
181 if (GetSlotIcon(i).IsVisible())
182 return true;
183 }
184 return false;
185 }
186
188 {
189 if (m_Icons.IsValidIndex(index))
190 return m_Icons.Get(index);
191
192 return null;
193 }
194
196 {
197 if (m_Icons.Count())
198 return m_Icons.Get(m_FocusedColumn);
199 return null;
200 }
201
203 {
205
206 if (focus_icon && !focus_icon.IsReserved())
207 return EntityAI.Cast(focus_icon.GetObject());
208
209 return null;
210 }
211
212 override void SetLayoutName()
213 {
214#ifdef PLATFORM_CONSOLE
216#else
217 switch (InventoryMenu.GetWidthType())
218 {
219 case ScreenWidthType.NARROW:
220 {
222 break;
223 }
224 case ScreenWidthType.MEDIUM:
225 {
227 break;
228 }
229 case ScreenWidthType.WIDE:
230 {
232 break;
233 }
234 }
235#endif
236
237 }
238
241 {
242 if (idx != -1)
243 return m_Icons[idx].IsVisible() && m_Icons[idx].GetRadialIconPanel().IsVisible() && m_Icons[idx].GetRadialIcon().IsVisible();
244 else
245 {
246 int count = m_Icons.Count();
247 for (int i = 0; i < count; i++)
248 {
249 if (m_Icons[i].IsVisible() && m_Icons[i].GetRadialIconPanel().IsVisible() && m_Icons[i].GetRadialIcon().IsVisible())
250 return true;
251 }
252 }
253 return false;
254 }
255}
const int ITEMS_IN_ROW
Definition Attachments.c:1
Icon x
Icon y
ScreenWidthType
void InventoryMenu()
static ItemManager GetInstance()
override void SetNextRightActive()
override void SetDefaultFocus(bool while_micromanagment_mode=false)
override EntityAI GetFocusedItem()
override void SetLastFocus()
override SlotsIcon GetFocusedSlotsIcon()
override bool IsEmpty()
override bool IsDisplayable()
void SlotsContainer(LayoutHolder parent, EntityAI slot_parent)
override void Unfocus()
SlotsIcon GetSlotIcon(int index)
override bool SelectItem()
override void UnfocusAll()
override void SetLayoutName()
ref array< ref SlotsIcon > m_Icons
override void SetNextLeftActive()
void SetFocus(int index)
bool VerifySlotsIconVisibility(int idx=-1)
Returns 'true' if radial icon is VISIBLE and also OPEN (individual icon or any icon,...
void SetVisibleFocus(int index)
const string InventorySlotsContainerWide
const string InventorySlotsContainerMedium
const string InventorySlotsContainerXbox
const string InventorySlotsContainerNarrow
proto native Widget FindAnyWidget(string pathname)
proto native bool IsVisible()