コード例 #1
0
        private async Task SaveWorldSchema()
        {
            if (File.Exists(this.WorldSchemaFilePath))
            {
                string fileContents = null;
                using (StreamReader reader = new StreamReader(File.OpenRead(this.WorldSchemaFilePath)))
                {
                    fileContents = await reader.ReadToEndAsync();
                }

                if (!string.IsNullOrEmpty(fileContents))
                {
                    JArray schemas = SerializerHelper.DeserializeObjectFromString <JArray>(fileContents);
                    foreach (JToken schema in schemas)
                    {
                        if (schema["name"] != null && schema["name"].ToString().Equals("$working"))
                        {
                            List <InteractiveSceneModel> sceneData = new List <InteractiveSceneModel>();
                            foreach (SceneViewModel scene in this.Scenes)
                            {
                                sceneData.Add(scene.GetSceneData());
                            }
                            schema["world"]["scenes"] = JArray.FromObject(sceneData);
                        }
                    }

                    using (StreamWriter writer = new StreamWriter(File.Open(this.WorldSchemaFilePath, FileMode.Create)))
                    {
                        await writer.WriteAsync(SerializerHelper.SerializeObjectToString(schemas));
                    }
                }
            }
        }
コード例 #2
0
        private async void LoadProjectButton_Click(object sender, RoutedEventArgs e)
        {
            await this.LoadingOperation(async() =>
            {
                OpenFileDialog fileDialog  = new OpenFileDialog();
                fileDialog.Filter          = CDKProjectViewModel.MixPlayCreatorSettingsFileBrowserFilter;
                fileDialog.CheckFileExists = true;
                fileDialog.CheckPathExists = true;
                if (fileDialog.ShowDialog() == true)
                {
                    using (StreamReader reader = new StreamReader(File.OpenRead(fileDialog.FileName)))
                    {
                        string fileContents     = await reader.ReadToEndAsync();
                        CDKProjectModel project = SerializerHelper.DeserializeObjectFromString <CDKProjectModel>(fileContents);
                        App.Project             = new CDKProjectViewModel(project, fileDialog.FileName);
                    }

                    this.SwitchToProjectGrid();
                }
            });
        }
コード例 #3
0
        public async Task UploadLinkedInteractiveGame(MixerConnection connection)
        {
            InteractiveGameListingModel linkedGame = null;

            using (StreamReader reader = new StreamReader(File.OpenRead(this.LinkedInteractiveGameJSONFilePath)))
            {
                string fileContents = await reader.ReadToEndAsync();

                linkedGame = SerializerHelper.DeserializeObjectFromString <InteractiveGameListingModel>(fileContents);
            }

            InteractiveGameVersionModel version = linkedGame.versions[0];

            version = await connection.Interactive.GetInteractiveGameVersion(version);

            version.controls.scenes = new List <InteractiveSceneModel>();
            foreach (SceneViewModel scene in this.Scenes)
            {
                version.controls.scenes.Add(scene.GetSceneData());
            }

            version = await connection.Interactive.UpdateInteractiveGameVersion(version);
        }