Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_NewsSubMenu.c
Go to the documentation of this file.
3 {
4  NewsFeedItem m_Item;
6  Widget m_wRoot;
7  bool m_bRead;
8 
9  void SCR_NewsEntry(NewsFeedItem item)
10  {
11  m_Item = item;
12  }
13 
14  void SetTile(SCR_NewsTileComponent tile, Widget w)
15  {
16  m_Tile = tile;
17  m_wRoot = w;
18  }
19 }
20 
21 class SCR_NewsSubMenu : SCR_SubMenuBase
22 {
23  [Attribute("{02155A85F2DC521F}UI/layouts/Menus/PlayMenu/PlayMenuTile.layout", UIWidgets.ResourceNamePicker, "", "layout")]
24  protected ResourceName m_Layout;
25 
26  protected static ref array<ref SCR_NewsEntry> m_aEntries = {};
27 
30 
31  //------------------------------------------------------------------------------------------------
32  override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
33  {
34  super.OnTabCreate(menuRoot, buttonsLayout, index);
35 
36  m_Gallery = SCR_GalleryComponent.GetGalleryComponent("Gallery", m_wRoot);
37 
38  Widget simpleMessageRoot = m_wRoot.FindAnyWidget("SimpleMessage");
39  if (simpleMessageRoot)
40  m_SimpleMessage = SCR_SimpleMessageComponent.Cast(simpleMessageRoot.FindHandler(SCR_SimpleMessageComponent));
41 
42  SCR_ServicesStatusHelper.RefreshPing();
43  SCR_ServicesStatusHelper.GetOnCommStatusCheckFinished().Insert(OnCommStatusCheckFinished);
44  }
45 
46  //------------------------------------------------------------------------------------------------
47  override void OnTabShow()
48  {
49  super.OnTabShow();
50 
51  if (m_SimpleMessage && SCR_ServicesStatusHelper.GetLastReceivedCommStatus() != SCR_ECommStatus.FINISHED && m_aEntries.IsEmpty())
52  m_SimpleMessage.SetVisible(true);
53  else
55  }
56 
57  //------------------------------------------------------------------------------------------------
58  override void OnTabRemove()
59  {
60  super.OnTabRemove();
61  SCR_ServicesStatusHelper.GetOnCommStatusCheckFinished().Remove(OnCommStatusCheckFinished);
62  }
63 
64  //------------------------------------------------------------------------------------------------
65  protected void SetNewsEntries()
66  {
67  MainMenuUI.GetNewsEntries(m_aEntries);
68 
69  if (m_aEntries.IsEmpty())
70  {
72  return;
73  }
74 
75  if (m_SimpleMessage)
76  m_SimpleMessage.SetVisible(false);
77 
78  m_Gallery.ClearAll();
79 
80  foreach (SCR_NewsEntry entry : m_aEntries)
81  {
82  Widget w = GetGame().GetWorkspace().CreateWidgets(m_Layout);
83  if (!w)
84  continue;
85 
87  if (!tile)
88  continue;
89 
90  entry.SetTile(tile, tile.m_wRoot);
91  tile.m_OnRead.Insert(OnRead);
92  tile.ShowTile(entry);
93 
94  m_Gallery.AddItem(w);
95  }
96  }
97 
98  //------------------------------------------------------------------------------------------------
99  protected void OnRead(SCR_NewsTileComponent comp)
100  {
101  string url = comp.m_Entry.m_Item.URL();
102  if (url.IsEmpty())
103  return;
104 
105  GetGame().GetPlatformService().OpenBrowser(url);
106  }
107 
108  //------------------------------------------------------------------------------------------------
109  protected void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
110  {
111  if (!m_bShown)
112  return;
113 
114  if (status == SCR_ECommStatus.FINISHED)
115  SetNewsEntries();
116  else
117  ShowErrorDialog();
118  }
119 
120  //------------------------------------------------------------------------------------------------
121  protected void ShowErrorDialog()
122  {
123  if (!m_bShown)
124  return;
125 
126  SCR_ConfigurableDialogUi dialog = SCR_CommonDialogs.CreateTimeoutOkDialog();
127  if (dialog)
128  dialog.m_OnConfirm.Insert(OnErrorDialogClose);
129  }
130 
131  //------------------------------------------------------------------------------------------------
132  protected void OnErrorDialogClose()
133  {
134  if (!m_bShown)
135  return;
136 
137  RequestTabChange(SCR_EProfileSuperMenuTabId.COMMUNITY);
138  }
139 }
m_bShown
protected bool m_bShown
Definition: SCR_InfoDisplay.c:61
m_Tile
SCR_NewsTileComponent m_Tile
Definition: SCR_NewsSubMenu.c:3
SCR_ECommStatus
SCR_ECommStatus
This class may become obsolete on BackendAPI update.
Definition: SCR_ServicesStatusHelper.c:2
m_wRoot
Widget m_wRoot
Definition: SCR_NewsSubMenu.c:4
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
m_SimpleMessage
protected SCR_SimpleMessageComponent m_SimpleMessage
Definition: SCR_NewsSubMenu.c:29
m_Item
NewsFeedItem m_Item
Definition: SCR_NewsSubMenu.c:2
OnTabShow
override void OnTabShow()
Definition: SCR_NewsSubMenu.c:47
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
Attribute
class SCR_NewsEntry Attribute("{02155A85F2DC521F}UI/layouts/Menus/PlayMenu/PlayMenuTile.layout", UIWidgets.ResourceNamePicker, "", "layout")] protected ResourceName m_Layout
SCR_CommonDialogs
Definition: CommonDialogs.c:5
SCR_NewsTileComponent
Definition: SCR_NewsTileComponent.c:1
m_Layout
ResourceName m_Layout
Definition: SCR_ActionsToolbarEditorUIComponent.c:6
SCR_SubMenuBase
Definition: SCR_SubMenuBase.c:6
OnRead
protected void OnRead(SCR_NewsTileComponent comp)
Definition: SCR_NewsSubMenu.c:99
m_Gallery
protected SCR_GalleryComponent m_Gallery
Definition: SCR_NewsSubMenu.c:28
OnTabCreate
override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
Definition: SCR_NewsSubMenu.c:32
SCR_NewsEntry
Definition: SCR_NewsSubMenu.c:2
m_aEntries
protected ref array< ref SCR_TextsTaskManagerEntry > m_aEntries
Definition: SCR_TextsTaskManagerComponent.c:3
MainMenuUI
Definition: MainMenuUI.c:1
OnTabRemove
override void OnTabRemove()
Definition: SCR_NewsSubMenu.c:58
ShowErrorDialog
protected void ShowErrorDialog()
Definition: SCR_NewsSubMenu.c:121
SCR_ServicesStatusHelper
Definition: SCR_ServicesStatusHelper.c:15
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SetNewsEntries
protected void SetNewsEntries()
Definition: SCR_NewsSubMenu.c:65
OnErrorDialogClose
protected void OnErrorDialogClose()
Definition: SCR_NewsSubMenu.c:132
SCR_SimpleMessageComponent
Definition: SCR_SimpleMessageComponent.c:1
SCR_ConfigurableDialogUi
Definition: SCR_ConfigurableDialogUI.c:13
SCR_EProfileSuperMenuTabId
SCR_EProfileSuperMenuTabId
Definition: SCR_ProfileSuperMenu.c:1
OnCommStatusCheckFinished
protected void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
Definition: SCR_NewsSubMenu.c:109
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