Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PlayerSupplyAllocationUI.c
Go to the documentation of this file.
1//PlayerSupplyAllocation Widget Handler
2
4{
5 //Supplies text widget for showing up maximum amount of supplies Allocation and current supplies amount
6 [Attribute("MSARSuppliesText", desc: "Text for displaying supplies related info to player")]
8
9 //Number of currently available allocated supplies
10 [Attribute("0", desc: "Available supplies Count")]
12
13 //Current allocated supplies limit
14 [Attribute("0", desc: "Allocated supplies limit")]
16
17 //Switch for allowing visible top limit of supplies, if set to true - there will be also top limit visible in inventory at all times no matter this setting
18 [Attribute("0", desc: "Bool for switching between supplies amount display modes")]
19 protected bool m_bVisibleTopLimit;
20
22
24
25 protected string m_sSuppliesAmount;
26
27 [Attribute("#AR-supplies_MSAR_Availability")]
28 protected string m_sAvailableText;
29
30 [Attribute("#AR-supplies_MSAR_Availability_Long")]
31 protected string m_sAvailableTextLong;
32
33 protected PlayerController m_PlayerController = GetGame().GetPlayerController();
34
35 protected SCR_PlayerSupplyAllocationComponent m_PlayerSupplyAllocationComponent;
36
37 //------------------------------------------------------------------------------------------------
40 override void HandlerAttached(Widget w)
41 {
42 super.HandlerAttached(w);
43
45 {
46 w.SetVisible(false);
47 return;
48 }
49
50 m_PlayerSupplyAllocationComponent = SCR_PlayerSupplyAllocationComponent.Cast(m_PlayerController.FindComponent(SCR_PlayerSupplyAllocationComponent));
51 if (!m_PlayerSupplyAllocationComponent || !SCR_ArsenalManagerComponent.IsMilitarySupplyAllocationEnabled())
52 {
53 w.SetVisible(false);
54 return;
55 }
56
57 w.SetVisible(true);
58 m_wSuppliesText = RichTextWidget.Cast(w.GetParent().FindAnyWidget(m_sSuppliesText));
59
60 m_PlayerSupplyAllocationComponent.GetOnAvailableAllocatedSuppliesChanged().Insert(OnAvailableAllocatedSuppliesChanged);
61 m_PlayerSupplyAllocationComponent.GetOnMilitarySupplyAllocationChanged().Insert(OnMilitarySupplyAllocationChanged);
62
65
67 }
68
69 //------------------------------------------------------------------------------------------------
72 override void HandlerDeattached(Widget w)
73 {
74 super.HandlerDeattached(w);
75
77 {
78 w.SetVisible(false);
79 m_PlayerSupplyAllocationComponent.GetOnAvailableAllocatedSuppliesChanged().Remove(OnAvailableAllocatedSuppliesChanged);
80 m_PlayerSupplyAllocationComponent.GetOnMilitarySupplyAllocationChanged().Remove(OnMilitarySupplyAllocationChanged);
81 }
82
85 }
86
87 //------------------------------------------------------------------------------------------------
89 {
91 return;
92
93 m_iAvailableSuppliesAmount = m_PlayerSupplyAllocationComponent.GetPlayerAvailableAllocatedSupplies();
94 m_iMaxAvailableSuppliesAmount = m_PlayerSupplyAllocationComponent.GetPlayerMilitarySupplyAllocation();
95
97 }
98
99 //------------------------------------------------------------------------------------------------
101 protected void UpdateSupplyAmountText()
102 {
103 if (!m_wSuppliesText)
104 return;
105
106 string maxSuppliesString = m_iMaxAvailableSuppliesAmount.ToString();
108 maxSuppliesString = maxSuppliesString.Format("%1 (<color name='red'>%2</color>)", maxSuppliesString, m_iPlayerSupplyAllocationOffset.ToString());
110 maxSuppliesString = maxSuppliesString.Format("%1 (<color name='green'>+%2</color>)", maxSuppliesString, m_iPlayerSupplyAllocationOffset.ToString());
111
113 //Formating String to display to player Available supplies/Max Available Supplies, 100/500 Available
114 m_wSuppliesText.SetTextFormat(m_sAvailableTextLong, m_iAvailableSuppliesAmount, maxSuppliesString);
115 else
116 //Formating String to display to player Available supplies only 100 Available
118 }
119
120 //------------------------------------------------------------------------------------------------
121 protected void OnItemHover(SCR_InventorySlotUI slot)
122 {
123 if (!slot || !SCR_ArsenalManagerComponent.IsMilitarySupplyAllocationEnabled())
124 return;
125
127 if (arsenalSlot)
128 {
129 // Item to be purchased, show the effect of the purchase on MSAR
132 }
133 else
134 {
135 // Item to be refunded, show the effect of the refund on MSAR
138 }
139 }
140
141 //------------------------------------------------------------------------------------------------
142 protected void OnItemHoverEnd()
143 {
146 }
147
148 //------------------------------------------------------------------------------------------------
152 {
154 return;
155
156 SCR_ArsenalManagerComponent arsenalManager;
157 SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager);
158 if (!arsenalManager)
159 return;
160
161 m_iPlayerSupplyAllocationOffset = -arsenalManager.GetLoadoutMilitarySupplyAllocationCost(loadout, m_PlayerController.GetPlayerId());
163 }
164
165 //------------------------------------------------------------------------------------------------
167 {
169 if (!inventoryMenu)
170 return 0;
171
172 SCR_InventoryStorageBaseUI storageUI = inventoryMenu.GetLootStorage();
173 if (!storageUI)
174 return 0;
175
176 BaseInventoryStorageComponent storage = storageUI.GetCurrentNavigationStorage();
177 if (!storage)
178 return 0;
179
180 IEntity storageOwner = storage.GetOwner();
181 if (!storageOwner)
182 return 0;
183
185 if (!arsenalComp)
186 return 0;
187
188 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(SCR_PlayerController.GetLocalControlledEntity());
189 if (!character)
190 return 0;
191
192 if (arsenalComp.GetAssignedFaction() != character.GetFaction())
193 return 0;
194
196 if (!item)
197 return 0;
198
199 IEntity itemEntity = item.GetOwner();
200 if (!itemEntity)
201 return 0;
202
203 SCR_ArsenalManagerComponent arsenalManager;
204 if (!SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
205 return 0;
206
207 return arsenalManager.GetItemMilitarySupplyAllocationRefundAmount(itemEntity, arsenalComp);
208 }
209
210 //------------------------------------------------------------------------------------------------
213 protected void OnAvailableAllocatedSuppliesChanged(int amount)
214 {
215 if (m_iAvailableSuppliesAmount == amount)
216 return;
217
220 }
221
222 //------------------------------------------------------------------------------------------------
225 protected void OnMilitarySupplyAllocationChanged(int amount)
226 {
227 if (m_iMaxAvailableSuppliesAmount == amount)
228 return;
229
232 }
233}
ArmaReforgerScripted GetGame()
Definition game.c:1398
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
static bool IsEditMode()
Definition Functions.c:1566
static ScriptInvoker GetOnItemHoverEnd()
SCR_InventoryStorageBaseUI GetLootStorage()
static ScriptInvokerInventorySlotHover GetOnItemHover()
static SCR_InventoryMenuUI GetInventoryMenu()
InventoryItemComponent GetInventoryItemComponent()
static IEntity GetLocalControlledEntity()
SCR_PlayerSupplyAllocationComponent m_PlayerSupplyAllocationComponent
int GetItemPlayerSupplyAllocationRefundValue(SCR_InventorySlotUI slot)
void OnLoadoutSelected(SCR_BasePlayerLoadout loadout)
void UpdateSupplyAmountText()
Sets the Supplies text to current amount of available and allocated supplies.
void OnItemHover(SCR_InventorySlotUI slot)
SCR_FieldOfViewSettings Attribute