display note on grid

This commit is contained in:
Michele 2020-11-30 23:17:12 +00:00 committed by Michele Scandura
parent ec98d53f48
commit af7d9ee6cb
2 changed files with 43 additions and 0 deletions

View file

@ -26,6 +26,7 @@ namespace Sledgemapper.Shared.Entities
Map = new ConcurrentDictionary<string, Tile>();
Overlays = new ConcurrentDictionary<string, Overlay>();
Walls = new ConcurrentDictionary<string, Wall>();
Notes = new ConcurrentDictionary<string, Note>();
Players = new List<Player>();
Colors = new List<string>();
}
@ -33,6 +34,7 @@ namespace Sledgemapper.Shared.Entities
public ConcurrentDictionary<string, Tile> Map { get; set; }
public ConcurrentDictionary<string, Wall> Walls { get; set; }
public ConcurrentDictionary<string, Overlay> Overlays { get; set; }
public ConcurrentDictionary<string, Note> Notes { get; set; }
public bool IsValid { get; set; }
public List<Player> Players { get; set; }
public List<string> Colors { get; set; }

View file

@ -208,7 +208,17 @@ namespace Sledgemapper
{
Title = "Note"
};
noteWindow.BtnOk.Click += (s, e) =>
{
var note = new Note
{
X = _state.SelectedTile.X,
Y = _state.SelectedTile.Y,
Text = noteWindow.NoteText.Text
};
_sessionData.Notes.TryAdd(note.ToString(), note);
};
// var content = new LoginRegisterWindow();
// content.RdoLogin.IsPressed = true;
// content.RdoLogin.Click += (s, e) =>
@ -386,6 +396,8 @@ namespace Sledgemapper
DrawWalls();
DrawOverlays();
DrawNotes();
if (string.IsNullOrWhiteSpace(_sessionData.SessionName))
{
@ -548,6 +560,35 @@ namespace Sledgemapper
}
}
private void DrawNotes()
{
foreach (var note in _sessionData.Notes.Values)
{
var ffont = _fonts.FirstOrDefault(m => int.Parse(m.Key.Replace("font", "")) > _state.TileSize / 8).Value ?? _fonts.Last().Value;
var fscale = 1f;
var screenPosition = new Point(note.X * _state.TileSize - (int)_viewportCenter.X, note.Y * _state.TileSize - (int)_viewportCenter.Y);
var x = screenPosition.X / _state.TileSize;
var y = screenPosition.Y / _state.TileSize;
_spriteBatch.DrawString(ffont,
"N",
new Vector2(
x * _state.TileSize + _state.TileSize - _state.TileSize/3,
y * _state.TileSize + 2
),
Color.Black,
0,
Vector2.Zero,
fscale,
SpriteEffects.None,
0);
}
}
private void DrawOverlays()
{
foreach (var tile in _sessionData.Overlays.Values)