From a85b5e51ee8a9245daf62e7c07365486a976892a Mon Sep 17 00:00:00 2001 From: "SND\\eagleeyestudios_cp" Date: Wed, 29 Aug 2012 19:02:13 +0000 Subject: [PATCH] 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 --- .../ANX.Framework.Content.Pipeline.csproj | 2 + .../Tasks/ContentProject.cs | 202 ++++++++++++++++++ .../ANX.ContentCompiler.GUI.csproj | 8 +- Tools/ANXContentCompilerGUI/App.config | 7 +- .../MainWindow.Designer.cs | 7 + Tools/ANXContentCompilerGUI/MainWindow.cs | 40 ++++ Tools/ANXContentCompilerGUI/MainWindow.resx | 6 +- .../Properties/Resources.Designer.cs | 34 +-- .../Properties/Settings.Designer.cs | 10 +- .../ANXContentCompilerGUI/States/MenuState.cs | 6 +- 10 files changed, 289 insertions(+), 33 deletions(-) create mode 100644 ANX.Framework.Content.Pipeline/Tasks/ContentProject.cs diff --git a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj index c8b9bf4a..ba7e0b64 100644 --- a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj +++ b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj @@ -35,6 +35,7 @@ + @@ -180,6 +181,7 @@ + diff --git a/ANX.Framework.Content.Pipeline/Tasks/ContentProject.cs b/ANX.Framework.Content.Pipeline/Tasks/ContentProject.cs new file mode 100644 index 00000000..cff6fadf --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Tasks/ContentProject.cs @@ -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 + /// + /// Name of the Content Project + /// + public String Name { get; set; } + + /// + /// Major version of the project format + /// + public int VersionMajor { get { return 1; } } + + /// + /// Minor version of the project format. + /// Used to keep backwards compatibility + /// + 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). + + /// + /// The directory where the compiled output will be placed + /// + public String OutputDirectory { get; set; } + + /// + /// The Content Root Directory. Default value is "Content". + /// + public String ContentRoot { get; set; } + + /// + /// A list containing all build items of this project + /// + public List BuildItems { get; private set; } + + /// + /// List which holds Assemblies that contain custom importers/processors + /// + public List References { get; set; } + + /// + /// Name of the tool that generated the resulting file. Might be useful for tracking down + /// bugs in that particular application. + /// + public String Creator { get; set; } + + /// + /// The configuration. Can be "Debug" or "Release". + /// + public String Configuration { get; set; } + + /// + /// The platform the content will be compiled for. + /// + public TargetPlatform Platform { get; set; } + #endregion + + /// + /// Initializes a new instance of a + /// + /// Name of the project + public ContentProject(String name) + { + Name = name; + OutputDirectory = "bin"; + BuildItems = new List(); + References = new List(); + } + + #region Save + /// + /// Saves the project into a file. Should be a .cproj extension. + /// + /// The path to save the project + 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(); + + // + writer.WriteStartElement("ContentProject"); + writer.WriteStartAttribute("Version"); + writer.WriteValue(VersionMajor + "." + VersionMinor); + writer.WriteEndAttribute(); + writer.WriteStartAttribute("Creator"); + writer.WriteValue(Creator); + writer.WriteEndAttribute(); + + //Name + writer.WriteStartElement("ProjectName"); + writer.WriteValue(Name); + writer.WriteEndElement(); + + //Debug + writer.WriteStartElement("Configuration"); + writer.WriteValue(Configuration); + writer.WriteEndElement(); + + //Windows + writer.WriteStartElement("Platform"); + writer.WriteValue(Platform.ToString()); + writer.WriteEndElement(); + + //A:\Somewhere + writer.WriteStartElement("OutputPath"); + writer.WriteValue(OutputDirectory); + writer.WriteEndElement(); + + //Content + writer.WriteStartElement("ContentRoot"); + writer.WriteValue(ContentRoot); + writer.WriteEndElement(); + + // + // ANX.Framework.Content.Pipeline.SomewhatImporter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=blah, ProcessorArch=MSIL + // + writer.WriteStartElement("References"); + foreach (var reference in References) + { + writer.WriteStartElement("Reference"); + writer.WriteValue(reference); + writer.WriteEndElement(); + } + writer.WriteEndElement(); + + // + // + // A:\MyPicture.png + // + // True + // + // + //Properties ANX.ContentCompiler.GUI ccompiler4 - v3.5 + v4.0 512 @@ -195,6 +195,12 @@ + + + {2DAFDFC1-223B-4741-87BB-BE3D0A7617DB} + ANX.Framework.Content.Pipeline + +