aa
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openceg {
|
||||
|
||||
struct WindowConfig {
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
std::string title = "OpenCGE";
|
||||
};
|
||||
|
||||
struct MeshConfig {
|
||||
std::string shape = "quad";
|
||||
std::array<float, 4> color{0.5F, 0.5F, 0.5F, 1.0F};
|
||||
};
|
||||
|
||||
struct ActorConfig {
|
||||
std::string name;
|
||||
std::string init_function;
|
||||
std::string tick_function;
|
||||
std::array<float, 2> position{0.0F, 0.0F};
|
||||
std::array<float, 2> facing{1.0F, 0.0F};
|
||||
MeshConfig mesh;
|
||||
};
|
||||
|
||||
struct InputBindingConfig {
|
||||
std::string action;
|
||||
std::vector<int> keys;
|
||||
std::vector<int> mouse_buttons;
|
||||
};
|
||||
|
||||
struct GameConfig {
|
||||
WindowConfig window;
|
||||
std::vector<InputBindingConfig> input_bindings;
|
||||
std::vector<ActorConfig> actors;
|
||||
};
|
||||
|
||||
// 从 JSON 加载游戏场景配置(类似 Godot 的场景描述)。
|
||||
class ConfigLoader {
|
||||
public:
|
||||
bool load(const std::string& path);
|
||||
const GameConfig& config() const;
|
||||
const std::string& last_error() const;
|
||||
|
||||
private:
|
||||
GameConfig config_;
|
||||
std::string last_error_;
|
||||
};
|
||||
|
||||
} // namespace openceg
|
||||
Reference in New Issue
Block a user