4 const string SLOT_LAYOUT_SUPPLY =
"{EA29CC1952F8B019}UI/layouts/Menus/Inventory/SupplyInventoryItemSlot.layout";
5 const float SLOT_UNAVAILABLE_OPACITY = 0.35;
7 protected const string RESOURCES_TEXT_WIDGET_NAME =
"SuppliesText";
8 protected const string STORED_RESOURCES_WIDGET_NAME =
"SuppliesStored";
9 protected const string AVAILABLE_RESOURCES_WIDGET_NAME =
"SuppliesAvailable";
10 protected const string COST_RESOURCES_WIDGET_NAME =
"SuppliesCost";
12 protected Widget m_StoredResourcesHolder;
13 protected TextWidget m_StoredResourcesText;
15 protected Widget m_AvailableResourcesHolder;
16 protected TextWidget m_AvailableResourcesText;
23 protected LocalizedString m_sCurrentAndMaxResourceFormat =
"#AR-Campaign_BaseSuppliesAmount";
25 protected SCR_ResourceComponent m_ResourceComponent;
26 protected SCR_ResourceConsumer m_ResourceConsumer;
30 override protected string SetSlotSize()
32 string slotLayout = SLOT_LAYOUT_SUPPLY;
61 override void SetItemFunctionality()
63 if (m_pItem.GetOwner().FindComponent(BaseInventoryStorageComponent))
68 override void SetSlotVisible(
bool bVisible)
70 super.SetSlotVisible(bVisible);
73 m_wDimmerEffect = m_widget.FindAnyWidget(
"Dimmer");
75 m_StoredResourcesHolder = m_widget.FindAnyWidget(STORED_RESOURCES_WIDGET_NAME);
76 if (m_StoredResourcesHolder)
77 m_StoredResourcesText = TextWidget.Cast(m_StoredResourcesHolder.FindAnyWidget(RESOURCES_TEXT_WIDGET_NAME));
79 m_AvailableResourcesHolder = m_widget.FindAnyWidget(AVAILABLE_RESOURCES_WIDGET_NAME);
80 if (m_AvailableResourcesHolder)
81 m_AvailableResourcesText = TextWidget.Cast(m_AvailableResourcesHolder.FindAnyWidget(RESOURCES_TEXT_WIDGET_NAME));
84 Widget resourceCost = m_widget.FindAnyWidget(COST_RESOURCES_WIDGET_NAME);
86 resourceCost.SetVisible(
false);
92 override void Refresh()
103 float totalResources, maxResources;
107 UpdateStoredResources(showUI, totalResources, maxResources);
111 UpdateAvailableResources(showUI, totalResources);
115 void UpdateStoredResources(
bool showUI,
float totalResources,
float maxResources)
117 if (!m_StoredResourcesHolder || !m_StoredResourcesText)
122 m_StoredResourcesHolder.SetVisible(
false);
128 m_StoredResourcesHolder.SetVisible(
true);
132 void UpdateAvailableResources(
bool showUI,
float totalResources)
134 if (!m_AvailableResourcesHolder || !m_AvailableResourcesText)
139 m_AvailableResourcesHolder.SetVisible(
false);
145 m_AvailableResourcesHolder.SetVisible(
true);
149 override void HandlerAttached(Widget w)
151 super.HandlerAttached(w);
157 override void HandlerDeattached(Widget w)
159 super.HandlerDeattached(w);
161 m_ResourceSubscriptionHandle =
null;
185 if (!resourceInventoryPlayerComponent)
188 RplId resourceInventoryPlayerComponentRplId = Replication.FindId(resourceInventoryPlayerComponent);
190 if (!resourceInventoryPlayerComponentRplId.IsValid())
193 m_ResourceSubscriptionHandle =
GetGame().GetResourceSystemSubscriptionManager().RequestSubscriptionListenerHandle(
m_ResourceConsumer, resourceInventoryPlayerComponentRplId);