backward compatible small fixes

This commit is contained in:
Michele 2021-01-18 10:05:40 +00:00
parent 70abe86ae3
commit 5c0608c537
4 changed files with 58 additions and 81 deletions

View File

@ -97,7 +97,7 @@ namespace Sledgemapper
private void ResetRenderTarget()
{
rendertarget = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.DiscardContents);
rendertarget = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.DiscardContents);
}
@ -106,7 +106,7 @@ namespace Sledgemapper
rendertarget?.Dispose();
try
{
ResetRenderTarget();
ResetRenderTarget();
// rendertarget = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, true, SurfaceFormat.Alpha8, DepthFormat.Depth16, 0, RenderTargetUsage.DiscardContents);
//rendertarget = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
@ -171,9 +171,9 @@ ResetRenderTarget();
_mainWidget.BtnToolbarTile.Visible=false;
_mainWidget.BtnToolbarWall.Visible=false;
AddItemToToolGrid(_mainWidget.GridWalls, OnWallButtonClicked, "walls");
_mainWidget.BtnToolbarTile.Visible = false;
_mainWidget.BtnToolbarWall.Visible = false;
AddItemToToolGrid(_mainWidget.GridWalls, OnWallButtonClicked, "walls");
AddItemToToolGrid(_mainWidget.GridOverlays, OnOverlayButtonClicked, "overlays");
_fonts = Content.LoadContentFolder<SpriteFont>("fonts");
@ -508,6 +508,9 @@ ResetRenderTarget();
switch (_state.InsertMode)
{
case InsertMode.Tile:
case InsertMode.NewRoom:
case InsertMode.NewLine:
case InsertMode.NewDelete:
_state.SelectedTile.X = _state.HoveredTile.X;
_state.SelectedTile.Y = _state.HoveredTile.Y;
_sessionData.DeleteTile(_state.SelectedTile);
@ -590,8 +593,8 @@ ResetRenderTarget();
_spriteBatch.Begin(depthStencilState: DepthStencilState.None,
transformMatrix: Matrix.CreateTranslation(_viewportCenter),
blendState: BlendState.Opaque,
//rasterizerState:RasterizerState.CullClockwise,
samplerState:SamplerState.PointClamp,
//rasterizerState:RasterizerState.CullClockwise,
samplerState: SamplerState.PointClamp,
sortMode: SpriteSortMode.Deferred);
@ -624,14 +627,14 @@ ResetRenderTarget();
GraphicsDevice.SetRenderTarget(null);
Vector2 texelSize = new Vector2((float)rendertarget.Width, (float)rendertarget.Height);
Vector2 texelSize = new Vector2((float)rendertarget.Width, (float)rendertarget.Height);
outlineShader.Parameters["ImageSize"].SetValue(texelSize);
outlineShader.Parameters["BorderSize"].SetValue((int)(_state.TileSize / 100f *10f));
outlineShader.Parameters["BorderSize"].SetValue((int)(_state.TileSize / 100f * 10f));
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);
// outlineShader2.Parameters["ScreenSize"].SetValue(texelSize);
// outlineShader2.Parameters["ScreenSize"].SetValue(texelSize);
_spriteBatch.Begin(
effect: outlineShader,
blendState: BlendState.NonPremultiplied,
@ -643,7 +646,7 @@ ResetRenderTarget();
_spriteBatch.Begin(
transformMatrix: Matrix.CreateTranslation(_viewportCenter),
sortMode: SpriteSortMode.Deferred);
DrawTiles();
DrawWalls();
DrawOverlays();
DrawNotes();
@ -1164,33 +1167,46 @@ ResetRenderTarget();
// }
// border pass
foreach (var tile in _sessionData.Map.Values)
{
var content = Content.Load<Texture2D>($"tiles/{tile.ID}");
// foreach (var tile in _sessionData.Map.Values)
// {
// var content = Content.Load<Texture2D>($"tiles/{tile.ID}");
var posX = tile.X * _state.TileSize;
var posY = tile.Y * _state.TileSize;
// var posX = tile.X * _state.TileSize;
// var posY = tile.Y * _state.TileSize;
var whiteRectangle = new Texture2D(GraphicsDevice, 1, 1);
whiteRectangle.SetData(new[] { _settings.OverlayTintColor });
// var whiteRectangle = new Texture2D(GraphicsDevice, 1, 1);
// 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.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);
// }
//inner pass
// foreach (var tile in _sessionData.Map.Values)
// {
// var content = Content.Load<Texture2D>($"tiles/{tile.ID}");
// var posX = tile.X * _state.TileSize;
// var posY = tile.Y * _state.TileSize;
// var whiteRectangle = new Texture2D(GraphicsDevice, 1, 1);
// 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);
// }
foreach (var tile in _sessionData.Map.Values)
{
var content = Content.Load<Texture2D>($"tiles/{tile.ID}");
var posX = tile.X * _state.TileSize;
var posY = tile.Y * _state.TileSize;
var posX = tile.X * _state.TileSize + _state.TileSize / 2f;
var posY = tile.Y * _state.TileSize + _state.TileSize / 2f;
var whiteRectangle = new Texture2D(GraphicsDevice, 1, 1);
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.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 DrawLine(Line tile)
{
@ -1329,10 +1345,10 @@ ResetRenderTarget();
var endposX = tile.End.X * _state.TileSize;
var endposY = tile.End.Y * _state.TileSize;
var ww = _state.TileSize / _settings.TileDeleteDivider;
if (posX == endposX) { endposX += ww; posX -= ww; }
if (posY == endposY) { endposY += ww; posY -= ww; }
var ww = _state.TileSize / _settings.TileDeleteDivider;
if (posX == endposX) { endposX += ww; posX -= ww; }
if (posY == endposY) { endposY += ww; posY -= ww; }
switch (tile.Start.Index)
{
case 1:

View File

@ -6,7 +6,6 @@ namespace Sledgemapper.UI
{
public void ClearSelection()
{
ClearSelection(GridTiles);
ClearSelection(GridWalls);
ClearSelection(GridOverlays);
}

View File

@ -1,4 +1,4 @@
/* Generated by MyraPad at 07/01/2021 22:44:41 */
/* Generated by MyraPad at 18/01/2021 09:38:43 */
using Myra;
using Myra.Graphics2D;
using Myra.Graphics2D.TextureAtlases;
@ -178,31 +178,6 @@ namespace Sledgemapper.UI
horizontalStackPanel1.Widgets.Add(BtnToolbarRoom);
horizontalStackPanel1.Widgets.Add(BtnToolbarDelete);
GridTiles = new Grid();
GridTiles.ColumnSpacing = 8;
GridTiles.RowSpacing = 8;
GridTiles.DefaultColumnProportion = new Proportion
{
Type = Myra.Graphics2D.UI.ProportionType.Pixels,
Value = 40,
};
GridTiles.DefaultRowProportion = new Proportion
{
Type = Myra.Graphics2D.UI.ProportionType.Pixels,
Value = 40,
};
GridTiles.Id = "GridTiles";
var scrollViewer1 = new ScrollViewer();
scrollViewer1.Content = GridTiles;
var verticalStackPanel1 = new VerticalStackPanel();
verticalStackPanel1.Proportions.Add(new Proportion
{
Type = Myra.Graphics2D.UI.ProportionType.Fill,
});
verticalStackPanel1.Widgets.Add(scrollViewer1);
GridWalls = new Grid();
GridWalls.ColumnSpacing = 8;
GridWalls.RowSpacing = 8;
@ -218,15 +193,15 @@ namespace Sledgemapper.UI
};
GridWalls.Id = "GridWalls";
var scrollViewer2 = new ScrollViewer();
scrollViewer2.Content = GridWalls;
var scrollViewer1 = new ScrollViewer();
scrollViewer1.Content = GridWalls;
var verticalStackPanel2 = new VerticalStackPanel();
verticalStackPanel2.Proportions.Add(new Proportion
var verticalStackPanel1 = new VerticalStackPanel();
verticalStackPanel1.Proportions.Add(new Proportion
{
Type = Myra.Graphics2D.UI.ProportionType.Fill,
});
verticalStackPanel2.Widgets.Add(scrollViewer2);
verticalStackPanel1.Widgets.Add(scrollViewer1);
GridOverlays = new Grid();
GridOverlays.ColumnSpacing = 8;
@ -243,22 +218,21 @@ namespace Sledgemapper.UI
};
GridOverlays.Id = "GridOverlays";
var scrollViewer3 = new ScrollViewer();
scrollViewer3.Content = GridOverlays;
var scrollViewer2 = new ScrollViewer();
scrollViewer2.Content = GridOverlays;
var verticalStackPanel3 = new VerticalStackPanel();
verticalStackPanel3.Proportions.Add(new Proportion
var verticalStackPanel2 = new VerticalStackPanel();
verticalStackPanel2.Proportions.Add(new Proportion
{
Type = Myra.Graphics2D.UI.ProportionType.Fill,
});
verticalStackPanel3.Widgets.Add(scrollViewer3);
verticalStackPanel2.Widgets.Add(scrollViewer2);
var verticalSplitPane1 = new VerticalSplitPane();
verticalSplitPane1.Width = 200;
verticalSplitPane1.Background = new SolidBrush("#A1A1A1FF");
verticalSplitPane1.Widgets.Add(verticalStackPanel1);
verticalSplitPane1.Widgets.Add(verticalStackPanel2);
verticalSplitPane1.Widgets.Add(verticalStackPanel3);
var label1 = new Label();
label1.Text = "Connection status:";
@ -345,7 +319,6 @@ namespace Sledgemapper.UI
public ImageTextButton BtnToolbarWall;
public ImageTextButton BtnToolbarRoom;
public ImageTextButton BtnToolbarDelete;
public Grid GridTiles;
public Grid GridWalls;
public Grid GridOverlays;
public Label lblConnectionStatus;

View File

@ -43,17 +43,6 @@
<ImageTextButton Text=" D" Width="40" Height="40" 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="GridTiles">
<Grid.DefaultColumnProportion Type="Pixels" Value="40" />
<Grid.DefaultRowProportion Type="Pixels" Value="40" />
</Grid>
</ScrollViewer>
</VerticalStackPanel>
<VerticalStackPanel>
<VerticalStackPanel.Proportions>
<Proportion Type="Fill" />