diff --git a/src/Assets/Asset.bf b/src/Assets/Asset.bf index 51156fb..8e28172 100644 --- a/src/Assets/Asset.bf +++ b/src/Assets/Asset.bf @@ -5,7 +5,7 @@ namespace Strawberry { public abstract class Asset { - public readonly String Path; + public readonly String Path ~ delete _; protected this(String path) { diff --git a/src/Assets/Font.bf b/src/Assets/Font.bf index ba2a395..55268df 100644 --- a/src/Assets/Font.bf +++ b/src/Assets/Font.bf @@ -25,7 +25,6 @@ namespace Strawberry return fonts[size]; else { - Calc.Log(Path); let f = SDLTTF.OpenFont(Path, size); fonts[size] = f; return f; diff --git a/src/Content/strawberry-seeds.ttf b/src/Content/strawberry-seeds.ttf new file mode 100644 index 0000000..c94216b Binary files /dev/null and b/src/Content/strawberry-seeds.ttf differ diff --git a/src/Core/Game.bf b/src/Core/Game.bf index 0728bc5..5980f62 100644 --- a/src/Core/Game.bf +++ b/src/Core/Game.bf @@ -20,7 +20,6 @@ namespace Strawberry public readonly int Width; public readonly int Height; public readonly int WindowScale; - public readonly String ContentRoot; private Scene scene; private Scene switchToScene; @@ -49,12 +48,6 @@ namespace Strawberry WindowScale = windowScale; screenRect = SDL.Rect(0, 0, width * windowScale, height * windowScale); -#if DEBUG - ContentRoot = "../../../src/Content/"; -#else - ContentRoot = "Content/"; -#endif - String exePath = scope .(); Environment.GetExecutableFilePath(exePath); String exeDir = scope .(); @@ -85,6 +78,7 @@ namespace Strawberry BuildTypeLists(); Assets.LoadAll(); + Strawberry.Console.Init(); } public ~this() @@ -107,6 +101,7 @@ namespace Strawberry Assets.DisposeAll(); DisposeTypeLists(); Input.[Friend]Dispose(); + Strawberry.Console.Dispose(); Game = null; } diff --git a/src/Static/Console.bf b/src/Static/Console.bf index 4fb2448..b0724c8 100644 --- a/src/Static/Console.bf +++ b/src/Static/Console.bf @@ -1,18 +1,70 @@ +using System; + namespace Strawberry { static public class Console { - static public bool Enabled; + static public bool Open; + + static private bool enabled; + static private SDL2.SDLTTF.Font* font; + + static public void Init() + { + enabled = true; + font = SDL2.SDLTTF.OpenFont("../../../../Strawberry/src/Content/strawberry-seeds.ttf", 8); + } + + static public void Dispose() + { + SDL2.SDLTTF.CloseFont(font); + } + + static public bool Enabled + { + get => enabled; + set + { + enabled = value; + if (!enabled) + Open = false; + } + } static public void Update() { - if (Input.KeyPressed(.Grave)) - Enabled = !Enabled; + if (enabled) + { + if (Input.KeyPressed(.Grave)) + Open = !Open; + + if (Open) + { + + } + } } static public void Draw() { - Draw.Rect(0, 0, Game.Width, Game.Height, .Black * 0.4f); + if (enabled && Open) + { + Draw.Rect(0, 0, Game.Width, Game.Height, .Black * 0.5f); + + Text(">", 0, 0, .White); + if (Time.BetweenInterval(0.5f)) + Text("_", 0, 1, .White); + } } + + static private void Text(String str, int row, int col, Color color) + { + Point pos = .(4 + 6 * col, Game.Height - 10 - 10 * row); + if (row > 0) + pos.Y -= 4; + + Draw.Text(font, str, pos + .Down, .Black); + Draw.Text(font, str, pos, color); + } } }