Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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")]
36  protected ResourceName m_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")]
42  ResourceName m_sConfig;
43 
44  ref ScriptInvoker m_OnAction = new ScriptInvoker;
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  pActionButton.SetEnabled( bEnable );
77  pActionButton.GetRootWidget().SetVisible( bEnable );
78 
79  if( !sName.IsEmpty() )
80  pActionButton.SetLabel(sName);
81  }
82 
83  //------------------------------------------------------------------------------------------------
84  void SetButtonActionName( string sButtonName, string sName )
85  {
86  SCR_InputButtonComponent pActionButton = GetButton( sButtonName );
87  if( !pActionButton )
88  return;
89  pActionButton.SetLabel(sName);
90  }
91 
92  //------------------------------------------------------------------------------------------------
93  void SetAllButtonEnabled( bool bEnable = true )
94  {
95  foreach ( NavigationButtonEntry entry: m_aEntries )
96  {
97  SCR_InputButtonComponent comp = entry.m_Component;
98  if (!comp)
99  return;
100 
101  entry.m_Component.SetEnabled( bEnable );
102  entry.m_Component.GetRootWidget().SetVisible( bEnable );
103  }
104  }
105 
106  //------------------------------------------------------------------------ COMMON METHODS ----------------------------------------------------------------------
107 
108  void FillFromConfig()
109  {
110  if (m_sConfig.GetPath().IsEmpty())
111  return;
112 
113  Resource res = BaseContainerTools.LoadContainer(m_sConfig);
114  if (!res)
115  return;
116 
117  BaseContainer container = res.GetResource().ToBaseContainer();
118  if (!container)
119  return;
120 
121  SCR_NavigationBarConfig config = SCR_NavigationBarConfig.Cast(BaseContainerTools.CreateInstanceFromContainer(container));
122  if (!config)
123  return;
124 
125  m_aEntries.Clear();
126  m_aEntries = config.GetEntries();
127  InitNavButtons();
128  }
129 
130  protected void InitNavButtons()
131  {
132  foreach (NavigationButtonEntry entry : m_aEntries)
133  {
134  if (entry.m_sAction == "Inventory_Selected")
135  continue;
136 
137  Widget button = GetGame().GetWorkspace().CreateWidgets(m_Layout, GetRootWidget());
138  if (!button)
139  continue;
140 
142  if (!comp)
143  continue;
144 
145  entry.m_Component = comp;
146  comp.SetAction(entry.m_sAction);
147  comp.SetLabel(entry.m_sDisplayName);
148  comp.m_OnActivated.Insert(OnNavigation);
149  comp.SetClickedSound("");
150  }
151  }
152 
153  //------------------------------------------------------------------------------------------------
154  override void HandlerAttached( Widget w )
155  {
156  super.HandlerAttached(w);
157 
158  InitNavButtons();
159  }
160 };
SCR_NavigationBarConfig
Definition: SCR_NavigationBarUI.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
m_OnAction
protected ref ScriptInvokerAction m_OnAction
Definition: SCR_MenuActionsComponent.c:15
m_sConfig
protected ResourceName m_sConfig
Definition: SCR_GMMenu.c:30
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
SCR_NavigationBarUI
Definition: SCR_NavigationBarUI.c:31
m_aEntries
protected ref array< ref SCR_TextsTaskManagerEntry > m_aEntries
Definition: SCR_TextsTaskManagerComponent.c:3
Attribute
typedef Attribute
Post-process effect of scripted camera.
NavigationButtonEntry
Definition: SCR_NavigationBarUI.c:15
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7
LocalizedString
Definition: LocalizedString.c:21
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468