diff --git a/engine/asset/src/asset.cpp b/engine/asset/src/asset.cpp index 8ab47e6..1f4ca80 100644 --- a/engine/asset/src/asset.cpp +++ b/engine/asset/src/asset.cpp @@ -13,7 +13,7 @@ #include "renderer.hpp" #include "input.hpp" #include "physics.hpp" -#include "imguilayer.hpp" +#include "imgui_backend.hpp" std::unique_ptr load_mesh(const file::Path path) { Expects(!path.empty()); diff --git a/engine/core/CMakeLists.txt b/engine/core/CMakeLists.txt index 8e947c2..782a34c 100755 --- a/engine/core/CMakeLists.txt +++ b/engine/core/CMakeLists.txt @@ -5,7 +5,7 @@ set(SRC include/cutscene.hpp include/physics.hpp include/scene.hpp - include/imguilayer.hpp + include/imgui_backend.hpp include/uielement.hpp include/screen.hpp include/object.hpp @@ -18,7 +18,7 @@ set(SRC src/engine.cpp src/input.cpp src/physics.cpp - src/imguilayer.cpp + src/imgui_backend.cpp src/screen.cpp src/scene.cpp src/debug.cpp diff --git a/engine/core/include/engine.hpp b/engine/core/include/engine.hpp index 7280aa8..33e17ee 100755 --- a/engine/core/include/engine.hpp +++ b/engine/core/include/engine.hpp @@ -20,11 +20,11 @@ class Input; class Renderer; class RenderTarget; class Physics; -class ImGuiLayer; struct Timer; namespace prism { class app; + class imgui_backend; struct AnimationTarget { float current_time = 0.0f; @@ -381,7 +381,7 @@ namespace prism { std::vector animation_targets; - std::unique_ptr imgui; + std::unique_ptr imgui; const InputButton debug_button = InputButton::Q; }; diff --git a/engine/core/include/imgui_backend.hpp b/engine/core/include/imgui_backend.hpp new file mode 100644 index 0000000..f2a509c --- /dev/null +++ b/engine/core/include/imgui_backend.hpp @@ -0,0 +1,16 @@ +#pragma once + +namespace prism { + class imgui_backend { + public: + imgui_backend(); + + void begin_frame(float delta_time); + + void render(int index); + + void process_key_down(unsigned int key_code); + + void process_key_up(unsigned int key_code); + }; +} \ No newline at end of file diff --git a/engine/core/include/imguilayer.hpp b/engine/core/include/imguilayer.hpp deleted file mode 100755 index fb16ecf..0000000 --- a/engine/core/include/imguilayer.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -class ImGuiLayer { -public: - ImGuiLayer(); - - void begin_frame(const float delta_time); - void render(int index); - - void process_key_down(unsigned int keyCode); - void process_key_up(unsigned int keyCode); -}; diff --git a/engine/core/src/engine.cpp b/engine/core/src/engine.cpp index 91ee8ed..feff6a2 100755 --- a/engine/core/src/engine.cpp +++ b/engine/core/src/engine.cpp @@ -14,7 +14,7 @@ #include "screen.hpp" #include "renderer.hpp" #include "gfx.hpp" -#include "imguilayer.hpp" +#include "imgui_backend.hpp" #include "debug.hpp" #include "timer.hpp" #include "physics.hpp" @@ -35,7 +35,7 @@ engine::engine(const int argc, char* argv[]) { console::register_variable("rs_dynamic_resolution", render_options.dynamic_resolution); - console::register_command("quit", console::ArgumentFormat(0), [this](const console::Arguments) { + console::register_command("quit", console::ArgumentFormat(0), [this](const console::Arguments&) { quit(); }); @@ -44,7 +44,7 @@ engine::engine(const int argc, char* argv[]) { input = std::make_unique(); physics = std::make_unique(); - imgui = std::make_unique(); + imgui = std::make_unique(); assetm = std::make_unique(); } diff --git a/engine/core/src/imguilayer.cpp b/engine/core/src/imgui_backend.cpp old mode 100755 new mode 100644 similarity index 93% rename from engine/core/src/imguilayer.cpp rename to engine/core/src/imgui_backend.cpp index 4351cc9..df24c8c --- a/engine/core/src/imguilayer.cpp +++ b/engine/core/src/imgui_backend.cpp @@ -1,4 +1,4 @@ -#include "imguilayer.hpp" +#include "imgui_backend.hpp" #include #include @@ -7,6 +7,8 @@ #include "platform.hpp" #include "assertions.hpp" +using prism::imgui_backend; + const std::map imToPl = { {ImGuiKey_Tab, InputButton::Tab}, {ImGuiKey_LeftArrow, InputButton::LeftArrow}, @@ -31,7 +33,7 @@ const std::map imToPl = { {ImGuiKey_Z, InputButton::Z} }; -ImGuiLayer::ImGuiLayer() { +imgui_backend::imgui_backend() { ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); @@ -155,7 +157,7 @@ ImGuiLayer::ImGuiLayer() { }; } -void ImGuiLayer::begin_frame(const float delta_time) { +void imgui_backend::begin_frame(const float delta_time) { ImGuiIO& io = ImGui::GetIO(); const auto [width, height] = platform::get_window_size(0); @@ -190,7 +192,7 @@ void ImGuiLayer::begin_frame(const float delta_time) { ImGui::NewFrame(); } -void ImGuiLayer::render(int index) { +void imgui_backend::render(int index) { Expects(index >= 0); if(index == 0) { @@ -199,19 +201,19 @@ void ImGuiLayer::render(int index) { } } -void ImGuiLayer::process_key_down(unsigned int keyCode) { - Expects(keyCode >= 0); +void imgui_backend::process_key_down(unsigned int key_code) { + Expects(key_code >= 0); ImGuiIO& io = ImGui::GetIO(); - io.AddInputCharactersUTF8(platform::translate_keycode(keyCode)); + io.AddInputCharactersUTF8(platform::translate_keycode(key_code)); - io.KeysDown[keyCode] = true; + io.KeysDown[key_code] = true; } -void ImGuiLayer::process_key_up(unsigned int keyCode) { - Expects(keyCode >= 0); +void imgui_backend::process_key_up(unsigned int key_code) { + Expects(key_code >= 0); ImGuiIO& io = ImGui::GetIO(); - io.KeysDown[keyCode] = false; + io.KeysDown[key_code] = false; }