DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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 {
32 bool show_radial_icon;
33 show_radial_icon = IsOpened();
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 {
43 m_SlotIcon.GetRadialIconPanel().Show( false );
44 }
45 }
46 }
47
48 void SetOpenState( bool state )
49 {
51 m_Closed = !state;
52 if( !m_Closed )
53 {
54 OnShow();
55 }
56 else
57 {
58 OnHide();
59 }
60 }
61
62 override Header GetHeader()
63 {
64 return m_ClosableHeader;
65 }
66
67 override void Open()
68 {
69 if( IsDisplayable() )
70 {
71 super.Open();
73 SetOpenForSlotIcon(true);
74 OnShow();
75 m_Parent.m_Parent.Refresh();
76 }
77 }
78
79 override void Close()
80 {
82 super.Close();
83 SetOpenForSlotIcon(false);
84 OnHide();
85 m_Parent.m_Parent.Refresh(); //TODO: ???
86 }
87
88 override void SetLayoutName()
89 {
91 }
92
93 override void OnShow()
94 {
95 if( IsOpened() )
96 {
97 super.OnShow();
98 }
99 }
100
101 override LayoutHolder Get( int x )
102 {
103 if( m_Body && x < m_Body.Count() && x >= 0 )
104 return m_Body.Get( x );
105 return null;
106 }
107
108 override void Refresh()
109 {
110 if( !m_Closed )
111 {
112 super.Refresh();
113 }
114 }
115
117 {
118 Close();
119 }
120
121 override float GetFocusedContainerHeight( bool contents = false )
122 {
123 float x, y;
124 if( contents && GetFocusedContainer() )
125 y = GetFocusedContainer().GetFocusedContainerHeight( contents );
126 else if( GetRootWidget() )
127 GetRootWidget().GetScreenSize( x, y );
128 return y;
129 }
130
131 override float GetFocusedContainerYPos( bool contents = false )
132 {
133 float x, y;
134 if( contents && GetFocusedContainer() )
135 y = GetFocusedContainer().GetFocusedContainerYPos( contents );
136 else if( GetRootWidget() )
137 GetRootWidget().GetPos( x, y );
138 return y;
139 }
140
141 override float GetFocusedContainerYScreenPos( bool contents = false )
142 {
143 float x, y;
144 if( contents && GetFocusedContainer() )
145 y = GetFocusedContainer().GetFocusedContainerYScreenPos( contents );
146 else if( GetRootWidget() )
147 GetRootWidget().GetScreenPos( x, y );
148 return y;
149 }
150
152 {
153 if( m_Entity )
154 {
156 m_Entity.GetInventory().GetCurrentInventoryLocation( loc );
157 if( loc.IsValid() )
158 {
159 int slot = loc.GetSlot();
160 Inventory.MoveAttachmentUp( slot );
161 UpdateSelectionIcons();
162 }
163 }
164 }
165
167 {
168 if( m_Entity )
169 {
171 m_Entity.GetInventory().GetCurrentInventoryLocation( loc );
172 if( loc.IsValid() )
173 {
174 int slot = loc.GetSlot();
175 Inventory.MoveAttachmentDown( slot );
176 UpdateSelectionIcons();
177 }
178 }
179 }
180
182 {
183 super.CheckHeaderDragability();
184
185 if (m_ClosableHeader && m_Entity) //TODO: do the entity check here?
186 {
187 int flag = m_ClosableHeader.GetMainWidget().GetFlags();
188 bool old = flag & WidgetFlags.DRAGGABLE;
189 bool current = ItemBase.Cast(m_Entity) && m_Entity.IsTakeable();
190 //bool changed = false;
191 if (old && !current)
192 {
193 m_ClosableHeader.GetMainWidget().ClearFlags( WidgetFlags.DRAGGABLE );
194 Widget drag = GetDragWidget();
195 if (drag && drag == m_ClosableHeader.GetMainWidget())
196 {
198 m_ClosableHeader.OnDropHeader(null);
199 }
200
201 //changed = true;
202 }
203 else if (!old && current)
204 {
205 m_ClosableHeader.GetMainWidget().SetFlags( WidgetFlags.DRAGGABLE );
206 //changed = true;
207 }
208 /*if (old != current)
209 {
210 flag &= ~WidgetFlags.DRAGGABLE;
211 m_ClosableHeader.GetMainWidget().SetFlags( flag );
212 }*/
213 }
214 }
215}
void Inventory(LayoutHolder parent)
Definition Inventory.c:75
override void OnShow()
Icon x
Icon y
override void OnHide()
class PluginItemDiagnosticEventHandler extends ScriptedWidgetEventHandler m_Entity
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
protected Widget m_Parent
Definition SizeToChild.c:92
override bool IsOpened()
override void Close()
override bool IsDisplayable()
override float GetFocusedContainerYPos(bool contents=false)
void SetOpenState(bool state)
void ClosableContainer(LayoutHolder parent, int sort=-1)
void MoveContainerDown(Widget cont)
override void Refresh()
override void OnShow()
protected bool m_LockCargo
override float GetFocusedContainerYScreenPos(bool contents=false)
override void UpdateRadialIcon()
protected ref ClosableHeader m_ClosableHeader
void CloseButtonOnMouseButtonDown()
override Header GetHeader()
override LayoutHolder Get(int x)
override void CheckHeaderDragability()
override float GetFocusedContainerHeight(bool contents=false)
override void Close()
void MoveContainerUp(Widget cont)
override void SetLayoutName()
override void Open()
override bool IsDisplayable()
Definition Header.c:2
InventoryLocation.
proto native bool IsValid()
verify current set inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
void SetDefaultOpenState(string type, bool is_opened)
static ItemManager GetInstance()
float GetFocusedContainerHeight(bool contents=false)
Definition Container.c:248
LayoutHolder Get(int x)
Definition Container.c:1011
float GetFocusedContainerYPos(bool contents=false)
Definition Container.c:269
float GetFocusedContainerYScreenPos(bool contents=false)
Definition Container.c:280
const string ClosableContainer
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
WidgetFlags
Definition EnWidgets.c:57
proto native Widget CancelWidgetDragging()
proto native Widget GetDragWidget()