Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AccountWidgetComponent.c
Go to the documentation of this file.
2 {
3  [Attribute(UIColors.GetColorAttribute(UIColors.CONFIRM), UIWidgets.ColorPicker)]
4  protected ref Color m_ColorOnline;
5 
6  [Attribute(UIColors.GetColorAttribute(UIColors.NEUTRAL_ACTIVE_STANDBY), UIWidgets.ColorPicker)]
7  protected ref Color m_ColorOffline;
8 
9  [Attribute(UIColors.GetColorAttribute(UIColors.NEUTRAL_ACTIVE_STANDBY), UIWidgets.ColorPicker)]
10  protected ref Color m_ColorConnecting;
11 
12  [Attribute(UIConstants.ICON_CONNECTION)]
13  protected string m_sIconOnline;
14 
15  [Attribute(UIConstants.ICON_SERVICES_ISSUES)]
16  protected string m_sIconOffline;
17 
18  [Attribute(UIConstants.ICON_CONNECTION)]
19  protected string m_sIconConnecting;
20 
21  [Attribute("0")]
22  protected bool m_bShowOnlineIcon;
23 
24  [Attribute("Profile")]
25  protected string m_sTooltipTag;
26 
27  [Attribute("#AR-Account_AuthenticationFailed")]
28  protected string m_sTooltipMessageOffline;
29 
30  [Attribute("#AR-Account_Authenticating")]
31  protected string m_sTooltipMessageConnecting;
32 
33  protected SCR_CoreMenuHeaderButtonComponent m_News;
34  protected SCR_CoreMenuHeaderButtonComponent m_Career;
35 
36  protected SCR_ModularButtonComponent m_Profile;
37  protected SCR_DynamicIconComponent m_ProfileStatusIcon;
38 
39  protected bool m_bLoggedIn;
40  protected BackendApi m_BackendApi;
41 
42  protected SCR_ScriptedWidgetTooltip m_Tooltip;
43 
44  static const int AUTH_CHECK_PERIOD = 1000;
45 
46  //------------------------------------------------------------------------------------------------
47  override void HandlerAttached(Widget w)
48  {
49  super.HandlerAttached(w);
50 
51  m_News = SCR_CoreMenuHeaderButtonComponent.Cast(GetComponent(SCR_CoreMenuHeaderButtonComponent, "NewsButton", w));
52  if (m_News)
53  m_News.GetButton().m_OnClicked.Insert(OnNews);
54 
55  m_Career = SCR_CoreMenuHeaderButtonComponent.Cast(GetComponent(SCR_CoreMenuHeaderButtonComponent, "CareerButton", w));
56  if (m_Career)
57  m_Career.GetButton().m_OnClicked.Insert(OnCareer);
58 
59  Widget profile = w.FindAnyWidget("Profile");
60  if (profile)
61  {
62  m_Profile = SCR_ModularButtonComponent.FindComponent(profile);
63  if (m_Profile)
64  m_Profile.m_OnClicked.Insert(OnProfile);
65 
66  m_ProfileStatusIcon = SCR_DynamicIconComponent.FindComponent("DotOverlay", profile);
67  if (m_ProfileStatusIcon)
68  m_ProfileStatusIcon.SetIconColor(m_ColorOffline);
69  }
70 
71  m_BackendApi = GetGame().GetBackendApi();
72 
73  UpdateAuthentication();
74 
75  // Owner menu events
76  SCR_MenuHelper.GetOnMenuFocusGained().Insert(OnMenuEnabled);
77  SCR_MenuHelper.GetOnMenuOpen().Insert(OnMenuEnabled);
78  SCR_MenuHelper.GetOnMenuFocusLost().Insert(OnMenuDisabled);
79  SCR_MenuHelper.GetOnMenuClose().Insert(OnMenuDisabled);
80  }
81 
82  //------------------------------------------------------------------------------------------------
83  override void HandlerDeattached(Widget w)
84  {
85  super.HandlerDeattached(w);
86 
87  // Owner menu events
88  SCR_MenuHelper.GetOnMenuFocusGained().Remove(OnMenuEnabled);
89  SCR_MenuHelper.GetOnMenuOpen().Remove(OnMenuEnabled);
90  SCR_MenuHelper.GetOnMenuFocusLost().Remove(OnMenuDisabled);
91  SCR_MenuHelper.GetOnMenuClose().Remove(OnMenuDisabled);
92  }
93 
94  //------------------------------------------------------------------------------------------------
95  protected void OnMenuEnabled(ChimeraMenuBase menu)
96  {
97  if (menu == ChimeraMenuBase.GetOwnerMenu(GetRootWidget()))
98  {
99  GetGame().GetCallqueue().Remove(UpdateAuthentication);
100  GetGame().GetCallqueue().CallLater(UpdateAuthentication, AUTH_CHECK_PERIOD, true);
101 
102  SCR_ScriptedWidgetTooltip.GetOnTooltipShow().Insert(OnTooltipShow);
103  }
104  }
105 
106  //------------------------------------------------------------------------------------------------
107  protected void OnMenuDisabled(ChimeraMenuBase menu)
108  {
109  if (menu == ChimeraMenuBase.GetOwnerMenu(GetRootWidget()))
110  {
111  GetGame().GetCallqueue().Remove(UpdateAuthentication);
112 
113  SCR_ScriptedWidgetTooltip.GetOnTooltipShow().Remove(OnTooltipShow);
114  }
115  }
116 
117  //------------------------------------------------------------------------------------------------
118  protected void OnTooltipShow(SCR_ScriptedWidgetTooltip tooltipClass, Widget tooltipWidget, Widget hoverWidget, SCR_ScriptedWidgetTooltipPreset preset, string tag)
119  {
120  if (tag == m_sTooltipTag)
121  {
122  m_Tooltip = tooltipClass;
123  UpdateAuthentication();
124  }
125  }
126 
127  //------------------------------------------------------------------------------------------------
128  protected void UpdateAuthentication()
129  {
130  if (!m_BackendApi)
131  {
132  m_BackendApi = GetGame().GetBackendApi();
133  if (!m_BackendApi)
134  return;
135  }
136 
137  if (!m_ProfileStatusIcon)
138  return;
139 
140  m_ProfileStatusIcon.SetVisibile(true);
141 
142  Color color = m_ColorOffline;
143  string image = m_sIconOffline;
144 
145  string tooltipMessage = m_sTooltipMessageOffline;
146  Color tooltipMessageColor = m_ColorOffline;
147 
148  if (m_BackendApi.IsAuthInProgress())
149  {
150  color = m_ColorConnecting;
151  image = m_sIconConnecting;
152 
153  tooltipMessage = m_sTooltipMessageConnecting;
154  tooltipMessageColor = m_ColorConnecting;
155  }
156  else if (m_BackendApi.IsAuthenticated())
157  {
158  color = m_ColorOnline;
159  image = m_sIconOnline;
160 
161  m_ProfileStatusIcon.SetVisibile(m_bShowOnlineIcon);
162 
163  if (m_Tooltip)
164  tooltipMessage = m_Tooltip.GetDefaultMessage();
165 
166  tooltipMessageColor = Color.FromInt(Color.WHITE);
167  }
168 
169  m_ProfileStatusIcon.SetIconColor(color);
170  m_ProfileStatusIcon.SetImage(image);
171 
172  if (m_Tooltip)
173  {
174  m_Tooltip.SetMessage(tooltipMessage);
175  m_Tooltip.SetMessageColor(tooltipMessageColor);
176  }
177  }
178 
179  //------------------------------------------------------------------------------------------------
180  protected void OnNews()
181  {
182  SCR_ProfileSuperMenu menu = SCR_ProfileSuperMenu.Cast(GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.ProfileSuperMenu, 0, true));
183  if (menu)
184  menu.SetPage(SCR_EProfileSuperMenuTabId.NEWS);
185  }
186 
187  //------------------------------------------------------------------------------------------------
188  protected void OnCareer()
189  {
190  //TODO: uncomment once Career Menu is finished
191  //GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.CareerProfileMenu, 0, true);
192  }
193 
194  //------------------------------------------------------------------------------------------------
195  protected void OnProfile()
196  {
197  // Show profile screen
198  if (m_BackendApi.IsBIAccountLinked())
199  SCR_LoginProcessDialogUI.CreateProfileDialog();
200  else
201  SCR_LoginProcessDialogUI.CreateLoginDialog();
202  }
203 }
ChimeraMenuBase
Constant variables used in various menus.
Definition: ChimeraMenuBase.c:70
UIConstants
Definition: Constants.c:130
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
Attribute
typedef Attribute
Post-process effect of scripted camera.
UIColors
Definition: Constants.c:16
m_sTooltipTag
protected string m_sTooltipTag
Definition: SCR_ServicesStatusDialogComponent.c:55
SCR_MenuHelper
Definition: SCR_MenuHelper.c:15
m_Tooltip
protected SCR_ScriptedWidgetTooltip m_Tooltip
Definition: SCR_ServicesStatusDialogComponent.c:76
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
SCR_EProfileSuperMenuTabId
SCR_EProfileSuperMenuTabId
Definition: SCR_ProfileSuperMenu.c:1
SCR_DynamicIconComponent
Definition: SCR_DynamicIconComponent.c:5
SCR_CoreMenuHeaderButtonComponent
Helper component for core menu header button prefabs.
Definition: SCR_CoreMenuHeaderButtonComponent.c:2
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7
SCR_ScriptedWidgetTooltip
Definition: SCR_ScriptedWidgetTooltip.c:15
SCR_AccountWidgetComponent
Definition: SCR_AccountWidgetComponent.c:1
SCR_LoginProcessDialogUI
Definition: SCR_LoginProcessDialogUI.c:5