Author: sapient
Date: Sat Jun  2 03:30:41 2007
New Revision: 18001

URL: http://svn.gna.org/viewcvs/wesnoth?rev=18001&view=rev
Log:
   * ability to view a list of MP servers with the Join Game dialog

Modified:
    trunk/changelog
    trunk/src/construct_dialog.hpp
    trunk/src/multiplayer.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=18001&r1=18000&r2=18001&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sat Jun  2 03:30:41 2007
@@ -21,6 +21,7 @@
    * fixed bug with the number of turns to reach when crossing ZoC
    * allow to choose the direction from where attacking, even when you
      are just near the enemy unit.
+   * ability to view a list of MP servers with the Join Game dialog
  * Miscellaneous and bugfixes
    * fix bug #4299: word wrap for menus with very long option strings
    * various bugfixes and code cleanups

Modified: trunk/src/construct_dialog.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/construct_dialog.hpp?rev=18001&r1=18000&r2=18001&view=diff
==============================================================================
--- trunk/src/construct_dialog.hpp (original)
+++ trunk/src/construct_dialog.hpp Sat Jun  2 03:30:41 2007
@@ -202,6 +202,7 @@
        menu &get_menu();
        bool done() const { return (result_ != CONTINUE_DIALOG); }
        const std::string textbox_text() const { return text_widget_->text();}
+       dialog_textbox& get_textbox() const { return *text_widget_; }
        const bool option_checked(unsigned int option_index=0);
        display& get_display() { return disp_; }
 
@@ -218,7 +219,6 @@
        //refresh - forces the display to refresh
        void refresh();
        label& get_message() const { return *message_; }
-       dialog_textbox& get_textbox() const { return *text_widget_; }
        dialog_frame& get_frame();
 
 private:

Modified: trunk/src/multiplayer.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer.cpp?rev=18001&r1=18000&r2=18001&view=diff
==============================================================================
--- trunk/src/multiplayer.cpp (original)
+++ trunk/src/multiplayer.cpp Sat Jun  2 03:30:41 2007
@@ -13,6 +13,7 @@
 
 #include "global.hpp"
 
+#include "construct_dialog.hpp"
 #include "game_config.hpp"
 #include "gettext.hpp"
 #include "log.hpp"
@@ -90,6 +91,29 @@
        SIMPLE_SERVER
 };
 
+class server_button : public gui::dialog_button
+{
+public:
+       server_button(CVideo &vid): dialog_button(vid, _("View List"))
+       {}
+protected:
+       int action(gui::dialog_process_info &dp_info)
+       {
+               gui::dialog server_dialog(dialog()->get_display(), _("List of 
Servers"),
+                       _("Choose a known server from the list"), 
gui::OK_CANCEL);
+               std::vector<std::string> servers;
+               servers.push_back(preferences::official_network_host());
+               //add alternate servers here...
+               //just a hardcoded list for now
+               servers.push_back("games.tuxfamily.org:14998");
+               server_dialog.set_menu(servers);
+               if(server_dialog.show() >= 0) {
+                       
dialog()->get_textbox().set_text(servers[server_dialog.result()]);
+               }
+               dp_info.clear_buttons();
+               return gui::CONTINUE_DIALOG;
+       }
+};
 }
 
 static server_type open_connection(display& disp, const std::string& 
original_host)
@@ -97,14 +121,13 @@
        std::string h = original_host;
 
        if(h.empty()) {
-               h = preferences::network_host();
-               const int res = gui::show_dialog(disp, NULL, _("Connect to 
Host"), "",
-                               gui::OK_CANCEL, NULL, NULL,
-                               _("Choose host to connect to: "), &h);
-
-               if(res != 0 || h.empty()) {
+               gui::dialog d(disp, _("Connect to Host"), "", gui::OK_CANCEL);
+               d.set_textbox(_("Choose host to connect to: "), 
preferences::network_host());
+               d.add_button( new server_button(disp.video()), 
gui::dialog::BUTTON_EXTRA);
+               if(d.show() || d.textbox_text().empty()) {
                        return ABORT_SERVER;
                }
+               h = d.textbox_text();
        }
 
        network::connection sock;


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to