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

Protected Member Functions

void HandsContainer (LayoutHolder parent)
 
void ~HandsContainer ()
 
void ResetContainer ()
 
override Header GetHeader ()
 
override bool IsLastIndex ()
 
void SetFocusToIndex ()
 
void ScrollToActiveContainer (Container active_container)
 
override void Insert (LayoutHolder container, int pos=-1, bool immedUpdate=true)
 
override bool TransferItem ()
 
override bool SplitItem ()
 
override bool EquipItem ()
 
override void SetActive (bool active)
 
override void SetLastActive ()
 
override void Refresh ()
 
override bool IsItemActive ()
 
override bool IsItemWithQuantityActive ()
 
override bool IsEmpty ()
 
override bool TransferItemToVicinity ()
 
override bool InspectItem ()
 
override bool OnSelectButton ()
 
EntityAI GetItemPreviewItem (Widget w)
 
override void DraggingOverHeader (Widget w, int x, int y, Widget receiver)
 
void OnDropReceivedFromHeader2 (Widget w, int x, int y, Widget receiver)
 
void OnPerformCombination (int combinationFlags)
 
void ShowActionMenuCombine (EntityAI entity1, EntityAI entity2, int combinationFlags)
 
override void OnDropReceivedFromHeader (Widget w, int x, int y, Widget receiver)
 
int GetCombinationFlags (EntityAI entity1, EntityAI entity2)
 
int GetRecipeCount (bool recipe_anywhere, EntityAI entity1, EntityAI entity2)
 
void RemoveItem ()
 
void DestroyAtt ()
 
override void UnfocusGrid ()
 
override void UnfocusAll ()
 
void DestroyCargo ()
 
void DropReceived (Widget w, int x, int y, CargoContainer cargo)
 
bool DraggingOverGrid (Widget w, int x, int y, Widget reciever, CargoContainer cargo)
 
void TakeAsAttachment (Widget w, Widget receiver)
 
void ShowAtt (EntityAI entity)
 
void RefreshHands ()
 
void AttachmentAdded (EntityAI item, string slot, EntityAI parent)
 
void AttachmentRemoved (EntityAI item, string slot, EntityAI parent)
 
override void UpdateInterval ()
 
override void SetLayoutName ()
 
override void OnShow ()
 
void MouseClick2 (Widget w, int x, int y, int button)
 
void DoubleClick (Widget w, int x, int y, int button)
 
void DraggingOverHeader2 (Widget w, int x, int y, Widget receiver)
 
void ElectricityIcon ()
 
void CollapseButtonOnMouseButtonDown (Widget w)
 
void HideCargo ()
 
void ShowCargo ()
 

Protected Attributes

bool m_Hidden
 
ref HandsHeader m_CollapsibleHeader
 
ref HandsPreview m_HandsPreview
 
ref Attachments m_Atts
 
ref CargoContainer m_CargoGrid
 
ref map< EntityAI, ref CargoContainerm_AttachmentCargos
 
ref map< EntityAI, AttachmentsWrapperm_AttachmentAttachmentsContainers
 
ref map< EntityAI, ref Attachmentsm_AttachmentAttachments
 
ref array< intm_AttachmentSlotsSorted
 
int m_StaticAttCount = 0
 
int m_StaticCargoCount = 0
 
ScrollWidget m_ScrollWidget
 

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 HandsContainer.c.

Constructor & Destructor Documentation

◆ HandsContainer()

void HandsContainer::HandsContainer ( LayoutHolder parent)
inlineprotected

Definition at line 20 of file HandsContainer.c.

21 {
25
26 m_CollapsibleHeader = new HandsHeader(this, "CollapseButtonOnMouseButtonDown");
27 GetMainWidget().SetFlags(WidgetFlags.IGNOREPOINTER);
28 m_MainWidget = m_MainWidget.FindWidget("body");
29 GetMainWidget().SetFlags(WidgetFlags.IGNOREPOINTER);
30 m_Body = new array<ref LayoutHolder>;
31 m_HandsPreview = new HandsPreview(this);
32 ItemManager.GetInstance().SetHandsPreview(m_HandsPreview);
33 m_Body.Insert(m_HandsPreview);
34
35 ItemBase hands_item = ItemBase.Cast(GetGame().GetPlayer().GetHumanInventory().GetEntityInHands());
36 if (hands_item)
37 m_HandsPreview.CreateNewIcon(hands_item);
38
39 m_ScrollWidget = ScrollWidget.Cast(m_RootWidget.GetParent().GetParent());
40 RecomputeOpenedContainers();
41 }
PlayerBase GetPlayer()
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
ref map< EntityAI, ref CargoContainer > m_AttachmentCargos
ref map< EntityAI, AttachmentsWrapper > m_AttachmentAttachmentsContainers
ref map< EntityAI, ref Attachments > m_AttachmentAttachments
ref HandsHeader m_CollapsibleHeader
ScrollWidget m_ScrollWidget
ref HandsPreview m_HandsPreview
static ItemManager GetInstance()
proto native CGame GetGame()
WidgetFlags
Definition EnWidgets.c:58

References GetGame(), ItemManager::GetInstance(), GetPlayer(), m_AttachmentAttachments, m_AttachmentAttachmentsContainers, m_AttachmentCargos, m_CollapsibleHeader, m_HandsPreview, m_RootWidget, and m_ScrollWidget.

◆ ~HandsContainer()

void HandsContainer::~HandsContainer ( )
inlineprotected

Definition at line 43 of file HandsContainer.c.

44 {
45 if (m_Entity)
46 {
47 m_Entity.GetOnItemAttached().Remove(AttachmentAdded);
48 m_Entity.GetOnItemDetached().Remove(AttachmentRemoved);
49 }
50
51 m_AttachmentCargos.Clear();
54 }
EntityAI m_Entity
Definition ActionDebug.c:11
void AttachmentRemoved(EntityAI item, string slot, EntityAI parent)
void AttachmentAdded(EntityAI item, string slot, EntityAI parent)

References AttachmentAdded(), AttachmentRemoved(), m_AttachmentAttachments, m_AttachmentAttachmentsContainers, m_AttachmentCargos, and m_Entity.

Member Function Documentation

◆ AttachmentAdded()

void HandsContainer::AttachmentAdded ( EntityAI item,
string slot,
EntityAI parent )
inlineprotected

Definition at line 1144 of file HandsContainer.c.

1145 {
1147 int sort = -1;
1150
1151 if (item.GetInventory().GetAttachmentSlotsCount() > 0)
1152 {
1153 att_cont = new Attachments(this, item);
1154 sort = (m_AttachmentSlotsSorted.Find(slot_id) * 2) + SORT_ATTACHMENTS_NEXT_OFFSET;
1155 att_cont.InitAttachmentGrid(sort);
1156
1158 m_AttachmentAttachmentsContainers.Insert(item, att_cont.GetWrapper());
1159
1160 att_cont.UpdateInterval();
1161 if (m_Parent)
1162 m_Parent.Refresh();
1163 Inventory.GetInstance().UpdateConsoleToolbar();
1164 }
1165
1166 if (item.GetInventory().GetCargo())
1167 {
1168 cont = new CargoContainer(this, true);
1169 sort = (m_AttachmentSlotsSorted.Find(slot_id) * 2) + SORT_CARGO_NEXT_OFFSET; //m_AttachmentSlotsSorted.Find( slot_id ) + 50
1170 cont.GetRootWidget().SetSort(sort);
1171 cont.SetEntity(item);
1172
1173 Insert(cont, -1);
1174
1175 m_AttachmentCargos.Insert(item, cont);
1176 if (m_Parent)
1177 m_Parent.Refresh();
1178 Inventory.GetInstance().UpdateConsoleToolbar();
1179 }
1180
1181 if (att_cont)
1182 {
1183 att_cont.ShowFalseAttachmentsHeader(true);
1184 if (cont)
1185 {
1186 cont.ShowFalseCargoHeader(false);
1187 cont.UpdateSize();
1188 cont.SetAlternateFalseTextHeaderWidget(att_cont.GetFalseHeaderTextWidget());
1189 }
1190 }
1191 else if (cont)
1192 {
1193 cont.SetAlternateFalseTextHeaderWidget(null); //just to be safe..
1194 }
1195
1196 RecomputeOpenedContainers();
1197 }
void Inventory(LayoutHolder parent)
Definition Inventory.c:76
Widget m_Parent
Definition SizeToChild.c:86
void CargoContainer(LayoutHolder parent, bool is_attachment=false)
override void Insert(LayoutHolder container, int pos=-1, bool immedUpdate=true)
ref array< int > m_AttachmentSlotsSorted
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id

References Container::CargoContainer(), InventorySlots::GetSlotIdFromString(), Insert(), Inventory(), m_AttachmentAttachments, m_AttachmentAttachmentsContainers, m_AttachmentCargos, m_AttachmentSlotsSorted, and m_Parent.

Referenced by DestroyAtt(), ShowAtt(), and ~HandsContainer().

◆ AttachmentRemoved()

void HandsContainer::AttachmentRemoved ( EntityAI item,
string slot,
EntityAI parent )
inlineprotected

Definition at line 1199 of file HandsContainer.c.

1200 {
1202
1204 if (old_cont)
1205 {
1206 m_Body.RemoveItem(old_cont);
1207 m_AttachmentCargos.Remove(item);
1208 delete old_cont;
1209 if (m_Parent)
1210 m_Parent.Refresh();
1211 Inventory.GetInstance().UpdateConsoleToolbar();
1212 }
1213
1215 if (old_att_cont)
1216 {
1219 m_Body.RemoveItem(old_att_cont);
1220 delete old_att_cont;
1221 if (m_Parent)
1222 m_Parent.Refresh();
1223 Inventory.GetInstance().UpdateConsoleToolbar();
1224 }
1225 RecomputeOpenedContainers();
1226 }

References Container::CargoContainer(), InventorySlots::GetSlotIdFromString(), Inventory(), m_AttachmentAttachments, m_AttachmentAttachmentsContainers, m_AttachmentCargos, and m_Parent.

Referenced by DestroyAtt(), ShowAtt(), and ~HandsContainer().

◆ CollapseButtonOnMouseButtonDown()

void HandsContainer::CollapseButtonOnMouseButtonDown ( Widget w)
inlineprotected

Definition at line 1391 of file HandsContainer.c.

1392 {
1393 int i;
1394 if (!m_Hidden)
1395 {
1396 for (i = 0; i < m_Body.Count(); i++)
1397 m_Body.Get(i).OnHide();
1398 m_Hidden = true;
1399 }
1400 else
1401 {
1402 for (i = 0; i < m_Body.Count(); i++)
1403 m_Body.Get(i).OnShow();
1404 m_Hidden = false;
1405 }
1406
1407 w.FindAnyWidget("opened").Show(m_Hidden);
1408 w.FindAnyWidget("closed").Show(!m_Hidden);
1409
1410 m_Parent.Refresh();
1411 }

References m_Hidden, and m_Parent.

◆ DestroyAtt()

void HandsContainer::DestroyAtt ( )
inlineprotected

Definition at line 795 of file HandsContainer.c.

796 {
797 if (m_Atts)
798 {
799 m_Body.RemoveItem(m_Atts.GetWrapper());
800 delete m_Atts;
801
802 if (m_Entity)
803 {
804 m_Entity.GetOnItemAttached().Remove(AttachmentAdded);
805 m_Entity.GetOnItemDetached().Remove(AttachmentRemoved);
806 }
807 }
808
810 {
812 {
813 m_Body.RemoveItem(att);
815 delete att;
816 }
817 }
818
820 Refresh();
821 m_Parent.Refresh();
822 RecomputeOpenedContainers();
823 }
ref Attachments m_Atts
override void Refresh()

References AttachmentAdded(), AttachmentRemoved(), m_AttachmentAttachments, m_AttachmentAttachmentsContainers, m_Atts, m_Entity, m_Parent, and Refresh().

◆ DestroyCargo()

void HandsContainer::DestroyCargo ( )
inlineprotected

Definition at line 852 of file HandsContainer.c.

853 {
854 if (m_CargoGrid)
855 {
856 m_Body.RemoveItem(m_CargoGrid);
857 delete m_CargoGrid;
858 }
859
861 {
863 {
864 m_Body.RemoveItem(cargo);
865 delete cargo;
866 }
867 }
868
869 m_AttachmentCargos.Clear();
870 Refresh();
871 m_Parent.Refresh();
872 RecomputeOpenedContainers();
873 }
ref CargoContainer m_CargoGrid

References Container::CargoContainer(), m_AttachmentCargos, m_CargoGrid, m_Parent, and Refresh().

◆ DoubleClick()

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

Definition at line 1319 of file HandsContainer.c.

1320 {
1321 if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
1322 {
1323 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
1324 if (!iw)
1325 {
1326 string name = w.GetName();
1327 name.Replace("PanelWidget", "Render");
1328 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
1329 }
1330
1331 if (!iw)
1332 iw = ItemPreviewWidget.Cast(w);
1333
1334 ItemBase item = ItemBase.Cast(iw.GetItem());
1335 if (item)
1336 {
1338 EntityAI itemInHands = controlledPlayer.GetHumanInventory().GetEntityInHands();
1339
1340 if (!item.GetInventory().CanRemoveEntity())
1341 return;
1342
1343 if (controlledPlayer.GetInventory().HasEntityInInventory(item) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
1344 controlledPlayer.PredictiveTakeEntityToHands(item);
1345 else
1346 {
1347 if (controlledPlayer.GetInventory().CanAddEntityToInventory(item) && controlledPlayer.GetHumanInventory().CanRemoveEntityInHands())
1348 controlledPlayer.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, item);
1349 else
1350 {
1351 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
1352 controlledPlayer.PredictiveTakeEntityToHands(item);
1353 }
1354 }
1355
1356 HideOwnedTooltip();
1357
1358 name = w.GetName();
1359 name.Replace("PanelWidget", "Temperature");
1360 w.FindAnyWidget(name).Show(false);
1361 }
1362 }
1363 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Definition DayZGame.c:3528
FindInventoryLocationType
flags for searching locations in inventory
MouseState
Definition EnSystem.c:311

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

◆ DraggingOverGrid()

bool HandsContainer::DraggingOverGrid ( Widget w,
int x,
int y,
Widget reciever,
CargoContainer cargo )
inlineprotected

Definition at line 958 of file HandsContainer.c.

959 {
960 EntityAI item_in_hands = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
961 if (w == null)
962 return false;
964 if (!item || !item_in_hands)
965 return false;
966
967 int color;
968 int idx = 0;
969 int c_x, c_y;
970
971 if (item_in_hands.GetInventory().GetCargo())
972 {
973 c_x = item_in_hands.GetInventory().GetCargo().GetHeight();
974 c_y = item_in_hands.GetInventory().GetCargo().GetWidth();
975 }
976
977 if (c_x > x && c_y > y && item_in_hands.GetInventory().CanAddEntityInCargoEx(item, 0, x, y, item.GetInventory().GetFlipCargo()))
978 {
979 ItemManager.GetInstance().HideDropzones();
980 ItemManager.GetInstance().GetCenterDropzone().SetAlpha(1);
982 }
983 else
984 {
986 ItemManager.GetInstance().ShowSourceDropzone(item);
987 }
988
989 if (w.FindAnyWidget("Cursor"))
990 w.FindAnyWidget("Cursor").SetColor(color);
991 else
992 {
993 string name = w.GetName();
994 name.Replace("PanelWidget", "Cursor");
995 w.FindAnyWidget(name).SetColor(color);
996 }
997
998 return true;
999 }
Icon x
Icon y
static int GREEN_COLOR
static int RED_COLOR
EntityAI GetItemPreviewItem(Widget w)

References GetGame(), ItemManager::GetInstance(), GetItemPreviewItem(), ColorManager::GREEN_COLOR, name, ColorManager::RED_COLOR, x, and y.

◆ DraggingOverHeader()

override void HandsContainer::DraggingOverHeader ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 422 of file HandsContainer.c.

423 {
424 if (w == null)
425 return;
428 int slot_id = -1;
429
430 string name = w.GetName();
431 name.Replace("PanelWidget", "Render");
432
433 ItemPreviewWidget w_ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
434 if (w_ipw == null)
435 w_ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
436 if (w_ipw == null)
437 return;
438
440 receiver.GetUserData(slots_icon);
441
442 if (slots_icon)
443 {
444 receiver_item = slots_icon.GetEntity();
445 slot_id = slots_icon.GetSlotID();
446 slot_owner = slots_icon.GetSlotParent();
447 }
448
449
451 InventoryItem receiver_entity = InventoryItem.Cast(p.GetHumanInventory().GetEntityInHands());
452 InventoryItem w_entity = InventoryItem.Cast(w_ipw.GetItem());
453 if (!w_entity)
454 return;
455
456 if (receiver_entity)
457 {
458 if (receiver_item)
459 {
462 if (receiver_itemIB && itemIB && receiver_itemIB.CanBeCombined(itemIB))
463 {
464 ItemManager.GetInstance().HideDropzones();
465 if (m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
466 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
467 else
468 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
470 }
471 else
472 {
475 Weapon_Base wpn = Weapon_Base.Cast(receiver_item.GetHierarchyParent());
476
477 if (wpn && mag)
478 {
479 if (player.GetWeaponManager().CanSwapMagazine(wpn, Magazine.Cast(w_entity)))
480 {
482 if (w_entity.GetHierarchyRootPlayer() == player)
483 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
484 else
485 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
486 }
487 else
488 {
490 ItemManager.GetInstance().ShowSourceDropzone(w_entity);
491 }
492 }
493 else
494 {
496 {
497 ItemManager.GetInstance().HideDropzones();
498 if (m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
499 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
500 else
501 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
503 }
504 else if (receiver_itemIB.GetInventory().CanAddAttachment(w_entity))
505 {
506 ItemManager.GetInstance().HideDropzones();
507 if (receiver_itemIB.GetHierarchyRootPlayer() == GetGame().GetPlayer())
508 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
509 else
510 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
512 }
513 }
514 }
515 }
516 else if (slot_owner && slot_owner.GetInventory().CanAddAttachment(w_entity))
517 {
518 ItemManager.GetInstance().HideDropzones();
519 ItemManager.GetInstance().GetCenterDropzone().SetAlpha(1);
521 }
522 else if (receiver_entity.GetInventory().CanAddAttachment(w_entity))
523 {
524 ItemManager.GetInstance().HideDropzones();
525 if (receiver_entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
526 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
527 else
528 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
530 }
531 else
532 {
534 ItemManager.GetInstance().ShowSourceDropzone(w_entity);
535 }
536 }
537 else
538 {
539 /*if( m_HandsIcon )
540 {
541 ColorManager.GetInstance().SetColor( w, ColorManager.SWAP_COLOR );
542 ItemManager.GetInstance().HideDropzones();
543 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
544 }
545
546 else
547 {*/
549 ItemManager.GetInstance().ShowSourceDropzone(w_entity);
550 //}
551 }
552 }
static int COMBINE_COLOR
static int SWAP_COLOR
static ColorManager GetInstance()
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(), ColorManager::COMBINE_COLOR, GetGame(), ColorManager::GetInstance(), ItemManager::GetInstance(), GetPlayer(), ColorManager::GREEN_COLOR, m_Entity, name, ColorManager::RED_COLOR, and ColorManager::SWAP_COLOR.

Referenced by DraggingOverHeader2().

◆ DraggingOverHeader2()

void HandsContainer::DraggingOverHeader2 ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 1365 of file HandsContainer.c.

1366 {
1368 }
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)

References DraggingOverHeader(), x, and y.

◆ DropReceived()

void HandsContainer::DropReceived ( Widget w,
int x,
int y,
CargoContainer cargo )
inlineprotected

Definition at line 875 of file HandsContainer.c.

876 {
878 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
879
881 if (!item)
882 return;
883
884 int idx = 0;
885 int c_x, c_y;
886
889
890 if (cargo == m_CargoGrid)
891 {
893 target_cargo = m_Entity.GetInventory().GetCargo();
894#ifdef PLATFORM_CONSOLE
895 if (m_CargoGrid.HasItem(item))
896 return;
897#endif
898 }
899 else
900 {
901 target_entity = m_AttachmentCargos.GetKeyByValue(cargo);
902 if (target_entity)
903 {
904 target_cargo = target_entity.GetInventory().GetCargo();
905#ifdef PLATFORM_CONSOLE
906 if (cargo.HasItem(item))
907 return;
908#endif
909 }
910 else
911 return;
912 }
913
915 {
916 c_x = target_cargo.GetHeight();
917 c_y = target_cargo.GetWidth();
918 }
919 else
920 return;
921
923#ifdef PLATFORM_CONSOLE
924 x = 0;
925 y = target_cargo.GetItemCount();
926 target_entity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.CARGO, dst);
927#else
928 dst.SetCargoAuto(target_cargo, item, x, y, item.GetInventory().GetFlipCargo());
929#endif
930
932 item.GetInventory().GetCurrentInventoryLocation(src);
933 if (src.CompareLocationOnly(dst) && src.GetFlip() == dst.GetFlip())
934 return;
935
936#ifdef PLATFORM_CONSOLE
937 if (dst.IsValid() && target_entity.GetInventory().LocationCanAddEntity(dst))
938#else
939 if (c_x > x && c_y > y && target_entity.GetInventory().LocationCanAddEntity(dst))
940#endif
941 {
943
944 Icon icon = cargo.GetIcon(item);
945
946 if (icon)
947 {
948 if (w && w.FindAnyWidget("Cursor"))
949 w.FindAnyWidget("Cursor").SetColor(ColorManager.BASE_COLOR);
950 icon.Refresh();
951 Refresh();
952 }
953 }
954 ItemManager.GetInstance().HideDropzones();
955 ItemManager.GetInstance().SetIsDragging(false);
956 }
represents base for cargo storage for entities
Definition Cargo.c:7
static int BASE_COLOR
Definition Icon.c:2
InventoryLocation.
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)

References ColorManager::BASE_COLOR, GetGame(), ItemManager::GetInstance(), GetItemPreviewItem(), GetPlayer(), m_AttachmentCargos, m_CargoGrid, m_Entity, Refresh(), SplitItemUtils::TakeOrSplitToInventoryLocation(), x, and y.

◆ ElectricityIcon()

void HandsContainer::ElectricityIcon ( )
inlineprotected

Definition at line 1370 of file HandsContainer.c.

1371 {
1372 EntityAI item_in_hands = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
1373 if (item_in_hands && item_in_hands.GetCompEM())
1374 {
1375 if (GetRootWidget().FindAnyWidget("electricity"))
1376 {
1377 bool show_electricity_icon = item_in_hands.GetCompEM().HasElectricityIcon();
1378 GetRootWidget().FindAnyWidget("electricity").Show(show_electricity_icon);
1379 }
1380
1381 if (GetRootWidget().FindAnyWidget("electricity_can_work"))
1382 {
1383 bool show_electricity_can_work_icon = item_in_hands.GetCompEM().CanWork() && !item_in_hands.IsRuined();
1384 GetRootWidget().FindAnyWidget("electricity_can_work").Show(show_electricity_can_work_icon);
1385 }
1386 }
1387 else
1388 GetRootWidget().FindAnyWidget("electricity").Show(false);
1389 }
proto native Widget FindAnyWidget(string pathname)

References FindAnyWidget(), and GetGame().

Referenced by UpdateInterval().

◆ EquipItem()

override bool HandsContainer::EquipItem ( )
inlineprotected

Definition at line 227 of file HandsContainer.c.

228 {
229 if (CanEquip())
230 {
231 if (m_ActiveIndex == 0)
232 {
233 ItemBase item_in_hands = ItemBase.Cast(GetGame().GetPlayer().GetHumanInventory().GetEntityInHands());
234 if (item_in_hands)
235 {
236 if (GetGame().GetPlayer().GetHumanInventory().CanRemoveEntityInHands() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(item_in_hands, null))
237 {
238 if (GetGame().GetPlayer().PredictiveTakeEntityToInventory(FindInventoryLocationType.ATTACHMENT, item_in_hands))
239 {
240 m_MainWidget.FindAnyWidget("Cursor").Show(false);
241 m_MainWidget.FindAnyWidget("hands_preview_root").SetAlpha(0.7);
242 return true;
243 }
244 }
245 }
246 }
247 else if (GetFocusedContainer())
248 return GetFocusedContainer().EquipItem();
249 }
250 return false;
251 }

References GetGame(), and GetPlayer().

◆ GetCombinationFlags()

int HandsContainer::GetCombinationFlags ( EntityAI entity1,
EntityAI entity2 )
inlineprotected

Definition at line 707 of file HandsContainer.c.

708 {
709 int flags = 0;
711 EntityAI entity_in_hands = m_player.GetHumanInventory().GetEntityInHands();
712
713 if (!entity1 || !entity2) return flags;
714
717 bool skipSwap = false;
718
720 {
722
723 if (Class.CastTo(parentWpn, swapmag1.GetHierarchyParent()))
724 {
725 skipSwap = true;
727 flags = flags | InventoryCombinationFlags.SWAP;
728 }
729
730 if (Class.CastTo(parentWpn, swapmag2.GetHierarchyParent()))
731 {
732 skipSwap = true;
734 flags = flags | InventoryCombinationFlags.SWAP;
735
736 }
737 }
738
739 if (!skipSwap)
740 {
741 if (entity1 == m_player.GetHumanInventory().GetEntityInHands()) flags = flags | InventoryCombinationFlags.TAKE_TO_HANDS;
743 {
744 if (!entity1.IsInherited(ZombieBase) && !entity1.IsInherited(Car))
745 flags = flags | InventoryCombinationFlags.SWAP;
746 }
747 }
748
749 if (entity1.IsInherited(ItemBase) && entity2.IsInherited(ItemBase))
750 {
752 if (ent1.CanBeCombined(ItemBase.Cast(entity2))) flags = flags | InventoryCombinationFlags.COMBINE_QUANTITY2;
753 }
754
755 else if (entity1.GetInventory().CanAddAttachment(entity2))
756 {
757 if (!entity1.IsInherited(ZombieBase) && !entity1.IsInherited(Car) && !entity2.IsInherited(ZombieBase) && !entity2.IsInherited(Car))
759 }
760 if (!entity1.GetInventory().HasEntityInInventory(entity2) && entity1.GetInventory().CanAddEntityInCargo(entity2, entity2.GetInventory().GetFlipCargo())) flags = flags | InventoryCombinationFlags.ADD_AS_CARGO;
761
762 if (entity1 == m_player.GetHumanInventory().GetEntityInHands() || entity2 == m_player.GetHumanInventory().GetEntityInHands())
763 {
765 Class.CastTo(amc, m_player.GetActionManager());
766 if (entity1 == m_player.GetHumanInventory().GetEntityInHands())
767 {
768 if (amc.CanSetActionFromInventory(ItemBase.Cast(entity1), ItemBase.Cast(entity2)))
770 }
771 else
772 {
773 if (amc.CanSetActionFromInventory(ItemBase.Cast(entity2), ItemBase.Cast(entity1)))
775 }
776 }
777
778 if (GetRecipeCount(true, entity1, entity2) > 0)
780 return flags;
781 }
DayZPlayer m_player
Super root of all classes in Enforce script.
Definition EnScript.c:11
WeaponManager GetWeaponManager()
int GetRecipeCount(bool recipe_anywhere, EntityAI entity1, EntityAI entity2)
bool CanSwapMagazine(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References InventoryCombinationFlags::ADD_AS_ATTACHMENT, InventoryCombinationFlags::ADD_AS_CARGO, GameInventory::CanSwapEntitiesEx(), WeaponManager::CanSwapMagazine(), Class::CastTo(), InventoryCombinationFlags::COMBINE_QUANTITY2, GetGame(), GetPlayer(), GetRecipeCount(), DayZPlayer::GetWeaponManager(), m_player, InventoryCombinationFlags::RECIPE_ANYWHERE, InventoryCombinationFlags::SET_ACTION, InventoryCombinationFlags::SWAP, and InventoryCombinationFlags::TAKE_TO_HANDS.

◆ GetHeader()

override Header HandsContainer::GetHeader ( )
inlineprotected

Definition at line 62 of file HandsContainer.c.

63 {
65 }

References m_CollapsibleHeader.

Referenced by HandsPreview::CreateNewIcon().

◆ GetItemPreviewItem()

EntityAI HandsContainer::GetItemPreviewItem ( Widget w)
inlineprotected

Definition at line 403 of file HandsContainer.c.

404 {
405 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
406 if (!ipw)
407 {
408 string name = w.GetName();
409 name.Replace("PanelWidget", "Render");
410 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
411 }
412
413 if (!ipw)
414 ipw = ItemPreviewWidget.Cast(w);
415
416 if (!ipw)
417 return null;
418
419 return ipw.GetItem();
420 }

References name.

Referenced by DraggingOverGrid(), DropReceived(), and TakeAsAttachment().

◆ GetRecipeCount()

int HandsContainer::GetRecipeCount ( bool recipe_anywhere,
EntityAI entity1,
EntityAI entity2 )
inlineprotected

Definition at line 783 of file HandsContainer.c.

784 {
785 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
786 return plugin_recipes_manager.GetValidRecipes(ItemBase.Cast(entity1), ItemBase.Cast(entity2), null, PlayerBase.Cast(GetGame().GetPlayer()));
787 }
PluginBase GetPlugin(typename plugin_type)

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

Referenced by GetCombinationFlags().

◆ HideCargo()

void HandsContainer::HideCargo ( )
inlineprotected

Definition at line 1413 of file HandsContainer.c.

1414 {
1415 if (m_CargoGrid)
1416 {
1417 m_CargoGrid.OnHide();
1418 RecomputeOpenedContainers();
1419 }
1420 }

References m_CargoGrid.

Referenced by ShowAtt(), and UpdateInterval().

◆ Insert()

override void HandsContainer::Insert ( LayoutHolder container,
int pos = -1,
bool immedUpdate = true )
inlineprotected

Definition at line 180 of file HandsContainer.c.

181 {
182 super.Insert(container, pos, immedUpdate);
183 }

Referenced by AttachmentAdded(), and ShowAtt().

◆ InspectItem()

override bool HandsContainer::InspectItem ( )
inlineprotected

Definition at line 357 of file HandsContainer.c.

358 {
359 if (m_ActiveIndex == 0)
360 {
362 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
363 if (item_in_hands)
364 {
366 return true;
367 }
368 }
369 else if (GetFocusedContainer())
370 return GetFocusedContainer().InspectItem();
371 return false;
372 }
override bool InspectItem()

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

Referenced by InspectItem(), and MouseClick2().

◆ IsEmpty()

override bool HandsContainer::IsEmpty ( )
inlineprotected

Definition at line 326 of file HandsContainer.c.

327 {
329 return player.GetHumanInventory().GetEntityInHands() == null;
330 }

References GetGame(), and GetPlayer().

Referenced by IsItemActive(), and IsItemWithQuantityActive().

◆ IsItemActive()

override bool HandsContainer::IsItemActive ( )
inlineprotected

Definition at line 308 of file HandsContainer.c.

309 {
311 ItemBase item = ItemBase.Cast(player.GetHumanInventory().GetEntityInHands());
312 if (item == null)
313 return false;
315 }
override bool IsEmpty()
static int HasItemQuantity(notnull EntityAI item)

References GetGame(), GetPlayer(), QuantityConversions::HasItemQuantity(), and IsEmpty().

◆ IsItemWithQuantityActive()

override bool HandsContainer::IsItemWithQuantityActive ( )
inlineprotected

Definition at line 317 of file HandsContainer.c.

318 {
320 ItemBase item = ItemBase.Cast(player.GetHumanInventory().GetEntityInHands());
321 if (item == null)
322 return false;
323 return !IsEmpty() && QuantityConversions.HasItemQuantity(item) && item.CanBeSplit();
324 }

References GetGame(), GetPlayer(), QuantityConversions::HasItemQuantity(), and IsEmpty().

◆ IsLastIndex()

override bool HandsContainer::IsLastIndex ( )
inlineprotected

Definition at line 67 of file HandsContainer.c.

68 {
69 return m_ActiveIndex == m_OpenedContainers.Count() - 1;
70 }

◆ MouseClick2()

void HandsContainer::MouseClick2 ( Widget w,
int x,
int y,
int button )
inlineprotected

Definition at line 1269 of file HandsContainer.c.

1270 {
1271 string name = w.GetName();
1272 name.Replace("PanelWidget", "Render");
1273 ItemPreviewWidget itemPreview = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
1274
1275 if (itemPreview)
1276 {
1277 ItemBase selectedItem = ItemBase.Cast(itemPreview.GetItem());
1278
1279 if (selectedItem)
1280 {
1281 switch (button)
1282 {
1283 case MouseState.RIGHT:
1284#ifdef DIAG_DEVELOPER
1285 if (g_Game.IsLeftCtrlDown())
1286 ShowActionMenu(selectedItem);
1287#endif
1288
1289 break;
1290
1291 case MouseState.MIDDLE:
1293 break;
1294
1295 case MouseState.LEFT:
1297 if (g_Game.IsLeftCtrlDown())
1298 {
1299 if (controlledPlayer.CanDropEntity(selectedItem))
1300 {
1301 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
1302 selectedItem.SplitIntoStackMaxClient(null, -1);
1303 else
1304 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
1305 }
1306 else
1307 {
1308 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
1309 ItemManager.GetInstance().SetWidgetDraggable(w, draggable);
1310 }
1311 }
1312
1313 break;
1314 }
1315 }
1316 }
1317 }

References g_Game, GetGame(), ItemManager::GetInstance(), GetPlayer(), InspectItem(), and name.

◆ OnDropReceivedFromHeader()

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

Definition at line 702 of file HandsContainer.c.

703 {
705 }
void TakeAsAttachment(Widget w, Widget receiver)

References TakeAsAttachment().

◆ OnDropReceivedFromHeader2()

void HandsContainer::OnDropReceivedFromHeader2 ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 554 of file HandsContainer.c.

555 {
557 }

References TakeAsAttachment().

◆ OnPerformCombination()

void HandsContainer::OnPerformCombination ( int combinationFlags)
inlineprotected

Definition at line 559 of file HandsContainer.c.

560 {
562 if (m_am_entity1 == null || m_am_entity2 == null) return;
563
565
567 {
569 if (Class.CastTo(mag, m_am_entity2))
570 {
572 return;
573 }
574 }
575
577 {
578 if (m_Atts)
579 {
580 m_Body.RemoveItem(m_Atts.GetWrapper());
581 delete m_Atts;
582 }
583 if (m_am_entity2.GetSlotsCountCorrect() > 0)
584 {
585 m_Atts = new Attachments(this, m_am_entity2);
586 m_Atts.InitAttachmentGrid(1);
587
588 }
589
590 Refresh();
591 m_Parent.Refresh();
592
595 if (Class.CastTo(wpn1, m_am_entity1) && Class.CastTo(mag1, m_am_entity2))
596 {
598 {
600 return;
601 }
602 }
603
604 SplitItemUtils.TakeOrSplitToInventory(m_player, m_am_entity1, m_am_entity2);
605 //m_player.PredictiveTakeEntityToTargetAttachment( m_am_entity1, m_am_entity2 );
606 }
607
609 m_player.PredictiveTakeEntityToTargetCargo(m_am_entity1, m_am_entity2);
610
612 {
615 if (Class.CastTo(swapmag1, m_am_entity1) && Class.CastTo(swapmag2, m_am_entity2))
616 {
618 {
620 return;
621 }
622
624 {
626 return;
627 }
628 }
629 if (!m_player.PredictiveSwapEntities(m_am_entity1, m_am_entity2) && m_player.GetHumanInventory().CanAddEntityInHands(m_am_entity1))
630 m_player.PredictiveTakeEntityToHands(m_am_entity1);
631 }
632
634 {
635 if (m_Atts)
636 {
637 m_Body.RemoveItem(m_Atts.GetWrapper());
638 delete m_Atts;
639 }
640
641 if (m_am_entity2.GetSlotsCountCorrect() > 0)
642 {
643 m_Atts = new Attachments(this, m_am_entity2);
644 m_Atts.InitAttachmentGrid(1);
645
646 }
647 Refresh();
648 m_Parent.Refresh();
649
650 if (m_player.GetHumanInventory().CanAddEntityInHands(m_am_entity2))
651 m_player.PredictiveTakeEntityToHands(m_am_entity2);
652 }
653 }
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
bool CanAttachMagazine(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
bool AttachMagazine(Magazine mag, ActionBase control_action=NULL)
bool LoadBullet(Magazine mag, ActionBase control_action=NULL)
bool SwapMagazine(Magazine mag, ActionBase control_action=NULL)

References InventoryCombinationFlags::ADD_AS_ATTACHMENT, InventoryCombinationFlags::ADD_AS_CARGO, WeaponManager::AttachMagazine(), WeaponManager::CanAttachMagazine(), WeaponManager::CanSwapMagazine(), Class::CastTo(), GetGame(), GetPlayer(), DayZPlayer::GetWeaponManager(), InventoryCombinationFlags::LOAD_CHAMBER, WeaponManager::LoadBullet(), m_Atts, m_Parent, m_player, InventoryCombinationFlags::NONE, Refresh(), InventoryCombinationFlags::SWAP, WeaponManager::SwapMagazine(), InventoryCombinationFlags::TAKE_TO_HANDS, and SplitItemUtils::TakeOrSplitToInventory().

◆ OnSelectButton()

override bool HandsContainer::OnSelectButton ( )
inlineprotected

Definition at line 374 of file HandsContainer.c.

375 {
376 if (m_ActiveIndex == 0)
377 {
378 if (ItemManager.GetInstance().IsMicromanagmentMode())
379 {
380 EntityAI selectedItem = ItemManager.GetInstance().GetSelectedItem();
382 {
383 Inventory.GetInstance().DisableMicromanagement();
384 return true;
385 }
386 else
387 return Select();
388 }
389 else
390 {
391 Inventory.GetInstance().EnableMicromanagement();
392 return true;
393 }
394 }
395 else
396 {
397 if (GetFocusedContainer())
398 return GetFocusedContainer().OnSelectButton();
399 }
400 return false;
401 }
override EntityAI GetFocusedItem()
override bool Select()

References Container::GetFocusedItem(), ItemManager::GetInstance(), Inventory(), and Container::Select().

◆ OnShow()

override void HandsContainer::OnShow ( )
inlineprotected

Definition at line 1261 of file HandsContainer.c.

1262 {
1263 super.OnShow();
1264
1265 for (int i = 0; i < m_Body.Count(); i++)
1266 m_Body.Get(i).OnShow();
1267 }

◆ Refresh()

override void HandsContainer::Refresh ( )
inlineprotected

Definition at line 302 of file HandsContainer.c.

303 {
304 super.Refresh();
306 }
bool m_IsActive
void SetActive()
Definition TrapBase.c:409

References m_IsActive, and SetActive().

Referenced by DestroyAtt(), DestroyCargo(), DropReceived(), OnPerformCombination(), RefreshHands(), and ShowAtt().

◆ RefreshHands()

void HandsContainer::RefreshHands ( )
inlineprotected

Definition at line 1136 of file HandsContainer.c.

1137 {
1138 for (int i = 0; i < m_Body.Count(); i++)
1139 m_Body.Get(i).OnShow();
1140 Refresh();
1141 m_Parent.Refresh();
1142 }

References m_Parent, and Refresh().

◆ RemoveItem()

void HandsContainer::RemoveItem ( )
inlineprotected

Definition at line 789 of file HandsContainer.c.

790 {
791 m_Entity = null;
792 m_CollapsibleHeader.ShowCollapseButtons(false, true);
793 }

References m_CollapsibleHeader, and m_Entity.

◆ ResetContainer()

void HandsContainer::ResetContainer ( )
inlineprotected

Definition at line 56 of file HandsContainer.c.

57 {
58 m_Body.Clear();
59 m_Body.Insert(m_HandsPreview);
60 }

References m_HandsPreview.

Referenced by ShowAtt().

◆ ScrollToActiveContainer()

void HandsContainer::ScrollToActiveContainer ( Container active_container)
inlineprotected

Definition at line 158 of file HandsContainer.c.

159 {
160 if (!active_container)
161 return;
162 float x, y, y_s;
163 m_ScrollWidget.GetScreenPos(x, y);
164 m_ScrollWidget.GetScreenSize(x, y_s);
165 float amount;
166 float next_pos = active_container.GetFocusedContainerYScreenPos(true) + active_container.GetFocusedContainerHeight(true);
167
168 if (next_pos > (y + y_s))
169 {
170 amount = y + active_container.GetFocusedContainerYScreenPos(true);
171 m_ScrollWidget.VScrollToPos(m_ScrollWidget.GetVScrollPos() + active_container.GetFocusedContainerHeight(true) + 2);
172 }
173 else if (active_container.GetFocusedContainerYScreenPos(true) < y)
174 {
175 amount = active_container.GetFocusedContainerYScreenPos(true) - y;
176 m_ScrollWidget.VScrollToPos(m_ScrollWidget.GetVScrollPos() + amount - 2);
177 }
178 }

References m_ScrollWidget, x, and y.

Referenced by SetFocusToIndex().

◆ SetActive()

override void HandsContainer::SetActive ( bool active)
inlineprotected

Definition at line 253 of file HandsContainer.c.

254 {
255 super.SetActive(active);
257 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
258
259 if (item_in_hands)
260 {
261 if (m_MainWidget.FindAnyWidget("Cursor"))
262 m_MainWidget.FindAnyWidget("Cursor").Show(active);
263
264 if (active)
265 {
266 float x, y;
267 GetMainWidget().GetScreenPos(x, y);
268 PrepareOwnedTooltip(item_in_hands, -1, y);
269 }
270 }
271 else
272 {
273 if (active)
274 m_MainWidget.FindAnyWidget("hands_preview_root").SetAlpha(0.85);
275 else
276 m_MainWidget.FindAnyWidget("hands_preview_root").SetAlpha(0.7);
277 }
278 }

References GetGame(), GetPlayer(), x, and y.

◆ SetFocusToIndex()

void HandsContainer::SetFocusToIndex ( )
inlineprotected

Definition at line 72 of file HandsContainer.c.

73 {
74 int index = m_ActiveIndex - 1;
76 int cargo_start_index = -1;
77 int attachment_end_index = -1;
78 int cargo_end_index = -1;
79
80 if (m_Atts || m_AttachmentAttachments.Count() > 0)
81 {
83 if (m_Atts)
86 }
87
88 if (m_CargoGrid || m_AttachmentCargos.Count() > 0)
89 {
91 if (m_CargoGrid)
94 }
95
96 if (m_ActiveIndex > m_OpenedContainers.Count())
97 m_ActiveIndex = m_OpenedContainers.Count();
98
99 if (index == -1)
100 {
101#ifdef PLATFORM_CONSOLE
102 if (m_MainWidget.FindAnyWidget("Cursor"))
103 m_MainWidget.FindAnyWidget("Cursor").Show(true);
104#endif
105 m_ScrollWidget.VScrollToPos01(0);
106 }
107 else
108 {
109 if (index.InRange(0, attachment_end_index))
110 {
111 if (m_Atts)
112 {
113 if (index == 0)
114 {
115 m_Atts.SetDefaultFocus();
116 SetFocusedContainer(m_Atts.GetWrapper());
117 }
118 else
119 {
120 m_AttachmentAttachments.GetElement(index - 1).SetDefaultFocus();
121 SetFocusedContainer(m_AttachmentAttachments.GetElement(index - 1).GetWrapper());
122 }
123 }
124 else
125 {
126 m_AttachmentAttachments.GetElement(index).SetDefaultFocus();
127 SetFocusedContainer(m_AttachmentAttachments.GetElement(index).GetWrapper());
128 }
129 }
130 else if (index.InRange(cargo_start_index, cargo_end_index))
131 {
132 if (m_CargoGrid)
133 {
135 {
136 m_CargoGrid.SetDefaultFocus();
137 SetFocusedContainer(m_CargoGrid);
138 }
139 else
140 {
141 m_AttachmentCargos.GetElement(index - 1 - cargo_start_index).SetDefaultFocus();
142 SetFocusedContainer(m_AttachmentCargos.GetElement(index - 1 - cargo_start_index));
143 }
144 }
145 else
146 {
147 m_AttachmentCargos.GetElement(index - cargo_start_index).SetDefaultFocus();
148 SetFocusedContainer(m_AttachmentCargos.GetElement(index - cargo_start_index));
149 }
150 }
151
152 if (m_MainWidget.FindAnyWidget("Cursor"))
153 m_MainWidget.FindAnyWidget("Cursor").Show(false);
154 ScrollToActiveContainer(GetFocusedContainer());
155 }
156 }
void ScrollToActiveContainer(Container active_container)

References m_AttachmentAttachments, m_AttachmentCargos, m_Atts, m_CargoGrid, m_ScrollWidget, and ScrollToActiveContainer().

◆ SetLastActive()

override void HandsContainer::SetLastActive ( )
inlineprotected

Definition at line 280 of file HandsContainer.c.

281 {
282 super.SetLastActive();
284 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
285
286 if (item_in_hands)
287 {
288 if (m_ActiveIndex == 0)
289 {
290 if (m_MainWidget.FindAnyWidget("Cursor"))
291 m_MainWidget.FindAnyWidget("Cursor").Show(true);
292
293 float x, y;
294 GetMainWidget().GetScreenPos(x, y);
295 PrepareOwnedTooltip(item_in_hands, x, y);
296 }
297 }
298 else
299 m_MainWidget.FindAnyWidget("hands_preview_root").SetAlpha(0.85);
300 }

References GetGame(), GetPlayer(), x, and y.

◆ SetLayoutName()

override void HandsContainer::SetLayoutName ( )
inlineprotected

Definition at line 1256 of file HandsContainer.c.

1257 {
1258 m_LayoutName = WidgetLayoutName.ClosableContainer;
1259 }
const string ClosableContainer

References WidgetLayoutName::ClosableContainer.

◆ ShowActionMenuCombine()

void HandsContainer::ShowActionMenuCombine ( EntityAI entity1,
EntityAI entity2,
int combinationFlags )
inlineprotected

Definition at line 655 of file HandsContainer.c.

656 {
657 if (entity1 && entity2) PrintString("Showing action menu for " + entity1.GetDisplayName() + " and " + entity2.GetDisplayName());
658
659 ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
660 m_am_entity1 = entity1;
661 m_am_entity2 = entity2;
662 cmenu.Hide();
663 cmenu.Clear();
664
666 {
668 entity.CombineItemsClient(ItemBase.Cast(entity2));
669 return;
670 }
671
672 if (entity1 == null || entity2 == null) return;
673
675
677 cmenu.Add("#inv_context_add_as_attachment", this, "OnPerformCombination", new Param1<int>(InventoryCombinationFlags.ADD_AS_ATTACHMENT));
679 cmenu.Add("#inv_context_load_chamber", this, "OnPerformCombination", new Param1<int>(InventoryCombinationFlags.LOAD_CHAMBER));
680
682 cmenu.Add("#inv_context_add_as_cargo", this, "OnPerformCombination", new Param1<int>(InventoryCombinationFlags.ADD_AS_CARGO));
683
685 cmenu.Add("#inv_context_swap", this, "OnPerformCombination", new Param1<int>(InventoryCombinationFlags.SWAP));
686
688 cmenu.Add("#inv_context_take_to_hands", this, "OnPerformCombination", new Param1<int>(InventoryCombinationFlags.TAKE_TO_HANDS));
689
691 cmenu.Add("#inv_context_combine", this, "OnPerformCombination", new Param1<int>(InventoryCombinationFlags.COMBINE_QUANTITY2));
692
695 m_am_pos_x -= 5;
696 m_am_pos_y -= 5;
697
699 }
override ContextMenu GetContextMenu()
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Definition EnScript.c:344
proto void GetMousePos(out int x, out int y)

References InventoryCombinationFlags::ADD_AS_ATTACHMENT, InventoryCombinationFlags::ADD_AS_CARGO, InventoryCombinationFlags::COMBINE_QUANTITY2, GetContextMenu(), GetGame(), GetMousePos(), InventoryCombinationFlags::LOAD_CHAMBER, InventoryCombinationFlags::NONE, PrintString(), InventoryCombinationFlags::SWAP, and InventoryCombinationFlags::TAKE_TO_HANDS.

◆ ShowAtt()

void HandsContainer::ShowAtt ( EntityAI entity)
inlineprotected

Definition at line 1083 of file HandsContainer.c.

1084 {
1087 m_Entity = entity;
1088 m_ActiveIndex = 0;
1089 if (entity.GetSlotsCountCorrect() > 0)
1090 {
1091 m_Atts = new Attachments(this, entity);
1092 m_Atts.InitAttachmentGrid(1);
1093 m_AttachmentSlotsSorted = m_Atts.GetSlotsSorted();
1094 m_StaticAttCount = m_Atts.GetAttachmentHeight();
1095 m_Entity.GetOnItemAttached().Insert(AttachmentAdded);
1096 m_Entity.GetOnItemDetached().Insert(AttachmentRemoved);
1097 }
1098 else
1099 m_StaticAttCount = 0;
1100
1101 if (entity.GetInventory().GetCargo())
1102 {
1103 m_CargoGrid = new CargoContainer(this, false);
1104 m_CargoGrid.SetEntity(entity);
1105 m_CargoGrid.GetRootWidget().SetSort(1);
1108 }
1109
1111 {
1112 foreach (int slot_id : m_AttachmentSlotsSorted)
1113 {
1114 EntityAI item = m_Entity.GetInventory().FindAttachment(slot_id);
1115 if (item)
1117 }
1118 }
1119
1120 if (m_CargoGrid)
1121 {
1122 bool hideCargo = m_Entity.GetInventory().IsInventoryLockedForLockType(HIDE_INV_FROM_SCRIPT) || !m_Entity.CanDisplayCargo() || m_ForcedHide;
1123 if (m_CargoGrid.IsVisible() && hideCargo)
1124 HideCargo();
1125 else if (!m_CargoGrid.IsVisible() && !hideCargo)
1126 ShowCargo();
1127 }
1128
1129 m_CollapsibleHeader.ShowCollapseButtons(false);
1130 //m_CollapsibleHeader.ShowCollapseButtons( m_Atts || m_CargoGrid, m_Atts || m_CargoGrid );
1131 RecomputeOpenedContainers();
1132 Refresh();
1133 m_Parent.Refresh();
1134 }
static proto native owned string GetSlotName(int id)
converts slot_id to string

References AttachmentAdded(), AttachmentRemoved(), Container::CargoContainer(), InventorySlots::GetSlotName(), HideCargo(), Insert(), m_AttachmentSlotsSorted, m_Atts, m_CargoGrid, m_CollapsibleHeader, m_Entity, m_Parent, m_StaticAttCount, m_StaticCargoCount, Refresh(), ResetContainer(), and ShowCargo().

◆ ShowCargo()

void HandsContainer::ShowCargo ( )
inlineprotected

Definition at line 1422 of file HandsContainer.c.

1423 {
1424 if (m_CargoGrid)
1425 {
1426 m_CargoGrid.OnShow();
1427 RecomputeOpenedContainers();
1428 }
1429 }

References m_CargoGrid.

Referenced by ShowAtt(), and UpdateInterval().

◆ SplitItem()

override bool HandsContainer::SplitItem ( )
inlineprotected

Definition at line 208 of file HandsContainer.c.

209 {
210 if (CanSplit())
211 {
212 if (m_ActiveIndex == 0)
213 {
214 ItemBase item_in_hands = ItemBase.Cast(GetGame().GetPlayer().GetHumanInventory().GetEntityInHands());
215 if (item_in_hands)
216 {
217 if (item_in_hands.CanBeSplit())
218 item_in_hands.OnRightClick();
219 }
220 }
221 else if (GetFocusedContainer())
222 return GetFocusedContainer().SplitItem();
223 }
224 return false;
225 }

References GetGame(), and GetPlayer().

◆ TakeAsAttachment()

void HandsContainer::TakeAsAttachment ( Widget w,
Widget receiver )
inlineprotected

Definition at line 1001 of file HandsContainer.c.

1002 {
1005 int slot_id = -1;
1006
1008 receiver.GetUserData(slots_icon);
1009 if (slots_icon)
1010 {
1011 receiver_item = slots_icon.GetEntity();
1012 slot_id = slots_icon.GetSlotID();
1013 slot_owner = slots_icon.GetSlotParent();
1014 }
1015
1017 if (!item)
1018 return;
1019
1021 float stack_max = item_base.GetTargetQuantityMax(slot_id);
1022
1024 if (!item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory())
1025 return;
1026
1029 Magazine mag;
1031 {
1032 if (player.GetWeaponManager().CanAttachMagazine(wpn, mag))
1033 player.GetWeaponManager().AttachMagazine(mag);
1034 else if (player.GetWeaponManager().CanSwapMagazine(wpn, mag))
1035 player.GetWeaponManager().SwapMagazine(mag);
1036 }
1037 else if (receiver_item)
1038 {
1039 if (receiver_item != item)
1040 {
1041 if ((ItemBase.Cast(receiver_item)).CanBeCombined(ItemBase.Cast(item)))
1044 {
1045 if (!receiver_item.GetInventory().CanRemoveEntity())
1046 return;
1047 GetGame().GetPlayer().PredictiveSwapEntities(item, receiver_item);
1048 }
1049 }
1050 }
1051 else if (slot_owner && slot_owner.GetInventory().CanAddAttachmentEx(item, slot_id))
1052 {
1053 if (stack_max == 0 || stack_max >= item_base.GetQuantity())
1054 player.PredictiveTakeEntityToTargetAttachmentEx(slot_owner, item, slot_id);
1055 else if (stack_max != 0 && stack_max < item_base.GetQuantity())
1056 item_base.SplitIntoStackMaxClient(m_Entity, slot_id);
1057 }
1058 else if (slot_owner && slot_owner.GetInventory().CanAddAttachment(item))
1059 {
1060 if (stack_max == 0 || stack_max >= item_base.GetQuantity())
1061 player.PredictiveTakeEntityToTargetAttachment(slot_owner, item);
1062 else if (stack_max != 0 && stack_max < item_base.GetQuantity())
1063 item_base.SplitIntoStackMaxClient(m_Entity, -1);
1064 }
1065 else if (m_Entity.GetInventory().CanAddAttachment(item))
1066 {
1067 if (stack_max == 0 || stack_max >= item_base.GetQuantity())
1068 player.PredictiveTakeEntityToTargetAttachment(m_Entity, item);
1069 else if (stack_max != 0 && stack_max < item_base.GetQuantity())
1070 item_base.SplitIntoStackMaxClient(m_Entity, -1);
1071 }
1072 else if ((m_Entity.GetInventory().CanAddEntityInCargo(item, item.GetInventory().GetFlipCargo()) && (!player.GetInventory().HasEntityInInventory(item) || !m_Entity.GetInventory().HasEntityInCargo(item))) || player.GetHumanInventory().HasEntityInHands(item))
1074 /*else if( !player.GetInventory().HasEntityInInventory( item ) || !m_Entity.GetInventory().HasEntityInCargo( item ) )
1075 {
1076 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( GetGame().GetPlayer() ), m_Entity, item );
1077 }*/
1078
1079 ItemManager.GetInstance().HideDropzones();
1080 ItemManager.GetInstance().SetIsDragging(false);
1081 }
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Definition ItemBase.c:5528

References GameInventory::CanSwapEntitiesEx(), Class::CastTo(), CombineItemsClient(), GetGame(), ItemManager::GetInstance(), GetItemPreviewItem(), GetPlayer(), m_Entity, and SplitItemUtils::TakeOrSplitToInventory().

Referenced by OnDropReceivedFromHeader(), and OnDropReceivedFromHeader2().

◆ TransferItem()

override bool HandsContainer::TransferItem ( )
inlineprotected

Definition at line 185 of file HandsContainer.c.

186 {
187 if (m_ActiveIndex == 0)
188 {
189 if (CanTakeToInventory())
190 {
191 EntityAI item_in_hands = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
192 if (item_in_hands && GetGame().GetPlayer().GetHumanInventory().CanRemoveEntityInHands() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(item_in_hands, null))
193 {
194 if (GetGame().GetPlayer().PredictiveTakeEntityToInventory(FindInventoryLocationType.CARGO, item_in_hands))
195 {
196 m_MainWidget.FindAnyWidget("Cursor").Show(false);
197 m_MainWidget.FindAnyWidget("hands_preview_root").SetAlpha(0.7);
198 return true;
199 }
200 }
201 }
202 }
203 else if (GetFocusedContainer())
204 return GetFocusedContainer().TransferItem();
205 return false;
206 }

References GetGame(), and GetPlayer().

◆ TransferItemToVicinity()

override bool HandsContainer::TransferItemToVicinity ( )
inlineprotected

Definition at line 332 of file HandsContainer.c.

333 {
334 if (CanDrop())
335 {
336 if (m_ActiveIndex == 0)
337 {
339 ItemBase item_in_hands = ItemBase.Cast(player.GetHumanInventory().GetEntityInHands());
340 if (item_in_hands && player.CanDropEntity(item_in_hands) && GetGame().GetPlayer().GetHumanInventory().CanRemoveEntityInHands() && !player.GetInventory().HasInventoryReservation(item_in_hands, null))
341 {
342 if (item_in_hands.GetTargetQuantityMax() < item_in_hands.GetQuantity())
343 item_in_hands.SplitIntoStackMaxClient(null, -1);
344 else
345 player.PhysicalPredictiveDropItem(item_in_hands);
346 m_MainWidget.FindAnyWidget("Cursor").Show(false);
347 m_MainWidget.FindAnyWidget("hands_preview_root").SetAlpha(0.7);
348 return true;
349 }
350 }
351 else if (GetFocusedContainer())
352 return GetFocusedContainer().TransferItemToVicinity();
353 }
354 return false;
355 }

References GetGame(), and GetPlayer().

◆ UnfocusAll()

override void HandsContainer::UnfocusAll ( )
inlineprotected

Definition at line 847 of file HandsContainer.c.

848 {
849 UnfocusGrid();
850 }
override void UnfocusGrid()

References UnfocusGrid().

◆ UnfocusGrid()

override void HandsContainer::UnfocusGrid ( )
inlineprotected

Definition at line 825 of file HandsContainer.c.

826 {
827 if (m_Atts)
828 m_Atts.UnfocusAll();
829
830 if (m_CargoGrid)
831 m_CargoGrid.UnfocusAll();
832
834 {
837
838 }
839
841 {
843 att.UnfocusAll();
844 }
845 }
override void UnfocusAll()

References Container::CargoContainer(), m_AttachmentAttachments, m_AttachmentCargos, m_Atts, and m_CargoGrid.

Referenced by UnfocusAll().

◆ UpdateInterval()

override void HandsContainer::UpdateInterval ( )
inlineprotected

Definition at line 1228 of file HandsContainer.c.

1229 {
1230 super.UpdateInterval();
1231
1232 if (m_Entity)
1233 {
1234 if (m_CargoGrid)
1235 {
1236 bool hideCargo = m_Entity.GetInventory().IsInventoryLockedForLockType(HIDE_INV_FROM_SCRIPT) || !m_Entity.CanDisplayCargo() || m_ForcedHide;
1237 if (m_CargoGrid.IsVisible() && hideCargo)
1238 HideCargo();
1239 else if (!m_CargoGrid.IsVisible() && !hideCargo)
1240 ShowCargo();
1241
1242 m_CargoGrid.UpdateInterval();
1243 }
1244
1245 if (m_Atts)
1246 m_Atts.UpdateInterval();
1247
1248 for (int i = 0; i < m_AttachmentCargos.Count(); i++)
1249 m_AttachmentCargos.GetElement(i).UpdateInterval();
1250 }
1251
1253 m_CollapsibleHeader.UpdateInterval();
1254 }

References ElectricityIcon(), HideCargo(), m_AttachmentCargos, m_Atts, m_CargoGrid, m_CollapsibleHeader, m_Entity, and ShowCargo().

Member Data Documentation

◆ m_AttachmentAttachments

ref map<EntityAI, ref Attachments> HandsContainer::m_AttachmentAttachments
protected

◆ m_AttachmentAttachmentsContainers

ref map<EntityAI, AttachmentsWrapper> HandsContainer::m_AttachmentAttachmentsContainers
protected

◆ m_AttachmentCargos

◆ m_AttachmentSlotsSorted

ref array<int> HandsContainer::m_AttachmentSlotsSorted
protected

Definition at line 13 of file HandsContainer.c.

Referenced by AttachmentAdded(), and ShowAtt().

◆ m_Atts

ref Attachments HandsContainer::m_Atts
protected

◆ m_CargoGrid

ref CargoContainer HandsContainer::m_CargoGrid
protected

◆ m_CollapsibleHeader

ref HandsHeader HandsContainer::m_CollapsibleHeader
protected

Definition at line 4 of file HandsContainer.c.

Referenced by GetHeader(), HandsContainer(), RemoveItem(), ShowAtt(), and UpdateInterval().

◆ m_HandsPreview

ref HandsPreview HandsContainer::m_HandsPreview
protected

Definition at line 5 of file HandsContainer.c.

Referenced by HandsContainer(), and ResetContainer().

◆ m_Hidden

bool HandsContainer::m_Hidden
protected

Definition at line 3 of file HandsContainer.c.

Referenced by CollapseButtonOnMouseButtonDown().

◆ m_ScrollWidget

ScrollWidget HandsContainer::m_ScrollWidget
protected

Definition at line 18 of file HandsContainer.c.

Referenced by HandsContainer(), ScrollToActiveContainer(), and SetFocusToIndex().

◆ m_StaticAttCount

int HandsContainer::m_StaticAttCount = 0
protected

Definition at line 15 of file HandsContainer.c.

Referenced by ShowAtt().

◆ m_StaticCargoCount

int HandsContainer::m_StaticCargoCount = 0
protected

Definition at line 16 of file HandsContainer.c.

Referenced by ShowAtt().


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