Exemplo n.º 1
0
        private void EditStateGroup(object sender, RoutedEventArgs e)
        {
            if (viewmodel.SelectedStateGroup == null)
            {
                return;
            }

            string oldName     = viewmodel.SelectedStateGroup.Name;
            string oldImported = viewmodel.SelectedStateGroup.ImportedFilename;

            var editor = new StateGroupEditor(viewmodel.SelectedStateGroup);

            editor.AvailableVertexShaders = viewmodel.Shaders;

            editor.AvailableGeometryShaders = new ObservableCollection <ShaderAsset>(viewmodel.Shaders.Where(s =>
                                                                                                             s.Combination == ShaderCombination.VertexGeometry || s.Combination == ShaderCombination.VertexGeometryPixel));

            editor.AvailablePixelShaders = new ObservableCollection <ShaderAsset>(viewmodel.Shaders.Where(s =>
                                                                                                          s.Combination == ShaderCombination.VertexPixel || s.Combination == ShaderCombination.VertexGeometryPixel));

            var result = editor.ShowDialog();

            if (result == true)
            {
                if (oldName != editor.asset.Name)
                {
                    var newName = editor.asset.Name;

                    editor.asset.Name = oldName;

                    //we changed the name, delete the old asset then create a new one
                    System.IO.File.Delete(oldImported);

                    editor.asset.Name = newName;
                }
                else
                {
                    AssetMetadata.createStateGroupMetadata(viewmodel.SelectedStateGroup);
                }
            }
        }
Exemplo n.º 2
0
        private void CreateStateGroup(object sender, RoutedEventArgs e)
        {
            StateGroupEditor editor = new StateGroupEditor();

            editor.AvailableVertexShaders = viewmodel.Shaders;

            editor.AvailableGeometryShaders = new ObservableCollection <ShaderAsset>(viewmodel.Shaders.Where(s =>
                                                                                                             s.Combination == ShaderCombination.VertexGeometry || s.Combination == ShaderCombination.VertexGeometryPixel));

            editor.AvailablePixelShaders = new ObservableCollection <ShaderAsset>(viewmodel.Shaders.Where(s =>
                                                                                                          s.Combination == ShaderCombination.VertexPixel || s.Combination == ShaderCombination.VertexGeometryPixel));

            var result = editor.ShowDialog();

            if (result == true)
            {
                AssetMetadata.createStateGroupMetadata(editor.asset);

                viewmodel.StateGroups.Add(editor.asset);
            }
        }