diff --git a/OpenRA.Editor/Form1.Designer.cs b/OpenRA.Editor/Form1.Designer.cs index 2f72c51025..97b3a29913 100755 --- a/OpenRA.Editor/Form1.Designer.cs +++ b/OpenRA.Editor/Form1.Designer.cs @@ -67,6 +67,7 @@ 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.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); @@ -381,7 +382,8 @@ // this.mapToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.propertiesToolStripMenuItem, - this.resizeToolStripMenuItem}); + this.resizeToolStripMenuItem, + this.showActorNamesToolStripMenuItem}); this.mapToolStripMenuItem.Name = "mapToolStripMenuItem"; this.mapToolStripMenuItem.Size = new System.Drawing.Size(43, 23); this.mapToolStripMenuItem.Text = "&Map"; @@ -391,7 +393,7 @@ this.propertiesToolStripMenuItem.Enabled = false; this.propertiesToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("propertiesToolStripMenuItem.Image"))); this.propertiesToolStripMenuItem.Name = "propertiesToolStripMenuItem"; - this.propertiesToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.propertiesToolStripMenuItem.Size = new System.Drawing.Size(175, 22); this.propertiesToolStripMenuItem.Text = "&Properties..."; this.propertiesToolStripMenuItem.Click += new System.EventHandler(this.PropertiesClicked); // @@ -400,7 +402,7 @@ this.resizeToolStripMenuItem.Enabled = false; this.resizeToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("resizeToolStripMenuItem.Image"))); this.resizeToolStripMenuItem.Name = "resizeToolStripMenuItem"; - this.resizeToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.resizeToolStripMenuItem.Size = new System.Drawing.Size(175, 22); this.resizeToolStripMenuItem.Text = "&Resize..."; this.resizeToolStripMenuItem.Click += new System.EventHandler(this.ResizeClicked); // @@ -442,6 +444,13 @@ this.toolStripStatusLabelMousePosition.Size = new System.Drawing.Size(22, 17); this.toolStripStatusLabelMousePosition.Text = "0,0"; // + // 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.showActorNamesToolStripMenuItem_Click); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -521,6 +530,7 @@ private System.Windows.Forms.ToolStripMenuItem resizeToolStripMenuItem; private System.Windows.Forms.ToolStripLabel toolStripLabel1; private System.Windows.Forms.ToolStripComboBox toolStripComboBox1; + private System.Windows.Forms.ToolStripMenuItem showActorNamesToolStripMenuItem; } } diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 20fb7a349f..67843b2cd9 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -406,6 +406,12 @@ namespace OpenRA.Editor if (DialogResult.OK == saveFileDialog.ShowDialog()) pmMiniMap.Image.Save(saveFileDialog.FileName); + } + + void showActorNamesToolStripMenuItem_Click(object sender, EventArgs e) + { + showActorNamesToolStripMenuItem.Checked ^= true; + surface1.ShowActorNames = showActorNamesToolStripMenuItem.Checked; } } } diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index 8176246857..02825aa149 100755 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -34,7 +34,9 @@ namespace OpenRA.Editor ITool Tool; - public bool IsPanning; + public bool IsPanning; + public bool ShowActorNames; + public event Action AfterChange = () => { }; public event Action MousePositionChanged = _ => { }; @@ -336,12 +338,23 @@ namespace OpenRA.Editor Map.Bounds.Left * TileSet.TileSize * Zoom + Offset.X, Map.Bounds.Top * TileSet.TileSize * Zoom + Offset.Y, Map.Bounds.Width * TileSet.TileSize * Zoom, - Map.Bounds.Height * TileSet.TileSize * Zoom); - - foreach (var ar in Map.Actors.Value) - if (ActorTemplates.ContainsKey(ar.Value.Type)) - DrawActor(e.Graphics, ar.Value.Location(), ActorTemplates[ar.Value.Type], - GetPaletteForActor(ar.Value)); + Map.Bounds.Height * TileSet.TileSize * Zoom); + + foreach (var ar in Map.Actors.Value) + { + if (ActorTemplates.ContainsKey(ar.Value.Type)) + DrawActor(e.Graphics, ar.Value.Location(), ActorTemplates[ar.Value.Type], + GetPaletteForActor(ar.Value)); + } + + if (ShowActorNames) + foreach (var ar in Map.Actors.Value) + if (!ar.Key.StartsWith("Actor")) // if it has a custom name + e.Graphics.DrawStringContrast(Font, ar.Key, + (int)(ar.Value.Location().X * TileSet.TileSize * Zoom + Offset.X), + (int)(ar.Value.Location().Y * TileSet.TileSize * Zoom + Offset.Y), + Brushes.White, + Brushes.Black); if (Tool != null) Tool.Preview(this, e.Graphics); @@ -360,6 +373,16 @@ namespace OpenRA.Editor public static int2 Location(this ActorReference ar) { return ar.InitDict.Get().value; + } + + public static void DrawStringContrast(this SGraphics g, Font f, string s, int x, int y, Brush fg, Brush bg) + { + g.DrawString(s, f, bg, x - 1, y - 1); + g.DrawString(s, f, bg, x + 1, y - 1); + g.DrawString(s, f, bg, x - 1, y + 1); + g.DrawString(s, f, bg, x + 1, y + 1); + + g.DrawString(s, f, fg, x, y); } } } \ No newline at end of file