From 9966b4efd1e0922e56f41d4bd55e2c0e87a3d7db Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 26 Jun 2012 19:33:11 +1200 Subject: [PATCH] group tiles by category --- OpenRA.Editor/Form1.cs | 50 +++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 77d6eef1b7..83436d6310 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -144,32 +144,38 @@ namespace OpenRA.Editor // construct the palette of tiles var palettes = new[] { tilePalette, actorPalette, resourcePalette }; foreach (var p in palettes) { p.Visible = false; p.SuspendLayout(); } - foreach (var t in tileset.Templates) + + foreach (var tc in tileset.Templates.GroupBy(t => t.Value.Category)) { - try + var category = tc.Key ?? "(Uncategorized)"; + + foreach( var t in tc ) { - var bitmap = tileset.RenderTemplate((ushort)t.Key, palette); - var ibox = new PictureBox + try { - Image = bitmap, - Width = bitmap.Width / 2, - Height = bitmap.Height / 2, - SizeMode = PictureBoxSizeMode.StretchImage - }; - - var brushTemplate = new BrushTemplate { Bitmap = bitmap, N = t.Key }; - ibox.Click += (_, e) => surface1.SetTool(new BrushTool(brushTemplate)); - - var template = t.Value; - tilePalette.Controls.Add(ibox); - tt.SetToolTip(ibox, - "{1}:{0} ({2}x{3})".F( - template.Image, - template.Id, - template.Size.X, - template.Size.Y)); + var bitmap = tileset.RenderTemplate((ushort)t.Key, palette); + var ibox = new PictureBox + { + Image = bitmap, + Width = bitmap.Width / 2, + Height = bitmap.Height / 2, + SizeMode = PictureBoxSizeMode.StretchImage + }; + + var brushTemplate = new BrushTemplate { Bitmap = bitmap, N = t.Key }; + ibox.Click += (_, e) => surface1.SetTool(new BrushTool(brushTemplate)); + + var template = t.Value; + tilePalette.Controls.Add(ibox); + tt.SetToolTip(ibox, + "{1}:{0} ({2}x{3})".F( + template.Image, + template.Id, + template.Size.X, + template.Size.Y)); + } + catch { } } - catch { } } var actorTemplates = new List();