Merge pull request 'roomDrawingArea' (#39) from roomDrawingArea into develop
Reviewed-on: michele/Map#39
This commit is contained in:
commit
5434766207
1 changed files with 89 additions and 20 deletions
|
@ -796,25 +796,94 @@ _lblOverlayName.Padding=new Myra.Graphics2D.Thickness(4);
|
|||
break;
|
||||
}
|
||||
|
||||
var ffont = _fonts.FirstOrDefault(m => int.Parse(m.Key.Replace("font", "")) > _state.TileSize / 3).Value ?? _fonts.Last().Value;
|
||||
var fscale = 1.2f;
|
||||
var width = Math.Abs((endposX - posX));
|
||||
var height = Math.Abs((posY - endposY));
|
||||
var tilesWidth = width / (double)_state.TileSize;
|
||||
var tilesHeight = height / (double)_state.TileSize;
|
||||
tilesWidth = Math.Round(tilesWidth * 2, MidpointRounding.AwayFromZero) / 2;
|
||||
tilesHeight = Math.Round(tilesHeight * 2, MidpointRounding.AwayFromZero) / 2;
|
||||
var xmeasure = ffont.MeasureString($"{tilesWidth}");
|
||||
var ymeasure = ffont.MeasureString($"{tilesHeight}");
|
||||
float widthX = 0, widthY = 0, heightX = 0, heightY = 0;
|
||||
|
||||
Rectangle area = new Rectangle();
|
||||
if (posX != endposX && posY != endposY)
|
||||
{
|
||||
|
||||
if ((posX > endposX && posY > endposY) || (posX < endposX && posY < endposY))
|
||||
{
|
||||
_spriteBatch.Draw(_transparentRedRectangle, new Rectangle(posX, posY, endposX - posX, endposY - posY), null, Color.White, 0, new Vector2(0, 0), SpriteEffects.None, 1);
|
||||
area = new Rectangle(posX, posY, endposX - posX, endposY - posY);
|
||||
|
||||
if (posX > endposX && posY > endposY)
|
||||
{
|
||||
widthX = endposX + (width / 2) - xmeasure.X / 2;
|
||||
widthY = endposY - ymeasure.Y * 1.2f;
|
||||
|
||||
heightX = posX + xmeasure.X / 2;
|
||||
heightY = endposY + (height / 2) - ymeasure.Y / 2;
|
||||
}
|
||||
else if (posX < endposX && posY < endposY)
|
||||
{
|
||||
widthX = posX + (width / 2) - xmeasure.X / 2;
|
||||
widthY = posY - ymeasure.Y * 1.2f;
|
||||
|
||||
heightX = endposX + xmeasure.X / 2;
|
||||
heightY = posY + (height / 2) - ymeasure.Y / 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (endposY < posY)
|
||||
{
|
||||
_spriteBatch.Draw(_transparentRedRectangle, new Rectangle(posX, endposY, endposX - posX, posY - endposY), null, Color.White, 0, new Vector2(0, 0), SpriteEffects.None, 1);
|
||||
area = new Rectangle(posX, endposY, endposX - posX, posY - endposY);
|
||||
|
||||
widthX = posX + (width / 2) - xmeasure.X / 2;
|
||||
widthY = endposY - ymeasure.Y * 1.2f;
|
||||
|
||||
heightX = endposX + xmeasure.X / 2;
|
||||
heightY = endposY + (height / 2) - ymeasure.Y / 2;
|
||||
}
|
||||
|
||||
if (endposX < posX)
|
||||
{
|
||||
_spriteBatch.Draw(_transparentRedRectangle, new Rectangle(endposX, posY, posX - endposX, endposY - posY), null, Color.White, 0, new Vector2(0, 0), SpriteEffects.None, 1);
|
||||
area = new Rectangle(endposX, posY, posX - endposX, endposY - posY);
|
||||
|
||||
widthX = endposX + (width / 2) - xmeasure.X / 2;
|
||||
widthY = posY - ymeasure.Y * 1.2f;
|
||||
|
||||
heightX = posX + xmeasure.X / 2;
|
||||
heightY = posY + (height / 2) - ymeasure.Y / 2;
|
||||
}
|
||||
}
|
||||
|
||||
_spriteBatch.Draw(_transparentRedRectangle, area, null, Color.White, 0, new Vector2(0, 0), SpriteEffects.None, 1);
|
||||
|
||||
_spriteBatch.DrawString(ffont,
|
||||
$"{tilesWidth}",
|
||||
new Vector2(
|
||||
widthX,
|
||||
widthY
|
||||
),
|
||||
Color.Red,
|
||||
0,
|
||||
Vector2.Zero,
|
||||
fscale,
|
||||
SpriteEffects.None,
|
||||
0);
|
||||
|
||||
_spriteBatch.DrawString(ffont,
|
||||
$"{tilesHeight}",
|
||||
new Vector2(
|
||||
heightX, heightY
|
||||
),
|
||||
Color.Red,
|
||||
0,
|
||||
Vector2.Zero,
|
||||
fscale,
|
||||
SpriteEffects.None,
|
||||
0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue