From af7d9ee6cb91539395b734af8122d51b66b9b32b Mon Sep 17 00:00:00 2001 From: Michele Date: Mon, 30 Nov 2020 23:17:12 +0000 Subject: [PATCH] display note on grid --- Sledgemapper.Shared/Entities/Session.cs | 2 ++ Sledgemapper/Sledgemapper.cs | 41 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/Sledgemapper.Shared/Entities/Session.cs b/Sledgemapper.Shared/Entities/Session.cs index 8f5ec5a..692471f 100644 --- a/Sledgemapper.Shared/Entities/Session.cs +++ b/Sledgemapper.Shared/Entities/Session.cs @@ -26,6 +26,7 @@ namespace Sledgemapper.Shared.Entities Map = new ConcurrentDictionary(); Overlays = new ConcurrentDictionary(); Walls = new ConcurrentDictionary(); + Notes = new ConcurrentDictionary(); Players = new List(); Colors = new List(); } @@ -33,6 +34,7 @@ namespace Sledgemapper.Shared.Entities public ConcurrentDictionary Map { get; set; } public ConcurrentDictionary Walls { get; set; } public ConcurrentDictionary Overlays { get; set; } + public ConcurrentDictionary Notes { get; set; } public bool IsValid { get; set; } public List Players { get; set; } public List Colors { get; set; } diff --git a/Sledgemapper/Sledgemapper.cs b/Sledgemapper/Sledgemapper.cs index 8aab4a9..fd301bc 100644 --- a/Sledgemapper/Sledgemapper.cs +++ b/Sledgemapper/Sledgemapper.cs @@ -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)