DayZ 1.24
Loading...
Searching...
No Matches
HandsPreview.c
Go to the documentation of this file.
2{
3 protected ref Icon m_Icon;
5
6 protected float m_IconSize;
7
8 protected ItemBase m_Item
9
11 {
12 GetGame().GetPlayer().GetOnItemAddedToHands().Insert(CreateNewIcon);
13 GetGame().GetPlayer().GetOnItemRemovedFromHands().Insert(DeleteIcon);
14 }
15
17 {
18 GetGame().GetPlayer().GetOnItemAddedToHands().Remove(CreateNewIcon);
19 GetGame().GetPlayer().GetOnItemRemovedFromHands().Remove(DeleteIcon);
20 }
21
23 {
24 if (m_Icon)
25 m_Icon.SetQuantity();
26 }
27
29 {
30 return m_Item;
31 }
32
34 {
35 return m_Icon;
36 }
37
38 override void SetDefaultFocus(bool while_micromanagment_mode = false)
39 {
40 super.SetDefaultFocus(while_micromanagment_mode);
41 if (m_Icon)
42 m_Icon.SetActive(true);
43 }
44
45 override void SetLastFocus()
46 {
47 super.SetLastFocus();
48 if (m_Icon)
49 m_Icon.SetActive(true);
50 }
51
52 override void Unfocus()
53 {
54 super.Unfocus();
55 if (m_Icon)
56 m_Icon.SetActive(false);
57 }
58
60 {
61 return m_IconSize;
62 }
63
64 override void SetLayoutName()
65 {
66 m_LayoutName = WidgetLayoutName.HandsPreview;
67 }
68
70 {
71 delete m_Icon;
72 m_Item = null;
73 }
74
75 override void UpdateInterval()
76 {
77 bool show_combine_swap = ItemManager.GetInstance().IsDragging();
78
79#ifdef PLATFORM_CONSOLE
80 if (m_Icon && !m_Icon.IsDragged() && GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer())
81#else
82 if (m_Icon && !m_Icon.IsDragged())
83#endif
84 {
85 m_Icon.GetMainWidget().FindAnyWidget("Combine").Show(show_combine_swap);
86 m_Icon.GetMainWidget().FindAnyWidget("Swap").Show(show_combine_swap);
87 }
88
89 if (m_Icon)
90 m_Icon.UpdateInterval();
91 }
92
94 {
95 float y;
96 GetRootWidget().GetParent().GetParent().GetParent().GetParent().GetScreenSize(m_IconSize, y);
98
99 m_Icon = new Icon(this, true);
100 m_Icon.Refresh();
101 if (m_Icon)
102 {
103 m_Item = item;
104 m_Icon.Init(m_Item);
105 m_Icon.FullScreen();
106 (HandsContainer.Cast(m_Parent)).ShowAtt(m_Item);
107 m_Icon.Refresh();
108 }
109
110 m_RootWidget.SetColor(ARGB(180, 0, 0, 0));
111 m_Parent.GetParent().Refresh();
112 Inventory.GetInstance().UpdateConsoleToolbar();
113
115 HandsHeader header = HandsHeader.Cast(parent.GetHeader());
116
117 if (m_Item && !m_Item.GetInventory().GetCargo())
118 {
119 string display_name = m_Item.GetDisplayName();
120 display_name.ToUpper();
121 header.SetName(display_name);
122 }
123 }
124
126 {
127 RemoveItem();
128 (HandsContainer.Cast(m_Parent)).DestroyAtt();
129 (HandsContainer.Cast(m_Parent)).DestroyCargo();
132 m_RootWidget.SetColor(ARGB(166, 80, 80, 80));
133 m_Parent.GetParent().Refresh();
134 Inventory.GetInstance().UpdateConsoleToolbar();
135 }
136
137 override bool SelectItem()
138 {
139 if (m_Item)
140 {
141 ItemManager.GetInstance().SetSelectedItemEx(m_Item, null, null);
142 return true;
143 }
144 return false;
145 }
146
147 override bool Select()
148 {
149 Man player = GetGame().GetPlayer();
151 if (ItemManager.GetInstance().IsMicromanagmentMode())
152 {
153 EntityAI selected_item = ItemManager.GetInstance().GetSelectedItem();
154 if (selected_item && selected_item.GetInventory().CanRemoveEntity())
155 {
156 if (item_in_hands && item_in_hands.GetInventory().CanRemoveEntity())
157 {
159 {
160 player.PredictiveSwapEntities(item_in_hands, selected_item);
161 return true;
162 }
163 }
164 else
165 {
166 if (player.GetHumanInventory().CanAddEntityInHands(selected_item) && selected_item.GetInventory().CanRemoveEntity())
167 {
169 float stackable = item_base.GetTargetQuantityMax();
170 if (stackable == 0 || item_base.GetQuantity() <= stackable)
171 {
172 GetGame().GetPlayer().PredictiveTakeEntityToHands(item_base);
173 return true;
174 }
175 else if (stackable != 0 && stackable <= item_base.GetQuantity())
176 {
177 item_base.SplitIntoStackMaxHandsClient(PlayerBase.Cast(GetGame().GetPlayer()));
178 return true;
179 }
180 }
181 }
182 }
183 }
184 return false;
185 }
186}
void Inventory(LayoutHolder parent)
Definition Inventory.c:76
ActionInput GetInput()
Definition ActionBase.c:989
ItemBase m_Item
Definition ActionInput.c:16
Icon y
PlayerBase GetPlayer()
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Widget m_Parent
Definition SizeToChild.c:86
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Definition Inventory.c:610
override Header GetHeader()
override bool Select()
float GetIconSize()
override void SetLayoutName()
override void UpdateInterval()
EntityAI m_AttachmentsInitialized
Definition HandsPreview.c:4
override bool SelectItem()
float m_IconSize
Definition HandsPreview.c:6
void RefreshQuantity(EntityAI m_Item_to_refresh)
ref Icon m_Icon
Definition HandsPreview.c:3
override void Unfocus()
override void SetDefaultFocus(bool while_micromanagment_mode=false)
override EntityAI GetFocusedItem()
void CreateNewIcon(ItemBase item)
void RemoveItem()
ItemBase m_Item void HandsPreview(LayoutHolder parent)
void DeleteIcon()
override void SetLastFocus()
void ~HandsPreview()
Definition Icon.c:2
static ItemManager GetInstance()
const string HandsPreview
proto native CGame GetGame()
int ARGB(int a, int r, int g, int b)
Definition proto.c:322