From f84312acb91f72132faf2bf215c53ea7c61c8fda Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 30 May 2011 21:59:25 +1200 Subject: [PATCH] add editor hack for fixing open areas in existing ra maps --- OpenRA.Editor/Form1.Designer.cs | 24 +++++++++++++++++------- OpenRA.Editor/Form1.cs | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/OpenRA.Editor/Form1.Designer.cs b/OpenRA.Editor/Form1.Designer.cs index 21685e920f..667fd6a0b8 100755 --- a/OpenRA.Editor/Form1.Designer.cs +++ b/OpenRA.Editor/Form1.Designer.cs @@ -72,12 +72,13 @@ namespace OpenRA.Editor this.mapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.propertiesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.resizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.showActorNamesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox(); this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabelFiller = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelMousePosition = new System.Windows.Forms.ToolStripStatusLabel(); - this.showActorNamesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.fixOpenAreasToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); @@ -393,7 +394,8 @@ namespace OpenRA.Editor this.mapToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.propertiesToolStripMenuItem, this.resizeToolStripMenuItem, - this.showActorNamesToolStripMenuItem}); + this.showActorNamesToolStripMenuItem, + this.fixOpenAreasToolStripMenuItem}); this.mapToolStripMenuItem.Name = "mapToolStripMenuItem"; this.mapToolStripMenuItem.Size = new System.Drawing.Size(43, 23); this.mapToolStripMenuItem.Text = "&Map"; @@ -416,6 +418,13 @@ namespace OpenRA.Editor this.resizeToolStripMenuItem.Text = "&Resize..."; this.resizeToolStripMenuItem.Click += new System.EventHandler(this.ResizeClicked); // + // showActorNamesToolStripMenuItem + // + this.showActorNamesToolStripMenuItem.Name = "showActorNamesToolStripMenuItem"; + this.showActorNamesToolStripMenuItem.Size = new System.Drawing.Size(175, 22); + this.showActorNamesToolStripMenuItem.Text = "Show Actor &Names"; + this.showActorNamesToolStripMenuItem.Click += new System.EventHandler(this.ShowActorNamesClicked); + // // toolStripComboBox1 // this.toolStripComboBox1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; @@ -454,12 +463,12 @@ namespace OpenRA.Editor this.toolStripStatusLabelMousePosition.Size = new System.Drawing.Size(22, 17); this.toolStripStatusLabelMousePosition.Text = "0,0"; // - // showActorNamesToolStripMenuItem + // fixOpenAreasToolStripMenuItem // - this.showActorNamesToolStripMenuItem.Name = "showActorNamesToolStripMenuItem"; - this.showActorNamesToolStripMenuItem.Size = new System.Drawing.Size(175, 22); - this.showActorNamesToolStripMenuItem.Text = "Show Actor &Names"; - this.showActorNamesToolStripMenuItem.Click += new System.EventHandler(this.ShowActorNamesClicked); + this.fixOpenAreasToolStripMenuItem.Name = "fixOpenAreasToolStripMenuItem"; + this.fixOpenAreasToolStripMenuItem.Size = new System.Drawing.Size(175, 22); + this.fixOpenAreasToolStripMenuItem.Text = "&Fix Open Areas"; + this.fixOpenAreasToolStripMenuItem.Click += new System.EventHandler(this.FixOpenAreas); // // Form1 // @@ -541,6 +550,7 @@ namespace OpenRA.Editor private System.Windows.Forms.ToolStripLabel toolStripLabel1; private System.Windows.Forms.ToolStripComboBox toolStripComboBox1; private System.Windows.Forms.ToolStripMenuItem showActorNamesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem fixOpenAreasToolStripMenuItem; } } diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 9ebf4896ab..dea04c0e80 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -415,5 +415,25 @@ namespace OpenRA.Editor showActorNamesToolStripMenuItem.Checked ^= true; surface1.ShowActorNames = showActorNamesToolStripMenuItem.Checked; } + + void FixOpenAreas(object sender, EventArgs e) + { + dirty = true; + var r = new Random(); + + for (var j = surface1.Map.Bounds.Top; j < surface1.Map.Bounds.Bottom; j++) + for (var i = surface1.Map.Bounds.Left; i < surface1.Map.Bounds.Right; i++) + { + var tr = surface1.Map.MapTiles.Value[i, j]; + if (tr.type == 0xff || tr.type == 0xffff || tr.type == 1 || tr.type == 2) + tr.index = (byte)r.Next(0, + Rules.TileSets[surface1.Map.Tileset].Tiles[tr.type].TileBitmapBytes.Count); + + surface1.Map.MapTiles.Value[i, j] = tr; + } + + surface1.Chunks.Clear(); + surface1.Invalidate(); + } } }