Merge pull request 'develop' (#42) from develop into master

Reviewed-on: michele/Map#42
This commit is contained in:
michele 2021-02-11 10:35:06 +00:00
commit f00b295b5e
39 changed files with 1889 additions and 384 deletions

331
Assets/walls.svg Normal file
View file

@ -0,0 +1,331 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15, custom)"
sodipodi:docname="walls.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.6"
inkscape:cx="541.84864"
inkscape:cy="364.64104"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1017"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
id="rect839-9-8"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:0.996289;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 161.33258,110.84152 -3.40179,-1e-5 -1e-5,-10.29985 h 3.4018 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall11.png" />
<path
id="rect839"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:0.996289;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 124.66732,52.916664 h 3.40179 v 10.29985 h -3.40179 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
id="rect837"
style="fill:#ffffff;fill-opacity:1;stroke:#18769d;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 121.68006,63.820026 h 9.37631 v 9.376308 h -9.37631 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
id="rect839-9"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:0.996289;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 128.06912,84.099698 -3.40179,-6e-6 -1e-5,-10.299849 3.4018,-3e-6 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<g
id="g991">
<path
id="rect839-8"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:0.996289;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 100.35072,62.785272 h 3.40179 v 10.29985 h -3.40179 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
id="rect837-6"
style="fill:#ffffff;fill-opacity:1;stroke:#18769d;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 97.363463,68.820831 h 9.376307 v 9.376308 h -9.376307 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
id="rect839-9-5"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:0.996289;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 103.75252,93.968306 -3.40179,-6e-6 -1e-5,-10.299849 3.4018,-3e-6 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
id="rect837-6-1"
style="fill:#ffffff;fill-opacity:1;stroke:#18769d;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 97.363473,78.427726 h 9.376287 v 9.376308 h -9.376287 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
</g>
<path
id="rect839-8-4"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.73352;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 76.557846,61.618719 h 3.40179 v 31.183 h -3.40179 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.73352;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 66.970525,70.345466 c -51.094901,-47.36214 -25.54745,-23.681071 0,0 z"
id="path1022" />
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.73352;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 70.372384,82.679594 h -3.401859 v 9.424231 h 3.401859 z"
id="path1020"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.73352;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 70.372384,82.679594 c -53.362807,-55.584891 -26.681403,-27.792447 0,0 z"
id="path1018" />
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.73352;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 66.970525,60.920716 v 9.42475 h 3.401859 v -9.42475 z"
id="rect839-8-4-4"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:17.1899px;line-height:1.25;font-family:sans-serif;fill:#18769d;fill-opacity:1;stroke:none;stroke-width:0.42975"
x="28.85297"
y="68.818146"
id="text1026"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"><tspan
sodipodi:role="line"
id="tspan1024"
x="28.85297"
y="68.818146"
style="fill:#18769d;fill-opacity:1;stroke-width:0.42975">S</tspan></text>
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.59717;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 36.496502,70.199 h -3.401859 v 8 h 3.401859 z"
id="path1020-7"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.59713;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 33.094643,47.016332 v 8 h 3.401859 v -8 z"
id="rect839-8-4-4-6"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.38319;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 31.419307,117.6453 h -3.401859 v 6 h 3.401859 z"
id="path1020-7-8-3"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall06.png" />
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.38316;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 28.017448,92.462583 v 6 h 3.401859 v -6 z"
id="rect839-8-4-4-6-9-7"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall06.png" />
<circle
style="fill:#18769d;fill-opacity:1;stroke:#18769d;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path1084-9"
cx="29.718378"
cy="101.75826"
r="1.4699824"
inkscape:transform-center-x="3.6081386"
inkscape:transform-center-y="0.13363476"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall06.png"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<circle
style="fill:#18769d;fill-opacity:1;stroke:#18769d;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path1084-8-4"
cx="29.718378"
cy="108.05394"
r="1.4699824"
inkscape:transform-center-x="3.6081386"
inkscape:transform-center-y="0.13363476"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall06.png"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<circle
style="fill:#18769d;fill-opacity:1;stroke:#18769d;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path1084-89-3"
cx="29.718378"
cy="114.34962"
r="1.4699824"
inkscape:transform-center-x="3.6081386"
inkscape:transform-center-y="0.13363476"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall06.png"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<g
id="g1182"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall08.png"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087">
<path
id="rect839-84"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:0.996289;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 141.83556,55.042784 h 3.40179 v 10.29985 h -3.40179 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
id="rect837-8"
style="fill:#ffffff;fill-opacity:1;stroke:#18769d;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 138.8483,65.946146 h 9.37631 v 9.376308 h -9.37631 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
id="rect839-9-6"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:0.996289;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 145.23736,86.225818 -3.40179,-6e-6 -1e-5,-10.299849 3.4018,-3e-6 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
</g>
<rect
style="fill:#18769d;fill-opacity:1;stroke:#18769d;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1184"
width="8.4572172"
height="0.33072916"
x="139.30785"
y="70.468933"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall08.png"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<g
id="g1182-9"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall07.png"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"
transform="translate(-9.283251,23.495728)">
<path
id="rect839-84-0"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:0.996289;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 141.83556,55.042784 h 3.40179 v 10.29985 h -3.40179 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
id="rect837-8-8"
style="fill:#ffffff;fill-opacity:1;stroke:#18769d;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 138.8483,65.946146 h 9.37631 v 9.376308 h -9.37631 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
id="rect839-9-6-0"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:0.996289;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 145.23736,86.225818 -3.40179,-6e-6 -1e-5,-10.299849 3.4018,-3e-6 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
</g>
<rect
style="fill:#18769d;fill-opacity:1;stroke:#18769d;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1184-0"
width="8.4572172"
height="0.33072916"
x="-98.358635"
y="134.08784"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall07.png"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"
transform="rotate(-90)" />
<path
id="rect839-8-4-2"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.73352;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 79.941962,159.0335 h 3.40179 v 31.183 h -3.40179 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
style="fill:none;stroke:#18769d;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="m 56.885417,187.47616 c 0,0 -3.871824,-2.25269 -2.783926,-4.80866 0.300311,-2.45648 6.258604,-1.34995 5.809048,-3.85616 -0.40522,-2.25905 -5.821832,-1.81558 -5.859944,-4.99196 -0.03811,-3.17637 5.87567,-1.83643 6.113573,-4.86905 0.237904,-3.03261 -5.934304,-1.34719 -6.019078,-4.835 -0.08478,-3.48781 6.385232,-1.54767 6.047619,-3.94791 -0.337614,-2.40025 -3.307292,-3.87426 -3.307292,-3.87426"
id="path1242"
sodipodi:nodetypes="ccszzzzc"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall09.png"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087" />
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.73352;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 136.24808,198.5572 h -3.40186 v 9.42423 h 3.40186 z"
id="path1020-9"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall10.png" />
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.73352;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 132.84622,176.79833 v 9.42475 h 3.40186 v -9.42475 z"
id="rect839-8-4-4-9"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall10.png" />
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.73352;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 129.83478,199.83406 h 9.42475 v -3.40186 h -9.42475 z"
id="rect839-8-4-4-9-8"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall10.png" />
<path
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:1.73352;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 129.83478,188.34782 h 9.42475 v -3.40186 h -9.42475 z"
id="rect839-8-4-4-9-8-5"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall10.png" />
<path
id="rect839-3"
style="fill:#18769d;fill-opacity:1;stroke:none;stroke-width:0.996289;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 157.93079,79.658483 h 3.40179 v 10.29985 h -3.40179 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall11.png" />
<path
id="rect837-4"
style="fill:#ffffff;fill-opacity:1;stroke:#18769d;stroke-width:1.57862;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 156.42099,85.518439 h 6.42138 v 19.463121 h -6.42138 z"
inkscape:export-xdpi="208.89087"
inkscape:export-ydpi="208.89087"
inkscape:export-filename="C:\dev\Map\Sledgemapper\Content\walls\wall11.png" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -0,0 +1,13 @@
// using Sledgemapper.Shared.Entities;
// namespace Sledgemapper.Api.Commands
// {
// public class PingCommand : BaseCommand<bool>
// {
// public Ping Location { get; private set; }
// public PingCommand(string sessionName, Ping location, int userId) : base(sessionName, userId)
// {
// Location = location;
// }
// }
// }

View file

@ -2,6 +2,7 @@ using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Sledgemapper.Api.Commands;
using Sledgemapper.Api.Notifications;
using Sledgemapper.Shared.Entities;
using System.Threading.Tasks;
@ -30,6 +31,12 @@ namespace Sledgemapper.Api.Controllers
return result;
}
// [HttpPost("ping")]
// public async Task Post(string sessionName, [FromBody] Ping pingLocation)
// {
// await _mediator.Send(new PingCommand(sessionName, pingLocation, UserId));
// }
[HttpPost("snapshot")]
public async Task Post(string sessionName, [FromBody] Session session)
{
@ -60,13 +67,13 @@ namespace Sledgemapper.Api.Controllers
await _mediator.Send(new NewNoteCommand(sessionName, note, UserId));
}
[HttpPost("room")]
[HttpPost("room")]
public async Task Post(string sessionName, [FromBody] Room room)
{
await _mediator.Send(new NewRoomCommand(sessionName, room, UserId));
}
[HttpPost("line")]
[HttpPost("line")]
public async Task Post(string sessionName, [FromBody] Line line)
{
await _mediator.Send(new NewLineCommand(sessionName, line, UserId));

View file

@ -35,7 +35,5 @@ namespace Sledgemapper.Api.Commands
await _mediator.Publish(new NewTileNotification(session, notification.Tile, notification.UserId));
return true;
}
}
}

View file

@ -0,0 +1,28 @@
// using MediatR;
// using Sledgemapper.Api.Data;
// using System.Threading;
// using System.Threading.Tasks;
// using Sledgemapper.Api.Notifications;
// using System.Linq;
// namespace Sledgemapper.Api.Commands
// {
// public class PingCommandHandler : IRequestHandler<PingCommand, bool>
// {
// private readonly MyDbContext _dbcontext;
// private readonly IMediator _mediator;
// public PingCommandHandler(IMediator mediator, MyDbContext dbcontext) { _dbcontext = dbcontext; _mediator = mediator; }
// public async Task<bool> Handle(PingCommand notification, CancellationToken cancellationToken)
// {
// var session = _dbcontext.Sessions.First(m => m.SessionName == notification.SessionName);
// await _mediator.Publish(new PingNotification(session, notification.Location, notification.UserId));
// return true;
// }
// }
// }

View file

@ -0,0 +1,23 @@
// using MediatR;
// using Microsoft.AspNetCore.SignalR;
// using Sledgemapper.Api.Notifications;
// using Sledgemapper.Clients;
// using System.Threading;
// using System.Threading.Tasks;
// using Sledgemapper.Api.Hubs;
// namespace Sledgemapper.Api.Handlers
// {
// public class SendPingMessage : INotificationHandler<PingNotification>
// {
// private readonly IHubContext<SledgemapperHub, ISledgemapperClient> _hub;
// public SendPingMessage(IHubContext<SledgemapperHub, ISledgemapperClient> hub) => _hub = hub;
// public async Task Handle(PingNotification notification, CancellationToken cancellationToken)
// {
// await _hub.Clients.Groups(notification.Session.SessionName).Ping(notification.Location, notification.UserId);
// }
// }
// }

View file

@ -51,7 +51,7 @@ namespace Sledgemapper.Api.Hubs
await Clients.Group(sessionName).NewRoom(room);
}
public async Task NewLine(string sessionName, Line line)
public async Task NewLine(string sessionName, Line line)
{
await Clients.Group(sessionName).NewLine(line);
}
@ -86,6 +86,15 @@ namespace Sledgemapper.Api.Hubs
await Clients.Group(sessionName).DeleteOverlay(tile);
}
public async Task Ping(string sessionName, Tile location)
{
var userId = int.Parse(Context.User.Identity.Name);
var user = _datacontext.Users.First(u => u.Id == userId);
var player = new Player { UserId = userId, Initials = user.Initials, Position = new Tile { X = 0, Y = 0 }, Color = UserColors[userId] };
await Clients.Group(sessionName).Ping(new Ping{X=location.X, Y=location.Y, Player=player});
}
public async Task<Sledgemapper.Shared.Entities.Session> JoinSession(string sessionName)
{
var session = _dbContext.Sessions.FirstOrDefault(s => s.SessionName == sessionName);

View file

@ -0,0 +1,14 @@
// using Sledgemapper.Shared.Entities;
// namespace Sledgemapper.Api.Notifications
// {
// public class PingNotification : BaseNotification
// {
// public Ping Location { get; private set; }
// public PingNotification(Models.Session session, Ping location, int userId) : base(session, userId)
// {
// Location = location;
// }
// }
// }

Binary file not shown.

Binary file not shown.

View file

@ -20,5 +20,6 @@ namespace Sledgemapper.Clients
Task UpdateMap(Session player);
Task RefreshPlayers();
Task NewLine(Line line);
Task Ping(Ping ping);
}
}

View file

@ -0,0 +1,450 @@
using System;
#if UNITY
using UnityEngine;
using Math = UnityEngine.Mathf;
#endif
static public class Easings
{
/// <summary>
/// Constant Pi.
/// </summary>
private const float PI = (float)(float)Math.PI;
/// <summary>
/// Constant Pi / 2.
/// </summary>
private const float HALFPI =(float) (float)Math.PI / 2.0f;
/// <summary>
/// Easing Functions enumeration
/// </summary>
public enum Functions
{
Linear,
QuadraticEaseIn,
QuadraticEaseOut,
QuadraticEaseInOut,
CubicEaseIn,
CubicEaseOut,
CubicEaseInOut,
QuarticEaseIn,
QuarticEaseOut,
QuarticEaseInOut,
QuinticEaseIn,
QuinticEaseOut,
QuinticEaseInOut,
SineEaseIn,
SineEaseOut,
SineEaseInOut,
CircularEaseIn,
CircularEaseOut,
CircularEaseInOut,
ExponentialEaseIn,
ExponentialEaseOut,
ExponentialEaseInOut,
ElasticEaseIn,
ElasticEaseOut,
ElasticEaseInOut,
BackEaseIn,
BackEaseOut,
BackEaseInOut,
BounceEaseIn,
BounceEaseOut,
BounceEaseInOut
}
/// <summary>
/// Interpolate using the specified function.
/// </summary>
static public float Interpolate(float p, Functions function)
{
switch(function)
{
default:
case Functions.Linear: return Linear(p);
case Functions.QuadraticEaseOut: return QuadraticEaseOut(p);
case Functions.QuadraticEaseIn: return QuadraticEaseIn(p);
case Functions.QuadraticEaseInOut: return QuadraticEaseInOut(p);
case Functions.CubicEaseIn: return CubicEaseIn(p);
case Functions.CubicEaseOut: return CubicEaseOut(p);
case Functions.CubicEaseInOut: return CubicEaseInOut(p);
case Functions.QuarticEaseIn: return QuarticEaseIn(p);
case Functions.QuarticEaseOut: return QuarticEaseOut(p);
case Functions.QuarticEaseInOut: return QuarticEaseInOut(p);
case Functions.QuinticEaseIn: return QuinticEaseIn(p);
case Functions.QuinticEaseOut: return QuinticEaseOut(p);
case Functions.QuinticEaseInOut: return QuinticEaseInOut(p);
case Functions.SineEaseIn: return SineEaseIn(p);
case Functions.SineEaseOut: return SineEaseOut(p);
case Functions.SineEaseInOut: return SineEaseInOut(p);
case Functions.CircularEaseIn: return CircularEaseIn(p);
case Functions.CircularEaseOut: return CircularEaseOut(p);
case Functions.CircularEaseInOut: return CircularEaseInOut(p);
case Functions.ExponentialEaseIn: return ExponentialEaseIn(p);
case Functions.ExponentialEaseOut: return ExponentialEaseOut(p);
case Functions.ExponentialEaseInOut: return ExponentialEaseInOut(p);
case Functions.ElasticEaseIn: return ElasticEaseIn(p);
case Functions.ElasticEaseOut: return ElasticEaseOut(p);
case Functions.ElasticEaseInOut: return ElasticEaseInOut(p);
case Functions.BackEaseIn: return BackEaseIn(p);
case Functions.BackEaseOut: return BackEaseOut(p);
case Functions.BackEaseInOut: return BackEaseInOut(p);
case Functions.BounceEaseIn: return BounceEaseIn(p);
case Functions.BounceEaseOut: return BounceEaseOut(p);
case Functions.BounceEaseInOut: return BounceEaseInOut(p);
}
}
/// <summary>
/// Modeled after the line y = x
/// </summary>
static public float Linear(float p)
{
return p;
}
/// <summary>
/// Modeled after the parabola y = x^2
/// </summary>
static public float QuadraticEaseIn(float p)
{
return p * p;
}
/// <summary>
/// Modeled after the parabola y = -x^2 + 2x
/// </summary>
static public float QuadraticEaseOut(float p)
{
return -(p * (p - 2));
}
/// <summary>
/// Modeled after the piecewise quadratic
/// y = (1/2)((2x)^2) ; [0, 0.5)
/// y = -(1/2)((2x-1)*(2x-3) - 1) ; [0.5, 1]
/// </summary>
static public float QuadraticEaseInOut(float p)
{
if(p < 0.5f)
{
return 2 * p * p;
}
else
{
return (-2 * p * p) + (4 * p) - 1;
}
}
/// <summary>
/// Modeled after the cubic y = x^3
/// </summary>
static public float CubicEaseIn(float p)
{
return p * p * p;
}
/// <summary>
/// Modeled after the cubic y = (x - 1)^3 + 1
/// </summary>
static public float CubicEaseOut(float p)
{
float f = (p - 1);
return f * f * f + 1;
}
/// <summary>
/// Modeled after the piecewise cubic
/// y = (1/2)((2x)^3) ; [0, 0.5)
/// y = (1/2)((2x-2)^3 + 2) ; [0.5, 1]
/// </summary>
static public float CubicEaseInOut(float p)
{
if(p < 0.5f)
{
return 4 * p * p * p;
}
else
{
float f = ((2 * p) - 2);
return 0.5f * f * f * f + 1;
}
}
/// <summary>
/// Modeled after the quartic x^4
/// </summary>
static public float QuarticEaseIn(float p)
{
return p * p * p * p;
}
/// <summary>
/// Modeled after the quartic y = 1 - (x - 1)^4
/// </summary>
static public float QuarticEaseOut(float p)
{
float f = (p - 1);
return f * f * f * (1 - p) + 1;
}
/// <summary>
// Modeled after the piecewise quartic
// y = (1/2)((2x)^4) ; [0, 0.5)
// y = -(1/2)((2x-2)^4 - 2) ; [0.5, 1]
/// </summary>
static public float QuarticEaseInOut(float p)
{
if(p < 0.5f)
{
return 8 * p * p * p * p;
}
else
{
float f = (p - 1);
return -8 * f * f * f * f + 1;
}
}
/// <summary>
/// Modeled after the quintic y = x^5
/// </summary>
static public float QuinticEaseIn(float p)
{
return p * p * p * p * p;
}
/// <summary>
/// Modeled after the quintic y = (x - 1)^5 + 1
/// </summary>
static public float QuinticEaseOut(float p)
{
float f = (p - 1);
return f * f * f * f * f + 1;
}
/// <summary>
/// Modeled after the piecewise quintic
/// y = (1/2)((2x)^5) ; [0, 0.5)
/// y = (1/2)((2x-2)^5 + 2) ; [0.5, 1]
/// </summary>
static public float QuinticEaseInOut(float p)
{
if(p < 0.5f)
{
return 16 * p * p * p * p * p;
}
else
{
float f = ((2 * p) - 2);
return 0.5f * f * f * f * f * f + 1;
}
}
/// <summary>
/// Modeled after quarter-cycle of sine wave
/// </summary>
static public float SineEaseIn(float p)
{
return (float)(float)Math.Sin((p - 1) * HALFPI) + 1;
}
/// <summary>
/// Modeled after quarter-cycle of sine wave (different phase)
/// </summary>
static public float SineEaseOut(float p)
{
return (float)(float)Math.Sin(p * HALFPI);
}
/// <summary>
/// Modeled after half sine wave
/// </summary>
static public float SineEaseInOut(float p)
{
return 0.5f * (1 - (float)(float)Math.Cos(p * PI));
}
/// <summary>
/// Modeled after shifted quadrant IV of unit circle
/// </summary>
static public float CircularEaseIn(float p)
{
return 1 - (float)Math.Sqrt(1 - (p * p));
}
/// <summary>
/// Modeled after shifted quadrant II of unit circle
/// </summary>
static public float CircularEaseOut(float p)
{
return (float)Math.Sqrt((2 - p) * p);
}
/// <summary>
/// Modeled after the piecewise circular function
/// y = (1/2)(1 - (float)Math.Sqrt(1 - 4x^2)) ; [0, 0.5)
/// y = (1/2)((float)Math.Sqrt(-(2x - 3)*(2x - 1)) + 1) ; [0.5, 1]
/// </summary>
static public float CircularEaseInOut(float p)
{
if(p < 0.5f)
{
return 0.5f * (1 - (float)Math.Sqrt(1 - 4 * (p * p)));
}
else
{
return 0.5f * ((float)Math.Sqrt(-((2 * p) - 3) * ((2 * p) - 1)) + 1);
}
}
/// <summary>
/// Modeled after the exponential function y = 2^(10(x - 1))
/// </summary>
static public float ExponentialEaseIn(float p)
{
return (p == 0.0f) ? p : (float)Math.Pow(2, 10 * (p - 1));
}
/// <summary>
/// Modeled after the exponential function y = -2^(-10x) + 1
/// </summary>
static public float ExponentialEaseOut(float p)
{
return (p == 1.0f) ? p : 1 - (float)Math.Pow(2, -10 * p);
}
/// <summary>
/// Modeled after the piecewise exponential
/// y = (1/2)2^(10(2x - 1)) ; [0,0.5)
/// y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1]
/// </summary>
static public float ExponentialEaseInOut(float p)
{
if(p == 0.0 || p == 1.0) return p;
if(p < 0.5f)
{
return 0.5f * (float)Math.Pow(2, (20 * p) - 10);
}
else
{
return -0.5f * (float)Math.Pow(2, (-20 * p) + 10) + 1;
}
}
/// <summary>
/// Modeled after the damped sine wave y = sin(13pi/2*x)*(float)Math.Pow(2, 10 * (x - 1))
/// </summary>
static public float ElasticEaseIn(float p)
{
return (float)Math.Sin(13 * HALFPI * p) * (float)Math.Pow(2, 10 * (p - 1));
}
/// <summary>
/// Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*(float)Math.Pow(2, -10x) + 1
/// </summary>
static public float ElasticEaseOut(float p)
{
return (float)Math.Sin(-13 * HALFPI * (p + 1)) * (float)Math.Pow(2, -10 * p) + 1;
}
/// <summary>
/// Modeled after the piecewise exponentially-damped sine wave:
/// y = (1/2)*sin(13pi/2*(2*x))*(float)Math.Pow(2, 10 * ((2*x) - 1)) ; [0,0.5)
/// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*(float)Math.Pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
/// </summary>
static public float ElasticEaseInOut(float p)
{
if(p < 0.5f)
{
return 0.5f * (float)Math.Sin(13 * HALFPI * (2 * p)) * (float)Math.Pow(2, 10 * ((2 * p) - 1));
}
else
{
return 0.5f * ((float)Math.Sin(-13 * HALFPI * ((2 * p - 1) + 1)) * (float)Math.Pow(2, -10 * (2 * p - 1)) + 2);
}
}
/// <summary>
/// Modeled after the overshooting cubic y = x^3-x*sin(x*pi)
/// </summary>
static public float BackEaseIn(float p)
{
return p * p * p - p * (float)Math.Sin(p * PI);
}
/// <summary>
/// Modeled after overshooting cubic y = 1-((1-x)^3-(1-x)*sin((1-x)*pi))
/// </summary>
static public float BackEaseOut(float p)
{
float f = (1 - p);
return 1 - (f * f * f - f * (float)Math.Sin(f * PI));
}
/// <summary>
/// Modeled after the piecewise overshooting cubic function:
/// y = (1/2)*((2x)^3-(2x)*sin(2*x*pi)) ; [0, 0.5)
/// y = (1/2)*(1-((1-x)^3-(1-x)*sin((1-x)*pi))+1) ; [0.5, 1]
/// </summary>
static public float BackEaseInOut(float p)
{
if(p < 0.5f)
{
float f = 2 * p;
return 0.5f * (f * f * f - f * (float)Math.Sin(f * PI));
}
else
{
float f = (1 - (2*p - 1));
return 0.5f * (1 - (f * f * f - f * (float)Math.Sin(f * PI))) + 0.5f;
}
}
/// <summary>
/// </summary>
static public float BounceEaseIn(float p)
{
return 1 - BounceEaseOut(1 - p);
}
/// <summary>
/// </summary>
static public float BounceEaseOut(float p)
{
if(p < 4/11.0f)
{
return (121 * p * p)/16.0f;
}
else if(p < 8/11.0f)
{
return (363/40.0f * p * p) - (99/10.0f * p) + 17/5.0f;
}
else if(p < 9/10.0f)
{
return (4356/361.0f * p * p) - (35442/1805.0f * p) + 16061/1805.0f;
}
else
{
return (54/5.0f * p * p) - (513/25.0f * p) + 268/25.0f;
}
}
/// <summary>
/// </summary>
static public float BounceEaseInOut(float p)
{
if(p < 0.5f)
{
return 0.5f * BounceEaseIn(p*2);
}
else
{
return 0.5f * BounceEaseOut(p * 2 - 1) + 0.5f;
}
}
}

View file

@ -27,10 +27,11 @@ namespace Sledgemapper.Shared.Entities
Overlays = new ConcurrentDictionary<string, Overlay>();
Walls = new ConcurrentDictionary<string, Wall>();
Notes = new ConcurrentDictionary<string, Note>();
Lines=new ConcurrentDictionary<string, Line>();
Rooms=new ConcurrentDictionary<string, Room>();
Lines = new ConcurrentDictionary<string, Line>();
Rooms = new ConcurrentDictionary<string, Room>();
Players = new List<Player>();
Colors = new List<string>();
Pings = new ConcurrentDictionary<Guid, Ping>();
}
public ConcurrentDictionary<string, Tile> Map { get; set; }
@ -39,189 +40,190 @@ namespace Sledgemapper.Shared.Entities
public ConcurrentDictionary<string, Note> Notes { get; set; }
public bool IsValid { get; set; }
public List<Player> Players { get; set; }
public List<string> Colors { get; set; }
public string SessionName { get; set; }
public int SessionId { get; set; }
public ConcurrentDictionary<string, Line> Lines { get; set; }
public ConcurrentDictionary<string, Room> Rooms { get; set; }
public ConcurrentDictionary<Guid, Ping> Pings { get; set; }
public List<string> Colors { get; set; }
public string SessionName { get; set; }
public int SessionId { get; set; }
public ConcurrentDictionary<string, Line> Lines { get; set; }
public ConcurrentDictionary<string, Room> Rooms { get; set; }
public void NewTile(Tile selectedTile, string tileId)
public void NewTile(Tile selectedTile, string tileId)
{
if (selectedTile is null || string.IsNullOrWhiteSpace(tileId))
{
if (selectedTile is null || string.IsNullOrWhiteSpace(tileId))
{
return;
}
var tileExist = Map.TryGetValue(selectedTile.ToString(), out var tile);
var newTile = new Tile { X = selectedTile.X, Y = selectedTile.Y, ID = tileId };
if (tileExist)
{
Map.TryRemove(tile.ToString(), out var _);
if (tile.ID == tileId)
{
newTile.Rotation = (tile.Rotation + 1) % 4;
}
}
Map.TryAdd(newTile.ToString(), newTile);
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newTile));
return;
}
public void NewOverlay(Overlay selectedOverlay, string overlayId)
var tileExist = Map.TryGetValue(selectedTile.ToString(), out var tile);
var newTile = new Tile { X = selectedTile.X, Y = selectedTile.Y, ID = tileId };
if (tileExist)
{
if (selectedOverlay is null || string.IsNullOrWhiteSpace(overlayId))
Map.TryRemove(tile.ToString(), out var _);
if (tile.ID == tileId)
{
return;
}
var overlayExist = Overlays.TryGetValue(selectedOverlay.ToString(), out var overlay);
var newOverlay = new Overlay { X = selectedOverlay.X, Y = selectedOverlay.Y, ID = overlayId, Intersection = selectedOverlay.Intersection };
if (overlayExist)
{
Overlays.TryRemove(overlay.ToString(), out var _);
if (overlay.ID == overlayId)
{
newOverlay.Rotation = (overlay.Rotation + 1) % 4;
}
}
Overlays.TryAdd(newOverlay.ToString(), newOverlay);
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newOverlay));
}
public void NewWall(Wall selectedWall, string wallId)
{
if (selectedWall is null || string.IsNullOrWhiteSpace(wallId))
{
return;
}
var tileExist = Walls.TryGetValue(selectedWall.ToString(), out var wall);
var newWall = new Wall { X = selectedWall.X, Y = selectedWall.Y, ID = wallId, Rotation = selectedWall.Rotation };
if (tileExist)
{
Walls.TryRemove(wall.ToString(), out var _);
}
Walls.TryAdd(newWall.ToString(), newWall);
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newWall));
}
public void NewNote(Note selectedNote)
{
if (selectedNote is null)
{
return;
}
var noteExists = Notes.TryGetValue(selectedNote.ToString(), out var note);
var newNote = new Note { X = selectedNote.X, Y = selectedNote.Y, Text=selectedNote.Text };
if (noteExists)
{
Walls.TryRemove(note.ToString(), out var _);
}
Notes.TryAdd(newNote.ToString(), newNote);
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newNote));
}
public void DeleteWall(Wall wall)
{
if (wall is null)
{
return;
}
var removed = Walls.TryRemove(wall.ToString(), out var _);
if (removed)
{
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(wall));
newTile.Rotation = (tile.Rotation + 1) % 4;
}
}
public void DeleteNote(Note note)
Map.TryAdd(newTile.ToString(), newTile);
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newTile));
}
public void NewOverlay(Overlay selectedOverlay, string overlayId)
{
if (selectedOverlay is null || string.IsNullOrWhiteSpace(overlayId))
{
if (note is null)
return;
}
var overlayExist = Overlays.TryGetValue(selectedOverlay.ToString(), out var overlay);
var newOverlay = new Overlay { X = selectedOverlay.X, Y = selectedOverlay.Y, ID = overlayId, Intersection = selectedOverlay.Intersection };
if (overlayExist)
{
Overlays.TryRemove(overlay.ToString(), out var _);
if (overlay.ID == overlayId)
{
return;
}
var removed = Notes.TryRemove(note.ToString(), out var _);
if (removed)
{
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(note));
newOverlay.Rotation = (overlay.Rotation + 1) % 4;
}
}
public void DeleteOverlay(Overlay overlay)
Overlays.TryAdd(newOverlay.ToString(), newOverlay);
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newOverlay));
}
public void NewWall(Wall selectedWall, string wallId)
{
if (selectedWall is null || string.IsNullOrWhiteSpace(wallId))
{
if (overlay is null)
{
return;
}
var removed = Overlays.TryRemove(overlay.ToString(), out var _);
if (removed)
{
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(overlay));
}
return;
}
var tileExist = Walls.TryGetValue(selectedWall.ToString(), out var wall);
var newWall = new Wall { X = selectedWall.X, Y = selectedWall.Y, ID = wallId, Rotation = selectedWall.Rotation };
if (tileExist)
{
Walls.TryRemove(wall.ToString(), out var _);
}
public void DeleteTile(Tile tile)
Walls.TryAdd(newWall.ToString(), newWall);
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newWall));
}
public void NewNote(Note selectedNote)
{
if (selectedNote is null)
{
if (tile is null)
{
return;
}
var removed = Map.TryRemove(tile.ToString(), out var _);
if (removed)
{
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(tile));
}
return;
}
var noteExists = Notes.TryGetValue(selectedNote.ToString(), out var note);
var newNote = new Note { X = selectedNote.X, Y = selectedNote.Y, Text = selectedNote.Text };
if (noteExists)
{
Walls.TryRemove(note.ToString(), out var _);
}
protected virtual void OnRaiseMapEntityAddedEvent(MapEntityAddedEventArgs e)
Notes.TryAdd(newNote.ToString(), newNote);
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newNote));
}
public void DeleteWall(Wall wall)
{
if (wall is null)
{
MapEntityAdded?.Invoke(this, e);
return;
}
protected virtual void OnRaiseMapEntityDeletedEvent(MapEntityDeletedEventArgs e)
var removed = Walls.TryRemove(wall.ToString(), out var _);
if (removed)
{
MapEntityDeleted?.Invoke(this, e);
}
public void NewLine(Line line)
{
if (line is null)
{
return;
}
var lineExist = Lines.TryGetValue(line.ToString(), out var tile);
var newLine = new Line { Start=line.Start, End=line.End, Width=line.Width};
if (lineExist)
{
Lines.TryRemove(line.ToString(), out var _);
}
Lines.TryAdd(newLine.ToString(), newLine);
//TODO fix this
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newLine));
}
public void NewRoom(Room line)
{
if (line is null)
{
return;
}
var lineExist = Rooms.TryGetValue(line.ToString(), out var tile);
var newLine = new Room { Start=line.Start, End=line.End, Delete=line.Delete};
if (lineExist)
{
Rooms.TryRemove(line.ToString(), out var _);
}
Rooms.TryAdd(newLine.ToString(), newLine);
//TODO fix this
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newLine));
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(wall));
}
}
public void DeleteNote(Note note)
{
if (note is null)
{
return;
}
var removed = Notes.TryRemove(note.ToString(), out var _);
if (removed)
{
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(note));
}
}
public void DeleteOverlay(Overlay overlay)
{
if (overlay is null)
{
return;
}
var removed = Overlays.TryRemove(overlay.ToString(), out var _);
if (removed)
{
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(overlay));
}
}
public void DeleteTile(Tile tile)
{
if (tile is null)
{
return;
}
var removed = Map.TryRemove(tile.ToString(), out var _);
if (removed)
{
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(tile));
}
}
protected virtual void OnRaiseMapEntityAddedEvent(MapEntityAddedEventArgs e)
{
MapEntityAdded?.Invoke(this, e);
}
protected virtual void OnRaiseMapEntityDeletedEvent(MapEntityDeletedEventArgs e)
{
MapEntityDeleted?.Invoke(this, e);
}
public void NewLine(Line line)
{
if (line is null)
{
return;
}
var lineExist = Lines.TryGetValue(line.ToString(), out var tile);
var newLine = new Line { Start = line.Start, End = line.End, Width = line.Width };
if (lineExist)
{
Lines.TryRemove(line.ToString(), out var _);
}
Lines.TryAdd(newLine.ToString(), newLine);
//TODO fix this
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newLine));
}
public void NewRoom(Room line)
{
if (line is null)
{
return;
}
var lineExist = Rooms.TryGetValue(line.ToString(), out var tile);
var newLine = new Room { Start = line.Start, End = line.End, Delete = line.Delete };
if (lineExist)
{
Rooms.TryRemove(line.ToString(), out var _);
}
Rooms.TryAdd(newLine.ToString(), newLine);
//TODO fix this
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newLine));
}
}
}

View file

@ -1,4 +1,5 @@
using System;
using System.Security.Cryptography;
namespace Sledgemapper.Shared.Entities
{
@ -20,8 +21,73 @@ namespace Sledgemapper.Shared.Entities
public double Timestamp { get; set; }
}
public class Ping : BaseMapEntity
{
public Player Player { get; set; }
public int Iterations {get;set;}
public double StartTime {get;set;}
}
public class Tile : BaseMapEntity
{
public bool Equals(Tile other)
{
if (other == null) return false;
return (X == other.X && Y == other.Y);
}
public static bool operator ==(Tile a, Tile b)
{
// If both are null, or both are same instance, return true.
if (System.Object.ReferenceEquals(a, b))
{
return true;
}
// If one is null, but not both, return false.
if (((object)a == null) || ((object)b == null))
{
return false;
}
// Return true if the fields match:
return a.X == b.X && a.Y == b.Y;
}
public static bool operator !=(Tile a, Tile b)
{
return !(a == b);
}
public override bool Equals(object obj)
{
//
// See the full list of guidelines at
// http://go.microsoft.com/fwlink/?LinkID=85237
// and also the guidance for operator== at
// http://go.microsoft.com/fwlink/?LinkId=85238
//
if (obj == null || GetType() != obj.GetType())
{
return false;
}
return Equals(obj as Tile);
}
// override object.GetHashCode
public override int GetHashCode()
{
unchecked
{
int hash = 13;
hash = (hash * 7) + X + Y;
return hash;
}
}
}
public class Line : BaseMapEntity

View file

@ -1,11 +1,10 @@
namespace Sledgemapper.Shared.Entities
{
public class Wall :BaseMapEntity
public class Wall : BaseMapEntity
{
public override string ToString()
{
return $"{X}_{Y}_{Rotation}";
}
}
}

View file

@ -155,6 +155,11 @@ namespace Sledgemapper
p.Position = player.Position;
}
});
Connection.On<Ping>("Ping", (ping) =>
{
SessionData.Pings.TryAdd(Guid.NewGuid(), ping);
});
}
private Task<string> GetToken()
@ -233,6 +238,14 @@ namespace Sledgemapper
}
}
internal async Task Ping(Tile location)
{
if (Connection!=null && Connection.State == HubConnectionState.Connected)
{
await Connection.InvokeAsync("Ping",SessionData.SessionName, location);
}
}
}
class AuthenticatedHttpClientHandler : HttpClientHandler

View file

@ -93,6 +93,23 @@
/processorParam:TextureFormat=Compressed
/build:fonts/font99.spritefont
#begin handcursors
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:handcursors
#begin handcursorsIndex
/importer:XmlImporter
/processor:
/build:handcursorsIndex
#begin icon_delete.png
/importer:TextureImporter
/processor:TextureProcessor
@ -141,6 +158,23 @@
/processorParam:TextureFormat=Color
/build:location.png
#begin rippleSpriteIndex
/importer:XmlImporter
/processor:PassThroughProcessor
/build:rippleSpriteIndex
#begin rippleSpriteMap
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:rippleSpriteMap
#begin shaders/OutlineShader.fx
/importer:EffectImporter
/processor:EffectProcessor
@ -428,3 +462,75 @@
/processorParam:TextureFormat=Color
/build:walls/wall05.png
#begin walls/wall06.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:walls/wall06.png
#begin walls/wall07.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:walls/wall07.png
#begin walls/wall08.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:walls/wall08.png
#begin walls/wall09.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:walls/wall09.png
#begin walls/wall10.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:walls/wall10.png
#begin walls/wall11.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:walls/wall11.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<Asset Type="System.Collections.Generic.Dictionary[System.String, Microsoft.Xna.Framework.Rectangle]">
<Item><Key>handcursor_00</Key><Value>0 0 60 60</Value></Item>
<Item><Key>handcursor_01</Key><Value>61 0 60 60</Value></Item>
</Asset>
</XnaContent>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<Asset Type="System.Collections.Generic.Dictionary[System.String, Microsoft.Xna.Framework.Rectangle]">
<Item><Key>ripple_00</Key><Value>0 0 128 128</Value></Item>
<Item><Key>ripple_01</Key><Value>129 0 128 128</Value></Item>
<Item><Key>ripple_02</Key><Value>258 0 128 128</Value></Item>
<Item><Key>ripple_03</Key><Value>0 129 128 128</Value></Item>
<Item><Key>ripple_04</Key><Value>129 129 128 128</Value></Item>
<Item><Key>ripple_05</Key><Value>0 258 128 128</Value></Item>
<Item><Key>ripple_06</Key><Value>129 258 128 128</Value></Item>
<Item><Key>ripple_07</Key><Value>258 129 128 128</Value></Item>
<Item><Key>ripple_08</Key><Value>258 258 128 128</Value></Item>
<Item><Key>ripple_09</Key><Value>387 0 128 128</Value></Item>
<Item><Key>ripple_10</Key><Value>387 129 128 128</Value></Item>
<Item><Key>ripple_11</Key><Value>516 0 128 128</Value></Item>
<Item><Key>ripple_12</Key><Value>387 258 128 128</Value></Item>
<Item><Key>ripple_13</Key><Value>516 129 128 128</Value></Item>
<Item><Key>ripple_14</Key><Value>645 0 128 128</Value></Item>
<Item><Key>ripple_15</Key><Value>774 0 128 128</Value></Item>
<Item><Key>ripple_16</Key><Value>645 129 128 128</Value></Item>
<Item><Key>ripple_17</Key><Value>516 258 128 128</Value></Item>
<Item><Key>ripple_18</Key><Value>645 258 128 128</Value></Item>
</Asset>
</XnaContent>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 986 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 B

After

Width:  |  Height:  |  Size: 4.7 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -12,6 +12,7 @@ namespace Sledgemapper
public Color NoteColor { get; set; }
public string MachineName { get; set; }
public int TileDeleteDivider { get; set; }
public int PingDuration {get;set;}
public Settings()
{
@ -19,7 +20,8 @@ namespace Sledgemapper
GridColor = Color.Black;
NoteColor = Color.DarkRed;
OverlayTintColor = new Color(24, 118, 157);
TileDeleteDivider=14;
TileDeleteDivider = 14;
PingDuration = 4000;
try
{
MachineName = Environment.MachineName;

View file

@ -6,12 +6,14 @@ using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MonoGame.Extended;
using MonoGame.Extended.VectorDraw;
using Myra;
using Myra.Graphics2D.Brushes;
using Myra.Graphics2D.TextureAtlases;
using Myra.Graphics2D.UI;
using Myra.Graphics2D.UI.File;
using Myra.Graphics2D.UI.Properties;
using Myra.Utility;
using Newtonsoft.Json;
using Sledgemapper.Shared.Entities;
using Sledgemapper.UI;
@ -23,6 +25,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AsyncAwaitBestPractices;
namespace Sledgemapper
{
@ -147,14 +150,18 @@ namespace Sledgemapper
}
}
private void AddItemToToolGrid(Grid grid, EventHandler eventAction, SpriteSheet spriteSheet)
private void AddItemToToolGrid(Grid grid, EventHandler eventAction, SpriteSheet spriteSheet, string e = "")
{
var indexX = 0;
var indexY = 0;
foreach (var item in spriteSheet.index)
grid.Widgets.Clear();
_mainWidget.ScrOverlay.ResetScroll();
foreach (var item in spriteSheet.index.Where(t => String.IsNullOrWhiteSpace(e) || t.Key.ToLower().Contains(e.ToLower())))
{
var tileButton = new ImageButton { Image = new TextureRegion(spriteSheet.Texture, item.Value), GridColumn = indexY, GridRow = indexX, Id = item.Key, Width = 40, Height = 40 };
tileButton.Click += eventAction;
tileButton.MouseMoved += OnTileButtonTouchEntered;
tileButton.MouseLeft += OnTileButtonTouchLeft;
grid.Widgets.Add(tileButton);
indexY++;
if (indexY == 4)
@ -165,6 +172,25 @@ namespace Sledgemapper
}
}
private void OnTileButtonTouchLeft(object sender, EventArgs e)
{
_desktop.HideContextMenu();
_lblOverlayName.Visible = false;
}
private SpriteSheet _rippleSpriteSheet;
Label _lblOverlayName;
private void OnTileButtonTouchEntered(object sender, EventArgs e)
{
var mouseState = Mouse.GetState().Position;
mouseState.X += 10;
mouseState.Y += 10;
_lblOverlayName.Visible = true;
_lblOverlayName.Text = ((ImageButton)sender).Id;
_desktop.ShowContextMenu(_lblOverlayName, mouseState);
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
@ -191,16 +217,18 @@ namespace Sledgemapper
_mainWidget.MenuConnectUpload.Enabled = false;
_mainWidget.BtnToolbarLine.Click += OnBtnToolbarLinClicked;
_mainWidget.BtnToolbarRoom.Click += OnBtnToolbarRoomClicked;
_mainWidget.BtnToolbarTile.Click += OnBtnToolbarTileClicked;
_mainWidget.BtnToolbarWall.Click += OnBtnToolbarWallClicked;
_mainWidget.BtnToolbarDelete.Click += OnBtnToolbarDeleteClicked;
_mainWidget.BtnToolbarTile.Visible = false;
_mainWidget.BtnToolbarWall.Visible = false;
_wallsContent = Content.LoadContentFolder<Texture2D>("walls");
_spriteSheet = new SpriteSheet();
_spriteSheet.LoadContent(Content);
_spriteSheet.LoadContent(Content, "spriteIndex", "sprites");
_rippleSpriteSheet = new SpriteSheet();
_rippleSpriteSheet.LoadContent(Content, "handcursorsIndex", "handcursors");
_lblOverlayName = new Label();
_lblOverlayName.Background = new SolidBrush(Color.SlateGray);
_lblOverlayName.Padding = new Myra.Graphics2D.Thickness(4);
AddItemToToolGrid(_mainWidget.GridWalls, OnWallButtonClicked, _wallsContent);
AddItemToToolGrid(_mainWidget.GridOverlays, OnOverlayButtonClicked, _spriteSheet);
@ -212,6 +240,8 @@ namespace Sledgemapper
_mainWidget.BtnToolbarLine.Image = new TextureRegion(Content.Load<Texture2D>("icon_line"));
_mainWidget.BtnToolbarRoom.Image = new TextureRegion(Content.Load<Texture2D>("icon_room"));
_mainWidget.BtnToolbarDelete.Image = new TextureRegion(Content.Load<Texture2D>("icon_delete"));
_mainWidget.TxtOverlaySearch.TextChangedByUser += OnTxtOverlaySearchChange;
_desktop.Root = _mainWidget;
_transparentRedRectangle = new Texture2D(GraphicsDevice, 1, 1);
@ -221,30 +251,51 @@ namespace Sledgemapper
_whiteRectangle.SetData(new[] { Color.White });
}
private void OnTxtOverlaySearchChange(object sender, ValueChangedEventArgs<string> e)
{
AddItemToToolGrid(_mainWidget.GridOverlays, OnOverlayButtonClicked, _spriteSheet, e.NewValue);
}
private void OnBtnToolbarDeleteClicked(object sender, EventArgs e)
{
_state.InsertMode = InsertMode.NewDelete;
_mainWidget.ClearSelection();
((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
}
private void OnBtnToolbarWallClicked(object sender, EventArgs e)
{
_state.InsertMode = InsertMode.NewWall;
_mainWidget.ClearSelection();
((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
}
private void OnBtnToolbarTileClicked(object sender, EventArgs e)
{
_state.InsertMode = InsertMode.NewTile;
_mainWidget.ClearSelection();
((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
}
private void OnBtnToolbarRoomClicked(object sender, EventArgs e)
{
_state.InsertMode = InsertMode.NewRoom;
_mainWidget.ClearSelection();
((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
}
private void OnBtnToolbarLinClicked(object sender, EventArgs e)
{
_state.InsertMode = InsertMode.NewLine;
_mainWidget.ClearSelection();
((ImageTextButton)sender).Border = new SolidBrush(Color.Red);
((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
}
private void OneMenuFileSettingsSelected(object sender, EventArgs e)
@ -389,6 +440,8 @@ namespace Sledgemapper
var newNoteButton = new TextButton { Text = "New Note", Width = 80, Height = 20, Padding = new Myra.Graphics2D.Thickness(2), HorizontalAlignment = HorizontalAlignment.Left };
newNoteButton.Click += OnContextMenuNewNoteClick;
popup.AddChild(newNoteButton);
}
else
{
@ -403,6 +456,11 @@ namespace Sledgemapper
popup.AddChild(deleteNoteButton);
}
var pingButton = new TextButton { Text = "Ping", Width = 80, Height = 20, Padding = new Myra.Graphics2D.Thickness(2), HorizontalAlignment = HorizontalAlignment.Left };
var location = new Tile { X = _state.HoveredTile.X, Y = _state.HoveredTile.Y };
pingButton.Click += (s, e) => OnContextMenuPingClick(s, e, location);
popup.AddChild(pingButton);
_desktop.ShowContextMenu(popup, mouseState.Position);
}
@ -559,6 +617,11 @@ namespace Sledgemapper
}
}
if (oldState.IsKeyDown(Keys.P) && newState.IsKeyUp(Keys.P))
{
_communicationManager.Ping(_state.HoveredTile).SafeFireAndForget();
}
foreach (var key in newState.GetPressedKeys())
{
switch (key)
@ -610,10 +673,17 @@ namespace Sledgemapper
var center = new Point((Window.ClientBounds.Width + 200) / 2 - _state.TileSize / 2, Window.ClientBounds.Height / 2 - _state.TileSize / 2);
var dx = center.X - x * _state.TileSize - _viewportCenter.X;
var dy = center.Y - y * _state.TileSize - _viewportCenter.Y;
_viewportCenter.X += dx;
_viewportCenter.Y += dy;
}
private void OnContextMenuPingClick(object sender, EventArgs e, Tile location)
{
_desktop.HideContextMenu();
_communicationManager.Ping(location).SafeFireAndForget();
}
protected override void Draw(GameTime gameTime)
{
if (_spriteBatch is null)
@ -628,7 +698,7 @@ namespace Sledgemapper
_spriteBatch.Begin(
transformMatrix: Matrix.CreateTranslation(_viewportCenter),
sortMode: SpriteSortMode.Texture);
sortMode: SpriteSortMode.Texture, samplerState: SamplerState.PointClamp);
DrawTiles();
@ -654,6 +724,8 @@ namespace Sledgemapper
_spriteBatch.End();
DrawRipple(gameTime);
try
{
_desktop?.Render();
@ -665,6 +737,81 @@ namespace Sledgemapper
base.Draw(gameTime);
}
private void DrawRipple(GameTime gameTime)
{
_spriteBatch.Begin(
blendState: BlendState.NonPremultiplied,
transformMatrix: Matrix.CreateTranslation(_viewportCenter));
var durationMs = 2000;
var baseRadius = _state.TileSize / 4f;
var baseOuterRadius = (float)_state.TileSize;
var iterations = 3f;
var guids = _sessionData.Pings.Keys.ToArray();
foreach (var guid in guids)
{
var pingFound = _sessionData.Pings.TryGetValue(guid, out var ping);
if (!pingFound)
{
continue;
}
if (ping.StartTime == 0)
{
ping.StartTime = gameTime.TotalGameTime.TotalMilliseconds;
}
var x = ping.X * _state.TileSize + _state.TileSize / 2f;
var y = ping.Y * _state.TileSize + _state.TileSize / 2f;
if (IsOffscreen(new Tile { X = ping.X, Y = ping.Y }))
{
DrawPingPointer(ping, gameTime);
}
else
{
_spriteBatch.DrawCircle(
center: new Vector2(x, y),
radius: baseRadius,
sides: 20,
color: ping.Player.Color.ToColor(),
thickness: baseRadius);
for (var i = 0; i < iterations; i++)
{
var cycleTime = (((float)gameTime.TotalGameTime.TotalMilliseconds + (float)i * durationMs / iterations) % durationMs) / durationMs;
var easing = Easings.Interpolate(cycleTime, Easings.Functions.SineEaseInOut);
_spriteBatch.DrawCircle(
center: new Vector2(x, y),
radius: baseRadius + baseOuterRadius * easing,
sides: 20,
color: new Color(ping.Player.Color.ToColor(), (1 - easing)),
thickness: 2 + 5 * (1 - easing));
}
}
}
foreach (var guid in guids)
{
var pingFound = _sessionData.Pings.TryGetValue(guid, out var ping);
if (!pingFound)
{
continue;
}
if ((gameTime.TotalGameTime.TotalMilliseconds - ping.StartTime) > _settings.PingDuration)
{
_sessionData.Pings.TryRemove(guid, out var _);
}
}
_spriteBatch.End();
}
private void DrawRoomPreview()
{
if ((_state.InsertMode == InsertMode.NewRoom || _state.InsertMode == InsertMode.NewDelete) && _state.SelectedSnapPoint != null)
@ -736,25 +883,94 @@ namespace Sledgemapper
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);
}
}
}
@ -863,88 +1079,16 @@ namespace Sledgemapper
var isoffscreen = IsOffscreen(_state.SelectedTile);
if (isoffscreen)
{
var center = new Point((Window.ClientBounds.Width + 200) / 2 - (int)_viewportCenter.X, Window.ClientBounds.Height / 2 - (int)_viewportCenter.Y);
var cx = center.X / _state.TileSize;
var cy = center.Y / _state.TileSize;
var p1 = new Vector2(cx * _state.TileSize, cy * _state.TileSize);
var p2 = new Vector2(_state.SelectedTile.X * _state.TileSize, _state.SelectedTile.Y * _state.TileSize);
var p3 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, 0 - _viewportCenter.Y);
var p4 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y);
var ua1 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
p3 = new Vector2(200 - _viewportCenter.X, 0 - _viewportCenter.Y);
p4 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, 0 - _viewportCenter.Y);
var ua2 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
p3 = new Vector2(200 - _viewportCenter.X, 0 - _viewportCenter.Y);
p4 = new Vector2(200 - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y);
var ua3 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
p3 = new Vector2(200 - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y);
p4 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y);
var ua4 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
var uas = new float[] { ua1, ua2, ua3, ua4 };
if (uas.Any(u => u > 0 && u < 1))
var validPointer = GetPointerVector(new Point(_state.SelectedTile.X, _state.SelectedTile.Y), out var points);
if (validPointer)
{
var ua = uas.Where(u => u > 0 && u < 1).Min();
int i = 0;
for (var j = 0; j < 4; j++)
{
if (uas[j] == ua)
{
i = j;
}
}
var x = (p1.X + ua * (p2.X - p1.X));
var y = (p1.Y + ua * (p2.Y - p1.Y));
var v = _vector2Pool.Rent(4);
switch (i)
{
case 0:
v[0] = new Vector2(x, y);
v[1] = new Vector2(x - 20, y + 10);
v[2] = new Vector2(x - 20, y - 10);
v[3] = new Vector2(x, y);
break;
case 1:
v[0] = new Vector2(x, y);
v[1] = new Vector2(x - 10, y + 20);
v[2] = new Vector2(x + 10, y + 20);
v[3] = new Vector2(x, y);
y += 20;
break;
case 2:
x += 0;
v[0] = new Vector2(x, y);
v[1] = new Vector2(x + 20, y + 10);
v[2] = new Vector2(x + 20, y - 10);
v[3] = new Vector2(x, y);
break;
case 3:
y -= 20;
v[0] = new Vector2(x, y);
v[1] = new Vector2(x - 10, y - 20);
v[2] = new Vector2(x + 10, y - 20);
v[3] = new Vector2(x, y);
break;
}
_spriteBatch.DrawPolygon(Vector2.Zero, v, Color.Red, 2);
_vector2Pool.Return(v);
_spriteBatch.DrawPolygon(Vector2.Zero, points, Color.Red, 2);
}
}
_spriteBatch.DrawRectangle(new Rectangle((_state.SelectedTile.X * _state.TileSize) - 2, (_state.SelectedTile.Y * _state.TileSize) - 2, _state.TileSize + 3, _state.TileSize + 3), Color.Red, 2);
else
{
_spriteBatch.DrawRectangle(new Rectangle((_state.SelectedTile.X * _state.TileSize) - 2, (_state.SelectedTile.Y * _state.TileSize) - 2, _state.TileSize + 3, _state.TileSize + 3), Color.Red, 2);
}
}
}
@ -1011,22 +1155,22 @@ namespace Sledgemapper
private bool IsMapElementOffscreen(BaseMapEntity item)
{
SnapPoint start,end;
SnapPoint start, end;
switch (item)
{
case Line l:
start=l.Start;
end=l.End;
break;
switch (item)
{
case Line l:
start = l.Start;
end = l.End;
break;
case Room room:
start = room.Start;
end=room.End;
break;
default:
return true;
}
case Room room:
start = room.Start;
end = room.End;
break;
default:
return true;
}
var visibleTilesX = GraphicsDevice.Viewport.Width / _state.TileSize + 1;
var visibleTilesY = GraphicsDevice.Viewport.Height / _state.TileSize + 1;
@ -1175,22 +1319,131 @@ namespace Sledgemapper
private void DrawPlayers()
{
for (int i = 0; i < _sessionData.Players.Count; i++)
var ffont = _fonts.FirstOrDefault(m => int.Parse(m.Key.Replace("font", "")) > _state.TileSize).Value ?? _fonts.Last().Value;
var fscale = _state.TileSize / ((float)ffont.LineSpacing * 3f);
var playerCells = _sessionData.Players.Select(m => m.Position).Distinct().ToList();
foreach (var cell in playerCells.Where(c => !IsOffscreen(c)))
{
Player player = _sessionData.Players[i];
var color = player.Color.ToColor();
_spriteBatch.DrawRectangle(new Rectangle(player.Position.X * _state.TileSize - 4, player.Position.Y * _state.TileSize - 4, _state.TileSize + 7, _state.TileSize + 7), color, 2);
var ffont = _fonts.FirstOrDefault(m => int.Parse(m.Key.Replace("font", "")) > _state.TileSize).Value ?? _fonts.Last().Value;
var fscale = _state.TileSize / ((float)ffont.LineSpacing * 2);
_spriteBatch.DrawString(ffont,
player.Initials,
new Vector2(player.Position.X * _state.TileSize + 2, player.Position.Y * _state.TileSize + _state.TileSize - 2 - ffont.LineSpacing * fscale),
color,
0,
Vector2.Zero,
fscale,
SpriteEffects.None,
0);
var playersInCell = _sessionData.Players.Where(m => m.Position == cell).ToList();
var i = 0;
foreach (var player in playersInCell)
{
var color = player.Color.ToColor();
var rectangle = new Rectangle();
var stringPosition = new Vector2();
var measure = ffont.MeasureString(player.Initials);
var maxSize = Math.Max(measure.X, measure.Y);
if (playersInCell.Count == 1)
{
fscale = (_state.TileSize - 2) / maxSize;
rectangle = new Rectangle(
player.Position.X * _state.TileSize,
player.Position.Y * _state.TileSize,
_state.TileSize - 1,
_state.TileSize - 1);
stringPosition = new Vector2(
player.Position.X * _state.TileSize + 1,
player.Position.Y * _state.TileSize + _state.TileSize - measure.Y * fscale);
}
else if (playersInCell.Count == 2)
{
fscale = (_state.TileSize / 2 - 2) / maxSize;
if (i == 0)
{
rectangle = new Rectangle(
player.Position.X * _state.TileSize,
player.Position.Y * _state.TileSize,
_state.TileSize / 2 - 1,
_state.TileSize - 1);
stringPosition = new Vector2(
player.Position.X * _state.TileSize + 1,
player.Position.Y * _state.TileSize + _state.TileSize - measure.Y * fscale);
}
else
{
rectangle = new Rectangle(
player.Position.X * _state.TileSize + _state.TileSize / 2,
player.Position.Y * _state.TileSize,
_state.TileSize / 2 - 1,
_state.TileSize - 1);
stringPosition = new Vector2(
player.Position.X * _state.TileSize + _state.TileSize / 2 + 1,
player.Position.Y * _state.TileSize + _state.TileSize - measure.Y * fscale);
}
i++;
}
else if (playersInCell.Count >= 3)
{
fscale = (_state.TileSize / 2 - 2) / maxSize;
switch (i)
{
case 0:
rectangle = new Rectangle(
player.Position.X * _state.TileSize,
player.Position.Y * _state.TileSize,
_state.TileSize / 2 - 1,
_state.TileSize / 2 - 1);
stringPosition = new Vector2(
player.Position.X * _state.TileSize + 1,
player.Position.Y * _state.TileSize + _state.TileSize / 2 - measure.Y * fscale);
break;
case 1:
rectangle = new Rectangle(
player.Position.X * _state.TileSize + _state.TileSize / 2,
player.Position.Y * _state.TileSize,
_state.TileSize / 2 - 1,
_state.TileSize / 2 - 1);
stringPosition = new Vector2(
player.Position.X * _state.TileSize + _state.TileSize / 2 + 1,
player.Position.Y * _state.TileSize + _state.TileSize / 2 - measure.Y * fscale);
break;
case 2:
rectangle = new Rectangle(
player.Position.X * _state.TileSize,
player.Position.Y * _state.TileSize + _state.TileSize / 2,
_state.TileSize / 2 - 1,
_state.TileSize / 2 - 1);
stringPosition = new Vector2(
player.Position.X * _state.TileSize + 1,
player.Position.Y * _state.TileSize + _state.TileSize - measure.Y * fscale);
break;
case 3:
default:
rectangle = new Rectangle(
player.Position.X * _state.TileSize + _state.TileSize / 2,
player.Position.Y * _state.TileSize + _state.TileSize / 2,
_state.TileSize / 2 - 1,
_state.TileSize / 2 - 1);
stringPosition = new Vector2(
player.Position.X * _state.TileSize + _state.TileSize / 2 + 1,
player.Position.Y * _state.TileSize + _state.TileSize - measure.Y * fscale);
break;
}
i++;
}
_spriteBatch.DrawRectangle(rectangle, color, 2);
_spriteBatch.DrawString(ffont,
player.Initials,
stringPosition,
color,
0,
Vector2.Zero,
fscale,
SpriteEffects.None,
0);
}
}
foreach (var player in _sessionData.Players)
@ -1203,30 +1456,88 @@ namespace Sledgemapper
}
}
private void DrawPlayerPointer(Player player)
private void DrawPingPointer(Ping ping, GameTime gameTime)
{
var center = new Point((Window.ClientBounds.Width + 200) / 2 - (int)_viewportCenter.X, Window.ClientBounds.Height / 2 - (int)_viewportCenter.Y);
var durationMs = 2000f;
var baseRadius = _state.TileSize / 4f;
var baseOuterRadius = (float)_state.TileSize;
var iterations = 3f;
var validPointer = GetPointerVector(new Point(ping.X, ping.Y), out var points);
var cx = center.X / _state.TileSize;
var cy = center.Y / _state.TileSize;
if (validPointer)
{
_spriteBatch.DrawPolygon(Vector2.Zero, points, ping.Player.Color.ToColor(), 4);
var p1 = new Vector2(cx * _state.TileSize, cy * _state.TileSize);
var p2 = new Vector2(player.Position.X * _state.TileSize, player.Position.Y * _state.TileSize);
var p3 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, 0 - _viewportCenter.Y);
var p4 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y);
for (var j = 0; j < iterations; j++)
{
var cycleTime = (((float)gameTime.TotalGameTime.TotalMilliseconds + (float)j * durationMs / iterations) % durationMs) / durationMs;
var easing = Easings.Interpolate(cycleTime, Easings.Functions.SineEaseInOut);
var v2 = new Vector2[points.Length];
var tCenter = new Vector2((points[0].X + points[1].X + points[2].X) / 3f, (points[0].Y + points[1].Y + points[2].Y) / 3f);
for (int i1 = 0; i1 < v2.Length; i1++)
{
var svx = ((points[i1].X - tCenter.X) * (1 + (2 * easing))) + tCenter.X;
var svy = ((points[i1].Y - tCenter.Y) * (1 + (2 * easing))) + tCenter.Y;
v2[i1] = new Vector2(svx, svy);
}
_spriteBatch.DrawPolygon(
offset: Vector2.Zero,
points: v2,
color: new Color(ping.Player.Color.ToColor(), 1f - easing),
thickness: 2 + 2 * (1 - easing));
}
}
}
private bool GetPointerVector(Point target, out Vector2[] points)
{
var offset = _state.TileSize / 2;
var leftBound = 200 + offset;
var topBound = 75 + offset;
var bottomBound = 25 + offset;
var rightBound = offset;
points = new Vector2[0];
var center = new Point((Window.ClientBounds.Width + leftBound) / 2 - (int)_viewportCenter.X, Window.ClientBounds.Height / 2 - (int)_viewportCenter.Y);
// center
var p1 = new Vector2(center.X, center.Y);
// point
var p2 = new Vector2(
target.X * _state.TileSize + offset,
target.Y * _state.TileSize + offset);
// top right
var p3 = new Vector2(
Window.ClientBounds.Width - _viewportCenter.X - rightBound,
topBound - _viewportCenter.Y);
//bottom right
var p4 = new Vector2(
Window.ClientBounds.Width - _viewportCenter.X - rightBound,
Window.ClientBounds.Height - _viewportCenter.Y - bottomBound);
var ua1 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
p3 = new Vector2(200 - _viewportCenter.X, 0 - _viewportCenter.Y);
p4 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, 0 - _viewportCenter.Y);
p3 = new Vector2(leftBound - _viewportCenter.X, topBound - _viewportCenter.Y);
p4 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, topBound - _viewportCenter.Y);
var ua2 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
p3 = new Vector2(200 - _viewportCenter.X, 0 - _viewportCenter.Y);
p4 = new Vector2(200 - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y);
p3 = new Vector2(leftBound - _viewportCenter.X, topBound - _viewportCenter.Y);
p4 = new Vector2(leftBound - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y - bottomBound);
var ua3 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
p3 = new Vector2(200 - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y);
p4 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y);
p3 = new Vector2(leftBound - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y - bottomBound);
p4 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y - bottomBound);
var ua4 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
var uas = new List<float> { ua1, ua2, ua3, ua4 };
@ -1236,26 +1547,37 @@ namespace Sledgemapper
var i = uas.IndexOf(ua);
var x = (p1.X + ua * (p2.X - p1.X));
var y = (p1.Y + ua * (p2.Y - p1.Y));
Vector2[] vertexes = new Vector2[0];
switch (i)
{
case 0:
vertexes = new Vector2[] { new Vector2(x, y), new Vector2(x - 20, y + 10), new Vector2(x - 20, y - 10), new Vector2(x, y) };
x += offset;
points = new Vector2[] { new Vector2(x, y), new Vector2(x - 20, y - 10), new Vector2(x - 20, y + 10), new Vector2(x, y) };
break;
case 1:
y += 20;
vertexes = new Vector2[] { new Vector2(x, y), new Vector2(x - 10, y + 20), new Vector2(x + 10, y + 20), new Vector2(x, y) };
y -= offset;
points = new Vector2[] { new Vector2(x, y), new Vector2(x - 10, y + 20), new Vector2(x + 10, y + 20), new Vector2(x, y) };
break;
case 2:
x += 0;
vertexes = new Vector2[] { new Vector2(x, y), new Vector2(x + 20, y + 10), new Vector2(x + 20, y - 10), new Vector2(x, y) };
x -= offset;
points = new Vector2[] { new Vector2(x, y), new Vector2(x + 20, y + 10), new Vector2(x + 20, y - 10), new Vector2(x, y) };
break;
case 3:
y -= 20;
vertexes = new Vector2[] { new Vector2(x, y), new Vector2(x - 10, y - 20), new Vector2(x + 10, y - 20), new Vector2(x, y) };
y += offset;
points = new Vector2[] { new Vector2(x, y), new Vector2(x + 10, y - 20), new Vector2(x - 10, y - 20), new Vector2(x, y) };
break;
}
_spriteBatch.DrawPolygon(Vector2.Zero, vertexes, player.Color.ToColor(), 2);
return true;
}
return false;
}
private void DrawPlayerPointer(Player player)
{
var validPointer = GetPointerVector(new Point(player.Position.X, player.Position.Y), out var points);
if (validPointer)
{
_spriteBatch.DrawPolygon(Vector2.Zero, points, player.Color.ToColor(), 2);
}
}
@ -1263,20 +1585,18 @@ namespace Sledgemapper
private bool IsOffscreen(Tile position)
{
var visibleTilesX = GraphicsDevice.Viewport.Width / _state.TileSize + 1;
var visibleTilesY = GraphicsDevice.Viewport.Height / _state.TileSize + 1;
var boxTL = new Point(200 - _state.TileSize / 2, 75 - _state.TileSize / 2);
var boxBR = new Point(GraphicsDevice.Viewport.Width + _state.TileSize / 2, GraphicsDevice.Viewport.Height - 25 + _state.TileSize / 2);
var screenPositionTopLeft = new Point(200 - _state.TileSize + 0 * _state.TileSize - (int)_viewportCenter.X, 0 * _state.TileSize + _state.TileSize - (int)_viewportCenter.Y);
var screenPositionBottomRight = new Point(visibleTilesX * _state.TileSize - (int)_viewportCenter.X, visibleTilesY * _state.TileSize - 20 - (int)_viewportCenter.Y);
var tileTopLeft = new Point(screenPositionTopLeft.X / _state.TileSize, screenPositionTopLeft.Y / _state.TileSize);
var tileBottomRight = new Point(screenPositionBottomRight.X / _state.TileSize, screenPositionBottomRight.Y / _state.TileSize);
var tileTL = new Point(position.X * _state.TileSize + (int)_viewportCenter.X, position.Y * _state.TileSize + (int)_viewportCenter.Y);
var tileBR = new Point(position.X * _state.TileSize + (int)_viewportCenter.X + _state.TileSize, position.Y * _state.TileSize + (int)_viewportCenter.Y + _state.TileSize);
if (position.X < tileTopLeft.X || position.Y < tileTopLeft.Y || position.X > tileBottomRight.X || position.Y > tileBottomRight.Y)
if (tileTL.X <= boxTL.X || tileTL.Y <= boxTL.Y || tileBR.X >= boxBR.X || tileBR.Y >= boxBR.Y)
{
return true;
}
return false;
return false;
}
private int _borderWidth => (_state.TileSize / 6) % 2 == 0 ? (_state.TileSize / 6) : (_state.TileSize / 6) + 1;
@ -1419,11 +1739,11 @@ namespace Sledgemapper
}
}
}
Effect outlineShader;
Effect outlineShader;
private Texture2D _transparentRedRectangle;
private Texture2D _whiteRectangle;
private Dictionary<string, Texture2D> _wallsContent;
private SpriteSheet _spriteSheet;
private void DrawDelete(Room tile)
@ -1870,6 +2190,8 @@ namespace Sledgemapper
noteWindow.NoteText.SetKeyboardFocus();
}
private void OnContextMenuDeleteNoteClick(object sender, EventArgs e)
{
_desktop.HideContextMenu();
@ -2091,10 +2413,10 @@ namespace Sledgemapper
internal Texture2D Texture;
internal Dictionary<String, Rectangle> index;
public void LoadContent(ContentManager content)
public void LoadContent(ContentManager content, string spriteIndex, string texture)
{
index = content.Load<Dictionary<String, Rectangle>>("spriteIndex");
Texture = content.Load<Texture2D>("sprites");
index = content.Load<Dictionary<String, Rectangle>>(spriteIndex);
Texture = content.Load<Texture2D>(texture);
}
internal Rectangle? SourceRectangle(string spriteName)
@ -2112,4 +2434,6 @@ namespace Sledgemapper
}
}
}
}

View file

@ -8,9 +8,18 @@ namespace Sledgemapper.UI
{
ClearSelection(GridWalls);
ClearSelection(GridOverlays);
ClearSelection(Toolbar);
}
private void ClearSelection(Grid grid)
{
foreach (var widget in grid.Widgets)
{
widget.Border = null;
}
}
private void ClearSelection(HorizontalStackPanel grid)
{
foreach (var widget in grid.Widgets)
{

View file

@ -1,4 +1,4 @@
/* Generated by MyraPad at 18/01/2021 09:38:43 */
/* Generated by MyraPad at 04/02/2021 10:36:48 */
using Myra;
using Myra.Graphics2D;
using Myra.Graphics2D.TextureAtlases;
@ -127,31 +127,19 @@ namespace Sledgemapper.UI
_mainMenu.Items.Add(menuItem2);
_mainMenu.Items.Add(menuItem3);
BtnToolbarTile = new ImageTextButton();
BtnToolbarTile.Text = " T";
BtnToolbarTile.Width = 40;
BtnToolbarTile.Height = 40;
BtnToolbarTile.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
BtnToolbarTile.Id = "BtnToolbarTile";
BtnToolbarLine = new ImageTextButton();
BtnToolbarLine.Text = " C";
BtnToolbarLine.Width = 40;
BtnToolbarLine.Height = 40;
BtnToolbarLine.BorderThickness = new Thickness(2);
BtnToolbarLine.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
BtnToolbarLine.Id = "BtnToolbarLine";
BtnToolbarWall = new ImageTextButton();
BtnToolbarWall.Text = " W";
BtnToolbarWall.Width = 40;
BtnToolbarWall.Height = 40;
BtnToolbarWall.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
BtnToolbarWall.Id = "BtnToolbarWall";
BtnToolbarRoom = new ImageTextButton();
BtnToolbarRoom.Text = " R";
BtnToolbarRoom.Width = 40;
BtnToolbarRoom.Height = 40;
BtnToolbarRoom.BorderThickness = new Thickness(2);
BtnToolbarRoom.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
BtnToolbarRoom.Id = "BtnToolbarRoom";
@ -159,24 +147,24 @@ namespace Sledgemapper.UI
BtnToolbarDelete.Text = " D";
BtnToolbarDelete.Width = 40;
BtnToolbarDelete.Height = 40;
BtnToolbarDelete.BorderThickness = new Thickness(2);
BtnToolbarDelete.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
BtnToolbarDelete.Id = "BtnToolbarDelete";
var horizontalStackPanel1 = new HorizontalStackPanel();
horizontalStackPanel1.Spacing = 5;
horizontalStackPanel1.Proportions.Add(new Proportion
Toolbar = new HorizontalStackPanel();
Toolbar.Spacing = 12;
Toolbar.Proportions.Add(new Proportion
{
Type = Myra.Graphics2D.UI.ProportionType.Auto,
});
horizontalStackPanel1.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
horizontalStackPanel1.Height = 51;
horizontalStackPanel1.Padding = new Thickness(4, 0, 0, 0);
horizontalStackPanel1.Background = new SolidBrush("#404040FF");
horizontalStackPanel1.Widgets.Add(BtnToolbarTile);
horizontalStackPanel1.Widgets.Add(BtnToolbarLine);
horizontalStackPanel1.Widgets.Add(BtnToolbarWall);
horizontalStackPanel1.Widgets.Add(BtnToolbarRoom);
horizontalStackPanel1.Widgets.Add(BtnToolbarDelete);
Toolbar.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
Toolbar.Height = 51;
Toolbar.Padding = new Thickness(4, 0, 0, 0);
Toolbar.Background = new SolidBrush("#404040FF");
Toolbar.Id = "Toolbar";
Toolbar.Widgets.Add(BtnToolbarLine);
Toolbar.Widgets.Add(BtnToolbarRoom);
Toolbar.Widgets.Add(BtnToolbarDelete);
GridWalls = new Grid();
GridWalls.ColumnSpacing = 8;
@ -218,15 +206,22 @@ namespace Sledgemapper.UI
};
GridOverlays.Id = "GridOverlays";
var scrollViewer2 = new ScrollViewer();
scrollViewer2.Content = GridOverlays;
ScrOverlay = new ScrollViewer();
ScrOverlay.Id = "ScrOverlay";
ScrOverlay.Content = GridOverlays;
TxtOverlaySearch = new TextBox();
TxtOverlaySearch.Height = 40;
TxtOverlaySearch.Margin = new Thickness(0, 4);
TxtOverlaySearch.Id = "TxtOverlaySearch";
var verticalStackPanel2 = new VerticalStackPanel();
verticalStackPanel2.Proportions.Add(new Proportion
{
Type = Myra.Graphics2D.UI.ProportionType.Fill,
});
verticalStackPanel2.Widgets.Add(scrollViewer2);
verticalStackPanel2.Widgets.Add(ScrOverlay);
verticalStackPanel2.Widgets.Add(TxtOverlaySearch);
var verticalSplitPane1 = new VerticalSplitPane();
verticalSplitPane1.Width = 200;
@ -262,22 +257,22 @@ namespace Sledgemapper.UI
lblSessionName.MinWidth = 100;
lblSessionName.Id = "lblSessionName";
var horizontalStackPanel2 = new HorizontalStackPanel();
horizontalStackPanel2.Spacing = 10;
horizontalStackPanel2.Proportions.Add(new Proportion
var horizontalStackPanel1 = new HorizontalStackPanel();
horizontalStackPanel1.Spacing = 10;
horizontalStackPanel1.Proportions.Add(new Proportion
{
Type = Myra.Graphics2D.UI.ProportionType.Auto,
});
horizontalStackPanel2.Height = 25;
horizontalStackPanel2.Background = new SolidBrush("#333333FF");
horizontalStackPanel2.Widgets.Add(label1);
horizontalStackPanel2.Widgets.Add(lblConnectionStatus);
horizontalStackPanel2.Widgets.Add(verticalSeparator1);
horizontalStackPanel2.Widgets.Add(label2);
horizontalStackPanel2.Widgets.Add(lblUsername);
horizontalStackPanel2.Widgets.Add(verticalSeparator2);
horizontalStackPanel2.Widgets.Add(label3);
horizontalStackPanel2.Widgets.Add(lblSessionName);
horizontalStackPanel1.Height = 25;
horizontalStackPanel1.Background = new SolidBrush("#333333FF");
horizontalStackPanel1.Widgets.Add(label1);
horizontalStackPanel1.Widgets.Add(lblConnectionStatus);
horizontalStackPanel1.Widgets.Add(verticalSeparator1);
horizontalStackPanel1.Widgets.Add(label2);
horizontalStackPanel1.Widgets.Add(lblUsername);
horizontalStackPanel1.Widgets.Add(verticalSeparator2);
horizontalStackPanel1.Widgets.Add(label3);
horizontalStackPanel1.Widgets.Add(lblSessionName);
Proportions.Add(new Proportion
@ -293,9 +288,9 @@ namespace Sledgemapper.UI
Type = Myra.Graphics2D.UI.ProportionType.Fill,
});
Widgets.Add(_mainMenu);
Widgets.Add(horizontalStackPanel1);
Widgets.Add(Toolbar);
Widgets.Add(verticalSplitPane1);
Widgets.Add(horizontalStackPanel2);
Widgets.Add(horizontalStackPanel1);
}
@ -314,13 +309,14 @@ namespace Sledgemapper.UI
public MenuItem MenuViewCenterOnSelection;
public MenuItem MenuHelpAbout;
public HorizontalMenu _mainMenu;
public ImageTextButton BtnToolbarTile;
public ImageTextButton BtnToolbarLine;
public ImageTextButton BtnToolbarWall;
public ImageTextButton BtnToolbarRoom;
public ImageTextButton BtnToolbarDelete;
public HorizontalStackPanel Toolbar;
public Grid GridWalls;
public Grid GridOverlays;
public ScrollViewer ScrOverlay;
public TextBox TxtOverlaySearch;
public Label lblConnectionStatus;
public Label lblUsername;
public Label lblSessionName;

View file

@ -32,15 +32,13 @@
<MenuItem Text="&amp;About" Id="MenuHelpAbout" />
</MenuItem>
</HorizontalMenu>
<HorizontalStackPanel Spacing="5" VerticalAlignment="Center" Height="51" Padding="4, 0, 0, 0" Background="#404040FF">
<HorizontalStackPanel Spacing="12" VerticalAlignment="Center" Height="51" Padding="4, 0, 0, 0" Background="#404040FF" Id="Toolbar">
<HorizontalStackPanel.Proportions>
<Proportion Type="Auto" />
</HorizontalStackPanel.Proportions>
<ImageTextButton Text=" T" Width="40" Height="40" VerticalAlignment="Center" Id="BtnToolbarTile" />
<ImageTextButton Text=" C" Width="40" Height="40" VerticalAlignment="Center" Id="BtnToolbarLine" />
<ImageTextButton Text=" W" Width="40" Height="40" VerticalAlignment="Center" Id="BtnToolbarWall" />
<ImageTextButton Text=" R" Width="40" Height="40" VerticalAlignment="Center" Id="BtnToolbarRoom" />
<ImageTextButton Text=" D" Width="40" Height="40" VerticalAlignment="Center" Id="BtnToolbarDelete" />
<ImageTextButton Text=" C" Width="40" Height="40" BorderThickness="2" VerticalAlignment="Center" Id="BtnToolbarLine" />
<ImageTextButton Text=" R" Width="40" Height="40" BorderThickness="2" VerticalAlignment="Center" Id="BtnToolbarRoom" />
<ImageTextButton Text=" D" Width="40" Height="40" BorderThickness="2" VerticalAlignment="Center" Id="BtnToolbarDelete" />
</HorizontalStackPanel>
<VerticalSplitPane Width="200" Background="#A1A1A1FF">
<VerticalStackPanel>
@ -58,6 +56,9 @@
<VerticalStackPanel.Proportions>
<Proportion Type="Fill" />
</VerticalStackPanel.Proportions>
<TextBox MinHeight="40" Margin="0, 4" >
</TextBox>
<ScrollViewer>
<Grid ColumnSpacing="8" RowSpacing="8" Id="GridOverlays">
<Grid.DefaultColumnProportion Type="Pixels" Value="40" />

View file

@ -0,0 +1,82 @@
<Project>
<Project.ExportOptions Namespace="Sledgemapper.UI" Class="MainWidget" OutputPath="C:\dev\Map\Sledgemapper\UI" />
<VerticalStackPanel>
<VerticalStackPanel.Proportions>
<Proportion Type="Auto" />
<Proportion Type="Auto" />
<Proportion Type="Fill" />
</VerticalStackPanel.Proportions>
<HorizontalMenu Id="_mainMenu">
<MenuItem Text="&amp;File" Id="MenuFile">
<MenuItem Text="&amp;Load" ShortcutText="Ctrl+L" Id="MenuFileLoad" />
<MenuItem Text="&amp;Save" ShortcutText="Ctrl+S" Id="MenuFileSave" />
<MenuSeparator />
<MenuItem Text="S&amp;ettings" ShortcutText="Ctrl+E" Id="MenuFileSettings" />
<MenuSeparator />
<MenuItem Text="&amp;Quit" ShortcutText="Ctrl+Q" Id="MenuFileQuit" />
</MenuItem>
<MenuItem Text="&amp;Connect">
<MenuItem Text="L&amp;ogin" ShortcutText="Ctrl+O" Id="MenuConnectLogin" />
<MenuSeparator />
<MenuItem Text="&amp;New" ShortcutText="Ctrl+N" Id="MenuConnectNew" />
<MenuItem Text="&amp;Join" ShortcutText="Ctrl+J" Id="MenuConnectJoin" />
<MenuItem Text="S&amp;ync" ShortcutText="Ctrl+Y" Id="MenuConnectSync" />
<MenuItem Text="&amp;Upload" ShortcutText="Ctrl+U" Id="MenuConnectUpload" />
</MenuItem>
<MenuItem Text="&amp;View">
<MenuItem Text="N&amp;otes" ShortcutText="Ctrl+O" Id="MenuViewShowNotes" />
<MenuItem Text="S&amp;how cell numbers" ShortcutText="Ctrl+H" Id="MenuViewShowCellNUmbers" />
<MenuItem Text="C&amp;enter on selection" ShortcutText="Ctrl+E" Id="MenuViewCenterOnSelection" />
</MenuItem>
<MenuItem Text="&amp;Help">
<MenuItem Text="&amp;About" Id="MenuHelpAbout" />
</MenuItem>
</HorizontalMenu>
<HorizontalStackPanel Spacing="12" VerticalAlignment="Center" Height="51" Padding="4, 0, 0, 0" Background="#404040FF" Id="Toolbar">
<HorizontalStackPanel.Proportions>
<Proportion Type="Auto" />
</HorizontalStackPanel.Proportions>
<ImageTextButton Text=" C" Width="40" Height="40" BorderThickness="2" VerticalAlignment="Center" Id="BtnToolbarLine" />
<ImageTextButton Text=" R" Width="40" Height="40" BorderThickness="2" VerticalAlignment="Center" Id="BtnToolbarRoom" />
<ImageTextButton Text=" D" Width="40" Height="40" BorderThickness="2" VerticalAlignment="Center" Id="BtnToolbarDelete" />
</HorizontalStackPanel>
<VerticalSplitPane Width="200" Background="#A1A1A1FF">
<VerticalStackPanel>
<VerticalStackPanel.Proportions>
<Proportion Type="Fill" />
</VerticalStackPanel.Proportions>
<ScrollViewer>
<Grid ColumnSpacing="8" RowSpacing="8" Id="GridWalls">
<Grid.DefaultColumnProportion Type="Pixels" Value="40" />
<Grid.DefaultRowProportion Type="Pixels" Value="40" />
</Grid>
</ScrollViewer>
</VerticalStackPanel>
<VerticalStackPanel>
<VerticalStackPanel.Proportions>
<Proportion Type="Fill" />
</VerticalStackPanel.Proportions>
<ScrollViewer Id="ScrOverlay">
<Grid ColumnSpacing="8" RowSpacing="8" Id="GridOverlays">
<Grid.DefaultColumnProportion Type="Pixels" Value="40" />
<Grid.DefaultRowProportion Type="Pixels" Value="40" />
</Grid>
</ScrollViewer>
<TextBox Height="40" Margin="0, 4" Id="TxtOverlaySearch" />
</VerticalStackPanel>
</VerticalSplitPane>
<HorizontalStackPanel Spacing="10" Height="25" Background="#333333FF">
<HorizontalStackPanel.Proportions>
<Proportion Type="Auto" />
</HorizontalStackPanel.Proportions>
<Label Text="Connection status:" />
<Label Text="Disconnected" MinWidth="100" Id="lblConnectionStatus" />
<VerticalSeparator />
<Label Text="Username:" />
<Label Text="n/a" MinWidth="100" Id="lblUsername" />
<VerticalSeparator />
<Label Text="Session name:" />
<Label Text="n/a" MinWidth="100" Id="lblSessionName" />
</HorizontalStackPanel>
</VerticalStackPanel>
</Project>