Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
leftarea.c
Go to the documentation of this file.
2 {
3  protected Widget m_UpIcon;
4  protected Widget m_DownIcon;
5  protected Widget m_ContentParent;
6  protected ref VicinityContainer m_VicinityContainer;
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");
17  m_ContentParent.GetScript(m_ContentResize);
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 
58  UpdateSelectionIcons();
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 
97  float GetCurrentContainerTopY()
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 
107  float GetCurrentContainerBottomY()
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 
121  override void SetSameLevelNextActive()
122  {
123  m_VicinityContainer.SetSameLevelNextActive();
124  Refresh();
125  }
126  override void SetSameLevelPreviousActive()
127  {
128  m_VicinityContainer.SetSameLevelPreviousActive();
129  Refresh();
130  }
131 
132  override void ExpandCollapseContainer()
133  {
134  Container c = GetFocusedContainer();
135  if (c)
136  {
137  c.ExpandCollapseContainer();
138  }
139 
140  Refresh();
141  }
142 
143  void OnLeftPanelDropReceived( Widget w, int x, int y, Widget receiver )
144  {
145  m_VicinityContainer.OnLeftPanelDropReceived( w, x, y, receiver );
146  }
147 
148  override void DraggingOverHeader( Widget w, int x, int y, Widget receiver )
149  {
150  m_VicinityContainer.DraggingOverHeader( w, x, y, receiver );
151  }
152 
153  override void SetLayoutName()
154  {
155  #ifdef PLATFORM_CONSOLE
156  m_LayoutName = WidgetLayoutName.LeftAreaXbox;
157  #else
158  switch ( InventoryMenu.GetWidthType() )
159  {
160  case ScreenWidthType.NARROW:
161  {
162  m_LayoutName = WidgetLayoutName.LeftAreaNarrow;
163  break;
164  }
165  case ScreenWidthType.MEDIUM:
166  {
167  m_LayoutName = WidgetLayoutName.LeftAreaMedium;
168  break;
169  }
170  case ScreenWidthType.WIDE:
171  {
172  m_LayoutName = WidgetLayoutName.LeftAreaWide;
173  break;
174  }
175  }
176  #endif
177 
178  }
179 
180  override EntityAI GetFocusedItem()
181  {
182  EntityAI item = GetFocusedContainer().GetFocusedItem();
183  return item;
184  }
185 
186  VicinityContainer GetVicinityContainer()
187  {
188  return m_VicinityContainer;
189  }
190 
191  override void SetParentWidget()
192  {
193  m_ParentWidget = m_Parent.GetMainWidget().FindAnyWidget( "LeftPanel" );
194  }
195 
196  override void OnShow()
197  {
198  super.OnShow();
199  Refresh();
200  }
201 
202  override void Refresh()
203  {
204  super.Refresh();
205 
206  m_MainWidget.Update();
207  m_RootWidget.Update();
208  m_ScrollWidget.Update();
209 
210  UpdateSelectionIcons();
211  m_ShouldChangeSize = true;
212  }
213 
214  override void UpdateInterval()
215  {
216  m_IsProcessing = true;
217  super.UpdateInterval();
218  m_IsProcessing = false;
219 
220  float x, y;
221  float x2, y2;
222  m_ContentParent.GetScreenSize( x, y );
223  m_MainWidget.GetScreenSize( x2, y2 );
224  if ( y2 != y )
225  m_ShouldChangeSize = true;
226  bool changed_size;
227  //if ( m_ShouldChangeSize )
228  m_ContentResize.ResizeParentToChild( changed_size );
229  if ( changed_size || m_ShouldChangeSize )
230  {
231  m_MainWidget.Update();
232  m_RootWidget.Update();
233  m_ScrollWidget.Update();
234  m_ShouldChangeSize = false;
235  }
236  CheckScrollbarVisibility();
237  }
238 
239  override bool OnChildRemove( Widget w, Widget child )
240  {
241  if (!m_IsProcessing)
242  Refresh();
243  return true;
244  }
245 
246  override bool OnChildAdd( Widget w, Widget child )
247  {
248  if (!m_IsProcessing)
249  Refresh();
250  return true;
251  }
252 }
LayoutHolder
Definition: container.c:1
m_RootWidget
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Definition: pluginremoteplayerdebugclient.c:14
y
Icon y
WidgetLayoutName
Definition: widgetlayoutname.c:1
m_Parent
protected Widget m_Parent
Definition: sizetochild.c:92
VicinityContainer
Definition: vicinitycontainer.c:1
m_IsActive
bool m_IsActive
Definition: modifierbase.c:20
Container
Definition: cargocontainer.c:2
ScreenWidthType
ScreenWidthType
Definition: inventorymenu.c:1
x
Icon x
InventoryMenu
void InventoryMenu()
Definition: inventorymenu.c:20
m_ParentWidget
protected Widget m_ParentWidget
Definition: uihintpanel.c:24
Widget
Definition: enwidgets.c:189
LeftArea
Definition: leftarea.c:1
Math
Definition: enmath.c:6
EntityAI
Definition: building.c:5
WidgetEventHandler
Definition: widgeteventhandler.c:1