From 7402494e92148315240dd45b142d5d30d2218576 Mon Sep 17 00:00:00 2001 From: KP Date: Wed, 24 Jul 2024 03:56:45 -0500 Subject: [PATCH] Mode switching via console --- Data/sandbox-log.txt | 18 ++++++++++-------- Sandbox/src/Sandbox.cpp | 12 ++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Data/sandbox-log.txt b/Data/sandbox-log.txt index bf91536..340912c 100644 --- a/Data/sandbox-log.txt +++ b/Data/sandbox-log.txt @@ -1,14 +1,16 @@ -[03:16:52 AM] Info: Starting... +[03:52:19 AM] Info: Starting... KP3D version 2 =============================== Copyright (C) kpworld.xyz 2018-2024 Contact me! @kp_cftsz -[03:16:52 AM] Info: Initializing SDL -[03:16:52 AM] Info: Initializing OpenGL -[03:16:52 AM] Info: OpenGL version: 4.6.0 NVIDIA 536.23 -[03:16:52 AM] Info: Initializing GLEW -[03:16:52 AM] Info: Initializing SDL_mixer -[03:16:52 AM] Info: Reticulating splines... -[03:16:52 AM] Info: Ready! +[03:52:19 AM] Info: Initializing SDL +[03:52:19 AM] Info: Initializing OpenGL +[03:52:19 AM] Info: OpenGL version: 4.6.0 NVIDIA 536.23 +[03:52:19 AM] Info: Initializing GLEW +[03:52:19 AM] Info: Initializing SDL_mixer +[03:52:19 AM] Info: Reticulating splines... +[03:52:20 AM] Info: Ready! +[03:53:11 AM] Info: $ set-mode edit +[03:53:11 AM] Info: $ diff --git a/Sandbox/src/Sandbox.cpp b/Sandbox/src/Sandbox.cpp index ccce8d2..f15f42b 100644 --- a/Sandbox/src/Sandbox.cpp +++ b/Sandbox/src/Sandbox.cpp @@ -7,6 +7,7 @@ #include #include #include +#include static kp3d::Texture tex; static std::vector points; @@ -25,6 +26,17 @@ Sandbox::Sandbox(const std::string& path): points.push_back({x, y}); return {CELL_VOID}; }}); + kp3d::console::environment.Set("edit", {CELL_NUMBER, MODE_EDIT}); + kp3d::console::environment.Set("game", {CELL_NUMBER, MODE_GAME}); + kp3d::console::environment.Set("edit", {CELL_NUMBER, MODE_MENU}); + kp3d::console::environment.Set("set-mode", {CELL_FUNCTION_CPP, [&](std::list args) -> Cell { + if (args.empty()) return {CELL_VOID}; + int mode = (int) FromCell(args.back()); + m_mode = mode; + kp3d::console::open = false; + SetMouseLockEnabled(true); + return {CELL_VOID}; + }}); m_mode = MODE_MENU; }