added switchable ruler markings to editor

This commit is contained in:
Matthias Mailänder
2013-04-02 08:55:45 +02:00
parent 6a466bde38
commit a55a902ba5
4 changed files with 84 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ namespace OpenRA.Editor
public bool IsPanning;
public bool ShowActorNames;
public bool ShowGrid;
public bool ShowRuler;
public bool IsPaste { get { return TileSelection != null && ResourceSelection != null; } }
public TileReference<ushort, byte>[,] TileSelection;
@@ -54,6 +55,9 @@ namespace OpenRA.Editor
Dictionary<string, ActorTemplate> ActorTemplates = new Dictionary<string, ActorTemplate>();
public Dictionary<int, ResourceTemplate> ResourceTemplates = new Dictionary<int, ResourceTemplate>();
static readonly Font MarkerFont = new Font(FontFamily.GenericSansSerif, 12.0f, FontStyle.Regular);
static readonly SolidBrush TextBrush = new SolidBrush(Color.Red);
public Keys GetModifiers() { return ModifierKeys; }
public void Bind(Map m, TileSet ts, Palette p, Palette pp)
@@ -438,6 +442,27 @@ namespace OpenRA.Editor
Brushes.White,
Brushes.Black);
if (ShowRuler && Zoom > 0.2)
{
for (int i = Map.Bounds.Left; i <= Map.Bounds.Right; i+=8)
{
if( i % 8 == 0)
{
PointF point = new PointF(i * TileSet.TileSize * Zoom + Offset.X, (Map.Bounds.Top - 8) * TileSet.TileSize * Zoom + Offset.Y);
e.Graphics.DrawString((i - Map.Bounds.Left).ToString(), MarkerFont, TextBrush, point);
}
}
for (int i = Map.Bounds.Top; i <= Map.Bounds.Bottom; i+=8)
{
if (i % 8 == 0)
{
PointF point = new PointF((Map.Bounds.Left - 8) * TileSet.TileSize * Zoom + Offset.X, i * TileSet.TileSize * Zoom + Offset.Y);
e.Graphics.DrawString((i - Map.Bounds.Left).ToString(), MarkerFont, TextBrush, point);
}
}
}
if (Tool != null)
Tool.Preview(this, e.Graphics);