Shader galore

This commit is contained in:
Michele 2021-01-09 00:38:19 +00:00
parent 519b7518ff
commit 07685fcd9c
62 changed files with 496 additions and 266 deletions

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,4 @@
<Project StylesheetPath="commodore-64/ui_stylesheet.xml">
<Project StylesheetPath="commodore-64/ui_stylesheet.xmms">
<ExportOptions Namespace="Myra.Samples.CustomUIStylesheet" Class="AllWidgets" OutputPath="D:\Projects\Hebron\Myra\Source\Samples\Myra.Samples.CustomUIStylesheet" />
<HorizontalSplitPane GridRow="1">
<ScrollPane>

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -212,7 +212,7 @@ namespace Sledgemapper.Shared.Entities
}
var lineExist = Rooms.TryGetValue(line.ToString(), out var tile);
var newLine = new Room { Start=line.Start, End=line.End};
var newLine = new Room { Start=line.Start, End=line.End, Delete=line.Delete};
if (lineExist)
{
Rooms.TryRemove(line.ToString(), out var _);

View File

@ -1,7 +1,14 @@
namespace Sledgemapper.Shared.Entities
using System;
namespace Sledgemapper.Shared.Entities
{
public abstract class BaseMapEntity
{
public BaseMapEntity()
{
Timestamp = DateTime.UtcNow.Ticks;
}
public int X { get; set; }
public int Y { get; set; }
public string ID { get; set; }
@ -21,26 +28,27 @@
{
public SnapPoint Start { get; set; }
public SnapPoint End { get; set; }
public float Width {get;set;}
public float Width { get; set; }
public override string ToString()
{
return $"{Start.X}_{Start.Y}_{Start.Index}_{End.X}_{End.Y}_{End.Index}";
}
}
public class Room : BaseMapEntity
public class Room : BaseMapEntity
{
public SnapPoint Start { get; set; }
public SnapPoint End { get; set; }
public bool Delete { get; set; }
public override string ToString()
{
return $"{Start.X}_{Start.Y}_{Start.Index}_{End.X}_{End.Y}_{End.Index}";
}
}
public class SnapPoint : BaseMapEntity
public class SnapPoint : BaseMapEntity
{
public int Index { get; set; }

View File

@ -3021,6 +3021,12 @@
/processorParam:TextureFormat=Color
/build:overlays/zigzag-hieroglyph.png
#begin shaders/OutlineShader.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:shaders/OutlineShader.fx
#begin tiles/tile01.png
/importer:TextureImporter
/processor:TextureProcessor

View File

@ -0,0 +1,92 @@
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif
float2 TexelSize; // should be (1f/textureSize.X, 1f/textureSize.Y)
int shadow;
int BorderSize;
float R;
float G;
float B;
Texture2D SpriteTexture;
sampler2D SpriteTextureSampler = sampler_state
{
Texture = <SpriteTexture>;
};
struct VertexShaderOutput
{
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};
sampler ColorMapSampler = sampler_state
{
Texture = <ColorMap>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
float4 MainPS(VertexShaderOutput input) : COLOR
{
float4 color = tex2D(ColorMapSampler, input.TextureCoordinates);
float2 offsetX = float2(TexelSize.x, 0);
float2 offsetY = { 0, TexelSize.y };
float2 offsetd1 = { TexelSize.x, TexelSize.y };
float2 offsetd2 = { -TexelSize.x, -TexelSize.y };
float2 offsetd3 = { TexelSize.x, -TexelSize.y };
float2 offsetd4 = { -TexelSize.x, TexelSize.y };
if (color.a == 0)
{
for (int i = 1; i < 16; i++)
{
if (i<=BorderSize)
{
float4 c1 = tex2D(ColorMapSampler, input.TextureCoordinates + offsetX*i);
float4 c2 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetX*i);
float4 c3 = tex2D(ColorMapSampler, input.TextureCoordinates + offsetY*i);
float4 c4 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetY*i);
float4 d1 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetd1*i);
float4 d2 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetd2*i);
float4 d3 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetd3*i);
float4 d4 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetd4*i);
if (color.a != c1.a || color.a != c2.a|| color.a != c3.a|| color.a != c4.a
|| color.a != d1.a
|| color.a != d2.a
|| color.a != d3.a
|| color.a != d4.a
)
{
color.r=R;
color.g=G;
color.b=B;
color.a=1;
}
}
}
return color;
}
return color;
}
technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
};

View File

@ -8,6 +8,7 @@
NewWall,
NewLine,
NewRoom,
NewTile
NewTile,
NewDelete
}
}

View File

@ -11,6 +11,8 @@ namespace Sledgemapper
public Color GridColor { get; set; }
public Color NoteColor { get; set; }
public string MachineName { get; set; }
public int Thickness { get; internal set; }
public int Threshold { get; internal set; }
public Settings()
{

View File

@ -4,7 +4,9 @@ using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using MonoGame.Extended;
using Myra;
using Myra.Graphics2D;
using Myra.Graphics2D.Brushes;
using Myra.Graphics2D.TextureAtlases;
using Myra.Graphics2D.UI;
@ -39,6 +41,7 @@ namespace Sledgemapper
private Texture2D _comment;
private readonly Session _sessionData;
private AuthenticateResponse _authResponse;
private RenderTarget2D rendertarget;
private MainWidget _mainWidget;
private bool _showCellNumbers;
private readonly Settings _settings;
@ -89,9 +92,28 @@ namespace Sledgemapper
ExceptionlessClient.Default.SubmitEvent(new Event { Message = "Initialize", Type = "AppLifecycle", Source = _settings.MachineName });
IsMouseVisible = true;
Window.AllowUserResizing = true;
Window.ClientSizeChanged += OnClientSizeChanged;
base.Initialize();
}
private void OnClientSizeChanged(object sender, EventArgs e)
{
rendertarget?.Dispose();
try
{
// rendertarget = new RenderTarget2D(GraphicsDevice, _graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents);
rendertarget = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
}
catch
{
System.Console.WriteLine("rendertarget dispose exception");
}
}
private void AddItemToToolGrid(Grid grid, EventHandler eventAction, string folder)
{
var tilesFolderContent = Content.LoadContentFolder<Texture2D>(folder);
@ -114,7 +136,13 @@ namespace Sledgemapper
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
outlineShader = Content.Load<Effect>("shaders/OutlineShader");
// outlineShader.Parameters["Thickness"].SetValue((float)_settings.Thickness);
// outlineShader.Parameters["shadow"].SetValue(1);
// outlineShader.Parameters["ScreenSize"].SetValue(
// new Vector2(GraphicsDevice.Viewport.Bounds.Width, GraphicsDevice.Viewport.Bounds.Height));
MyraEnvironment.Game = this;
rendertarget = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
_mainWidget = new MainWidget();
@ -137,6 +165,7 @@ namespace Sledgemapper
_mainWidget.BtnToolbarRoom.Click += OnBtnToolbarRoomClicked;
_mainWidget.BtnToolbarTile.Click += OnBtnToolbarTileClicked;
_mainWidget.BtnToolbarWall.Click += OnBtnToolbarWallClicked;
_mainWidget.BtnToolbarDelete.Click += OnBtnToolbarDeleteClicked;
AddItemToToolGrid(_mainWidget.GridTiles, OnTileButtonClicked, "tiles");
AddItemToToolGrid(_mainWidget.GridWalls, OnWallButtonClicked, "walls");
@ -149,6 +178,11 @@ namespace Sledgemapper
_desktop.Root = _mainWidget;
}
private void OnBtnToolbarDeleteClicked(object sender, EventArgs e)
{
_state.InsertMode = InsertMode.NewDelete;
}
private void OnBtnToolbarWallClicked(object sender, EventArgs e)
{
_state.InsertMode = InsertMode.NewWall;
@ -272,7 +306,7 @@ namespace Sledgemapper
_state.SelectOverlay(screenPosition);
}
if (_state.InsertMode == InsertMode.NewLine || _state.InsertMode == InsertMode.NewRoom)
if (_state.InsertMode == InsertMode.NewLine || _state.InsertMode == InsertMode.NewRoom || _state.InsertMode == InsertMode.NewDelete)
{
_state.SelectClosestSnapPoint(screenPosition);
}
@ -282,6 +316,16 @@ namespace Sledgemapper
// CenterOnSelectedTile();
// }
if (newState.IsKeyUp(Keys.Up) && (newState.IsKeyUp(Keys.Up) != oldState.IsKeyUp(Keys.Up)))
{
_settings.Thickness++;
}
if (newState.IsKeyUp(Keys.Down) && (newState.IsKeyUp(Keys.Down) != oldState.IsKeyUp(Keys.Down)))
{
_settings.Threshold++;
}
if (!newState.IsKeyDown(Keys.LeftControl) && mouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton == oldMouseState.LeftButton)
{
_viewportCenter = new Vector3(_viewportCenter.X + mouseState.Position.X - oldMouseState.Position.X, _viewportCenter.Y + mouseState.Position.Y - oldMouseState.Position.Y, 0);
@ -410,6 +454,31 @@ namespace Sledgemapper
}
if (_state.InsertMode == InsertMode.NewDelete && newState.IsKeyDown(Keys.LeftControl)
&& mouseState.LeftButton == ButtonState.Released
&& mouseState.LeftButton != oldMouseState.LeftButton)
{
if (_state.LineStart is null)
{
_state.LineStart = new SnapPoint { X = _state.SelectedSnapPoint.X, Y = _state.SelectedSnapPoint.Y, Index = _state.SelectedSnapPoint.Index };
}
else
{
var line = new Room
{
Start = new SnapPoint { X = _state.LineStart.X, Y = _state.LineStart.Y, Index = _state.LineStart.Index },
End = new SnapPoint { X = _state.SelectedSnapPoint.X, Y = _state.SelectedSnapPoint.Y, Index = _state.SelectedSnapPoint.Index },
Delete = true
};
_state.LineStart = null;
_state.LineWidth = 1;
_sessionData.NewRoom(line);
}
}
if (_state.InsertMode == InsertMode.NewLine && _state.LineStart != null)
{
if (mouseState.ScrollWheelValue > oldMouseState.ScrollWheelValue)
@ -527,23 +596,73 @@ namespace Sledgemapper
{
return;
}
GraphicsDevice.Clear(_settings.BackgroundColor);
var visibleTilesX = GraphicsDevice.Viewport.Width / _state.TileSize + 1;
var visibleTilesY = GraphicsDevice.Viewport.Height / _state.TileSize + 1;
_spriteBatch.Begin(transformMatrix: Matrix.CreateTranslation(_viewportCenter));
DrawTiles();
GraphicsDevice.SetRenderTarget(rendertarget);
GraphicsDevice.Clear(Color.Transparent);
DrawBorderLines();
DrawBorderRooms();
DrawInnerLines();
DrawInnerRooms();
DrawWalls();
DrawOverlays();
DrawNotes();
_spriteBatch.Begin(
transformMatrix: Matrix.CreateTranslation(_viewportCenter),
blendState: BlendState.Opaque,
sortMode: SpriteSortMode.Immediate);
// DrawTiles();
var items = new List<BaseMapEntity>();
items.AddRange(_sessionData.Lines.Values);
items.AddRange(_sessionData.Rooms.Values);
foreach (var item in items.OrderBy(t => t.Timestamp))
{
switch (item)
{
case Line l:
DrawLine(l);
break;
case Room room:
if (room.Delete)
{
DrawDelete(room);
}
else
{
DrawRoom(room);
}
break;
}
}
//DrawWalls();
_spriteBatch.End();
GraphicsDevice.SetRenderTarget(null);
GraphicsDevice.Clear(_settings.BackgroundColor);
Vector2 texelSize = new Vector2((float)(1 / (double)rendertarget.Width), (float)(1 / (double)rendertarget.Height));
outlineShader.Parameters["TexelSize"].SetValue(texelSize);
outlineShader.Parameters["BorderSize"].SetValue(_state.TileSize / 8);
outlineShader.Parameters["R"].SetValue(_settings.OverlayTintColor.R / 255.0f);
outlineShader.Parameters["G"].SetValue(_settings.OverlayTintColor.G / 255.0f);
outlineShader.Parameters["B"].SetValue(_settings.OverlayTintColor.B / 255.0f);
_spriteBatch.Begin(
effect: outlineShader,
blendState: BlendState.AlphaBlend,
sortMode: SpriteSortMode.Immediate);
_spriteBatch.Draw(rendertarget, Vector2.Zero, null, Color.White);
_spriteBatch.End();
_spriteBatch.Begin(
transformMatrix: Matrix.CreateTranslation(_viewportCenter),
sortMode: SpriteSortMode.Deferred);
//DrawOverlays();
//DrawNotes();
DrawGrid(visibleTilesX, visibleTilesY);
if (string.IsNullOrWhiteSpace(_sessionData.SessionName))
@ -711,7 +830,7 @@ DrawBorderLines();
}
}
if (_state.InsertMode == InsertMode.NewRoom && _state.SelectedSnapPoint != null)
if ((_state.InsertMode == InsertMode.NewRoom || _state.InsertMode == InsertMode.NewDelete) && _state.SelectedSnapPoint != null)
{
var snapPoint = new Vector2(_state.SelectedSnapPoint.X * _state.TileSize, _state.SelectedSnapPoint.Y * _state.TileSize);
@ -807,7 +926,6 @@ DrawBorderLines();
}
}
}
_spriteBatch.End();
try
@ -1075,10 +1193,6 @@ DrawBorderLines();
whiteRectangle.SetData(new[] { _settings.OverlayTintColor });
_spriteBatch.Draw(whiteRectangle, new Rectangle((int)posX - _borderWidth / 2, (int)posY - _borderWidth / 2, _state.TileSize + _borderWidth, _state.TileSize + _borderWidth), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
// _spriteBatch.DrawRectangle(new Rectangle((int)posX-4, (int)posY-4, _state.TileSize+_borderWidth, _state.TileSize+_borderWidth), _settings.OverlayTintColor,1);
// _spriteBatch.Draw(content, new Vector2(posX, posY),
// null, Color.White, MathHelper.ToRadians(90 * tile.Rotation), new Vector2(content.Width / 2, content.Height / 2), ((float)_state.TileSize) / content.Width, SpriteEffects.None, 0);
}
//inner pass
@ -1094,24 +1208,150 @@ DrawBorderLines();
whiteRectangle.SetData(new[] { Color.White });
_spriteBatch.Draw(whiteRectangle, new Rectangle((int)posX, (int)posY, _state.TileSize, _state.TileSize), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
// _spriteBatch.DrawRectangle(new Rectangle((int)posX, (int)posY, _state.TileSize, _state.TileSize), _settings.BackgroundColor,1);
// _spriteBatch.Draw(content, new Vector2(posX, posY),
// null, Color.White, MathHelper.ToRadians(90 * tile.Rotation), new Vector2(content.Width / 2, content.Height / 2), ((float)_state.TileSize) / content.Width, SpriteEffects.None, 0);
}
}
private void DrawBorderLines()
private void DrawLine(Line tile)
{
// var borderRectangle = new Texture2D(GraphicsDevice, 1, 1);
// borderRectangle.SetData(new[] { _settings.OverlayTintColor });
//inner pass
// var content = Content.Load<Texture2D>($"tiles/{tile.ID}");
// var innerRectangle = new Texture2D(GraphicsDevice, 1, 1);
// innerRectangle.SetData(new[] { Color.White });
var posX = tile.Start.X * _state.TileSize;
var posY = tile.Start.Y * _state.TileSize;
// border pass
foreach (var tile in _sessionData.Lines.Values)
var endposX = tile.End.X * _state.TileSize;
var endposY = tile.End.Y * _state.TileSize;
switch (tile.Start.Index)
{
case 1:
break;
case 2:
posX += _state.TileSize / 2;
break;
case 3:
posY += _state.TileSize / 2;
break;
case 4:
posX += _state.TileSize / 2;
posY += _state.TileSize / 2;
break;
}
switch (tile.End.Index)
{
case 1:
break;
case 2:
endposX += _state.TileSize / 2;
break;
case 3:
endposY += _state.TileSize / 2;
break;
case 4:
endposX += _state.TileSize / 2;
endposY += _state.TileSize / 2;
break;
}
var length = (int)Math.Sqrt(Math.Pow(posX - endposX, 2) + Math.Pow(posY - endposY, 2));
var height = (int)(_state.TileSize * tile.Width);
if (length > 0)
{
var innerRectangle = new Texture2D(GraphicsDevice, 1, 1);
innerRectangle.SetData(new[] { Color.White });
var angle = Math.Atan2(posY - endposY, endposX - posX);
var angleRad = -(float)angle;
_spriteBatch.Draw(innerRectangle, new Rectangle(posX, posY, length, height), null, Color.White, angleRad, new Vector2(0, 0), SpriteEffects.None, 1);
}
}
private void DrawRoom(Room tile)
{
var posX = tile.Start.X * _state.TileSize;
var posY = tile.Start.Y * _state.TileSize;
var endposX = tile.End.X * _state.TileSize;
var endposY = tile.End.Y * _state.TileSize;
switch (tile.Start.Index)
{
case 1:
break;
case 2:
posX += _state.TileSize / 2;
break;
case 3:
posY += _state.TileSize / 2;
break;
case 4:
posX += _state.TileSize / 2;
posY += _state.TileSize / 2;
break;
}
switch (tile.End.Index)
{
case 1:
break;
case 2:
endposX += _state.TileSize / 2;
break;
case 3:
endposY += _state.TileSize / 2;
break;
case 4:
endposX += _state.TileSize / 2;
endposY += _state.TileSize / 2;
break;
}
if (posX != endposX && posY != endposY)
{
var borderRectangle = new Texture2D(GraphicsDevice, 1, 1);
borderRectangle.SetData(new[] { Color.White });
if ((posX < endposX && posY < endposY))
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX, posY, endposX - posX, endposY - posY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
else if ((posX > endposX && posY > endposY))
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX, posY, endposX - posX, endposY - posY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
else
{
if (endposY < posY)
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX, endposY, endposX - posX, posY - endposY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
if (endposX < posX)
{
_spriteBatch.Draw(borderRectangle, new Rectangle(endposX, posY, posX - endposX, endposY - posY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
}
// _spriteBatch.Draw(borderRectangle, new Rectangle(posX, posY, length, height), null, Color.White, 0, new Vector2(0, _borderWidth / 2), SpriteEffects.None, 1);
}
}
Effect outlineShader; // Outline shader effect
private void DrawDelete()
{
//inner pass
foreach (var tile in _sessionData.Rooms.Values.Where(r => r.Delete))
{
// var content = Content.Load<Texture2D>($"tiles/{tile.ID}");
@ -1155,255 +1395,119 @@ DrawBorderLines();
break;
}
var length = (int)Math.Sqrt(Math.Pow(posX - endposX, 2) + Math.Pow(posY - endposY, 2));
var height = (int)(_state.TileSize * tile.Width) + _borderWidth;
if (length > 0)
{
var borderRectangle = new Texture2D(GraphicsDevice, length, height);
borderRectangle.SetData(Enumerable.Range(0, length * height).Select(i => _settings.OverlayTintColor).ToArray());
var angle = Math.Atan2(posY - endposY, endposX - posX);
var angleRad = -(float)angle;
_spriteBatch.Draw(borderRectangle, new Rectangle(posX, posY, length, height), null, Color.White, angleRad, new Vector2(0, _borderWidth / 2), SpriteEffects.None, 1);
}
}
}
private void DrawInnerLines()
{
//inner pass
foreach (var tile in _sessionData.Lines.Values)
{
// var content = Content.Load<Texture2D>($"tiles/{tile.ID}");
var posX = tile.Start.X * _state.TileSize;
var posY = tile.Start.Y * _state.TileSize;
var endposX = tile.End.X * _state.TileSize;
var endposY = tile.End.Y * _state.TileSize;
switch (tile.Start.Index)
{
case 1:
break;
case 2:
posX += _state.TileSize / 2;
break;
case 3:
posY += _state.TileSize / 2;
break;
case 4:
posX += _state.TileSize / 2;
posY += _state.TileSize / 2;
break;
}
switch (tile.End.Index)
{
case 1:
break;
case 2:
endposX += _state.TileSize / 2;
break;
case 3:
endposY += _state.TileSize / 2;
break;
case 4:
endposX += _state.TileSize / 2;
endposY += _state.TileSize / 2;
break;
}
var length = (int)Math.Sqrt(Math.Pow(posX - endposX, 2) + Math.Pow(posY - endposY, 2));
var height = (int)(_state.TileSize * tile.Width);
if (length > 0)
{
var innerRectangle = new Texture2D(GraphicsDevice, 1, 1);
innerRectangle.SetData(new[] { Color.White });
var angle = Math.Atan2(posY - endposY, endposX - posX);
var angleRad = -(float)angle;
_spriteBatch.Draw(innerRectangle, new Rectangle(posX, posY, length, height), null, Color.White, angleRad, new Vector2(0, 0), SpriteEffects.None, 1);
}
}
}
private void DrawBorderRooms()
{
// var borderRectangle = new Texture2D(GraphicsDevice, 1, 1);
// borderRectangle.SetData(new[] { _settings.OverlayTintColor });
// var innerRectangle = new Texture2D(GraphicsDevice, 1, 1);
// innerRectangle.SetData(new[] { Color.White });
// border pass
foreach (var tile in _sessionData.Rooms.Values)
{
// var content = Content.Load<Texture2D>($"tiles/{tile.ID}");
var posX = tile.Start.X * _state.TileSize;
var posY = tile.Start.Y * _state.TileSize;
var endposX = tile.End.X * _state.TileSize;
var endposY = tile.End.Y * _state.TileSize;
switch (tile.Start.Index)
{
case 1:
break;
case 2:
posX += _state.TileSize / 2;
break;
case 3:
posY += _state.TileSize / 2;
break;
case 4:
posX += _state.TileSize / 2;
posY += _state.TileSize / 2;
break;
}
switch (tile.End.Index)
{
case 1:
break;
case 2:
endposX += _state.TileSize / 2;
break;
case 3:
endposY += _state.TileSize / 2;
break;
case 4:
endposX += _state.TileSize / 2;
endposY += _state.TileSize / 2;
break;
}
// posX-=_borderWidth/2;
// posY-=_borderWidth/2;
if (posX != endposX && posY != endposY)
{
var borderRectangle = new Texture2D(GraphicsDevice, 1, 1);
borderRectangle.SetData(new [] { _settings.OverlayTintColor });
if ( (posX < endposX && posY < endposY))
borderRectangle.SetData(new[] { Color.Transparent });
if ((posX < endposX && posY < endposY))
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX, posY, endposX - posX, endposY - posY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
else if ((posX > endposX && posY > endposY))
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX, posY, endposX - posX, endposY - posY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
else
{
if (endposY < posY)
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX-_borderWidth/2, posY-_borderWidth/2, endposX - posX+_borderWidth, endposY - posY+_borderWidth), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
else if ((posX > endposX && posY > endposY) )
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX+_borderWidth/2, posY+_borderWidth/2, endposX - posX-_borderWidth, endposY - posY-_borderWidth), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
_spriteBatch.Draw(borderRectangle, new Rectangle(posX, endposY, endposX - posX, posY - endposY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
else
if (endposX < posX)
{
if (endposY < posY)
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX-_borderWidth/2, endposY-_borderWidth/2, endposX - posX+_borderWidth, posY - endposY+_borderWidth), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
if (endposX < posX)
{
_spriteBatch.Draw(borderRectangle, new Rectangle(endposX-_borderWidth/2, posY-_borderWidth/2, posX - endposX+_borderWidth, endposY - posY+_borderWidth), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
_spriteBatch.Draw(borderRectangle, new Rectangle(endposX, posY, posX - endposX, endposY - posY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
}
// _spriteBatch.Draw(borderRectangle, new Rectangle(posX, posY, length, height), null, Color.White, 0, new Vector2(0, _borderWidth / 2), SpriteEffects.None, 1);
}
}
}
private void DrawInnerRooms()
private void DrawDelete(Room tile)
{
//inner pass
foreach (var tile in _sessionData.Rooms.Values)
// var content = Content.Load<Texture2D>($"tiles/{tile.ID}");
var posX = tile.Start.X * _state.TileSize;
var posY = tile.Start.Y * _state.TileSize;
var endposX = tile.End.X * _state.TileSize;
var endposY = tile.End.Y * _state.TileSize;
switch (tile.Start.Index)
{
// var content = Content.Load<Texture2D>($"tiles/{tile.ID}");
case 1:
break;
case 2:
posX += _state.TileSize / 2;
break;
case 3:
posY += _state.TileSize / 2;
var posX = tile.Start.X * _state.TileSize;
var posY = tile.Start.Y * _state.TileSize;
break;
case 4:
posX += _state.TileSize / 2;
posY += _state.TileSize / 2;
break;
}
var endposX = tile.End.X * _state.TileSize;
var endposY = tile.End.Y * _state.TileSize;
switch (tile.End.Index)
{
case 1:
break;
case 2:
endposX += _state.TileSize / 2;
break;
case 3:
endposY += _state.TileSize / 2;
break;
case 4:
endposX += _state.TileSize / 2;
endposY += _state.TileSize / 2;
break;
}
if (posX != endposX && posY != endposY)
{
var borderRectangle = new Texture2D(GraphicsDevice, 1, 1);
borderRectangle.SetData(new[] { Color.Transparent });
if ((posX < endposX && posY < endposY))
switch (tile.Start.Index)
{
case 1:
break;
case 2:
posX += _state.TileSize / 2;
break;
case 3:
posY += _state.TileSize / 2;
break;
case 4:
posX += _state.TileSize / 2;
posY += _state.TileSize / 2;
break;
_spriteBatch.Draw(borderRectangle, new Rectangle(posX, posY, endposX - posX, endposY - posY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
else if ((posX > endposX && posY > endposY))
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX, posY, endposX - posX, endposY - posY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
switch (tile.End.Index)
else
{
case 1:
break;
case 2:
endposX += _state.TileSize / 2;
break;
case 3:
endposY += _state.TileSize / 2;
if (endposY < posY)
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX, endposY, endposX - posX, posY - endposY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
break;
case 4:
endposX += _state.TileSize / 2;
endposY += _state.TileSize / 2;
break;
if (endposX < posX)
{
_spriteBatch.Draw(borderRectangle, new Rectangle(endposX, posY, posX - endposX, endposY - posY), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
}
if (posX != endposX && posY != endposY)
{
var borderRectangle = new Texture2D(GraphicsDevice, 1, 1);
borderRectangle.SetData(new [] {Color.White });
if ( (posX < endposX && posY < endposY))
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX , posY , endposX - posX , endposY - posY ), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
else if ((posX > endposX && posY > endposY) )
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX , posY , endposX - posX , endposY - posY ), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
else
{
if (endposY < posY)
{
_spriteBatch.Draw(borderRectangle, new Rectangle(posX, endposY, endposX - posX , posY - endposY ), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
if (endposX < posX)
{
_spriteBatch.Draw(borderRectangle, new Rectangle(endposX , posY , posX - endposX , endposY - posY ), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1);
}
}
// _spriteBatch.Draw(borderRectangle, new Rectangle(posX, posY, length, height), null, Color.White, 0, new Vector2(0, _borderWidth / 2), SpriteEffects.None, 1);
}
// _spriteBatch.Draw(borderRectangle, new Rectangle(posX, posY, length, height), null, Color.White, 0, new Vector2(0, _borderWidth / 2), SpriteEffects.None, 1);
}
}

View File

@ -44,12 +44,13 @@
<PackageReference Include="AsyncAwaitBestPractices" Version="5.0.2" />
<PackageReference Include="exceptionless" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="MonoGame.Extended" Version="3.8.0" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client">
<Version>5.0.0</Version>
</PackageReference>
<PackageReference Include="Myra" Version="1.0.3.213" />
<PackageReference Include="Myra" Version="1.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="polly" Version="7.2.1" />
<PackageReference Include="polly.extensions.http" Version="3.0.0" />

View File

@ -1,14 +1,18 @@
/* Generated by MyraPad at 21/12/2020 21:54:47 */
/* Generated by MyraPad at 07/01/2021 22:44:41 */
using Myra;
using Myra.Graphics2D;
using Myra.Graphics2D.TextureAtlases;
using Myra.Graphics2D.UI;
using Myra.Graphics2D.Brushes;
#if !STRIDE
#if MONOGAME || FNA
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
#else
#elif STRIDE
using Stride.Core.Mathematics;
#else
using System.Drawing;
using System.Numerics;
#endif
namespace Sledgemapper.UI
@ -131,7 +135,7 @@ namespace Sledgemapper.UI
BtnToolbarTile.Id = "BtnToolbarTile";
BtnToolbarLine = new ImageTextButton();
BtnToolbarLine.Text = " L";
BtnToolbarLine.Text = " C";
BtnToolbarLine.Width = 40;
BtnToolbarLine.Height = 40;
BtnToolbarLine.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
@ -151,18 +155,28 @@ namespace Sledgemapper.UI
BtnToolbarRoom.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
BtnToolbarRoom.Id = "BtnToolbarRoom";
BtnToolbarDelete = new ImageTextButton();
BtnToolbarDelete.Text = " D";
BtnToolbarDelete.Width = 40;
BtnToolbarDelete.Height = 40;
BtnToolbarDelete.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
BtnToolbarDelete.Id = "BtnToolbarDelete";
var horizontalStackPanel1 = new HorizontalStackPanel();
horizontalStackPanel1.Spacing = 5;
horizontalStackPanel1.Proportions.Add(new Proportion
{
Type = Myra.Graphics2D.UI.ProportionType.Auto,
});
horizontalStackPanel1.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Top;
horizontalStackPanel1.Height = 50;
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);
GridTiles = new Grid();
GridTiles.ColumnSpacing = 8;
@ -330,6 +344,7 @@ namespace Sledgemapper.UI
public ImageTextButton BtnToolbarLine;
public ImageTextButton BtnToolbarWall;
public ImageTextButton BtnToolbarRoom;
public ImageTextButton BtnToolbarDelete;
public Grid GridTiles;
public Grid GridWalls;
public Grid GridOverlays;
@ -337,4 +352,4 @@ namespace Sledgemapper.UI
public Label lblUsername;
public Label lblSessionName;
}
}
}

View File

@ -32,14 +32,15 @@
<MenuItem Text="&amp;About" Id="MenuHelpAbout" />
</MenuItem>
</HorizontalMenu>
<HorizontalStackPanel Spacing="5" VerticalAlignment="Top" Height="50">
<HorizontalStackPanel Spacing="5" VerticalAlignment="Center" Height="51" Padding="4, 0, 0, 0" Background="#404040FF">
<HorizontalStackPanel.Proportions>
<Proportion Type="Auto" />
</HorizontalStackPanel.Proportions>
<ImageTextButton Text=" T" Width="40" Height="40" VerticalAlignment="Center" Id="BtnToolbarTile" />
<ImageTextButton Text=" L" Width="40" Height="40" VerticalAlignment="Center" Id="BtnToolbarLine" />
<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" />
</HorizontalStackPanel>
<VerticalSplitPane Width="200" Background="#A1A1A1FF">
<VerticalStackPanel>