DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
LeftArea.c
Go to the documentation of this file.
2{
3 protected Widget m_UpIcon;
4 protected Widget m_DownIcon;
7 protected ScrollWidget m_ScrollWidget;
8 protected ref SizeToChild m_ContentResize;
9 protected bool m_ShouldChangeSize = true;
10 protected bool m_IsProcessing = false; // Prevents refreshing every time a child is added while it is still processing
11
12 void LeftArea(LayoutHolder parent )
13 {
14 m_MainWidget.Show(true, false);
15
16 m_ContentParent = m_MainWidget.FindAnyWidget("ContentParent");
18
19 m_ScrollWidget = ScrollWidget.Cast(m_MainWidget.FindAnyWidget("Scroller"));
20 m_MainWidget = m_MainWidget.FindAnyWidget("Content");
21
22 m_UpIcon = m_RootWidget.FindAnyWidget("Up");
23 m_DownIcon = m_RootWidget.FindAnyWidget("Down");
24
25 m_VicinityContainer = new VicinityContainer(this, false);
26 m_Body.Insert(m_VicinityContainer);
27 m_ActiveIndex = 0;
28
29 WidgetEventHandler.GetInstance().RegisterOnChildAdd(m_MainWidget, this, "OnChildAdd");
30 WidgetEventHandler.GetInstance().RegisterOnChildRemove(m_MainWidget, this, "OnChildRemove");
31 RecomputeOpenedContainers();
32 }
33
34 override void UnfocusGrid()
35 {
36 Container active_container;
37 for ( int i = 0; i < m_OpenedContainers.Count(); i++ )
38 {
39 active_container = Container.Cast( m_OpenedContainers.Get( i ) );
40 active_container.UnfocusGrid();
41 }
42 }
43
44 override bool IsActive()
45 {
46 if( m_OpenedContainers.Count() <= m_ActiveIndex )
47 {
48 m_ActiveIndex = 0;
49 }
50 Container active_container = Container.Cast( m_OpenedContainers.Get( m_ActiveIndex ) );
51 return active_container.IsActive( );
52 }
53
54 override void SetActive( bool active )
55 {
56 super.SetActive( active );
57
59 }
60
61 override ScrollWidget GetScrollWidget()
62 {
63 return m_ScrollWidget;
64 }
65
66 override void UpdateSelectionIcons()
67 {
68 #ifdef PLATFORM_CONSOLE
69 ScrollToActiveContainer();
70 #endif
71 m_UpIcon.Show( m_IsActive );
72 m_DownIcon.Show( m_IsActive );
73 if( m_IsActive )
74 {
75 float x, y;
76 m_UpIcon.GetScreenSize( x, y );
77
78 float top_y = GetCurrentContainerTopY();
79 m_UpIcon.SetPos( 0, Math.Clamp( top_y, 0, 99999 ) );
80
81 #ifndef PLATFORM_CONSOLE
82 float x2, y2;
83 m_DownIcon.GetScreenSize( x2, y2 );
84 float bottom_y = GetCurrentContainerBottomY() - y2;
85
86 float diff = bottom_y - ( top_y + y );
87 if( diff < 0 )
88 {
89 top_y += diff / 2;
90 bottom_y -= diff / 2;
91 }
92 m_DownIcon.SetPos( 0, bottom_y );
93 #endif
94 }
95 }
96
98 {
99 float x, y, cont_screen_pos;
100 m_MainWidget.GetScreenPos( x, y );
101 if ( m_OpenedContainers.IsValidIndex( m_ActiveIndex ) )
102 cont_screen_pos = Container.Cast( m_OpenedContainers.Get( m_ActiveIndex ) ).GetFocusedContainerYScreenPos();
103
104 return cont_screen_pos - y;
105 }
106
108 {
109 float x, y, cont_screen_pos, cont_screen_height;
110 m_MainWidget.GetScreenPos( x, y );
111
112 if ( m_OpenedContainers.IsValidIndex( m_ActiveIndex ) )
113 {
114 cont_screen_pos = Container.Cast( m_OpenedContainers.Get( m_ActiveIndex ) ).GetFocusedContainerYScreenPos();
115 cont_screen_height = Container.Cast( m_OpenedContainers.Get( m_ActiveIndex ) ).GetFocusedContainerHeight();
116 }
117
118 return cont_screen_pos - y + cont_screen_height;
119 }
120
122 {
123 Container c = GetFocusedContainer();
124 if (c)
125 {
126 c.ExpandCollapseContainer();
127 }
128
129 Refresh();
130 }
131
132 void OnLeftPanelDropReceived( Widget w, int x, int y, Widget receiver )
133 {
135 }
136
137 override void DraggingOverHeader( Widget w, int x, int y, Widget receiver )
138 {
139 m_VicinityContainer.DraggingOverHeader( w, x, y, receiver );
140 }
141
142 override void SetLayoutName()
143 {
144 #ifdef PLATFORM_CONSOLE
145 m_LayoutName = WidgetLayoutName.LeftAreaXbox;
146 #else
147 switch ( InventoryMenu.GetWidthType() )
148 {
149 case ScreenWidthType.NARROW:
150 {
151 m_LayoutName = WidgetLayoutName.LeftAreaNarrow;
152 break;
153 }
154 case ScreenWidthType.MEDIUM:
155 {
156 m_LayoutName = WidgetLayoutName.LeftAreaMedium;
157 break;
158 }
159 case ScreenWidthType.WIDE:
160 {
161 m_LayoutName = WidgetLayoutName.LeftAreaWide;
162 break;
163 }
164 }
165 #endif
166
167 }
168
170 {
171 EntityAI item = GetFocusedContainer().GetFocusedItem();
172 return item;
173 }
174
176 {
177 return m_VicinityContainer;
178 }
179
180 override void SetParentWidget()
181 {
182 m_ParentWidget = m_Parent.GetMainWidget().FindAnyWidget( "LeftPanel" );
183 }
184
185 override void OnShow()
186 {
187 super.OnShow();
188 Refresh();
189 }
190
191 override void Refresh()
192 {
193 super.Refresh();
194
195 m_MainWidget.Update();
196 m_RootWidget.Update();
197 m_ScrollWidget.Update();
198
200 m_ShouldChangeSize = true;
201 }
202
203 override void UpdateInterval()
204 {
205 m_IsProcessing = true;
206 super.UpdateInterval();
207 m_IsProcessing = false;
208
209 float x, y;
210 float x2, y2;
211 m_ContentParent.GetScreenSize( x, y );
212 m_MainWidget.GetScreenSize( x2, y2 );
213 if ( y2 != y )
214 m_ShouldChangeSize = true;
215 bool changed_size;
216 //if ( m_ShouldChangeSize )
217 m_ContentResize.ResizeParentToChild( changed_size );
218 if ( changed_size || m_ShouldChangeSize )
219 {
220 m_MainWidget.Update();
221 m_RootWidget.Update();
222 m_ScrollWidget.Update();
223 m_ShouldChangeSize = false;
224 }
225 CheckScrollbarVisibility();
226 }
227
228 override bool OnChildRemove( Widget w, Widget child )
229 {
230 if (!m_IsProcessing)
231 Refresh();
232 return true;
233 }
234
235 override bool OnChildAdd( Widget w, Widget child )
236 {
237 if (!m_IsProcessing)
238 Refresh();
239 return true;
240 }
241}
Icon x
Icon y
ScreenWidthType
void InventoryMenu()
bool m_IsActive
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
protected Widget m_Parent
Definition SizeToChild.c:92
protected Widget m_ParentWidget
override float GetFocusedContainerYScreenPos(bool contents=false)
override float GetFocusedContainerHeight(bool contents=false)
protected ref SizeToChild m_ContentResize
Definition LeftArea.c:8
override void UnfocusGrid()
Definition LeftArea.c:34
protected Widget m_ContentParent
Definition LeftArea.c:5
override bool OnChildAdd(Widget w, Widget child)
Definition LeftArea.c:235
void LeftArea(LayoutHolder parent)
Definition LeftArea.c:12
protected ScrollWidget m_ScrollWidget
Definition LeftArea.c:7
protected bool m_IsProcessing
Definition LeftArea.c:10
override void Refresh()
Definition LeftArea.c:191
override void UpdateSelectionIcons()
Definition LeftArea.c:66
override void UpdateInterval()
Definition LeftArea.c:203
override void OnShow()
Definition LeftArea.c:185
void OnLeftPanelDropReceived(Widget w, int x, int y, Widget receiver)
Definition LeftArea.c:132
protected Widget m_UpIcon
Definition LeftArea.c:3
override bool IsActive()
Definition LeftArea.c:44
float GetCurrentContainerTopY()
Definition LeftArea.c:97
override bool OnChildRemove(Widget w, Widget child)
Definition LeftArea.c:228
override void SetActive(bool active)
Definition LeftArea.c:54
override ScrollWidget GetScrollWidget()
Definition LeftArea.c:61
protected bool m_ShouldChangeSize
Definition LeftArea.c:9
protected ref VicinityContainer m_VicinityContainer
Definition LeftArea.c:6
float GetCurrentContainerBottomY()
Definition LeftArea.c:107
override void ExpandCollapseContainer()
Definition LeftArea.c:121
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
Definition LeftArea.c:137
VicinityContainer GetVicinityContainer()
Definition LeftArea.c:175
override void SetParentWidget()
Definition LeftArea.c:180
protected Widget m_DownIcon
Definition LeftArea.c:4
override void SetLayoutName()
Definition LeftArea.c:142
override EntityAI GetFocusedItem()
Definition LeftArea.c:169
Definition EnMath.c:7
void OnLeftPanelDropReceived(Widget w, int x, int y, Widget receiver)
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
static WidgetEventHandler GetInstance()
void RegisterOnChildRemove(Widget w, Managed eventHandler, string functionName)
void RegisterOnChildAdd(Widget w, Managed eventHandler, string functionName)
const string LeftAreaMedium
const string LeftAreaWide
const string LeftAreaXbox
const string LeftAreaNarrow
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.