Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
PublishCommunityLinkDialog.cs
浏览该文件的文档.
1using System.Xml.Linq;
2using Engine;
3
4namespace Game {
7
9
11
13
15
17
19
20 public string m_user;
21
23
24 public PublishCommunityLinkDialog(string user, string address, string name) {
25 XElement node = ContentManager.Get<XElement>("Dialogs/PublishCommunityLinkDialog");
26 LoadContents(this, node);
27 m_linkTextBoxWidget = Children.Find<TextBoxWidget>("PublishCommunityLinkDialog.Link");
28 m_nameTextBoxWidget = Children.Find<TextBoxWidget>("PublishCommunityLinkDialog.Name");
29 m_typeIconWidget = Children.Find<RectangleWidget>("PublishCommunityLinkDialog.TypeIcon");
30 m_typeLabelWidget = Children.Find<LabelWidget>("PublishCommunityLinkDialog.Type");
31 m_changeTypeButtonWidget = Children.Find<ButtonWidget>("PublishCommunityLinkDialog.ChangeType");
32 m_publishButtonWidget = Children.Find<ButtonWidget>("PublishCommunityLinkDialog.Publish");
33 m_cancelButtonWidget = Children.Find<ButtonWidget>("PublishCommunityLinkDialog.Cancel");
34 m_linkTextBoxWidget.TextChanged += delegate {
36 };
37 if (!string.IsNullOrEmpty(address)) {
38 m_linkTextBoxWidget.Text = address;
39 }
40 if (!string.IsNullOrEmpty(name)) {
41 m_nameTextBoxWidget.Text = name;
42 }
43 m_user = user;
44 }
45
46 public override void Update() {
47 string text = m_linkTextBoxWidget.Text.Trim();
48 string text2 = m_nameTextBoxWidget.Text.Trim();
50 m_typeIconWidget.Subtexture = ExternalContentManager.GetEntryTypeIcon(m_type);
51 m_publishButtonWidget.IsEnabled = text.Length > 0 && text2.Length > 0;
52 if (m_changeTypeButtonWidget.IsClicked) {
55 new SelectExternalContentTypeDialog("Select Content Type", delegate(ExternalContentType item) { m_type = item; })
56 );
57 }
58 else if (Input.Cancel
59 || m_cancelButtonWidget.IsClicked) {
61 }
62 else if (m_publishButtonWidget.IsClicked) {
63 CancellableBusyDialog busyDialog = new("Publishing", false);
66 text,
67 text2,
68 m_type,
69 m_user,
70 busyDialog.Progress,
71 delegate {
72 DialogsManager.HideDialog(busyDialog);
73 DialogsManager.ShowDialog(
74 ParentWidget,
75 new MessageDialog(
76 "Link Published Successfully",
77 "It should start appearing in the listings after it is moderated. Please keep the file accessible through this link, so that other community members can download it.",
78 "OK",
79 null,
80 delegate { DialogsManager.HideDialog(this); }
81 )
82 );
83 },
84 delegate(Exception error) {
85 DialogsManager.HideDialog(busyDialog);
86 DialogsManager.ShowDialog(ParentWidget, new MessageDialog("Error", error.Message, "OK", null, null));
87 }
88 );
89 }
90 }
91
92 public static string GetFilenameFromLink(string address) {
93 try {
94 string text = address;
95 int num = text.IndexOf('&');
96 if (num > 0) {
97 text = text.Remove(num);
98 }
99 int num2 = text.IndexOf('?');
100 if (num2 > 0) {
101 text = text.Remove(num2);
102 }
103 text = Uri.UnescapeDataString(text);
104 return Storage.GetFileName(text);
105 }
106 catch (Exception) {
107 return string.Empty;
108 }
109 }
110 }
111}
Android.Net.Uri Uri
static string GetFileNameWithoutExtension(string path)
static string GetFileName(string path)
static void Publish(string address, string name, ExternalContentType type, string userId, 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)
static Subtexture GetEntryTypeIcon(ExternalContentType type)
static string GetEntryTypeDescription(ExternalContentType type)
ContainerWidget ParentWidget
virtual void LoadContents(object eventsTarget, XElement node)