Created
July 19, 2017 18:31
-
-
Save anonymous/eb3eb4f14e9aeb16ffe5eb04c5575bc4 to your computer and use it in GitHub Desktop.
ScreenAdapter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Microsoft.Xna.Framework; | |
using Microsoft.Xna.Framework.Graphics; | |
using Microsoft.Xna.Framework.Content; | |
using System.Threading.Tasks; | |
namespace Pharmakon | |
{ | |
class ScreenAdapter | |
{ | |
static public Rectangle safe_bounds; | |
static public Rectangle safe_ui; | |
static public float supported_w; | |
static public float supported_h; | |
static public bool fullscreen = true; | |
static public float offset; | |
public ScreenAdapter(GraphicsDeviceManager screen) | |
{ | |
screen.HardwareModeSwitch = false; | |
supported_w = 1366; | |
supported_h = 768; | |
if (fullscreen == true) | |
{ | |
screen.PreferredBackBufferWidth = (int)supported_w; | |
screen.PreferredBackBufferHeight = (int)supported_h; | |
screen.IsFullScreen = true; | |
} | |
if (fullscreen == false) | |
{ | |
screen.PreferredBackBufferWidth = (int)supported_w; | |
screen.PreferredBackBufferHeight = (int)supported_h; | |
screen.IsFullScreen = false; | |
} | |
safe_bounds = new Rectangle(0, 0, screen.PreferredBackBufferWidth, screen.PreferredBackBufferHeight); | |
float marge_factor = (float)supported_w / 30; | |
float marge = (float)screen.PreferredBackBufferWidth / marge_factor; | |
marge = (int)marge; | |
float offset_factor = (float)supported_w / 400; | |
offset = screen.PreferredBackBufferWidth / offset_factor; | |
offset = (int)offset; | |
safe_ui = new Rectangle(safe_bounds.X + 15, safe_bounds.Y + 15, safe_bounds.Width - (int)marge, safe_bounds.Height - (int)marge); | |
screen.ApplyChanges(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment