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

Protected Member Functions

void VicinitySlotsContainer (LayoutHolder parent)
 
bool IsItemWithContainerActive ()
 
override bool IsItemWithQuantityActive ()
 
override bool IsItemActive ()
 
bool IsEmptyItemActive ()
 
override bool IsDisplayable ()
 
bool IsTakeable ()
 
override bool CanCombineAmmo ()
 
override bool EquipItem ()
 
override bool InspectItem ()
 
override bool TransferItem ()
 
override bool Combine ()
 
override bool Select ()
 
void ~VicinitySlotsContainer ()
 
override void SetLayoutName ()
 
override void OnShow ()
 
int GetRowSlotCount ()
 
bool ExcludeFromContainer (EntityAI item)
 Decides on the icon visibility.
 
void ShowItemsInContainers (array< EntityAI > items)
 
void DoubleClick (Widget w, int x, int y, int button)
 
string GetItemQuantityText (EntityAI item)
 
int HasItemQuantity (EntityAI item)
 
float GetItemQuantity (InventoryItem item)
 
void MouseButtonDown (Widget w, int x, int y, int button)
 
void MouseClick (Widget w, int x, int y, int button)
 
override void OnDropReceivedFromHeader (Widget w, int x, int y, Widget receiver)
 
void RecomputeNumberOfContainers (array< EntityAI > items)
 

Protected Attributes

ref AttachmentsGroupContainer m_Container
 
int m_ItemsCount
 
int m_SlotsCount
 
ref array< EntityAIm_ShowedItems
 

Additional Inherited Members

- Private Member Functions inherited from Container
void CargoContainer (LayoutHolder parent, bool is_attachment=false)
 
void ~CargoContainer ()
 
int GetCargoIndex ()
 
void AddedToCargoEx (EntityAI item, bool refresh=true)
 
void AddedToCargo (EntityAI item)
 
void RemovedFromCargo (EntityAI item)
 
void MovedInCargo (EntityAI item)
 
void SetLock (EntityAI item)
 
void ReleaseLock (EntityAI item)
 
override void SetLayoutName ()
 
void SetEntity (EntityAI item, int cargo_index=0, bool immedUpdate=true)
 
EntityAI GetEntity ()
 
void UpdateHeaderText ()
 
void InitGridHeight ()
 
void UpdateSize ()
 
float GetIconSize ()
 
float GetSpaceSize ()
 
int GetCargoCapacity ()
 
int GetMaxCargoCapacity ()
 
Icon GetIcon (EntityAI item)
 
Icon GetIcon (int index)
 
Icon GetFocusedIcon ()
 
override float GetFocusedContainerHeight (bool contents=false)
 
override float GetFocusedContainerYPos (bool contents=false)
 
override float GetFocusedContainerYScreenPos (bool contents=false)
 
void UpdateSelection ()
 
void UpdateRowVisibility (int count)
 
override void Refresh ()
 
void RefreshImpl ()
 
override void UpdateInterval ()
 
Icon InitIconEx (Icon icon, EntityAI item, int pos_x, int pos_y, bool refresh=true)
 
Icon InitIcon (Icon icon, EntityAI item, int pos_x, int pos_y)
 
bool HasItem (EntityAI item)
 
override bool TransferItemToVicinity ()
 
override void SetDefaultFocus (bool while_micromanagment_mode=false)
 
override void SetLastFocus ()
 
override void Unfocus ()
 
override void UnfocusAll ()
 
override void SetNextActive ()
 
override void SetPreviousActive (bool force=false)
 
override void SetNextRightActive ()
 
override void SetNextLeftActive ()
 
override EntityAI GetFocusedItem ()
 
override void SetLastActive ()
 
override void SetActive (bool active)
 
override bool IsItemActive ()
 
override bool IsItemWithQuantityActive ()
 
override bool IsEmpty ()
 
int GetRecipeCount (bool recipe_anywhere, ItemBase entity1, ItemBase entity2, PlayerBase player)
 
override bool CanCombineAmmo ()
 
override bool TransferItem ()
 
override bool SplitItem ()
 
override bool EquipItem ()
 
override bool SelectItem ()
 
override bool Select ()
 
override bool Combine ()
 
void ShowFalseCargoHeader (bool show)
 
void SetAlternateFalseTextHeaderWidget (TextWidget w)
 
void ClosableContainer (LayoutHolder parent, int sort=-1)
 
override bool IsDisplayable ()
 
override void UpdateRadialIcon ()
 
void SetOpenState (bool state)
 
override Header GetHeader ()
 
override void Open ()
 
override void Close ()
 
override void SetLayoutName ()
 
override void OnShow ()
 
override LayoutHolder Get (int x)
 
override void Refresh ()
 
void CloseButtonOnMouseButtonDown ()
 
override float GetFocusedContainerHeight (bool contents=false)
 
override float GetFocusedContainerYPos (bool contents=false)
 
override float GetFocusedContainerYScreenPos (bool contents=false)
 
void MoveContainerUp (Widget cont)
 
void MoveContainerDown (Widget cont)
 
override void CheckHeaderDragability ()
 
- Private Attributes inherited from Container
const int ROWS_NUMBER_XBOX = 5
 
CargoBase m_Cargo
 
int m_CargoIndex = -1
 
int m_FocusedItemPosition = -1
 
ref array< ref CargoContainerRowm_Rows
 
ref array< ref Iconm_Icons
 
ref map< EntityAI, ref Param3< ref Icon, int, int > > m_ShowedItemPositions
 
ref map< EntityAI, ref Param3< ref Icon, int, int > > m_ShowedLockPositions
 
float m_IconSize
 
float m_SpaceSize
 
bool m_IsAttachment
 
TextWidget m_FalseHeaderTextWidget
 
TextWidget m_AlternateFalseHeaderTextWidget
 
Widget m_CargoHeader
 
Widget m_CargoContainer
 
Widget m_ItemsContainer
 
ref SizeToChild m_Resizer1
 
ref SizeToChild m_Resizer2
 
ref Timer m_ResizeTimer
 
ref ClosableHeader m_ClosableHeader
 
bool m_LockCargo
 

Detailed Description

Definition at line 1 of file VicinitySlotsContainer.c.

Constructor & Destructor Documentation

◆ VicinitySlotsContainer()

void VicinitySlotsContainer::VicinitySlotsContainer ( LayoutHolder parent)
inlineprotected

Definition at line 8 of file VicinitySlotsContainer.c.

9 {
12 m_Container.Insert(con);
13 m_Body.Insert(m_Container);
14 for (int j = 0; j < ITEMS_IN_ROW; j++)
15 {
16 SlotsIcon icon = con.GetSlotIcon(j);
17 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetPanelWidget(), m_Parent, "OnDropReceivedFromIcon");
18 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetGhostSlot(), m_Parent, "OnDropReceivedFromHeader");
19 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetMainWidget(), m_Parent, "OnDropReceivedFromHeader");
20
21 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetPanelWidget(), m_Parent, "DraggingOverIcon");
22 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetGhostSlot(), m_Parent, "DraggingOverHeader");
23 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetMainWidget(), m_Parent, "DraggingOverHeader");
24
25 WidgetEventHandler.GetInstance().RegisterOnDoubleClick(icon.GetPanelWidget(), this, "DoubleClick");
26 WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp(icon.GetPanelWidget(), this, "MouseClick");
27 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown(icon.GetPanelWidget(), this, "MouseButtonDown");
28 }
29
30 con.SetColumnCount(0);
31 con.SetForceShow(true);
32
33 WidgetEventHandler.GetInstance().RegisterOnDropReceived(m_Container.GetMainWidget(), m_Parent, "OnDropReceivedFromHeader");
34 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(m_Container.GetMainWidget(), m_Parent, "DraggingOverHeader");
35
37 }
const int ITEMS_IN_ROW
Definition Attachments.c:1
Widget m_Parent
Definition SizeToChild.c:86
ref array< EntityAI > m_ShowedItems
ref AttachmentsGroupContainer m_Container
static WidgetEventHandler GetInstance()

References WidgetEventHandler::GetInstance(), ITEMS_IN_ROW, m_Container, m_Parent, and m_ShowedItems.

◆ ~VicinitySlotsContainer()

void VicinitySlotsContainer::~VicinitySlotsContainer ( )
inlineprotected

Definition at line 212 of file VicinitySlotsContainer.c.

213 {
214 for (int i = 0; i < m_Container.Count(); i++)
215 {
217 if (c && c.GetMainWidget())
218 delete m_Container.Get(i / ITEMS_IN_ROW).GetMainWidget();
219 }
220 }

References ITEMS_IN_ROW, and m_Container.

Member Function Documentation

◆ CanCombineAmmo()

override bool VicinitySlotsContainer::CanCombineAmmo ( )
inlineprotected

Definition at line 76 of file VicinitySlotsContainer.c.

77 {
80 ItemBase item_in_hands = ItemBase.Cast(GetGame().GetPlayer().GetHumanInventory().GetEntityInHands());
82 Class.CastTo(amc, m_player.GetActionManager());
83
84 return (amc.CanPerformActionFromInventory(item_in_hands, ent) || amc.CanSetActionFromInventory(item_in_hands, ent));
85 }
PlayerBase GetPlayer()
DayZPlayer m_player
Super root of all classes in Enforce script.
Definition EnScript.c:11
override EntityAI GetFocusedItem()
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo(), Container::GetFocusedItem(), GetGame(), GetPlayer(), and m_player.

◆ Combine()

override bool VicinitySlotsContainer::Combine ( )
inlineprotected

Definition at line 139 of file VicinitySlotsContainer.c.

140 {
142
143 ItemBase item_in_hands = ItemBase.Cast(GetGame().GetPlayer().GetHumanInventory().GetEntityInHands());
144
145 Icon hands_icon = ItemManager.GetInstance().GetHandsPreview().GetIcon();
146
147 if (item_in_hands && ent && hands_icon)
148 return hands_icon.CombineItems(item_in_hands, ent);
149 return false;
150 }
Definition Icon.c:2
static ItemManager GetInstance()

References Container::GetFocusedItem(), GetGame(), ItemManager::GetInstance(), and GetPlayer().

◆ DoubleClick()

void VicinitySlotsContainer::DoubleClick ( Widget w,
int x,
int y,
int button )
inlineprotected

Definition at line 326 of file VicinitySlotsContainer.c.

327 {
328 if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
329 {
330 if (w == null)
331 return;
332 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
333 if (!iw)
334 {
335 string name = w.GetName();
336 name.Replace("PanelWidget", "Render");
337 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
338 }
339
340 if (!iw)
341 iw = ItemPreviewWidget.Cast(w);
342
343 ItemBase item = ItemBase.Cast(iw.GetItem());
344 if (!item)
345 return;
346
347 if (!item.IsTakeable())
348 return;
349
350 if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(item, null))
351 return;
352
353 if (!item.GetInventory().CanRemoveEntity())
354 return;
355
357
358 if (player.GetInventory().HasEntityInInventory(item) && GetGame().GetPlayer().GetHumanInventory().CanAddEntityInHands(item))
359 player.PredictiveTakeEntityToHands(item);
360 else
361 {
363 player.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ANY, dst);
364 if (dst.IsValid() && player.GetInventory().LocationCanAddEntity(dst))
366 }
367
368 HideOwnedTooltip();
369 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
370 if (menu)
371 menu.RefreshQuickbar();
372 }
373 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Definition DayZGame.c:3528
FindInventoryLocationType
flags for searching locations in inventory
void InventoryMenu()
InventoryLocation.
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
const int MENU_INVENTORY
Definition constants.c:170
MouseState
Definition EnSystem.c:311

References g_Game, GetGame(), GetPlayer(), InventoryMenu(), MENU_INVENTORY, name, and SplitItemUtils::TakeOrSplitToInventoryLocation().

◆ EquipItem()

override bool VicinitySlotsContainer::EquipItem ( )
inlineprotected

Definition at line 87 of file VicinitySlotsContainer.c.

88 {
89 if (CanEquip())
90 {
92 bool res = false;
93
94 if (ent && !ent.IsInherited(Magazine))
95 {
96 res = GetGame().GetPlayer().PredictiveTakeOrSwapAttachment(ent);
97 if (!res)
98 res = GetGame().GetPlayer().GetInventory().TakeEntityToInventory(InventoryMode.JUNCTURE, FindInventoryLocationType.ATTACHMENT, ent);
99 }
100 return res;
101 }
102 return false;
103 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22

References Container::GetFocusedItem(), and GetGame().

◆ ExcludeFromContainer()

bool VicinitySlotsContainer::ExcludeFromContainer ( EntityAI item)
inlineprotected

Decides on the icon visibility.

Definition at line 238 of file VicinitySlotsContainer.c.

239 {
240 int mask = item.GetHideIconMask();
241 return mask & EInventoryIconVisibility.HIDE_VICINITY;
242 }

Referenced by ShowItemsInContainers().

◆ GetItemQuantity()

float VicinitySlotsContainer::GetItemQuantity ( InventoryItem item)
inlineprotected

Definition at line 431 of file VicinitySlotsContainer.c.

432 {
433 float quantity = 0;
434 if (item.IsInherited(InventoryItem))
435 {
437 if (item.IsInherited(Magazine))
438 {
440 quantity = magazine_item.GetAmmoCount();
441 }
442 else
443 quantity = item_base.GetQuantity();
444 }
445 return quantity;
446 }

◆ GetItemQuantityText()

string VicinitySlotsContainer::GetItemQuantityText ( EntityAI item)
inlineprotected

Definition at line 375 of file VicinitySlotsContainer.c.

376 {
377 string quantity_text = "";
378 if (item.IsInherited(InventoryItem))
379 {
381 float quantity = item_base.GetQuantity();
382 int ammo;
383 if (item.IsInherited(Magazine))
384 {
386 ammo = magazine_item.GetAmmoCount();
387 quantity_text = ammo.ToString();
388 return quantity_text;
389 }
390 else if (item.IsInherited(ItemBook))
391 return "";
392 int max = item.GetQuantityMax();
393 //string unit = item.ConfigGetString( "stackedUnit" );
394
395 if (max > 0)
396 {
397 if (max == 1)
398 {
399 float tmp = Math.Round((quantity / max) * 100);
400 quantity_text = tmp.ToString() + "%";
401 }
402 else
403 quantity_text = quantity.ToString();
404 }
405 }
406 return quantity_text;
407 }
Definition EnMath.c:7
static proto float Round(float f)
Returns mathematical round of value.

References Math::Round().

◆ GetRowSlotCount()

int VicinitySlotsContainer::GetRowSlotCount ( )
inlineprotected

Definition at line 232 of file VicinitySlotsContainer.c.

233 {
234 return GetFocusedContainer().GetColumnCount();
235 }

◆ HasItemQuantity()

int VicinitySlotsContainer::HasItemQuantity ( EntityAI item)
inlineprotected

Definition at line 409 of file VicinitySlotsContainer.c.

410 {
411 if (item.IsInherited(InventoryItem))
412 {
414 if (item.IsInherited(Magazine))
415 return QUANTITY_COUNT;
416 else if (item.IsInherited(ItemBook))
417 return QUANTITY_HIDDEN;
418 int max = item.GetQuantityMax();
419 bool bar = item.ConfigGetBool("quantityBar");
420 if (max > 0)
421 {
422 if (max == 1 || bar)
423 return QUANTITY_PROGRESS;
424 else
425 return QUANTITY_COUNT;
426 }
427 }
428 return QUANTITY_HIDDEN;
429 }
const int QUANTITY_PROGRESS
Definition constants.c:484
const int QUANTITY_COUNT
Definition constants.c:483
const int QUANTITY_HIDDEN
Definition constants.c:482

References QUANTITY_COUNT, QUANTITY_HIDDEN, and QUANTITY_PROGRESS.

◆ InspectItem()

override bool VicinitySlotsContainer::InspectItem ( )
inlineprotected

Definition at line 105 of file VicinitySlotsContainer.c.

106 {
108
109 if (ent)
110 {
112 return true;
113 }
114 return false;
115 }

References Container::GetFocusedItem(), and InspectItem().

Referenced by InspectItem(), and MouseClick().

◆ IsDisplayable()

override bool VicinitySlotsContainer::IsDisplayable ( )
inlineprotected

Definition at line 65 of file VicinitySlotsContainer.c.

66 {
67 return true;
68 }

◆ IsEmptyItemActive()

bool VicinitySlotsContainer::IsEmptyItemActive ( )
inlineprotected

Definition at line 58 of file VicinitySlotsContainer.c.

59 {
61 return ent == null;
62 }

References Container::GetFocusedItem().

◆ IsItemActive()

override bool VicinitySlotsContainer::IsItemActive ( )
inlineprotected

◆ IsItemWithContainerActive()

bool VicinitySlotsContainer::IsItemWithContainerActive ( )
inlineprotected

Definition at line 39 of file VicinitySlotsContainer.c.

40 {
42 return ent && (ent.GetInventory().GetCargo() || (ent.GetSlotsCountCorrect() > 0 && ent.CanDisplayAnyAttachmentSlot()));
43 //TODO: also check for cargo visibility maybe?
44 }

References Container::GetFocusedItem().

Referenced by IsItemActive().

◆ IsItemWithQuantityActive()

override bool VicinitySlotsContainer::IsItemWithQuantityActive ( )
inlineprotected

Definition at line 46 of file VicinitySlotsContainer.c.

47 {
49 return ent && QuantityConversions.HasItemQuantity(ent) && ent.CanBeSplit();
50 }
static int HasItemQuantity(notnull EntityAI item)

References Container::GetFocusedItem(), and QuantityConversions::HasItemQuantity().

Referenced by IsItemActive().

◆ IsTakeable()

bool VicinitySlotsContainer::IsTakeable ( )
inlineprotected

Definition at line 70 of file VicinitySlotsContainer.c.

71 {
73 return ent.IsTakeable();
74 }

References Container::GetFocusedItem().

◆ MouseButtonDown()

void VicinitySlotsContainer::MouseButtonDown ( Widget w,
int x,
int y,
int button )
inlineprotected

Definition at line 449 of file VicinitySlotsContainer.c.

450 {
451 string name = w.GetName();
452 name.Replace("PanelWidget", "Render");
454 ItemBase item = ItemBase.Cast(item_preview.GetItem());
455 bool draggable = ItemManager.GetInstance().EvaluateContainerDragabilityDefault(item);
456 ItemManager.GetInstance().SetWidgetDraggable(w, draggable);
457 }

References ItemManager::GetInstance(), and name.

◆ MouseClick()

void VicinitySlotsContainer::MouseClick ( Widget w,
int x,
int y,
int button )
inlineprotected

Definition at line 460 of file VicinitySlotsContainer.c.

461 {
462 string name = w.GetName();
463 name.Replace("PanelWidget", "Render");
465 EntityAI item = item_preview.GetItem();
468
469#ifdef DIAG_DEVELOPER
470 if (ItemBase.Cast(item))
471 {
472 if (GetDayZGame().IsLeftCtrlDown() && button == MouseState.RIGHT)
473 ShowActionMenu(ItemBase.Cast(item));
474 }
475#endif
476
477 if (m_Parent)
478 {
480
481 if (item && showed_items)
482 {
483 conta = showed_items.Get(item.GetID());
484
485 (VicinityContainer.Cast(m_Parent)).ToggleContainer(w, item);
486 if (button == MouseState.RIGHT)
487 {
488 if (itemAtPos)
489 itemAtPos.OnRightClick();
490 }
491 else if (button == MouseState.MIDDLE)
492 {
494 return;
495 }
496 }
497 }
498 }
DayZGame GetDayZGame()
Definition DayZGame.c:3530

References GetDayZGame(), InspectItem(), m_Parent, and name.

◆ OnDropReceivedFromHeader()

override void VicinitySlotsContainer::OnDropReceivedFromHeader ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 500 of file VicinitySlotsContainer.c.

501 {
502 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
503 if (!ipw)
504 {
505 string name = w.GetName();
506 name.Replace("PanelWidget", "Render");
507 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
508 }
509 if (!ipw)
510 ipw = ItemPreviewWidget.Cast(w);
511
512 if (!ipw.IsInherited(ItemPreviewWidget))
513 return;
514
516 ItemBase item = ItemBase.Cast(ipw.GetItem());
517
518 if (item)
519 {
520 if (!item.GetInventory().CanRemoveEntity())
521 return;
522
523 if (player.CanDropEntity(item))
524 {
525 if (item.GetTargetQuantityMax() < item.GetQuantity())
526 item.SplitIntoStackMaxClient(null, -1);
527 else
528 player.PhysicalPredictiveDropItem(item);
529 }
530 }
531 }

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

◆ OnShow()

override void VicinitySlotsContainer::OnShow ( )
inlineprotected

Definition at line 227 of file VicinitySlotsContainer.c.

228 {
229 super.OnShow();
230 }

◆ RecomputeNumberOfContainers()

void VicinitySlotsContainer::RecomputeNumberOfContainers ( array< EntityAI > items)
inlineprotected

Definition at line 533 of file VicinitySlotsContainer.c.

534 {
535 int number_of_containers = m_Container.m_Body.Count();
536 int number_of_containers_needed = (items.Count() / ITEMS_IN_ROW) + 1;
538 int g;
539
541 {
543 m_Container.Insert(con, -1, false);
544 for (int j = 0; j < ITEMS_IN_ROW; j++)
545 {
546 SlotsIcon icon = con.GetSlotIcon(j);
547 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetPanelWidget(), m_Parent, "OnDropReceivedFromIcon");
548 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetGhostSlot(), m_Parent, "OnDropReceivedFromHeader");
549 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetMainWidget(), m_Parent, "OnDropReceivedFromHeader");
550
551 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetPanelWidget(), m_Parent, "DraggingOverIcon");
552 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetGhostSlot(), m_Parent, "DraggingOverHeader");
553 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetMainWidget(), m_Parent, "DraggingOverHeader");
554
555 WidgetEventHandler.GetInstance().RegisterOnDoubleClick(icon.GetPanelWidget(), this, "DoubleClick");
556 WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp(icon.GetPanelWidget(), this, "MouseClick");
557 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown(icon.GetPanelWidget(), this, "MouseButtonDown");
558 }
559
560 con.SetColumnCount(items.Count() % ITEMS_IN_ROW);
561 }
562
563 for (g = number_of_containers - 1 ; g >= number_of_containers_needed ; g--)
564 {
565 Widget w = m_Container.m_Body.Get(g).GetMainWidget();
566 delete w;
567 m_Container.m_Body.Remove(g);
568 }
569
570 if ((items.Count() % ITEMS_IN_ROW) == 0)
572 else
573 SlotsContainer.Cast(m_Container.Get(number_of_containers_needed - 1)).SetColumnCount(items.Count() % ITEMS_IN_ROW);
574
575 for (int i = 0; i < number_of_containers_needed - 1; i++)
576 SlotsContainer.Cast(m_Container.Get(i)).SetColumnCount(ITEMS_IN_ROW);
577
578 RecomputeOpenedContainers();
579 m_Container.RecomputeOpenedContainers();
580 }

References WidgetEventHandler::GetInstance(), ITEMS_IN_ROW, m_Container, and m_Parent.

Referenced by ShowItemsInContainers().

◆ Select()

override bool VicinitySlotsContainer::Select ( )
inlineprotected

Definition at line 152 of file VicinitySlotsContainer.c.

153 {
154 SlotsIcon selected_slot = ItemManager.GetInstance().GetSelectedIcon();
156 ItemBase selected_item = ItemBase.Cast(ItemManager.GetInstance().GetSelectedItem());
157
158 if (!(selected_slot && selected_slot.IsOutOfReach()))
159 {
160 if (selected_item)
161 {
162 if (ent != selected_item)
163 {
164 if (selected_item && GetGame().GetPlayer().CanDropEntity(selected_item))
165 {
166 bool draggable = false;
167
169 draggable = !player.GetInventory().HasInventoryReservation(selected_item, null) && !player.IsItemsToDelete();
170 draggable = draggable && selected_item.GetInventory().CanRemoveEntity();
171
172 if (draggable && m_ShowedItems.Find(selected_item) == -1)
173 {
174 if (selected_item.GetTargetQuantityMax() < selected_item.GetQuantity())
175 selected_item.SplitIntoStackMaxClient(null, -1);
176 else
177 player.PhysicalPredictiveDropItem(selected_item);
178 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
179 return true;
180 }
181 }
182 }
183 }
184 else
185 {
186 if (ent && ent.GetInventory().CanRemoveEntity())
187 {
188 EntityAI item_in_hands = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
189 if (item_in_hands)
190 {
192 {
193 GetGame().GetPlayer().PredictiveSwapEntities(item_in_hands, ent);
194 return true;
195 }
196 }
197 else
198 {
199 if (GetGame().GetPlayer().GetHumanInventory().CanAddEntityInHands(ent))
200 {
201 GetGame().GetPlayer().PredictiveTakeEntityToHands(ent);
202 return true;
203 }
204 }
205 }
206 }
207 }
208
209 return false;
210 }
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(), Container::GetFocusedItem(), GetGame(), ItemManager::GetInstance(), GetPlayer(), and m_ShowedItems.

◆ SetLayoutName()

override void VicinitySlotsContainer::SetLayoutName ( )
inlineprotected

Definition at line 222 of file VicinitySlotsContainer.c.

223 {
224 m_LayoutName = WidgetLayoutName.Container;
225 }
const string Container

References WidgetLayoutName::Container.

◆ ShowItemsInContainers()

void VicinitySlotsContainer::ShowItemsInContainers ( array< EntityAI > items)
inlineprotected

Definition at line 244 of file VicinitySlotsContainer.c.

245 {
248 int x;
249 int visible_items_count = 0;
250 int visible_rows = 0;
252
253 for (x = 0; x < items.Count(); ++x)
254 {
255 item = items.Get(x);
256
258 continue;
259
260 visible_items.Insert(item);
262 }
263
265
266 for (x = 0; x < visible_items_count; ++x)
267 {
268 item = visible_items.Get(x);
269 int row = (int)Math.Floor(x / ITEMS_IN_ROW);
270 int column = x % ITEMS_IN_ROW;
271 icon = SlotsContainer.Cast(m_Container.Get(row)).GetSlotIcon(column);
272
273 icon.GetMainWidget().Show(true);
274 icon.GetPanelWidget().SetUserID(item.GetID());
275
276 if (m_ShowedItems.Find(item) != x)
277 icon.Init(item);
278 icon.UpdateInterval();
279
280 if (!ItemManager.GetInstance().IsDragging())
281 ItemManager.GetInstance().SetTemperature(item, icon.GetRender());
282
283 bool draggable = ItemManager.GetInstance().EvaluateContainerDragabilityDefault(item);
284 if (!draggable && GetDragWidget() == icon.GetPanelWidget())
286 ItemManager.GetInstance().SetWidgetDraggable(icon.GetPanelWidget(), draggable);
287
289
290 Container conta = Container.Cast(showed_items.Get(item.GetID()));
291 if (conta)
292 conta.SetSlotIcon(icon);
293
294 if (conta && conta.IsDisplayable())
295 conta.UpdateRadialIcon();
296 else
297 {
298 icon.GetRadialIconPanel().Show(false);
299 if (conta)
300 conta.OnHide();
301 }
302 }
303
305
307 {
308 icon = slots_last.GetSlotIcon(c);
309 icon.GetMainWidget().Show(false);
310 icon.Clear();
311 }
312
313 //#ifndef PLATFORM_CONSOLE
315 {
316 slots_last = SlotsContainer.Cast(m_Container.Get(m_Container.Count() - 1));
317 slots_last.GetSlotIcon(0).GetMainWidget().Show(true);
318 slots_last.GetSlotIcon(0).GetGhostSlot().Show(false);
319 slots_last.GetMainWidget().Update();
320 }
321 //#endif
322
324 }
Param3 int
Icon x
bool ExcludeFromContainer(EntityAI item)
Decides on the icon visibility.
void RecomputeNumberOfContainers(array< EntityAI > items)
static proto float Floor(float f)
Returns floor of value.
proto native Widget CancelWidgetDragging()
proto native Widget GetDragWidget()

References CancelWidgetDragging(), ExcludeFromContainer(), Math::Floor(), GetDragWidget(), ItemManager::GetInstance(), ITEMS_IN_ROW, m_Container, m_Parent, m_ShowedItems, RecomputeNumberOfContainers(), and x.

◆ TransferItem()

override bool VicinitySlotsContainer::TransferItem ( )
inlineprotected

Definition at line 117 of file VicinitySlotsContainer.c.

118 {
119 if (CanTakeToInventory())
120 {
122 if (ent)
123 {
124 if (ent.IsTakeable())
125 {
127 GetGame().GetPlayer().GetInventory().FindFreeLocationFor(ent, FindInventoryLocationType.CARGO, il);
128 if (il.IsValid() && GetGame().GetPlayer().GetInventory().LocationCanAddEntity(il))
129 {
131 return true;
132 }
133 }
134 }
135 }
136 return false;
137 }

References Container::GetFocusedItem(), GetGame(), GetPlayer(), and SplitItemUtils::TakeOrSplitToInventoryLocation().

Member Data Documentation

◆ m_Container

ref AttachmentsGroupContainer VicinitySlotsContainer::m_Container
protected

◆ m_ItemsCount

int VicinitySlotsContainer::m_ItemsCount
protected

Definition at line 4 of file VicinitySlotsContainer.c.

◆ m_ShowedItems

ref array<EntityAI> VicinitySlotsContainer::m_ShowedItems
protected

Definition at line 6 of file VicinitySlotsContainer.c.

Referenced by Select(), ShowItemsInContainers(), and VicinitySlotsContainer().

◆ m_SlotsCount

int VicinitySlotsContainer::m_SlotsCount
protected

Definition at line 5 of file VicinitySlotsContainer.c.


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