diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 407863b3..9ff7f9f9 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -221,6 +221,7 @@ namespace Components if (!object.is_array()) { Logger::Print("Favourites storage file is invalid!\n"); + Game::MessageBox("Favourites storage file is invalid!", "Error"); return; } @@ -229,7 +230,11 @@ namespace Components for (unsigned int i = 0; i < storedServers.size(); i++) { if (!storedServers[i].is_string()) continue; - if (storedServers[i].string_value() == server) return; + if (storedServers[i].string_value() == server) + { + Game::MessageBox("Server already marked as favourite.", "Error"); + return; + } servers.push_back(storedServers[i].string_value()); } @@ -239,6 +244,7 @@ namespace Components json11::Json data = json11::Json(servers); Utils::WriteFile("players/favourites.json", data.dump()); + Game::MessageBox("Server added to favourites.", "Success"); } void ServerList::LoadFavourties() @@ -253,6 +259,7 @@ namespace Components if (!object.is_array()) { Logger::Print("Favourites storage file is invalid!\n"); + Game::MessageBox("Favourites storage file is invalid!", "Error"); return; } diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 3416574d..acf79366 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -241,4 +241,11 @@ namespace Game return ASSET_TYPE_INVALID; } -} \ No newline at end of file + + void MessageBox(std::string message, std::string title) + { + SetConsole("com_errorMessage", message.data()); + SetConsole("com_errorTitle", title.data()); + Cbuf_AddText(0, "openmenu error_popmenu_lobby"); + } +} diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 08e3a2b3..306e118a 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -281,4 +281,6 @@ namespace Game const char *DB_GetXAssetName(XAsset *asset); XAssetType DB_GetXAssetNameType(const char* name); + + void MessageBox(std::string message, std::string title); }