Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MainMenuNewsToast.c
Go to the documentation of this file.
2{
3 [Attribute(uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(SCR_EPlatform))]
4 private SCR_EPlatform m_eHideOnPlatform;
5
6 protected const string LINK_FALLBACK = "https://reforger.armaplatform.com/news";
7
8 protected const string WIDGET_NAME_TITLE = "m_wTitle";
9 protected const string WIDGET_NAME_DESC = "m_wDescription";
10 protected const string WIDGET_NAME_BUTTON = "m_wButton";
11
15
16 protected string m_sMoreInfoLink;
17
18 protected bool m_bIsHovered;
19
20 //------------------------------------------------------------------------------------------------
21 override void HandlerAttached(Widget w)
22 {
23 super.HandlerAttached(w);
24
26 return;
27
28 EPlatform currentPlatform = System.GetPlatform();
29 w.SetVisible(false);
30
31 if ((m_eHideOnPlatform & (1 << currentPlatform)) == (1 << currentPlatform))
32 return;
33
36 }
37
38 //------------------------------------------------------------------------------------------------
39 protected void Init()
40 {
41 if (GetGame().GetBackendApi().GetNewsCount() < 1)
42 return;
43
44 NewsFeedItem newsItem = GetGame().GetBackendApi().GetNewsItem(0);
45 if (!newsItem)
46 return;
47
48 m_wRoot.SetVisible(true);
49
50 m_wTitle = TextWidget.Cast(m_wRoot.FindAnyWidget(WIDGET_NAME_TITLE));
52
53 m_wTitle.SetText(newsItem.Title());
54 m_wDescription.SetText(newsItem.Date());
55
56 Widget buttonWidget = m_wRoot.FindAnyWidget(WIDGET_NAME_BUTTON);
57 if (!buttonWidget)
58 return;
59
60 m_sMoreInfoLink = newsItem.URL();
61 if (m_sMoreInfoLink.IsEmpty())
63
66 m_MoreInfoButton.m_OnActivated.Insert(OnMoreInfo);
67
68 if (GetGame().GetGameInstallStatus() != 1.0)
69 m_wRoot.SetVisible(0);
70 }
71
72 //------------------------------------------------------------------------------------------------
73 bool IsHovered()
74 {
75 return m_bIsHovered;
76 }
77
78 //------------------------------------------------------------------------------------------------
79 override bool OnMouseEnter(Widget w, int x, int y)
80 {
81 m_bIsHovered = true;
82 return super.OnMouseEnter(w, x, y);
83 }
84
85 //------------------------------------------------------------------------------------------------
86 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
87 {
88 m_bIsHovered = false;
89 return super.OnMouseLeave(w, enterW, x, y);
90 }
91
92 //------------------------------------------------------------------------------------------------
93 protected void OnMoreInfo()
94 {
95 float xPos, yPos, width, height;
96 m_wRoot.GetScreenPos(xPos, yPos);
97 m_wRoot.GetWorkspace().GetScreenSize(width, height);
98
99 GetGame().GetWorkspace().DPIUnscale(xPos);
100 GetGame().GetWorkspace().DPIUnscale(yPos);
101
102 if (xPos < 0 || yPos < 0 || xPos > width || yPos > height)
103 return;
104
105 GetGame().GetPlatformService().OpenBrowser(m_sMoreInfoLink);
106 }
107
108 //------------------------------------------------------------------------------------------------
109 protected void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
110 {
112 Init();
113 }
114}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_ECommStatus
This class may become obsolete on BackendAPI update.
New Feed data structure.
static bool IsEditMode()
Definition Functions.c:1566
SCR_InputButtonComponent m_MoreInfoButton
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
override void HandlerAttached(Widget w)
static ScriptInvokerCommStatus GetOnCommStatusCheckFinished()
SCR_FieldOfViewSettings Attribute
EPlatform
Definition EPlatform.c:13