DayZ 1.24
Loading...
Searching...
No Matches
HandsArea.c
Go to the documentation of this file.
2{
6
7 protected bool m_ShouldChangeSize = true;
8
10 {
12 m_Body.Insert(m_HandsContainer);
13
14 if (m_ImmedUpdate)
15 m_MainWidget.Update();
16
19 RecomputeOpenedContainers();
20 }
21
23 {
24 Widget swap_cursor = m_MainWidget.FindAnyWidget("SwapCursor");
25
26 if (swap_cursor)
27 return swap_cursor.IsVisible();
28 else
29 return false;
30 }
31
33 {
34 Widget combine_cursor = m_MainWidget.FindAnyWidget("CombineCursor");
35
37 return combine_cursor.IsVisible();
38 else
39 return false;
40 }
41
43 {
44 return m_Scroller;
45 }
46
47 override void UpdateSelectionIcons()
48 {
49#ifdef PLATFORM_CONSOLE
50 ScrollToActiveContainer();
51#endif
52 }
53
54 override void UpdateInterval()
55 {
56 if (!m_Scroller.IsScrollbarVisible())
57 m_Scroller.VScrollToPos01(0.0);
58 else if (m_Scroller.GetVScrollPos01() > 1.0)
59 m_Scroller.VScrollToPos01(1.0);
60 m_HandsContainer.UpdateInterval();
61
62 float x, y;
63 float x2, y2;
64 m_Scroller.GetScreenSize(x, y);
65 m_MainWidget.GetScreenSize(x2, y2);
66 if (y2 != y)
67 m_ShouldChangeSize = true;
68
69 bool changed_size;
70 if (m_ShouldChangeSize && m_HandsResizer.ResizeParentToChild(changed_size, InventoryMenu.GetHeight() * 0.5))
71 m_Scroller.SetAlpha(0.3921);
72 else
73 m_Scroller.SetAlpha(0);
74
75 if (changed_size)
76 m_ShouldChangeSize = false;
77 }
78
79 override void SetLayoutName()
80 {
81 m_LayoutName = WidgetLayoutName.HandsArea;
82 }
83
84 override void SetParentWidget()
85 {
86 m_ParentWidget = m_Parent.GetMainWidget().FindAnyWidget("HandsPanel");
87 }
88
89 override void OnShow()
90 {
91 super.OnShow();
92 m_HandsContainer.OnShow();
93 }
94
95 override void Refresh()
96 {
98 m_ShouldChangeSize = true;
99 }
100
102 {
103 super.SetSameLevelNextActive();
104
105 Refresh();
106 }
108 {
109 super.SetSameLevelPreviousActive();
110
111 Refresh();
112 }
113
115 {
116 if (w == NULL)
117 return;
118
119 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
120
121 if (!ipw)
122 {
123 string name = w.GetName();
124 name.Replace("PanelWidget", "Render");
125 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
126 }
127
128 if (!ipw)
129 ipw = ItemPreviewWidget.Cast(w);
130
131 if (!ipw || !ipw.IsInherited(ItemPreviewWidget))
132 return;
133
134 if (ipw.GetItem() && GetGame().GetPlayer().GetHumanInventory().CanAddEntityIntoHands(ipw.GetItem()))
135 {
137 ItemManager.GetInstance().HideDropzones();
138 ItemManager.GetInstance().GetCenterDropzone().SetAlpha(1);
139 }
140 else
141 {
143 ItemManager.GetInstance().HideDropzones();
144 ItemManager.GetInstance().GetCenterDropzone().SetAlpha(1);
145 }
146 }
147
149 {
150 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
151 if (!ipw)
152 {
153 string name = w.GetName();
154 name.Replace("PanelWidget", "Render");
155 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
156 }
157
158 if (!ipw)
159 ipw = ItemPreviewWidget.Cast(w);
160
161 if (!ipw || !ipw.GetItem() || !ipw.IsInherited(ItemPreviewWidget))
162 return;
163
164 if (!ipw.GetItem().GetInventory().CanRemoveEntity())
165 return;
166
167 if (GetGame().GetPlayer().GetHumanInventory().CanAddEntityIntoHands(ipw.GetItem()))
168 {
169 ItemBase item_base = ItemBase.Cast(ipw.GetItem());
170 float stackable = item_base.GetTargetQuantityMax(-1);
171
172 if (stackable == 0 || item_base.GetQuantity() <= stackable)
173 GetGame().GetPlayer().PredictiveTakeEntityToHands(item_base);
174 else if (stackable != 0 && stackable <= item_base.GetQuantity())
175 item_base.SplitIntoStackMaxHandsClient(PlayerBase.Cast(GetGame().GetPlayer()));
176 }
177 }
178}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Icon x
Icon y
void InventoryMenu()
PlayerBase GetPlayer()
Widget m_Parent
Definition SizeToChild.c:86
Widget m_ParentWidget
static int GREEN_COLOR
static int RED_COLOR
static ColorManager GetInstance()
void OnHandsPanelDropReceived(Widget w, int x, int y, Widget receiver)
Definition HandsArea.c:148
override void SetSameLevelPreviousActive()
Definition HandsArea.c:107
override ScrollWidget GetScrollWidget()
Definition HandsArea.c:42
bool IsSwapActive()
Definition HandsArea.c:22
ScrollWidget m_Scroller
Definition HandsArea.c:3
bool IsCombineActive()
Definition HandsArea.c:32
bool m_ShouldChangeSize
Definition HandsArea.c:7
override void OnShow()
Definition HandsArea.c:89
override void Refresh()
Definition HandsArea.c:95
override void SetParentWidget()
Definition HandsArea.c:84
void HandsArea(LayoutHolder parent)
Definition HandsArea.c:9
override void SetSameLevelNextActive()
Definition HandsArea.c:101
ref SizeToChild m_HandsResizer
Definition HandsArea.c:5
override void UpdateInterval()
Definition HandsArea.c:54
override void UpdateSelectionIcons()
Definition HandsArea.c:47
ref HandsContainer m_HandsContainer
Definition HandsArea.c:4
override void SetLayoutName()
Definition HandsArea.c:79
void DraggingOverHandsPanel(Widget w, int x, int y, Widget receiver)
Definition HandsArea.c:114
static ItemManager GetInstance()
const string HandsArea
proto native CGame GetGame()