Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BrowserLinkComponent.c
Go to the documentation of this file.
1 class SCR_BrowserLinkComponent : ScriptedWidgetComponent
2 {
3  [Attribute("Link_Bohemia")]
4  protected string m_sAddress;
5 
6  [Attribute("false")]
7  protected bool m_bIsURL;
8 
9  protected SCR_ButtonBaseComponent m_Button;
10 
11  //------------------------------------------------------------------------------------------------
12  override void HandlerAttached(Widget w)
13  {
14  super.HandlerAttached(w);
15 
16  m_Button = SCR_ButtonBaseComponent.Cast(w.FindHandler(SCR_ButtonBaseComponent));
17  if (m_Button)
18  {
19  SCR_ServicesStatusHelper.RefreshPing();
20  SCR_ServicesStatusHelper.GetOnCommStatusCheckFinished().Insert(OnCommStatusCheckFinished);
21 
22  m_Button.SetEnabled(SCR_ServicesStatusHelper.IsBackendConnectionAvailable());
23  }
24  }
25 
26  //------------------------------------------------------------------------------------------------
27  override void HandlerDeattached(Widget w)
28  {
29  super.HandlerDeattached(w);
30  }
31 
32  //------------------------------------------------------------------------------------------------
33  override bool OnClick(Widget w, int x, int y, int button)
34  {
35  return OpenBrowser();
36  }
37 
38  //------------------------------------------------------------------------------------------------
39  protected void OnCommStatusCheckFinished(SCR_ECommStatus status, float responseTime, float lastSuccessTime, float lastFailTime)
40  {
41  if (m_Button)
42  m_Button.SetEnabled(SCR_ServicesStatusHelper.IsBackendConnectionAvailable());
43  }
44 
45  //------------------------------------------------------------------------------------------------
46  bool OpenBrowser()
47  {
48  PlatformService ps = GetGame().GetPlatformService();
49 
50  if (!ps)
51  return false;
52 
53  BackendApi backendAPI = GetGame().GetBackendApi();
54  string url = backendAPI.GetLinkItem(m_sAddress);
55 
56  if (m_bIsURL)
57  ps.OpenBrowser(m_sAddress);
58  else
59  ps.OpenBrowser(url);
60 
61  return true;
62  }
63 };
SCR_ECommStatus
SCR_ECommStatus
This class may become obsolete on BackendAPI update.
Definition: SCR_ServicesStatusHelper.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_ButtonBaseComponent
Base class for any button, regardless its own content.
Definition: SCR_ButtonBaseComponent.c:3
SCR_ServicesStatusHelper
Definition: SCR_ServicesStatusHelper.c:15