// // Created by darman on 9/24/26. // #pragma once #include "Engine/Platform/SdlContext.h" #include "Engine/Platform/Window.h" #include "Engine/Time/FrameClock.h" #include "Engine/Time/SimClock.h" #include namespace SiegeDeck::Engine { class Application; struct AppConfig { string Title = "Siege Deck"; string Version = "0.1.0"; int32 Width = 1280; int32 Height = 720; bool Fullscreen = false; bool Vsync = false; uint64 Seed = 0; Optional MaxFrames = None; // Bad arguments are reported, not thrown: main prints them and exits with a usage error. static std::expected FromArgs(int argc, char* argv[]); }; struct EngineContext { Application& App; Window& MainWindow; const FrameClock& Frame; // real time: UI, card hand, camera SimClock& Sim; // sim time: SetSpeed(0) is the planning phase }; class Application { public: explicit Application(AppConfig appConfig); ~Application(); Application(const Application&) = delete; Application& operator=(const Application&) = delete; Application(Application&&) = delete; Application& operator=(Application&&) = delete; int Run(); void Quit() { running = false; }; EngineContext& GetContext() { return context; } private: void HandleEvents(); void DrawFrame(double alpha); static constexpr double kSimDt = 1.0 / 60.0; static constexpr int32 kMaxStepsPerFrame = 8; AppConfig config; // Members are constructed in declaration order and destroyed in reverse, // so anything that depends on another subsystem is declared after it. SdlContext sdl; Window window; FrameClock frameClock; SimClock simClock { kSimDt, kMaxStepsPerFrame }; EngineContext context; bool running = true; }; }