mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2024-11-28 16:58:56 +08:00
Memory leak fix. Start of debug console
This commit is contained in:
parent
f1285179cd
commit
f325ed2598
|
@ -5,7 +5,7 @@ namespace Strawberry
|
|||
{
|
||||
public abstract class Asset
|
||||
{
|
||||
public readonly String Path;
|
||||
public readonly String Path ~ delete _;
|
||||
|
||||
protected this(String path)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace Strawberry
|
|||
return fonts[size];
|
||||
else
|
||||
{
|
||||
Calc.Log(Path);
|
||||
let f = SDLTTF.OpenFont(Path, size);
|
||||
fonts[size] = f;
|
||||
return f;
|
||||
|
|
BIN
src/Content/strawberry-seeds.ttf
Normal file
BIN
src/Content/strawberry-seeds.ttf
Normal file
Binary file not shown.
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user