DayZ 1.24
Loading...
Searching...
No Matches
LeftArea.c
Go to the documentation of this file.
2{
3 protected Widget m_UpIcon;
4 protected Widget m_DownIcon;
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
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 {
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 m_ActiveIndex = 0;
48 Container active_container = Container.Cast(m_OpenedContainers.Get(m_ActiveIndex));
49 return active_container.IsActive();
50 }
51
52 override void SetActive(bool active)
53 {
54 super.SetActive(active);
55
57 }
58
60 {
61 return m_ScrollWidget;
62 }
63
64 override void UpdateSelectionIcons()
65 {
66#ifdef PLATFORM_CONSOLE
67 ScrollToActiveContainer();
68#endif
69 m_UpIcon.Show(m_IsActive);
71 if (m_IsActive)
72 {
73 float x, y;
74 m_UpIcon.GetScreenSize(x, y);
75
77 m_UpIcon.SetPos(0, Math.Clamp(top_y, 0, 99999));
78
79#ifndef PLATFORM_CONSOLE
80 float x2, y2;
81 m_DownIcon.GetScreenSize(x2, y2);
83
84 float diff = bottom_y - (top_y + y);
85 if (diff < 0)
86 {
87 top_y += diff / 2;
88 bottom_y -= diff / 2;
89 }
90 m_DownIcon.SetPos(0, bottom_y);
91#endif
92 }
93 }
94
96 {
97 float x, y, cont_screen_pos;
98 m_MainWidget.GetScreenPos(x, y);
99 if (m_OpenedContainers.IsValidIndex(m_ActiveIndex))
100 cont_screen_pos = Container.Cast(m_OpenedContainers.Get(m_ActiveIndex)).GetFocusedContainerYScreenPos();
101
102 return cont_screen_pos - y;
103 }
104
106 {
108 m_MainWidget.GetScreenPos(x, y);
109
110 if (m_OpenedContainers.IsValidIndex(m_ActiveIndex))
111 {
112 cont_screen_pos = Container.Cast(m_OpenedContainers.Get(m_ActiveIndex)).GetFocusedContainerYScreenPos();
113 cont_screen_height = Container.Cast(m_OpenedContainers.Get(m_ActiveIndex)).GetFocusedContainerHeight();
114 }
115
117 }
118
120 {
121 m_VicinityContainer.SetSameLevelNextActive();
122 Refresh();
123 }
125 {
126 m_VicinityContainer.SetSameLevelPreviousActive();
127 Refresh();
128 }
129
131 {
132 Container c = GetFocusedContainer();
133 if (c)
134 c.ExpandCollapseContainer();
135
136 Refresh();
137 }
138
140 {
141 m_VicinityContainer.OnLeftPanelDropReceived(w, x, y, receiver);
142 }
143
144 override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
145 {
146 m_VicinityContainer.DraggingOverHeader(w, x, y, receiver);
147 }
148
149 override void SetLayoutName()
150 {
151#ifdef PLATFORM_CONSOLE
152 m_LayoutName = WidgetLayoutName.LeftAreaXbox;
153#else
154 switch (InventoryMenu.GetWidthType())
155 {
156 case ScreenWidthType.NARROW:
157 {
158 m_LayoutName = WidgetLayoutName.LeftAreaNarrow;
159 break;
160 }
161 case ScreenWidthType.MEDIUM:
162 {
163 m_LayoutName = WidgetLayoutName.LeftAreaMedium;
164 break;
165 }
166 case ScreenWidthType.WIDE:
167 {
168 m_LayoutName = WidgetLayoutName.LeftAreaWide;
169 break;
170 }
171 }
172#endif
173
174 }
175
177 {
178 EntityAI item = GetFocusedContainer().GetFocusedItem();
179 return item;
180 }
181
186
187 override void SetParentWidget()
188 {
189 m_ParentWidget = m_Parent.GetMainWidget().FindAnyWidget("LeftPanel");
190 }
191
192 override void OnShow()
193 {
194 super.OnShow();
195 Refresh();
196 }
197
198 override void Refresh()
199 {
200 super.Refresh();
201
202 m_MainWidget.Update();
203 m_RootWidget.Update();
204 m_ScrollWidget.Update();
205
207 m_ShouldChangeSize = true;
208 }
209
210 override void UpdateInterval()
211 {
212 m_IsProcessing = true;
213 super.UpdateInterval();
214 m_IsProcessing = false;
215
216 float x, y;
217 float x2, y2;
218 m_ContentParent.GetScreenSize(x, y);
219 m_MainWidget.GetScreenSize(x2, y2);
220 if (y2 != y)
221 m_ShouldChangeSize = true;
222 bool changed_size;
223 //if ( m_ShouldChangeSize )
224 m_ContentResize.ResizeParentToChild(changed_size);
226 {
227 m_MainWidget.Update();
228 m_RootWidget.Update();
229 m_ScrollWidget.Update();
230 m_ShouldChangeSize = false;
231 }
232 CheckScrollbarVisibility();
233 }
234
236 {
237 if (!m_IsProcessing)
238 Refresh();
239 return true;
240 }
241
243 {
244 if (!m_IsProcessing)
245 Refresh();
246 return true;
247 }
248}
Icon x
Icon y
ScreenWidthType
void InventoryMenu()
bool m_IsActive
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Widget m_Parent
Definition SizeToChild.c:86
Widget m_ParentWidget
override float GetFocusedContainerHeight(bool contents=false)
override float GetFocusedContainerYScreenPos(bool contents=false)
override void ExpandCollapseContainer()
Definition LeftArea.c:130
override void UpdateInterval()
Definition LeftArea.c:210
override bool OnChildAdd(Widget w, Widget child)
Definition LeftArea.c:242
bool m_IsProcessing
Definition LeftArea.c:10
override void SetParentWidget()
Definition LeftArea.c:187
override void SetSameLevelNextActive()
Definition LeftArea.c:119
override void SetActive(bool active)
Definition LeftArea.c:52
override bool IsActive()
Definition LeftArea.c:44
override EntityAI GetFocusedItem()
Definition LeftArea.c:176
float GetCurrentContainerTopY()
Definition LeftArea.c:95
override void SetLayoutName()
Definition LeftArea.c:149
void OnLeftPanelDropReceived(Widget w, int x, int y, Widget receiver)
Definition LeftArea.c:139
Widget m_ContentParent
Definition LeftArea.c:5
ScrollWidget m_ScrollWidget
Definition LeftArea.c:7
Widget m_UpIcon
Definition LeftArea.c:3
void LeftArea(LayoutHolder parent)
Definition LeftArea.c:12
override ScrollWidget GetScrollWidget()
Definition LeftArea.c:59
override void UpdateSelectionIcons()
Definition LeftArea.c:64
float GetCurrentContainerBottomY()
Definition LeftArea.c:105
bool m_ShouldChangeSize
Definition LeftArea.c:9
override void Refresh()
Definition LeftArea.c:198
VicinityContainer GetVicinityContainer()
Definition LeftArea.c:182
override void SetSameLevelPreviousActive()
Definition LeftArea.c:124
override bool OnChildRemove(Widget w, Widget child)
Definition LeftArea.c:235
ref VicinityContainer m_VicinityContainer
Definition LeftArea.c:6
ref SizeToChild m_ContentResize
Definition LeftArea.c:8
override void UnfocusGrid()
Definition LeftArea.c:34
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
Definition LeftArea.c:144
Widget m_DownIcon
Definition LeftArea.c:4
override void OnShow()
Definition LeftArea.c:192
Definition EnMath.c:7
static WidgetEventHandler GetInstance()
const string LeftAreaWide
const string LeftAreaNarrow
const string LeftAreaXbox
const string LeftAreaMedium
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'.