Content Pipeline:

- added ContentProject to Tasks namespace
- implemented Saving of the ContentProject (Loading is still missing)
Content Compiler:
- Basic creation/saving of an empty project without any files to XML works
- added Save and SaveAs implementations
This commit is contained in:
SND\eagleeyestudios_cp 2012-08-29 19:02:13 +00:00
parent b3895055bd
commit a85b5e51ee
10 changed files with 289 additions and 33 deletions

View File

@ -35,6 +35,7 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AnxContentImporterContext.cs" />
@ -180,6 +181,7 @@
<Compile Include="TargetPlatform.cs" />
<Compile Include="Tasks\BuildContent.cs" />
<Compile Include="Tasks\BuildItem.cs" />
<Compile Include="Tasks\ContentProject.cs" />
<Compile Include="Tasks\ImporterManager.cs" />
<Compile Include="Tasks\ProcessorManager.cs" />
<Compile Include="VideoContent.cs" />

View File

@ -0,0 +1,202 @@
#region Using Statements
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using ANX.Framework.NonXNA.Development;
#endregion
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace ANX.Framework.Content.Pipeline.Tasks
{
//comment by author: if you find any mistakes in my language, go fix it ;-)
[Developer("SilentWarrior/Eagle Eye Studios")]
[PercentageComplete(70)]
[TestState(TestStateAttribute.TestState.InProgress)]
public class ContentProject
{
#region Properties
/// <summary>
/// Name of the Content Project
/// </summary>
public String Name { get; set; }
/// <summary>
/// Major version of the project format
/// </summary>
public int VersionMajor { get { return 1; } }
/// <summary>
/// Minor version of the project format.
/// Used to keep backwards compatibility
/// </summary>
public int VersionMinor { get { return 0; } } //before you commit your changes, please increase this value by one (and if you added stuff, please check the version before you read anything out of a file).
/// <summary>
/// The directory where the compiled output will be placed
/// </summary>
public String OutputDirectory { get; set; }
/// <summary>
/// The Content Root Directory. Default value is "Content".
/// </summary>
public String ContentRoot { get; set; }
/// <summary>
/// A list containing all build items of this project
/// </summary>
public List<BuildItem> BuildItems { get; private set; }
/// <summary>
/// List which holds Assemblies that contain custom importers/processors
/// </summary>
public List<String> References { get; set; }
/// <summary>
/// Name of the tool that generated the resulting file. Might be useful for tracking down
/// bugs in that particular application.
/// </summary>
public String Creator { get; set; }
/// <summary>
/// The configuration. Can be "Debug" or "Release".
/// </summary>
public String Configuration { get; set; }
/// <summary>
/// The platform the content will be compiled for.
/// </summary>
public TargetPlatform Platform { get; set; }
#endregion
/// <summary>
/// Initializes a new instance of a <see cref="ContentProject"/>
/// </summary>
/// <param name="name">Name of the project</param>
public ContentProject(String name)
{
Name = name;
OutputDirectory = "bin";
BuildItems = new List<BuildItem>();
References = new List<string>();
}
#region Save
/// <summary>
/// Saves the project into a file. Should be a .cproj extension.
/// </summary>
/// <param name="path">The path to save the project</param>
public void Save(string path)
{
if (!Directory.Exists(Path.GetDirectoryName(path)))
Directory.CreateDirectory(Path.GetDirectoryName(path));
XmlWriter writer = XmlTextWriter.Create(path, new XmlWriterSettings() {Encoding = Encoding.UTF8, Indent = true, NewLineHandling = NewLineHandling.Entitize} );
writer.WriteStartDocument();
// <ContentProject Version="4.0">
writer.WriteStartElement("ContentProject");
writer.WriteStartAttribute("Version");
writer.WriteValue(VersionMajor + "." + VersionMinor);
writer.WriteEndAttribute();
writer.WriteStartAttribute("Creator");
writer.WriteValue(Creator);
writer.WriteEndAttribute();
//<ProjectName>Name</ProjectName>
writer.WriteStartElement("ProjectName");
writer.WriteValue(Name);
writer.WriteEndElement();
//<Configuration>Debug</Configuration>
writer.WriteStartElement("Configuration");
writer.WriteValue(Configuration);
writer.WriteEndElement();
//<Platform>Windows</Platform>
writer.WriteStartElement("Platform");
writer.WriteValue(Platform.ToString());
writer.WriteEndElement();
//<OutputPath>A:\Somewhere</OutputPath>
writer.WriteStartElement("OutputPath");
writer.WriteValue(OutputDirectory);
writer.WriteEndElement();
//<ContentRoot>Content</ContentRoot>
writer.WriteStartElement("ContentRoot");
writer.WriteValue(ContentRoot);
writer.WriteEndElement();
//<References>
// <Reference>ANX.Framework.Content.Pipeline.SomewhatImporter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=blah, ProcessorArch=MSIL</Reference>
//</References>
writer.WriteStartElement("References");
foreach (var reference in References)
{
writer.WriteStartElement("Reference");
writer.WriteValue(reference);
writer.WriteEndElement();
}
writer.WriteEndElement();
//<BuildItems>
// <BuildItem AssetName="Content/MyPicture" OutputFilename="Content/MyPicture.xnb" Importer="TextureImporter" Processor="TextureProcessor">
// <SourceFile>A:\MyPicture.png</SourceFile>
// <ProcessorParams>
// <Parameter Name="DoThis">True</Parameter>
// <ProcessorParams>
// </BuildItem>
//</BuildItems
writer.WriteStartElement("BuildItems");
foreach (var buildItem in BuildItems)
{
writer.WriteStartElement("BuildItem");
writer.WriteStartAttribute("AssetName");
writer.WriteValue(buildItem.AssetName);
writer.WriteEndAttribute();
writer.WriteStartAttribute("OutputFilename");
writer.WriteValue(buildItem.OutputFilename);
writer.WriteEndAttribute();
writer.WriteStartAttribute("Importer");
writer.WriteValue(buildItem.ImporterName);
writer.WriteEndAttribute();
writer.WriteStartAttribute("Processor");
writer.WriteValue(buildItem.ProcessorName);
writer.WriteEndAttribute();
writer.WriteStartElement("SourceFile");
writer.WriteValue(buildItem.SourceFilename);
writer.WriteEndElement();
writer.WriteStartElement("ProcessorParams");
foreach (var pair in buildItem.ProcessorParameters)
{
writer.WriteStartElement("Parameter");
writer.WriteStartAttribute("Name");
writer.WriteValue(pair.Key);
writer.WriteEndAttribute();
writer.WriteValue(pair.Value);
writer.WriteEndElement();
}
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.Flush();
writer.Close();
}
#endregion
#region Load
public static ContentProject Load(string path)
{
var project = new ContentProject("Blubb");
//TODO: Implement loading mechanism
return project;
}
#endregion
}
}

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ANX.ContentCompiler.GUI</RootNamespace>
<AssemblyName>ccompiler4</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
@ -195,6 +195,12 @@
<None Include="Resources\arrow.png" />
<Content Include="Resources\clouds.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ANX.Framework.Content.Pipeline\ANX.Framework.Content.Pipeline.csproj">
<Project>{2DAFDFC1-223B-4741-87BB-BE3D0A7617DB}</Project>
<Name>ANX.Framework.Content.Pipeline</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,8 +1,7 @@
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727" />
</startup>
</configuration>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>

View File

@ -54,13 +54,16 @@ namespace ANX.ContentCompiler.GUI
this.labelProperties = new System.Windows.Forms.Label();
this.propertyGrid = new System.Windows.Forms.PropertyGrid();
this.menuState = new ANX.ContentCompiler.GUI.States.MenuState();
((System.ComponentModel.ISupportInitialize)(this.splitContainerMenuLayout)).BeginInit();
this.splitContainerMenuLayout.Panel1.SuspendLayout();
this.splitContainerMenuLayout.Panel2.SuspendLayout();
this.splitContainerMenuLayout.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainerFileTree)).BeginInit();
this.splitContainerFileTree.Panel1.SuspendLayout();
this.splitContainerFileTree.Panel2.SuspendLayout();
this.splitContainerFileTree.SuspendLayout();
this.treeViewContextMenu.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainerProperties)).BeginInit();
this.splitContainerProperties.Panel1.SuspendLayout();
this.splitContainerProperties.Panel2.SuspendLayout();
this.splitContainerProperties.SuspendLayout();
@ -134,6 +137,7 @@ namespace ANX.ContentCompiler.GUI
this.ribbonButtonSave.Name = "ribbonButtonSave";
this.ribbonButtonSave.Size = new System.Drawing.Size(52, 68);
this.ribbonButtonSave.TabIndex = 5;
this.ribbonButtonSave.Click += new System.EventHandler(this.SaveProject);
//
// ribbonButtonLoad
//
@ -403,13 +407,16 @@ namespace ANX.ContentCompiler.GUI
this.Shown += new System.EventHandler(this.MainWindowShown);
this.splitContainerMenuLayout.Panel1.ResumeLayout(false);
this.splitContainerMenuLayout.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainerMenuLayout)).EndInit();
this.splitContainerMenuLayout.ResumeLayout(false);
this.splitContainerFileTree.Panel1.ResumeLayout(false);
this.splitContainerFileTree.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainerFileTree)).EndInit();
this.splitContainerFileTree.ResumeLayout(false);
this.treeViewContextMenu.ResumeLayout(false);
this.splitContainerProperties.Panel1.ResumeLayout(false);
this.splitContainerProperties.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainerProperties)).EndInit();
this.splitContainerProperties.ResumeLayout(false);
this.ResumeLayout(false);

View File

@ -3,6 +3,8 @@ using System.Drawing;
using System.IO;
using System.Windows.Forms;
using ANX.ContentCompiler.GUI.Dialogues;
using ANX.Framework.Content.Pipeline;
using ANX.Framework.Content.Pipeline.Tasks;
namespace ANX.ContentCompiler.GUI
{
@ -16,6 +18,8 @@ namespace ANX.ContentCompiler.GUI
private bool _mouseDown;
private bool _menuMode;
private readonly bool _firstStart = true;
private ContentProject _contentProject;
#endregion
#region Properties
@ -65,6 +69,7 @@ namespace ANX.ContentCompiler.GUI
{
ProjectName = dlg.textBoxName.Text;
ProjectFolder = !String.IsNullOrEmpty(dlg.textBoxLocation.Text) ? dlg.textBoxLocation.Text : Path.Combine(Settings.DefaultProjectPath, ProjectName);
ProjectPath = Path.Combine(ProjectFolder, ProjectName + ".cproj");
}
else
{
@ -95,6 +100,14 @@ namespace ANX.ContentCompiler.GUI
{
dlg4.ShowDialog();
}
_contentProject = new ContentProject(ProjectName)
{
OutputDirectory = ProjectOutputDir,
Configuration = "Release",
Creator = "ANX Content Compiler (4.0)",
ContentRoot = "Content",
Platform = TargetPlatform.Windows
};
ChangeEnvironmentOpenProject();
}
#endregion
@ -112,6 +125,33 @@ namespace ANX.ContentCompiler.GUI
}
#endregion
#region SaveProject
public void SaveProject(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(ProjectPath))
SaveProjectAs(sender, e);
_contentProject.Save(ProjectPath);
}
#endregion
#region SaveProjectAs
public void SaveProjectAs(object sender, EventArgs e)
{
using (var dlg = new SaveFileDialog())
{
dlg.Title = "Save project as";
dlg.AddExtension = true;
dlg.Filter = "ANX Content Project (*.cproj)|*.cproj|Compressed Content Project (*.ccproj)|*.ccproj";
if (dlg.ShowDialog() == DialogResult.OK)
{
ProjectPath = dlg.FileName;
SaveProject(sender, e);
}
}
}
#endregion
#region EnvironmentStates
public void ChangeEnvironmentStartState()
{

View File

@ -112,12 +112,12 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="treeViewContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="treeViewContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>16, 30</value>
</metadata>
</root>

View File

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
@ -13,12 +13,12 @@ namespace ANX.ContentCompiler.GUI.Properties {
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
@ -33,7 +33,7 @@ namespace ANX.ContentCompiler.GUI.Properties {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
@ -47,8 +47,8 @@ namespace ANX.ContentCompiler.GUI.Properties {
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
@ -61,7 +61,7 @@ namespace ANX.ContentCompiler.GUI.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrow {
get {
@ -71,7 +71,7 @@ namespace ANX.ContentCompiler.GUI.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrow_left {
get {
@ -81,7 +81,7 @@ namespace ANX.ContentCompiler.GUI.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrow_right {
get {
@ -91,7 +91,7 @@ namespace ANX.ContentCompiler.GUI.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap clouds {
get {
@ -101,7 +101,7 @@ namespace ANX.ContentCompiler.GUI.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Deleket_Smileys_8 {
get {

View File

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
@ -12,7 +12,7 @@ namespace ANX.ContentCompiler.GUI.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

View File

@ -77,7 +77,7 @@ namespace ANX.ContentCompiler.GUI.States
private void ButtonSaveClick(object sender, EventArgs e)
{
MainWindow.Instance.SaveProject(sender, e);
}
private void ButtonSaveAsClick(object sender, EventArgs e)
@ -141,12 +141,12 @@ namespace ANX.ContentCompiler.GUI.States
#region MenuSave
private void ArrowButtonSaveAsCprojClick(object sender, EventArgs e)
{
MainWindow.Instance.SaveProjectAs(sender, e);
}
private void ArrowButtonSaveAsCcProjClick(object sender, EventArgs e)
{
MainWindow.Instance.SaveProjectAs(sender, e);
}
#endregion