Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CommunitySubMenu.c
Go to the documentation of this file.
2 {
3  [Attribute("{6FFF0601A48C7FEE}UI/layouts/Menus/MainMenu/CommunityNotificationButton.layout", UIWidgets.ResourceNamePicker, "", "layout")]
4  protected ResourceName m_sNotificationsLayout;
5 
6  [Attribute("Send")]
7  protected string m_sSendButtonName;
8  [Attribute("Feedback")]
9  protected string m_sFeedbackEditboxName;
10  [Attribute("Address")]
11  protected string m_sMailEditboxName;
12  [Attribute("Notifications")]
13  protected string m_sNotificationName;
14  [Attribute("Type")]
15  protected string m_sTypeComboBoxName;
16  [Attribute("Category")]
17  protected string m_sCategoryComboBoxName;
18 
19  protected SCR_ButtonBaseComponent m_Send;
20  protected SCR_EditBoxComponent m_Feedback;
21  protected SCR_ComboBoxComponent m_FeedbackType;
22  protected SCR_ComboBoxComponent m_FeedbackCategory;
23 
24  SCR_InputButtonComponent m_TermsOfService;
25 
26  //------------------------------------------------------------------------------------------------
27  override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
28  {
29  super.OnTabCreate(menuRoot, buttonsLayout, index);
30 
31  SetupNotifications();
32 
33  m_Send = SCR_ButtonBaseComponent.GetButtonBase(m_sSendButtonName, m_wRoot);
34  if (m_Send)
35  {
36  m_Send.m_OnClicked.Insert(OnSendFeedback);
37  m_Send.SetEnabled(false, false);
38  }
39 
40  m_Feedback = SCR_EditBoxComponent.GetEditBoxComponent(m_sFeedbackEditboxName, m_wRoot);
41 
42  m_TermsOfService = m_DynamicFooter.FindButton("ToS");
43  if (m_TermsOfService)
44  {
45  m_TermsOfService.SetVisible(true);
46  m_TermsOfService.m_OnActivated.Insert(OnTos);
47  }
48 
49  SetupCategories();
50  }
51 
52  //------------------------------------------------------------------------------------------------
53  override void OnMenuUpdate(float tDelta)
54  {
55  super.OnMenuUpdate(tDelta);
56 
57  if (m_Send)
58  m_Send.SetEnabled(m_Feedback.GetValue() != string.Empty && FeedbackDialogUI.CanSendFeedback());
59  }
60 
61  //------------------------------------------------------------------------------------------------
62  override void OnTabHide()
63  {
64  super.OnTabHide();
65 
66  FeedbackDialogUI.ClearFeedback();
67 
68  if (m_TermsOfService)
69  m_TermsOfService.SetVisible(false);
70  }
71 
72  //------------------------------------------------------------------------------------------------
73  override void OnTabRemove()
74  {
75  super.OnTabRemove();
76 
77  FeedbackDialogUI.ClearFeedback();
78  }
79 
80  // Setup type and category combos according to FeedbackDialogUI constants
81  //------------------------------------------------------------------------------------------------
82  protected void SetupCategories()
83  {
84  m_FeedbackCategory = SCR_ComboBoxComponent.GetComboBoxComponent(m_sCategoryComboBoxName, m_wRoot);
85  m_FeedbackType = SCR_ComboBoxComponent.GetComboBoxComponent(m_sTypeComboBoxName, m_wRoot);
86  if (!m_FeedbackCategory || !m_FeedbackType)
87  return;
88 
89  m_FeedbackCategory.ClearAll();
90  m_FeedbackType.ClearAll();
91 
92 
93  foreach (string s : FeedbackDialogUI.CATEGORY_NAMES)
94  {
95  m_FeedbackCategory.AddItem(s);
96  }
97 
98  foreach (string s : FeedbackDialogUI.TYPE_NAMES)
99  {
100  m_FeedbackType.AddItem(s);
101  }
102 
103  m_FeedbackType.SetCurrentItem(0);
104  m_FeedbackCategory.SetCurrentItem(0);
105  }
106 
107  //------------------------------------------------------------------------------------------------
108  protected void SetupNotifications()
109  {
110  Widget notifications = m_wRoot.FindAnyWidget(m_sNotificationName);
111  if (!notifications)
112  return;
113 
114  array<ref SCR_NewsEntry> entries = {};
115  MainMenuUI.GetNotificationEntries(entries);
116  foreach (SCR_NewsEntry entry : entries)
117  {
118  Widget w = GetGame().GetWorkspace().CreateWidgets(m_sNotificationsLayout, notifications);
119  if (!w)
120  continue;
121 
123  if (!tile)
124  continue;
125 
126  tile.ShowTile(entry);
127  }
128  }
129 
130  // Copy code from feedback dialog
131  //------------------------------------------------------------------------------------------------
132  protected void OnSendFeedback()
133  {
134  if (!m_Feedback || !m_FeedbackType || !m_FeedbackCategory)
135  return;
136 
137  string content = m_Feedback.GetValue();
138 
139  // Clear feedback window
140  m_Feedback.SetValue(string.Empty);
141 
142  // Send feedback
143  FeedbackDialogUI.SendFeedback(content, m_FeedbackType.GetCurrentIndex(), m_FeedbackCategory.GetCurrentIndex());
144  }
145 
146  //------------------------------------------------------------------------------------------------
147  protected void OnTos()
148  {
149  GetGame().GetPlatformService().OpenBrowser(GetGame().GetBackendApi().GetLinkItem("Link_PrivacyPolicy"));
150  }
151 }
SCR_ComboBoxComponent
Definition: SCR_ComboBoxComponent.c:1
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
FeedbackDialogUI
Definition: FeedbackDialogUI.c:239
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_NewsTileComponent
Definition: SCR_NewsTileComponent.c:1
SCR_SubMenuBase
Definition: SCR_SubMenuBase.c:6
SCR_NewsEntry
Definition: SCR_NewsSubMenu.c:2
SCR_CommunitySubMenu
Definition: SCR_CommunitySubMenu.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
MainMenuUI
Definition: MainMenuUI.c:1
SCR_ButtonBaseComponent
Base class for any button, regardless its own content.
Definition: SCR_ButtonBaseComponent.c:3
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_EditBoxComponent
Definition: SCR_EditBoxComponent.c:8
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1