Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CampaignBuildingBudgetEditorUIComponent.c
Go to the documentation of this file.
2 {
3  [Attribute(desc: "Budgets to be shown in UI", UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EEditableEntityBudget))]
4  protected ref array<EEditableEntityBudget> m_aVisibleBudgetUI;
5 
6  protected static const int UNLIMITED_PROP_BUDGET = -1;
7 
8  //------------------------------------------------------------------------------------------------
9  override void InitializeBudgets()
10  {
11  array<ref SCR_EditableEntityCoreBudgetSetting> budgets = {};
12  m_BudgetManager.GetBudgets(budgets);
13 
14  foreach (SCR_EditableEntityCoreBudgetSetting budget : budgets)
15  {
16  if (!m_aVisibleBudgetUI.Contains(budget.GetBudgetType()))
17  continue;
18 
19  int MaxBudgetValue = GetMaxBudgetValue(budget.GetBudgetType());
20 
21  if (MaxBudgetValue == UNLIMITED_PROP_BUDGET)
22  {
24  return;
25  }
26 
27  OnBudgetAdd(budget, MaxBudgetValue);
28  }
29  }
30 
31  //------------------------------------------------------------------------------------------------
32  override void OnBudgetAdd(SCR_EditableEntityCoreBudgetSetting budget, int maxBudget)
33  {
34  WorkspaceWidget workspace = GetGame().GetWorkspace();
35  if (!workspace || !m_Layout || m_BudgetEntryPrefab.IsEmpty())
36  return;
37 
38  EEditableEntityBudget budgetType = budget.GetBudgetType();
39  if (m_BudgetWidgets.Contains(budgetType))
40  return;
41 
42  Widget budgetWidget = workspace.CreateWidgets(m_BudgetEntryPrefab, m_Layout);
43  SetBudgetData(budgetWidget, GetCurrentBudgetValue(), maxBudget, budget.GetInfo());
44 
45  m_BudgetWidgets.Insert(budgetType, budgetWidget);
46  }
47 
48  //------------------------------------------------------------------------------------------------
49  override void OnBudgetUpdate(EEditableEntityBudget budgetType, int originalBudgetValue, int updatedBudgetValue, int maxBudgetValue)
50  {
51  TextWidget budgetWidget;
52  if (m_BudgetWidgets.Find(budgetType, budgetWidget))
53  {
54  SetBudgetData(budgetWidget, GetCurrentBudgetValue(), maxBudgetValue);
55  SetBudgetPreviewData(budgetWidget, 0, 0);
56  }
57  }
58 
59  //------------------------------------------------------------------------------------------------
61  SCR_CampaignBuildingProviderComponent GetProviderComponent()
62  {
64  if (!core)
65  return null;
66 
67  SCR_EditorManagerEntity editorManager = core.GetEditorManager();
68  if (!editorManager)
69  return null;
70 
71  SCR_EditorModeEntity modeEntity = SCR_EditorModeEntity.Cast(editorManager.FindModeEntity(EEditorMode.BUILDING));
72  if (!modeEntity)
73  return null;
74 
75  SCR_CampaignBuildingEditorComponent editorComponent = SCR_CampaignBuildingEditorComponent.Cast(modeEntity.FindComponent(SCR_CampaignBuildingEditorComponent));
76  if (!editorComponent)
77  return null;
78 
79  return editorComponent.GetProviderComponent();
80  }
81 
82  //------------------------------------------------------------------------------------------------
84  int GetMaxBudgetValue(EEditableEntityBudget budget)
85  {
86  SCR_CampaignBuildingProviderComponent provider = GetProviderComponent();
87  if (!provider)
88  return UNLIMITED_PROP_BUDGET;
89 
90  return provider.GetMaxBudgetValue(budget);
91  }
92 
93  //------------------------------------------------------------------------------------------------
95  int GetCurrentBudgetValue()
96  {
97  SCR_CampaignBuildingProviderComponent provider = GetProviderComponent();
98  if (!provider)
99  return UNLIMITED_PROP_BUDGET;
100 
101  return provider.GetCurrentPropValue();
102  }
103 }
SCR_EditableEntityCoreBudgetSetting
Definition: SCR_EditableEntityCoreBudgetSetting.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_Layout
ResourceName m_Layout
Definition: SCR_ActionsToolbarEditorUIComponent.c:6
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_EditorModeEntity
Definition: SCR_EditorModeEntity.c:22
SCR_CampaignBuildingBudgetEditorUIComponent
Definition: SCR_CampaignBuildingBudgetEditorUIComponent.c:1
EEditableEntityBudget
EEditableEntityBudget
Definition: EEditableEntityBudget.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_EditorManagerCore
Core component to manage SCR_EditorManagerEntity.
Definition: SCR_EditorManagerCore.c:5
SCR_BudgetEditorUIComponent
Definition: SCR_BudgetEditorUIComponent.c:1
EEditorMode
EEditorMode
Editor mode that defines overall functionality.
Definition: EEditorMode.c:5
UnregisterEvents
protected void UnregisterEvents(IEntity from)
Definition: SCR_ItemPlacementComponent.c:63
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26