[Wesnoth-commits] r9923 - in /trunk/src: game.cpp multiplayer.cpp multiplayer_wait.cpp playcampaign.cpp show_dialog.cpp show_dialog.hpp (February 02, 2006 - 06:10)

Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Headers

 

Author: rusty
Date: Thu Feb  2 06:09:21 2006
New Revision: 9923

URL: http://svn.gna.org/viewcvs/wesnoth?rev=9923&view=rev
Log:
Generalize network dialog so it can do uploads as well (fixes https://gna.org/bugs/index.php?func=detailitem&item_id=4408)
We now use caller-supplied title for dialog instead of "Receiving data..."

Modified:
    trunk/src/game.cpp
    trunk/src/multiplayer.cpp
    trunk/src/multiplayer_wait.cpp
    trunk/src/playcampaign.cpp
    trunk/src/show_dialog.cpp
    trunk/src/show_dialog.hpp

Modified: trunk/src/game.cpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=9923&r1=9922&r2=9923&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Thu Feb  2 06:09:21 2006
@@ -852,7 +852,7 @@
 		cfg.add_child("request_campaign_list");
 		network::send_data(cfg,sock);
 
-		network::connection res = gui::network_data_dialog(disp(),_("Awaiting response from server"),cfg,sock);
+		network::connection res = gui::network_receive_dialog(disp(),_("Asking for campaign list"),cfg,sock);
 		if(!res) {
 			return;
 		}
@@ -971,7 +971,7 @@
 		request.add_child("request_campaign")["name"] = campaigns[index];
 		network::send_data(request,sock);
 
-		res = gui::network_data_dialog(disp(),_("Downloading campaign..."),cfg,sock);
+		res = gui::network_receive_dialog(disp(),_("Downloading campaign..."),cfg,sock);
 		if(!res) {
 			return;
 		}
@@ -1065,7 +1065,7 @@
 	std::cerr << "uploading campaign...\n";
 	network::send_data(data,sock);
 
-	sock = gui::network_data_dialog(disp(),_("Awaiting response from server"),data,sock);
+	sock = gui::network_send_dialog(disp(),_("Sending campaign"),data,sock);
 	if(!sock) {
 		gui::show_error_message(disp(), _("Connection timed out"));
 	} else if(data.child("error")) {

Modified: trunk/src/multiplayer.cpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer.cpp?rev=9923&r1=9922&r2=9923&view=diff
==============================================================================
--- trunk/src/multiplayer.cpp (original)
+++ trunk/src/multiplayer.cpp Thu Feb  2 06:09:21 2006
@@ -130,8 +130,8 @@
 		}
 
 		data.clear();
-		network::connection data_res = gui::network_data_dialog(
-				disp,_("Connecting to remote host..."),data);
+		network::connection data_res = gui::network_receive_dialog(
+				disp,_("Reading from Server..."),data);
 		mp::check_response(data_res, data);
 
 		// Backwards-compatibility "version" attribute

Modified: trunk/src/multiplayer_wait.cpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_wait.cpp?rev=9923&r1=9922&r2=9923&view=diff
==============================================================================
--- trunk/src/multiplayer_wait.cpp (original)
+++ trunk/src/multiplayer_wait.cpp Thu Feb  2 06:09:21 2006
@@ -166,7 +166,7 @@
 void wait::join_game(bool observe)
 {
 	for(;;) {
-		network::connection data_res = gui::network_data_dialog(disp(),
+		network::connection data_res = gui::network_receive_dialog(disp(),
 				_("Getting game data..."), level_);
 		check_response(data_res, level_);
 

Modified: trunk/src/playcampaign.cpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/playcampaign.cpp?rev=9923&r1=9922&r2=9923&view=diff
==============================================================================
--- trunk/src/playcampaign.cpp (original)
+++ trunk/src/playcampaign.cpp Thu Feb  2 06:09:21 2006
@@ -283,7 +283,7 @@
 			config cfg;
 			do {
 				cfg.clear();
-				network::connection data_res = gui::network_data_dialog(disp,
+				network::connection data_res = gui::network_receive_dialog(disp,
 						_("Downloading next level..."), cfg);
 				if(!data_res)
 					throw network::error(_("Connection timed out"));

Modified: trunk/src/show_dialog.cpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/show_dialog.cpp?rev=9923&r1=9922&r2=9923&view=diff
==============================================================================
--- trunk/src/show_dialog.cpp (original)
+++ trunk/src/show_dialog.cpp Thu Feb  2 06:09:21 2006
@@ -837,10 +837,8 @@
 
 namespace gui {
 
-network::connection network_data_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num)
-{
-	const std::string title = _("Receiving data...");
-
+	network::connection network_data_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num, network::statistics (*get_stats)(network::connection handle))
+{
 	const size_t width = 300;
 	const size_t height = 80;
 	const size_t border = 20;
@@ -853,7 +851,7 @@
 	std::vector<gui::button*> buttons_ptr(1,&cancel_button);
 
 	surface_restorer restorer;
-	gui::draw_dialog(left,top,width,height,disp.video(),title,NULL,&buttons_ptr,&restorer);
+	gui::draw_dialog(left,top,width,height,disp.video(),msg,NULL,&buttons_ptr,&restorer);
 
 	const SDL_Rect progress_rect = {left+border,top+border,width-border*2,height-border*2};
 	gui::progress_bar progress(disp.video());
@@ -862,12 +860,12 @@
 	events::raise_draw_event();
 	disp.flip();
 
-	network::statistics old_stats = network::get_receive_stats(connection_num);
+	network::statistics old_stats = get_stats(connection_num);
 
 	cfg.clear();
 	for(;;) {
 		const network::connection res = network::receive_data(cfg,connection_num,100);
-		const network::statistics stats = network::get_receive_stats(connection_num);
+		const network::statistics stats = get_stats(connection_num);
 		if(stats.current_max != 0 && stats != old_stats) {
 			old_stats = stats;
 			progress.set_progress_percent((stats.current*100)/stats.current_max);
@@ -888,6 +886,18 @@
 			return res;
 		}
 	}
+}
+
+network::connection network_send_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num)
+{
+	return network_data_dialog(disp, msg, cfg, connection_num,
+							   network::get_send_stats);
+}
+
+network::connection network_receive_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num)
+{
+	return network_data_dialog(disp, msg, cfg, connection_num,
+							   network::get_receive_stats);
 }
 
 namespace {

Modified: trunk/src/show_dialog.hpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/show_dialog.hpp?rev=9923&r1=9922&r2=9923&view=diff
==============================================================================
--- trunk/src/show_dialog.hpp (original)
+++ trunk/src/show_dialog.hpp Thu Feb  2 06:09:21 2006
@@ -140,7 +140,8 @@
 
 void show_error_message(display &disp, std::string const &message);
 
-network::connection network_data_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0);
+network::connection network_send_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0);
+network::connection network_receive_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0);
 network::connection network_connect_dialog(display& disp, const std::string& msg, const std::string& hostname, int port);
 
 void check_quit(CVideo &video);



Related Mails




Powered by MHonArc, Updated Thu Feb 02 07:00:13 2006