#pragma once #include #include #include #include namespace extra2d { // 前向声明 class Input; class TimerManager; // ============================================================================ // Application 配置 // ============================================================================ enum class PlatformType { Auto = 0, PC, Switch }; struct AppConfig { std::string title = "Easy2D Application"; int width = 800; int height = 600; bool fullscreen = false; bool resizable = true; bool vsync = true; int fpsLimit = 0; int msaaSamples = 0; PlatformType platform = PlatformType::Auto; bool enableCursors = true; bool enableDpiScale = false; }; // ============================================================================ // Application 单例 - 应用主控 // ============================================================================ class Application { public: 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_; } Input &input(); TimerManager &timers(); float deltaTime() const { return deltaTime_; } float totalTime() const { return totalTime_; } int fps() const { return currentFps_; } const AppConfig &getConfig() const { return config_; } private: Application() = default; ~Application(); void mainLoop(); void update(); AppConfig config_; UniquePtr window_; UniquePtr timerManager_; bool initialized_ = false; bool running_ = false; bool paused_ = false; bool shouldQuit_ = false; float deltaTime_ = 0.0f; float totalTime_ = 0.0f; double lastFrameTime_ = 0.0; int frameCount_ = 0; float fpsTimer_ = 0.0f; int currentFps_ = 0; }; } // namespace extra2d