mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
- Introduce Event variant and Overloaded helper for input handling - Move game state (camera, client_world, dev_panel) from App to WorldScene - Add SceneManager with push/pop/change operations for scene stack - Refactor input callbacks to dispatch events through scene hierarchy - Extract Argument struct to separate header - Update Renderer and WorldRenderer to accept world reference - Replace global input state with event-driven processing in ClientPlayer, Camera, etc.
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#pragma once
|
|
#include "Cubed/scene/scene.hpp"
|
|
|
|
#include <memory>
|
|
#include <stack>
|
|
#include <vector>
|
|
namespace Cubed {
|
|
class App;
|
|
class SceneManager {
|
|
public:
|
|
SceneManager(const SceneManager&) = delete;
|
|
SceneManager(SceneManager&&) = delete;
|
|
SceneManager& operator=(const SceneManager&) = delete;
|
|
SceneManager& operator=(SceneManager&&) = delete;
|
|
SceneManager(App& app);
|
|
~SceneManager();
|
|
|
|
void update(float dt);
|
|
void render(Renderer& renderer);
|
|
|
|
bool handle_event(const Event& e);
|
|
|
|
void request_change(SceneType type);
|
|
void request_push(SceneType type);
|
|
void request_pop();
|
|
|
|
App& app();
|
|
|
|
private:
|
|
enum class OperationType { PUSH, POP, CHANGE };
|
|
struct SceneOperation {
|
|
OperationType type;
|
|
std::optional<SceneType> scene;
|
|
};
|
|
|
|
App& m_app;
|
|
std::vector<std::unique_ptr<Scene>> m_pending_delete_scene;
|
|
std::optional<SceneOperation> m_operation;
|
|
std::stack<std::unique_ptr<Scene>> m_scenes;
|
|
void process_operation();
|
|
void change(SceneType type);
|
|
void push(SceneType type);
|
|
void pop();
|
|
|
|
std::unique_ptr<Scene> create_scene(SceneType);
|
|
};
|
|
} // namespace Cubed
|