コード例 #1
0
        public IEnumerable <ActiveExternalContentInfo> GetActiveExternalContent()
        {
            string downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.World, DirectoryName);

            if (!string.IsNullOrEmpty(downloadedContentAddress))
            {
                yield return(new ActiveExternalContentInfo
                {
                    Address = downloadedContentAddress,
                    DisplayName = WorldSettings.Name,
                    Type = ExternalContentType.World
                });
            }
            if (!BlocksTexturesManager.IsBuiltIn(WorldSettings.BlocksTextureName))
            {
                downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.BlocksTexture, WorldSettings.BlocksTextureName);
                if (!string.IsNullOrEmpty(downloadedContentAddress))
                {
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = BlocksTexturesManager.GetDisplayName(WorldSettings.BlocksTextureName),
                        Type = ExternalContentType.BlocksTexture
                    });
                }
            }
            SubsystemPlayers subsystemPlayers = base.Project.FindSubsystem <SubsystemPlayers>(throwOnError: true);

            foreach (PlayerData playersDatum in subsystemPlayers.PlayersData)
            {
                if (!CharacterSkinsManager.IsBuiltIn(playersDatum.CharacterSkinName))
                {
                    downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.CharacterSkin, playersDatum.CharacterSkinName);
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = CharacterSkinsManager.GetDisplayName(playersDatum.CharacterSkinName),
                        Type = ExternalContentType.CharacterSkin
                    });
                }
            }
            SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior = base.Project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true);

            foreach (FurnitureSet furnitureSet in subsystemFurnitureBlockBehavior.FurnitureSets)
            {
                if (furnitureSet.ImportedFrom != null)
                {
                    downloadedContentAddress = CommunityContentManager.GetDownloadedContentAddress(ExternalContentType.FurniturePack, furnitureSet.ImportedFrom);
                    yield return(new ActiveExternalContentInfo
                    {
                        Address = downloadedContentAddress,
                        DisplayName = FurniturePacksManager.GetDisplayName(furnitureSet.ImportedFrom),
                        Type = ExternalContentType.FurniturePack
                    });
                }
            }
        }
コード例 #2
0
 public void ExportFurnitureSet()
 {
     try
     {
         FurnitureDesign[] designs     = SubsystemFurnitureBlockBehavior.GetFurnitureSetDesigns(ComponentFurnitureInventory.FurnitureSet).ToArray();
         string            displayName = FurniturePacksManager.GetDisplayName(FurniturePacksManager.CreateFurniturePack(ComponentFurnitureInventory.FurnitureSet.Name, designs));
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 21), string.Format(LanguageControl.Get(fName, 22), displayName), LanguageControl.Get("Usual", "ok"), null, null));
     }
     catch (Exception ex)
     {
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 23), ex.Message, LanguageControl.Get("Usual", "ok"), null, null));
     }
 }
コード例 #3
0
        public LoadingScreen()
        {
            WidgetsManager.LoadWidgetContents((Widget)this.ScreenWidget, (object)this, ContentManager.Get <XElement>("Screens/LoadingScreen"));

            LabelWidget ExternalAssemblyInfo = new LabelWidget();

            ExternalAssemblyInfo.Text = "Powered By GScience Studio\n";
            //下列两行代码请勿随意删除
            ExternalAssemblyInfo.Text += "Author:" + Info.author + "\n";
            ExternalAssemblyInfo.Text += "Version:" + Info.version;

            ExternalAssemblyInfo.Color     = Color.LightBlue;
            ExternalAssemblyInfo.FontScale = 0.5f;
            this.ScreenWidget.Children.Add(ExternalAssemblyInfo);

            this.AddLoadAction((Action)(() => CommunityContentManager.Initialize()));
            this.AddLoadAction((Action)(() => MotdManager.Initialize()));
            this.AddLoadAction((Action)(() => LightingManager.Initialize()));
            this.AddLoadAction((Action)(() => StringsManager.LoadStrings()));
            this.AddLoadAction((Action)(() => TextureAtlasManager.LoadAtlases()));
            ReadOnlyList <ContentInfo> readOnlyList = ContentManager.List();

            // ISSUE: explicit reference operation
            using (ReadOnlyList <ContentInfo> .Enumerator enumerator = ((ReadOnlyList <ContentInfo>)@readOnlyList).GetEnumerator())
            {
                // ISSUE: explicit reference operation
                while (((ReadOnlyList <ContentInfo> .Enumerator)@enumerator).MoveNext())
                {
                    // ISSUE: explicit reference operation
                    ContentInfo localContentInfo = ((ReadOnlyList <ContentInfo> .Enumerator)@enumerator).Current;
                    this.AddLoadAction((Action)(() => ContentManager.Get((string)localContentInfo.Name)));
                }
            }
            this.AddLoadAction((Action)(() => DatabaseManager.LoadDatabase()));
            this.AddLoadAction((Action)(() => WorldsManager.Initialize()));
            this.AddLoadAction((Action)(() => BlocksTexturesManager.Initialize()));
            this.AddLoadAction((Action)(() => CharacterSkinsManager.Initialize()));
            this.AddLoadAction((Action)(() => FurniturePacksManager.Initialize()));
            this.AddLoadAction((Action)(() => BlocksManager.Initialize()));
            this.AddLoadAction((Action)(() => CraftingRecipesManager.Initialize()));
            this.AddLoadAction((Action)(() => GScienceStudio.InputManager.Initialize()));
        }
コード例 #4
0
        public static string ImportExternalContentSync(Stream stream, ExternalContentType type, string name)
        {
            switch (type)
            {
            case ExternalContentType.World:
                return(WorldsManager.ImportWorld(stream));

            case ExternalContentType.BlocksTexture:
                return(BlocksTexturesManager.ImportBlocksTexture(name, stream));

            case ExternalContentType.CharacterSkin:
                return(CharacterSkinsManager.ImportCharacterSkin(name, stream));

            case ExternalContentType.FurniturePack:
                return(FurniturePacksManager.ImportFurniturePack(name, stream));

            default:
                throw new InvalidOperationException(LanguageControl.Get(fName, 4));
            }
        }
コード例 #5
0
        public static void DeleteExternalContent(ExternalContentType type, string name)
        {
            switch (type)
            {
            case ExternalContentType.World:
                WorldsManager.DeleteWorld(name);
                break;

            case ExternalContentType.BlocksTexture:
                BlocksTexturesManager.DeleteBlocksTexture(name);
                break;

            case ExternalContentType.CharacterSkin:
                CharacterSkinsManager.DeleteCharacterSkin(name);
                break;

            case ExternalContentType.FurniturePack:
                FurniturePacksManager.DeleteFurniturePack(name);
                break;

            default:
                throw new InvalidOperationException(LanguageControl.Get(fName, 4));
            }
        }
コード例 #6
0
        public LoadingScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/LoadingScreen");

            LoadContents(this, node);
            AddLoadAction(delegate
            {
                VrManager.Initialize();
            });
            AddLoadAction(delegate
            {
                CommunityContentManager.Initialize();
            });
            AddLoadAction(delegate
            {
                MotdManager.Initialize();
            });
            AddLoadAction(delegate
            {
                LightingManager.Initialize();
            });
            AddLoadAction(delegate
            {
                StringsManager.LoadStrings();
            });
            AddLoadAction(delegate
            {
                TextureAtlasManager.LoadAtlases();
            });
            foreach (ContentInfo item in ContentManager.List())
            {
                ContentInfo localContentInfo = item;
                AddLoadAction(delegate
                {
                    ContentManager.Get(localContentInfo.Name);
                });
            }
            AddLoadAction(delegate
            {
                DatabaseManager.Initialize();
            });
            AddLoadAction(delegate
            {
                WorldsManager.Initialize();
            });
            AddLoadAction(delegate
            {
                BlocksTexturesManager.Initialize();
            });
            AddLoadAction(delegate
            {
                CharacterSkinsManager.Initialize();
            });
            AddLoadAction(delegate
            {
                FurniturePacksManager.Initialize();
            });
            AddLoadAction(delegate
            {
                BlocksManager.Initialize();
            });
            AddLoadAction(delegate
            {
                CraftingRecipesManager.Initialize();
            });
            AddLoadAction(delegate
            {
                MusicManager.CurrentMix = MusicManager.Mix.Menu;
            });
        }
コード例 #7
0
 public void ImportFurnitureSet(SubsystemTerrain subsystemTerrain)
 {
     FurniturePacksManager.UpdateFurniturePacksList();
     if (FurniturePacksManager.FurniturePackNames.Count() == 0)
     {
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 18), LanguageControl.Get(fName, 19), LanguageControl.Get("Usual", "ok"), null, null));
     }
     else
     {
         DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new ListSelectionDialog(LanguageControl.Get(fName, 20), FurniturePacksManager.FurniturePackNames, 64f, (object s) => FurniturePacksManager.GetDisplayName((string)s), delegate(object s)
         {
             try
             {
                 int num     = 0;
                 int num2    = 0;
                 string text = (string)s;
                 List <List <FurnitureDesign> > list = FurnitureDesign.ListChains(FurniturePacksManager.LoadFurniturePack(subsystemTerrain, text));
                 List <FurnitureDesign> list2        = new List <FurnitureDesign>();
                 SubsystemFurnitureBlockBehavior.GarbageCollectDesigns();
                 foreach (List <FurnitureDesign> item in list)
                 {
                     FurnitureDesign furnitureDesign = SubsystemFurnitureBlockBehavior.TryAddDesignChain(item[0], garbageCollectIfNeeded: false);
                     if (furnitureDesign == item[0])
                     {
                         list2.Add(furnitureDesign);
                     }
                     else if (furnitureDesign == null)
                     {
                         num2++;
                     }
                     else
                     {
                         num++;
                     }
                 }
                 if (list2.Count > 0)
                 {
                     FurnitureSet furnitureSet = SubsystemFurnitureBlockBehavior.NewFurnitureSet(FurniturePacksManager.GetDisplayName(text), text);
                     foreach (FurnitureDesign item2 in list2)
                     {
                         SubsystemFurnitureBlockBehavior.AddToFurnitureSet(item2, furnitureSet);
                     }
                     ComponentFurnitureInventory.FurnitureSet = furnitureSet;
                 }
                 Invalidate();
                 string text2 = string.Format(LanguageControl.Get(fName, 1), list2.Count);
                 if (num > 0)
                 {
                     text2 += string.Format(LanguageControl.Get(fName, 2), num);
                 }
                 if (num2 > 0)
                 {
                     text2 += string.Format(LanguageControl.Get(fName, 3), num2, 65535);
                 }
                 DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 4), text2.Trim(), LanguageControl.Get("Usual", "ok"), null, null));
             }
             catch (Exception ex)
             {
                 DialogsManager.ShowDialog(m_componentPlayer.GuiWidget, new MessageDialog(LanguageControl.Get(fName, 5), ex.Message, LanguageControl.Get("Usual", "ok"), null, null));
             }
         }));
     }
 }
コード例 #8
0
 public static void ShowUploadUi(ExternalContentType type, string name)
 {
     DialogsManager.ShowDialog(null, new SelectExternalContentProviderDialog(LanguageControl.Get(fName, 9), listingSupportRequired : false, delegate(IExternalContentProvider provider)
     {
         try
         {
             if (provider != null)
             {
                 ShowLoginUiIfNeeded(provider, showWarningDialog: true, delegate
                 {
                     CancellableBusyDialog busyDialog = new CancellableBusyDialog(LanguageControl.Get(fName, 10), autoHideOnCancel: false);
                     DialogsManager.ShowDialog(null, busyDialog);
                     Task.Run(delegate
                     {
                         bool needsDelete  = false;
                         string sourcePath = null;
                         Stream stream     = null;
                         Action cleanup    = delegate
                         {
                             Utilities.Dispose(ref stream);
                             if (needsDelete && sourcePath != null)
                             {
                                 try
                                 {
                                     Storage.DeleteFile(sourcePath);
                                 }
                                 catch
                                 {
                                 }
                             }
                         };
                         try
                         {
                             string path;
                             if (type == ExternalContentType.BlocksTexture)
                             {
                                 sourcePath = BlocksTexturesManager.GetFileName(name);
                                 if (sourcePath == null)
                                 {
                                     throw new InvalidOperationException(LanguageControl.Get(fName, 11));
                                 }
                                 path = Storage.GetFileName(sourcePath);
                             }
                             else if (type == ExternalContentType.CharacterSkin)
                             {
                                 sourcePath = CharacterSkinsManager.GetFileName(name);
                                 if (sourcePath == null)
                                 {
                                     throw new InvalidOperationException(LanguageControl.Get(fName, 11));
                                 }
                                 path = Storage.GetFileName(sourcePath);
                             }
                             else if (type == ExternalContentType.FurniturePack)
                             {
                                 sourcePath = FurniturePacksManager.GetFileName(name);
                                 if (sourcePath == null)
                                 {
                                     throw new InvalidOperationException(LanguageControl.Get(fName, 11));
                                 }
                                 path = Storage.GetFileName(sourcePath);
                             }
                             else
                             {
                                 if (type != ExternalContentType.World)
                                 {
                                     throw new InvalidOperationException(LanguageControl.Get(fName, 12));
                                 }
                                 busyDialog.LargeMessage = LanguageControl.Get(fName, 13);
                                 sourcePath   = "android:SurvivalCraft2.2/WorldUpload.tmp";
                                 needsDelete  = true;
                                 string name2 = WorldsManager.GetWorldInfo(name).WorldSettings.Name;
                                 path         = $"{name2}.scworld";
                                 using (Stream targetStream = Storage.OpenFile(sourcePath, OpenFileMode.Create))
                                 {
                                     WorldsManager.ExportWorld(name, targetStream);
                                 }
                             }
                             busyDialog.LargeMessage = LanguageControl.Get(fName, 14);
                             stream = Storage.OpenFile(sourcePath, OpenFileMode.Read);
                             provider.Upload(path, stream, busyDialog.Progress, delegate(string link)
                             {
                                 long length = stream.Length;
                                 cleanup();
                                 DialogsManager.HideDialog(busyDialog);
                                 if (string.IsNullOrEmpty(link))
                                 {
                                     DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "success"), string.Format(LanguageControl.Get(fName, 15), DataSizeFormatter.Format(length)), LanguageControl.Get("Usual", "ok"), null, null));
                                 }
                                 else
                                 {
                                     DialogsManager.ShowDialog(null, new ExternalContentLinkDialog(link));
                                 }
                             }, delegate(Exception error)
                             {
                                 cleanup();
                                 DialogsManager.HideDialog(busyDialog);
                                 DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), error.Message, LanguageControl.Get("Usual", "ok"), null, null));
                             });
                         }
                         catch (Exception ex2)
                         {
                             cleanup();
                             DialogsManager.HideDialog(busyDialog);
                             DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), ex2.Message, LanguageControl.Get("Usual", "ok"), null, null));
                         }
                     });
                 });
             }
         }
         catch (Exception ex)
         {
             DialogsManager.ShowDialog(null, new MessageDialog(LanguageControl.Get("Usual", "error"), ex.Message, LanguageControl.Get("Usual", "ok"), null, null));
         }
     }));
 }