small fixes
This commit is contained in:
parent
32bc8274a2
commit
2a796509c8
7 changed files with 60 additions and 36 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,9 +1,11 @@
|
||||||
using Microsoft.AspNetCore.SignalR.Client;
|
using Microsoft.AspNetCore.SignalR.Client;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Polly;
|
using Polly;
|
||||||
using Refit;
|
using Refit;
|
||||||
using Sledgemapper.Shared.Entities;
|
using Sledgemapper.Shared.Entities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
@ -23,26 +25,27 @@ namespace Sledgemapper
|
||||||
|
|
||||||
public CommunicationManager(Session sessionData)
|
public CommunicationManager(Session sessionData)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
var baseAddress = "http://localhost:5000";
|
||||||
|
#else
|
||||||
|
var baseAddress = "http://hub.michelescandura.com:5000";
|
||||||
|
#endif
|
||||||
|
|
||||||
SessionData = sessionData;
|
SessionData = sessionData;
|
||||||
Connection = new HubConnectionBuilder()
|
Connection = new HubConnectionBuilder()
|
||||||
.WithAutomaticReconnect()
|
.WithAutomaticReconnect()
|
||||||
//.WithUrl("http://hub.michelescandura.com:5001/SledgemapperHub")
|
|
||||||
|
|
||||||
//.WithUrl("http://localhost:5001/SledgemapperHub", options =>
|
|
||||||
.WithUrl("http://hub.michelescandura.com:5000/SledgemapperHub", options =>
|
|
||||||
{
|
|
||||||
options.AccessTokenProvider = () => Task.FromResult(_authenticateResponse.Token);
|
|
||||||
})
|
|
||||||
|
|
||||||
|
.WithUrl($"{baseAddress}/SledgemapperHub", options =>
|
||||||
|
{
|
||||||
|
options.AccessTokenProvider = () => Task.FromResult(_authenticateResponse.Token);
|
||||||
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Api = RestService.For<IMapApi>(
|
Api = RestService.For<IMapApi>(
|
||||||
new HttpClient(new AuthenticatedHttpClientHandler(GetToken))
|
new HttpClient(new AuthenticatedHttpClientHandler(GetToken))
|
||||||
{
|
{
|
||||||
BaseAddress = new Uri("http://hub.michelescandura.com:5000")
|
BaseAddress = new Uri(baseAddress)
|
||||||
// BaseAddress = new Uri("http://localhost:5001")
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -659,34 +659,46 @@ namespace Sledgemapper
|
||||||
|
|
||||||
private void DrawPlayers()
|
private void DrawPlayers()
|
||||||
{
|
{
|
||||||
foreach (var player in _sessionData.Players.Copy())
|
try
|
||||||
{
|
{
|
||||||
|
foreach (var player in _sessionData.Players.Copy())
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var player in _sessionData.Players.Copy())
|
|
||||||
{
|
|
||||||
var isOffscreen = IsOffscreen(player.Position);
|
|
||||||
if (isOffscreen)
|
|
||||||
{
|
{
|
||||||
DrawPlayerPointer(player);
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
foreach (var font in _fonts.Keys)
|
||||||
|
{
|
||||||
|
System.Console.WriteLine(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var player in _sessionData.Players.Copy())
|
||||||
|
{
|
||||||
|
var isOffscreen = IsOffscreen(player.Position);
|
||||||
|
if (isOffscreen)
|
||||||
|
{
|
||||||
|
DrawPlayerPointer(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Console.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Icon.ico" />
|
<None Remove="Icon.ico" />
|
||||||
<None Remove="Icon.bmp" />
|
<None Remove="Icon.bmp" />
|
||||||
|
@ -36,6 +42,7 @@
|
||||||
</ItemGroup> -->
|
</ItemGroup> -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AsyncAwaitBestPractices" Version="5.0.2" />
|
<PackageReference Include="AsyncAwaitBestPractices" Version="5.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
|
||||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
|
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
|
||||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
|
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client">
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client">
|
||||||
|
|
|
@ -18,10 +18,12 @@ namespace Sledgemapper
|
||||||
|
|
||||||
public static Color ToColor(this string s)
|
public static Color ToColor(this string s)
|
||||||
{
|
{
|
||||||
|
System.Console.WriteLine(s);
|
||||||
var hexs = s.TrimStart('#').Split(2).ToArray();
|
var hexs = s.TrimStart('#').Split(2).ToArray();
|
||||||
var color = new Color(int.Parse(hexs[0], System.Globalization.NumberStyles.HexNumber),
|
var color = new Color(int.Parse(hexs[0], System.Globalization.NumberStyles.HexNumber),
|
||||||
int.Parse(hexs[1], System.Globalization.NumberStyles.HexNumber),
|
int.Parse(hexs[1], System.Globalization.NumberStyles.HexNumber),
|
||||||
int.Parse(hexs[2], System.Globalization.NumberStyles.HexNumber));
|
int.Parse(hexs[2], System.Globalization.NumberStyles.HexNumber));
|
||||||
|
System.Console.WriteLine(color);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue