From 9393264fdce4a23526b1fa6979a9a6a68dfd03eb Mon Sep 17 00:00:00 2001 From: chrisf Date: Fri, 6 Jul 2007 12:06:12 +0000 Subject: [PATCH] git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1114 993157c7-ee19-0410-b2c4-bb4e9862e678 --- OpenRa.FileFormats/TileSheetBuilder.cs | 6 +- OpenRa.sln | 12 ++ TileSheetTest/Form1.Designer.cs | 60 +++++++++ TileSheetTest/Form1.cs | 69 ++++++++++ TileSheetTest/Form1.resx | 120 ++++++++++++++++++ TileSheetTest/Program.cs | 20 +++ TileSheetTest/Properties/AssemblyInfo.cs | 33 +++++ .../Properties/Resources.Designer.cs | 71 +++++++++++ TileSheetTest/Properties/Resources.resx | 117 +++++++++++++++++ TileSheetTest/Properties/Settings.Designer.cs | 30 +++++ TileSheetTest/Properties/Settings.settings | 7 + TileSheetTest/TileSheetTest.csproj | 84 ++++++++++++ 12 files changed, 626 insertions(+), 3 deletions(-) create mode 100644 TileSheetTest/Form1.Designer.cs create mode 100644 TileSheetTest/Form1.cs create mode 100644 TileSheetTest/Form1.resx create mode 100644 TileSheetTest/Program.cs create mode 100644 TileSheetTest/Properties/AssemblyInfo.cs create mode 100644 TileSheetTest/Properties/Resources.Designer.cs create mode 100644 TileSheetTest/Properties/Resources.resx create mode 100644 TileSheetTest/Properties/Settings.Designer.cs create mode 100644 TileSheetTest/Properties/Settings.settings create mode 100644 TileSheetTest/TileSheetTest.csproj diff --git a/OpenRa.FileFormats/TileSheetBuilder.cs b/OpenRa.FileFormats/TileSheetBuilder.cs index 3eafc7c8cb..1fbe5cf3bc 100644 --- a/OpenRa.FileFormats/TileSheetBuilder.cs +++ b/OpenRa.FileFormats/TileSheetBuilder.cs @@ -54,9 +54,9 @@ namespace OpenRa.FileFormats public class SheetRectangle where T : class { - readonly Point origin; - readonly Size size; - readonly T sheet; + public readonly Point origin; + public readonly Size size; + public readonly T sheet; internal SheetRectangle(T sheet, Point origin, Size size) { diff --git a/OpenRa.sln b/OpenRa.sln index ad1b47e60c..2022fe774c 100644 --- a/OpenRa.sln +++ b/OpenRa.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Core", "OpenRa.Core\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Game", "OpenRa.Game\OpenRa.Game.csproj", "{0DFB103F-2962-400F-8C6D-E2C28CCBA633}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TileSheetTest", "TileSheetTest\TileSheetTest.csproj", "{8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -71,6 +73,16 @@ Global {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Mixed Platforms.Build.0 = Release|Any CPU {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Win32.ActiveCfg = Release|Any CPU + {8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B}.Debug|Win32.ActiveCfg = Debug|Any CPU + {8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B}.Release|Any CPU.Build.0 = Release|Any CPU + {8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B}.Release|Win32.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TileSheetTest/Form1.Designer.cs b/TileSheetTest/Form1.Designer.cs new file mode 100644 index 0000000000..83a27d45d6 --- /dev/null +++ b/TileSheetTest/Form1.Designer.cs @@ -0,0 +1,60 @@ +namespace TileSheetTest +{ + 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.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.SuspendLayout(); + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoScroll = true; + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(917, 582); + this.flowLayoutPanel1.TabIndex = 0; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(917, 582); + this.Controls.Add(this.flowLayoutPanel1); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + } +} + diff --git a/TileSheetTest/Form1.cs b/TileSheetTest/Form1.cs new file mode 100644 index 0000000000..e5368ee284 --- /dev/null +++ b/TileSheetTest/Form1.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using OpenRa.FileFormats; +using System.IO; + +namespace TileSheetTest +{ + public partial class Form1 : Form + { + static readonly Size pageSize = new Size(256,256); + const int sheetBorder = 4; + + Bitmap CreateNewPage() + { + return new Bitmap(pageSize.Width, pageSize.Height); + } + + public Form1() + { + InitializeComponent(); + + Package package = new Package("../../../snow.mix"); + Palette palette = new Palette(File.OpenRead("../../../snow.pal")); + TileSet tileSet = new TileSet(package, ".sno", palette); + + TileSheetBuilder builder = + new TileSheetBuilder(pageSize, CreateNewPage); + + List sheets = new List(); + + MessageBox.Show(tileSet.tiles.Values.Count.ToString()); + + foreach (Terrain t in tileSet.tiles.Values) + for (int i = 0; i < t.NumTiles; i++) + { + Bitmap tileImage = t.GetTile(i); + + if (tileImage == null) + continue; + + SheetRectangle item = builder.AddImage(tileImage.Size); + + using (Graphics g = Graphics.FromImage(item.sheet)) + { + g.DrawImage(tileImage, item.origin); + g.DrawRectangle(Pens.Red, new Rectangle(item.origin, item.size)); + } + + if (!sheets.Contains(item.sheet)) + sheets.Add(item.sheet); + } + + foreach (Bitmap b in sheets) + { + PictureBox box = new PictureBox(); + box.Image = b; + box.SizeMode = PictureBoxSizeMode.CenterImage; + box.Size = new Size(2 * sheetBorder + b.Width, 2 * sheetBorder + b.Height); + + flowLayoutPanel1.Controls.Add(box); + } + } + } +} \ No newline at end of file diff --git a/TileSheetTest/Form1.resx b/TileSheetTest/Form1.resx new file mode 100644 index 0000000000..ff31a6db56 --- /dev/null +++ b/TileSheetTest/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/TileSheetTest/Program.cs b/TileSheetTest/Program.cs new file mode 100644 index 0000000000..e877032d0a --- /dev/null +++ b/TileSheetTest/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace TileSheetTest +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/TileSheetTest/Properties/AssemblyInfo.cs b/TileSheetTest/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..cb4fadb38a --- /dev/null +++ b/TileSheetTest/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +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("TileSheetTest")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TileSheetTest")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[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("9eca2ea1-e6e8-42ac-af48-2422176e7132")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TileSheetTest/Properties/Resources.Designer.cs b/TileSheetTest/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..9dd3bea2c8 --- /dev/null +++ b/TileSheetTest/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1318 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace TileSheetTest.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("TileSheetTest.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/TileSheetTest/Properties/Resources.resx b/TileSheetTest/Properties/Resources.resx new file mode 100644 index 0000000000..c40a448a31 --- /dev/null +++ b/TileSheetTest/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/TileSheetTest/Properties/Settings.Designer.cs b/TileSheetTest/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..4ea1c3a45a --- /dev/null +++ b/TileSheetTest/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1318 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace TileSheetTest.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.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/TileSheetTest/Properties/Settings.settings b/TileSheetTest/Properties/Settings.settings new file mode 100644 index 0000000000..abf36c5d3d --- /dev/null +++ b/TileSheetTest/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/TileSheetTest/TileSheetTest.csproj b/TileSheetTest/TileSheetTest.csproj new file mode 100644 index 0000000000..02139d41d8 --- /dev/null +++ b/TileSheetTest/TileSheetTest.csproj @@ -0,0 +1,84 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {8A2FF5A6-D2CC-4CC4-844A-A1E7D3F69D0B} + WinExe + Properties + TileSheetTest + TileSheetTest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA} + OpenRa.FileFormats + + + + + \ No newline at end of file