From 319ade258e12bb8909a24fdb0888d349d5dc492f Mon Sep 17 00:00:00 2001 From: Harrison Date: Sun, 5 Jul 2020 23:45:04 -0500 Subject: [PATCH] Refactoring. --- .../Graphics/{Render => }/Camera.cs | 3 ++- .../Graphics/{Render => }/Camera2D.cs | 2 +- src/SlatedGameToolkit.Framework/Graphics/Text/BitmapFont.cs | 2 +- .../Graphics/Window/WindowContext.cs | 2 +- .../Utilities/Playground/MainState.cs | 5 +---- 5 files changed, 6 insertions(+), 8 deletions(-) rename src/SlatedGameToolkit.Framework/Graphics/{Render => }/Camera.cs (98%) rename src/SlatedGameToolkit.Framework/Graphics/{Render => }/Camera2D.cs (93%) diff --git a/src/SlatedGameToolkit.Framework/Graphics/Render/Camera.cs b/src/SlatedGameToolkit.Framework/Graphics/Camera.cs similarity index 98% rename from src/SlatedGameToolkit.Framework/Graphics/Render/Camera.cs rename to src/SlatedGameToolkit.Framework/Graphics/Camera.cs index 6b99d80..cbd9162 100644 --- a/src/SlatedGameToolkit.Framework/Graphics/Render/Camera.cs +++ b/src/SlatedGameToolkit.Framework/Graphics/Camera.cs @@ -1,8 +1,9 @@ using System; using System.Numerics; +using SlatedGameToolkit.Framework.Graphics.Render; using SlatedGameToolkit.Framework.Utilities; -namespace SlatedGameToolkit.Framework.Graphics.Render +namespace SlatedGameToolkit.Framework.Graphics { public class Camera : IMoveable { private bool viewUpdated = true, projectionUpdated = true, orthographic = false; diff --git a/src/SlatedGameToolkit.Framework/Graphics/Render/Camera2D.cs b/src/SlatedGameToolkit.Framework/Graphics/Camera2D.cs similarity index 93% rename from src/SlatedGameToolkit.Framework/Graphics/Render/Camera2D.cs rename to src/SlatedGameToolkit.Framework/Graphics/Camera2D.cs index b6cd20b..4fd0b4c 100644 --- a/src/SlatedGameToolkit.Framework/Graphics/Render/Camera2D.cs +++ b/src/SlatedGameToolkit.Framework/Graphics/Camera2D.cs @@ -1,6 +1,6 @@ using System.Numerics; -namespace SlatedGameToolkit.Framework.Graphics.Render +namespace SlatedGameToolkit.Framework.Graphics { public class Camera2D : Camera { public new Vector2 Position { diff --git a/src/SlatedGameToolkit.Framework/Graphics/Text/BitmapFont.cs b/src/SlatedGameToolkit.Framework/Graphics/Text/BitmapFont.cs index e197c2d..9e77ed2 100644 --- a/src/SlatedGameToolkit.Framework/Graphics/Text/BitmapFont.cs +++ b/src/SlatedGameToolkit.Framework/Graphics/Text/BitmapFont.cs @@ -124,7 +124,7 @@ namespace SlatedGameToolkit.Framework.Graphics.Text CharacterMetrics metrics = metricsCache.ComputeIfNonExistent(c, (p) => new CharacterMetrics(glyphIndex, info)); //Check if glyph is loaded, if not, throw exception. if (!glyphTexLocations.ContainsKey((c, scale)) || !textures[glyphTexLocations[(c, scale)]].ContainsChar(c, scale)) { - throw new FrameworkUsageException(string.Format("Character \'{0}\' was not prepared and is missing!", c)); + throw new FrameworkUsageException(string.Format("Character \'{0}\' at pixel height {1} was not prepared and is missing!", c, PixelHeight)); } FontTexture texture = textures[glyphTexLocations[(c, scale)]]; diff --git a/src/SlatedGameToolkit.Framework/Graphics/Window/WindowContext.cs b/src/SlatedGameToolkit.Framework/Graphics/Window/WindowContext.cs index 1a95d8c..cd93b0b 100644 --- a/src/SlatedGameToolkit.Framework/Graphics/Window/WindowContext.cs +++ b/src/SlatedGameToolkit.Framework/Graphics/Window/WindowContext.cs @@ -257,7 +257,7 @@ namespace SlatedGameToolkit.Framework.Graphics.Window /// Instantiates a window with the given OpenGL context, or a new context. /// public WindowContext(string title, int x = -1, int y = -1, int width = 640, int height = 480, bool specialRegions = false, SDL.SDL_WindowFlags options = default(SDL.SDL_WindowFlags)) { - Logger.Log(String.Format("Starting openGL window with title \"{0}\"", title)); + Logger.Log(String.Format("Starting openGL window with title \"{0}\"", title), LogLevel.DEBUG); windowHandle = SDL.SDL_CreateWindow(title, x < 0 ? SDL.SDL_WINDOWPOS_CENTERED : x, y < 0 ? SDL.SDL_WINDOWPOS_CENTERED : y, width, height, SDL.SDL_WindowFlags.SDL_WINDOW_INPUT_FOCUS | SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL | SDL.SDL_WindowFlags.SDL_WINDOW_MOUSE_FOCUS | options); if (windowHandle == null) { throw new SDLException(); diff --git a/src/SlatedGameToolkit.Tools/Utilities/Playground/MainState.cs b/src/SlatedGameToolkit.Tools/Utilities/Playground/MainState.cs index a80abe1..ef4cc87 100644 --- a/src/SlatedGameToolkit.Tools/Utilities/Playground/MainState.cs +++ b/src/SlatedGameToolkit.Tools/Utilities/Playground/MainState.cs @@ -1,8 +1,5 @@ -using System; using System.Drawing; -using System.IO; using System.Numerics; -using System.Runtime.InteropServices; using SDL2; using SlatedGameToolkit.Framework.Loaders; using SlatedGameToolkit.Framework.Graphics.Render; @@ -12,7 +9,7 @@ using SlatedGameToolkit.Framework.Graphics.Window; using SlatedGameToolkit.Framework.Input.Devices; using SlatedGameToolkit.Framework.StateSystem; using SlatedGameToolkit.Framework.StateSystem.States; -using StbTrueTypeSharp; +using SlatedGameToolkit.Framework.Graphics; namespace SlatedGameToolkit.Tools.Utilities.Playground {