Use loading screen instead of network transmission screen when connecting to the MP server
This commit is contained in:
parent
abdba44e73
commit
e32b88568e
8 changed files with 30 additions and 14 deletions
|
@ -73,7 +73,8 @@ bool addons_client::request_addons_list(config& cfg)
|
|||
|
||||
config response_buf;
|
||||
|
||||
/** @todo FIXME: get rid of this legacy "campaign"/"campaigns" silliness */
|
||||
/** @todo FIXME: get rid of this legacy "campaign"/"campaigns" silliness
|
||||
*/
|
||||
|
||||
this->send_simple_request("request_campaign_list", response_buf);
|
||||
this->wait_for_transfer_done(_("Downloading list of add-ons..."));
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "gui/dialogs/addon/description.hpp"
|
||||
#include "gui/dialogs/addon/uninstall_list.hpp"
|
||||
#include "gui/dialogs/message.hpp"
|
||||
#include "gui/dialogs/network_transmission.hpp"
|
||||
#include "gui/dialogs/simple_item_selector.hpp"
|
||||
#include "gui/dialogs/transient_message.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "generators/map_create.hpp"
|
||||
#include "generators/map_generator.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "gui/dialogs/loadscreen.hpp"
|
||||
#include "gui/dialogs/lobby/lobby.hpp"
|
||||
#include "gui/dialogs/message.hpp"
|
||||
#include "gui/dialogs/multiplayer/mp_connect.hpp"
|
||||
|
@ -143,7 +144,7 @@ static std::unique_ptr<twesnothd_connection> open_connection(CVideo& video, cons
|
|||
shown_hosts.insert(hostpair(host, port));
|
||||
|
||||
config data;
|
||||
sock = gui2::tnetwork_transmission::wesnothd_connect_dialog(video, _("Connecting to Server..."), host, port);
|
||||
sock = gui2::tnetwork_transmission::wesnothd_connect_dialog(video, "connect to server", host, port);
|
||||
do {
|
||||
|
||||
if (!sock) {
|
||||
|
@ -151,7 +152,7 @@ static std::unique_ptr<twesnothd_connection> open_connection(CVideo& video, cons
|
|||
}
|
||||
|
||||
data.clear();
|
||||
gui2::tnetwork_transmission::wesnothd_receive_dialog(video, "", data, *sock);
|
||||
gui2::tnetwork_transmission::wesnothd_receive_dialog(video, "waiting", data, *sock);
|
||||
//mp::check_response(data_res, data);
|
||||
|
||||
if (data.has_child("reject") || data.has_attribute("version")) {
|
||||
|
@ -181,7 +182,7 @@ static std::unique_ptr<twesnothd_connection> open_connection(CVideo& video, cons
|
|||
}
|
||||
shown_hosts.insert(hostpair(host, port));
|
||||
sock.release();
|
||||
sock = gui2::tnetwork_transmission::wesnothd_connect_dialog(video, _("Connecting to Server..."), host, port);
|
||||
sock = gui2::tnetwork_transmission::wesnothd_connect_dialog(video, "redirect", host, port);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -298,7 +299,7 @@ static std::unique_ptr<twesnothd_connection> open_connection(CVideo& video, cons
|
|||
|
||||
// Once again send our request...
|
||||
sock->send_data(response);
|
||||
gui2::tnetwork_transmission::wesnothd_receive_dialog(video, "", data, *sock);
|
||||
gui2::tnetwork_transmission::wesnothd_receive_dialog(video, "login response", data, *sock);
|
||||
|
||||
|
||||
error = &data.child("error");
|
||||
|
|
|
@ -480,7 +480,7 @@ bool wait::download_level_data()
|
|||
while (!has_scenario_and_controllers) {
|
||||
config revc;
|
||||
bool data_res = gui2::tnetwork_transmission::wesnothd_receive_dialog(
|
||||
video(), _("Getting game data..."), revc, *wesnothd_connection_);
|
||||
video(), "download level data", revc, *wesnothd_connection_);
|
||||
|
||||
if (!data_res) {
|
||||
DBG_MP << "download_level_data bad results\n";
|
||||
|
|
|
@ -58,6 +58,12 @@ static const std::map<std::string, std::string> stages =
|
|||
{ "refresh addons", N_("Searching for installed add-ons") },
|
||||
{ "start game", N_("Starting game") },
|
||||
{ "verify cache", N_("Verifying cache") },
|
||||
{ "connect to server", N_("Connecting to server") },
|
||||
{ "login response", N_("Logging in") },
|
||||
{ "waiting", N_("Waiting for server") },
|
||||
{ "redirect", N_("Connecting to redirected server") },
|
||||
{ "next scenario", N_("Waiting for next scenario") },
|
||||
{ "download level data", N_("Getting game data") },
|
||||
};
|
||||
|
||||
namespace gui2
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "gui/widgets/progress_bar.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/dialogs/loadscreen.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "log.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
@ -96,7 +97,7 @@ void tnetwork_transmission::post_show(twindow& /*window*/)
|
|||
connection_->cancel();
|
||||
}
|
||||
|
||||
void tnetwork_transmission::wesnothd_dialog(CVideo& video, gui2::tnetwork_transmission::connection_data& conn, const std::string& msg1, const std::string& msg2)
|
||||
void tnetwork_transmission::wesnothd_dialog(CVideo& video, gui2::tnetwork_transmission::connection_data& conn, const std::string& msg)
|
||||
{
|
||||
if (video.faked()) {
|
||||
while (!conn.finished()) {
|
||||
|
@ -105,7 +106,13 @@ void tnetwork_transmission::wesnothd_dialog(CVideo& video, gui2::tnetwork_transm
|
|||
}
|
||||
}
|
||||
else {
|
||||
gui2::tnetwork_transmission(conn, msg1, msg2).show(video);
|
||||
gui2::tloadscreen::display(video, [&]() {
|
||||
gui2::tloadscreen::progress(msg.c_str());
|
||||
while(!conn.finished()) {
|
||||
conn.poll();
|
||||
SDL_Delay(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,8 +129,9 @@ struct read_wesnothd_connection_data : public gui2::tnetwork_transmission::conne
|
|||
|
||||
bool tnetwork_transmission::wesnothd_receive_dialog(CVideo& video, const std::string& msg, config& cfg, twesnothd_connection& wesnothd_connection)
|
||||
{
|
||||
assert(!msg.empty());
|
||||
read_wesnothd_connection_data gui_data(wesnothd_connection);
|
||||
wesnothd_dialog(video, gui_data, msg, _("Waiting"));
|
||||
wesnothd_dialog(video, gui_data, msg);
|
||||
return wesnothd_connection.receive_data(cfg);
|
||||
}
|
||||
|
||||
|
@ -138,9 +146,10 @@ struct connect_wesnothd_connection_data : public gui2::tnetwork_transmission::co
|
|||
|
||||
std::unique_ptr<twesnothd_connection> tnetwork_transmission::wesnothd_connect_dialog(CVideo& video, const std::string& msg, const std::string& hostname, int port)
|
||||
{
|
||||
assert(!msg.empty());
|
||||
std::unique_ptr<twesnothd_connection> res(new twesnothd_connection(hostname, std::to_string(port)));
|
||||
connect_wesnothd_connection_data gui_data(*res);
|
||||
wesnothd_dialog(video, gui_data, msg, _("Connecting"));
|
||||
wesnothd_dialog(video, gui_data, msg);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace gui2
|
|||
class tnetwork_transmission : public tdialog
|
||||
{
|
||||
public:
|
||||
//A wrapper of eigher a twesnothd_connection or a network_asio::connection
|
||||
//A wrapper of either a twesnothd_connection or a network_asio::connection
|
||||
class connection_data
|
||||
{
|
||||
public:
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
static std::unique_ptr<twesnothd_connection> wesnothd_connect_dialog(CVideo& video, const std::string& msg, const std::string& hostname, int port);
|
||||
|
||||
private:
|
||||
static void wesnothd_dialog(CVideo& video, gui2::tnetwork_transmission::connection_data& conn, const std::string& msg1, const std::string& msg2);
|
||||
static void wesnothd_dialog(CVideo& video, gui2::tnetwork_transmission::connection_data& conn, const std::string& msg);
|
||||
connection_data* connection_;
|
||||
|
||||
class pump_monitor : public events::pump_monitor
|
||||
|
|
|
@ -281,7 +281,7 @@ void playmp_controller::wait_for_upload()
|
|||
while(true) {
|
||||
try {
|
||||
const bool res = gui2::tnetwork_transmission::wesnothd_receive_dialog(
|
||||
gui_->video(), _("Waiting for next scenario..."), cfg, mp_info_->wesnothd_connection);
|
||||
gui_->video(), "next scenario", cfg, mp_info_->wesnothd_connection);
|
||||
|
||||
if(res) {
|
||||
if (turn_data_.process_network_data_from_reader() == turn_info::PROCESS_END_LINGER) {
|
||||
|
|
Loading…
Add table
Reference in a new issue