Author: mordante
Date: Sat Apr  5 16:52:25 2008
New Revision: 25583

URL: http://svn.gna.org/viewcvs/wesnoth?rev=25583&view=rev
Log:
Add the first ugly proof-of-concept for the new gui library. Still buggy and
barely funtioning but it works. Added the 'hidden' parameter --new-widgets 
which will use the new gui toolkit. Atm only the addon connection dialog uses
the new code.

Modified:
    trunk/src/game.cpp

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=25583&r1=25582&r2=25583&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Sat Apr  5 16:52:25 2008
@@ -29,6 +29,8 @@
 #include "game_errors.hpp"
 #include "gamestatus.hpp"
 #include "gettext.hpp"
+#include "gui/dialogs/addon_connect.hpp"
+#include "gui/widgets/button.hpp"
 #include "help.hpp"
 #include "hotkeys.hpp"
 #include "intro.hpp"
@@ -94,6 +96,8 @@
 
 namespace {
 
+static bool new_widgets = false;
+
 class game_controller
 {
 public:
@@ -294,6 +298,9 @@
                } else if (val.substr(0, 6) == "--log-") {
                } else if(val == "--nosound") {
                        no_sound = true;
+               } else if(val == "--new-widgets") {
+                       // This is a hidden option to enable the new widget 
toolkit.
+                       new_widgets = true;
                } else if(val[0] == '-') {
                        std::cerr << "unknown option: " << val << std::endl;
                        throw config::error("unknown option");
@@ -1077,16 +1084,30 @@
        void game_controller::manage_addons()
        {
                int res;
-
-               gui::dialog d(disp(),
-                                   _("Connect to Server"),
-                                   _("You will now connect to a server to 
download add-ons."),
-                                   gui::OK_CANCEL);
-               d.set_textbox(_("Server: "), preferences::campaign_server());
-               d.add_button( new gui::dialog_button(disp().video(), _("Remove 
Add-ons"),
-                       gui::button::TYPE_PRESS, 2), gui::dialog::BUTTON_EXTRA);
-               res = d.show();
-               const std::string host = d.textbox_text();
+               std::string host;
+               if(new_widgets) {
+                       gui2::taddon_connect addon_dlg;
+                       
+                       addon_dlg.set_host_name(preferences::campaign_server());
+                       addon_dlg.show(disp().video());
+                       
+                       res = addon_dlg.get_retval();
+                       if(res == gui2::tbutton::OK) {
+                               res = 0;
+                               host = addon_dlg.host_name();
+                       } 
+               } else {
+
+                       gui::dialog d(disp(),
+                                               _("Connect to Server"),
+                                               _("You will now connect to a 
server to download add-ons."),
+                                               gui::OK_CANCEL);
+                       d.set_textbox(_("Server: "), 
preferences::campaign_server());
+                       d.add_button( new gui::dialog_button(disp().video(), 
_("Remove Add-ons"),
+                               gui::button::TYPE_PRESS, 2), 
gui::dialog::BUTTON_EXTRA);
+                       res = d.show();
+                       host = d.textbox_text();
+               }
 
                if (res == 0 )  // Get Add-Ons
                {


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

Reply via email to