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

Protected Member Functions

void AttachmentCategoriesRow (LayoutHolder parent, int sort=-1)
 
string GetCategoryIdentifier ()
 
int GetFocusedSlot ()
 
override bool Select ()
 
override bool TransferItem ()
 
override bool TransferItemToVicinity ()
 
override bool Combine ()
 
override bool CanSplitEx (EntityAI focusedItem)
 
override bool SplitItem ()
 
override bool EquipItem ()
 
override bool CanCombine ()
 
override bool CanCombineAmmo ()
 
override bool IsItemActive ()
 
override bool IsItemWithQuantityActive ()
 
override void OnDropReceivedFromHeader (Widget w, int x, int y, Widget receiver)
 
override void UnfocusAll ()
 
override void DraggingOverHeader (Widget w, int x, int y, Widget receiver)
 
bool DraggingOverGrid (Widget w, int x, int y, Widget reciever, CargoContainer cargo)
 
void DropReceived (Widget w, int x, int y, CargoContainer cargo)
 
EntityAI GetItemPreviewItem (Widget w)
 
override void Refresh ()
 
void RefreshAllSlots ()
 
void RefreshSlot (int row, int column, int slot_id, string slot_name)
 
void DoubleClick (Widget w, int x, int y, int button)
 
void MouseClick (Widget w, int x, int y, int button)
 
void Init (int attachments_categories_count, int i, string attachment_category, string config_path_attachment_categories, EntityAI entity, int parent_m_Body_count)
 
override void UpdateInterval ()
 

Protected Attributes

string m_CategoryIdentifier
 
string m_RowConfigPath
 
bool m_Refreshing
 
ref AttachmentsGroupContainer m_AttachmentsContainer
 
ref map< int, ref ContainerWithCargom_AttachmentCargos
 

Additional Inherited Members

- Private Member Functions inherited from ClosableContainer
void ContainerWithCargo (Container parent, int sort=-1)
 
override bool IsDisplayable ()
 
override bool IsEmpty ()
 
override bool IsItemActive ()
 
override bool CanCombine ()
 
override bool CanCombineAmmo ()
 
override bool IsItemWithQuantityActive ()
 
void LockCargo (bool value)
 
override void Open ()
 
override void Close ()
 
override bool IsOpened ()
 
override void UpdateInterval ()
 
override bool IsFirstContainerFocused ()
 
override bool IsLastContainerFocused ()
 
override void SetDefaultFocus (bool while_micromanagment_mode=false)
 
override void UnfocusAll ()
 
override bool SplitItem ()
 
override bool EquipItem ()
 
override bool TransferItem ()
 
override bool TransferItemToVicinity ()
 
override bool InspectItem ()
 
void SetEntity (EntityAI entity, int cargo_index=0, bool immedUpdate=true)
 
EntityAI GetEntity ()
 
override EntityAI GetFocusedContainerEntity ()
 
EntityAI GetItemPreviewItem (Widget w)
 
bool DraggingOverGrid (Widget w, int x, int y, Widget reciever)
 
void DropReceived (Widget w, int x, int y)
 
void TakeIntoHands (notnull PlayerBase player, notnull EntityAI item)
 
override void DraggingOverHeader (Widget w, int x, int y, Widget receiver)
 
override void DraggingOver (Widget w, int x, int y, Widget receiver)
 
override void OnDropReceivedFromHeader (Widget w, int x, int y, Widget receiver)
 
void ContainerWithCargoAndAttachments (LayoutHolder parent, int sort=-1)
 
void ~ContainerWithCargoAndAttachments ()
 
void RecomputeContainers ()
 
void AttachmentAddedEx (EntityAI item, string slot, EntityAI parent, bool immedUpdate=true)
 
void AttachmentAdded (EntityAI item, string slot, EntityAI parent)
 
void AttachmentRemoved (EntityAI item, string slot, EntityAI parent)
 
override void UpdateInterval ()
 
override EntityAI GetFocusedContainerEntity ()
 
override void UnfocusAll ()
 
override bool IsLastIndex ()
 
override bool IsFirstContainerFocused ()
 
override bool IsLastContainerFocused ()
 
override void MoveGridCursor (int direction)
 
void SetEntity (EntityAI entity, bool immedUpdate=true)
 
void HideCargo ()
 
void ShowCargo ()
 
EntityAI GetEntity ()
 
ItemPreviewWidget GetItemPreviewWidgetDragOrDrop (Widget w)
 
EntityAI GetItemPreviewItem (Widget w)
 
Widget GetItemPreviewWidget (Widget w)
 
void MouseClick2 (Widget w, int x, int y, int button)
 
void DropReceived (Widget w, int x, int y, CargoContainer cargo)
 NOTE Used for mouse only.
 
void TakeAsAttachment (Widget w, Widget receiver)
 
override void OnDropReceivedFromHeader (Widget w, int x, int y, Widget receiver)
 
void OnDropReceivedFromHeader2 (Widget w, int x, int y, Widget receiver)
 
void DoubleClick (Widget w, int x, int y, int button)
 
bool DraggingOverGrid (Widget w, int x, int y, Widget reciever, CargoContainer cargo)
 
override void DraggingOver (Widget w, int x, int y, Widget receiver)
 
override void DraggingOverHeader (Widget w, int x, int y, Widget receiver)
 
- Private Attributes inherited from ClosableContainer
ref CargoContainer m_CargoGrid
 
int m_CargoIndex = -1
 
ref Attachments m_Atts
 
ref map< EntityAI, ref CargoContainer > m_AttachmentCargos
 
ref map< EntityAI, ref AttachmentsWrapperm_AttachmentAttachmentsContainers
 
ref map< EntityAI, ref Attachmentsm_AttachmentAttachments
 
ref array< intm_AttachmentSlotsSorted
 

Detailed Description

Definition at line 1 of file AttachmentCategoriesRow.c.

Constructor & Destructor Documentation

◆ AttachmentCategoriesRow()

void AttachmentCategoriesRow::AttachmentCategoriesRow ( LayoutHolder parent,
int sort = -1 )
inlineprotected

Definition at line 10 of file AttachmentCategoriesRow.c.

11 {
12 m_Refreshing = false;
15
16 m_Body.Insert(m_AttachmentsContainer);
17
18 m_ClosableHeader.GetMainWidget().ClearFlags(WidgetFlags.DRAGGABLE);
19
20 RecomputeOpenedContainers();
21 }
ref AttachmentsGroupContainer m_AttachmentsContainer
ref map< int, ref ContainerWithCargo > m_AttachmentCargos
WidgetFlags
Definition EnWidgets.c:58

References m_AttachmentCargos, m_AttachmentsContainer, and m_Refreshing.

Member Function Documentation

◆ CanCombine()

override bool AttachmentCategoriesRow::CanCombine ( )
inlineprotected

Definition at line 242 of file AttachmentCategoriesRow.c.

243 {
244 Man player = GetGame().GetPlayer();
245 ItemBase prev_item = ItemBase.Cast(GetFocusedItem());
246 ItemBase selected_item = ItemBase.Cast(player.GetHumanInventory().GetEntityInHands());
247 SlotsIcon focused_icon = GetFocusedSlotsIcon();
248
249 if (selected_item)
250 {
252 int stack_max;
253 if (selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.IsOutOfReach()))
254 {
255 if (m_Entity.GetInventory().CanAddAttachmentEx(selected_item, selected_slot))
256 {
258 float quantity = selected_item.GetQuantity();
259 if (stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit())
260 return true;
261 else
262 return true;
263 }
264 else if (selected_slot != -1)
265 {
266 if (prev_item)
267 {
269 prev_item.GetInventory().GetCurrentInventoryLocation(inv_loc);
271 quantity = prev_item.GetQuantity();
272 if (prev_item.CanBeCombined(ItemBase.Cast(selected_item)))
273 return true;
274 }
275 }
276 }
277 }
278 return false;
279 }
EntityAI m_Entity
Definition ActionDebug.c:11
InventoryLocation.
provides access to slot configuration
static proto native int GetStackMaxForSlotId(int slot_Id)
proto native CGame GetGame()

References GetFocusedSlot(), GetGame(), InventorySlots::GetStackMaxForSlotId(), and m_Entity.

Referenced by Combine().

◆ CanCombineAmmo()

override bool AttachmentCategoriesRow::CanCombineAmmo ( )
inlineprotected

Definition at line 281 of file AttachmentCategoriesRow.c.

282 {
283 return false;
284 }

◆ CanSplitEx()

override bool AttachmentCategoriesRow::CanSplitEx ( EntityAI focusedItem)
inlineprotected

Definition at line 227 of file AttachmentCategoriesRow.c.

228 {
229 return false;
230 }

◆ Combine()

override bool AttachmentCategoriesRow::Combine ( )
inlineprotected

Definition at line 163 of file AttachmentCategoriesRow.c.

164 {
165 if (CanCombine())
166 {
167 Man player = GetGame().GetPlayer();
168 ItemBase prev_item = ItemBase.Cast(GetFocusedItem());
169 ItemBase selected_item = ItemBase.Cast(player.GetHumanInventory().GetEntityInHands());
170 SlotsIcon focused_icon = GetFocusedSlotsIcon();
171
172 if (selected_item)
173 {
175 int stack_max;
176 if (selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.IsOutOfReach()))
177 {
178 if (!prev_item && m_Entity.GetInventory().CanAddAttachmentEx(selected_item, selected_slot))
179 {
181 float quantity = selected_item.GetQuantity();
182 if (stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit())
183 {
184 player.PredictiveTakeEntityToTargetAttachmentEx(m_Entity, selected_item, selected_slot);
185 return true;
186 }
187 else
188 {
189 selected_item.SplitIntoStackMaxClient(m_Entity, selected_slot);
190 return true;
191 }
192 }
193 else if (selected_slot != -1)
194 {
195 if (prev_item)
196 {
198 prev_item.GetInventory().GetCurrentInventoryLocation(inv_loc);
200 quantity = prev_item.GetQuantity();
201 if (prev_item.CanBeCombined(ItemBase.Cast(selected_item)))
202 {
203 prev_item.CombineItemsClient(selected_item, true);
204 return true;
205 }
207 {
208 player.PredictiveSwapEntities(selected_item, prev_item);
209 return true;
210 }
211 else if (m_AttachmentCargos.Contains(inv_loc.GetSlot()))
212 {
213 if (prev_item.GetInventory().CanAddEntityInCargo(selected_item, selected_item.GetInventory().GetFlipCargo()))
214 {
216 return true;
217 }
218 }
219 }
220 }
221 }
222 }
223 }
224 return false;
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
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)

References CanCombine(), GameInventory::CanSwapEntitiesEx(), GetFocusedSlot(), GetGame(), InventorySlots::GetStackMaxForSlotId(), m_AttachmentCargos, m_Entity, and SplitItemUtils::TakeOrSplitToInventory().

◆ DoubleClick()

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

Definition at line 704 of file AttachmentCategoriesRow.c.

705 {
706 if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
707 {
708 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
709 if (!iw)
710 {
711 string name = w.GetName();
712 name.Replace("PanelWidget", "Render");
713 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
714 }
715
716 if (!iw)
717 iw = ItemPreviewWidget.Cast(w);
718
720 w.GetUserData(icon);
721
722 if (icon && m_Entity.GetInventory().GetSlotLock(iw.GetUserID()))
723 return;
724
725 if (icon.IsOutOfReach())
726 return;
727
728 ItemBase item = ItemBase.Cast(iw.GetItem());
729 if (item)
730 {
731 if (!item.GetInventory().CanRemoveEntity())
732 return;
733
735 if (controlledPlayer.GetInventory().HasEntityInInventory(item) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
736 controlledPlayer.PredictiveTakeEntityToHands(item);
737 else
738 {
739 if (controlledPlayer.GetInventory().CanAddEntityToInventory(item) && item.GetInventory().CanRemoveEntity())
740 {
741 if (item.GetTargetQuantityMax() < item.GetQuantity())
742 item.SplitIntoStackMaxClient(controlledPlayer, -1);
743 else
744 controlledPlayer.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, item);
745 }
746 else
747 {
748 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
749 {
750 if (item.GetTargetQuantityMax() < item.GetQuantity())
751 item.SplitIntoStackMaxHandsClient(controlledPlayer);
752 else
753 controlledPlayer.PredictiveTakeEntityToHands(item);
754 }
755 }
756 }
757
758 HideOwnedTooltip();
759
760 name = w.GetName();
761 name.Replace("PanelWidget", "Temperature");
762 w.FindAnyWidget(name).Show(false);
763 }
764 }
765 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Definition DayZGame.c:3528
FindInventoryLocationType
flags for searching locations in inventory
PlayerBase GetPlayer()
MouseState
Definition EnSystem.c:311

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

◆ DraggingOverGrid()

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

Definition at line 469 of file AttachmentCategoriesRow.c.

470 {
471 if (w == null)
472 return false;
473
475
476 if (!item)
477 return false;
478
479 int color;
480 int idx = 0;
481 int c_x, c_y;
482
485
486 target_entity = cargo.GetEntity() ;
487 if (target_entity)
488 target_cargo = target_entity.GetInventory().GetCargo();
489 else
490 return false;
491
493 {
494 c_x = target_cargo.GetHeight();
495 c_y = target_cargo.GetWidth();
496 }
497 else
498 return false;
499
500 if (c_x > x && c_y > y && target_entity.GetInventory().CanAddEntityInCargoEx(item, idx, x, y, item.GetInventory().GetFlipCargo()))
502 else
504
505 if (w.FindAnyWidget("Cursor"))
506 w.FindAnyWidget("Cursor").SetColor(color);
507 else
508 {
509 string name = w.GetName();
510 name.Replace("PanelWidget", "Cursor");
511 if (w.FindAnyWidget(name))
512 w.FindAnyWidget(name).SetColor(color);
513 }
514
515 return true;
516 }
Icon x
Icon y
EntityAI GetItemPreviewItem(Widget w)
represents base for cargo storage for entities
Definition Cargo.c:7
static int GREEN_COLOR
static int RED_COLOR

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

◆ DraggingOverHeader()

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

Definition at line 395 of file AttachmentCategoriesRow.c.

396 {
397 if (w == null)
398 return;
399 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
400 if (!iw)
401 {
402 string name = w.GetName();
403 name.Replace("PanelWidget", "Render");
404 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
405 }
406 if (!iw)
407 iw = ItemPreviewWidget.Cast(w);
408
409 if (!iw || !iw.GetItem() || (iw.GetItem() == m_Entity))
410 return;
411
414 name = receiver.GetName();
415 name.Replace("PanelWidget", "Render");
417 if (receiver_iw)
418 receiver_item = ItemBase.Cast(receiver_iw.GetItem());
419
421 receiver.GetUserData(slots_icon);
422
423 if (receiver_item)
424 {
425 int stack_max = InventorySlots.GetStackMaxForSlotId(receiver_item.GetInventory().GetSlotId(0));
426 //int quantity = receiver_item.GetQuantity();
427 //bool combinable = ( quantity < stack_max ) && ( ItemBase.Cast( receiver_item ).CanBeCombined( ItemBase.Cast( iw.GetItem() ) ) );
428 if (receiver_item.CanBeCombined(ItemBase.Cast(iw.GetItem())))
429 {
430 ItemManager.GetInstance().HideDropzones();
431 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
433 }
434 else if (stack_max == 0 && GameInventory.CanSwapEntitiesEx(receiver_item, iw.GetItem()))
435 {
436 ItemManager.GetInstance().HideDropzones();
437 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
439 }
440 else
441 {
442 ItemManager.GetInstance().ShowSourceDropzone(iw.GetItem());
444 }
445 }
446 else if (slots_icon && slots_icon.GetSlotID() != -1)
447 {
448 item = ItemBase.Cast(iw.GetItem());
449
450 if (item && m_Entity.GetInventory().CanAddAttachmentEx(item, slots_icon.GetSlotID()))
451 {
452 ItemManager.GetInstance().HideDropzones();
453 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
455 }
456 else
457 {
458 ItemManager.GetInstance().ShowSourceDropzone(iw.GetItem());
460 }
461 }
462 else
463 {
464 ItemManager.GetInstance().ShowSourceDropzone(iw.GetItem());
466 }
467 }
static int COMBINE_COLOR
static int SWAP_COLOR
static ColorManager GetInstance()
static ItemManager GetInstance()

References GameInventory::CanSwapEntitiesEx(), ColorManager::COMBINE_COLOR, ColorManager::GetInstance(), ItemManager::GetInstance(), InventorySlots::GetStackMaxForSlotId(), ColorManager::GREEN_COLOR, m_Entity, name, ColorManager::RED_COLOR, and ColorManager::SWAP_COLOR.

◆ DropReceived()

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

Definition at line 518 of file AttachmentCategoriesRow.c.

519 {
521 if (!item)
522 return;
523
524 int idx = 0;
525 int c_x, c_y;
526
529
530 target_entity = cargo.GetEntity();
531 if (target_entity)
532 target_cargo = target_entity.GetInventory().GetCargo();
533 else
534 return;
535
537 {
538 c_x = target_cargo.GetHeight();
539 c_y = target_cargo.GetWidth();
540 }
541 else
542 return;
543
545 dst.SetCargoAuto(target_cargo, item, x, y, item.GetInventory().GetFlipCargo());
546
547 if (c_x > x && c_y > y && target_entity.GetInventory().LocationCanAddEntity(dst))
548 {
550
552
553 Icon icon = cargo.GetIcon(item);
554
555 if (icon)
556 {
557 icon.GetCursorWidget().SetColor(ColorManager.BASE_COLOR);
558 icon.RefreshPos(x, y);
559 icon.Refresh();
560 Refresh();
561 }
562 }
563 }
static int BASE_COLOR
Definition Icon.c:2
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)

References ColorManager::BASE_COLOR, GetGame(), GetItemPreviewItem(), GetPlayer(), Refresh(), SplitItemUtils::TakeOrSplitToInventoryLocation(), x, and y.

◆ EquipItem()

override bool AttachmentCategoriesRow::EquipItem ( )
inlineprotected

Definition at line 237 of file AttachmentCategoriesRow.c.

238 {
239 return false;
240 }

◆ GetCategoryIdentifier()

string AttachmentCategoriesRow::GetCategoryIdentifier ( )
inlineprotected

Definition at line 23 of file AttachmentCategoriesRow.c.

24 {
26 }

References m_CategoryIdentifier.

◆ GetFocusedSlot()

int AttachmentCategoriesRow::GetFocusedSlot ( )
inlineprotected

Definition at line 28 of file AttachmentCategoriesRow.c.

29 {
30 SlotsIcon icon = GetFocusedSlotsIcon();
31 if (icon)
32 return icon.GetSlotID();
33 return -1;
34 }

Referenced by CanCombine(), and Combine().

◆ GetItemPreviewItem()

EntityAI AttachmentCategoriesRow::GetItemPreviewItem ( Widget w)
inlineprotected

Definition at line 565 of file AttachmentCategoriesRow.c.

566 {
567 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
568 if (!ipw)
569 {
570 string name = w.GetName();
571 name.Replace("PanelWidget", "Render");
572 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
573 }
574 if (!ipw)
575 ipw = ItemPreviewWidget.Cast(w);
576 if (!ipw || !ipw.IsInherited(ItemPreviewWidget))
577 return null;
578 return ipw.GetItem();
579 }

References name.

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

◆ Init()

void AttachmentCategoriesRow::Init ( int attachments_categories_count,
int i,
string attachment_category,
string config_path_attachment_categories,
EntityAI entity,
int parent_m_Body_count )
inlineprotected

Definition at line 823 of file AttachmentCategoriesRow.c.

824 {
827
829
831 string categoryName;
832
835 GetGame().ConfigGetTextArray(m_RowConfigPath, player_ghosts_slots2);
837 header.SetName(categoryName);
838
840 SetHeader(null);
841
842 int count = player_ghosts_slots2.Count();
843 int lastRow = count / ITEMS_IN_ROW;
845
846 for (int j = 0; j < count; j++)
847 {
848 string slotName = player_ghosts_slots2.Get(j);
849 string iconName; //must be in format "set:<setname> image:<imagename>"
850 string path = "CfgSlots" + " Slot_" + slotName;
851
853
854 GetGame().ConfigGetText(path + " ghostIcon", iconName);
855 GetGame().ConfigGetText(path + " name", slotName);
856
857 int row = j / ITEMS_IN_ROW;
858 int column = j % ITEMS_IN_ROW;
859 if (column == 0)
860 {
862 slotsContainer.GetRootWidget().SetAlpha(0.7);
863 if (row == lastRow)
864 slotsContainer.SetColumnCount(count % ITEMS_IN_ROW);
865 else
866 slotsContainer.SetColumnCount(ITEMS_IN_ROW);
867
869 slotsContainer.GetRootWidget().SetSort(row);
870 }
871
872 SlotsIcon icon = slotsContainer.GetSlotIcon(column);
873 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetMainWidget(), this, "OnDropReceivedFromHeader");
874 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetGhostSlot(), this, "OnDropReceivedFromHeader");
875 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetPanelWidget(), this, "OnDropReceivedFromHeader");
876
877 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetMainWidget(), this, "DraggingOverHeader");
878 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetGhostSlot(), this, "DraggingOverHeader");
879 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetPanelWidget(), this, "DraggingOverHeader");
880
881 WidgetEventHandler.GetInstance().RegisterOnDrop(icon.GetMainWidget(), this, "OnIconDrop");
882 WidgetEventHandler.GetInstance().RegisterOnDrop(icon.GetPanelWidget(), this, "OnIconDrop");
883
884 WidgetEventHandler.GetInstance().RegisterOnDoubleClick(icon.GetPanelWidget(), this, "DoubleClick");
885 WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp(icon.GetPanelWidget(), this, "MouseClick");
886
888 icon.SetSlotID(slotId);
889 icon.SetSlotDisplayName(InventorySlots.GetSlotDisplayName(slotId));
890
891 icon.Clear();
892 }
894 }
const int ITEMS_IN_ROW
Definition Attachments.c:1
PlayerSpawnPreset slotName
string GetHeader()
Definition Header.c:2
static proto native owned string GetSlotDisplayName(int id)
converts slot_id to string
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static const int IMAGESETGROUP_INVENTORY
static string VerifyIconImageString(int imageset_group=IMAGESETGROUP_INVENTORY, string icon_name="")
Checks for improperly formated, legacy image names and corrects them to default format.
static WidgetEventHandler GetInstance()

References GetGame(), GetHeader(), WidgetEventHandler::GetInstance(), InventorySlots::GetSlotDisplayName(), InventorySlots::GetSlotIdFromString(), StaticGUIUtils::IMAGESETGROUP_INVENTORY, ITEMS_IN_ROW, m_AttachmentsContainer, m_CategoryIdentifier, m_Entity, m_RowConfigPath, path, RefreshAllSlots(), slotName, and StaticGUIUtils::VerifyIconImageString().

◆ IsItemActive()

override bool AttachmentCategoriesRow::IsItemActive ( )
inlineprotected

Definition at line 286 of file AttachmentCategoriesRow.c.

287 {
288 SlotsIcon icon = GetFocusedSlotsIcon();
289 return GetFocusedItem() != null && (!icon || !icon.IsOutOfReach());
290 }

◆ IsItemWithQuantityActive()

override bool AttachmentCategoriesRow::IsItemWithQuantityActive ( )
inlineprotected

Definition at line 292 of file AttachmentCategoriesRow.c.

293 {
294 ItemBase item = ItemBase.Cast(GetFocusedItem());
295 SlotsIcon icon = GetFocusedSlotsIcon();
296 return item && (!icon || !icon.IsOutOfReach()) && item.CanBeSplit();
297 }

◆ MouseClick()

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

Definition at line 767 of file AttachmentCategoriesRow.c.

768 {
771 w.GetUserData(icon);
772 if (icon)
773 selectedItem = ItemBase.Cast(icon.GetEntity());
774
775 if (selectedItem)
776 {
777 switch (button)
778 {
779 case MouseState.RIGHT:
780#ifdef DIAG_DEVELOPER
781 if (g_Game.IsLeftCtrlDown())
782 ShowActionMenu(selectedItem);
783#endif
784
785 break;
786
787 case MouseState.MIDDLE:
789 break;
790
791 case MouseState.LEFT:
793 if (g_Game.IsLeftCtrlDown())
794 {
795 if (icon.IsOutOfReach())
796 return;
797
798 if (controlledPlayer.CanDropEntity(selectedItem))
799 {
800 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
801 selectedItem.SplitIntoStackMaxClient(null, -1);
802 else
803 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
804 }
805 else
806 {
807 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
808 ItemManager.GetInstance().SetWidgetDraggable(w, draggable);
809 }
810 }
811 else
812 {
813 ClosableContainer c = ClosableContainer.Cast(icon.GetContainer());
814 if (c)
815 c.Toggle();
816 }
817
818 break;
819 }
820 }
821 }
override bool InspectItem()

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

◆ OnDropReceivedFromHeader()

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

Definition at line 299 of file AttachmentCategoriesRow.c.

300 {
301 ItemManager.GetInstance().HideDropzones();
302 ItemManager.GetInstance().SetIsDragging(false);
305 int slot_id = -1;
306 bool is_reserved = false;
308 receiver.GetUserData(slots_icon);
309 float stackable = 0.0;
311
312 if (slots_icon)
313 {
314 receiver_item = slots_icon.GetEntity();
315 slot_id = slots_icon.GetSlotID();
316 attached_entity = slots_icon.GetSlotParent();
317 is_reserved = slots_icon.IsReserved();
318 }
319
321 if (!item)
322 return;
324
326 if (!item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory())
327 return;
328
333 {
334 if (player.GetWeaponManager().CanAttachMagazine(wpn, mag))
335 player.GetWeaponManager().AttachMagazine(mag);
336 }
337 else if (receiver_item && !is_reserved)
338 {
339 if ((ItemBase.Cast(receiver_item)).CanBeCombined(ItemBase.Cast(item)))
342 {
343 if (!receiver_item.GetInventory().CanRemoveEntity())
344 return;
345 GetGame().GetPlayer().PredictiveSwapEntities(receiver_item, item);
346 }
347 else if (receiver_item.GetInventory().CanAddAttachment(item))
348 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
349 }
350 else if (attached_entity && slot_id != -1 && attached_entity.GetInventory().CanAddAttachmentEx(item, slot_id))
351 {
352 item_base = ItemBase.Cast(item);
353 stackable = item_base.GetTargetQuantityMax(slot_id);
354
355 if (stackable == 0 || stackable >= item_base.GetQuantity())
356 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, slot_id);
357 else if (stackable != 0 && stackable < item_base.GetQuantity())
358 item_base.SplitIntoStackMaxClient(m_Entity, slot_id);
359 }
360 else if (attached_entity && slot_id == -1 && attached_entity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ATTACHMENT, il))
361 {
362 item_base = ItemBase.Cast(item);
363 stackable = item_base.GetTargetQuantityMax(il.GetSlot());
364
365 if (stackable == 0 || stackable >= item_base.GetQuantity())
366 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, il.GetSlot());
367 else if (stackable != 0 && stackable < item_base.GetQuantity())
368 item_base.SplitIntoStackMaxClient(m_Entity, il.GetSlot());
369 }
370 /*else if( ( m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && ( !player.GetInventory().HasEntityInInventory( item ) || !m_Entity.GetInventory().HasEntityInCargo( item )) ) )
371 {
372 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( GetGame().GetPlayer() ), m_Entity, item );
373 }*/
374 }
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Definition ItemBase.c:5528
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

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

◆ Refresh()

override void AttachmentCategoriesRow::Refresh ( )
inlineprotected

Definition at line 581 of file AttachmentCategoriesRow.c.

582 {
583 if (!m_Refreshing)
584 {
585 if (!m_Closed)
586 {
587 super.Refresh();
589 }
590 }
591 }

References m_Refreshing, and RefreshAllSlots().

Referenced by DropReceived().

◆ RefreshAllSlots()

void AttachmentCategoriesRow::RefreshAllSlots ( )
inlineprotected

Definition at line 593 of file AttachmentCategoriesRow.c.

594 {
595 m_Refreshing = true;
596 int row_count = m_AttachmentsContainer.GetRowCount();
597 int row;
598 for (row = 0; row < row_count; row++)
599 {
600 int col_count = m_AttachmentsContainer.GetColumnCountForRow(row);
601 int col;
602 for (col = 0; col < col_count; col++)
603 RefreshSlot(row, col, -1, "");
604 }
605 m_Refreshing = false;
606 }
void RefreshSlot(int row, int column, int slot_id, string slot_name)

References m_AttachmentsContainer, m_Refreshing, and RefreshSlot().

Referenced by Init(), Refresh(), and UpdateInterval().

◆ RefreshSlot()

void AttachmentCategoriesRow::RefreshSlot ( int row,
int column,
int slot_id,
string slot_name )
inlineprotected

Definition at line 609 of file AttachmentCategoriesRow.c.

610 {
612 int slot_id_ = icon.GetSlotID();
613 EntityAI item = m_Entity.GetInventory().FindAttachment(slot_id_);
615
616 if (!m_Entity.CanDisplayAttachmentSlot(slot_id_))
617 {
618 icon.Clear();
619 icon.GetMainWidget().Show(false);
620 }
621 else if (!item)
622 {
623 if (icon.GetEntity())
624 {
625 icon.ClearRemainSelected();
626
628 if (cont)
629 {
631 this.Remove(cont);
632 (Container.Cast(cont.m_Parent)).Remove(cont);
633 }
634 }
635 icon.GetMainWidget().Show(true);
636 }
637 else
638 {
639 icon.GetMainWidget().Show(true);
640 if (icon.GetEntity() != item)
641 icon.Init(item);
642 else
643 icon.Refresh();
644
646 if (cont && cont.GetEntity() != item)
647 {
649 (Container.Cast(cont.m_Parent)).Remove(cont);
650 this.Remove(cont);
651 cont = null;
652 }
653
654 if (!cont)
655 {
656 if (item.GetInventory().GetCargo() && m_AttachmentCargos)
657 {
658 cont = new ContainerWithCargo(this, true);
659 cont.GetRootWidget().SetSort(m_AttachmentCargos.Count() + 10);
660 cont.SetEntity(item);
661 cont.SetSlotIcon(icon);
662
664 icon.SetContainer(cont);
665
666 SetOpenForSlotIcon(cont.IsOpened(), icon);
667 }
668 }
669
670 if (cont)
671 icon.GetRadialIconPanel().Show(cont.IsDisplayable());
672
674 bool draggable = true;
675 bool can_be_removed = item.GetInventory().CanRemoveEntity();
676 bool in_hands_condition = m_Entity.GetHierarchyRoot() == GetGame().GetPlayer();
678 if (m_Entity.GetInventory().GetSlotLock(slot_id_) && ItemManager.GetInstance().GetDraggedItem() != item)
679 {
680 icon.GetMountedWidget().Show(true);
681 draggable = false;
682 }
683 else
684 icon.GetMountedWidget().Show(false);
685
686 if (!m_Entity.CanReleaseAttachment(item))
687 draggable = false;
688
690 icon.GetOutOfReachWidget().Show(false);
691 else
692 {
693 icon.GetOutOfReachWidget().Show(true);
694 draggable = false;
695 }
696
697 if (draggable)
698 icon.GetRender().GetParent().SetFlags(WidgetFlags.DRAGGABLE);
699 else
700 icon.GetRender().GetParent().ClearFlags(WidgetFlags.DRAGGABLE);
701 }
702 }
void Remove(Object object)
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
void ContainerWithCargo(Container parent, int sort=-1)
static proto native owned string GetSlotName(int id)
converts slot_id to string

References ClosableContainer::ContainerWithCargo(), GetGame(), ItemManager::GetInstance(), InventorySlots::GetSlotName(), AttachmentsOutOfReach::IsAttachmentReachable(), m_AttachmentCargos, m_AttachmentsContainer, m_Entity, and Remove().

Referenced by RefreshAllSlots().

◆ Select()

override bool AttachmentCategoriesRow::Select ( )
inlineprotected

Definition at line 36 of file AttachmentCategoriesRow.c.

37 {
38 Man player = GetGame().GetPlayer();
39 SlotsIcon focused_icon = GetFocusedSlotsIcon();
40 EntityAI focused_item = GetFocusedItem();
41 Container focused_cont = GetFocusedContainer();
42 ItemBase selected_item = ItemBase.Cast(ItemManager.GetInstance().GetSelectedItem()); // == dragged item
43
44 if (selected_item && focused_item != selected_item)//dropping from micromanagement
45 {
46 if (selected_item.GetInventory().CanRemoveEntity())
47 {
48 int stack_max;
49
50 if (!focused_icon)
51 {
52 if (focused_cont)
53 focused_cont.Select();
54 }
55 else if (!focused_item && m_Entity && m_Entity.GetInventory().CanAddAttachmentEx(selected_item, focused_icon.GetSlotID()))
56 {
58 float quantity = selected_item.GetQuantity();
59 if (stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit())
60 {
61 player.PredictiveTakeEntityToTargetAttachmentEx(m_Entity, selected_item, focused_icon.GetSlotID());
62 return true;
63 }
64 else
65 {
66 selected_item.SplitIntoStackMaxClient(m_Entity, focused_icon.GetSlotID());
67 return true;
68 }
69 }
70 else if (focused_icon.GetSlotID() != -1)
71 {
72 if (focused_item && focused_item.GetHierarchyParent() && focused_item.GetHierarchyParent().GetInventory().CanAddAttachment(selected_item))
73 {
75 focused_item.GetInventory().GetCurrentInventoryLocation(inv_loc);
77 quantity = focused_item.GetQuantity();
78 if (focused_item.CanBeCombined(ItemBase.Cast(selected_item)))
79 {
80 focused_item.CombineItemsClient(selected_item, true);
81 return true;
82 }
84 {
85 player.PredictiveSwapEntities(selected_item, focused_item);
86 return true;
87 }
88 else if (m_AttachmentCargos.Contains(inv_loc.GetSlot()))
89 {
90 if (focused_item.GetInventory().CanAddEntityInCargo(selected_item, selected_item.GetInventory().GetFlipCargo()))
91 {
93 return true;
94 }
95 }
96 }
97 }
98 }
99 }
100 else //clicking
101 {
102 if (focused_item && focused_item.GetInventory().CanRemoveEntity() && (!focused_icon || !focused_icon.IsOutOfReach()))
103 {
104 EntityAI item_in_hands = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
105 if (item_in_hands && item_in_hands.GetInventory().CanRemoveEntity())
106 {
108 {
109 player.PredictiveSwapEntities(item_in_hands, focused_item);
110 return true;
111 }
112 }
113 else
114 {
115 if (player.GetHumanInventory().CanAddEntityInHands(focused_item))
116 {
117 player.PredictiveTakeEntityToHands(focused_item);
118 return true;
119 }
120 }
121 }
122 }
123
124 return false;
125 }

References GameInventory::CanSwapEntitiesEx(), GetGame(), ItemManager::GetInstance(), InventorySlots::GetStackMaxForSlotId(), m_AttachmentCargos, m_Entity, and SplitItemUtils::TakeOrSplitToInventory().

◆ SplitItem()

override bool AttachmentCategoriesRow::SplitItem ( )
inlineprotected

Definition at line 232 of file AttachmentCategoriesRow.c.

233 {
234 return false;
235 }

◆ TransferItem()

override bool AttachmentCategoriesRow::TransferItem ( )
inlineprotected

Definition at line 127 of file AttachmentCategoriesRow.c.

128 {
129 if (CanTakeToInventory())
130 {
131 EntityAI entity = GetFocusedItem();
132 SlotsIcon focused_icon = GetFocusedSlotsIcon();
133 if (entity && !entity.IsLockedInSlot() && (!focused_icon || !focused_icon.IsOutOfReach()))
134 {
136 GetGame().GetPlayer().PredictiveTakeEntityToInventory(FindInventoryLocationType.CARGO, entity);
137 return true;
138 }
139 }
140 return false;
141 }

References GetGame(), and GetPlayer().

◆ TransferItemToVicinity()

override bool AttachmentCategoriesRow::TransferItemToVicinity ( )
inlineprotected

Definition at line 143 of file AttachmentCategoriesRow.c.

144 {
145 if (CanDrop())
146 {
147 ItemBase item = ItemBase.Cast(GetFocusedItem());
149 SlotsIcon focused_icon = GetFocusedSlotsIcon();
150
151 if (item && !item.IsLockedInSlot() && (focused_icon && !focused_icon.IsOutOfReach()))
152 {
153 if (item.GetTargetQuantityMax() < item.GetQuantity())
154 item.SplitIntoStackMaxClient(null, -1);
155 else
156 player.PhysicalPredictiveDropItem(item);
157 return true;
158 }
159 }
160 return false;
161 }

References GetGame(), and GetPlayer().

◆ UnfocusAll()

override void AttachmentCategoriesRow::UnfocusAll ( )
inlineprotected

Definition at line 376 of file AttachmentCategoriesRow.c.

377 {
378 int i;
379 for (i = 1; i < Count(); i++)
380 {
381 for (int j = 0; j < ITEMS_IN_ROW; j++)
382 {
383 Widget w = Get(i).GetMainWidget().FindAnyWidget("Cursor" + j);
384 if (w)
385 w.Show(false);
386 }
387 }
388 for (i = 0; i < m_AttachmentCargos.Count(); i++)
389 {
390 m_AttachmentCargos.GetElement(i).Unfocus();
391 m_AttachmentCargos.GetElement(i).SetActive(false);
392 }
393 }
array< ref PlayerStatBase > Get()

References Count, Get(), ITEMS_IN_ROW, and m_AttachmentCargos.

◆ UpdateInterval()

override void AttachmentCategoriesRow::UpdateInterval ( )
inlineprotected

Definition at line 896 of file AttachmentCategoriesRow.c.

897 {
898 super.UpdateInterval();
900 }

References RefreshAllSlots().

Member Data Documentation

◆ m_AttachmentCargos

ref map<int, ref ContainerWithCargo> AttachmentCategoriesRow::m_AttachmentCargos
protected

◆ m_AttachmentsContainer

ref AttachmentsGroupContainer AttachmentCategoriesRow::m_AttachmentsContainer
protected

◆ m_CategoryIdentifier

string AttachmentCategoriesRow::m_CategoryIdentifier
protected

Definition at line 3 of file AttachmentCategoriesRow.c.

Referenced by GetCategoryIdentifier(), and Init().

◆ m_Refreshing

bool AttachmentCategoriesRow::m_Refreshing
protected

Definition at line 5 of file AttachmentCategoriesRow.c.

Referenced by AttachmentCategoriesRow(), Refresh(), and RefreshAllSlots().

◆ m_RowConfigPath

string AttachmentCategoriesRow::m_RowConfigPath
protected

Definition at line 4 of file AttachmentCategoriesRow.c.

Referenced by Init().


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