From 075df457f4c391002d752acb9052394cb5ef3c63 Mon Sep 17 00:00:00 2001 From: redthing1 Date: Tue, 8 Oct 2024 10:30:25 -0700 Subject: [PATCH] entity inspect view should be disabled in release --- source/re/ng/diag/console.d | 4 +-- source/re/ng/diag/default_inspect_commands.d | 2 +- source/re/ng/diag/entity_inspect_view.d | 2 +- source/re/ng/diag/inspector_overlay.d | 37 +++++++++++++------- source/re/ng/diag/package.d | 6 ++-- 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/source/re/ng/diag/console.d b/source/re/ng/diag/console.d index 5500580..a1339d8 100644 --- a/source/re/ng/diag/console.d +++ b/source/re/ng/diag/console.d @@ -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() { diff --git a/source/re/ng/diag/default_inspect_commands.d b/source/re/ng/diag/default_inspect_commands.d index 22971d2..6b63577 100644 --- a/source/re/ng/diag/default_inspect_commands.d +++ b/source/re/ng/diag/default_inspect_commands.d @@ -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; diff --git a/source/re/ng/diag/entity_inspect_view.d b/source/re/ng/diag/entity_inspect_view.d index ce912c9..16b1568 100644 --- a/source/re/ng/diag/entity_inspect_view.d +++ b/source/re/ng/diag/entity_inspect_view.d @@ -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 diff --git a/source/re/ng/diag/inspector_overlay.d b/source/re/ng/diag/inspector_overlay.d index 8068aba..92a6022 100644 --- a/source/re/ng/diag/inspector_overlay.d +++ b/source/re/ng/diag/inspector_overlay.d @@ -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); @@ -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 @@ -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); } diff --git a/source/re/ng/diag/package.d b/source/re/ng/diag/package.d index 7ab3f56..a34bb62 100644 --- a/source/re/ng/diag/package.d +++ b/source/re/ng/diag/package.d @@ -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; }