Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_NavigationBarUI.c
Go to the documentation of this file.
1[BaseContainerProps(configRoot: true)]
3{
4 [Attribute()]
5 protected ref array<ref NavigationButtonEntry> m_aEntries;
6
7 array<ref NavigationButtonEntry> GetEntries()
8 {
9 return m_aEntries;
10 }
11};
12
13//------------------------------------------------------------------------------------------------
16{
17 [Attribute(uiwidget: UIWidgets.LocaleEditBox, desc: "Display name of input action")]
18 LocalizedString m_sDisplayName;
19 [Attribute(desc: "Name of input action")]
20 string m_sAction;
21 [Attribute(desc: "Name of the button - ID")]
22 string m_sButtonID;
23
24 SCR_InputButtonComponent m_Component;
25};
26
27//------------------------------------------------------------------------------------------------
32{
33 //#define BUTTON_LAYOUT "{19A9CC7487AAD442}UI/layouts/Common/Buttons/NavigationButton.layout"
34
35 [Attribute("{08CF3B69CB1ACBC4}UI/layouts/WidgetLibrary/WLib_NavigationButton.layout", UIWidgets.ResourceNamePicker, "Layout", "layout")]
37
38 [Attribute(uiwidget: UIWidgets.Object, desc: "Action Buttons")]
39 ref array<ref NavigationButtonEntry> m_aEntries;
40
41 [Attribute("{E09350C3FD7F0812}Configs/Inventory/InventoryNavigationBar.conf")]
43
45
46 //------------------------------------------------------------------------ USER METHODS ------------------------------------------------------------------------
47
48 //------------------------------------------------------------------------------------------------
49 void Refresh();
50
51 //------------------------------------------------------------------------------------------------
52 protected SCR_InputButtonComponent GetButton( string name )
53 {
54 foreach ( NavigationButtonEntry entry : m_aEntries )
55 {
56 SCR_InputButtonComponent comp = entry.m_Component;
57 if (entry.m_sButtonID == name && comp)
58 return comp;
59 }
60
61 return null;
62 }
63
64 //------------------------------------------------------------------------------------------------
65 protected void OnNavigation(SCR_InputButtonComponent comp, string action)
66 {
67 m_OnAction.Invoke(comp, action, null, -1);
68 }
69
70 //------------------------------------------------------------------------------------------------
71 void SetButtonEnabled( string sButtonName, bool bEnable = true, string sName = "" )
72 {
73 SCR_InputButtonComponent pActionButton = GetButton( sButtonName );
74 if(!pActionButton)
75 return;
76
77 //if state is the same then quit early
78 if (pActionButton.IsEnabled() == bEnable)
79 return;
80
81 array<string> keyStack = {};
82 bEnable = bEnable && pActionButton.IsKeybindAvailable(keyStack);
83 pActionButton.SetEnabled(bEnable);
84 pActionButton.GetRootWidget().SetVisible(bEnable);
85
86 if(!sName.IsEmpty())
87 pActionButton.SetLabel(sName);
88 }
89
90 //------------------------------------------------------------------------------------------------
91 void SetButtonActionName( string sButtonName, string sName )
92 {
93 SCR_InputButtonComponent pActionButton = GetButton( sButtonName );
94 if( !pActionButton )
95 return;
96 pActionButton.SetLabel(sName);
97 }
98
99 //------------------------------------------------------------------------------------------------
100 void SetAllButtonEnabled( bool bEnable = true )
101 {
102 foreach ( NavigationButtonEntry entry: m_aEntries )
103 {
104 SCR_InputButtonComponent comp = entry.m_Component;
105 if (!comp)
106 return;
107
108 entry.m_Component.SetEnabled( bEnable );
109 entry.m_Component.GetRootWidget().SetVisible( bEnable );
110 }
111 }
112
113 //------------------------------------------------------------------------ COMMON METHODS ----------------------------------------------------------------------
114
116 {
117 if (m_sConfig.GetPath().IsEmpty())
118 return;
119
120 Resource res = BaseContainerTools.LoadContainer(m_sConfig);
121 if (!res)
122 return;
123
124 BaseContainer container = res.GetResource().ToBaseContainer();
125 if (!container)
126 return;
127
128 SCR_NavigationBarConfig config = SCR_NavigationBarConfig.Cast(BaseContainerTools.CreateInstanceFromContainer(container));
129 if (!config)
130 return;
131
132 m_aEntries.Clear();
133 m_aEntries = config.GetEntries();
135 }
136
137 protected void InitNavButtons()
138 {
139 foreach (NavigationButtonEntry entry : m_aEntries)
140 {
141 if (entry.m_sAction == "Inventory_Selected")
142 continue;
143
144 Widget button = GetGame().GetWorkspace().CreateWidgets(m_Layout, GetRootWidget());
145 if (!button)
146 continue;
147
149 if (!comp)
150 continue;
151
152 entry.m_Component = comp;
153 comp.SetAction(entry.m_sAction, forceUpdate: true);
154 comp.SetLabel(entry.m_sDisplayName);
155 comp.m_OnActivated.Insert(OnNavigation);
156 comp.SetClickedSound(string.Empty);
157 }
158 }
159
160 //------------------------------------------------------------------------------------------------
161 override void HandlerAttached( Widget w )
162 {
163 super.HandlerAttached(w);
164
166 }
167};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
bool IsKeybindAvailable(inout notnull array< string > keyStack)
bool SetAction(string action, EInputDeviceType currentInputDevice=-1, bool forceUpdate=false)
void SetLabel(string label)
PUBLIC API\.
override void SetEnabled(bool enabled, bool animate=true)
array< ref NavigationButtonEntry > GetEntries()
ref array< ref NavigationButtonEntry > m_aEntries
ref ScriptInvoker m_OnAction
void SetAllButtonEnabled(bool bEnable=true)
void SetButtonActionName(string sButtonName, string sName)
override void HandlerAttached(Widget w)
ref array< ref NavigationButtonEntry > m_aEntries
SCR_InputButtonComponent GetButton(string name)
void OnNavigation(SCR_InputButtonComponent comp, string action)
void SetButtonEnabled(string sButtonName, bool bEnable=true, string sName="")
SCR_FieldOfViewSettings Attribute
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134