Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SelectionMenuEntry.c
Go to the documentation of this file.
1 
5 //------------------------------------------------------------------------------------------------
8 {
9  const string DEFAULT_IMAGE_SET = "{3262679C50EF4F01}UI/Textures/Icons/icons_wrapperUI.imageset";
10 
11  [Attribute(desc: "Entry name used for searching and definition")]
12  protected string m_sId;
13 
14  [Attribute("1")]
15  protected bool m_bEnabled;
16 
17  [Attribute(desc: "Action name use as input shortcut for entry")]
18  protected string m_sInputAction;
19 
20  [Attribute("", ".layout", desc: "By default menu has predefined layouts. Use only if specific layout for entry is needed")]
21  protected ResourceName m_sCustomLayout;
22 
23  protected ref SCR_SelectionMenuEntryComponent m_EntryComponent;
24 
25  // Invokers
26  protected ref ScriptInvoker<SCR_SelectionMenuEntry> m_OnPerform;
27  protected ref ScriptInvoker<SCR_SelectionMenuEntry> m_OnPerformFail;
28  protected ref ScriptInvoker<SCR_SelectionMenuEntry, ResourceName, string> m_OnIconChange;
29 
30  //------------------------------------------------------------------------------------------------
31  protected void InvokeOnPerform()
32  {
33  if (m_OnPerform)
34  m_OnPerform.Invoke(this);
35  }
36 
37  //------------------------------------------------------------------------------------------------
38  ScriptInvoker GetOnPerform()
39  {
40  if (!m_OnPerform)
41  m_OnPerform = new ScriptInvoker();
42 
43  return m_OnPerform;
44  }
45 
46  //------------------------------------------------------------------------------------------------
47  protected void InvokeOnPerformFail()
48  {
49  if (m_OnPerformFail)
50  m_OnPerformFail.Invoke(this);
51  }
52 
53  //------------------------------------------------------------------------------------------------
54  ScriptInvoker GetOnPerformFail()
55  {
56  if (!m_OnPerformFail)
57  m_OnPerformFail = new ScriptInvoker();
58 
59  return m_OnPerformFail;
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  protected void InvokeOnIconChange(ResourceName icon, string imageSetImage)
64  {
65  if (m_OnIconChange)
66  m_OnIconChange.Invoke(this, icon, imageSetImage);
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  ScriptInvoker GetOnIconChange()
71  {
72  if (!m_OnIconChange)
73  m_OnIconChange = new ScriptInvoker();
74 
75  return m_OnIconChange;
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  // Custom methods
80  //------------------------------------------------------------------------------------------------
81 
82  //------------------------------------------------------------------------------------------------
84  void Update()
85  {
86  }
87 
88  //------------------------------------------------------------------------------------------------
91  void Perform()
92  {
93  // Check can be performed
94  if (!m_bEnabled)
95  {
96  InvokeOnPerformFail();
97  return;
98  }
99 
100  OnPerform();
101  InvokeOnPerform();
102  }
103 
104  //------------------------------------------------------------------------------------------------
106  protected void OnPerform()
107  {
108  }
109 
110  //------------------------------------------------------------------------------------------------
111  void Enable(bool enable)
112  {
113  m_bEnabled = enable;
114 
115  if (m_EntryComponent)
116  m_EntryComponent.SetEnabled(enable);
117  }
118 
119  //------------------------------------------------------------------------------------------------
120  // Callbacks
121  //------------------------------------------------------------------------------------------------
122 
123  //------------------------------------------------------------------------------------------------
124  protected void OnEntryClick(SCR_SelectionMenuEntryComponent entryComponent)
125  {
126  Perform();
127  }
128 
129  //------------------------------------------------------------------------------------------------
130  // Get set
131  //------------------------------------------------------------------------------------------------
132 
133  //------------------------------------------------------------------------------------------------
134  void SetId(string id)
135  {
136  m_sId = id;
137  }
138 
139  //------------------------------------------------------------------------------------------------
140  string GetId()
141  {
142  if (m_sId.IsEmpty())
143  Print("Selection menu entry has enmpty id", LogLevel.WARNING);
144 
145  return m_sId;
146  }
147 
148  //------------------------------------------------------------------------------------------------
149  void SetName(string name)
150  {
151  Name = name;
152  }
153 
154  //------------------------------------------------------------------------------------------------
155  void SetDescription(string description)
156  {
157  Description = description;
158  }
159 
160  //------------------------------------------------------------------------------------------------
162  void SetIcon(ResourceName iconPath, string imageSetName = "")
163  {
164  Icon = iconPath;
165  IconSetName = imageSetName;
166 
167  InvokeOnIconChange(Icon, IconSetName);
168  }
169 
170  //------------------------------------------------------------------------------------------------
171  void SetIconFromDeafaultImageSet(string imageSetName = "")
172  {
173  Icon = DEFAULT_IMAGE_SET;
174  IconSetName = imageSetName;
175 
176  InvokeOnIconChange(Icon, IconSetName);
177  }
178 
179  //------------------------------------------------------------------------------------------------
180  ResourceName GetCustomLayout()
181  {
182  return m_sCustomLayout;
183  }
184 
185  //------------------------------------------------------------------------------------------------
186  void SetCustomLayout(ResourceName layout)
187  {
188  m_sCustomLayout = layout;
189  }
190 
191  //------------------------------------------------------------------------------------------------
192  void SetEntryComponent(SCR_SelectionMenuEntryComponent entryComponent)
193  {
194  // Clear
195  if (m_EntryComponent)
196  m_EntryComponent.GetOnClick().Clear();
197 
198 
199  m_EntryComponent = entryComponent;
200 
201  // Setup invokers
202  if (m_EntryComponent)
203  m_EntryComponent.GetOnClick().Insert(OnEntryClick);
204 
205 
206  // Setup icons - TODO: probably can be moved to seperate component
208  if (iconEntry)
209  iconEntry.SetImage(Icon, IconSetName);
210 
211  entryComponent.SetEntry(this);
212  }
213 
214  //------------------------------------------------------------------------------------------------
215  SCR_SelectionMenuEntryComponent GetEntryComponent()
216  {
217  return m_EntryComponent;
218  }
219 
220  //------------------------------------------------------------------------------------------------
221  bool IsEnabled()
222  {
223  return m_bEnabled;
224  }
225 
226  //------------------------------------------------------------------------------------------------
227  void SetInputAction(string action)
228  {
229  m_sInputAction = action;
230  }
231 
232  //------------------------------------------------------------------------------------------------
233  string GetInputAction()
234  {
235  return m_sInputAction;
236  }
237 
238  //------------------------------------------------------------------------------------------------
239  // Constructor
240  //------------------------------------------------------------------------------------------------
241 
242  //------------------------------------------------------------------------------------------------
244  {
245  m_bEnabled = true;
246 
247  if (Icon.IsEmpty())
248  Icon = DEFAULT_IMAGE_SET;
249  }
250 };
SCR_SelectionMenuEntryIconComponent
Definition: SCR_SelectionMenuEntryIconComponent.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_SelectionMenuEntryComponent
Definition: SCR_SelectionMenuEntryComponent.c:6
SCR_UIInfo
Definition: SCR_UIInfo.c:7
layout
UI layouts HUD CampaignMP CampaignMainHUD layout
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:20
m_bEnabled
private bool m_bEnabled
Definition: SCR_BaseManualCameraComponent.c:3
SCR_SelectionMenuEntry
Definition: SCR_SelectionMenuEntry.c:7
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
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