private void RemoveShader(object sender, RoutedEventArgs e) { if (viewmodel.SelectedShader == null) { return; } var result = MessageBox.Show("This will remove the shader from the asset database, and the exported shader file from GameRepos\\Assets\\Shaders. Are you sure? (Do this only if its saved in mercurial)", "WARNING! SHADER DELETION IMMINENT!", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { //check to see if any state group depends on this shader var dependencyChecker = new DependencyChecker(); dependencyChecker.Dependencies = viewmodel.StateGroups.Where( m => m.VertexShader == viewmodel.SelectedShader || m.GeometryShader == viewmodel.SelectedShader || m.PixelShader == viewmodel.SelectedShader) .Select(m => new Dependency { Name = m.Name, AssetType = "StateGroup" }).ToList(); if (dependencyChecker.Dependencies.Count > 0) { dependencyChecker.Show(); MessageBox.Show("Can't remove this shader, there are state groups that depend on it. See the dependency window", "ERROR!", MessageBoxButton.OK, MessageBoxImage.Stop); return; } else { AssetMetadata.deleteShaderMetadata(viewmodel.SelectedShader); System.IO.File.Delete(viewmodel.SelectedShader.ImportedFilename); viewmodel.Shaders.Remove(viewmodel.SelectedShader); } } }
private void RemoveTexture(object sender, RoutedEventArgs e) { if (viewmodel.SelectedTexture == null) { return; } var result = MessageBox.Show("This will remove the texture from the asset database, and the exported texture file from GameRepos\\Assets\\Textures. Are you sure? (Do this only if its saved in mercurial)", "WARNING! TEXTURE DELETION IMMINENT!", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { //check to see if any material depends on this shader var dependencyChecker = new DependencyChecker(); dependencyChecker.Dependencies = viewmodel.Materials.Where( m => m.Textures.Where(t => t.SourceId == viewmodel.SelectedTexture.Name).ToList().Count > 0) .Select(m => new Dependency { Name = m.Name, AssetType = "Texture" }).ToList(); if (dependencyChecker.Dependencies.Count > 0) { dependencyChecker.Show(); MessageBox.Show("Can't remove this texture, there are materials that depend on it. See the dependency window", "ERROR!", MessageBoxButton.OK, MessageBoxImage.Stop); return; } else { AssetMetadata.deleteTextureMetadata(viewmodel.SelectedTexture); System.IO.File.Delete(viewmodel.SelectedTexture.ImportedFilename); viewmodel.Textures.Remove(viewmodel.SelectedTexture); } dependencyChecker.Close(); } }
private void CreateMaterial(object sender, RoutedEventArgs e) { var basedStateGroup = new BaseMaterialOnStateGroup(viewmodel.StateGroups.ToList()); var result = basedStateGroup.ShowDialog(); if (result == false) { return; } var editor = new MaterialEditor(basedStateGroup.SelectedStateGroup); editor.AvailableTextures = viewmodel.Textures; result = editor.ShowDialog(); if (result == true) { AssetMetadata.createMaterialMetadata(editor.asset); viewmodel.Materials.Add(editor.asset); } }
public static bool UpdateAsset(Object asset, out string error, out string successMessage) { error = ""; successMessage = ""; if (asset is MeshAsset) { MeshAsset mesh = asset as MeshAsset; var result = ImportMesh.import(mesh.SourceFilename, mesh.ImportedFilename); if (string.IsNullOrEmpty(result)) { successMessage = "Successfully updated mesh: " + mesh.Name; mesh.LastUpdated = DateTime.Now; AssetMetadata.createMeshMetadata(mesh); return(true); } } else if (asset is TextureAsset) { TextureAsset texture = asset as TextureAsset; var result = ImportTexture.import(texture.Format, texture.ChannelMappings, texture.ImportedFilename); if (string.IsNullOrEmpty(result)) { successMessage = "Successfully updated texture: " + texture.Name; texture.LastUpdated = DateTime.Now; AssetMetadata.createTextureMetadata(texture); return(true); } else { error = "ERROR: Updating texture: " + texture.Name + " failed!" + Environment.NewLine + result; } } else if (asset is ShaderAsset) { ShaderAsset shader = asset as ShaderAsset; var result = ImportShader.import(shader.SourceFilename, shader.ImportedFilename); if (string.IsNullOrEmpty(result)) { successMessage = "Successfully updated shader: " + shader.Name; shader.LastUpdated = DateTime.Now; AssetMetadata.createShaderMetadata(shader); return(true); } else { error = "ERROR: Updating shader: " + shader.Name + " failed!" + Environment.NewLine + result; } } else if (asset is MaterialAsset) { MaterialAsset material = asset as MaterialAsset; var result = MaterialImporter.Import(material); if (result) { successMessage = "Successfully updated material: " + material.Name; material.LastUpdated = DateTime.Now; AssetMetadata.createMaterialMetadata(material); return(true); } else { error = "ERROR: Updating material: " + material.Name + " failed!" + Environment.NewLine; } } else if (asset is StateGroupAsset) { var stateGroup = asset as StateGroupAsset; var result = StateGroupImporter.Import(stateGroup); if (result) { successMessage = "Successfully updated state group: " + stateGroup.Name; stateGroup.LastUpdated = DateTime.Now; AssetMetadata.createStateGroupMetadata(stateGroup); return(true); } else { error = "ERROR: Updating state group: " + stateGroup.Name + " failed!" + Environment.NewLine + result; } } return(false); }