mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
feat: add DevPanel
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Cubed/camera.hpp>
|
||||
#include <Cubed/dev_panel.hpp>
|
||||
#include <Cubed/gameplay/world.hpp>
|
||||
#include <Cubed/input.hpp>
|
||||
#include <Cubed/renderer.hpp>
|
||||
@@ -18,16 +19,26 @@ public:
|
||||
static void window_focus_callback(GLFWwindow* window, int focused);
|
||||
static void window_reshape_callback(GLFWwindow* window, int new_width, int new_height);
|
||||
static void mouse_scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
|
||||
|
||||
static void cursor_enter_callback(GLFWwindow* window, int entered);
|
||||
static int start_cubed_application(int argc, char** argv);
|
||||
static unsigned int seed();
|
||||
static float delte_time();
|
||||
static float get_fps();
|
||||
|
||||
Camera& camera();
|
||||
DevPanel& dev_panel();
|
||||
Renderer& renderer();
|
||||
TextureManager& texture_manager();
|
||||
Window& window();
|
||||
World& world();
|
||||
|
||||
|
||||
private:
|
||||
Camera m_camera;
|
||||
TextureManager m_texture_manager;
|
||||
World m_world;
|
||||
Renderer m_renderer{m_camera, m_world, m_texture_manager};
|
||||
DevPanel m_dev_panel{*this};
|
||||
Renderer m_renderer{m_camera, m_world, m_texture_manager, m_dev_panel};
|
||||
|
||||
Window m_window{m_renderer};
|
||||
|
||||
|
||||
@@ -114,8 +114,14 @@ public:
|
||||
std::abort();
|
||||
}
|
||||
table->insert_or_assign(n_key, std::forward<T>(val));
|
||||
|
||||
}
|
||||
template <typename T>
|
||||
void set_and_save(std::string_view key, T&& val) {
|
||||
set(key, std::forward(val));
|
||||
save_to_file();
|
||||
}
|
||||
toml::node_view<toml::node> val_view(std::string_view key);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
35
include/Cubed/dev_panel.hpp
Normal file
35
include/Cubed/dev_panel.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <toml++/toml.hpp>
|
||||
|
||||
namespace Cubed {
|
||||
|
||||
class App;
|
||||
class Player;
|
||||
class DevPanel {
|
||||
struct ConfigView {
|
||||
float fov;
|
||||
bool fullscreen;
|
||||
bool v_sync;
|
||||
float mouse_sensitivity;
|
||||
int width;
|
||||
int height;
|
||||
int rendering_distance;
|
||||
};
|
||||
public:
|
||||
DevPanel(App& app);
|
||||
void init();
|
||||
void render();
|
||||
|
||||
private:
|
||||
App& m_app;
|
||||
ConfigView m_config;
|
||||
Player* m_player;
|
||||
|
||||
bool m_need_save_config = false;
|
||||
int m_theme = 0;
|
||||
void show_settings_tab_item();
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -13,11 +13,12 @@ namespace Cubed {
|
||||
class Camera;
|
||||
class TextureManager;
|
||||
class World;
|
||||
class DevPanel;
|
||||
class Renderer {
|
||||
public:
|
||||
constexpr static int NUM_VAO = 5;
|
||||
|
||||
Renderer(const Camera& camera, World& world, const TextureManager& texture_manager);
|
||||
Renderer(const Camera& camera, World& world, const TextureManager& texture_manager, DevPanel& dev_panel);
|
||||
~Renderer();
|
||||
void hot_reload();
|
||||
void init();
|
||||
@@ -28,6 +29,7 @@ public:
|
||||
private:
|
||||
|
||||
const Camera& m_camera;
|
||||
DevPanel& m_dev_panel;
|
||||
const TextureManager& m_texture_manager;
|
||||
World& m_world;
|
||||
|
||||
@@ -57,6 +59,7 @@ private:
|
||||
void render_text();
|
||||
void render_ui();
|
||||
void render_world();
|
||||
void render_dev_panel();
|
||||
};
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <glad/glad.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -31,6 +32,7 @@ public:
|
||||
|
||||
static std::vector<Vertex2D> vertices(const std::string& text, float x = 0.0f, float y = 0.0f, float scale = 1.0f);
|
||||
static GLuint text_texture();
|
||||
static const std::filesystem::path& font_path();
|
||||
private:
|
||||
FT_Library m_ft;
|
||||
FT_Face m_face;
|
||||
@@ -39,6 +41,7 @@ private:
|
||||
float m_texture_height = 64;
|
||||
|
||||
static inline GLuint m_text_texture;
|
||||
static inline std::filesystem::path m_font_path{ASSETS_PATH "fonts/IBMPlexSans-Regular.ttf"};
|
||||
std::unordered_map<char8_t, Character> m_characters;
|
||||
|
||||
void load_character(char8_t c);
|
||||
|
||||
@@ -12,6 +12,7 @@ public:
|
||||
const GLFWwindow* get_glfw_window() const;
|
||||
GLFWwindow* get_glfw_window();
|
||||
void init();
|
||||
void imgui_init();
|
||||
void update_viewport();
|
||||
// end of frame to reload!
|
||||
void hot_reload();
|
||||
|
||||
Reference in New Issue
Block a user