diff --git a/OpenRA.Editor/Form1.Designer.cs b/OpenRA.Editor/Form1.Designer.cs index 1fa311f31d..9cf21c942b 100644 --- a/OpenRA.Editor/Form1.Designer.cs +++ b/OpenRA.Editor/Form1.Designer.cs @@ -29,16 +29,21 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.tilePalette = new System.Windows.Forms.FlowLayoutPanel(); - this.tt = new System.Windows.Forms.ToolTip(this.components); this.surface1 = new OpenRA.Editor.Surface(); + this.tt = new System.Windows.Forms.ToolTip(this.components); + this.toolStrip1 = new System.Windows.Forms.ToolStrip(); + this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); this.toolStripContainer1.ContentPanel.SuspendLayout(); + this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); this.toolStripContainer1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); + this.toolStrip1.SuspendLayout(); this.SuspendLayout(); // // toolStripContainer1 @@ -55,6 +60,10 @@ this.toolStripContainer1.TabIndex = 1; this.toolStripContainer1.Text = "toolStripContainer1"; // + // toolStripContainer1.TopToolStripPanel + // + this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStrip1); + // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; @@ -81,10 +90,6 @@ this.tilePalette.Size = new System.Drawing.Size(198, 680); this.tilePalette.TabIndex = 0; // - // tt - // - this.tt.ShowAlways = true; - // // surface1 // this.surface1.BackColor = System.Drawing.Color.Black; @@ -92,11 +97,34 @@ this.surface1.Location = new System.Drawing.Point(0, 0); this.surface1.Map = null; this.surface1.Name = "surface1"; + this.surface1.Palette = null; this.surface1.Size = new System.Drawing.Size(783, 680); this.surface1.TabIndex = 2; this.surface1.Text = "surface1"; this.surface1.TileSet = null; // + // tt + // + this.tt.ShowAlways = true; + // + // toolStrip1 + // + this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None; + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripButton1}); + this.toolStrip1.Location = new System.Drawing.Point(3, 0); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.Size = new System.Drawing.Size(94, 25); + this.toolStrip1.TabIndex = 0; + // + // toolStripButton1 + // + this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image"))); + this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton1.Name = "toolStripButton1"; + this.toolStripButton1.Size = new System.Drawing.Size(51, 22); + this.toolStripButton1.Text = "Save"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -106,11 +134,15 @@ this.Name = "Form1"; this.Text = "OpenRA Editor"; this.toolStripContainer1.ContentPanel.ResumeLayout(false); + this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false); + this.toolStripContainer1.TopToolStripPanel.PerformLayout(); this.toolStripContainer1.ResumeLayout(false); this.toolStripContainer1.PerformLayout(); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); this.splitContainer1.ResumeLayout(false); + this.toolStrip1.ResumeLayout(false); + this.toolStrip1.PerformLayout(); this.ResumeLayout(false); } @@ -122,6 +154,8 @@ private Surface surface1; private System.Windows.Forms.FlowLayoutPanel tilePalette; private System.Windows.Forms.ToolTip tt; + private System.Windows.Forms.ToolStrip toolStrip1; + private System.Windows.Forms.ToolStripButton toolStripButton1; } } diff --git a/OpenRA.Editor/Form1.resx b/OpenRA.Editor/Form1.resx index f5bbc6f282..0235fec697 100644 --- a/OpenRA.Editor/Form1.resx +++ b/OpenRA.Editor/Form1.resx @@ -117,7 +117,26 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 77, 17 + 17, 17 + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIISURBVDhPpZP7S1NxGMbPPxKaXVUkMEq8IpKUCoY/hGgI + ymqkDYYXcCjDZOANURSjCNGFQUTsl4GXVMxKk62YU4fXQpaIlygHQxBRH8/zwvyaIAYe+HLgnPN8nue9 + HA3nvDTq63oW/jm13XOwvPTB3DYFY5MH+bXfcN8ygfTSMSSXfESicQDxBqdYHwH29g9w2tnZ3UcguIvN + rR3417exuBJE5N1n/wfwLgXEOc38Bc6xNRHb+/y4nm49G0Bnit2zf9H6bkliE/jKuYxrd6oVgDWfjB+K + TWeKMyrGEVfowITvD9re/9ABVQrAhh0HHK+ZselMMaN/mvwtDb+aVqkA7HYIwIj3ysfluPTorJnP6Ezx + oHsD1s5ZXEktUwCOioB5f1CEPR9+wTG6iuiserTo8dkwng7HT/R+XUPF8xlcTjErAOdMcW6NW8STiwG8 + 7vej8oUPN/PsEv3t8Ao0TZP3T1u8uJRkUgAuSYHtO97oLxmXd5t9Ho8aPTK+GzntqNfrLm2fFoihwYOI + xGIF4KjoGBLzY1OrF9k6OOFxnwDC4wxIMX1G0pMhgVyMNyoA13PAtS7OrJk1PrC69LUdQWxuF6IybHrX + LRI7JrtZdoDAo1XmbjMyD+tjSXxGcXRmnYg5ttD9QuxDhN0uUgDOmbvNTpPOJaGAo2K36cyaGZvOFIfd + KlSA8/zRh9ABIDUG+1JpAAAAAElFTkSuQmCC + + \ No newline at end of file diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index 3b7c1c5e84..a2b034850d 100644 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -26,21 +26,30 @@ namespace OpenRA.Editor UpdateStyles(); } - public const int CellSize = 24; static readonly Pen RedPen = new Pen(Color.Red); int2 MousePos; protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); + + var oldMousePos = MousePos; MousePos = new int2(e.Location); - Invalidate(); + if (e.Button == MouseButtons.Middle) + { + Offset += MousePos - oldMousePos; + Invalidate(); + } + else + if (Brush.Second != null) + Invalidate(); } protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); + if (e.Button == MouseButtons.Right) Brush = Pair.New((ushort)0, null as Bitmap); @@ -52,6 +61,7 @@ namespace OpenRA.Editor Bitmap RenderChunk(int u, int v) { var bitmap = new Bitmap(ChunkSize * 24, ChunkSize * 24); + bitmap.SetPixel(0, 0, Color.Green); var hx = Math.Min(Map.Width - u * ChunkSize, ChunkSize); var hy = Math.Min(Map.Height - v * ChunkSize, ChunkSize); @@ -62,21 +72,22 @@ namespace OpenRA.Editor var tr = Map.MapTiles[u * ChunkSize + i, v * ChunkSize + j]; var tile = TileSet.tiles[tr.type]; - try - { - var rawImage = tile.TileBitmapBytes[tr.index % tile.TileBitmapBytes.Count]; + var index = (tr.index < tile.TileBitmapBytes.Count) ? tr.index : 0; + var rawImage = tile.TileBitmapBytes[index]; for (var x = 0; x < 24; x++) for (var y = 0; y < 24; y++) bitmap.SetPixel(i * 24 + x, j * 24 + y, Palette.GetColor(rawImage[x + 24 * y])); - } - catch - { - } } return bitmap; } + int2 GetBrushLocation() + { + var v = MousePos - Offset; + return new int2(v.X / 24, v.Y / 24); + } + protected override void OnPaint(PaintEventArgs e) { if (Map == null) return; @@ -85,14 +96,14 @@ namespace OpenRA.Editor for( var u = Map.TopLeft.X - Map.TopLeft.X % ChunkSize; u < Map.BottomRight.X; u += ChunkSize ) for (var v = Map.TopLeft.Y - Map.TopLeft.Y % ChunkSize; v < Map.BottomRight.Y; v += ChunkSize) { - var x = new int2(u,v); + var x = new int2(u/ChunkSize,v/ChunkSize); if (!Chunks.ContainsKey(x)) Chunks[x] = RenderChunk(u / ChunkSize, v / ChunkSize); - e.Graphics.DrawImage(Chunks[x], u * ChunkSize * 24, v * ChunkSize * 24); + e.Graphics.DrawImage(Chunks[x], (24 * ChunkSize * x + Offset).ToPoint()); } if (Brush.Second != null) - e.Graphics.DrawImage(Brush.Second, - (MousePos - new int2(MousePos.X % 24, MousePos.Y % 24)).ToPoint()); + e.Graphics.DrawImage(Brush.Second, + (24 * GetBrushLocation() + Offset).ToPoint()); } } } \ No newline at end of file