Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
slotscontainer.c
Go to the documentation of this file.
1
class
SlotsContainer
:
Container
2
{
3
protected
ref
array<ref SlotsIcon>
m_Icons
;
4
int
m_VisibleColumnCount
;
5
6
void
SlotsContainer
(
LayoutHolder
parent,
EntityAI
slot_parent )
7
{
8
m_Icons
=
new
array<ref SlotsIcon>
;
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
{
18
child = child.GetSibling();
19
}
20
}*/
21
}
22
}
23
24
override
void
SetDefaultFocus
(
bool
while_micromanagment_mode =
false
)
25
{
26
m_FocusedColumn = 0;
27
for
(
int
i = 0; i < GetColumnCount(); i++)
28
{
29
SlotsIcon
icon =
m_Icons
[i];
30
if
(icon.
IsVisible
())
31
{
32
m_FocusedColumn = i;
33
break
;
34
}
35
}
36
37
SetFocus
( m_FocusedColumn );
38
}
39
40
override
void
SetLastFocus
()
41
{
42
SetDefaultFocus
();
43
}
44
45
void
SetFocus
(
int
index )
46
{
47
if
( index >= 0 && index <
m_Icons
.Count() )
48
{
49
m_Icons
.Get( index ).GetSelectedPanel().Show(
true
);
50
}
51
UpdateIcon
();
52
}
53
54
void
SetVisibleFocus
(
int
index )
55
{
56
Unfocus
();
57
int
visible_icons_count = 0;
58
59
m_FocusedColumn = 0;
60
for
(
int
i = 0; i < GetColumnCount(); i++)
61
{
62
SlotsIcon
icon =
m_Icons
[i];
63
if
(icon.
IsVisible
())
64
{
65
m_FocusedColumn = i;
66
if
(visible_icons_count == index)
67
break
;
68
visible_icons_count++;
69
}
70
}
71
72
SetFocus
( m_FocusedColumn );
73
}
74
75
int
GetVisibleFocus
()
76
{
77
int
visible_icons_count = 0;
78
for
(
int
i = 0; i < GetColumnCount(); i++)
79
{
80
if
(m_FocusedColumn == i)
81
{
82
return
visible_icons_count;
83
}
84
SlotsIcon
icon =
m_Icons
[i];
85
if
(icon.
IsVisible
())
86
{
87
visible_icons_count++;
88
}
89
}
90
return
visible_icons_count - 1;
91
}
92
93
override
void
SetNextRightActive
()
94
{
95
Unfocus
();
96
97
int
index = m_FocusedColumn + 1;
98
for
(
int
i = 0; i < GetColumnCount(); i++ )
99
{
100
if
(index >= GetColumnCount())
101
{
102
index = 0;
103
}
104
SlotsIcon
icon =
m_Icons
[index];
105
if
(icon.
IsVisible
())
106
{
107
m_FocusedColumn = index;
108
break
;
109
}
110
index++;
111
}
112
113
UpdateIcon
();
114
}
115
116
override
void
SetNextLeftActive
()
117
{
118
Unfocus
();
119
120
int
index = m_FocusedColumn - 1;
121
for
(
int
i = 0; i < GetColumnCount(); i++ )
122
{
123
if
(index < 0)
124
{
125
index = GetColumnCount() - 1;
126
}
127
SlotsIcon
icon =
m_Icons
[index];
128
if
(icon.
IsVisible
())
129
{
130
m_FocusedColumn = index;
131
break
;
132
}
133
index--;
134
}
135
136
UpdateIcon
();
137
}
138
139
void
UpdateIcon
()
140
{
141
float
x
,
y
;
142
SlotsIcon
icon =
GetSlotIcon
( m_FocusedColumn );
143
144
icon.
GetSelectedPanel
().Show(
true
);
145
icon.
GetSelectedPanel
().GetScreenPos(
x
,
y
);
146
147
EntityAI
focused_item =
GetFocusedItem
();
148
if
( focused_item )
149
{
150
PrepareOwnedTooltip( focused_item, -1,
y
);
//custom positioning for the controller
151
}
152
else
153
{
154
PrepareOwnedSlotsTooltip( icon.
GetSelectedPanel
(), icon.
GetSlotDisplayName
(), icon.
GetSlotDesc
(),
x
,
y
);
155
}
156
}
157
158
override
void
UnfocusAll
()
159
{
160
for
(
int
i = 0; i <
m_Icons
.Count(); i++)
161
{
162
m_Icons
.Get( i ).GetSelectedPanel().Show(
false
);
163
}
164
}
165
166
override
void
Unfocus
()
167
{
168
Widget
w =
m_Icons
.Get( m_FocusedColumn ).GetSelectedPanel();
169
if
( w )
170
{
171
w.Show(
false
);
172
}
173
}
174
175
override
bool
SelectItem
()
176
{
177
ItemBase
item =
ItemBase
.Cast(
GetFocusedItem
() );
178
SlotsIcon
icon =
GetFocusedSlotsIcon
();
179
180
if
( item && !item.IsLockedInSlot() && !icon.
IsOutOfReach
() && !icon.
IsReserved
() && item.
IsTakeable
() && item.
CanPutIntoHands
(null))
181
{
182
ItemManager
.
GetInstance
().
SetSelectedItemEx
(item, null, icon);
183
return
true
;
184
}
185
return
false
;
186
}
187
188
override
bool
IsEmpty
()
189
{
190
return
false
;
191
}
192
193
override
bool
IsDisplayable
()
194
{
195
if
(m_ForcedShow)
196
return
true
;
197
for
(
int
i = 0; i < m_ColumnCount; i++)
198
{
199
if
(
GetSlotIcon
(i).
IsVisible
() )
200
{
201
return
true
;
202
}
203
}
204
return
false
;
205
}
206
207
SlotsIcon
GetSlotIcon
(
int
index )
208
{
209
if
(
m_Icons
.IsValidIndex( index ) )
210
{
211
return
m_Icons
.Get( index );
212
}
213
214
return
null;
215
}
216
217
override
SlotsIcon
GetFocusedSlotsIcon
()
218
{
219
if
(
m_Icons
.Count())
220
{
221
return
m_Icons
.Get(m_FocusedColumn);
222
}
223
return
null;
224
}
225
226
override
EntityAI
GetFocusedItem
()
227
{
228
SlotsIcon
focus_icon =
GetFocusedSlotsIcon
();
229
230
if
(focus_icon && !focus_icon.
IsReserved
())
231
{
232
return
EntityAI
.Cast(focus_icon.
GetObject
());
233
}
234
235
return
null;
236
}
237
238
override
void
SetLayoutName
()
239
{
240
#ifdef PLATFORM_CONSOLE
241
m_LayoutName =
WidgetLayoutName
.
InventorySlotsContainerXbox
;
242
#else
243
switch
(
InventoryMenu
.GetWidthType() )
244
{
245
case
ScreenWidthType
.NARROW:
246
{
247
m_LayoutName =
WidgetLayoutName
.
InventorySlotsContainerNarrow
;
248
break
;
249
}
250
case
ScreenWidthType
.MEDIUM:
251
{
252
m_LayoutName =
WidgetLayoutName
.
InventorySlotsContainerMedium
;
253
break
;
254
}
255
case
ScreenWidthType
.WIDE:
256
{
257
m_LayoutName =
WidgetLayoutName
.
InventorySlotsContainerWide
;
258
break
;
259
}
260
}
261
#endif
262
263
}
264
266
bool
VerifySlotsIconVisibility
(
int
idx = -1)
267
{
268
if
(idx != -1)
269
{
270
return
m_Icons
[idx].IsVisible() &&
m_Icons
[idx].GetRadialIconPanel().IsVisible() &&
m_Icons
[idx].GetRadialIcon().IsVisible();
271
}
272
else
273
{
274
int
count =
m_Icons
.Count();
275
for
(
int
i = 0; i < count; i++)
276
{
277
if
(
m_Icons
[i].
IsVisible
() &&
m_Icons
[i].GetRadialIconPanel().
IsVisible
() &&
m_Icons
[i].GetRadialIcon().
IsVisible
())
278
{
279
return
true
;
280
}
281
}
282
}
283
return
false
;
284
}
285
}
ITEMS_IN_ROW
const int ITEMS_IN_ROW
Definition
attachments.c:1
Container
Definition
cargocontainer.c:3
EntityAI
Definition
inventoryitem.c:2
ItemBase
Definition
inventoryitem.c:742
ItemBase::CanPutIntoHands
override bool CanPutIntoHands(EntityAI parent)
Definition
gardenbase.c:337
ItemBase::IsTakeable
override bool IsTakeable()
Definition
basebuildingbase.c:1008
ItemManager
Definition
itemmanager.c:2
ItemManager::SetSelectedItemEx
void SetSelectedItemEx(EntityAI selected_item, Container selected_container, LayoutHolder selected_icon)
Definition
itemmanager.c:113
ItemManager::GetInstance
static ItemManager GetInstance()
Definition
itemmanager.c:282
LayoutHolder
Definition
container.c:2
SlotsContainer::m_Icons
ref array< ref SlotsIcon > m_Icons
Definition
slotscontainer.c:3
SlotsContainer::UnfocusAll
override void UnfocusAll()
Definition
slotscontainer.c:158
SlotsContainer::VerifySlotsIconVisibility
bool VerifySlotsIconVisibility(int idx=-1)
Returns 'true' if radial icon is VISIBLE and also OPEN (individual icon or any icon,...
Definition
slotscontainer.c:266
SlotsContainer::SlotsContainer
void SlotsContainer(LayoutHolder parent, EntityAI slot_parent)
Definition
slotscontainer.c:6
SlotsContainer::SelectItem
override bool SelectItem()
Definition
slotscontainer.c:175
SlotsContainer::GetFocusedSlotsIcon
override SlotsIcon GetFocusedSlotsIcon()
Definition
slotscontainer.c:217
SlotsContainer::m_VisibleColumnCount
int m_VisibleColumnCount
Definition
slotscontainer.c:4
SlotsContainer::SetLastFocus
override void SetLastFocus()
Definition
slotscontainer.c:40
SlotsContainer::GetSlotIcon
SlotsIcon GetSlotIcon(int index)
Definition
slotscontainer.c:207
SlotsContainer::SetNextRightActive
override void SetNextRightActive()
Definition
slotscontainer.c:93
SlotsContainer::SetFocus
void SetFocus(int index)
Definition
slotscontainer.c:45
SlotsContainer::Unfocus
override void Unfocus()
Definition
slotscontainer.c:166
SlotsContainer::SetVisibleFocus
void SetVisibleFocus(int index)
Definition
slotscontainer.c:54
SlotsContainer::SetDefaultFocus
override void SetDefaultFocus(bool while_micromanagment_mode=false)
Definition
slotscontainer.c:24
SlotsContainer::UpdateIcon
void UpdateIcon()
Definition
slotscontainer.c:139
SlotsContainer::IsEmpty
override bool IsEmpty()
Definition
slotscontainer.c:188
SlotsContainer::SetNextLeftActive
override void SetNextLeftActive()
Definition
slotscontainer.c:116
SlotsContainer::SetLayoutName
override void SetLayoutName()
Definition
slotscontainer.c:238
SlotsContainer::GetFocusedItem
override EntityAI GetFocusedItem()
Definition
slotscontainer.c:226
SlotsContainer::IsDisplayable
override bool IsDisplayable()
Definition
slotscontainer.c:193
SlotsContainer::GetVisibleFocus
int GetVisibleFocus()
Definition
slotscontainer.c:75
SlotsIcon
Definition
slotsicon.c:2
SlotsIcon::GetSlotDisplayName
string GetSlotDisplayName()
Definition
slotsicon.c:154
SlotsIcon::GetSelectedPanel
Widget GetSelectedPanel()
Definition
slotsicon.c:245
SlotsIcon::GetSlotDesc
string GetSlotDesc()
Definition
slotsicon.c:164
SlotsIcon::GetObject
Object GetObject()
Definition
slotsicon.c:360
SlotsIcon::IsReserved
bool IsReserved()
Definition
slotsicon.c:200
SlotsIcon::IsVisible
override bool IsVisible()
Definition
slotsicon.c:129
SlotsIcon::IsOutOfReach
bool IsOutOfReach()
Definition
slotsicon.c:729
Widget
Definition
enwidgets.c:190
WidgetLayoutName
Definition
widgetlayoutname.c:2
WidgetLayoutName::InventorySlotsContainerMedium
const string InventorySlotsContainerMedium
Definition
widgetlayoutname.c:14
WidgetLayoutName::InventorySlotsContainerNarrow
const string InventorySlotsContainerNarrow
Definition
widgetlayoutname.c:13
WidgetLayoutName::InventorySlotsContainerWide
const string InventorySlotsContainerWide
Definition
widgetlayoutname.c:15
WidgetLayoutName::InventorySlotsContainerXbox
const string InventorySlotsContainerXbox
Definition
widgetlayoutname.c:16
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
FindAnyWidget
proto native Widget FindAnyWidget(string pathname)
IsVisible
proto native bool IsVisible()
x
Icon x
y
Icon y
ScreenWidthType
ScreenWidthType
Definition
inventorymenu.c:2
InventoryMenu
void InventoryMenu()
Definition
inventorymenu.c:20
Games
Dayz
scripts
5_mission
gui
inventorynew
containeditems
slotscontainer.c
Generated by
1.17.0