Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_InventorySlotWeaponSlotsUI.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
5{
6 private static ResourceName m_sPrimaryWeaponSlot = "{CDE4B2BF08F5EA5F}UI/Textures/InventoryIcons/InvenorySlot-Primary_UI.edds";
7 private static ResourceName m_sSecondaryWeaponSlot = "{D08526F28B9ACAB9}UI/Textures/InventoryIcons/InvenorySlot-Secondary_UI.edds";
8 private static ResourceName m_sGrenadeWeaponSlot = "{E841B37EB8382114}UI/Textures/InventoryIcons/InvenorySlot-Grenade_UI.edds";
9
10 protected string m_sWeaponSlotType;
13 protected int m_iWeaponSlotIndex;
14
15 //------------------------------------------------------------------------ USER METHODS ----------------------------------------------------------------------
16
17 //------------------------------------------------------------------------------------------------
22
23 //------------------------------------------------------------------------------------------------
24 override void Init()
25 {
26 super.Init();
27
28 if (!m_pItem)
29 {
30 if (m_sWeaponSlotType == "primary")
31 SetIcon(m_sPrimaryWeaponSlot);
32 else if (m_sWeaponSlotType == "secondary")
33 SetIcon(m_sSecondaryWeaponSlot);
34 else if (m_sWeaponSlotType == "grenade")
35 SetIcon(m_sGrenadeWeaponSlot);
36 }
37 }
38
39 //------------------------------------------------------------------------------------------------
40 override string SetSlotSize()
41 {
42 ESlotSize slotSize;
43 string slotLayout = SLOT_LAYOUT_1x1;
44
45 if (m_sWeaponSlotType == "primary")
46 slotSize = ESlotSize.SLOT_2x1;
47 else
48 slotSize = ESlotSize.SLOT_1x1;
49
50 switch (slotSize)
51 {
52 case ESlotSize.SLOT_1x1: { m_iSizeX = 1; m_iSizeY = 1; } break;
53 case ESlotSize.SLOT_2x1: { m_iSizeX = 2; m_iSizeY = 1; } break;
54 }
55
56 return slotLayout;
57 }
58
59 //------------------------------------------------------------------------------------------------
61 {
62 return m_iWeaponSlotIndex;
63 }
64
65 //------------------------------------------------------------------------------------------------
67 {
68 SCR_InventoryMenuUI menu = SCR_InventoryMenuUI.Cast(GetGame().GetMenuManager().FindMenuByPreset(ChimeraMenuPreset.Inventory20Menu));
69 if (!menu)
70 return;
71
72 Widget incompatible = m_widget.FindAnyWidget("Incompatible");
73 if (!incompatible)
74 return;
75
76 if (!slot)
77 {
78 incompatible.SetVisible(false);
79 return;
80 }
81
82 if (slot.GetSlotedItemFunction() == ESlotFunction.TYPE_WEAPON)
83 {
85 if (!itemComp)
86 return;
87
88 BaseWeaponComponent weaponComp = BaseWeaponComponent.Cast(itemComp.GetOwner().FindComponent(BaseWeaponComponent));
89 if (!weaponComp)
90 return;
91
92 incompatible.SetVisible(weaponComp.GetWeaponSlotType() != m_sWeaponSlotType);
93 }
94 else if (slot.GetSlotedItemFunction() == ESlotFunction.TYPE_MAGAZINE)
95 {
96 if (!m_pItem)
97 {
98 incompatible.SetVisible(true);
99 return;
100 }
101
102 BaseWeaponComponent weapon = BaseWeaponComponent.Cast(m_pItem.GetOwner().FindComponent(BaseWeaponComponent));
103 if (!weapon)
104 {
105 incompatible.SetVisible(true);
106 return;
107 }
108
110 if (!itemComp)
111 return;
112
113 MagazineComponent magComp = MagazineComponent.Cast(itemComp.GetOwner().FindComponent(MagazineComponent));
114 if (!magComp)
115 return;
116
117 BaseMagazineWell well = magComp.GetMagazineWell();
118 if (!well)
119 return;
120
121 BaseMuzzleComponent muzzle = weapon.GetCurrentMuzzle();
122 if (!muzzle)
123 {
124 incompatible.SetVisible(true);
125 return;
126 }
127
128 BaseMagazineWell muzzleWell = muzzle.GetMagazineWell();
129 if (!muzzleWell)
130 {
131 incompatible.SetVisible(true);
132 return;
133 }
134
135 if (!menu.IsWeaponEquipped(m_pItem.GetOwner()) || slot.IsInherited(SCR_ArsenalInventorySlotUI))
136 {
137 incompatible.SetVisible(true);
138 return;
139 }
140
141 incompatible.SetVisible(!well.Type().IsInherited(muzzleWell.Type()));
142 }
143 else
144 {
145 incompatible.SetVisible(!menu.CanAddAttachment(slot, this));
146 }
147 }
148
149 //------------------------------------------------------------------------ COMMON METHODS ----------------------------------------------------------------------
150
151 //------------------------------------------------------------------------------------------------
152 void SCR_InventorySlotWeaponSlotsUI( InventoryItemComponent pComponent = null, SCR_InventoryStorageBaseUI pStorageUI = null, bool bVisible = true, int iSlotIndex = -1, SCR_ItemAttributeCollection pAttributes = null, int iWeaponSlotIndex = 0, string sWeaponSlotType = "" )
153 {
154 m_iQuickSlotIndex = iSlotIndex;
155 m_iWeaponSlotIndex = iWeaponSlotIndex;
156 m_sWeaponSlotType = sWeaponSlotType;
157 m_Attributes = pAttributes;
158 UpdateReferencedComponent( pComponent );
159 }
160
161 //------------------------------------------------------------------------------------------------
165};
ChimeraMenuPreset
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_EAnalyticalItemSlotType
const string SLOT_LAYOUT_1x1
proto external Managed FindComponent(typename typeName)
bool CanAddAttachment(SCR_InventorySlotUI itemSlot, SCR_InventorySlotUI targetSlot)
bool IsWeaponEquipped(IEntity weapon)
void SCR_InventorySlotUI(InventoryItemComponent pComponent=null, SCR_InventoryStorageBaseUI pStorageUI=null, bool bVisible=true, int iSlotIndex=-1, SCR_ItemAttributeCollection pAttributes=null)
InventoryItemComponent GetInventoryItemComponent()
ESlotFunction GetSlotedItemFunction()
What functionality the item in the slot has? ( weapon, magazine, health, consumable....
ref SCR_ItemAttributeCollection m_Attributes
InventoryItemComponent m_pItem
void SetIcon(ResourceName texture)
void UpdateReferencedComponent(InventoryItemComponent pComponent, SCR_ItemAttributeCollection attributes=null)
void SCR_InventorySlotWeaponSlotsUI(InventoryItemComponent pComponent=null, SCR_InventoryStorageBaseUI pStorageUI=null, bool bVisible=true, int iSlotIndex=-1, SCR_ItemAttributeCollection pAttributes=null, int iWeaponSlotIndex=0, string sWeaponSlotType="")
override SCR_EAnalyticalItemSlotType GetAnalyticalItemSlotType()
override void CheckCompatibility(SCR_InventorySlotUI slot)