#pragma once #include #include #include #include #include "gfx/types.h" #include "ui/ui_window.h" #include "ui/taskbar.h" #include "ui/launcher.h" #include "ui/ui_renderer.h" class GameState; /* Animated background stuff. */ struct ScrollingText { std::string text; float x; float y_precise; /* sub-pixel animation. */ float speed; int render_y; /* For pixel-perfect rendering. */ }; class Desktop { public: Desktop(int screen_width, int screen_height, GameState* game_state); ~Desktop(void); void add_window(std::unique_ptr window); void handle_event(SDL_Event* event, int screen_width, int screen_height); void update(float dt, int screen_width, int screen_height); void render(const RenderContext& context); void register_session(uint32_t session_id, UIWindow* window); UIWindow* get_window_by_session_id(uint32_t session_id); UIWindow* get_focused_window(void); UIWindow* get_window_awaiting_session_id(void); private: void _set_focused_window(UIWindow* window); void _render_wallpaper(UIRenderer* ui_renderer); void _update_wallpaper(float dt, int screen_width, int screen_height); std::vector> _windows; std::unique_ptr _taskbar; std::unique_ptr _launcher; UIWindow* _focused_window; UIWindow* _window_awaiting_session_id; std::map _session_windows; GameState* _game_state; std::vector _background_text; std::vector _snippets; bool _launcher_is_open; };