diff --git a/src/gui/dialogs/multiplayer/lobby.cpp b/src/gui/dialogs/multiplayer/lobby.cpp index e895be9194dcd..52e0a9055ec67 100644 --- a/src/gui/dialogs/multiplayer/lobby.cpp +++ b/src/gui/dialogs/multiplayer/lobby.cpp @@ -219,14 +219,6 @@ void modify_grid_with_data(grid* grid, const std::map& } } -void set_visible_if_exists(grid* grid, const std::string& id, bool visible) -{ - if(widget* w = grid->find(id, false)) { - //w->set_visible(visible ? widget::visibility::visible : widget::visibility::invisible); - w->set_visible(visible ? widget::visibility::visible : widget::visibility::hidden); - } -} - std::string colorize(const std::string& str, const std::string& color) { if(color.empty()) { @@ -236,6 +228,54 @@ std::string colorize(const std::string& str, const std::string& color) return (formatter() << "" << str << "").str(); } +bool handle_addon_requirements_gui(CVideo& v, const std::vector& reqs, mp::game_info::ADDON_REQ addon_outcome) +{ + if(addon_outcome == mp::game_info::CANNOT_SATISFY) { + std::string e_title = _("Incompatible User-made Content."); + std::string err_msg = _("This game cannot be joined because the host has out-of-date add-ons that are incompatible with your version. You might wish to suggest that the host's add-ons be updated."); + + err_msg +="\n\n"; + err_msg += _("Details:"); + err_msg += "\n"; + + for(const mp::game_info::required_addon & a : reqs) { + if (a.outcome == mp::game_info::CANNOT_SATISFY) { + err_msg += font::unicode_bullet + " " + a.message + "\n"; + } + } + gui2::show_message(v, e_title, err_msg, message::auto_close); + + return false; + } else if(addon_outcome == mp::game_info::NEED_DOWNLOAD) { + std::string e_title = _("Missing User-made Content."); + std::string err_msg = _("This game requires one or more user-made addons to be installed or updated in order to join.\nDo you want to try to install them?"); + + err_msg +="\n\n"; + err_msg += _("Details:"); + err_msg += "\n"; + + std::vector needs_download; + for(const mp::game_info::required_addon & a : reqs) { + if(a.outcome == mp::game_info::NEED_DOWNLOAD) { + err_msg += font::unicode_bullet + " " + a.message + "\n"; + + needs_download.push_back(a.addon_id); + } + } + + assert(needs_download.size() > 0); + + if(gui2::show_message(v, e_title, err_msg, message::yes_no_buttons, true) == gui2::window::OK) { + // Begin download session + ad_hoc_addon_fetch_session(v, needs_download); + + return true; + } + } + + return false; +} + } // end anonymous namespace void mp_lobby::update_gamelist() @@ -494,9 +534,6 @@ void mp_lobby::adjust_game_row_contents(const mp::game_info& game, int idx, grid map.set_config(&game_config_); map.set_map_data(game.map_data); - connect_signal_mouse_left_double_click(row_panel, - std::bind(&mp_lobby::join_or_observe, this, idx)); - button& join_button = find_widget