mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
feat: block switching (#2)
* feat: add item tab item in dev panel * feat: add block switching via mouse wheel
This commit is contained in:
@@ -48,6 +48,7 @@ private:
|
||||
void show_settings_tab_item();
|
||||
void show_world_tab_item();
|
||||
void show_player_tab_item();
|
||||
void show_items_tab_item();
|
||||
|
||||
void update_config_view();
|
||||
void update_player_profile();
|
||||
|
||||
@@ -42,6 +42,8 @@ private:
|
||||
|
||||
float m_xz_speed = 0.0f;
|
||||
|
||||
unsigned m_place_block = 1;
|
||||
|
||||
glm::vec3 direction = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
glm::vec3 move_distance{0.0f, 0.0f, 0.0f};
|
||||
// player is tow block tall, the pos is the lower pos
|
||||
@@ -85,6 +87,7 @@ public:
|
||||
void change_mode(GameMode mode);
|
||||
void hot_reload();
|
||||
void set_player_pos(const glm::vec3& pos);
|
||||
void set_place_block(unsigned id);
|
||||
void update(float delta_time);
|
||||
void update_front_vec(float offset_x, float offset_y);
|
||||
void update_player_move_state(int key, int action);
|
||||
@@ -97,6 +100,8 @@ public:
|
||||
float& deceleration();
|
||||
float& g();
|
||||
|
||||
unsigned place_block() const;
|
||||
|
||||
Gait& gait();
|
||||
GameMode& game_mode();
|
||||
};
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <vector>
|
||||
namespace Cubed {
|
||||
|
||||
class MapTable {
|
||||
private:
|
||||
static std::unordered_map<unsigned, std::string> id_to_name_map;
|
||||
static std::unordered_map<size_t, unsigned> name_to_id_map;
|
||||
static inline std::unordered_map<unsigned, std::string> id_to_name_map;
|
||||
static inline std::unordered_map<size_t, unsigned> name_to_id_map;
|
||||
static inline std::vector<std::string> item_id_to_name;
|
||||
|
||||
public:
|
||||
// please using reference
|
||||
static const std::string& get_name_from_id(unsigned id);
|
||||
static std::string_view get_name_from_id(unsigned id);
|
||||
static unsigned get_id_from_name(const std::string& name);
|
||||
static std::string_view item_name(unsigned id);
|
||||
static const std::vector<std::string>& item_map();
|
||||
static void init_map();
|
||||
};
|
||||
|
||||
|
||||
@@ -13,9 +13,16 @@ private:
|
||||
GLuint m_ui_array;
|
||||
GLfloat m_max_aniso = 0.0f;
|
||||
int m_aniso = 1;
|
||||
|
||||
std::vector<GLuint> m_item_textures;
|
||||
void load_block_status(unsigned status_id);
|
||||
void load_block_texture(unsigned block_id);
|
||||
void load_item_texture(const std::string& name);
|
||||
void load_ui_texture(unsigned id);
|
||||
void init_item();
|
||||
void init_block();
|
||||
void init_ui();
|
||||
void init_block_status();
|
||||
|
||||
public:
|
||||
TextureManager();
|
||||
@@ -25,6 +32,7 @@ public:
|
||||
GLuint get_block_status_array() const;
|
||||
GLuint get_texture_array() const;
|
||||
GLuint get_ui_array() const;
|
||||
const std::vector<GLuint>& item_textures() const;
|
||||
// Must call after MapTable::init_map() and glfwMakeContextCurrent(window);
|
||||
void init_texture();
|
||||
void hot_reload();
|
||||
|
||||
Reference in New Issue
Block a user