7 public static string fName =
"ExternalContentManager";
22 new AndroidSdCardExternalContentProvider(),
30 extension = extension.ToLower();
43 yield
return ".scbtex";
47 yield
return ".astcsrgb";
101 if (
string.IsNullOrEmpty(name)) {
104 if (name.Length > 50) {
108 || name[^1] ==
' ') {
127 Action<string> success,
128 Action<Exception> failure) {
134 catch (Exception obj) {
135 failure?.Invoke(obj);
157 async Task<string> Import(Stream stream,
string fileName) {
158 return await Task.Run(() => {
164 catch (Exception e) {
165 return string.Format(failureFormat, fileName, e.Message);
170 return string.Format(successFormat, fileName);
172 return string.Format(failureFormat, fileName, unsupportedString);
177 Task<string>[] tasks =
new Task<string>[files.Count];
178 for (
int i = 0; i < files.Count; i++) {
179 (Stream stream,
string fileName) = files[i];
180 tasks[i] = Import(stream, fileName);
182 string[] results = await Task.WhenAll(tasks);
183 StringBuilder sb =
new();
184 foreach (
string result
in results) {
185 sb.AppendLine(result);
187 string finalResult = sb.ToString();
189 if (showResultDialog) {
204 StringBuilder sb =
new();
205 foreach ((Stream stream,
string fileName) in files) {
210 sb.AppendLine(
string.Format(successFormat, fileName));
212 catch (Exception e) {
213 sb.AppendLine(
string.Format(failureFormat, fileName, e.Message));
217 sb.AppendLine(
string.Format(failureFormat, fileName, unsupportedString));
220 string finalResult = sb.ToString();
222 if (showResultDialog) {
236 DialogsManager.HideDialog(busyDialog);
239 delegate(Exception error) {
251 if (showWarningDialog) {
284 if (provider !=
null) {
293 bool needsDelete =
false;
294 string sourcePath =
null;
295 Stream stream =
null;
301 if (needsDelete && sourcePath !=
null) {
315 if (sourcePath ==
null) {
322 if (sourcePath ==
null) {
329 if (sourcePath ==
null) {
342 path = $
"{name2}.scworld";
353 delegate(
string link) {
355 long length = stream.Length;
360#if ANDROID || BROWSER
365 $
"{string.Format(LanguageControl.Get(fName, 15), DataSizeFormatter.Format(length))}\n{LanguageControl.Get(fName, "21
")}{link}",
369 if (button == MessageDialogButton.Button1) {
370 Task.Run(async () => {
372 await Storage.ShareFile(link);
374 catch (Exception e) {
375 Dispatcher.Dispatch(() => DialogsManager.ShowDialog(
378 LanguageControl.Error,
397 $
"{string.Format(LanguageControl.Get(fName, 15), DataSizeFormatter.Format(length))}\n{LanguageControl.Get(fName, "21
")}{link}",
409 delegate(Exception error) {
425 catch (Exception ex2) {
439 catch (Exception ex) {
static void Dispatch(Action action, bool waitUntilCompleted=false)
static void Information(object message)
static Stream OpenFile(string path, OpenFileMode openFileMode)
static string GetExtension(string path)
static string GetFileName(string path)
static void DeleteFile(string path)
static string CombinePaths(params string[] paths)
static string ImportBlocksTexture(string name, Stream stream)
static string GetFileName(string name)
static void DeleteBlocksTexture(string name)
CancellableProgress Progress
static string GetFileName(string name)
static void DeleteCharacterSkin(string name)
static string ImportCharacterSkin(string name, Stream stream)
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 bool IsEntryTypeDownloadSupported(ExternalContentType type)
static async Task ImportExternalContentsAsync(List<(Stream stream, string fileName)> files, bool showResultDialog)
static void ShowUploadUi(ExternalContentType type, string name)
static ReadOnlyList< IExternalContentProvider > Providers
static Exception VerifyExternalContentName(string name)
static ExternalContentType ExtensionToType(string extension)
static IEnumerable< string > GetEntryTypeExtensions(ExternalContentType type)
static void ImportExternalContentsSync(List<(Stream stream, string fileName)> files, bool showResultDialog)
static void ShowLoginUiIfNeeded(IExternalContentProvider provider, bool showWarningDialog, Action handler)
static List< IExternalContentProvider > m_providers
static bool DoesEntryTypeRequireName(ExternalContentType type)
static Subtexture GetEntryTypeIcon(ExternalContentType type)
static void DeleteExternalContent(ExternalContentType type, string name)
static string GetEntryTypeDescription(ExternalContentType type)
static string openFilePath
static IExternalContentProvider DefaultProvider
static string ImportExternalContentSync(Stream stream, ExternalContentType type, string name)
static string GetFileName(string name)
static void DeleteFurniturePack(string name)
static string ImportFurniturePack(string name, Stream stream)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
WorldSettings WorldSettings
static string ImportWorld(Stream sourceStream)
static void ExportWorld(string directoryName, Stream targetStream)
static WorldInfo GetWorldInfo(string directoryName)
static void DeleteWorld(string directoryName)
static string ExternalPath
static string ImportMod(string name, Stream stream)
void Upload(string path, Stream stream, CancellableProgress progress, Action< string > success, Action< Exception > failure)
void Login(CancellableProgress progress, Action success, Action< Exception > failure)