Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SuppliesTransportSystemUI.c
Go to the documentation of this file.
2{
3 [Attribute("{4093FEFCBC51D74A}UI/layouts/Campaign/TransportUnit.layout", desc: "Trasnport unit layout path.")]
5
6 [Attribute("Labels")]
7 protected string m_sLabelsWidgetName;
8
9 [Attribute("TransportUnitsContainer")]
11
12 [Attribute("NoTransportUnitInfo")]
14
15 protected Widget m_wLabels;
18
20
22
23 //------------------------------------------------------------------------------------------------
24 void Init()
25 {
27 return;
28
29 m_SuppliesTransportSystem.GetOnTransportUnitAdded().Insert(CreateTransportUnit);
30 m_SuppliesTransportSystem.GetOnTransportUnitRemoved().Insert(RemoveTransportUnit);
31
32 array<SCR_TransportUnitComponent> transportUnits = {};
33 m_SuppliesTransportSystem.GetTransportUnits(transportUnits, SCR_FactionManager.SGetLocalPlayerFaction());
34
35 bool isTransportUnitsEmpty = transportUnits.IsEmpty();
37 m_wNoTransportUnitInfo.SetVisible(isTransportUnitsEmpty);
38
39 if (m_wLabels)
40 m_wLabels.SetVisible(!isTransportUnitsEmpty);
41
42 foreach (SCR_TransportUnitComponent theTransportUnit : transportUnits)
43 {
44 CreateTransportUnit(theTransportUnit);
45 }
46 }
47
48 //------------------------------------------------------------------------------------------------
49 void Deinit()
50 {
52 return;
53
54 array<SCR_TransportUnitComponent> transportUnits = {};
55 m_SuppliesTransportSystem.GetTransportUnits(transportUnits, SCR_FactionManager.SGetLocalPlayerFaction());
56 for (int i = transportUnits.Count() - 1; i >= 0; i--)
57 {
58 RemoveTransportUnit(transportUnits[i]);
59 }
60
61 m_SuppliesTransportSystem.GetOnTransportUnitAdded().Remove(CreateTransportUnit);
62 m_SuppliesTransportSystem.GetOnTransportUnitRemoved().Remove(RemoveTransportUnit);
63 }
64
65 //------------------------------------------------------------------------------------------------
66 void ToggleVisibility(bool isVisible)
67 {
68 if (isVisible && !m_mTransportUnits.IsEmpty())
69 m_mTransportUnits.GetElement(0).FocusButton();
70 }
71
72 //------------------------------------------------------------------------------------------------
73 protected void CreateTransportUnit(notnull SCR_TransportUnitComponent transportUnit)
74 {
76 return;
77
78 if (transportUnit.GetFaction() != SCR_FactionManager.SGetLocalPlayerFaction())
79 return;
80
81 Widget transportUnitWidget = GetGame().GetWorkspace().CreateWidgets(m_sTransportUnitLayoutResource, m_wTransportUnitsContainer);
82 if (!transportUnitWidget)
83 return;
84
85 SCR_TransportUnitUI transportUnitUI = SCR_TransportUnitUI.Cast(transportUnitWidget.FindHandler(SCR_TransportUnitUI));
86 transportUnitUI.Init(transportUnit);
87 m_mTransportUnits.Insert(transportUnit, transportUnitUI);
88 }
89
90 //------------------------------------------------------------------------------------------------
91 protected void RemoveTransportUnit(SCR_TransportUnitComponent transportUnit)
92 {
93 SCR_TransportUnitUI transportUnitUI = m_mTransportUnits.Get(transportUnit);
94 if (!transportUnitUI)
95 return;
96
97 transportUnitUI.Deinit();
98 transportUnitUI.GetRootWidget().RemoveFromHierarchy();
99 m_mTransportUnits.Remove(transportUnit);
100 }
101
102 //------------------------------------------------------------------------------------------------
103 override void HandlerAttached(Widget w)
104 {
105 if (!GetGame().InPlayMode())
106 return;
107
108 super.HandlerAttached(w);
109
110 m_wLabels = w.FindAnyWidget(m_sLabelsWidgetName);
111
114 return;
115
117
119
121 }
122}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_FactionManager(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
static SCR_SuppliesTransportSystem GetInstance()
ref map< SCR_TransportUnitComponent, SCR_TransportUnitUI > m_mTransportUnits
SCR_SuppliesTransportSystem m_SuppliesTransportSystem
void CreateTransportUnit(notnull SCR_TransportUnitComponent transportUnit)
void RemoveTransportUnit(SCR_TransportUnitComponent transportUnit)
void Init(SCR_TransportUnitComponent transportUnit)
Definition Types.c:486
SCR_FieldOfViewSettings Attribute