8 protected string m_sBudgetProgressRoot;
10 protected SCR_CampaignBuildingEditorComponent m_CampaignBuildingComponent;
14 protected int m_iCurrentBudget;
15 protected int m_iMaxBudget;
16 protected const int INVALID_BUDGET = -1;
23 override void HandlerAttachedScripted(Widget w)
25 super.HandlerAttachedScripted(w);
28 Widget budgetRoot = w.FindAnyWidget(m_sBudgetProgressRoot);
32 m_CampaignBuildingComponent = SCR_CampaignBuildingEditorComponent.Cast(SCR_CampaignBuildingEditorComponent.GetInstance(SCR_CampaignBuildingEditorComponent));
40 m_BudgetManager.Event_OnBudgetUpdated.Insert(OnBudgetUpdate);
41 m_BudgetManager.Event_OnBudgetMaxUpdated.Insert(OnBudgetMaxUpdate);
42 m_BudgetManager.Event_OnBudgetPreviewUpdated.Insert(OnBudgetPreviewUpdate);
43 m_BudgetManager.Event_OnBudgetPreviewReset.Insert(ResetWidgetPreviewData);
48 override void HandlerDeattached(Widget w)
53 m_BudgetManager.Event_OnBudgetUpdated.Remove(OnBudgetUpdate);
54 m_BudgetManager.Event_OnBudgetMaxUpdated.Remove(OnBudgetMaxUpdate);
55 m_BudgetManager.Event_OnBudgetPreviewUpdated.Remove(OnBudgetPreviewUpdate);
56 m_BudgetManager.Event_OnBudgetPreviewReset.Remove(ResetWidgetPreviewData);
60 override protected bool IsUnique()
70 protected void InitializeBudgets()
72 if (!m_CampaignBuildingComponent || !m_BudgetManager)
75 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(
m_CampaignBuildingComponent.GetProviderComponent());
76 if (!providerComponent)
80 if (budgetToShow == INVALID_BUDGET)
82 m_BudgetProgress.GetRootWidget().SetVisible(
false);
86 SetBudgetType(budgetToShow);
89 m_iCurrentBudget = m_BudgetManager.GetCurrentBudgetValue(m_BudgetType);
90 m_BudgetManager.GetMaxBudgetValue(m_BudgetType, m_iMaxBudget);
92 if (!m_CampaignBuildingComponent)
95 m_BudgetProgress.HideBudgetChange();
97 if (m_iMaxBudget != 0)
98 m_BudgetProgress.ShowBudget(m_iCurrentBudget / m_iMaxBudget);
106 protected void OnBudgetUpdate(
EEditableEntityBudget budgetType,
int originalBudgetValue,
int updatedBudgetValue,
int maxBudgetValue)
108 m_iCurrentBudget = m_BudgetManager.GetCurrentBudgetValue(m_BudgetType);
109 m_BudgetManager.GetMaxBudgetValue(m_BudgetType, m_iMaxBudget);
111 m_BudgetProgress.HideBudgetChange();
112 m_BudgetProgress.ShowBudget(m_iCurrentBudget / m_iMaxBudget);
116 protected void OnBudgetMaxUpdate(
EEditableEntityBudget budgetType,
int currentBudgetValue,
int maxBudgetValue)
118 m_BudgetManager.GetMaxBudgetValue(m_BudgetType, m_iMaxBudget);
122 protected void OnBudgetPreviewUpdate(
EEditableEntityBudget budgetType,
float previewBudgetValue,
float budgetChange)
124 if (m_BudgetType != budgetType)
127 m_BudgetProgress.ShowBudgetChange(budgetChange, previewBudgetValue);
131 protected void ResetWidgetPreviewData()
133 m_BudgetProgress.HideBudgetChange();
140 if (!m_BudgetManager || !m_BudgetProgress)
151 info.SetIconTo(m_BudgetProgress.GetIconWidhget());
163 SetBudgetUIIcon(m_BudgetType);
175 return m_BudgetProgress;