4 protected TextWidget m_ProviderName;
5 protected TextWidget m_ProviderCallsign;
6 protected Widget m_wInGameSupply;
7 protected TextWidget m_ProviderSupplyCurrent;
8 protected TextWidget m_ProviderSupplyMax;
9 protected OverlayWidget m_ProviderIcon;
11 protected SCR_ResourceComponent m_ResourceComponent;
12 protected SCR_ResourceConsumer m_ResourceConsumer;
14 protected RplId m_ResourceInventoryPlayerComponentRplId;
17 override void HandlerAttached(Widget w)
19 super.HandlerAttached(w);
20 m_ProviderName = TextWidget.Cast(w.FindAnyWidget(
"Provider_Name"));
21 m_ProviderCallsign = TextWidget.Cast(w.FindAnyWidget(
"Provider_Callsign"));
22 m_ProviderSupplyCurrent = TextWidget.Cast(w.FindAnyWidget(
"Supply_Value_Current"));
23 m_wInGameSupply = w.FindAnyWidget(
"Supply_InGame_Supply");
24 m_ProviderSupplyMax = TextWidget.Cast(w.FindAnyWidget(
"Supply_Value_Max"));
25 m_ProviderIcon = OverlayWidget.Cast(w.FindAnyWidget(
"Provider_Icon_Overlay"));
27 SCR_CampaignBuildingEditorComponent buildingEditorComponent = SCR_CampaignBuildingEditorComponent.Cast(SCR_CampaignBuildingEditorComponent.GetInstance(SCR_CampaignBuildingEditorComponent));
28 if (!buildingEditorComponent)
31 IEntity targetEntity = buildingEditorComponent.GetProviderEntity();
39 SetSourceIcon(targetEntity);
40 SetProviderName(targetEntity);
57 override void HandlerDeattached(Widget w)
59 super.HandlerDeattached(w);
68 protected void SetSourceIcon(IEntity targetEntity)
85 factionColor = GetColorForFaction(faction.GetFactionKey());
91 switch(faction.GetFactionKey())
121 baseIcon.SetDimension(2);
122 m_ProviderIcon.SetColor(factionColor);
127 protected Color GetColorForFaction(
string factionKey)
129 FactionManager fm =
GetGame().GetFactionManager();
133 Faction faction = fm.GetFactionByKey(factionKey);
137 return faction.GetFactionColor();
141 protected void UpdateResources()
151 if (m_ProviderSupplyCurrent)
152 m_ProviderSupplyCurrent.SetText(consumer.GetAggregatedResourceValue().ToString());
154 if (m_ProviderSupplyMax)
155 m_ProviderSupplyMax.SetText(consumer.GetAggregatedMaxResourceValue().ToString());
158 if (consumer.GetAggregatedResourceValue() == 0)
159 m_wInGameSupply.SetColor(
UIColors.WARNING);
161 m_wInGameSupply.SetColor(Color.FromInt(Color.WHITE));
165 [
Obsolete(
"SCR_CampaignBuildingSupplyEditorUIComponent.UpdateResources() should be used instead.")]
166 protected void UpdateSupply()
175 if (m_ProviderSupplyCurrent)
176 m_ProviderSupplyCurrent.SetText(consumer.GetAggregatedResourceValue().ToString());
178 if (m_ProviderSupplyMax)
179 m_ProviderSupplyMax.SetText(consumer.GetAggregatedMaxResourceValue().ToString());
182 if (consumer.GetAggregatedResourceValue() == 0)
183 m_wInGameSupply.SetColor(
UIColors.WARNING);
185 m_wInGameSupply.SetColor(Color.FromInt(Color.WHITE));
189 protected void SetProviderName(IEntity targetEntity)
191 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(targetEntity.FindComponent(SCR_CampaignBuildingProviderComponent));
192 if (!providerComponent)
195 m_ProviderCallsign.SetText(providerComponent.GetProviderDisplayName());
197 SCR_MilitaryBaseComponent targetBase = SCR_MilitaryBaseComponent.Cast(providerComponent.GetMilitaryBaseComponent());
200 m_ProviderCallsign.SetText(targetBase.GetCallsignDisplayName());
204 m_ProviderName.SetText(
"");