3 protected ref array<InventoryStorageSlot> m_aStorageSlotsInStorage = {};
5 protected Widget m_wFrameSlot;
6 protected SCR_WeaponAttachmentsStorageComponent m_WeaponStorage;
9 override void HandlerAttached(Widget w)
11 super.HandlerAttached(w);
14 SCR_WeaponAttachmentsStorageComponent weaponStorage = SCR_WeaponAttachmentsStorageComponent.Cast(
m_Storage);
19 m_WeaponStorage.m_OnItemAddedToSlotInvoker.Insert(RefreshInspectionSlots);
20 m_WeaponStorage.m_OnItemRemovedFromSlotInvoker.Insert(RefreshInspectionSlots);
24 override void HandlerDeattached(Widget w)
28 m_WeaponStorage.m_OnItemAddedToSlotInvoker.Remove(RefreshInspectionSlots);
29 m_WeaponStorage.m_OnItemRemovedFromSlotInvoker.Remove(RefreshInspectionSlots);
33 super.HandlerDeattached(w);
37 protected void RefreshInspectionSlots()
45 override Widget GetStorageGrid()
51 override bool IsTraversalAllowed()
58 typename type = slot.GetParentContainer().Type();
61 name =
"#AR-Magazine_Name";
65 return magwell.Type();
67 else if (
type == AttachmentSlotComponent)
69 AttachmentSlotComponent
attachment = AttachmentSlotComponent.Cast(slot.GetParentContainer());
73 return typename.Empty;
78 name =
"#AR-KeybindSeparator_WeaponOptics";
80 name =
"#AR-AttachmentType_Underbarrel";
84 return typename.Empty;
92 override protected int CreateSlots()
94 array<IEntity> pItemsInStorage = {};
97 for (
int i = 0; i < count; ++i)
101 AttachmentSlotComponent
attachment = AttachmentSlotComponent.Cast(storageSlot.GetParentContainer());
105 m_aStorageSlotsInStorage.Insert(storageSlot);
106 pItemsInStorage.Insert(item);
109 UpdateOwnedSlots(pItemsInStorage);
114 override protected void UpdateOwnedSlots(notnull array<IEntity> pItemsInStorage)
116 int count = pItemsInStorage.Count();
120 for (
int i =
m_aSlots.Count() - count; i > 0; i--)
128 for (
int i = 0; i < count; i++)
133 m_aSlots[i].UpdateReferencedComponent(pComponent);
136 m_aSlots[i] = CreateSlotUI(pComponent);
140 typename slotType = GetSlotType(
m_Storage.GetSlot(i), slotName);
141 if (!slotName.Empty && slotType)
145 slot.m_tAttachmentType = slotType;
163 slotUI.UpdateReferencedComponent(slotUI.GetInventoryItemComponent());
165 Widget slotWidget = slotUI.GetWidget();
174 transform[3] = m_aStorageSlotsInStorage.Get(i).GetInspectionWidgetOffset();
176 charPreview.TryGetItemNodePositionInWidgetSpace(-1, transform, screenPos);
177 FrameSlot.SetPos(slotWidget, screenPos[0], screenPos[1]);
194 item = itemComp.GetOwner();
196 callBack.m_pItem = item;
199 callBack.m_pStorageFrom = slot.GetStorageUI();
200 callBack.m_pStorageTo =
this;
219 override void SetRowsAndColumns() {}
223 override protected void SortSlots() {}
230 override void FillWithEmptySlots() {}
233 override void Refresh() {}
236 override void InitPaging() {}
240 BaseInventoryStorageComponent storage,
244 array<BaseInventoryStorageComponent> aTraverseStorage =
null,
245 Widget frameSlot =
null)
249 m_eSlotAreaType = slotID;
252 m_iMatrix =
new SCR_Matrix(m_iMaxColumns, m_iMaxRows);
253 m_wFrameSlot = frameSlot;
260 protected static const float SLOT_SIZE_DEFAULT = 32;
261 protected static const float SLOT_SIZE_HIGHLIGHTED = 64;
263 protected static const ResourceName ICON_VALID_SLOT =
"{A1A2E6F6DB36CF61}UI/Textures/InventoryIcons/Inspection-gizmo-small_UI.edds";
264 protected static const ResourceName ICON_INVALID_SLOT =
"{2EB962B6F404C01E}UI/Textures/InventoryIcons/Inspection-gizmo-invalid-small_UI.edds";
265 protected static const string SLOT_LAYOUT =
"{EB835F21257F0C51}UI/layouts/Menus/Inventory/AttachmentItemSlot.layout";
267 protected Widget m_wItemWidget =
null;
268 protected ImageWidget m_wIconWidget =
null;
269 protected SizeLayoutWidget m_wItemSizeLayout =
null;
271 protected bool m_bCompatibleAttachmentsShown;
272 typename m_tAttachmentType;
283 m_pItem = pComponent;
284 Widget m_wFrameSlot = m_pStorageUI.GetStorageGrid();
285 m_widget =
GetGame().GetWorkspace().CreateWidgets(SLOT_LAYOUT, m_wFrameSlot);
286 m_widget.AddHandler(
this);
288 m_wItemWidget = m_widget.FindAnyWidget(
"ButtonOverlay");
289 m_wIconWidget = ImageWidget.Cast(m_widget.FindAnyWidget(
"WidgetGizmo"));
293 m_wIconWidget.LoadImageTexture(0, ICON_VALID_SLOT);
294 m_wIconWidget.SetVisible(
true);
298 m_wItemWidget.SetVisible(
false);
302 override bool OnMouseEnter(Widget w,
int x,
int y)
306 return super.OnMouseEnter(w, x, y);
310 override bool OnMouseLeave(Widget w, Widget enterW,
int x,
int y)
315 return super.OnMouseLeave(w, enterW, x, y);
318 override bool OnClick(Widget w,
int x,
int y,
int button)
322 if (!m_bCompatibleAttachmentsShown)
323 ShowCompatibleAttachments();
325 HideCompatibleAttachments();
331 void ShowCompatibleAttachments()
333 m_bCompatibleAttachmentsShown =
true;
337 SCR_MagazinePredicate predicate =
new SCR_MagazinePredicate();
338 predicate.magWellType = m_tAttachmentType;
340 m_pStorageUI.GetInventoryMenuHandler().ShowAttachmentStorage(predicate);
344 SCR_CompatibleAttachmentPredicate predicate =
new SCR_CompatibleAttachmentPredicate();
345 predicate.attachmentType = m_tAttachmentType;
347 m_pStorageUI.GetInventoryMenuHandler().ShowAttachmentStorage(predicate);
351 void HideCompatibleAttachments()
353 m_bCompatibleAttachmentsShown =
false;
355 m_pStorageUI.GetInventoryMenuHandler().CloseAttachmentStorage();
359 void Highlight(
bool highlight)
364 FrameSlot.SetSize(m_widget, SLOT_SIZE_HIGHLIGHTED, SLOT_SIZE_HIGHLIGHTED);
366 FrameSlot.SetSize(m_widget, SLOT_SIZE_DEFAULT, SLOT_SIZE_DEFAULT);
370 m_wItemWidget.SetVisible(highlight);
373 m_wIconWidget.SetVisible(!highlight);
376 void Select(
bool select =
true)
380 s_SelectedPoint.m_bIsSelected =
false;
381 s_SelectedPoint.Highlight(
false);
384 m_bIsSelected = select;
388 s_SelectedPoint =
this;
392 s_SelectedPoint =
null;
397 override BaseInventoryStorageComponent GetAsStorage()
399 return m_pStorageUI.GetStorage();
405 return m_pStorageUI.OnDrop(slot);