Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ScenarioDialogs.c
Go to the documentation of this file.
1 
4 void ScriptInvokerMissionWorkshopItemMethod(MissionWorkshopItem item);
6 typedef ScriptInvokerBase<ScriptInvokerMissionWorkshopItemMethod> ScriptInvokerMissionWorkshopItem;
7 
8 //------------------------------------------------------------------------------------------------
10 {
11  static protected const ResourceName DIALOGS_CONFIG = "{F020A20CC93DB3C7}Configs/ContentBrowser/ScenarioDialogs.conf";
12 
13  //------------------------------------------------------------------------------------------------
14  static SCR_ConfigurableDialogUi CreateDialog(string presetName)
15  {
16  return SCR_ConfigurableDialogUi.CreateFromPreset(DIALOGS_CONFIG, presetName);
17  }
18 
19  //------------------------------------------------------------------------------------------------
20  static SCR_ScenarioConfirmationDialogUi CreateScenarioConfirmationDialog(MissionWorkshopItem scenario, ScriptInvokerBool onFavoritesResponse = null)
21  {
22  SCR_ScenarioConfirmationDialogUi dialogUI = new SCR_ScenarioConfirmationDialogUi(scenario, onFavoritesResponse);
23  SCR_ConfigurableDialogUi.CreateFromPreset(DIALOGS_CONFIG, "SCENARIO_CONFIRMATION", dialogUI);
24 
25  return dialogUI;
26  }
27 }
28 
29 //------------------------------------------------------------------------------------------------
31 {
32  MissionWorkshopItem m_Scenario;
33 
37  protected ref array<SCR_InputButtonComponent> m_aRightFooterButtons = {};
38 
39  protected SCR_ModularButtonComponent m_FavoriteStarButton;
40 
42  protected bool m_bHandleFavoriting = true;
43 
45 
46  //This should probably be a setting in SCR_HorizontalScrollAnimationComponent, as this is a bandaid solution to the title flickering
47  protected const int MAX_TITLE_LENGTH = 55;
48 
49  //------------------------------------------------------------------------------------------------
50  void SCR_ScenarioConfirmationDialogUi(MissionWorkshopItem scenario, ScriptInvokerBool onFavoritesResponse = null)
51  {
52  m_Scenario = scenario;
53 
54  if (onFavoritesResponse)
55  {
56  m_bHandleFavoriting = false;
57  onFavoritesResponse.Insert(UpdateFavoriteWidgets);
58  }
59  }
60 
62  //------------------------------------------------------------------------------------------------
64  {
65  super.OnMenuOpen(preset);
66 
67  if (!m_Scenario)
68  return;
69 
70  // Connection state
71  SCR_ServicesStatusHelper.RefreshPing();
72  SCR_ServicesStatusHelper.GetOnCommStatusCheckFinished().Insert(OnCommStatusCheckFinished);
73 
75  SetTitle(m_Scenario.Name());
76 
77  Widget backgroundImageBackend = GetRootWidget().FindAnyWidget("BackgroundImageBackend");
78  if (backgroundImageBackend)
79  {
80  SCR_ScenarioBackendImageComponent backendImageComp = SCR_ScenarioBackendImageComponent.Cast(backgroundImageBackend.FindHandler(SCR_ScenarioBackendImageComponent));
81  if (backendImageComp)
82  backendImageComp.SetScenarioAndImage(m_Scenario, m_Scenario.Thumbnail());
83  }
84 
86  Widget contentLayoutRoot = GetContentLayoutRoot(GetRootWidget());
87  if (!contentLayoutRoot)
88  return;
89 
90  Widget singlePlayerImage = contentLayoutRoot.FindAnyWidget("SinglePlayerImageOverlay");
91  Widget multiPlayerImage = contentLayoutRoot.FindAnyWidget("MultiPlayerImageOverlay");
92  TextWidget playerCountLabelText = TextWidget.Cast(contentLayoutRoot.FindAnyWidget("PlayerCountLabelText"));
93 
94  Widget sourceImageOfficial = contentLayoutRoot.FindAnyWidget("SourceImageOfficialOverlay");
95  Widget sourceImageCommunity = contentLayoutRoot.FindAnyWidget("SourceImageCommunityOverlay");
96  TextWidget sourceNameTextOfficial = TextWidget.Cast(contentLayoutRoot.FindAnyWidget("SourceNameTextOfficial"));
97  TextWidget sourceNameTextCommunity = TextWidget.Cast(contentLayoutRoot.FindAnyWidget("SourceNameTextCommunity"));
98 
100  int playerCount = m_Scenario.GetPlayerCount();
101  bool mp = SCR_ScenarioEntryHelper.IsMultiplayer(m_Scenario);
102  singlePlayerImage.SetVisible(!mp);
103  multiPlayerImage.SetVisible(mp);
104 
105  playerCountLabelText.SetText(WidgetManager.Translate("#AR-Scenario_Players", playerCount.ToString()));
106 
108  bool isSourceAddonValid;
109  WorkshopItem sourceAddon = m_Scenario.GetOwner();
110 
111  if (sourceAddon)
112  {
113  isSourceAddonValid = true;
114  sourceNameTextCommunity.SetText(sourceAddon.Name());
115  }
116  else
117  {
118  isSourceAddonValid = false;
119  }
120 
121  sourceImageOfficial.SetVisible(!isSourceAddonValid);
122  sourceImageCommunity.SetVisible(isSourceAddonValid);
123  sourceNameTextOfficial.SetVisible(!isSourceAddonValid);
124  sourceNameTextCommunity.SetVisible(isSourceAddonValid);
125 
127  SCR_ScenarioEntryHelper.UpdateInputButtons(m_Scenario, m_aRightFooterButtons);
128 
129  m_FindServers = FindButton(SCR_ScenarioEntryHelper.BUTTON_FIND_SERVERS);
130  m_Host = FindButton(SCR_ScenarioEntryHelper.BUTTON_HOST);
131 
132  m_Favorite = FindButton(SCR_ScenarioEntryHelper.BUTTON_FAVORITE);
133  if (m_Favorite)
134  m_Favorite.m_OnActivated.Insert(OnFavoritesButton);
135 
137  Widget favButton = m_wRoot.FindAnyWidget("FavoriteButton");
138  if (favButton)
139  {
140  m_FavoriteStarButton = SCR_ModularButtonComponent.FindComponent(favButton);
142  m_FavoriteStarButton.m_OnClicked.Insert(OnFavoritesButton);
143  }
144 
146  UpdateFavoriteWidgets(m_Scenario.IsFavorite());
147  }
148 
149  //----------------------------------------------------------------------------------------
150  override void OnMenuClose()
151  {
152  SCR_ServicesStatusHelper.GetOnCommStatusCheckFinished().Remove(OnCommStatusCheckFinished);
153  }
154 
155  //------------------------------------------------------------------------------------------------
157  {
158  if (GetButtonTag(button) == SCR_ScenarioEntryHelper.BUTTON_FAVORITE)
159  return; // We use a specific invoker for favorites button
160 
161  super.OnButtonPressed(button);
162 
163  bool close = true;
164  SCR_EScenarioEntryErrorState state = SCR_ScenarioEntryHelper.GetErrorState(m_Scenario);
165  bool error = SCR_ScenarioEntryHelper.IsInErrorState(state);
166 
167  switch (m_sLastPressedButtonTag)
168  {
169  case SCR_ScenarioEntryHelper.BUTTON_FIND_SERVERS: close = !error; break;
170  case SCR_ScenarioEntryHelper.BUTTON_HOST: close = !error; break;
171  }
172 
173  if (close)
174  Close();
175  }
176 
177  //------------------------------------------------------------------------------------------------
178  override void SetTitle(string text)
179  {
180  super.SetTitle(text);
181 
182  Widget titleFrame = m_wRoot.FindAnyWidget("TitleFrame");
183  if (!titleFrame)
184  return;
185 
187  if (!scrollComp)
188  return;
189 
190  if (text.Length() < MAX_TITLE_LENGTH)
191  scrollComp.AnimationStop();
192  else
193  scrollComp.AnimationStart();
194  }
195 
196  //------------------------------------------------------------------------------------------------
198  {
199  SCR_InputButtonComponent comp = super.CreateButton(buttonPreset);
200 
201  Widget w;
202  if (comp)
203  w = comp.GetRootWidget();
204 
205  if (w)
206  w.SetName(buttonPreset.m_sTag);
207 
208  if (buttonPreset.m_eAlign == EConfigurableDialogUiButtonAlign.RIGHT)
209  m_aRightFooterButtons.Insert(comp);
210 
211  return comp;
212  }
213 
215  //------------------------------------------------------------------------------------------------
216  protected void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
217  {
218  if (m_FindServers)
219  SCR_ScenarioEntryHelper.UpdateInputButton(m_FindServers, m_Scenario);
220 
221  if (m_Host)
222  SCR_ScenarioEntryHelper.UpdateInputButton(m_Host, m_Scenario);
223  }
224 
225  //------------------------------------------------------------------------------------------------
226  protected void OnFavoritesButton()
227  {
228  if (!m_Scenario)
229  return;
230 
232  {
233  m_OnFavorite.Invoke(m_Scenario);
234  return;
235  }
236 
237  bool isFavorite = !m_Scenario.IsFavorite();
238  m_Scenario.SetFavorite(isFavorite);
239  UpdateFavoriteWidgets(isFavorite);
240  }
241 
242  //------------------------------------------------------------------------------------------------
243  protected void UpdateFavoriteWidgets(bool isFavorite)
244  {
245  // Footer Button
246  string label = UIConstants.FAVORITE_LABEL_ADD;
247  if (isFavorite)
248  label = UIConstants.FAVORITE_LABEL_REMOVE;
249 
250  m_Favorite.SetLabel(label);
251 
252  // Star Button
254  m_FavoriteStarButton.SetToggled(isFavorite, false);
255  }
256 
258  //------------------------------------------------------------------------------------------------
259  MissionWorkshopItem GetScenario()
260  {
261  return m_Scenario;
262  }
263 
264  //------------------------------------------------------------------------------------------------
266  {
267  if (!m_OnFavorite)
269 
270  return m_OnFavorite;
271  }
272 }
SCR_ECommStatus
SCR_ECommStatus
This class may become obsolete on BackendAPI update.
Definition: SCR_ServicesStatusHelper.c:2
m_Favorite
protected SCR_InputButtonComponent m_Favorite
Definition: SCR_ScenarioDialogs.c:34
SCR_HorizontalScrollAnimationComponent
Definition: SCR_HorizontalScrollAnimationComponent.c:14
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
ScriptInvokerMissionWorkshopItemMethod
func ScriptInvokerMissionWorkshopItemMethod
Definition: SCR_ScenarioDialogs.c:5
SCR_ConfigurableDialogUiButtonPreset
Configuration for a button.
Definition: SCR_ConfigurableDialogUI.c:782
m_aRightFooterButtons
protected ref array< SCR_InputButtonComponent > m_aRightFooterButtons
Definition: SCR_ScenarioDialogs.c:37
UIConstants
Definition: Constants.c:130
m_FindServers
protected SCR_InputButtonComponent m_FindServers
Definition: SCR_ScenarioDialogs.c:36
m_bHandleFavoriting
protected bool m_bHandleFavoriting
If true, the dialog itself will set the scenario favorite state, otherwise it will live it to the men...
Definition: SCR_ScenarioDialogs.c:42
GetScenario
MissionWorkshopItem GetScenario()
PUBLIC.
Definition: SCR_ScenarioDialogs.c:259
EConfigurableDialogUiButtonAlign
EConfigurableDialogUiButtonAlign
Configuration for button alignment.
Definition: SCR_ConfigurableDialogUI.c:756
CreateButton
override SCR_InputButtonComponent CreateButton(SCR_ConfigurableDialogUiButtonPreset buttonPreset)
Definition: SCR_ScenarioDialogs.c:197
m_Host
protected SCR_InputButtonComponent m_Host
Definition: SCR_ScenarioDialogs.c:35
func
func
Definition: SCR_AIThreatSystem.c:5
SCR_EScenarioEntryErrorState
SCR_EScenarioEntryErrorState
Definition: SCR_ScenarioEntryHelper.c:419
m_OnFavorite
protected ref ScriptInvokerMissionWorkshopItem m_OnFavorite
Definition: SCR_ScenarioDialogs.c:44
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
OnCommStatusCheckFinished
protected void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
PROTECTED.
Definition: SCR_ScenarioDialogs.c:216
UpdateFavoriteWidgets
protected void UpdateFavoriteWidgets(bool isFavorite)
Definition: SCR_ScenarioDialogs.c:243
OnMenuOpen
override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
OVERRIDES.
Definition: SCR_ScenarioDialogs.c:63
m_FavoriteStarButton
protected SCR_ModularButtonComponent m_FavoriteStarButton
Definition: SCR_ScenarioDialogs.c:39
ScriptInvokerBool
ScriptInvokerBase< ScriptInvokerBoolMethod > ScriptInvokerBool
Definition: SCR_ScriptInvokerHelper.c:41
OnFavoritesButton
protected void OnFavoritesButton()
Definition: SCR_ScenarioDialogs.c:226
SCR_ScenarioConfirmationDialogUi
void SCR_ScenarioConfirmationDialogUi(MissionWorkshopItem scenario, ScriptInvokerBool onFavoritesResponse=null)
Definition: SCR_ScenarioDialogs.c:50
SCR_ConfigurableDialogUiPreset
Configuration for a dialog.
Definition: SCR_ConfigurableDialogUI.c:809
MAX_TITLE_LENGTH
const protected int MAX_TITLE_LENGTH
Definition: SCR_ScenarioDialogs.c:47
ScriptInvokerMissionWorkshopItem
ScriptInvokerBase< ScriptInvokerMissionWorkshopItemMethod > ScriptInvokerMissionWorkshopItem
Definition: SCR_ScenarioDialogs.c:6
SCR_ServicesStatusHelper
Definition: SCR_ServicesStatusHelper.c:15
SCR_ScenarioDialogs
Definition: SCR_ScenarioDialogs.c:9
SCR_ConfigurableDialogUi
Definition: SCR_ConfigurableDialogUI.c:13
OnMenuClose
override void OnMenuClose()
Definition: SCR_ScenarioDialogs.c:150
GetOnFavorite
ScriptInvokerMissionWorkshopItem GetOnFavorite()
Definition: SCR_ScenarioDialogs.c:265
FindButton
SCR_InputButtonComponent FindButton(string tag)
Returns a button with given tag.
Definition: SCR_BrowserHoverTooltipComponent.c:116
m_Scenario
class SCR_ScenarioDialogs m_Scenario
OnButtonPressed
override void OnButtonPressed(SCR_InputButtonComponent button)
Definition: SCR_ScenarioDialogs.c:156
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1
SetTitle
override void SetTitle(string text)
Definition: SCR_ScenarioDialogs.c:178