From 7a143d94f90c437631cb535fee2049a5dce6f332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 2 Apr 2013 11:48:19 +0200 Subject: [PATCH] added an eraser toolbar button to erase with left-click as in image editing programs --- OpenRA.Editor/Form1.Designer.cs | 13 +++++++++++++ OpenRA.Editor/Form1.cs | 6 ++++++ OpenRA.Editor/Form1.resx | 10 ++++++++++ OpenRA.Editor/Surface.cs | 7 ++++--- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/OpenRA.Editor/Form1.Designer.cs b/OpenRA.Editor/Form1.Designer.cs index 775a3d3957..286fd9eee7 100755 --- a/OpenRA.Editor/Form1.Designer.cs +++ b/OpenRA.Editor/Form1.Designer.cs @@ -74,6 +74,7 @@ namespace OpenRA.Editor this.toolStripMenuItemFixOpenAreas = new System.Windows.Forms.ToolStripButton(); this.toolStripMenuItemSetupDefaultPlayers = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator(); + this.eraserToolStripButton = new System.Windows.Forms.ToolStripButton(); this.toolStripMenuItemCopySelection = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.QuickhelpToolStripButton = new System.Windows.Forms.ToolStripButton(); @@ -352,6 +353,7 @@ namespace OpenRA.Editor this.toolStripMenuItemFixOpenAreas, this.toolStripMenuItemSetupDefaultPlayers, this.toolStripSeparator11, + this.eraserToolStripButton, this.toolStripMenuItemCopySelection, this.toolStripSeparator7, this.QuickhelpToolStripButton}); @@ -520,6 +522,16 @@ namespace OpenRA.Editor this.toolStripSeparator11.Name = "toolStripSeparator11"; this.toolStripSeparator11.Size = new System.Drawing.Size(6, 25); // + // eraserToolStripButton + // + this.eraserToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.eraserToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("eraserToolStripButton.Image"))); + this.eraserToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.eraserToolStripButton.Name = "eraserToolStripButton"; + this.eraserToolStripButton.Size = new System.Drawing.Size(23, 22); + this.eraserToolStripButton.Text = "Erase actors and resources."; + this.eraserToolStripButton.Click += new System.EventHandler(this.EraserToolStripButtonClick); + // // toolStripMenuItemCopySelection // this.toolStripMenuItemCopySelection.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; @@ -1059,6 +1071,7 @@ namespace OpenRA.Editor private System.Windows.Forms.ToolStripSeparator toolStripSeparator12; private System.Windows.Forms.ToolStripButton showRulerToolStripItem; private System.Windows.Forms.ToolStripMenuItem showRulerToolStripMenuItem; + private System.Windows.Forms.ToolStripButton eraserToolStripButton; #endregion diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 6ce2f5f721..17a4a0283a 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -750,5 +750,11 @@ namespace OpenRA.Editor { showRulerToolStripMenuItemClick(sender, e); } + + void EraserToolStripButtonClick(object sender, System.EventArgs e) + { + eraserToolStripButton.Checked ^= true; + surface1.IsErasing = eraserToolStripButton.Checked; + } } } diff --git a/OpenRA.Editor/Form1.resx b/OpenRA.Editor/Form1.resx index dfc3958e13..84481a152c 100755 --- a/OpenRA.Editor/Form1.resx +++ b/OpenRA.Editor/Form1.resx @@ -296,6 +296,16 @@ /z3G8q/AKohxAcjPIGeDbAZpXmch9mteYfb/Gct2EhWQ/0EBBvIzyNkgm8t8A/9X10/6DwLEGoICXCKK /vfP2fr/2p1nJBkCUwSmHUMLwIZcv/ucJENQAMyQG3coMMQprBBsyO17T8k3xNgj+b9rZBF1DAFhqBDp AGQIlEkNwMAAAP7JtzLCVbRNAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAD2SURBVDhPY6ApmLlqNz+Irmqd/H/aqpP/S3s2/W+etuM/ + SKy8YxVYDidA1gwDv37/+X/i4sP/xR1rwYbgBNg0//z15/+9px/+3370HmxI7cQN2A3Bpfn1+29wA0Ag + o2YmpgHEam6buvm/V1wVqgGkaMYwgCLNMECqZpe0crClYACKYxggWTMIzFx7+v/zN1/+P3z+8f+7j99J + 0wwCzTN2/992+Ob/tXuv/j9w5j5Q8zu45saJy/FrhoGs+nn/SzsW/58FdM3s9Wf+L9l8/P+MZTuxBxg6 + SCufCTc5Jq/tf0r5hP9xhZ0gjcRgBAhN68DtRNoABgYAAoqNFseCkuMAAAAASUVORK5CYII= diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index 2188f58264..ea1823d478 100755 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -36,6 +36,7 @@ namespace OpenRA.Editor ITool Tool; public bool IsPanning; + public bool IsErasing; public bool ShowActorNames; public bool ShowGrid; public bool ShowRuler; @@ -158,10 +159,10 @@ namespace OpenRA.Editor Scroll(oldMousePos - MousePos); else { - if (e.Button == MouseButtons.Right) + if (e.Button == MouseButtons.Right || (IsErasing && e.Button == MouseButtons.Left)) Erase(); - if (e.Button == MouseButtons.Left) + if (e.Button == MouseButtons.Left && !IsErasing) Draw(); Invalidate(); @@ -221,7 +222,7 @@ namespace OpenRA.Editor if (!IsPanning) { if (e.Button == MouseButtons.Right) Erase(); - if (e.Button == MouseButtons.Left) + if (e.Button == MouseButtons.Left && !IsErasing) { Draw(); if (!IsPaste)