diff --git a/OpenRa.sln b/OpenRa.sln index 39f8228def..5670655036 100644 --- a/OpenRa.sln +++ b/OpenRa.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaletteUsage", "PaletteUsag EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaletteMatch", "PaletteMatch\PaletteMatch.csproj", "{31411761-224C-4C54-A5FE-280890A70259}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SequenceEditor", "SequenceEditor\SequenceEditor.csproj", "{230F65CE-A6DE-4235-8B38-13A3D606C7F7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug (x86)|Any CPU = Debug (x86)|Any CPU @@ -104,6 +106,7 @@ Global {31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|Any CPU {31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Mixed Platforms.Build.0 = Debug|Any CPU {31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Win32.ActiveCfg = Debug|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Win32.Build.0 = Debug|Any CPU {31411761-224C-4C54-A5FE-280890A70259}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {31411761-224C-4C54-A5FE-280890A70259}.Debug|Any CPU.Build.0 = Debug|Any CPU {31411761-224C-4C54-A5FE-280890A70259}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -119,6 +122,27 @@ Global {31411761-224C-4C54-A5FE-280890A70259}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {31411761-224C-4C54-A5FE-280890A70259}.Release|Mixed Platforms.Build.0 = Release|Any CPU {31411761-224C-4C54-A5FE-280890A70259}.Release|Win32.ActiveCfg = Release|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Any CPU.ActiveCfg = Debug|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Any CPU.Build.0 = Debug|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Mixed Platforms.Build.0 = Debug|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Win32.ActiveCfg = Debug|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Win32.Build.0 = Debug|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Win32.ActiveCfg = Debug|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Any CPU.ActiveCfg = Release|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Any CPU.Build.0 = Release|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Mixed Platforms.ActiveCfg = Release|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Mixed Platforms.Build.0 = Release|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Win32.ActiveCfg = Release|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Any CPU.Build.0 = Release|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Win32.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SequenceEditor/Form1.Designer.cs b/SequenceEditor/Form1.Designer.cs new file mode 100644 index 0000000000..e4eca1ff59 --- /dev/null +++ b/SequenceEditor/Form1.Designer.cs @@ -0,0 +1,60 @@ +namespace SequenceEditor +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.surface1 = new SequenceEditor.Surface(); + this.SuspendLayout(); + // + // surface1 + // + this.surface1.Dock = System.Windows.Forms.DockStyle.Fill; + this.surface1.Location = new System.Drawing.Point(0, 0); + this.surface1.Name = "surface1"; + this.surface1.Size = new System.Drawing.Size(708, 543); + this.surface1.TabIndex = 0; + this.surface1.Text = "surface1"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(708, 543); + this.Controls.Add(this.surface1); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + + } + + #endregion + + private Surface surface1; + } +} + diff --git a/SequenceEditor/Form1.cs b/SequenceEditor/Form1.cs new file mode 100644 index 0000000000..090ca582f7 --- /dev/null +++ b/SequenceEditor/Form1.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using OpenRa.FileFormats; + +namespace SequenceEditor +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} diff --git a/SequenceEditor/Form1.resx b/SequenceEditor/Form1.resx new file mode 100644 index 0000000000..ff31a6db56 --- /dev/null +++ b/SequenceEditor/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SequenceEditor/Program.cs b/SequenceEditor/Program.cs new file mode 100644 index 0000000000..d07e7991e2 --- /dev/null +++ b/SequenceEditor/Program.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using OpenRa.FileFormats; +using System.Xml; +using System.Drawing; +using System.Drawing.Imaging; + +namespace SequenceEditor +{ + static class Program + { + public static string UnitName; + public static XmlDocument Doc; + public static Dictionary Shps = new Dictionary(); + public static Palette Pal; + public static Dictionary Sequences = new Dictionary(); + + static Bitmap[] LoadAndResolve( string shp ) + { + var reader = new ShpReader(FileSystem.Open(shp + ".shp")); + return reader.Select(ih => + { + var bmp = new Bitmap(reader.Width, reader.Height); + for (var j = 0; j < bmp.Height; j++) + for (var i = 0; i < bmp.Width; i++) + bmp.SetPixel(i, j, Pal.GetColor(ih.Image[j * bmp.Width + i])); + return bmp; + }).ToArray(); + } + + [STAThread] + static void Main( string[] args ) + { + FileSystem.Mount(new Folder("./")); + var packages = new[] { "redalert", "conquer", "hires", "general", "local" }; + + foreach( var p in packages ) + FileSystem.Mount( new Package( p + ".mix" )); + + Doc = new XmlDocument(); + Doc.Load("sequences.xml"); + + Pal = new Palette(FileSystem.Open("temperat.pal")); + + UnitName = args.First(); + Shps[UnitName] = LoadAndResolve(UnitName); + + /* todo: load supplemental SHPs */ + + var xpath = string.Format("//unit[@name=\"{0}\"]/sequence", UnitName); + foreach (XmlElement e in Doc.SelectNodes(xpath)) + { + if (e.HasAttribute("src")) + { + var src = e.GetAttribute("src"); + if (!Shps.ContainsKey(src)) + Shps[src] = LoadAndResolve(src); + } + Sequences[e.GetAttribute("name")] = new Sequence(e); + } + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } + + class Sequence + { + public int start; + public int length; + public string shp; + + public Sequence(XmlElement e) + { + + } + } +} diff --git a/SequenceEditor/Properties/AssemblyInfo.cs b/SequenceEditor/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..ef6cd50d70 --- /dev/null +++ b/SequenceEditor/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SequenceEditor")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SequenceEditor")] +[assembly: AssemblyCopyright("Copyright © 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7e4566b7-a3cc-4d8f-ba9c-1a071883ba2c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SequenceEditor/Properties/Resources.Designer.cs b/SequenceEditor/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..d20b7cca75 --- /dev/null +++ b/SequenceEditor/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SequenceEditor.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SequenceEditor.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/SequenceEditor/Properties/Resources.resx b/SequenceEditor/Properties/Resources.resx new file mode 100644 index 0000000000..ffecec851a --- /dev/null +++ b/SequenceEditor/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SequenceEditor/Properties/Settings.Designer.cs b/SequenceEditor/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..867961c15d --- /dev/null +++ b/SequenceEditor/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4927 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SequenceEditor.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/SequenceEditor/Properties/Settings.settings b/SequenceEditor/Properties/Settings.settings new file mode 100644 index 0000000000..abf36c5d3d --- /dev/null +++ b/SequenceEditor/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/SequenceEditor/SequenceEditor.csproj b/SequenceEditor/SequenceEditor.csproj new file mode 100644 index 0000000000..4617ddb3f2 --- /dev/null +++ b/SequenceEditor/SequenceEditor.csproj @@ -0,0 +1,115 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {230F65CE-A6DE-4235-8B38-13A3D606C7F7} + WinExe + Properties + SequenceEditor + SequenceEditor + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\Ijw.DirectX\Release\Ijw.DirectX.dll + + + False + ..\Ijw.DirectX\Release\Ijw.Math.dll + + + False + ..\Ijw.DirectX\Release\IjwFramework.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + Component + + + + + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073} + OpenRa.DataStructures + + + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA} + OpenRa.FileFormats + + + + + \ No newline at end of file diff --git a/SequenceEditor/Surface.cs b/SequenceEditor/Surface.cs new file mode 100644 index 0000000000..b7e7d40cf0 --- /dev/null +++ b/SequenceEditor/Surface.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Drawing; + +namespace SequenceEditor +{ + public class Surface : Control + { + public Surface() + { + SetStyle(ControlStyles.OptimizedDoubleBuffer, true); + SetStyle(ControlStyles.ResizeRedraw, true); + UpdateStyles(); + } + + Dictionary> items + = new Dictionary>(); + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + var x = 0; + var y = 0; + + items.Clear(); + + foreach (var shp in Program.Shps) + { + x = 0; + e.Graphics.DrawString(shp.Key + ".shp", Font, Brushes.Black, x, y); + y += Font.Height; + var u = 0; + var i = 0; + + var dict = items[shp.Key] = new Dictionary(); + + foreach (var frame in shp.Value) + { + if (x + frame.Width >= ClientSize.Width) + { + x = 0; + y += u; + u = 0; + } + + dict[i++] = new Rectangle(x, y, frame.Width, frame.Height); + + e.Graphics.DrawImage(frame, x, y); + x += frame.Width; + u = Math.Max(u, frame.Height); + } + + y += u; + x = 0; + } + } + } +}