fix some dumb (nonfatal) crashes in the editor with nothing loaded

This commit is contained in:
Chris Forbes
2010-10-11 18:21:41 +13:00
parent 0df9815d2c
commit a2205e9031
3 changed files with 13 additions and 7 deletions

View File

@@ -429,7 +429,6 @@
this.surface1.Size = new System.Drawing.Size(783, 727); this.surface1.Size = new System.Drawing.Size(783, 727);
this.surface1.TabIndex = 5; this.surface1.TabIndex = 5;
this.surface1.Text = "surface1"; this.surface1.Text = "surface1";
this.surface1.Click += new System.EventHandler(this.OnSurfaceClicked);
// //
// saveFileDialog // saveFileDialog
// //

View File

@@ -35,7 +35,13 @@ namespace OpenRA.Editor
Rules.LoadRules(Game.modData.Manifest, new Map()); Rules.LoadRules(Game.modData.Manifest, new Map());
surface1.AfterChange += MakeDirty; surface1.AfterChange += OnMapChanged;
}
void OnMapChanged()
{
MakeDirty();
pmMiniMap.Image = Minimap.AddStaticResources(surface1.Map, Minimap.TerrainBitmap(surface1.Map, true));
} }
void MakeDirty() { dirty = true; } void MakeDirty() { dirty = true; }
@@ -390,11 +396,6 @@ namespace OpenRA.Editor
pb.Show(); pb.Show();
} }
private void OnSurfaceClicked(object sender, EventArgs e)
{
pmMiniMap.Image = Minimap.AddStaticResources(surface1.Map, Minimap.TerrainBitmap(surface1.Map, true));
}
private void mnuMinimapToPNG_Click(object sender, EventArgs e) private void mnuMinimapToPNG_Click(object sender, EventArgs e)
{ {
try try

View File

@@ -87,6 +87,8 @@ namespace OpenRA.Editor
{ {
base.OnMouseWheel(e); base.OnMouseWheel(e);
if (Map == null) return;
Zoom *= e.Delta > 0 ? 4.0f / 3.0f : .75f; Zoom *= e.Delta > 0 ? 4.0f / 3.0f : .75f;
Invalidate(); Invalidate();
@@ -114,6 +116,8 @@ namespace OpenRA.Editor
{ {
base.OnMouseMove(e); base.OnMouseMove(e);
if (Map == null) return;
var oldMousePos = MousePos; var oldMousePos = MousePos;
MousePos = new int2(e.Location); MousePos = new int2(e.Location);
@@ -332,6 +336,8 @@ namespace OpenRA.Editor
{ {
base.OnMouseDown(e); base.OnMouseDown(e);
if (Map == null) return;
if (!IsPanning) if (!IsPanning)
{ {
if (e.Button == MouseButtons.Right) Erase(); if (e.Button == MouseButtons.Right) Erase();