space-to-pan (like PS) in editor, not scrollbars.
This commit is contained in:
59
OpenRA.Editor/Form1.Designer.cs
generated
59
OpenRA.Editor/Form1.Designer.cs
generated
@@ -39,9 +39,6 @@
|
|||||||
this.actorPalette = new System.Windows.Forms.FlowLayoutPanel();
|
this.actorPalette = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
this.tabPage3 = new System.Windows.Forms.TabPage();
|
this.tabPage3 = new System.Windows.Forms.TabPage();
|
||||||
this.resourcePalette = new System.Windows.Forms.FlowLayoutPanel();
|
this.resourcePalette = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
this.surface1 = new OpenRA.Editor.Surface();
|
|
||||||
this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
|
|
||||||
this.hScrollBar1 = new System.Windows.Forms.HScrollBar();
|
|
||||||
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
|
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
|
||||||
this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
|
this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
|
||||||
this.toolStripButton5 = new System.Windows.Forms.ToolStripButton();
|
this.toolStripButton5 = new System.Windows.Forms.ToolStripButton();
|
||||||
@@ -52,6 +49,7 @@
|
|||||||
this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
|
this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
|
||||||
this.tt = new System.Windows.Forms.ToolTip(this.components);
|
this.tt = new System.Windows.Forms.ToolTip(this.components);
|
||||||
this.folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
|
this.folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
|
||||||
|
this.surface1 = new OpenRA.Editor.Surface();
|
||||||
this.toolStripContainer1.ContentPanel.SuspendLayout();
|
this.toolStripContainer1.ContentPanel.SuspendLayout();
|
||||||
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
|
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
|
||||||
this.toolStripContainer1.SuspendLayout();
|
this.toolStripContainer1.SuspendLayout();
|
||||||
@@ -96,8 +94,6 @@
|
|||||||
// splitContainer1.Panel2
|
// splitContainer1.Panel2
|
||||||
//
|
//
|
||||||
this.splitContainer1.Panel2.Controls.Add(this.surface1);
|
this.splitContainer1.Panel2.Controls.Add(this.surface1);
|
||||||
this.splitContainer1.Panel2.Controls.Add(this.vScrollBar1);
|
|
||||||
this.splitContainer1.Panel2.Controls.Add(this.hScrollBar1);
|
|
||||||
this.splitContainer1.Size = new System.Drawing.Size(985, 680);
|
this.splitContainer1.Size = new System.Drawing.Size(985, 680);
|
||||||
this.splitContainer1.SplitterDistance = 198;
|
this.splitContainer1.SplitterDistance = 198;
|
||||||
this.splitContainer1.TabIndex = 0;
|
this.splitContainer1.TabIndex = 0;
|
||||||
@@ -115,7 +111,6 @@
|
|||||||
this.tabControl1.SelectedIndex = 0;
|
this.tabControl1.SelectedIndex = 0;
|
||||||
this.tabControl1.Size = new System.Drawing.Size(198, 680);
|
this.tabControl1.Size = new System.Drawing.Size(198, 680);
|
||||||
this.tabControl1.TabIndex = 0;
|
this.tabControl1.TabIndex = 0;
|
||||||
this.tabControl1.Resize += new System.EventHandler(this.surface1_Resize);
|
|
||||||
//
|
//
|
||||||
// tabPage1
|
// tabPage1
|
||||||
//
|
//
|
||||||
@@ -179,43 +174,6 @@
|
|||||||
this.resourcePalette.Size = new System.Drawing.Size(171, 672);
|
this.resourcePalette.Size = new System.Drawing.Size(171, 672);
|
||||||
this.resourcePalette.TabIndex = 3;
|
this.resourcePalette.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// surface1
|
|
||||||
//
|
|
||||||
this.surface1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.surface1.BackColor = System.Drawing.Color.Black;
|
|
||||||
this.surface1.Location = new System.Drawing.Point(2, 0);
|
|
||||||
this.surface1.Name = "surface1";
|
|
||||||
this.surface1.Size = new System.Drawing.Size(763, 662);
|
|
||||||
this.surface1.TabIndex = 5;
|
|
||||||
this.surface1.Text = "surface1";
|
|
||||||
this.surface1.Resize += new System.EventHandler(this.surface1_Resize);
|
|
||||||
//
|
|
||||||
// vScrollBar1
|
|
||||||
//
|
|
||||||
this.vScrollBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.vScrollBar1.LargeChange = 24;
|
|
||||||
this.vScrollBar1.Location = new System.Drawing.Point(766, 0);
|
|
||||||
this.vScrollBar1.Name = "vScrollBar1";
|
|
||||||
this.vScrollBar1.Size = new System.Drawing.Size(16, 662);
|
|
||||||
this.vScrollBar1.SmallChange = 24;
|
|
||||||
this.vScrollBar1.TabIndex = 4;
|
|
||||||
this.vScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScrollBar1_Scroll);
|
|
||||||
//
|
|
||||||
// hScrollBar1
|
|
||||||
//
|
|
||||||
this.hScrollBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.hScrollBar1.LargeChange = 24;
|
|
||||||
this.hScrollBar1.Location = new System.Drawing.Point(0, 663);
|
|
||||||
this.hScrollBar1.Name = "hScrollBar1";
|
|
||||||
this.hScrollBar1.Size = new System.Drawing.Size(765, 16);
|
|
||||||
this.hScrollBar1.SmallChange = 24;
|
|
||||||
this.hScrollBar1.TabIndex = 3;
|
|
||||||
this.hScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.hScrollBar1_Scroll);
|
|
||||||
//
|
|
||||||
// toolStrip1
|
// toolStrip1
|
||||||
//
|
//
|
||||||
this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None;
|
this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None;
|
||||||
@@ -299,14 +257,27 @@
|
|||||||
//
|
//
|
||||||
this.tt.ShowAlways = true;
|
this.tt.ShowAlways = true;
|
||||||
//
|
//
|
||||||
|
// surface1
|
||||||
|
//
|
||||||
|
this.surface1.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.surface1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.surface1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.surface1.Name = "surface1";
|
||||||
|
this.surface1.Size = new System.Drawing.Size(783, 680);
|
||||||
|
this.surface1.TabIndex = 5;
|
||||||
|
this.surface1.Text = "surface1";
|
||||||
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(985, 705);
|
this.ClientSize = new System.Drawing.Size(985, 705);
|
||||||
this.Controls.Add(this.toolStripContainer1);
|
this.Controls.Add(this.toolStripContainer1);
|
||||||
|
this.KeyPreview = true;
|
||||||
this.Name = "Form1";
|
this.Name = "Form1";
|
||||||
this.Text = "OpenRA Editor";
|
this.Text = "OpenRA Editor";
|
||||||
|
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyUp);
|
||||||
|
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
|
||||||
this.toolStripContainer1.ContentPanel.ResumeLayout(false);
|
this.toolStripContainer1.ContentPanel.ResumeLayout(false);
|
||||||
this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false);
|
this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false);
|
||||||
this.toolStripContainer1.TopToolStripPanel.PerformLayout();
|
this.toolStripContainer1.TopToolStripPanel.PerformLayout();
|
||||||
@@ -346,8 +317,6 @@
|
|||||||
private System.Windows.Forms.FolderBrowserDialog folderBrowser;
|
private System.Windows.Forms.FolderBrowserDialog folderBrowser;
|
||||||
private System.Windows.Forms.ToolStripButton toolStripButton6;
|
private System.Windows.Forms.ToolStripButton toolStripButton6;
|
||||||
private System.Windows.Forms.ToolStripButton toolStripButton7;
|
private System.Windows.Forms.ToolStripButton toolStripButton7;
|
||||||
private System.Windows.Forms.VScrollBar vScrollBar1;
|
|
||||||
private System.Windows.Forms.HScrollBar hScrollBar1;
|
|
||||||
private Surface surface1;
|
private Surface surface1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,8 +88,6 @@ namespace OpenRA.Editor
|
|||||||
var palette = new Palette(FileSystem.Open(map.Theater.ToLowerInvariant() + ".pal"), true);
|
var palette = new Palette(FileSystem.Open(map.Theater.ToLowerInvariant() + ".pal"), true);
|
||||||
|
|
||||||
surface1.Bind(map, tileset, palette);
|
surface1.Bind(map, tileset, palette);
|
||||||
vScrollBar1.Maximum = map.MapSize.Y*24 - surface1.Height;
|
|
||||||
hScrollBar1.Maximum = map.MapSize.X*24 - surface1.Width;
|
|
||||||
|
|
||||||
// construct the palette of tiles
|
// construct the palette of tiles
|
||||||
|
|
||||||
@@ -318,8 +316,6 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
surface1.Map.Resize((int)rd.width.Value, (int)rd.height.Value);
|
surface1.Map.Resize((int)rd.width.Value, (int)rd.height.Value);
|
||||||
surface1.Bind(surface1.Map, surface1.TileSet, surface1.Palette); // rebind it to invalidate all caches
|
surface1.Bind(surface1.Map, surface1.TileSet, surface1.Palette); // rebind it to invalidate all caches
|
||||||
vScrollBar1.Maximum = surface1.Map.MapSize.Y * 24 - surface1.Height;
|
|
||||||
hScrollBar1.Maximum = surface1.Map.MapSize.X * 24 - surface1.Width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
surface1.Invalidate();
|
surface1.Invalidate();
|
||||||
@@ -438,30 +434,8 @@ namespace OpenRA.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpawnPointsClicked(object sender, EventArgs e)
|
void SpawnPointsClicked(object sender, EventArgs e) { surface1.SetWaypoint(new WaypointTemplate()); }
|
||||||
{
|
void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Space) surface1.IsPanning = true; }
|
||||||
surface1.SetWaypoint(new WaypointTemplate()); // hack
|
void Form1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Space) surface1.IsPanning = false; }
|
||||||
}
|
|
||||||
|
|
||||||
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
|
|
||||||
{
|
|
||||||
surface1.Scroll(new int2(0,e.NewValue-e.OldValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
|
|
||||||
{
|
|
||||||
surface1.Scroll(new int2(e.NewValue - e.OldValue,0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void surface1_Resize(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (surface1.Map == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
vScrollBar1.Maximum = surface1.Map.MapSize.Y * 24 - surface1.Height;
|
|
||||||
hScrollBar1.Maximum = surface1.Map.MapSize.X * 24 - surface1.Width;
|
|
||||||
|
|
||||||
surface1.ValidateOffset(surface1.Width,surface1.Height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Thirdparty;
|
using OpenRA.Thirdparty;
|
||||||
|
|
||||||
@@ -15,10 +15,12 @@ namespace OpenRA.Editor
|
|||||||
public Palette Palette { get; private set; }
|
public Palette Palette { get; private set; }
|
||||||
int2 Offset;
|
int2 Offset;
|
||||||
|
|
||||||
public BrushTemplate Brush;
|
BrushTemplate Brush;
|
||||||
public ActorTemplate Actor;
|
ActorTemplate Actor;
|
||||||
public ResourceTemplate Resource;
|
ResourceTemplate Resource;
|
||||||
public WaypointTemplate Waypoint;
|
WaypointTemplate Waypoint;
|
||||||
|
|
||||||
|
public bool IsPanning;
|
||||||
|
|
||||||
Dictionary<string, ActorTemplate> ActorTemplates = new Dictionary<string, ActorTemplate>();
|
Dictionary<string, ActorTemplate> ActorTemplates = new Dictionary<string, ActorTemplate>();
|
||||||
Dictionary<int, ResourceTemplate> ResourceTemplates = new Dictionary<int, ResourceTemplate>();
|
Dictionary<int, ResourceTemplate> ResourceTemplates = new Dictionary<int, ResourceTemplate>();
|
||||||
@@ -68,12 +70,6 @@ namespace OpenRA.Editor
|
|||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ValidateOffset(int width, int height)
|
|
||||||
{
|
|
||||||
Offset.X = System.Math.Max(Offset.X, width - Map.MapSize.X * 24);
|
|
||||||
Offset.Y = System.Math.Max(Offset.Y, height - Map.MapSize.Y * 24);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnMouseMove(MouseEventArgs e)
|
protected override void OnMouseMove(MouseEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnMouseMove(e);
|
base.OnMouseMove(e);
|
||||||
@@ -81,7 +77,7 @@ namespace OpenRA.Editor
|
|||||||
var oldMousePos = MousePos;
|
var oldMousePos = MousePos;
|
||||||
MousePos = new int2(e.Location);
|
MousePos = new int2(e.Location);
|
||||||
|
|
||||||
if (e.Button == MouseButtons.Middle)
|
if (e.Button == MouseButtons.Middle || (e.Button != MouseButtons.None && IsPanning))
|
||||||
Scroll(oldMousePos - MousePos);
|
Scroll(oldMousePos - MousePos);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -216,8 +212,11 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
base.OnMouseDown(e);
|
base.OnMouseDown(e);
|
||||||
|
|
||||||
|
if (!IsPanning)
|
||||||
|
{
|
||||||
if (e.Button == MouseButtons.Right) Erase();
|
if (e.Button == MouseButtons.Right) Erase();
|
||||||
if (e.Button == MouseButtons.Left) Draw();
|
if (e.Button == MouseButtons.Left) Draw();
|
||||||
|
}
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user