added cmd compatibility to the converter tool and
now you can convert from anx to xna as well (only todo is getting the FullName of the XNA assembly references and extensive testing)
This commit is contained in:
parent
2961704067
commit
74a1ca7417
21
Tools/XNAToANXConverter/ConverterForm.Designer.cs
generated
21
Tools/XNAToANXConverter/ConverterForm.Designer.cs
generated
@ -35,6 +35,7 @@
|
|||||||
this.browsePath2 = new System.Windows.Forms.Button();
|
this.browsePath2 = new System.Windows.Forms.Button();
|
||||||
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.listBox1 = new System.Windows.Forms.ListBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// convertButton
|
// convertButton
|
||||||
@ -43,7 +44,7 @@
|
|||||||
this.convertButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.convertButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.convertButton.Location = new System.Drawing.Point(161, 64);
|
this.convertButton.Location = new System.Drawing.Point(161, 64);
|
||||||
this.convertButton.Name = "convertButton";
|
this.convertButton.Name = "convertButton";
|
||||||
this.convertButton.Size = new System.Drawing.Size(275, 25);
|
this.convertButton.Size = new System.Drawing.Size(275, 40);
|
||||||
this.convertButton.TabIndex = 0;
|
this.convertButton.TabIndex = 0;
|
||||||
this.convertButton.Text = "Convert";
|
this.convertButton.Text = "Convert";
|
||||||
this.convertButton.UseVisualStyleBackColor = true;
|
this.convertButton.UseVisualStyleBackColor = true;
|
||||||
@ -110,11 +111,26 @@
|
|||||||
this.label1.TabIndex = 6;
|
this.label1.TabIndex = 6;
|
||||||
this.label1.Text = "Source";
|
this.label1.Text = "Source";
|
||||||
//
|
//
|
||||||
|
// listBox1
|
||||||
|
//
|
||||||
|
this.listBox1.Font = new System.Drawing.Font("Consolas", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.listBox1.FormattingEnabled = true;
|
||||||
|
this.listBox1.IntegralHeight = false;
|
||||||
|
this.listBox1.ItemHeight = 18;
|
||||||
|
this.listBox1.Items.AddRange(new object[] {
|
||||||
|
"XNA -> ANX",
|
||||||
|
"ANX -> XNA"});
|
||||||
|
this.listBox1.Location = new System.Drawing.Point(15, 64);
|
||||||
|
this.listBox1.Name = "listBox1";
|
||||||
|
this.listBox1.Size = new System.Drawing.Size(140, 40);
|
||||||
|
this.listBox1.TabIndex = 7;
|
||||||
|
//
|
||||||
// ConverterForm
|
// ConverterForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(451, 101);
|
this.ClientSize = new System.Drawing.Size(451, 114);
|
||||||
|
this.Controls.Add(this.listBox1);
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
this.Controls.Add(this.checkBox1);
|
this.Controls.Add(this.checkBox1);
|
||||||
this.Controls.Add(this.browsePath2);
|
this.Controls.Add(this.browsePath2);
|
||||||
@ -142,6 +158,7 @@
|
|||||||
private System.Windows.Forms.Button browsePath2;
|
private System.Windows.Forms.Button browsePath2;
|
||||||
private System.Windows.Forms.CheckBox checkBox1;
|
private System.Windows.Forms.CheckBox checkBox1;
|
||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.ListBox listBox1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ namespace XNAToANXConverter
|
|||||||
|
|
||||||
destPath.Enabled = false;
|
destPath.Enabled = false;
|
||||||
browsePath2.Enabled = false;
|
browsePath2.Enabled = false;
|
||||||
|
|
||||||
|
listBox1.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -100,7 +102,10 @@ namespace XNAToANXConverter
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectData.Convert(source, dest);
|
string target = listBox1.SelectedIndex == 0 ?
|
||||||
|
"anx" : "xna";
|
||||||
|
|
||||||
|
ProjectData.Convert(target, source, dest);
|
||||||
MessageBox.Show("Finished conversion!", "Conversion");
|
MessageBox.Show("Finished conversion!", "Conversion");
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -1,19 +1,56 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace XNAToANXConverter
|
namespace XNAToANXConverter
|
||||||
{
|
{
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Der Haupteinstiegspunkt für die Anwendung.
|
/// Starting the tool via cmd:
|
||||||
|
///
|
||||||
|
/// Converting into the same file:
|
||||||
|
/// "XNAToANXConverter.exe anx C:\code\testproject.csproj"
|
||||||
|
///
|
||||||
|
/// Converting into different file:
|
||||||
|
/// "XNAToANXConverter.exe anx C:\code\testproject.csproj C:\converted\test.csproj"
|
||||||
|
///
|
||||||
|
/// Converting ANX to XNA:
|
||||||
|
/// "XNAToANXConverter.exe xna C:\code\testproject.csproj"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Application.EnableVisualStyles();
|
if (args.Length > 0)
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
{
|
||||||
Application.Run(new ConverterForm());
|
#region Cmd starting
|
||||||
|
string target = args[0].ToLower();
|
||||||
|
if (target != "anx" &&
|
||||||
|
target != "xna")
|
||||||
|
{
|
||||||
|
Console.WriteLine("Unknown target '" + target +
|
||||||
|
"'. Valid targets are 'xna' or 'anx'.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string sourcePath = args[1];
|
||||||
|
if (File.Exists(sourcePath) == false)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Failed to convert. The sourcefile doesn't exist!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string destPath = args.Length > 2 ? args[2] : sourcePath;
|
||||||
|
|
||||||
|
Console.WriteLine("Starting conversion...");
|
||||||
|
ProjectData.Convert(target, sourcePath, destPath);
|
||||||
|
Console.WriteLine("Conversion complete!");
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new ConverterForm());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace XNAToANXConverter
|
namespace XNAToANXConverter
|
||||||
{
|
{
|
||||||
@ -12,7 +10,8 @@ namespace XNAToANXConverter
|
|||||||
private const string AnxBaseName = "ANX.Framework";
|
private const string AnxBaseName = "ANX.Framework";
|
||||||
|
|
||||||
#region Convert
|
#region Convert
|
||||||
public static void Convert(string sourceFilepath, string destinationFilepath)
|
public static void Convert(string target, string sourceFilepath,
|
||||||
|
string destinationFilepath)
|
||||||
{
|
{
|
||||||
string sourceFolderPath =
|
string sourceFolderPath =
|
||||||
sourceFilepath.Replace(Path.GetFileName(sourceFilepath), "");
|
sourceFilepath.Replace(Path.GetFileName(sourceFilepath), "");
|
||||||
@ -40,17 +39,37 @@ namespace XNAToANXConverter
|
|||||||
{
|
{
|
||||||
#region Process Reference
|
#region Process Reference
|
||||||
string assemblyPath = item.Attribute("Include").Value;
|
string assemblyPath = item.Attribute("Include").Value;
|
||||||
if (assemblyPath.Contains(XnaBaseName))
|
if (target == "anx")
|
||||||
{
|
{
|
||||||
item.Remove();
|
#region ANX
|
||||||
|
if (assemblyPath.Contains(XnaBaseName))
|
||||||
string anxPath = assemblyPath.Replace(XnaBaseName, AnxBaseName);
|
|
||||||
if (anxPath.Contains(", Version"))
|
|
||||||
{
|
{
|
||||||
anxPath = anxPath.Substring(0, anxPath.IndexOf(',')) + ".dll";
|
item.Remove();
|
||||||
|
|
||||||
|
string anxPath = assemblyPath.Replace(XnaBaseName, AnxBaseName);
|
||||||
|
if (anxPath.Contains(", Version"))
|
||||||
|
{
|
||||||
|
anxPath = anxPath.Substring(0, anxPath.IndexOf(',')) + ".dll";
|
||||||
|
}
|
||||||
|
propertyGroup.Add(new XElement("Reference",
|
||||||
|
new XAttribute("Include", anxPath)));
|
||||||
}
|
}
|
||||||
propertyGroup.Add(new XElement("Reference",
|
#endregion
|
||||||
new XAttribute("Include", anxPath)));
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#region XNA
|
||||||
|
if (assemblyPath.Contains(AnxBaseName))
|
||||||
|
{
|
||||||
|
item.Remove();
|
||||||
|
|
||||||
|
// TODO: FQN of the xna assemby
|
||||||
|
|
||||||
|
string xnaPath = assemblyPath.Replace(AnxBaseName, XnaBaseName);
|
||||||
|
propertyGroup.Add(new XElement("Reference",
|
||||||
|
new XAttribute("Include", xnaPath)));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -61,7 +80,14 @@ namespace XNAToANXConverter
|
|||||||
string absolutePath = Path.Combine(sourceFolderPath, codeFilepath);
|
string absolutePath = Path.Combine(sourceFolderPath, codeFilepath);
|
||||||
string text = File.ReadAllText(absolutePath);
|
string text = File.ReadAllText(absolutePath);
|
||||||
|
|
||||||
text = text.Replace(XnaBaseName, AnxBaseName);
|
if (target == "anx")
|
||||||
|
{
|
||||||
|
text = text.Replace(XnaBaseName, AnxBaseName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text = text.Replace(AnxBaseName, XnaBaseName);
|
||||||
|
}
|
||||||
|
|
||||||
string destCodeFolderPath = codeFilepath.Replace(
|
string destCodeFolderPath = codeFilepath.Replace(
|
||||||
Path.GetFileName(codeFilepath), "");
|
Path.GetFileName(codeFilepath), "");
|
||||||
@ -79,6 +105,11 @@ namespace XNAToANXConverter
|
|||||||
}
|
}
|
||||||
else if (item.Name.LocalName == "BootstrapperPackage")
|
else if (item.Name.LocalName == "BootstrapperPackage")
|
||||||
{
|
{
|
||||||
|
if (target == "xna")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
#region Process BootstrapperPackage
|
#region Process BootstrapperPackage
|
||||||
// Remove all bootstrapper tasks for XNA.
|
// Remove all bootstrapper tasks for XNA.
|
||||||
string includeName = item.Attribute("Include").Value;
|
string includeName = item.Attribute("Include").Value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user