diff --git a/OpenRA.Editor/Form1.Designer.cs b/OpenRA.Editor/Form1.Designer.cs
index 27bf1b66a2..f731cc2a72 100644
--- a/OpenRA.Editor/Form1.Designer.cs
+++ b/OpenRA.Editor/Form1.Designer.cs
@@ -36,17 +36,18 @@
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tilePalette = new System.Windows.Forms.FlowLayoutPanel();
this.tabPage2 = new System.Windows.Forms.TabPage();
- this.toolStrip1 = new System.Windows.Forms.ToolStrip();
- this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
- this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
- this.tt = new System.Windows.Forms.ToolTip(this.components);
this.actorPalette = new System.Windows.Forms.FlowLayoutPanel();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.resourcePalette = new System.Windows.Forms.FlowLayoutPanel();
this.surface1 = new OpenRA.Editor.Surface();
+ this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
- this.toolStripButton4 = new System.Windows.Forms.ToolStripButton();
this.toolStripButton5 = new System.Windows.Forms.ToolStripButton();
+ this.toolStripButton4 = new System.Windows.Forms.ToolStripButton();
+ this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
+ this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
+ this.tt = new System.Windows.Forms.ToolTip(this.components);
+ this.folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
this.toolStripContainer1.ContentPanel.SuspendLayout();
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
this.toolStripContainer1.SuspendLayout();
@@ -56,8 +57,8 @@
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
- this.toolStrip1.SuspendLayout();
this.tabPage3.SuspendLayout();
+ this.toolStrip1.SuspendLayout();
this.SuspendLayout();
//
// toolStripContainer1
@@ -140,41 +141,6 @@
this.tabPage2.Text = "Actors";
this.tabPage2.UseVisualStyleBackColor = true;
//
- // toolStrip1
- //
- this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None;
- this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.toolStripButton3,
- this.toolStripButton5,
- this.toolStripButton4,
- this.toolStripButton1,
- this.toolStripButton2});
- this.toolStrip1.Location = new System.Drawing.Point(3, 0);
- this.toolStrip1.Name = "toolStrip1";
- this.toolStrip1.Size = new System.Drawing.Size(336, 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(76, 22);
- this.toolStripButton1.Text = "Save As...";
- //
- // toolStripButton2
- //
- this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image")));
- this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
- this.toolStripButton2.Name = "toolStripButton2";
- this.toolStripButton2.Size = new System.Drawing.Size(59, 22);
- this.toolStripButton2.Text = "Resize";
- this.toolStripButton2.Click += new System.EventHandler(this.ResizeClicked);
- //
- // tt
- //
- this.tt.ShowAlways = true;
- //
// actorPalette
//
this.actorPalette.AutoScroll = true;
@@ -213,6 +179,20 @@
this.surface1.TabIndex = 2;
this.surface1.Text = "surface1";
//
+ // toolStrip1
+ //
+ this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None;
+ this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripButton3,
+ this.toolStripButton5,
+ this.toolStripButton4,
+ this.toolStripButton1,
+ this.toolStripButton2});
+ this.toolStrip1.Location = new System.Drawing.Point(3, 0);
+ this.toolStrip1.Name = "toolStrip1";
+ this.toolStrip1.Size = new System.Drawing.Size(305, 25);
+ this.toolStrip1.TabIndex = 0;
+ //
// toolStripButton3
//
this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image")));
@@ -221,14 +201,6 @@
this.toolStripButton3.Size = new System.Drawing.Size(51, 22);
this.toolStripButton3.Text = "New";
//
- // toolStripButton4
- //
- this.toolStripButton4.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton4.Image")));
- this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta;
- this.toolStripButton4.Name = "toolStripButton4";
- this.toolStripButton4.Size = new System.Drawing.Size(51, 22);
- this.toolStripButton4.Text = "Save";
- //
// toolStripButton5
//
this.toolStripButton5.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton5.Image")));
@@ -237,6 +209,37 @@
this.toolStripButton5.Size = new System.Drawing.Size(56, 22);
this.toolStripButton5.Text = "Open";
//
+ // toolStripButton4
+ //
+ this.toolStripButton4.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton4.Image")));
+ this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta;
+ this.toolStripButton4.Name = "toolStripButton4";
+ this.toolStripButton4.Size = new System.Drawing.Size(51, 22);
+ this.toolStripButton4.Text = "Save";
+ this.toolStripButton4.Click += new System.EventHandler(this.SaveClicked);
+ //
+ // 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(76, 22);
+ this.toolStripButton1.Text = "Save As...";
+ this.toolStripButton1.Click += new System.EventHandler(this.SaveAsClicked);
+ //
+ // toolStripButton2
+ //
+ this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image")));
+ this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
+ this.toolStripButton2.Name = "toolStripButton2";
+ this.toolStripButton2.Size = new System.Drawing.Size(59, 22);
+ this.toolStripButton2.Text = "Resize";
+ this.toolStripButton2.Click += new System.EventHandler(this.ResizeClicked);
+ //
+ // tt
+ //
+ this.tt.ShowAlways = true;
+ //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -256,9 +259,9 @@
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
+ this.tabPage3.ResumeLayout(false);
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
- this.tabPage3.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -282,6 +285,7 @@
private System.Windows.Forms.ToolStripButton toolStripButton3;
private System.Windows.Forms.ToolStripButton toolStripButton5;
private System.Windows.Forms.ToolStripButton toolStripButton4;
+ private System.Windows.Forms.FolderBrowserDialog folderBrowser;
}
}
diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs
index 3370f4744a..7c87778fa0 100644
--- a/OpenRA.Editor/Form1.cs
+++ b/OpenRA.Editor/Form1.cs
@@ -21,6 +21,10 @@ namespace OpenRA.Editor
LoadMap("ra", "mjolnir");
}
+ string loadedMapName;
+ string colors;
+ TileSet tileset;
+
void LoadMap(string mod, string mapname)
{
tilePalette.Controls.Clear();
@@ -43,7 +47,9 @@ namespace OpenRA.Editor
// we're also going to need a tileset...
var tsinfo = fileMapping[Pair.New(mods[0], map.Theater)];
- var tileset = new TileSet("tileset.til", "templates.ini", tsinfo.First);
+ tileset = new TileSet("tileset.til", "templates.ini", tsinfo.First);
+
+ colors = tsinfo.Second;
var palette = new Palette(FileSystem.Open(map.Theater.ToLowerInvariant() + ".pal"), true);
@@ -143,6 +149,7 @@ namespace OpenRA.Editor
}
surface1.BindResourceTemplates(resourceTemplates);
+ loadedMapName = mapname;
}
void LocateGameRoot()
@@ -281,5 +288,49 @@ namespace OpenRA.Editor
surface1.Invalidate();
}
}
+
+ void SavePreviewImage(string filepath)
+ {
+ var Map = surface1.Map;
+
+ var xs = Map.TopLeft.X;
+ var ys = Map.TopLeft.Y;
+
+ var terrainTypeColors = new TerrainColorSet(colors);
+
+ var bitmap = new Bitmap(Map.Width, Map.Height);
+ for (var x = 0; x < Map.Width; x++)
+ for (var y = 0; y < Map.Height; y++)
+ bitmap.SetPixel(x, y, terrainTypeColors.ColorForTerrainType(
+ tileset.GetTerrainType(Map.MapTiles[x + xs, y + ys])));
+
+ for (var x = 0; x < Map.Width; x++)
+ for (var y = 0; y < Map.Height; y++)
+ if (Map.MapResources[x + xs, y + ys].type > 0)
+ bitmap.SetPixel(x, y, terrainTypeColors.ColorForTerrainType(TerrainType.Ore));
+
+ bitmap.Save(filepath, ImageFormat.Png);
+ }
+
+ void SaveClicked(object sender, EventArgs e)
+ {
+ if (loadedMapName == null)
+ SaveAsClicked(sender, e);
+ else
+ {
+ surface1.Map.Package = new Folder(loadedMapName);
+ SavePreviewImage(Path.Combine(loadedMapName, "preview.png"));
+ surface1.Map.Save(loadedMapName);
+ }
+ }
+
+ void SaveAsClicked(object sender, EventArgs e)
+ {
+ if (DialogResult.OK == folderBrowser.ShowDialog())
+ {
+ loadedMapName = folderBrowser.SelectedPath;
+ SaveClicked(sender, e);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/OpenRA.Editor/Form1.resx b/OpenRA.Editor/Form1.resx
index 81b39c15ad..ed37871b95 100644
--- a/OpenRA.Editor/Form1.resx
+++ b/OpenRA.Editor/Form1.resx
@@ -199,4 +199,7 @@
17, 17
+
+ 182, 17
+
\ No newline at end of file
diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs
index b65147aee5..6053135537 100644
--- a/OpenRA.Editor/Surface.cs
+++ b/OpenRA.Editor/Surface.cs
@@ -81,6 +81,8 @@ namespace OpenRA.Editor
DrawWithBrush();
if (e.Button == MouseButtons.Left && Actor != null)
DrawWithActor();
+ if (e.Button == MouseButtons.Left && Resource != null)
+ DrawWithResource();
Invalidate();
}
@@ -183,6 +185,8 @@ namespace OpenRA.Editor
DrawWithBrush();
if (e.Button == MouseButtons.Left && Actor != null)
DrawWithActor();
+ if (e.Button == MouseButtons.Left && Resource != null)
+ DrawWithResource();
Invalidate();
}