DayZ 1.24
Loading...
Searching...
No Matches
InventoryGridController Class Reference
Collaboration diagram for InventoryGridController:
[legend]

Protected Member Functions

void InventoryQuickbar (Widget quickbarGridWidget)
 
void ~InventoryQuickbar ()
 
void UpdateItems (Widget quickbarGridWidget)
 
void Remove (InventoryItem itemToRemove)
 
override void OnItemEnter (InventoryGrid grid, Widget w, int row, int col)
 
override void OnItemLeave (InventoryGrid grid, Widget w)
 
override void OnItemDraggingOver (InventoryGrid grid, Widget w, int row, int col)
 
override void OnItemDropReceived (InventoryGrid grid, Widget w, int row, int col)
 
override void OnItemDrop (InventoryGrid grid, Widget w, int row, int col)
 
override void OnItemDrag (InventoryGrid grid, Widget w, int row, int col)
 
override int GetQuickbarItemColor (InventoryGrid grid, InventoryItem item)
 
override int HasItemQuantity (InventoryItem item)
 
override string GetItemQuantityText (InventoryItem item)
 
override float GetItemQuantity (InventoryItem item)
 
override int GetItemQuantityMax (InventoryItem item)
 
override int GetItemCount (InventoryItem item)
 
override bool CanAddItemInHandToInventory ()
 

Protected Attributes

ref TItemsMap m_Items
 
InventoryGrid m_Grid
 
int m_DraggingIndex
 

Detailed Description

Definition at line 1 of file InventoryQuickbar.c.

Constructor & Destructor Documentation

◆ ~InventoryQuickbar()

void InventoryGridController::~InventoryQuickbar ( )
inlineprotected

Definition at line 15 of file InventoryQuickbar.c.

16 {
17 }

Member Function Documentation

◆ CanAddItemInHandToInventory()

override bool InventoryGridController::CanAddItemInHandToInventory ( )
inlineprotected

Definition at line 255 of file InventoryQuickbar.c.

256 {
258 EntityAI itemInHand = player.GetHumanInventory().GetEntityInHands();
259 return itemInHand && player.GetInventory().CanAddEntityToInventory(itemInHand);
260 }
PlayerBase GetPlayer()
proto native CGame GetGame()

References GetGame(), and GetPlayer().

Referenced by ScriptedWidgetEventHandler::UpdateQuickbarItems().

◆ GetItemCount()

override int InventoryGridController::GetItemCount ( InventoryItem item)
inlineprotected

Definition at line 249 of file InventoryQuickbar.c.

250 {
251 ItemBase ib = ItemBase.Cast(item);
252 return ib.m_Count;
253 }

Referenced by ScriptedWidgetEventHandler::RefreshItemVariables().

◆ GetItemQuantity()

override float InventoryGridController::GetItemQuantity ( InventoryItem item)
inlineprotected

◆ GetItemQuantityMax()

override int InventoryGridController::GetItemQuantityMax ( InventoryItem item)
inlineprotected

Definition at line 243 of file InventoryQuickbar.c.

244 {
245 ItemBase ib = ItemBase.Cast(item);
246 return ib.m_VarQuantityMax;
247 }

Referenced by ScriptedWidgetEventHandler::RefreshItemVariables().

◆ GetItemQuantityText()

override string InventoryGridController::GetItemQuantityText ( InventoryItem item)
inlineprotected

Definition at line 233 of file InventoryQuickbar.c.

234 {
236 }
static string GetItemQuantityText(EntityAI item, bool showMax=false)

References QuantityConversions::GetItemQuantityText().

Referenced by ScriptedWidgetEventHandler::RefreshItemVariables().

◆ GetQuickbarItemColor()

override int InventoryGridController::GetQuickbarItemColor ( InventoryGrid grid,
InventoryItem item )
inlineprotected

Definition at line 207 of file InventoryQuickbar.c.

208 {
209 int color = 0x0AFFFFFF;
211 EntityAI itemInHand = player.GetHumanInventory().GetEntityInHands();
212 if (player && itemInHand == item)
213 {
214 if (player.GetHumanInventory().FindUserReservedLocationIndex(item) != -1 || grid.CanAddItemInHandToInventory())
215 color = InventoryGrid.ITEM_COLOR_QUICKBAR_H_GOOD;
216 else
217 color = InventoryGrid.ITEM_COLOR_QUICKBAR_H_BAD;
218 }
219 else if (itemInHand)
220 {
221 if (!grid.CanAddItemInHandToInventory() && !GameInventory.CanSwapEntitiesEx(item, itemInHand))
222 color = InventoryGrid.ITEM_COLOR_QUICKBAR_I_BAD;
223 }
224 return color;
225 }
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Definition Inventory.c:610

References GameInventory::CanSwapEntitiesEx(), GetGame(), and GetPlayer().

Referenced by ScriptedWidgetEventHandler::RefreshQuickbarItemVariables().

◆ HasItemQuantity()

override int InventoryGridController::HasItemQuantity ( InventoryItem item)
inlineprotected

Definition at line 228 of file InventoryQuickbar.c.

229 {
231 }
static int HasItemQuantity(notnull EntityAI item)

References QuantityConversions::HasItemQuantity().

Referenced by ScriptedWidgetEventHandler::RefreshItemVariables().

◆ InventoryQuickbar()

void InventoryGridController::InventoryQuickbar ( Widget quickbarGridWidget)
inlineprotected

Definition at line 8 of file InventoryQuickbar.c.

9 {
11 m_Items = new TItemsMap;
13 }
void UpdateItems(Widget quickbarGridWidget)
const int INDEX_NOT_FOUND
Definition gameplay.c:13

References INDEX_NOT_FOUND, and UpdateItems().

◆ OnItemDrag()

override void InventoryGridController::OnItemDrag ( InventoryGrid grid,
Widget w,
int row,
int col )
inlineprotected

Definition at line 196 of file InventoryQuickbar.c.

197 {
199 InventoryItem item = InventoryItem.Cast(player.GetQuickBarEntity(col));
200 if (item)
201 {
203 m_Grid.SetItemColor(item, InventoryGrid.ITEM_COLOR_DRAG);
204 }
205 }

References GetGame(), and GetPlayer().

Referenced by ScriptedWidgetEventHandler::OnDrag().

◆ OnItemDraggingOver()

override void InventoryGridController::OnItemDraggingOver ( InventoryGrid grid,
Widget w,
int row,
int col )
inlineprotected

Definition at line 89 of file InventoryQuickbar.c.

90 {
93 iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
94 if (!iw)
95 {
96 string name = w.GetName();
97 name.Replace("PanelWidget", "Render");
98 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
99 }
100
101 if (!iw || !iw.GetItem())
102 return;
103
104 if (!dragged_item && iw)
105 dragged_item = InventoryItem.Cast(iw.GetItem());
106
107 if (dragged_item == NULL)
108 return;
109
110 if (dragged_item && dragged_item.GetInventory().CanRemoveEntity() == false)
111 {
112 int color;
113
114 color = ARGB(150, 255, 1, 1);
115
116 if (w.FindAnyWidget("Cursor"))
117 w.FindAnyWidget("Cursor").SetColor(color);
118 else
119 {
120 name = w.GetName();
121 name.Replace("PanelWidget", "Cursor");
122 if (w.FindAnyWidget(name))
123 w.FindAnyWidget(name).SetColor(color);
124 }
125 }
126 else
127 {
128 color = ARGB(150, 1, 255, 1);
129
130 if (w.FindAnyWidget("Cursor"))
131 w.FindAnyWidget("Cursor").SetColor(color);
132 else
133 {
134 name = w.GetName();
135 name.Replace("PanelWidget", "Cursor");
136 if (w.FindAnyWidget(name))
137 w.FindAnyWidget(name).SetColor(color);
138 }
139 }
140 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
int ARGB(int a, int r, int g, int b)
Definition proto.c:322

References ARGB(), and name.

Referenced by ScriptedWidgetEventHandler::OnDraggingOver().

◆ OnItemDrop()

override void InventoryGridController::OnItemDrop ( InventoryGrid grid,
Widget w,
int row,
int col )
inlineprotected

Definition at line 180 of file InventoryQuickbar.c.

181 {
183 {
188 }
189
190 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
191 if (menu)
192 menu.RefreshQuickbar();
193 ItemManager.GetInstance().HideDropzones();
194 }
void InventoryMenu()
void Remove(InventoryItem itemToRemove)
static ItemManager GetInstance()
const int MENU_INVENTORY
Definition constants.c:170

References GetGame(), ItemManager::GetInstance(), GetPlayer(), INDEX_NOT_FOUND, InventoryMenu(), MENU_INVENTORY, and Remove().

Referenced by ScriptedWidgetEventHandler::OnDrop().

◆ OnItemDropReceived()

override void InventoryGridController::OnItemDropReceived ( InventoryGrid grid,
Widget w,
int row,
int col )
inlineprotected

Definition at line 142 of file InventoryQuickbar.c.

143 {
145
146 ItemBase dragged_item = ItemBase.Cast(ItemManager.GetInstance().GetDraggedItem());
147
148 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
149 if (!iw)
150 {
151 string name = w.GetName();
152 name.Replace("PanelWidget", "Render");
153 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
154 }
155
156 if (!dragged_item && iw)
157 dragged_item = ItemBase.Cast(iw.GetItem());
158
159 if (dragged_item && dragged_item.GetHierarchyRootPlayer() != GetGame().GetPlayer())
160 return;
161
162 ItemBase quickbar_item = ItemBase.Cast(player.GetQuickBarEntity(col));
163
165 dragged_item = ItemBase.Cast(player.GetQuickBarEntity(m_DraggingIndex));
166
167 if (dragged_item && dragged_item.GetInventory().CanRemoveEntity())
168 {
169 player.SetQuickBarEntityShortcut(dragged_item, col);
170
172 player.SetQuickBarEntityShortcut(quickbar_item, m_DraggingIndex);
173 }
175 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
176 if (menu)
177 menu.RefreshQuickbar();
178 }

References GetGame(), ItemManager::GetInstance(), GetPlayer(), INDEX_NOT_FOUND, InventoryMenu(), MENU_INVENTORY, and name.

Referenced by ScriptedWidgetEventHandler::OnDropReceived().

◆ OnItemEnter()

override void InventoryGridController::OnItemEnter ( InventoryGrid grid,
Widget w,
int row,
int col )
inlineprotected

Definition at line 71 of file InventoryQuickbar.c.

72 {
73 Widget quickbar = grid.GetRoot();
74 if (quickbar)
75 {
76 // quickbar.SetColor( 0xFFFFFFFF );
77 }
78 }

Referenced by ScriptedWidgetEventHandler::OnMouseEnter().

◆ OnItemLeave()

override void InventoryGridController::OnItemLeave ( InventoryGrid grid,
Widget w )
inlineprotected

Definition at line 80 of file InventoryQuickbar.c.

81 {
82 Widget quickbar = grid.GetRoot();
83 if (quickbar)
84 {
85 // quickbar.SetColor( 0x7FFFFFFF );
86 }
87 }

Referenced by ScriptedWidgetEventHandler::OnMouseLeave().

◆ Remove()

void InventoryGridController::Remove ( InventoryItem itemToRemove)
inlineprotected

Definition at line 58 of file InventoryQuickbar.c.

59 {
61
62 for (int i = 0; i < m_Grid.GetGridSize(); i++)
63 {
64 InventoryItem item = InventoryItem.Cast(player.GetQuickBarEntity(i));
65 if (item == itemToRemove)
66 player.RemoveQuickBarEntityShortcut(item);
67 }
68 }

References GetGame(), and GetPlayer().

Referenced by OnItemDrop().

◆ UpdateItems()

void InventoryGridController::UpdateItems ( Widget quickbarGridWidget)
inlineprotected

Definition at line 19 of file InventoryQuickbar.c.

20 {
22 return;
23
25 if (!player)
26 return;
27
28 int i;
29
30 // create grid and align it to center
31 if (!m_Grid)
32 {
33 quickbarGridWidget.GetScript(m_Grid);
34 m_Grid.SetController(this);
35 m_Grid.GenerateQuickBarBackgroundTiles(10);
36 }
37
38 m_Items.Clear();
40
41 if (m_Grid)
42 {
43 if (m_Grid.GetGridSize() != player.GetQuickBarSize())
44 m_Grid.SetGridSize(player.GetQuickBarSize());
45 }
46
47 for (i = 0; i < m_Grid.GetGridSize(); i++)
48 {
49 item = InventoryItem.Cast(player.GetQuickBarEntity(i));
50 if (item)
51 m_Items.Set(item, Vector(i, 1, 1));
52 }
53
54 if (m_Grid)
55 m_Grid.UpdateQuickbarItems(m_Items);
56 }
proto native vector Vector(float x, float y, float z)
Vector constructor from components.

References GetGame(), GetPlayer(), and Vector().

Referenced by InventoryQuickbar().

Member Data Documentation

◆ m_DraggingIndex

int InventoryGridController::m_DraggingIndex
protected

Definition at line 6 of file InventoryQuickbar.c.

◆ m_Grid

InventoryGrid InventoryGridController::m_Grid
protected

Definition at line 5 of file InventoryQuickbar.c.

◆ m_Items

ref TItemsMap InventoryGridController::m_Items
protected

Definition at line 4 of file InventoryQuickbar.c.


The documentation for this class was generated from the following file: