Rename ImGuiLayer to imgui_backend
This commit is contained in:
parent
b918d9fd85
commit
8370dfb6d6
7 changed files with 37 additions and 31 deletions
|
@ -13,7 +13,7 @@
|
||||||
#include "renderer.hpp"
|
#include "renderer.hpp"
|
||||||
#include "input.hpp"
|
#include "input.hpp"
|
||||||
#include "physics.hpp"
|
#include "physics.hpp"
|
||||||
#include "imguilayer.hpp"
|
#include "imgui_backend.hpp"
|
||||||
|
|
||||||
std::unique_ptr<Mesh> load_mesh(const file::Path path) {
|
std::unique_ptr<Mesh> load_mesh(const file::Path path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
|
@ -5,7 +5,7 @@ set(SRC
|
||||||
include/cutscene.hpp
|
include/cutscene.hpp
|
||||||
include/physics.hpp
|
include/physics.hpp
|
||||||
include/scene.hpp
|
include/scene.hpp
|
||||||
include/imguilayer.hpp
|
include/imgui_backend.hpp
|
||||||
include/uielement.hpp
|
include/uielement.hpp
|
||||||
include/screen.hpp
|
include/screen.hpp
|
||||||
include/object.hpp
|
include/object.hpp
|
||||||
|
@ -18,7 +18,7 @@ set(SRC
|
||||||
src/engine.cpp
|
src/engine.cpp
|
||||||
src/input.cpp
|
src/input.cpp
|
||||||
src/physics.cpp
|
src/physics.cpp
|
||||||
src/imguilayer.cpp
|
src/imgui_backend.cpp
|
||||||
src/screen.cpp
|
src/screen.cpp
|
||||||
src/scene.cpp
|
src/scene.cpp
|
||||||
src/debug.cpp
|
src/debug.cpp
|
||||||
|
|
|
@ -20,11 +20,11 @@ class Input;
|
||||||
class Renderer;
|
class Renderer;
|
||||||
class RenderTarget;
|
class RenderTarget;
|
||||||
class Physics;
|
class Physics;
|
||||||
class ImGuiLayer;
|
|
||||||
struct Timer;
|
struct Timer;
|
||||||
|
|
||||||
namespace prism {
|
namespace prism {
|
||||||
class app;
|
class app;
|
||||||
|
class imgui_backend;
|
||||||
|
|
||||||
struct AnimationTarget {
|
struct AnimationTarget {
|
||||||
float current_time = 0.0f;
|
float current_time = 0.0f;
|
||||||
|
@ -381,7 +381,7 @@ namespace prism {
|
||||||
|
|
||||||
std::vector<AnimationTarget> animation_targets;
|
std::vector<AnimationTarget> animation_targets;
|
||||||
|
|
||||||
std::unique_ptr<ImGuiLayer> imgui;
|
std::unique_ptr<imgui_backend> imgui;
|
||||||
|
|
||||||
const InputButton debug_button = InputButton::Q;
|
const InputButton debug_button = InputButton::Q;
|
||||||
};
|
};
|
||||||
|
|
16
engine/core/include/imgui_backend.hpp
Normal file
16
engine/core/include/imgui_backend.hpp
Normal file
|
@ -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);
|
||||||
|
};
|
||||||
|
}
|
|
@ -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);
|
|
||||||
};
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "screen.hpp"
|
#include "screen.hpp"
|
||||||
#include "renderer.hpp"
|
#include "renderer.hpp"
|
||||||
#include "gfx.hpp"
|
#include "gfx.hpp"
|
||||||
#include "imguilayer.hpp"
|
#include "imgui_backend.hpp"
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
#include "timer.hpp"
|
#include "timer.hpp"
|
||||||
#include "physics.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_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();
|
quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ engine::engine(const int argc, char* argv[]) {
|
||||||
|
|
||||||
input = std::make_unique<Input>();
|
input = std::make_unique<Input>();
|
||||||
physics = std::make_unique<Physics>();
|
physics = std::make_unique<Physics>();
|
||||||
imgui = std::make_unique<ImGuiLayer>();
|
imgui = std::make_unique<prism::imgui_backend>();
|
||||||
assetm = std::make_unique<AssetManager>();
|
assetm = std::make_unique<AssetManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
24
engine/core/src/imguilayer.cpp → engine/core/src/imgui_backend.cpp
Executable file → Normal file
24
engine/core/src/imguilayer.cpp → engine/core/src/imgui_backend.cpp
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
||||||
#include "imguilayer.hpp"
|
#include "imgui_backend.hpp"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <imgui_stdlib.h>
|
#include <imgui_stdlib.h>
|
||||||
|
@ -7,6 +7,8 @@
|
||||||
#include "platform.hpp"
|
#include "platform.hpp"
|
||||||
#include "assertions.hpp"
|
#include "assertions.hpp"
|
||||||
|
|
||||||
|
using prism::imgui_backend;
|
||||||
|
|
||||||
const std::map<ImGuiKey, InputButton> imToPl = {
|
const std::map<ImGuiKey, InputButton> imToPl = {
|
||||||
{ImGuiKey_Tab, InputButton::Tab},
|
{ImGuiKey_Tab, InputButton::Tab},
|
||||||
{ImGuiKey_LeftArrow, InputButton::LeftArrow},
|
{ImGuiKey_LeftArrow, InputButton::LeftArrow},
|
||||||
|
@ -31,7 +33,7 @@ const std::map<ImGuiKey, InputButton> imToPl = {
|
||||||
{ImGuiKey_Z, InputButton::Z}
|
{ImGuiKey_Z, InputButton::Z}
|
||||||
};
|
};
|
||||||
|
|
||||||
ImGuiLayer::ImGuiLayer() {
|
imgui_backend::imgui_backend() {
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
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();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
const auto [width, height] = platform::get_window_size(0);
|
const auto [width, height] = platform::get_window_size(0);
|
||||||
|
@ -190,7 +192,7 @@ void ImGuiLayer::begin_frame(const float delta_time) {
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiLayer::render(int index) {
|
void imgui_backend::render(int index) {
|
||||||
Expects(index >= 0);
|
Expects(index >= 0);
|
||||||
|
|
||||||
if(index == 0) {
|
if(index == 0) {
|
||||||
|
@ -199,19 +201,19 @@ void ImGuiLayer::render(int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiLayer::process_key_down(unsigned int keyCode) {
|
void imgui_backend::process_key_down(unsigned int key_code) {
|
||||||
Expects(keyCode >= 0);
|
Expects(key_code >= 0);
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
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) {
|
void imgui_backend::process_key_up(unsigned int key_code) {
|
||||||
Expects(keyCode >= 0);
|
Expects(key_code >= 0);
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
io.KeysDown[keyCode] = false;
|
io.KeysDown[key_code] = false;
|
||||||
}
|
}
|
Reference in a new issue