From d3f88982560d68528a5e73e9580e90ceb419c52a Mon Sep 17 00:00:00 2001 From: shykeiichi Date: Wed, 2 Aug 2023 19:47:59 +0200 Subject: [PATCH] Updated Fjord to use modern C# naming conventions --- Libraries/SDL2-CS | 2 +- src/Debug/ConsoleScene.cs | 8 ++-- src/Debug/Debug.cs | 2 +- src/Debug/InspectorScene.cs | 2 +- src/Debug/OldInspectorScene.cs | 4 +- src/Debug/PerformanceScene.cs | 8 ++-- src/Entity/Component.cs | 2 +- src/GameManager.cs | 44 +++++++---------- src/Graphics/Font.cs | 7 +-- src/Graphics/Graphics.cs | 4 +- src/Scenes/Camera.cs | 2 +- src/Scenes/Scene.cs | 87 ++++++++++------------------------ src/Scenes/SceneHandler.cs | 13 ++--- src/Ui/Builder.cs | 10 ++-- src/Ui/Ui.cs | 79 ++++++++++++------------------ 15 files changed, 103 insertions(+), 171 deletions(-) diff --git a/Libraries/SDL2-CS b/Libraries/SDL2-CS index 2d6d50c..6862b80 160000 --- a/Libraries/SDL2-CS +++ b/Libraries/SDL2-CS @@ -1 +1 @@ -Subproject commit 2d6d50cd00c32c00b1698eff9fee6fe3d9aef41f +Subproject commit 6862b80e50cf44fe653dc7b8ec9add328425a4bc diff --git a/src/Debug/ConsoleScene.cs b/src/Debug/ConsoleScene.cs index 7630337..2af25b4 100644 --- a/src/Debug/ConsoleScene.cs +++ b/src/Debug/ConsoleScene.cs @@ -16,8 +16,8 @@ public class ConsoleScene : Scene public ConsoleScene(int width, int height, string id) : base(width, height, id) { - SetClearColor(UiStyles.Background); - SetUpdateOnlyIfActive(true); + ClearColor = UiStyles.Background; + UpdateOnlyIfActive = true; } public override void Update() @@ -133,7 +133,7 @@ void HandleCurrentWord() logsLength = Debug.Logs.Count; - FUI.OverrideMousePosition(Mouse.Position); + FUI.OverMousePosition = Mouse.Position; float height = 0; if(consoleInput != "" && Debug.commands.Keys.ToList().Where((command) => command == consoleInput).ToList().Count != 1 ) @@ -177,6 +177,6 @@ void HandleCurrentWord() scrollYOffset = scrollY - Mouse.Position.Y; }); } - FUI.ResetMousePosition(); + FUI.OverMousePosition = null; } } \ No newline at end of file diff --git a/src/Debug/Debug.cs b/src/Debug/Debug.cs index 3ed0af1..9e5fe24 100644 --- a/src/Debug/Debug.cs +++ b/src/Debug/Debug.cs @@ -130,7 +130,7 @@ public static void Initialize() if(args.Length > 0) { if(args[0].GetType() == typeof(float)) { Debug.Log(args[0].GetType()); - Game.SetMaxFPS((double)((float)args[0])); + Game.FPSMax = (double)((float)args[0]); } else { Debug.Log(LogLevel.Warning, $"Argument must be number"); } diff --git a/src/Debug/InspectorScene.cs b/src/Debug/InspectorScene.cs index 720b78c..ff15bde 100644 --- a/src/Debug/InspectorScene.cs +++ b/src/Debug/InspectorScene.cs @@ -14,7 +14,7 @@ public class InspectorScene : Scene public InspectorScene(int width, int height, string id) : base(width, height, id) { - SetClearColor(UiStyles.Background); + ClearColor = UiStyles.Background; // SetUpdateOnlyIfActive(true); } diff --git a/src/Debug/OldInspectorScene.cs b/src/Debug/OldInspectorScene.cs index 85f99e2..43fd54b 100644 --- a/src/Debug/OldInspectorScene.cs +++ b/src/Debug/OldInspectorScene.cs @@ -13,8 +13,8 @@ public class OldInspectorScene : Scene public OldInspectorScene(int width, int height, string id) : base(width, height, id) { - SetClearColor(UiStyles.Background); - SetUpdateOnlyIfActive(true); + ClearColor = UiStyles.Background; + UpdateOnlyIfActive = true; } public override void Update() diff --git a/src/Debug/PerformanceScene.cs b/src/Debug/PerformanceScene.cs index 5d870e3..93f554e 100644 --- a/src/Debug/PerformanceScene.cs +++ b/src/Debug/PerformanceScene.cs @@ -32,7 +32,7 @@ public PerformanceScene(int width, int height, string id) : base(width, height, public override void Awake() { - SetClearColor(UiStyles.Background); + ClearColor = UiStyles.Background; } public override void Update() @@ -41,9 +41,9 @@ public override void Update() { setFps = SDL_GetTicks64(); - InputFPS = Game.inputFPS; - UpdateFPS = Game.updateFPS; - ProgramFPS = Game.programFPS; + InputFPS = Game.InputFPS; + UpdateFPS = Game.UpdateFPS; + ProgramFPS = Game.ProgramFPS; recentInputFPS.Add(InputFPS); recentProgramFPS.Add(ProgramFPS); diff --git a/src/Entity/Component.cs b/src/Entity/Component.cs index 8cb6193..918600d 100644 --- a/src/Entity/Component.cs +++ b/src/Entity/Component.cs @@ -14,7 +14,7 @@ public float DeltaTime { get { - return (float)Game.GetDeltaTime(); + return (float)Game.DeltaTime; } private set { diff --git a/src/GameManager.cs b/src/GameManager.cs index 7d25d66..d7eefec 100644 --- a/src/GameManager.cs +++ b/src/GameManager.cs @@ -23,16 +23,16 @@ public static class Game internal static bool Running = true; - private static ulong timeNow = 0; - private static ulong timeLast = 0; - private static double deltaTime = 0.0; + private static ulong _timeNow = 0; + private static ulong _timeLast = 0; + public static double DeltaTime { internal set; get; } = 0.0; - internal static float inputFPS = 0; - internal static float updateFPS = 0; - internal static float programFPS = 0; + internal static float InputFPS = 0; + internal static float UpdateFPS = 0; + internal static float ProgramFPS = 0; - private static double FPSCapLast = 0; - private static double FPSMax = 144; + private static double _fpsCapLast = 0; + public static double FPSMax = 144; public static void Initialize(string title, int width, int height) { @@ -98,15 +98,15 @@ public static void Run() while (Running) { var FPSCapNow = SDL_GetTicks64(); - var FPSCapDelta = FPSCapNow - FPSCapLast; + var FPSCapDelta = FPSCapNow - _fpsCapLast; if(FPSCapDelta > 1000/FPSMax) { - timeNow = SDL_GetPerformanceCounter(); - deltaTime = ((timeNow - timeLast)*1000 / (double)SDL_GetPerformanceFrequency()) * 0.001; - timeLast = timeNow; + _timeNow = SDL_GetPerformanceCounter(); + DeltaTime = ((_timeNow - _timeLast)*1000 / (double)SDL_GetPerformanceFrequency()) * 0.001; + _timeLast = _timeNow; - FPSCapLast = FPSCapNow; + _fpsCapLast = FPSCapNow; ulong programStart = SDL_GetPerformanceCounter(); @@ -123,13 +123,13 @@ public static void Run() var elapsed = (inputEnd - inputStart) / (float)SDL_GetPerformanceFrequency(); - inputFPS = 1f / elapsed; + InputFPS = 1f / elapsed; elapsed = (updateEnd - updateStart) / (float)SDL_GetPerformanceFrequency(); - updateFPS = 1f / elapsed; + UpdateFPS = 1f / elapsed; elapsed = (programEnd - programStart) / (float)SDL_GetPerformanceFrequency(); - programFPS = 1f / elapsed; + ProgramFPS = 1f / elapsed; for (var i = 0; i < GlobalKeyboard.downKeys.Length; i++) { @@ -155,16 +155,6 @@ public static void Run() } } - public static float GetDeltaTime() - { - return (float)deltaTime; - } - - public static void SetMaxFPS(double FPS) - { - FPSMax = FPS; - } - public static void Update() { SDL_GetWindowSize(SDLWindow, out Window.Width, out Window.Height); @@ -172,7 +162,7 @@ public static void Update() SDL_SetRenderDrawColor(SDLRenderer, 0, 0, 0, 255); SDL_RenderClear(SDLRenderer); - foreach (string id in SceneHandler.GetLoadedScenes()) + foreach (string id in SceneHandler.LoadedScenes) { try { SceneHandler.Scenes[id].UpdateCall(); diff --git a/src/Graphics/Font.cs b/src/Graphics/Font.cs index 9ac2001..d849b58 100644 --- a/src/Graphics/Font.cs +++ b/src/Graphics/Font.cs @@ -10,12 +10,7 @@ public static class Font internal static Dictionary Fonts = new (); internal static Dictionary FontCache = new(); - internal static string DefaultFont = "segoeui.ttf"; - - public static string GetDefaultFont() - { - return DefaultFont; - } + public static string DefaultFont { internal set; get; } = "segoeui.ttf"; public static void Initialize() { diff --git a/src/Graphics/Graphics.cs b/src/Graphics/Graphics.cs index 97a224d..d2a510f 100644 --- a/src/Graphics/Graphics.cs +++ b/src/Graphics/Graphics.cs @@ -407,9 +407,9 @@ internal static void LineDirect(Line line) // drawInsClone.color *= (drawIns.hoverAnimation.colorDriver(drawIns.hoverAnimation.progress) + 1); if(sceneId == null ? Helpers.PointDistance(GlobalMouse.Position, drawInsClone.position) < drawInsClone.radius : Helpers.PointDistance(SceneHandler.Scenes[sceneId].Mouse.Position, drawInsClone.position) < drawInsClone.radius) { if(drawIns.hoverAnimation.progress < 1) - drawIns.hoverAnimation.progress += drawIns.hoverAnimation.speed * (float)Game.GetDeltaTime(); + drawIns.hoverAnimation.progress += drawIns.hoverAnimation.speed * (float)Game.DeltaTime; } else if(drawIns.hoverAnimation.progress > 0) { - drawIns.hoverAnimation.progress -= drawIns.hoverAnimation.speed * (float)Game.GetDeltaTime(); + drawIns.hoverAnimation.progress -= drawIns.hoverAnimation.speed * (float)Game.DeltaTime; if(drawIns.hoverAnimation.progress < 0) drawIns.hoverAnimation.progress = 0; } diff --git a/src/Scenes/Camera.cs b/src/Scenes/Camera.cs index 5f50ab3..60bbd89 100644 --- a/src/Scenes/Camera.cs +++ b/src/Scenes/Camera.cs @@ -52,7 +52,7 @@ public void Update(Vector2 WindowSize) ((float)(random.NextDouble() - 0.5) * CameraShakeIntensity) * (CameraShakeLife / CameraShakeLifeMax) ) ); - CameraShakeLife -= 100 * Game.GetDeltaTime(); + CameraShakeLife -= 100 * (float)Game.DeltaTime; } else { Offset = CoreOffset; diff --git a/src/Scenes/Scene.cs b/src/Scenes/Scene.cs index ec0f546..f623fa7 100644 --- a/src/Scenes/Scene.cs +++ b/src/Scenes/Scene.cs @@ -8,20 +8,20 @@ namespace Fjord.Scenes; public abstract class Scene : ICloneable { - private string SceneID; + public string SceneID { get => SceneID; set => throw new Exception("Can't set SceneID"); } - public bool AllowWindowResize = false; - public bool AlwaysRebuildTexture = false; - public bool AlwaysAtBack = false; - public bool AlwaysAtFront = false; + public bool AllowWindowResize { get; set; } = false; + public bool AlwaysRebuildTexture { get; set; } = false; + public bool AlwaysAtBack { get; set; } = false; + public bool AlwaysAtFront { get; set; } = false; public bool Paused = false; - internal bool showCursor = true; - internal bool captureMouseInput = true; + internal bool ShowCursor = true; + internal bool CaptureMouseInput = true; - internal bool updateOnlyIfActive = false; - internal bool hasRendered = false; + internal bool UpdateOnlyIfActive = false; + internal bool HasRendered = false; public SceneKeyboard Keyboard; public SceneMouse Mouse; @@ -31,7 +31,7 @@ public float DeltaTime { get { - return (float)Game.GetDeltaTime(); + return (float)Game.DeltaTime; } private set { @@ -61,7 +61,8 @@ private set internal SDL_Rect LocalWindowSize = new(); internal Vector2 OriginalWindowSize = new(); internal IntPtr RenderTarget; - internal SDL_Color ClearColor = new() + + private SDL_Color _clearColor = new() { r = 0, g = 0, @@ -69,57 +70,21 @@ private set a = 0 }; - public void SetClearColor(SDL_Color cc) - { - ClearColor = cc; - } - - public void SetClearColor(Vector4 cc) - { - ClearColor = new() + public Vector4 ClearColor { + get => new(_clearColor.r, _clearColor.g, _clearColor.b, _clearColor.a); + set => _clearColor = new() { - r = (byte)cc.X, - g = (byte)cc.Y, - b = (byte)cc.Z, - a = (byte)cc.W + r = (byte)value.X, + g = (byte)value.Y, + b = (byte)value.Z, + a = (byte)value.W }; } - public void SetClearColor(int r, int g, int b, int a) - { - ClearColor = new() - { - r = (byte)r, - g = (byte)g, - b = (byte)b, - a = (byte)a - }; - } - - public SDL_Color GetClearColor() - { - return ClearColor; - } - public string GetSceneID() { return SceneID; } - - public void SetShowCursor(bool showCursor) - { - this.showCursor = showCursor; - } - - public void SetCaptureMouse(bool capture) - { - this.captureMouseInput = capture; - } - - public void SetUpdateOnlyIfActive(bool active) - { - this.updateOnlyIfActive = active; - } public void ApplyOriginalAspectRatio() { @@ -227,7 +192,7 @@ internal void UpdateCall() if(MouseInsideScene) { - SDL_ShowCursor(showCursor ? SDL_ENABLE : SDL_DISABLE); + SDL_ShowCursor(ShowCursor ? SDL_ENABLE : SDL_DISABLE); } LocalWindowSize = new() @@ -242,7 +207,7 @@ internal void UpdateCall() WindowSize = new(OriginalWindowSize.X, OriginalWindowSize.Y); } - if (AlwaysRebuildTexture && (MouseInsideScene || !updateOnlyIfActive)) + if (AlwaysRebuildTexture && (MouseInsideScene || !UpdateOnlyIfActive)) { WindowSize = new() { X = LocalWindowSize.w, @@ -260,7 +225,7 @@ internal void UpdateCall() Mouse.LocalPosition.X = (GlobalMouse.Position.X - LocalWindowSize.x) + Camera.Offset.X; Mouse.LocalPosition.Y = (GlobalMouse.Position.Y - LocalWindowSize.y) + Camera.Offset.Y; - hasRendered = false; + HasRendered = false; } else { float wRatio = (float)WindowSize.X / (float)LocalWindowSize.w; @@ -287,7 +252,7 @@ internal void UpdateCall() { if(Helpers.PointInside(GlobalMouse.Position, SceneHandler.Scenes[scene].LocalWindowSize)) { - if(SceneHandler.Scenes[scene].captureMouseInput) + if(SceneHandler.Scenes[scene].CaptureMouseInput) { eligble.Add(scene); } @@ -327,10 +292,10 @@ internal void UpdateCall() if(!Paused) Camera.Update(WindowSize); - if((!updateOnlyIfActive || !hasRendered) && !Paused) + if((!UpdateOnlyIfActive || !HasRendered) && !Paused) { SDL_SetRenderTarget(Game.SDLRenderer, RenderTarget); - SDL_SetRenderDrawColor(Game.SDLRenderer, ClearColor.r, ClearColor.g, ClearColor.b, ClearColor.a); + SDL_SetRenderDrawColor(Game.SDLRenderer, (byte)ClearColor.X, (byte)ClearColor.Y, (byte)ClearColor.Y, (byte)ClearColor.Z); SDL_RenderClear(Game.SDLRenderer); Draw.CurrentSceneID = SceneID; @@ -348,7 +313,7 @@ internal void UpdateCall() drawBuffer = new(); - hasRendered = true; + HasRendered = true; } SDL_SetRenderTarget(Game.SDLRenderer, IntPtr.Zero); diff --git a/src/Scenes/SceneHandler.cs b/src/Scenes/SceneHandler.cs index 2e02e8e..1960a2f 100644 --- a/src/Scenes/SceneHandler.cs +++ b/src/Scenes/SceneHandler.cs @@ -6,7 +6,13 @@ public static class SceneHandler { internal static Dictionary Scenes = new (); internal static Dictionary OriginalScenes = new (); - internal static List LoadedScenes = new(); + + private static List _loadedScenes = new(); + + internal static List LoadedScenes { + get => new List(_loadedScenes); + set => _loadedScenes = value; + } public static void Initialize() { Debug.RegisterCommand("scene_unload", (args) => { @@ -116,11 +122,6 @@ public static class SceneHandler }); } - public static List GetLoadedScenes() - { - return new List(LoadedScenes); - } - public static void Register(Scene scene) { Scenes.Add(scene.GetSceneID(), (Scene)scene.Clone()); diff --git a/src/Ui/Builder.cs b/src/Ui/Builder.cs index 3ecefd4..94458f9 100644 --- a/src/Ui/Builder.cs +++ b/src/Ui/Builder.cs @@ -16,7 +16,7 @@ public UiBuilder(Vector2 position=new(), Vector2? MouseOverride=null) this.Position = position; if(MouseOverride != null) { - FUI.OverrideMousePosition(MouseOverride.Value); + FUI.OverMousePosition = MouseOverride.Value; } } public UiBuilder(Vector4 rect, Vector2? MouseOverride = null) @@ -26,7 +26,7 @@ public UiBuilder(Vector4 rect, Vector2? MouseOverride = null) if (MouseOverride != null) { - FUI.OverrideMousePosition(MouseOverride.Value); + FUI.OverMousePosition = MouseOverride.Value; } } @@ -197,7 +197,7 @@ public HAlign BuildHAlign() public void Render(out int height) { - FUI.SetRenderOffset(Position + new Vector2(10, 5)); + FUI.UiRenderOffset = Position + new Vector2(10, 5); //float yOffset = 0; //float y = Ui.Render(Build(), ref yOffset); @@ -207,8 +207,8 @@ public void Render(out int height) // .Render(); FUI.Render(Build(), out float renderHeight); - FUI.ResetMousePosition(); - FUI.ResetRenderOffset(); + FUI.OverMousePosition = null; + FUI.UiRenderOffset = new(); height = (int)renderHeight; } diff --git a/src/Ui/Ui.cs b/src/Ui/Ui.cs index f4f257a..88be4ad 100644 --- a/src/Ui/Ui.cs +++ b/src/Ui/Ui.cs @@ -17,34 +17,15 @@ public static class FUI internal static string? selectedTextFieldValue = null; internal static Action? selectedTextFieldOnChange = null; internal static Action? selectedTextFieldOnSumbit = null; - private static Vector2 UiRenderOffset = new(); - private static Vector2? OverMousePosition = null; + public static Vector2 UiRenderOffset { get; set; } = new(); + public static Vector2? OverMousePosition { get; set; } = null; private static Dictionary> resizeRectCache = new(); private static (string, int) pressedCorner = new("", -1); internal static Dictionary containerShown = new(); - public static void OverrideMousePosition(Vector2 MousePosition) - { - OverMousePosition = MousePosition; - } - - public static void SetRenderOffset(Vector2 offset) - { - UiRenderOffset = offset; - } - - public static void ResetRenderOffset() - { - UiRenderOffset = new(); - } - - public static void ResetMousePosition() - { - OverMousePosition = null; - } public static void ButtonExt(Vector2 position, string text, Action callback, out Vector2 size) { - Vector2 TextSize = Font.DrawSize(Font.GetDefaultFont(), text, 16, new(255, 0, 0, 255)); + Vector2 TextSize = Font.DrawSize(Font.DefaultFont, text, 16, new(255, 0, 0, 255)); Vector4 ButtonRectangle = new(position, TextSize.X + 48, 40); @@ -55,7 +36,7 @@ public static void ButtonExt(Vector2 position, string text, Action callback, out public static void ButtonExt(Vector4 v4rect, string text, Action callback, bool runContinuously=false) { - Vector2 TextSize = Font.DrawSize(Font.GetDefaultFont(), text, 16, new(255, 0, 0, 255)); + Vector2 TextSize = Font.DrawSize(Font.DefaultFont, text, 16, new(255, 0, 0, 255)); SDL_FRect rect = new() { @@ -116,9 +97,9 @@ public static void Button(Vector2 position, string text, Action callback) public static void TextFieldExt(Vector2 position, float minSize, string id, string value, Action onChange, Action onSubmit, string? placeholder, out Vector2 fieldsize) { - // Font.Draw(new Vector2(indent * 10 + UiRenderOffset.X + 5, yOffset + UiRenderOffset.Y + 3), Font.GetDefaultFont(), component.value, 14, UiStyles.TextColor); - Vector2 size = Font.DrawSize(Font.GetDefaultFont(), "asdasd", 16, UiStyles.TextColor); - Vector2 size2 = Font.DrawSize(Font.GetDefaultFont(), value, 16, UiStyles.TextColor); + // Font.Draw(new Vector2(indent * 10 + UiRenderOffset.X + 5, yOffset + UiRenderOffset.Y + 3), Font.DefaultFont, component.value, 14, UiStyles.TextColor); + Vector2 size = Font.DrawSize(Font.DefaultFont, "asdasd", 16, UiStyles.TextColor); + Vector2 size2 = Font.DrawSize(Font.DefaultFont, value, 16, UiStyles.TextColor); Vector4 rect = new() { @@ -194,7 +175,7 @@ public static void TextFieldExt(Vector2 position, float minSize, string id, stri .Render(); //SDL_RenderFillFRect(Game.SDLRenderer, ref rect); - Draw.Text(position + new Vector2(16, 7), Font.GetDefaultFont(), value, 16, UiStyles.TextColor); + Draw.Text(position + new Vector2(16, 7), Font.DefaultFont, value, 16, UiStyles.TextColor); } public static void TextFieldExt(Vector2 position, string id, string value, Action onChange, Action onSubmit, string? placeholder, out Vector2 fieldsize) @@ -209,7 +190,7 @@ public static void TextField(Vector2 position, string id, string value, Action onChange, out Vector2 fieldsize) { - Vector2 size = Font.DrawSize(Font.GetDefaultFont(), "10", 16, UiStyles.TextColor); + Vector2 size = Font.DrawSize(Font.DefaultFont, "10", 16, UiStyles.TextColor); var SliderRectangle = new Rectangle(new() { @@ -273,7 +254,7 @@ public static void SliderExt(Vector2 position, float min, float max, float value .Color(SliderRectangle.color) .Render(); - // Font.Draw(position + new Vector2(5, 3), Font.GetDefaultFont(), value.ToString(), 16, UiStyles.TextColor); + // Font.Draw(position + new Vector2(5, 3), Font.DefaultFont, value.ToString(), 16, UiStyles.TextColor); } public static void Slider(Vector2 position, float min, float max, float value, Action onChange) { @@ -387,7 +368,7 @@ public static float Render(List components, ref float yOffset, int inden { i++; - Vector2 TextSize = Font.DrawSize(Font.GetDefaultFont(), component.text, 16, new(255, 0, 0, 255)); + Vector2 TextSize = Font.DrawSize(Font.DefaultFont, component.text, 16, new(255, 0, 0, 255)); Vector2 Position = new Vector2(indent * 10 + UiRenderOffset.X + xOffset, yOffset + UiRenderOffset.Y); Vector4 ButtonRectangle = new(Position, TextSize.X + 48, 36); @@ -474,15 +455,15 @@ public static float Render(List components, ref float yOffset, int inden else if (componentObj.GetType() == typeof(UiTitle)) { UiTitle component = (UiTitle)componentObj; - Draw.Text(new(indent * 10 + UiRenderOffset.X, yOffset + UiRenderOffset.Y), Font.GetDefaultFont(), component.text, 18, UiStyles.TextColor); - Vector2 size = Font.DrawSize(Font.GetDefaultFont(), component.text, 18, new(0, 0, 0, 255)); + Draw.Text(new(indent * 10 + UiRenderOffset.X, yOffset + UiRenderOffset.Y), Font.DefaultFont, component.text, 18, UiStyles.TextColor); + Vector2 size = Font.DrawSize(Font.DefaultFont, component.text, 18, new(0, 0, 0, 255)); yOffset += size.Y + 10; } else if (componentObj.GetType() == typeof(UiText)) { UiText component = (UiText)componentObj; - Draw.Text(new(indent * 10 + UiRenderOffset.X, yOffset + UiRenderOffset.Y), Font.GetDefaultFont(), component.text, 14, component.overrideColor.HasValue ? component.overrideColor.Value : UiStyles.TextColor); - Vector2 size = Font.DrawSize(Font.GetDefaultFont(), component.text, 14, new(0, 0, 0, 255)); + Draw.Text(new(indent * 10 + UiRenderOffset.X, yOffset + UiRenderOffset.Y), Font.DefaultFont, component.text, 14, component.overrideColor.HasValue ? component.overrideColor.Value : UiStyles.TextColor); + Vector2 size = Font.DrawSize(Font.DefaultFont, component.text, 14, new(0, 0, 0, 255)); yOffset += size.Y + 10; } else if (componentObj.GetType() == typeof(UiSpacer)) @@ -539,7 +520,7 @@ public static float Render(List components, ref float yOffset, int inden } else if (componentObj.GetType() == typeof(UiDebugLog)) { UiDebugLog component = (UiDebugLog)componentObj; - Vector2 size = Font.DrawSize(Font.GetDefaultFont(), component.time, 14, UiStyles.SuccessTextColor); + Vector2 size = Font.DrawSize(Font.DefaultFont, component.time, 14, UiStyles.SuccessTextColor); SDL_Rect rect = new SDL_Rect() { @@ -552,26 +533,26 @@ public static float Render(List components, ref float yOffset, int inden SDL_SetRenderDrawColor(Game.SDLRenderer, UiStyles.SuccessBackgroundColor.ToCol()); SDL_RenderFillRect(Game.SDLRenderer, ref rect); - Vector2 size2 = Font.DrawSize(Font.GetDefaultFont(), component.sender, 14, UiStyles.SuccessTextColor); + Vector2 size2 = Font.DrawSize(Font.DefaultFont, component.sender, 14, UiStyles.SuccessTextColor); - Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + 5, yOffset + UiRenderOffset.Y + 3), Font.GetDefaultFont(), component.time, 14, UiStyles.SuccessTextColor); - Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + size.X + 20, yOffset + UiRenderOffset.Y + 3), Font.GetDefaultFont(), component.sender, 14, UiStyles.SuccessTextColor); + Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + 5, yOffset + UiRenderOffset.Y + 3), Font.DefaultFont, component.time, 14, UiStyles.SuccessTextColor); + Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + size.X + 20, yOffset + UiRenderOffset.Y + 3), Font.DefaultFont, component.sender, 14, UiStyles.SuccessTextColor); switch(component.level) { case Scenes.LogLevel.Error: { - Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + size.X + 20 + size2.X + 10, yOffset + UiRenderOffset.Y + 3), Font.GetDefaultFont(), component.message, 14, UiStyles.ErrorTextColor); + Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + size.X + 20 + size2.X + 10, yOffset + UiRenderOffset.Y + 3), Font.DefaultFont, component.message, 14, UiStyles.ErrorTextColor); } break; case Scenes.LogLevel.Warning: { - Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + size.X + 20 + size2.X + 10, yOffset + UiRenderOffset.Y + 3), Font.GetDefaultFont(), component.message, 14, UiStyles.WarningTextColor); + Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + size.X + 20 + size2.X + 10, yOffset + UiRenderOffset.Y + 3), Font.DefaultFont, component.message, 14, UiStyles.WarningTextColor); } break; default: { - Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + size.X + 20 + size2.X + 10, yOffset + UiRenderOffset.Y + 3), Font.GetDefaultFont(), component.message, 14, UiStyles.TextColor); + Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + size.X + 20 + size2.X + 10, yOffset + UiRenderOffset.Y + 3), Font.DefaultFont, component.message, 14, UiStyles.TextColor); } break; } if(component.repeat > 0) { - Vector2 size3 = Font.DrawSize(Font.GetDefaultFont(), component.message, 14, UiStyles.TextColor); - Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + size.X + 20 + size2.X + 10 + size3.X + 10, yOffset + UiRenderOffset.Y + 3), Font.GetDefaultFont(), "(" + component.repeat.ToString() + "x)", 14, UiStyles.ErrorTextColor); + Vector2 size3 = Font.DrawSize(Font.DefaultFont, component.message, 14, UiStyles.TextColor); + Draw.Text(new Vector2(indent * 10 + UiRenderOffset.X + size.X + 20 + size2.X + 10 + size3.X + 10, yOffset + UiRenderOffset.Y + 3), Font.DefaultFont, "(" + component.repeat.ToString() + "x)", 14, UiStyles.ErrorTextColor); } yOffset += size.Y + 10; @@ -615,7 +596,7 @@ public static float Render(List components, ref float yOffset, int inden FUI.containerShown.Add(label.text + component.Count, true); } - Vector2 size = Font.DrawSize(Font.GetDefaultFont(), label.text + component.Count, 18, new(0, 0, 0, 255)); + Vector2 size = Font.DrawSize(Font.DefaultFont, label.text + component.Count, 18, new(0, 0, 0, 255)); Vector4 rect = new Vector4(new(indent * 10 + UiRenderOffset.X, yOffset + UiRenderOffset.Y), size.X + 15, size.Y); float xpos; @@ -707,7 +688,7 @@ public static float Render(List components, ref float yOffset, int inden } } - Draw.Text(new(indent * 10 + UiRenderOffset.X, yOffset + UiRenderOffset.Y), Font.GetDefaultFont(), label.text, 18, UiStyles.TextColor); + Draw.Text(new(indent * 10 + UiRenderOffset.X, yOffset + UiRenderOffset.Y), Font.DefaultFont, label.text, 18, UiStyles.TextColor); yOffset += size.Y + 10; @@ -751,8 +732,8 @@ public static float RenderHorizontal(HAlign components, ref float y else if (componentObj.GetType() == typeof(UiTitle)) { UiTitle component = (UiTitle)componentObj; - Draw.Text(new(indent * 10 + UiRenderOffset.X + xOffset, UiRenderOffset.Y + yOffset), Font.GetDefaultFont(), component.text, 18, UiStyles.TextColor); - Vector2 size = Font.DrawSize(Font.GetDefaultFont(), component.text, 18, new(0, 0, 0, 255)); + Draw.Text(new(indent * 10 + UiRenderOffset.X + xOffset, UiRenderOffset.Y + yOffset), Font.DefaultFont, component.text, 18, UiStyles.TextColor); + Vector2 size = Font.DrawSize(Font.DefaultFont, component.text, 18, new(0, 0, 0, 255)); xOffset += size.X + 10; if (size.Y > biggestHeight) biggestHeight = size.Y; @@ -760,8 +741,8 @@ public static float RenderHorizontal(HAlign components, ref float y else if (componentObj.GetType() == typeof(UiText)) { UiText component = (UiText)componentObj; - Draw.Text(new(indent * 10 + UiRenderOffset.X + xOffset, UiRenderOffset.Y + yOffset), Font.GetDefaultFont(), component.text, 14, component.overrideColor.HasValue ? component.overrideColor.Value : UiStyles.TextColor); - Vector2 size = Font.DrawSize(Font.GetDefaultFont(), component.text, 14, new(0, 0, 0, 255)); + Draw.Text(new(indent * 10 + UiRenderOffset.X + xOffset, UiRenderOffset.Y + yOffset), Font.DefaultFont, component.text, 14, component.overrideColor.HasValue ? component.overrideColor.Value : UiStyles.TextColor); + Vector2 size = Font.DrawSize(Font.DefaultFont, component.text, 14, new(0, 0, 0, 255)); xOffset += size.X + 10; if (size.Y > biggestHeight) biggestHeight = size.Y;