diff --git a/include/app/application.h b/include/app/application.h index b03e658..56c953e 100644 --- a/include/app/application.h +++ b/include/app/application.h @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -11,12 +10,9 @@ namespace extra2d { // 前向声明 class Input; class AudioEngine; -class SceneManager; -class ResourceManager; class TimerManager; class EventQueue; class EventDispatcher; -class Camera; // ============================================================================ // Application 配置 @@ -32,12 +28,10 @@ struct AppConfig { bool resizable = true; bool vsync = true; int fpsLimit = 0; - BackendType Renderer = BackendType::OpenGL; int msaaSamples = 0; PlatformType platform = PlatformType::Auto; - // 窗口高级配置 - bool enableCursors = true; // 是否启用光标 - bool enableDpiScale = false; // 是否启用DPI缩放 + bool enableCursors = true; + bool enableDpiScale = false; }; // ============================================================================ @@ -45,53 +39,32 @@ struct AppConfig { // ============================================================================ class Application { public: - // Meyer's 单例 static Application &instance(); - // 禁止拷贝 Application(const Application &) = delete; Application &operator=(const Application &) = delete; - // ------------------------------------------------------------------------ - // 生命周期 - // ------------------------------------------------------------------------ bool init(const AppConfig &config); void shutdown(); void run(); void quit(); - // ------------------------------------------------------------------------ - // 状态控制 - // ------------------------------------------------------------------------ void pause(); void resume(); bool isPaused() const { return paused_; } bool isRunning() const { return running_; } - // ------------------------------------------------------------------------ - // 子系统访问 - // ------------------------------------------------------------------------ Window &window() { return *window_; } - Renderer &renderer() { return *renderer_; } Input &input(); AudioEngine &audio(); - SceneManager &scenes(); - ResourceManager &resources(); TimerManager &timers(); EventQueue &eventQueue(); EventDispatcher &eventDispatcher(); - Camera &camera(); - - // ------------------------------------------------------------------------ - // 便捷方法 - // ------------------------------------------------------------------------ - void enterScene(IntrusivePtr scene); float deltaTime() const { return deltaTime_; } float totalTime() const { return totalTime_; } int fps() const { return currentFps_; } - // 获取配置 const AppConfig &getConfig() const { return config_; } private: @@ -100,28 +73,19 @@ private: void mainLoop(); void update(); - void render(); - // 配置 AppConfig config_; - // 子系统 UniquePtr window_; - UniquePtr renderer_; - UniquePtr sceneManager_; - UniquePtr resourceManager_; UniquePtr timerManager_; UniquePtr eventQueue_; UniquePtr eventDispatcher_; - UniquePtr camera_; - // 状态 bool initialized_ = false; bool running_ = false; bool paused_ = false; bool shouldQuit_ = false; - // 时间 float deltaTime_ = 0.0f; float totalTime_ = 0.0f; double lastFrameTime_ = 0.0; diff --git a/include/audio/audio_engine.h b/include/audio/audio_engine.h index 8da0ec4..2230c73 100644 --- a/include/audio/audio_engine.h +++ b/include/audio/audio_engine.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include @@ -11,37 +10,38 @@ class Sound; class AudioEngine { public: - static AudioEngine& getInstance(); + static AudioEngine &getInstance(); - AudioEngine(const AudioEngine&) = delete; - AudioEngine& operator=(const AudioEngine&) = delete; - AudioEngine(AudioEngine&&) = delete; - AudioEngine& operator=(AudioEngine&&) = delete; + AudioEngine(const AudioEngine &) = delete; + AudioEngine &operator=(const AudioEngine &) = delete; + AudioEngine(AudioEngine &&) = delete; + AudioEngine &operator=(AudioEngine &&) = delete; - bool initialize(); - void shutdown(); + bool initialize(); + void shutdown(); - IntrusivePtr loadSound(const std::string& filePath); - IntrusivePtr loadSound(const std::string& name, const std::string& filePath); + IntrusivePtr loadSound(const std::string &filePath); + IntrusivePtr loadSound(const std::string &name, + const std::string &filePath); - IntrusivePtr getSound(const std::string& name); - void unloadSound(const std::string& name); - void unloadAllSounds(); + IntrusivePtr getSound(const std::string &name); + void unloadSound(const std::string &name); + void unloadAllSounds(); - void setMasterVolume(float volume); - float getMasterVolume() const; + void setMasterVolume(float volume); + float getMasterVolume() const; - void pauseAll(); - void resumeAll(); - void stopAll(); + void pauseAll(); + void resumeAll(); + void stopAll(); private: - AudioEngine() = default; - ~AudioEngine(); + AudioEngine() = default; + ~AudioEngine(); - std::unordered_map> sounds_; - float masterVolume_ = 1.0f; - bool initialized_ = false; + std::unordered_map> sounds_; + float masterVolume_ = 1.0f; + bool initialized_ = false; }; } // namespace extra2d diff --git a/include/extra2d.h b/include/extra2d.h index c1eab85..cce5229 100644 --- a/include/extra2d.h +++ b/include/extra2d.h @@ -16,23 +16,6 @@ #include #include -// Graphics -#include -#include -#include - -// Renderer -#include -#include -#include - -// Scene -#include -#include -#include -#include -#include - // Event #include #include @@ -43,9 +26,6 @@ #include