Skip to content

Commit

Permalink
entity inspect view should be disabled in release
Browse files Browse the repository at this point in the history
  • Loading branch information
redthing1 committed Oct 8, 2024
1 parent a3e0cee commit 075df45
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
4 changes: 2 additions & 2 deletions source/re/ng/diag/console.d
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ class InspectorConsole {
add_command(ConsoleCommand("help", &cmd_help, "lists available commands"));
}

public void add_default_inspector_commands() {
debug public void add_default_inspector_commands() {
add_command(ConsoleCommand("entities", toDelegate(
&DefaultEntityInspectorCommands.c_entities), "lists scene entities"));
add_command(ConsoleCommand("dump", toDelegate(&DefaultEntityInspectorCommands.c_dump), "dump a component"));
add_command(ConsoleCommand("inspect", toDelegate(&DefaultEntityInspectorCommands.c_inspect),
"open the inspector on a component"));
add_command(ConsoleCommand("dump", toDelegate(&DefaultEntityInspectorCommands.c_dump), "dump a component"));
}

public void reset_commands() {
Expand Down
2 changes: 1 addition & 1 deletion source/re/ng/diag/default_inspect_commands.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import std.conv;
import re.core;
import re.ecs;

static class DefaultEntityInspectorCommands {
debug static class DefaultEntityInspectorCommands {
alias log = Core.log;
alias scenes = Core.scenes;
alias dbg = Core.inspector_overlay;
Expand Down
2 changes: 1 addition & 1 deletion source/re/ng/diag/entity_inspect_view.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static import raylib;
static import raygui;

/// real-time object inspector
class EntityInspectView {
debug class EntityInspectView {
/// panel width
public int width;
/// whether the inspector is open
Expand Down
37 changes: 24 additions & 13 deletions source/re/ng/diag/inspector_overlay.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ class InspectorOverlay {
private enum _render_col = Color(255, 255, 255, 160);

/// inspector panel
public static EntityInspectView entity_inspect_view;
debug {
public static EntityInspectView entity_inspect_view;
}

/// debug console
public static InspectorConsole console;

/// sets up debugger
this() {
entity_inspect_view = new EntityInspectView();
debug {
entity_inspect_view = new EntityInspectView();
}
console = new InspectorConsole();
if (!Core.headless) {
ui_bounds = Rectangle(0, 0, Core.window.screen_width, Core.window.screen_height);
Expand All @@ -48,31 +52,36 @@ class InspectorOverlay {
}

public void update() {
if (!Core.headless) {
// auto-resize inspector
entity_inspect_view.width = cast(int)(ui_bounds.width * 0.7);
}

if (Input.is_key_pressed(console.key)) {
Core.debug_render = !Core.debug_render;
console.open = !console.open;
}

if (entity_inspect_view.open)
entity_inspect_view.update();
if (console.open)
console.update();

debug {
if (!Core.headless) {
// auto-resize inspector
entity_inspect_view.width = cast(int)(ui_bounds.width * 0.7);
}
if (entity_inspect_view.open)
entity_inspect_view.update();
}
}

public void render() {
raylib.BeginTextureMode(_render_target);
raylib.ClearBackground(Colors.BLANK);

if (entity_inspect_view.open)
entity_inspect_view.render();
if (console.open)
console.render();

debug {
if (entity_inspect_view.open)
entity_inspect_view.render();
}

raylib.EndTextureMode();

// draw render target
Expand All @@ -84,8 +93,10 @@ class InspectorOverlay {

/// clean up
public void destroy() {
if (entity_inspect_view.open) {
entity_inspect_view.close();
debug {
if (entity_inspect_view.open) {
entity_inspect_view.close();
}
}
RenderExt.destroy_render_target(_render_target);
}
Expand Down
6 changes: 2 additions & 4 deletions source/re/ng/diag/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
module re.ng.diag;

public {
debug {
import re.ng.diag.inspector_overlay;
import re.ng.diag.console;
}
import re.ng.diag.inspector_overlay;
import re.ng.diag.console;
import re.ng.diag.render;
}

0 comments on commit 075df45

Please sign in to comment.