Content Pipeline:
- Finished implementation of ContentProject (needs detailed testing though, not tested yet: saving/loading BuildItems, Saving loading References) Content Compiler: - Implemented opening of saved projects
This commit is contained in:
parent
778f52b4a1
commit
6105dd9c02
@ -13,9 +13,9 @@ using ANX.Framework.NonXNA.Development;
|
|||||||
|
|
||||||
namespace ANX.Framework.Content.Pipeline.Tasks
|
namespace ANX.Framework.Content.Pipeline.Tasks
|
||||||
{
|
{
|
||||||
//comment by author: if you find any mistakes in my language, go fix it ;-)
|
//comment by author: if you find any mistakes in my language, go fix them ;-)
|
||||||
[Developer("SilentWarrior/Eagle Eye Studios")]
|
[Developer("SilentWarrior/Eagle Eye Studios")]
|
||||||
[PercentageComplete(70)]
|
[PercentageComplete(100)]
|
||||||
[TestState(TestStateAttribute.TestState.InProgress)]
|
[TestState(TestStateAttribute.TestState.InProgress)]
|
||||||
public class ContentProject
|
public class ContentProject
|
||||||
{
|
{
|
||||||
@ -34,13 +34,18 @@ namespace ANX.Framework.Content.Pipeline.Tasks
|
|||||||
/// Minor version of the project format.
|
/// Minor version of the project format.
|
||||||
/// Used to keep backwards compatibility
|
/// Used to keep backwards compatibility
|
||||||
/// </summary>
|
/// </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).
|
public int VersionMinor { get { return 1; } } //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>
|
/// <summary>
|
||||||
/// The directory where the compiled output will be placed
|
/// The directory where the compiled output will be placed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public String OutputDirectory { get; set; }
|
public String OutputDirectory { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Source root directory where the majority of files is located in.
|
||||||
|
/// </summary>
|
||||||
|
public String InputDirectory { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Content Root Directory. Default value is "Content".
|
/// The Content Root Directory. Default value is "Content".
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -51,6 +56,11 @@ namespace ANX.Framework.Content.Pipeline.Tasks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public List<BuildItem> BuildItems { get; private set; }
|
public List<BuildItem> BuildItems { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A custom directory to look for custom importers/processors
|
||||||
|
/// </summary>
|
||||||
|
public String ReferenceIncludeDirectory { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List which holds Assemblies that contain custom importers/processors
|
/// List which holds Assemblies that contain custom importers/processors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -126,15 +136,23 @@ namespace ANX.Framework.Content.Pipeline.Tasks
|
|||||||
writer.WriteValue(OutputDirectory);
|
writer.WriteValue(OutputDirectory);
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
|
|
||||||
|
//<InputPath>A:\Somewhere</InputPath>
|
||||||
|
writer.WriteStartElement("InputPath");
|
||||||
|
writer.WriteValue(InputDirectory);
|
||||||
|
writer.WriteEndElement();
|
||||||
|
|
||||||
//<ContentRoot>Content</ContentRoot>
|
//<ContentRoot>Content</ContentRoot>
|
||||||
writer.WriteStartElement("ContentRoot");
|
writer.WriteStartElement("ContentRoot");
|
||||||
writer.WriteValue(ContentRoot);
|
writer.WriteValue(ContentRoot);
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
|
|
||||||
//<References>
|
//<References IncludeDir="B:\Pipeline">
|
||||||
// <Reference>ANX.Framework.Content.Pipeline.SomewhatImporter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=blah, ProcessorArch=MSIL</Reference>
|
// <Reference>ANX.Framework.Content.Pipeline.SomewhatImporter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=blah, ProcessorArch=MSIL</Reference>
|
||||||
//</References>
|
//</References>
|
||||||
writer.WriteStartElement("References");
|
writer.WriteStartElement("References");
|
||||||
|
writer.WriteStartAttribute("IncludeDir");
|
||||||
|
writer.WriteString(ReferenceIncludeDirectory);
|
||||||
|
writer.WriteEndAttribute();
|
||||||
foreach (var reference in References)
|
foreach (var reference in References)
|
||||||
{
|
{
|
||||||
writer.WriteStartElement("Reference");
|
writer.WriteStartElement("Reference");
|
||||||
@ -190,10 +208,159 @@ namespace ANX.Framework.Content.Pipeline.Tasks
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Load
|
#region Load
|
||||||
|
private static BuildItem lastBuildItem = null;
|
||||||
public static ContentProject Load(string path)
|
public static ContentProject Load(string path)
|
||||||
{
|
{
|
||||||
var project = new ContentProject("Blubb");
|
if (!File.Exists(path))
|
||||||
//TODO: Implement loading mechanism
|
throw new FileNotFoundException("The content project you tried to load does not exist: ", path);
|
||||||
|
|
||||||
|
var reader = XmlTextReader.Create(path);
|
||||||
|
ContentProject project = null;
|
||||||
|
String creator = null;
|
||||||
|
int versionMajor = 0;
|
||||||
|
int versionMinor = 0;
|
||||||
|
while (!reader.EOF)
|
||||||
|
{
|
||||||
|
var readerName = reader.Name;
|
||||||
|
switch (readerName)
|
||||||
|
{
|
||||||
|
case "ProjectName":
|
||||||
|
project = new ContentProject(reader.ReadElementContentAsString());
|
||||||
|
break;
|
||||||
|
case "ContentProject":
|
||||||
|
reader.MoveToAttribute("Version");
|
||||||
|
if (reader.NodeType == XmlNodeType.Attribute)
|
||||||
|
{
|
||||||
|
versionMajor = Convert.ToInt32(reader.ReadContentAsString().Split('.')[0]);
|
||||||
|
versionMinor = Convert.ToInt32(reader.ReadContentAsString().Split('.')[1]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Creator":
|
||||||
|
if (reader.NodeType == XmlNodeType.Attribute)
|
||||||
|
creator = reader.ReadContentAsString();
|
||||||
|
break;
|
||||||
|
case "Configuration":
|
||||||
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
|
if (versionMajor == 1 && versionMinor >= 0)
|
||||||
|
project.Configuration = reader.ReadElementContentAsString();
|
||||||
|
break;
|
||||||
|
case "Platform":
|
||||||
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
|
{
|
||||||
|
if (versionMajor == 1 && versionMinor >= 0)
|
||||||
|
{
|
||||||
|
switch (reader.ReadElementContentAsString())
|
||||||
|
{
|
||||||
|
case "Windows":
|
||||||
|
project.Platform = TargetPlatform.Windows;
|
||||||
|
break;
|
||||||
|
case "WindowsPhone":
|
||||||
|
project.Platform = TargetPlatform.WindowsPhone;
|
||||||
|
break;
|
||||||
|
case "Linux":
|
||||||
|
project.Platform = TargetPlatform.Linux;
|
||||||
|
break;
|
||||||
|
case "Android":
|
||||||
|
project.Platform = TargetPlatform.Android;
|
||||||
|
break;
|
||||||
|
case "IOS":
|
||||||
|
project.Platform = TargetPlatform.IOS;
|
||||||
|
break;
|
||||||
|
case "PsVita":
|
||||||
|
project.Platform = TargetPlatform.PsVita;
|
||||||
|
break;
|
||||||
|
case "MacOs":
|
||||||
|
project.Platform = TargetPlatform.MacOs;
|
||||||
|
break;
|
||||||
|
case "WindowsMetro":
|
||||||
|
project.Platform = TargetPlatform.WindowsMetro;
|
||||||
|
break;
|
||||||
|
case "XBox360":
|
||||||
|
project.Platform = TargetPlatform.XBox360;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "OutputPath":
|
||||||
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
|
if (versionMajor == 1 && versionMinor >= 0)
|
||||||
|
project.OutputDirectory = reader.ReadElementContentAsString();
|
||||||
|
break;
|
||||||
|
case "InputPath":
|
||||||
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
|
if (versionMajor == 1 && versionMinor >= 0)
|
||||||
|
project.InputDirectory = reader.ReadElementContentAsString();
|
||||||
|
break;
|
||||||
|
case "ContentRoot":
|
||||||
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
|
if (versionMajor == 1 && versionMinor >= 0)
|
||||||
|
project.ContentRoot = reader.ReadElementContentAsString();
|
||||||
|
break;
|
||||||
|
case "IncludeDir":
|
||||||
|
if (reader.NodeType == XmlNodeType.Attribute)
|
||||||
|
project.ReferenceIncludeDirectory = reader.ReadContentAsString();
|
||||||
|
break;
|
||||||
|
case "Reference":
|
||||||
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
|
if (versionMajor == 1 && versionMinor >= 0)
|
||||||
|
project.References.Add(reader.ReadElementContentAsString());
|
||||||
|
break;
|
||||||
|
case "BuildItem":
|
||||||
|
if (versionMajor == 1 && versionMinor >= 0)
|
||||||
|
{
|
||||||
|
var buildItem = new BuildItem();
|
||||||
|
lastBuildItem = buildItem;
|
||||||
|
if (reader.NodeType == XmlNodeType.Attribute)
|
||||||
|
{
|
||||||
|
switch (reader.Name)
|
||||||
|
{
|
||||||
|
case "AssetName":
|
||||||
|
buildItem.AssetName = reader.ReadContentAsString();
|
||||||
|
break;
|
||||||
|
case "OutputFilename":
|
||||||
|
buildItem.OutputFilename = reader.ReadContentAsString();
|
||||||
|
break;
|
||||||
|
case "Importer":
|
||||||
|
buildItem.ImporterName = reader.ReadContentAsString();
|
||||||
|
break;
|
||||||
|
case "Processor":
|
||||||
|
buildItem.ProcessorName = reader.ReadContentAsString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
project.BuildItems.Add(buildItem);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "SourceFile":
|
||||||
|
if (versionMajor == 1 && versionMinor >= 0)
|
||||||
|
{
|
||||||
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
|
lastBuildItem.SourceFilename = reader.ReadElementContentAsString();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "ProcessorParameter":
|
||||||
|
if (versionMajor == 1 && versionMinor >= 0)
|
||||||
|
{
|
||||||
|
string key;
|
||||||
|
object value;
|
||||||
|
reader.MoveToNextAttribute();
|
||||||
|
key = reader.ReadContentAsString();
|
||||||
|
reader.MoveToContent();
|
||||||
|
value = reader.ReadElementContentAsObject();
|
||||||
|
lastBuildItem.ProcessorParameters.Add(key, value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
reader.Read();
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
//Check for features that were added in format version 1.1
|
||||||
|
if (project.InputDirectory == null)
|
||||||
|
project.InputDirectory = "";
|
||||||
|
if (project.ReferenceIncludeDirectory == null)
|
||||||
|
project.ReferenceIncludeDirectory = "";
|
||||||
|
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -43,7 +43,7 @@ namespace ANX.ContentCompiler.GUI.Dialogues
|
|||||||
dlg.Title = "Select project to open";
|
dlg.Title = "Select project to open";
|
||||||
if (dlg.ShowDialog() == DialogResult.OK)
|
if (dlg.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
textBoxLocation.Text = dlg.SafeFileName;
|
textBoxLocation.Text = dlg.FileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DialogResult = DialogResult.None;
|
DialogResult = DialogResult.None;
|
||||||
@ -51,7 +51,7 @@ namespace ANX.ContentCompiler.GUI.Dialogues
|
|||||||
|
|
||||||
private void ButtonNextClick(object sender, EventArgs e)
|
private void ButtonNextClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(textBoxLocation.Text) || listBoxRecentProjects.SelectedItem == null)
|
if (String.IsNullOrEmpty(textBoxLocation.Text) && listBoxRecentProjects.SelectedItem == null)
|
||||||
MessageBox.Show("You need to select a project!", "Missing value", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show("You need to select a project!", "Missing value", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
else
|
else
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
|
@ -148,7 +148,7 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
this.ribbonButtonLoad.Name = "ribbonButtonLoad";
|
this.ribbonButtonLoad.Name = "ribbonButtonLoad";
|
||||||
this.ribbonButtonLoad.Size = new System.Drawing.Size(52, 68);
|
this.ribbonButtonLoad.Size = new System.Drawing.Size(52, 68);
|
||||||
this.ribbonButtonLoad.TabIndex = 4;
|
this.ribbonButtonLoad.TabIndex = 4;
|
||||||
this.ribbonButtonLoad.Click += new System.EventHandler(this.OpenProject);
|
this.ribbonButtonLoad.Click += new System.EventHandler(this.OpenProjectDialog);
|
||||||
//
|
//
|
||||||
// ribbonButtonNew
|
// ribbonButtonNew
|
||||||
//
|
//
|
||||||
|
@ -113,16 +113,30 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region OpenProject
|
#region OpenProject
|
||||||
public void OpenProject(object sender, EventArgs e)
|
public void OpenProjectDialog(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using (var dlg = new OpenProjectScreen())
|
using (var dlg = new OpenProjectScreen())
|
||||||
{
|
{
|
||||||
if (dlg.ShowDialog() == DialogResult.OK)
|
if (dlg.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
|
OpenProject(dlg.textBoxLocation.Text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void OpenProject(string path)
|
||||||
|
{
|
||||||
|
if (!File.Exists(path))
|
||||||
|
throw new FileNotFoundException("No file found at the given location:", path);
|
||||||
|
_contentProject = ContentProject.Load(path);
|
||||||
|
ProjectName = _contentProject.Name;
|
||||||
|
ProjectOutputDir = _contentProject.OutputDirectory;
|
||||||
|
ProjectFolder = _contentProject.InputDirectory;
|
||||||
|
ProjectImportersDir = _contentProject.ReferenceIncludeDirectory;
|
||||||
|
ProjectPath = path;
|
||||||
|
if (string.IsNullOrEmpty(_contentProject.Creator))
|
||||||
|
_contentProject.Creator = "ANX Content Compiler (4.0)";
|
||||||
|
ChangeEnvironmentOpenProject();
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SaveProject
|
#region SaveProject
|
||||||
|
@ -27,7 +27,7 @@ namespace ANX.ContentCompiler.GUI.States
|
|||||||
|
|
||||||
private void ArrowButtonLoadClick(object sender, System.EventArgs e)
|
private void ArrowButtonLoadClick(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
MainWindow.Instance.OpenProject(sender, e);
|
MainWindow.Instance.OpenProjectDialog(sender, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user