Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ReportPlayerDialog.c
Go to the documentation of this file.
2{
3 protected int m_iReportedPlayedID;
4
5 protected ref array<SCR_ModularButtonComponent> m_aReasonButtons = {};
6
8
9 //------------------------------------------------------------------------------------------------
10 void SCR_ReportPlayerDialog(int reportedPlayedID)
11 {
12 m_iReportedPlayedID = reportedPlayedID;
13 SCR_ConfigurableDialogUi.CreateFromPreset(SCR_CommonDialogs.DIALOGS_CONFIG, "report_player", this);
14 }
15
16 //------------------------------------------------------------------------------------------------
18 {
19 super.OnMenuOpen(preset);
20
21 SCR_InputButtonComponent confirm = FindButton("confirm_report");
22 if (confirm)
23 confirm.m_OnActivated.Insert(OnConfirmReport);
24
25 Widget reasonsLayout = m_wRoot.FindAnyWidget("ReasonsLayout");
26 if (!reasonsLayout)
27 return;
28
29 Widget child = reasonsLayout.GetChildren();
30 if (!child)
31 return;
32
33 SCR_ModularButtonComponent modularComponent;
34 while (child)
35 {
36 modularComponent = SCR_ModularButtonComponent.Cast(child.FindHandler(SCR_ModularButtonComponent));
37 if (!modularComponent)
38 continue;
39
40 modularComponent.m_OnToggled.Insert(OnReasonToggled);
41 modularComponent.m_OnFocus.Insert(OnReasonFocused);
42 m_aReasonButtons.Insert(modularComponent);
43
44 child = child.GetSibling();
45 }
46
47 RichTextWidget reportedPlayerName = RichTextWidget.Cast(m_wRoot.FindAnyWidget("ReportedPlayerName"));
48 if (!reportedPlayerName)
49 return;
50
51 string name = SCR_PlayerNamesFilterCache.GetInstance().GetPlayerDisplayName(m_iReportedPlayedID);
52 reportedPlayerName.SetText(name);
53 }
54
55 //------------------------------------------------------------------------------------------------
57 {
59 if (!controller)
60 return;
61
62 SocialComponent social = SocialComponent.Cast(controller.FindComponent(SocialComponent));
63 if (!social)
64 return;
65
66 social.m_OnReportPlayerFinishInvoker.Insert(OnReportResult);
67 social.ReportPlayer(m_iReportedPlayedID, m_eReason);
68 }
69
70 //------------------------------------------------------------------------------------------------
71 void OnReasonToggled(SCR_ModularButtonComponent component, bool isToggled)
72 {
73 if (!isToggled)
74 return;
75
76 foreach (SCR_ModularButtonComponent comp : m_aReasonButtons)
77 {
78 if (comp == component)
79 continue;
80
81 comp.SetToggled(false);
82 }
83
84 Widget reasonWidget = component.GetRootWidget();
85 if (!reasonWidget)
86 return;
87
88 SCR_ReportReasonComponent reasonComponent = SCR_ReportReasonComponent.Cast(reasonWidget.FindHandler(SCR_ReportReasonComponent));
89 if (!reasonComponent)
90 return;
91
92 m_eReason = reasonComponent.GetReason();
93 }
94
95 //------------------------------------------------------------------------------------------------
96 void OnReasonFocused(SCR_ModularButtonComponent component)
97 {
98 if (GetGame().GetInputManager().GetLastUsedInputDevice() == EInputDeviceType.KEYBOARD)
99 return;
100
101 Widget reasonWidget = component.GetRootWidget();
102 if (!reasonWidget)
103 return;
104
105 SCR_ReportReasonComponent reasonComponent = SCR_ReportReasonComponent.Cast(reasonWidget.FindHandler(SCR_ReportReasonComponent));
106 if (!reasonComponent)
107 return;
108
109 m_eReason = reasonComponent.GetReason();
110 }
111
112 //------------------------------------------------------------------------------------------------
113 void OnReportResult(int playerID, bool success)
114 {
116 if (!controller)
117 return;
118
119 SocialComponent social = SocialComponent.Cast(controller.FindComponent(SocialComponent));
120 if (!social)
121 return;
122
123 social.m_OnReportPlayerFinishInvoker.Remove(OnReportResult);
124
125 if (success)
126 {
127 SCR_ConfigurableDialogUi.CreateFromPreset(SCR_CommonDialogs.DIALOGS_CONFIG, "report_player_confirmation");
128 Close();
129 }
130 else
131 {
134 Close();
135 }
136 }
137};
138
140{
141 [Attribute(SCR_EReportReason.CHEATING.ToString(), UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(SCR_EReportReason))]
143
144 [Attribute("Content", UIWidgets.EditBox, "Widget in which the text of the reason is placed")]
145 protected string m_sReasonTextWidget;
146
147 [Attribute("", UIWidgets.EditBox, "ID of the localized string for the report reason")]
148 protected string m_sReasonLocalizedTextID;
149
150 //------------------------------------------------------------------------------------------------
151 override void HandlerAttached(Widget w)
152 {
153 TextWidget textWidget = TextWidget.Cast(w.FindAnyWidget(m_sReasonTextWidget));
154 if (!textWidget)
155 return;
156 textWidget.SetText(m_sReasonLocalizedTextID);
157 }
158
159 //------------------------------------------------------------------------------------------------
161 {
162 return m_eReason;
163 }
164}
ArmaReforgerScripted GetGame()
Definition game.c:1398
InputManager GetInputManager()
static const ResourceName BLOCKED_USER_DIALOG_CONFIG
static SCR_ConfigurableDialogUi CreateFromPreset(ResourceName presetsResourceName, string tag, SCR_ConfigurableDialogUi customDialogObj=null)
Creates a dialog from preset.
SCR_InputButtonComponent FindButton(string tag)
Returns a button with given tag.
void SCR_ReportPlayerDialog(int reportedPlayedID)
void OnReasonToggled(SCR_ModularButtonComponent component, bool isToggled)
void OnReportResult(int playerID, bool success)
ref array< SCR_ModularButtonComponent > m_aReasonButtons
void OnReasonFocused(SCR_ModularButtonComponent component)
override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
override void HandlerAttached(Widget w)
SCR_FieldOfViewSettings Attribute
proto external PlayerController GetPlayerController()
SCR_EReportReason
Player report reason.