#pragma once #include #include #include namespace F4T::ServerBrowser { struct ServerEntry { std::string id; std::string name; std::string region; std::string worldspace; std::string mode; std::string status; std::string description; std::string host; int port{ 0 }; int players{ 0 }; int maxPlayers{ 0 }; int ping{ 0 }; bool modded{ false }; bool passworded{ false }; bool favorite{ false }; nlohmann::json ToJson() const; static ServerEntry FromJson(const nlohmann::json& a_json); }; struct BrowserFilters { std::string search; std::string region{ "Any Region" }; std::string mode{ "Any Mode" }; std::string worldspace{ "Any Worldspace" }; std::string ping{ "Any" }; bool showFull{ false }; bool hasPassword{ false }; bool modded{ false }; }; class ServerBrowserData { public: void SetFilters(const BrowserFilters& a_filters); void ResetFilters(); void ApplyFilters(); void SetAllServers(std::vector a_servers); void ToggleFavorite(const std::string& a_serverId); const ServerEntry* FindServer(const std::string& a_serverId) const; const std::vector& GetFilteredServers() const { return m_filteredServers; } const BrowserFilters& GetFilters() const { return m_filters; } std::string GetConnectionStatus() const { return m_connectionStatus; } void SetConnectionStatus(std::string a_status) { m_connectionStatus = std::move(a_status); } bool IsRefreshing() const { return m_isRefreshing; } void SetRefreshing(bool a_refreshing) { m_isRefreshing = a_refreshing; } nlohmann::json ToServerListJson() const; static std::vector CreateMockServers(); private: bool PassesFilters(const ServerEntry& a_entry) const; std::vector m_allServers; std::vector m_filteredServers; BrowserFilters m_filters; std::string m_connectionStatus{ "Online" }; bool m_isRefreshing{ false }; }; }