Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ReportCommunityContentDialog.cs
浏览该文件的文档.
1using System.Xml.Linq;
2
3namespace Game {
5 public string m_address;
6
7 public string m_userId;
8
10
12
14
16
17 public List<CheckboxWidget> m_reasonWidgetsList = [];
18
19 public ReportCommunityContentDialog(string address, string displayName, string userId) {
20 m_address = address;
21 m_userId = userId;
22 XElement node = ContentManager.Get<XElement>("Dialogs/ReportCommunityContentDialog");
23 LoadContents(this, node);
24 m_nameLabel = Children.Find<LabelWidget>("ReportCommunityContentDialog.Name");
25 m_container = Children.Find<ContainerWidget>("ReportCommunityContentDialog.Container");
26 m_reportButton = Children.Find<ButtonWidget>("ReportCommunityContentDialog.Report");
27 m_cancelButton = Children.Find<ButtonWidget>("ReportCommunityContentDialog.Cancel");
28 m_reasonWidgetsList.Add(new CheckboxWidget { Text = "Cruelty", Tag = "cruelty" });
29 m_reasonWidgetsList.Add(new CheckboxWidget { Text = "Dating", Tag = "dating" });
30 m_reasonWidgetsList.Add(new CheckboxWidget { Text = "Drugs / Alcohol", Tag = "drugs" });
31 m_reasonWidgetsList.Add(new CheckboxWidget { Text = "Hate Speech", Tag = "hate" });
32 m_reasonWidgetsList.Add(new CheckboxWidget { Text = "Plagiarism", Tag = "plagiarism" });
33 m_reasonWidgetsList.Add(new CheckboxWidget { Text = "Racism", Tag = "racism" });
34 m_reasonWidgetsList.Add(new CheckboxWidget { Text = "Sex / Nudity", Tag = "sex" });
35 m_reasonWidgetsList.Add(new CheckboxWidget { Text = "Excessive Swearing", Tag = "swearing" });
36 Random random = new();
37 m_reasonWidgetsList.RandomShuffle(max => random.Int(0, max - 1));
38 m_reasonWidgetsList.Add(new CheckboxWidget { Text = "Other", Tag = "other" });
39 foreach (CheckboxWidget reasonWidgets in m_reasonWidgetsList) {
40 m_container.Children.Add(reasonWidgets);
41 }
42 m_nameLabel.Text = displayName;
43 m_reportButton.IsEnabled = false;
44 }
45
46 public override void Update() {
47 m_reportButton.IsEnabled = m_reasonWidgetsList.Count(w => w.IsChecked) == 1;
48 if (m_reportButton.IsClicked) {
52 new MessageDialog(
53 "Are you sure?",
54 "Reporting offensive content is a serious matter. Please make sure you checked the right box. Do not report content which is not offensive.",
55 "Proceed",
56 "Cancel",
57 delegate(MessageDialogButton b) {
58 if (b == MessageDialogButton.Button1) {
59 string report = string.Empty;
60 foreach (CheckboxWidget reasonWidgets in m_reasonWidgetsList) {
61 if (reasonWidgets.IsChecked) {
62 report = (string)reasonWidgets.Tag;
63 break;
64 }
65 }
66 CancellableBusyDialog busyDialog = new("Sending Report", false);
71 report,
72 busyDialog.Progress,
73 delegate { DialogsManager.HideDialog(busyDialog); },
74 delegate { DialogsManager.HideDialog(busyDialog); }
75 );
76 }
77 }
78 )
79 );
80 }
81 if (Input.Cancel
82 || m_cancelButton.IsClicked) {
84 }
85 }
86 }
87}
static void Report(string address, string userId, string report, CancellableProgress progress, Action success, Action< Exception > failure)
readonly WidgetsList Children
static object Get(Type type, string name)
static void HideDialog(Dialog dialog)
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
ReportCommunityContentDialog(string address, string displayName, string userId)
ContainerWidget ParentWidget
virtual void LoadContents(object eventsTarget, XElement node)