Archived
1
Fork 0

Rename ImGuiLayer to imgui_backend

This commit is contained in:
redstrate 2021-04-20 10:37:56 -04:00
parent b918d9fd85
commit 8370dfb6d6
7 changed files with 37 additions and 31 deletions

View file

@ -13,7 +13,7 @@
#include "renderer.hpp"
#include "input.hpp"
#include "physics.hpp"
#include "imguilayer.hpp"
#include "imgui_backend.hpp"
std::unique_ptr<Mesh> load_mesh(const file::Path path) {
Expects(!path.empty());

View file

@ -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

View file

@ -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<AnimationTarget> animation_targets;
std::unique_ptr<ImGuiLayer> imgui;
std::unique_ptr<imgui_backend> imgui;
const InputButton debug_button = InputButton::Q;
};

View 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);
};
}

View file

@ -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);
};

View file

@ -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<Input>();
physics = std::make_unique<Physics>();
imgui = std::make_unique<ImGuiLayer>();
imgui = std::make_unique<prism::imgui_backend>();
assetm = std::make_unique<AssetManager>();
}

View file

@ -1,4 +1,4 @@
#include "imguilayer.hpp"
#include "imgui_backend.hpp"
#include <imgui.h>
#include <imgui_stdlib.h>
@ -7,6 +7,8 @@
#include "platform.hpp"
#include "assertions.hpp"
using prism::imgui_backend;
const std::map<ImGuiKey, InputButton> imToPl = {
{ImGuiKey_Tab, InputButton::Tab},
{ImGuiKey_LeftArrow, InputButton::LeftArrow},
@ -31,7 +33,7 @@ const std::map<ImGuiKey, InputButton> 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;
}