give the editor scrollbars

This commit is contained in:
Paul Chote
2010-05-14 20:33:54 +12:00
committed by Chris Forbes
parent 6936c73b68
commit c911065442
4 changed files with 156 additions and 93 deletions

View File

@@ -88,7 +88,9 @@ namespace OpenRA.Editor
var palette = new Palette(FileSystem.Open(map.Theater.ToLowerInvariant() + ".pal"), true);
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
foreach (var n in tileset.tiles.Keys)
@@ -316,6 +318,8 @@ namespace OpenRA.Editor
{
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
vScrollBar1.Maximum = surface1.Map.MapSize.Y * 24 - surface1.Height;
hScrollBar1.Maximum = surface1.Map.MapSize.X * 24 - surface1.Width;
}
surface1.Invalidate();
@@ -438,5 +442,26 @@ namespace OpenRA.Editor
{
surface1.SetWaypoint(new WaypointTemplate()); // hack
}
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);
}
}
}