Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
DownloadContentFromLinkDialog.cs
浏览该文件的文档.
1using System.Xml.Linq;
2using Engine;
3
4namespace Game {
7
9
11
13
15
17
19
21
23
25
27 XElement node = ContentManager.Get<XElement>("Dialogs/DownloadContentFromLinkDialog");
28 LoadContents(this, node);
29 m_linkTextBoxWidget = Children.Find<TextBoxWidget>("DownloadContentFromLinkDialog.Link");
30 m_nameTextBoxWidget = Children.Find<TextBoxWidget>("DownloadContentFromLinkDialog.Name");
31 m_typeIconWidget = Children.Find<RectangleWidget>("DownloadContentFromLinkDialog.TypeIcon");
32 m_typeLabelWidget = Children.Find<LabelWidget>("DownloadContentFromLinkDialog.Type");
33 m_changeTypeButtonWidget = Children.Find<ButtonWidget>("DownloadContentFromLinkDialog.ChangeType");
34 m_downloadButtonWidget = Children.Find<ButtonWidget>("DownloadContentFromLinkDialog.Download");
35 m_cancelButtonWidget = Children.Find<ButtonWidget>("DownloadContentFromLinkDialog.Cancel");
36 m_linkTextBoxWidget.TextChanged += delegate {
39 };
40 }
41
42 public override void Update() {
43 string text = m_linkTextBoxWidget.Text.Trim();
44 string name = m_nameTextBoxWidget.Text.Trim();
46 m_typeIconWidget.Subtexture = ExternalContentManager.GetEntryTypeIcon(m_type);
48 m_nameTextBoxWidget.IsEnabled = true;
49 m_downloadButtonWidget.IsEnabled = text.Length > 0 && name.Length > 0 && m_type != ExternalContentType.Unknown;
51 m_nameTextBoxWidget.Text = GetNameFromLink(m_linkTextBoxWidget.Text);
52 m_updateContentName = false;
53 }
54 }
55 else {
56 m_nameTextBoxWidget.IsEnabled = false;
57 m_nameTextBoxWidget.Text = string.Empty;
58 m_downloadButtonWidget.IsEnabled = text.Length > 0 && m_type != ExternalContentType.Unknown;
59 }
62 m_updateContentType = false;
63 }
64 if (m_changeTypeButtonWidget.IsClicked) {
68 "Select Content Type",
69 delegate(ExternalContentType item) {
70 m_type = item;
72 }
73 )
74 );
75 }
76 else if (Input.Cancel
77 || m_cancelButtonWidget.IsClicked) {
79 }
80 else if (m_downloadButtonWidget.IsClicked) {
81 CancellableBusyDialog busyDialog = new("Downloading", false);
84 text,
85 null,
86 null,
87 busyDialog.Progress,
88 delegate(byte[] data) {
90 new MemoryStream(data),
91 m_type,
92 name,
93 delegate {
94 DialogsManager.HideDialog(busyDialog);
96 },
97 delegate(Exception error) {
98 DialogsManager.HideDialog(busyDialog);
99 DialogsManager.ShowDialog(ParentWidget, new MessageDialog("Error", error.Message, "OK", null, null));
100 }
101 );
102 },
103 delegate(Exception error) {
104 DialogsManager.HideDialog(busyDialog);
105 DialogsManager.ShowDialog(ParentWidget, new MessageDialog("Error", error.Message, "OK", null, null));
106 }
107 );
108 }
109 }
110
111 public static string UnclutterLink(string address) {
112 try {
113 string text = address;
114 int num = text.IndexOf('&');
115 if (num > 0) {
116 text = text.Remove(num);
117 }
118 int num2 = text.IndexOf('?');
119 if (num2 > 0) {
120 text = text.Remove(num2);
121 }
122 return Uri.UnescapeDataString(text);
123 }
124 catch (Exception) {
125 return string.Empty;
126 }
127 }
128
129 public static string GetNameFromLink(string address) {
130 try {
132 }
133 catch (Exception) {
134 return string.Empty;
135 }
136 }
137
138 public static ExternalContentType GetTypeFromLink(string address) {
139 try {
141 }
142 catch (Exception) {
143 return ExternalContentType.Unknown;
144 }
145 }
146 }
147}
Android.Net.Uri Uri
static string GetExtension(string path)
static string GetFileNameWithoutExtension(string path)
readonly WidgetsList Children
static object Get(Type type, string name)
static void HideDialog(Dialog dialog)
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
static void ImportExternalContent(Stream stream, ExternalContentType type, string name, Action< string > success, Action< Exception > failure)
static ExternalContentType ExtensionToType(string extension)
static bool DoesEntryTypeRequireName(ExternalContentType type)
static Subtexture GetEntryTypeIcon(ExternalContentType type)
static string GetEntryTypeDescription(ExternalContentType type)
static void Get(string address, Dictionary< string, string > parameters, Dictionary< string, string > headers, CancellableProgress progress, Action< byte[]> success, Action< Exception > failure)
ContainerWidget ParentWidget
virtual void LoadContents(object eventsTarget, XElement node)