diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index f33faecd52..212e5981ee 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -43,7 +43,6 @@ namespace OpenRA.Editor } void MakeDirty() { dirty = true; } - string loadedMapName; string currentMod = "ra"; TileSet tileset; @@ -51,7 +50,7 @@ namespace OpenRA.Editor void LoadMap(string mapname) { - tilePalette.Controls.Clear(); + tilePalette.Controls.Clear(); actorPalette.Controls.Clear(); resourcePalette.Controls.Clear(); @@ -94,13 +93,12 @@ namespace OpenRA.Editor tileset = Rules.TileSets[map.Theater]; tileset.LoadTiles(); var palette = new Palette(FileSystem.Open(tileset.Palette), true); + surface1.Bind(map, tileset, palette); - // construct the palette of tiles - var palettes = new[] { tilePalette, actorPalette, resourcePalette }; + var palettes = new[] { tilePalette, actorPalette, resourcePalette }; foreach (var p in palettes) { p.Visible = false; p.SuspendLayout(); } - foreach (var t in tileset.Templates) { try @@ -119,7 +117,6 @@ namespace OpenRA.Editor var template = t.Value; tilePalette.Controls.Add(ibox); - tt.SetToolTip(ibox, "{1}:{0} ({2}x{3})".F( template.Image, @@ -148,6 +145,7 @@ namespace OpenRA.Editor BorderStyle = BorderStyle.FixedSingle }; + ibox.Click += (_, e) => surface1.SetActor(template); actorPalette.Controls.Add(ibox); @@ -178,6 +176,8 @@ namespace OpenRA.Editor SizeMode = PictureBoxSizeMode.StretchImage }; + + ibox.Click += (_, e) => surface1.SetResource(template); resourcePalette.Controls.Add(ibox); @@ -523,10 +523,8 @@ namespace OpenRA.Editor private void layersFloaterToolStripMenuItem_Click(object sender, EventArgs e) { - using (var npb = new PaletteBox()) - { - npb.Show(); - } + var pb = new PaletteBox(); + pb.Show(); } } } \ No newline at end of file diff --git a/OpenRA.Editor/PaletteBox.Designer.cs b/OpenRA.Editor/PaletteBox.Designer.cs index 883640b8b2..b4bc4e19ca 100644 --- a/OpenRA.Editor/PaletteBox.Designer.cs +++ b/OpenRA.Editor/PaletteBox.Designer.cs @@ -31,11 +31,11 @@ this.LayerBox = new System.Windows.Forms.ComboBox(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); - this.tilePalette = new System.Windows.Forms.FlowLayoutPanel(); + this.pbtilePalette = new System.Windows.Forms.FlowLayoutPanel(); this.tabPage2 = new System.Windows.Forms.TabPage(); - this.actorPalette = new System.Windows.Forms.FlowLayoutPanel(); + this.pbactorPalette = new System.Windows.Forms.FlowLayoutPanel(); this.tabPage3 = new System.Windows.Forms.TabPage(); - this.resourcePalette = new System.Windows.Forms.FlowLayoutPanel(); + this.pbresourcePalette = new System.Windows.Forms.FlowLayoutPanel(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); @@ -67,7 +67,7 @@ // // tabPage1 // - this.tabPage1.Controls.Add(this.tilePalette); + this.tabPage1.Controls.Add(this.pbtilePalette); this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); @@ -76,19 +76,19 @@ this.tabPage1.Text = "Templates"; this.tabPage1.UseVisualStyleBackColor = true; // - // tilePalette + // pbtilePalette // - this.tilePalette.AutoScroll = true; - this.tilePalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.tilePalette.Dock = System.Windows.Forms.DockStyle.Fill; - this.tilePalette.Location = new System.Drawing.Point(3, 3); - this.tilePalette.Name = "tilePalette"; - this.tilePalette.Size = new System.Drawing.Size(180, 325); - this.tilePalette.TabIndex = 1; + this.pbtilePalette.AutoScroll = true; + this.pbtilePalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.pbtilePalette.Dock = System.Windows.Forms.DockStyle.Fill; + this.pbtilePalette.Location = new System.Drawing.Point(3, 3); + this.pbtilePalette.Name = "pbtilePalette"; + this.pbtilePalette.Size = new System.Drawing.Size(180, 325); + this.pbtilePalette.TabIndex = 1; // // tabPage2 // - this.tabPage2.Controls.Add(this.actorPalette); + this.tabPage2.Controls.Add(this.pbactorPalette); this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); @@ -97,19 +97,19 @@ this.tabPage2.Text = "Actors"; this.tabPage2.UseVisualStyleBackColor = true; // - // actorPalette + // pbactorPalette // - this.actorPalette.AutoScroll = true; - this.actorPalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.actorPalette.Dock = System.Windows.Forms.DockStyle.Fill; - this.actorPalette.Location = new System.Drawing.Point(3, 3); - this.actorPalette.Name = "actorPalette"; - this.actorPalette.Size = new System.Drawing.Size(180, 325); - this.actorPalette.TabIndex = 2; + this.pbactorPalette.AutoScroll = true; + this.pbactorPalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.pbactorPalette.Dock = System.Windows.Forms.DockStyle.Fill; + this.pbactorPalette.Location = new System.Drawing.Point(3, 3); + this.pbactorPalette.Name = "pbactorPalette"; + this.pbactorPalette.Size = new System.Drawing.Size(180, 325); + this.pbactorPalette.TabIndex = 2; // // tabPage3 // - this.tabPage3.Controls.Add(this.resourcePalette); + this.tabPage3.Controls.Add(this.pbresourcePalette); this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Name = "tabPage3"; this.tabPage3.Size = new System.Drawing.Size(186, 331); @@ -117,15 +117,15 @@ this.tabPage3.Text = "Resources"; this.tabPage3.UseVisualStyleBackColor = true; // - // resourcePalette + // pbresourcePalette // - this.resourcePalette.AutoScroll = true; - this.resourcePalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.resourcePalette.Dock = System.Windows.Forms.DockStyle.Fill; - this.resourcePalette.Location = new System.Drawing.Point(0, 0); - this.resourcePalette.Name = "resourcePalette"; - this.resourcePalette.Size = new System.Drawing.Size(186, 331); - this.resourcePalette.TabIndex = 3; + this.pbresourcePalette.AutoScroll = true; + this.pbresourcePalette.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.pbresourcePalette.Dock = System.Windows.Forms.DockStyle.Fill; + this.pbresourcePalette.Location = new System.Drawing.Point(0, 0); + this.pbresourcePalette.Name = "pbresourcePalette"; + this.pbresourcePalette.Size = new System.Drawing.Size(186, 331); + this.pbresourcePalette.TabIndex = 3; // // PaletteBox // @@ -134,13 +134,14 @@ this.ClientSize = new System.Drawing.Size(194, 378); this.Controls.Add(this.tabControl1); this.Controls.Add(this.LayerBox); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "PaletteBox"; this.ShowIcon = false; + this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Palette Box"; + this.TopMost = true; this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); this.tabPage2.ResumeLayout(false); @@ -151,13 +152,14 @@ #endregion - private System.Windows.Forms.ComboBox LayerBox; - private System.Windows.Forms.TabControl tabControl1; - private System.Windows.Forms.TabPage tabPage1; - private System.Windows.Forms.FlowLayoutPanel tilePalette; - private System.Windows.Forms.TabPage tabPage2; - private System.Windows.Forms.FlowLayoutPanel actorPalette; - private System.Windows.Forms.TabPage tabPage3; - private System.Windows.Forms.FlowLayoutPanel resourcePalette; + public System.Windows.Forms.ComboBox LayerBox; + public System.Windows.Forms.TabControl tabControl1; + public System.Windows.Forms.TabPage tabPage1; + public System.Windows.Forms.FlowLayoutPanel pbtilePalette; + public System.Windows.Forms.TabPage tabPage2; + public System.Windows.Forms.FlowLayoutPanel pbactorPalette; + public System.Windows.Forms.TabPage tabPage3; + public System.Windows.Forms.FlowLayoutPanel pbresourcePalette; + } } \ No newline at end of file