Author: mordante
Date: Fri May 23 20:25:20 2008
New Revision: 26800

URL: http://svn.gna.org/viewcvs/wesnoth?rev=26800&view=rev
Log:
Adding initial proof-of-concept version for the MP method selection dialog.

Added:
    trunk/data/gui/default/window/mp_method_selection.cfg   (with props)
    trunk/src/gui/dialogs/mp_method_selection.cpp   (with props)
    trunk/src/gui/dialogs/mp_method_selection.hpp   (with props)
Modified:
    trunk/po/wesnoth-lib/POTFILES.in
    trunk/src/CMakeLists.txt
    trunk/src/Makefile.am
    trunk/src/SConscript
    trunk/src/game.cpp
    trunk/src/gui/widgets/settings.cpp
    trunk/src/gui/widgets/settings.hpp

Added: trunk/data/gui/default/window/mp_method_selection.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/mp_method_selection.cfg?rev=26800&view=auto
==============================================================================
--- trunk/data/gui/default/window/mp_method_selection.cfg (added)
+++ trunk/data/gui/default/window/mp_method_selection.cfg Fri May 23 20:25:20 
2008
@@ -1,0 +1,222 @@
+###
+### Definition of the window select the way to access the addon server.
+###
+
+[window]
+       id = "mp_method_selection"
+       description = "Language selection dialog."
+
+       [resolution]
+               definition = "default"
+
+               automatic_placement = "true"
+               vertical_placement = "center"
+               horizontal_placement = "center"
+
+               [grid]
+                       
+                       [row]
+                               grow_factor = 0
+
+                               [column]
+                                       grow_factor = 1
+
+                                       border = "all"
+                                       border_size = 5
+                                       horizontal_alignment = "left"
+                                       [label]
+                                               definition = "title"
+
+                                               label = _ "Multiplayer"
+                                       [/label]
+
+                               [/column]
+
+                       [/row]
+
+                       [row]
+                               grow_factor = 1
+
+                               [column]
+                                       grow_factor = 1
+
+                                       horizontal_grow = "true"
+
+                                       [grid]
+
+                                               [row]
+                                                       grow_factor = 1
+
+                                                       [column]
+                                                               grow_factor = 0
+
+                                                               border = "all"
+                                                               border_size = 5
+                                                               
horizontal_alignment = "left"
+
+                                                               [label]
+                                                                       
definition = "default"
+
+                                                                       label = 
_ "Login:"
+                                                               [/label]
+
+                                                       [/column]
+
+                                                       [column]
+                                                               grow_factor = 1
+
+                                                               border = "all"
+                                                               border_size = 5
+                                                               horizontal_grow 
= "true"
+
+                                                               [text_box]
+                                                                       id = 
"user_name"
+                                                                       
definition = "default"
+                                                                       history 
= "mp_user_name_history"
+
+                                                                       label = 
""
+                                                               [/text_box]
+
+                                                       [/column]
+
+                                               [/row]
+
+                                       [/grid]
+
+                               [/column]
+
+                       [/row]
+
+                       [row]
+                               grow_factor = 1
+                               vertical_grow = "true"
+
+                               [column]
+                                       grow_factor = 1
+                                       horizontal_grow = "true" 
+
+                                       border = "all"
+                                       border_size = 5
+                                       horizontal_alignment = "right"
+
+                                       [listbox]
+                                               id = "method_list"
+                                               definition = "default"
+
+                                               assume_fixed_row_size = "true"
+
+                                               [list_definition]
+
+                                                       [row]
+
+                                                                [column]
+                                                                       
grow_factor = 1
+                                                                       
horizontal_grow = "true"
+
+                                                                       
[toggle_button]
+                                                                               
definition = "listbox_text" # listbox_text_with_icon
+                                                                       
[/toggle_button]
+
+                                                               [/column]
+
+
+                                                       [/row]
+
+                                               [/list_definition]
+
+                                               [list_data]
+
+                                                       [row]
+
+                                                               [column]
+                                                                       retval 
= 1
+                                                                       label = 
_ "Join Official Server"
+                                                                       tooltip 
= _ "Log on to the official Wesnoth multiplayer server"
+                                                                       icon = 
"server.png"
+                                                               [/column]
+
+                                                       [/row]
+
+                                                       [row]
+
+                                                               [column]
+                                                                       retval 
= 2
+                                                                       label = 
_ "Connect to Server"
+                                                                       tooltip 
= _ "Join a different server"
+                                                                       icon = 
"serverother.png"
+                                                               [/column]
+
+                                                       [/row]
+
+                                                       [row]
+
+                                                               [column]
+                                                                       retval 
= 3
+                                                                       label = 
_ "Local Game"
+                                                                       tooltip 
= _ "Play a multiplayer game with the AI or humans sharing the same machine"
+                                                                       icon = 
"hotseat.png"
+                                                               [/column]
+
+                                                       [/row]
+
+                                               [/list_data]
+
+                                       [/listbox]
+
+                               [/column]
+
+                       [/row]
+
+                       [row]
+                               grow_factor = 0
+
+                               [column]
+                                       grow_factor = 1
+                                       horizontal_grow = "true" 
+
+                                       [grid]
+
+                                               [row]
+                                                       grow_factor = 0
+
+                                                       [column]
+                                                               border = "all"
+                                                               border_size = 5
+                                                               
horizontal_alignment = "right"
+
+                                                               [button]
+                                                                       id = 
"ok"
+                                                                       
definition = "default"
+
+                                                                       label = 
_ "Ok"
+                                                               [/button]
+
+                                                       [/column]
+
+                                                       [column]
+                                                               border = "all"
+                                                               border_size = 5
+                                                               
horizontal_alignment = "right"
+
+                                                               [button]
+                                                                       id = 
"cancel"
+                                                                       
definition = "default"
+
+                                                                       label = 
_ "Cancel"
+                                                               [/button]
+
+                                                       [/column]
+
+                                               [/row]
+
+                                       [/grid]
+
+                               [/column]
+
+                       [/row]
+
+               [/grid]
+
+       [/resolution]
+
+[/window]

Propchange: trunk/data/gui/default/window/mp_method_selection.cfg
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/po/wesnoth-lib/POTFILES.in
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/po/wesnoth-lib/POTFILES.in?rev=26800&r1=26799&r2=26800&view=diff
==============================================================================
--- trunk/po/wesnoth-lib/POTFILES.in (original)
+++ trunk/po/wesnoth-lib/POTFILES.in Fri May 23 20:25:20 2008
@@ -6,6 +6,7 @@
 src/game_preferences_display.cpp
 src/gui/dialogs/addon_connect.cpp
 src/gui/dialogs/language_selection.cpp
+src/gui/dialogs/mp_method_selection.cpp
 src/gui/widgets/button.cpp
 src/gui/widgets/canvas.cpp
 src/gui/widgets/control.cpp

Modified: trunk/src/CMakeLists.txt
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/CMakeLists.txt?rev=26800&r1=26799&r2=26800&view=diff
==============================================================================
--- trunk/src/CMakeLists.txt (original)
+++ trunk/src/CMakeLists.txt Fri May 23 20:25:20 2008
@@ -212,6 +212,7 @@
     generic_event.cpp
     gui/dialogs/addon_connect.cpp
     gui/dialogs/language_selection.cpp
+    gui/dialogs/mp_method_selection.cpp
     gui/widgets/button.cpp
     gui/widgets/canvas.cpp
     gui/widgets/control.cpp

Modified: trunk/src/Makefile.am
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/Makefile.am?rev=26800&r1=26799&r2=26800&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Fri May 23 20:25:20 2008
@@ -69,6 +69,7 @@
        generic_event.cpp \
        gui/dialogs/addon_connect.cpp \
        gui/dialogs/language_selection.cpp \
+       gui/dialogs/mp_method_selection.cpp \
        gui/widgets/button.cpp \
        gui/widgets/canvas.cpp \
        gui/widgets/control.cpp \

Modified: trunk/src/SConscript
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=26800&r1=26799&r2=26800&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Fri May 23 20:25:20 2008
@@ -83,6 +83,7 @@
     widgets/widget.cpp
     wml_exception.cpp
     gui/dialogs/language_selection.cpp
+    gui/dialogs/mp_method_selection.cpp
     gui/dialogs/addon_connect.cpp
     gui/widgets/button.cpp
     gui/widgets/canvas.cpp

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=26800&r1=26799&r2=26800&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Fri May 23 20:25:20 2008
@@ -31,6 +31,7 @@
 #include "gettext.hpp"
 #include "gui/dialogs/addon_connect.hpp"
 #include "gui/dialogs/language_selection.hpp"
+#include "gui/dialogs/mp_method_selection.hpp"
 #include "gui/widgets/button.hpp"
 #include "help.hpp"
 #include "hotkeys.hpp"
@@ -1578,36 +1579,55 @@
        state_.campaign_type = "multiplayer";
        state_.campaign_define = "MULTIPLAYER";
 
+
+
        //Print Gui only if the user hasn't specified any server
        if( multiplayer_server_.empty() ){
-               std::vector<std::string> host_or_join;
-               std::string const pre = IMAGE_PREFIX + 
std::string("icons/icon-");
-               char const sep1 = COLUMN_SEPARATOR, sep2 = 
HELP_STRING_SEPARATOR;
-
-               host_or_join.push_back(pre + "server.png"
-                       + sep1 + _("Join Official Server")
-                       + sep2 + _("Log on to the official Wesnoth multiplayer 
server"));
-               host_or_join.push_back(pre + "serverother.png"
-                       + sep1 + _("Connect to Server")
-                       + sep2 + _("Join a different server"));
-               host_or_join.push_back(pre + "hotseat.png"
-                       + sep1 + _("Local Game")
-                       + sep2 + _("Play a multiplayer game with the AI or 
humans sharing the same machine"));
-
-               std::string login = preferences::login();
-
-               {
-                       gui::dialog d(disp(), _("Multiplayer"), "", 
gui::OK_CANCEL);
-                       d.set_menu(host_or_join);
-                       d.set_textbox(_("Login: "), login, mp::max_login_size, 
font::relative_size(250));
-                       res = d.show();
-                       login = d.textbox_text();
-               }
-               if (res < 0)
-                       return false;
-
-
-               preferences::set_login(login);
+               if(new_widgets) {
+                       gui2::tmp_method_selection dlg;
+
+                               dlg.show(disp().video());
+                               
+                               if(dlg.get_retval() == gui2::tbutton::OK) {
+                                       std::cerr << "OK\n";
+                                       res = dlg.get_choice();
+                               } else {
+                                       std::cerr << "CANCEL\n";
+                                       return false;
+
+                               }
+
+               } else {
+
+                       std::vector<std::string> host_or_join;
+                       std::string const pre = IMAGE_PREFIX + 
std::string("icons/icon-");
+                       char const sep1 = COLUMN_SEPARATOR, sep2 = 
HELP_STRING_SEPARATOR;
+
+                       host_or_join.push_back(pre + "server.png"
+                               + sep1 + _("Join Official Server")
+                               + sep2 + _("Log on to the official Wesnoth 
multiplayer server"));
+                       host_or_join.push_back(pre + "serverother.png"
+                               + sep1 + _("Connect to Server")
+                               + sep2 + _("Join a different server"));
+                       host_or_join.push_back(pre + "hotseat.png"
+                               + sep1 + _("Local Game")
+                               + sep2 + _("Play a multiplayer game with the AI 
or humans sharing the same machine"));
+
+                       std::string login = preferences::login();
+
+                       {
+                               gui::dialog d(disp(), _("Multiplayer"), "", 
gui::OK_CANCEL);
+                               d.set_menu(host_or_join);
+                               d.set_textbox(_("Login: "), login, 
mp::max_login_size, font::relative_size(250));
+                               res = d.show();
+                               login = d.textbox_text();
+                       }
+                       if (res < 0)
+                               return false;
+
+
+                       preferences::set_login(login);
+               }
 
        }else{
                res = 3;

Added: trunk/src/gui/dialogs/mp_method_selection.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/mp_method_selection.cpp?rev=26800&view=auto
==============================================================================
--- trunk/src/gui/dialogs/mp_method_selection.cpp (added)
+++ trunk/src/gui/dialogs/mp_method_selection.cpp Fri May 23 20:25:20 2008
@@ -1,0 +1,72 @@
+/* $Id$ */
+/*
+   copyright (c) 2008 by mark de wever <[EMAIL PROTECTED]>
+   part of the battle for wesnoth project http://www.wesnoth.org/
+
+   this program is free software; you can redistribute it and/or modify
+   it under the terms of the gnu general public license version 2
+   or at your option any later version.
+   this program is distributed in the hope that it will be useful,
+   but without any warranty.
+
+   see the copying file for more details.
+*/
+
+#include "gui/dialogs/mp_method_selection.hpp"
+
+#include "game_preferences.hpp"
+#include "gui/widgets/button.hpp"
+#include "gui/widgets/listbox.hpp"
+#include "gui/widgets/toggle_button.hpp"
+#include "gui/widgets/widget.hpp"
+#include "gui/widgets/window.hpp"
+#include "gui/widgets/window_builder.hpp"
+#include "gui/widgets/settings.hpp"
+#include "gui/widgets/text_box.hpp"
+#include "log.hpp"
+#include "video.hpp"
+#include "wml_exception.hpp"
+
+#define DBG_GUI LOG_STREAM_INDENT(debug, widget)
+#define LOG_GUI LOG_STREAM_INDENT(info, widget)
+#define WRN_GUI LOG_STREAM_INDENT(warn, widget)
+#define ERR_GUI LOG_STREAM_INDENT(err, widget)
+
+namespace gui2 {
+
+void tmp_method_selection::show(CVideo& video)
+{
+
+       gui2::init();
+
+       twindow window = build(video, get_id(MP_METHOD_SELECTION));
+
+       user_name_ = preferences::login();
+       ttext_box* user_widget = 
dynamic_cast<ttext_box*>(window.find_widget("user_name", false));
+       if(user_widget) {
+               user_widget->set_text(user_name_);
+               window.keyboard_capture(user_widget);
+       }
+
+       tlistbox* list = 
dynamic_cast<tlistbox*>(window.find_widget("method_list", false));
+       VALIDATE(list, "No list defined.");
+
+       list->add_item("Join Official Server");
+       list->add_item("Connect to Server");
+       list->add_item("Local Game");
+       list->select_row(0);
+
+       window.recalculate_size();
+
+       retval_ = window.show(true);
+
+       if(retval_ == tbutton::OK) {
+
+               choice_ = list->get_selected_row();
+               user_widget->save_to_history();
+               user_name_= user_widget->get_text();
+               preferences::set_login(user_name_);
+       }
+}
+
+} // namespace gui2

Propchange: trunk/src/gui/dialogs/mp_method_selection.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/dialogs/mp_method_selection.cpp
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: trunk/src/gui/dialogs/mp_method_selection.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/mp_method_selection.hpp?rev=26800&view=auto
==============================================================================
--- trunk/src/gui/dialogs/mp_method_selection.hpp (added)
+++ trunk/src/gui/dialogs/mp_method_selection.hpp Fri May 23 20:25:20 2008
@@ -1,0 +1,50 @@
+/* $Id$ */
+/*
+   copyright (c) 2008 by mark de wever <[EMAIL PROTECTED]>
+   part of the battle for wesnoth project http://www.wesnoth.org/
+
+   this program is free software; you can redistribute it and/or modify
+   it under the terms of the gnu general public license version 2
+   or at your option any later version.
+   this program is distributed in the hope that it will be useful,
+   but without any warranty.
+
+   see the copying file for more details.
+*/
+
+#ifndef __GUI_DIALOGS_MP_METHOD_SELECTION_HPP_INCLUDED__
+#define __GUI_DIALOGS_MP_METHOD_SELECTION_HPP_INCLUDED__
+
+
+#include <string>
+
+class CVideo;
+
+namespace gui2 {
+
+class tmp_method_selection
+{
+public:
+       tmp_method_selection() : 
+               retval_(0),
+               user_name_(),
+               choice_(-1)
+       {}
+
+       void show(CVideo& video);
+
+       int get_retval() const { return retval_; }
+
+       const std::string& user_name() const { return user_name_; }
+
+       int get_choice() const { return choice_; }
+
+private:
+       int retval_;
+       std::string user_name_;
+       int choice_;
+};
+
+} // namespace gui2
+
+#endif

Propchange: trunk/src/gui/dialogs/mp_method_selection.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/dialogs/mp_method_selection.hpp
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: trunk/src/gui/widgets/settings.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=26800&r1=26799&r2=26800&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Fri May 23 20:25:20 2008
@@ -82,6 +82,7 @@
 {
        window_type_list[ADDON_CONNECT] = "addon_connect";
        window_type_list[LANGUAGE_SELECTION] = "language_selection";
+       window_type_list[MP_METHOD_SELECTION] = "mp_method_selection";
 }
 
 const std::string& get_id(const twindow_type window_type)

Modified: trunk/src/gui/widgets/settings.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.hpp?rev=26800&r1=26799&r2=26800&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Fri May 23 20:25:20 2008
@@ -33,6 +33,8 @@
 enum twindow_type {
        ADDON_CONNECT,           //<! The addon connection dialog.
        LANGUAGE_SELECTION,      //<! The language selection dialog.
+       MP_METHOD_SELECTION,     //<! The dialog which allows you to choose the 
kind
+                                //!  mp game the user wants to play.
 
        DUMMY                    //<! Dummy always the last one.
 };


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

Reply via email to