gui/dialogs/mp_method_selection.cpp

Go to the documentation of this file.
00001 /* $Id: mp_method_selection.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by Mark de Wever <koraq@xs4all.nl>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #define GETTEXT_DOMAIN "wesnoth-lib"
00017 
00018 #include "gui/dialogs/mp_method_selection.hpp"
00019 
00020 #include "game_preferences.hpp"
00021 #ifdef GUI2_EXPERIMENTAL_LISTBOX
00022 #include "gui/widgets/list.hpp"
00023 #else
00024 #include "gui/widgets/listbox.hpp"
00025 #endif
00026 #include "gui/widgets/window.hpp"
00027 #include "gui/widgets/settings.hpp"
00028 #include "gui/widgets/text_box.hpp"
00029 #include "gui/widgets/toggle_button.hpp"
00030 #include "multiplayer.hpp"
00031 
00032 namespace gui2 {
00033 
00034 /*WIKI
00035  * @page = GUIWindowDefinitionWML
00036  * @order = 2_mp_method_selection
00037  *
00038  * == MP method selection ==
00039  *
00040  * This shows the dialog to select the kind of MP game the user wants to play.
00041  *
00042  * @begin{table}{dialog_widgets}
00043  *
00044  * user_name & & text_box & m &
00045  *         This text contains the name the user on the MP server. This widget
00046  *         will get a fixed maximum length by the engine. $
00047  *
00048  * method_list & & listbox & m &
00049  *         The list with possible game methods. $
00050  *
00051  * @end{table}
00052  */
00053 
00054 REGISTER_DIALOG(mp_method_selection)
00055 
00056 void tmp_method_selection::pre_show(CVideo& /*video*/, twindow& window)
00057 {
00058     user_name_ = preferences::login();
00059     ttext_box* user_widget = find_widget<ttext_box>(
00060             &window, "user_name", false, true);
00061     user_widget->set_value(user_name_);
00062     user_widget->set_maximum_length(mp::max_login_size);
00063     window.keyboard_capture(user_widget);
00064 
00065     tlistbox* list = find_widget<tlistbox>(&window, "method_list", false, true);
00066 
00067     window.add_to_keyboard_chain(list);
00068 }
00069 
00070 void tmp_method_selection::post_show(twindow& window)
00071 {
00072     if(get_retval() == twindow::OK) {
00073         ttext_box& user_widget = find_widget<ttext_box>(
00074                 &window, "user_name", false);
00075         tlistbox& list = find_widget<tlistbox>(&window, "method_list", false);
00076 
00077         choice_ = list.get_selected_row();
00078 
00079         user_widget.save_to_history();
00080         user_name_ = user_widget.get_value();
00081         preferences::set_login(user_name_);
00082     }
00083 }
00084 
00085 } // namespace gui2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:58 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs