mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 18:46:43 +00:00
Add border even when in windowed mode
This commit is contained in:
parent
fd8b38932b
commit
4c78f8afff
1 changed files with 24 additions and 4 deletions
|
@ -23,6 +23,7 @@ using Capy64.Runtime;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using MonoGame.Extended;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -92,7 +93,7 @@ public class Capy64 : Game, IGame
|
||||||
if (resize)
|
if (resize)
|
||||||
{
|
{
|
||||||
_graphics.PreferredBackBufferWidth = (int)(Width * Scale) + Borders.Left + Borders.Right;
|
_graphics.PreferredBackBufferWidth = (int)(Width * Scale) + Borders.Left + Borders.Right;
|
||||||
_graphics.PreferredBackBufferHeight = (int)(Height * Scale) + Borders.Top + Borders.Right;
|
_graphics.PreferredBackBufferHeight = (int)(Height * Scale) + Borders.Top + Borders.Bottom;
|
||||||
_graphics.ApplyChanges();
|
_graphics.ApplyChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +108,6 @@ public class Capy64 : Game, IGame
|
||||||
Drawing.Canvas = renderTarget;
|
Drawing.Canvas = renderTarget;
|
||||||
|
|
||||||
_inputManager.Texture = renderTarget;
|
_inputManager.Texture = renderTarget;
|
||||||
_inputManager.WindowScale = Scale;
|
|
||||||
|
|
||||||
EventEmitter.RaiseScreenSizeChange();
|
EventEmitter.RaiseScreenSizeChange();
|
||||||
}
|
}
|
||||||
|
@ -129,19 +129,34 @@ public class Capy64 : Game, IGame
|
||||||
|
|
||||||
Borders.Left = (int)Math.Floor(horizontal / 2d);
|
Borders.Left = (int)Math.Floor(horizontal / 2d);
|
||||||
Borders.Right = (int)Math.Ceiling(horizontal / 2d);
|
Borders.Right = (int)Math.Ceiling(horizontal / 2d);
|
||||||
|
|
||||||
|
UpdateSize(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Borders = new Borders();
|
ResetBorder();
|
||||||
|
UpdateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateSize(false);
|
}
|
||||||
|
|
||||||
|
private void ResetBorder()
|
||||||
|
{
|
||||||
|
var size = (int)(Scale * 1.5);
|
||||||
|
Borders = new Borders
|
||||||
|
{
|
||||||
|
Top = size,
|
||||||
|
Bottom = size,
|
||||||
|
Left = size,
|
||||||
|
Right = size
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
{
|
{
|
||||||
Window.Title = "Capy64 " + Version;
|
Window.Title = "Capy64 " + Version;
|
||||||
|
|
||||||
|
ResetBorder();
|
||||||
UpdateSize();
|
UpdateSize();
|
||||||
|
|
||||||
Window.AllowUserResizing = true;
|
Window.AllowUserResizing = true;
|
||||||
|
@ -205,6 +220,11 @@ public class Capy64 : Game, IGame
|
||||||
protected override void Draw(GameTime gameTime)
|
protected override void Draw(GameTime gameTime)
|
||||||
{
|
{
|
||||||
SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp);
|
SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp);
|
||||||
|
GraphicsDevice.Clear(new Color(0x11, 0x11, 0x11));
|
||||||
|
|
||||||
|
SpriteBatch.DrawRectangle(renderTarget.Bounds.Location.ToVector2() + new Vector2(Borders.Left, Borders.Top),
|
||||||
|
new Size2(renderTarget.Bounds.Width * Scale, renderTarget.Bounds.Height * Scale), Color.Black, Math.Min(renderTarget.Bounds.Width, renderTarget.Bounds.Height), 0);
|
||||||
|
|
||||||
SpriteBatch.Draw(renderTarget, new(Borders.Left, Borders.Top), null, Color.White, 0f, Vector2.Zero, Scale, SpriteEffects.None, 0);
|
SpriteBatch.Draw(renderTarget, new(Borders.Left, Borders.Top), null, Color.White, 0f, Vector2.Zero, Scale, SpriteEffects.None, 0);
|
||||||
|
|
||||||
EventEmitter.RaiseOverlay(new()
|
EventEmitter.RaiseOverlay(new()
|
||||||
|
|
Loading…
Reference in a new issue