DayZ 1.24
Loading...
Searching...
No Matches
ClosableContainer.c
Go to the documentation of this file.
2{
4 protected bool m_LockCargo;
5
6 void ClosableContainer(LayoutHolder parent, int sort = -1)
7 {
8 m_Body = new array<ref LayoutHolder>;
9 m_ClosableHeader = new ClosableHeader(this, "CloseButtonOnMouseButtonDown");
10
11 if (sort > -1)
12 m_RootWidget.SetSort(sort + 2);
13
14 m_MainWidget = m_MainWidget.FindWidget("body");
15 }
16
17 override bool IsDisplayable()
18 {
19 for (int i = 0; i < m_Body.Count(); i++)
20 {
21 LayoutHolder c = m_Body[i];
22 if (c && c.IsDisplayable())
23 return true;
24 }
25 return false;
26 }
27
28 override void UpdateRadialIcon()
29 {
30 if (m_SlotIcon)
31 {
34 show_radial_icon = show_radial_icon && ((m_Entity.GetInventory().GetCargo() && m_Entity.CanDisplayCargo()) || m_Entity.GetSlotsCountCorrect() > 0);
35 show_radial_icon = show_radial_icon && !m_Entity.GetInventory().IsInventoryLockedForLockType(HIDE_INV_FROM_SCRIPT);
36 if (IsDisplayable())
37 {
38 m_SlotIcon.GetRadialIconPanel().Show(true);
39 SetOpenForSlotIcon(show_radial_icon);
40 }
41 else
42 m_SlotIcon.GetRadialIconPanel().Show(false);
43 }
44 }
45
47 {
48 ItemManager.GetInstance().SetDefaultOpenState(m_Entity.GetType(), state);
49 m_Closed = !state;
50 if (!m_Closed)
51 OnShow();
52 else
53 OnHide();
54 }
55
56 override Header GetHeader()
57 {
58 return m_ClosableHeader;
59 }
60
61 override void Open()
62 {
63 if (IsDisplayable())
64 {
65 super.Open();
66 ItemManager.GetInstance().SetDefaultOpenState(m_Entity.GetType(), true);
67 SetOpenForSlotIcon(true);
68 OnShow();
69 m_Parent.m_Parent.Refresh();
70 }
71 }
72
73 override void Close()
74 {
75 ItemManager.GetInstance().SetDefaultOpenState(m_Entity.GetType(), false);
76 super.Close();
77 SetOpenForSlotIcon(false);
78 OnHide();
79 m_Parent.m_Parent.Refresh(); //TODO: ???
80 }
81
82 override void SetLayoutName()
83 {
85 }
86
87 override void OnShow()
88 {
89 if (IsOpened())
90 super.OnShow();
91 }
92
93 override LayoutHolder Get(int x)
94 {
95 if (m_Body && x < m_Body.Count() && x >= 0)
96 return m_Body.Get(x);
97 return null;
98 }
99
100 override void Refresh()
101 {
102 if (!m_Closed)
103 super.Refresh();
104 }
105
107 {
108 Close();
109 }
110
111 override float GetFocusedContainerHeight(bool contents = false)
112 {
113 float x, y;
114 if (contents && GetFocusedContainer())
115 y = GetFocusedContainer().GetFocusedContainerHeight(contents);
116 else if (GetRootWidget())
117 GetRootWidget().GetScreenSize(x, y);
118 return y;
119 }
120
121 override float GetFocusedContainerYPos(bool contents = false)
122 {
123 float x, y;
124 if (contents && GetFocusedContainer())
125 y = GetFocusedContainer().GetFocusedContainerYPos(contents);
126 else if (GetRootWidget())
127 GetRootWidget().GetPos(x, y);
128 return y;
129 }
130
131 override float GetFocusedContainerYScreenPos(bool contents = false)
132 {
133 float x, y;
134 if (contents && GetFocusedContainer())
135 y = GetFocusedContainer().GetFocusedContainerYScreenPos(contents);
136 else if (GetRootWidget())
137 GetRootWidget().GetScreenPos(x, y);
138 return y;
139 }
140
142 {
143 if (m_Entity)
144 {
146 m_Entity.GetInventory().GetCurrentInventoryLocation(loc);
147 if (loc.IsValid())
148 {
149 int slot = loc.GetSlot();
150 Inventory.MoveAttachmentUp(slot);
151 UpdateSelectionIcons();
152 }
153 }
154 }
155
157 {
158 if (m_Entity)
159 {
161 m_Entity.GetInventory().GetCurrentInventoryLocation(loc);
162 if (loc.IsValid())
163 {
164 int slot = loc.GetSlot();
165 Inventory.MoveAttachmentDown(slot);
166 UpdateSelectionIcons();
167 }
168 }
169 }
170
172 {
173 super.CheckHeaderDragability();
174
175 if (m_ClosableHeader && m_Entity) //TODO: do the entity check here?
176 {
177 int flag = m_ClosableHeader.GetMainWidget().GetFlags();
178 bool old = flag & WidgetFlags.DRAGGABLE;
179 bool current = ItemBase.Cast(m_Entity) && m_Entity.IsTakeable();
180 //bool changed = false;
181 if (old && !current)
182 {
183 m_ClosableHeader.GetMainWidget().ClearFlags(WidgetFlags.DRAGGABLE);
185 if (drag && drag == m_ClosableHeader.GetMainWidget())
186 {
188 m_ClosableHeader.OnDropHeader(null);
189 }
190
191 //changed = true;
192 }
193 else if (!old && current)
194 {
195 m_ClosableHeader.GetMainWidget().SetFlags(WidgetFlags.DRAGGABLE);
196 //changed = true;
197 }
198 /*if (old != current)
199 {
200 flag &= ~WidgetFlags.DRAGGABLE;
201 m_ClosableHeader.GetMainWidget().SetFlags( flag );
202 }*/
203 }
204 }
205}
void Inventory(LayoutHolder parent)
Definition Inventory.c:76
EntityAI m_Entity
Definition ActionDebug.c:11
override void OnShow()
Icon x
Icon y
override void OnHide()
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Widget m_Parent
Definition SizeToChild.c:86
override void Close()
override bool IsOpened()
override bool IsDisplayable()
override void CheckHeaderDragability()
ref ClosableHeader m_ClosableHeader
override void SetLayoutName()
void SetOpenState(bool state)
override float GetFocusedContainerYPos(bool contents=false)
override LayoutHolder Get(int x)
override void UpdateRadialIcon()
override float GetFocusedContainerHeight(bool contents=false)
override void Close()
override bool IsDisplayable()
void MoveContainerUp(Widget cont)
override void Open()
override Header GetHeader()
override float GetFocusedContainerYScreenPos(bool contents=false)
override void OnShow()
override void Refresh()
void CloseButtonOnMouseButtonDown()
void ClosableContainer(LayoutHolder parent, int sort=-1)
void MoveContainerDown(Widget cont)
Definition Header.c:2
InventoryLocation.
static ItemManager GetInstance()
float GetFocusedContainerYPos(bool contents=false)
Definition Container.c:241
float GetFocusedContainerYScreenPos(bool contents=false)
Definition Container.c:252
float GetFocusedContainerHeight(bool contents=false)
Definition Container.c:220
const string ClosableContainer
WidgetFlags
Definition EnWidgets.c:58
proto native Widget CancelWidgetDragging()
proto native Widget GetDragWidget()