From aff4d2012cb525e1aa4e748b6c3d97ea1908dd42 Mon Sep 17 00:00:00 2001 From: AllyTally Date: Mon, 3 Jul 2023 14:34:02 -0300 Subject: [PATCH] Add -leveldebugger flag This commit adds the `-leveldebugger` flag so you can use it while playtesting from a different editor program, such as Ved. --- desktop_version/src/LevelDebugger.cpp | 22 ++++++++++++++-------- desktop_version/src/LevelDebugger.h | 1 + desktop_version/src/main.cpp | 5 +++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/desktop_version/src/LevelDebugger.cpp b/desktop_version/src/LevelDebugger.cpp index e5953390..b748e5a6 100644 --- a/desktop_version/src/LevelDebugger.cpp +++ b/desktop_version/src/LevelDebugger.cpp @@ -17,6 +17,7 @@ namespace level_debugger bool should_pause = true; bool tab_held = false; bool debug_held = false; + bool forced = false; // Moving entities/blocks bool mouse_held = false; @@ -48,9 +49,14 @@ namespace level_debugger key.my >= rect->y && key.my < rect->y + rect->h; } + void set_forced(void) + { + forced = true; + } + void input(void) { - if (!map.custommode || map.custommodeforreal) + if (!forced && (!map.custommode || map.custommodeforreal)) { active = false; return; @@ -285,14 +291,12 @@ namespace level_debugger graphics.draw_rect(bounding_box.x, bounding_box.y, bounding_box.w, bounding_box.h, graphics.getRGB(90, 15, 15)); } - font::print(PR_BOR | PR_FONT_8X8, 5, 14, loc::gettext("[Press TAB to toggle movement]"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); - int line = 0; if (key.isDown(SDLK_u)) { SDL_Color on = graphics.getRGB(220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); - SDL_Color off = graphics.getRGB(220 / 2 - (help.glow), 220 / 2 - (help.glow), 255 / 2 - (help.glow / 2)); + SDL_Color off = graphics.getRGB(220 / 1.5 - (help.glow), 220 / 1.5 - (help.glow), 255 / 1.5 - (help.glow / 2)); graphics.set_blendmode(SDL_BLENDMODE_BLEND); graphics.fill_rect(NULL, 0, 0, 0, 127); @@ -304,13 +308,13 @@ namespace level_debugger for (int i = 0; i < SDL_arraysize(obj.flags); i++) { SDL_Color color = obj.flags[i] ? on : off; - font::print(PR_BOR | PR_FONT_8X8, 5 + x, 32 + y, help.String(i), color.r, color.g, color.b); + font::print(PR_BOR | PR_FONT_8X8, 48 + x * 24, 48 + y * 16, help.String(i), color.r, color.g, color.b); - x += 16 + 8; - if (x >= 300) + x++; + if (x >= 10) { x = 0; - y += 16; + y++; } } } @@ -418,5 +422,7 @@ namespace level_debugger graphics.draw_rect(hover_box.x, hover_box.y, hover_box.w, hover_box.h, graphics.getRGB(255 - help.glow, 32, 32)); } } + + font::print(PR_BOR | PR_FONT_8X8, 5, 14, loc::gettext("[Press TAB to toggle movement]"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); } }; diff --git a/desktop_version/src/LevelDebugger.h b/desktop_version/src/LevelDebugger.h index 8f8b988a..e13fc0d0 100644 --- a/desktop_version/src/LevelDebugger.h +++ b/desktop_version/src/LevelDebugger.h @@ -9,6 +9,7 @@ namespace level_debugger bool is_active(void); void input(void); void render(void); + void set_forced(void); } #endif /* LEVELDEBUGGER_H */ diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index 300f675f..1d4c8557 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -19,6 +19,7 @@ #include "Input.h" #include "InterimVersion.h" #include "KeyPoll.h" +#include "LevelDebugger.h" #include "Localization.h" #include "LocalizationStorage.h" #include "Logic.h" @@ -489,6 +490,10 @@ int main(int argc, char *argv[]) playassets = "levels/" + std::string(argv[i]) + ".vvvvvv"; }) } + else if (ARG("-leveldebugger")) + { + level_debugger::set_forced(); + } else if (ARG("-nooutput")) { vlog_toggle_output(0);