The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
mp_method_selection.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
19 #include "game_preferences.hpp"
21 #ifdef GUI2_EXPERIMENTAL_LISTBOX
22 #include "gui/widgets/list.hpp"
23 #else
24 #include "gui/widgets/listbox.hpp"
25 #endif
26 #include "gui/widgets/window.hpp"
27 #include "gui/widgets/settings.hpp"
28 #include "gui/widgets/text_box.hpp"
31 
32 namespace gui2
33 {
34 
35 /*WIKI
36  * @page = GUIWindowDefinitionWML
37  * @order = 2_mp_method_selection
38  *
39  * == MP method selection ==
40  *
41  * This shows the dialog to select the kind of MP game the user wants to play.
42  *
43  * @begin{table}{dialog_widgets}
44  *
45  * user_name & & text_box & m &
46  * This text contains the name the user on the MP server. This widget
47  * will get a fixed maximum length by the engine. $
48  *
49  * method_list & & listbox & m &
50  * The list with possible game methods. $
51  *
52  * @end{table}
53  */
54 
55 REGISTER_DIALOG(mp_method_selection)
56 
57 void tmp_method_selection::pre_show(twindow& window)
58 {
59  user_name_ = preferences::login();
60  ttext_box* user_widget
61  = find_widget<ttext_box>(&window, "user_name", false, true);
62  user_widget->set_value(user_name_);
64  window.keyboard_capture(user_widget);
65 
66  tlistbox* list = find_widget<tlistbox>(&window, "method_list", false, true);
67 
68  window.add_to_keyboard_chain(list);
69 }
70 
72 {
73  if(get_retval() == twindow::OK) {
74  ttext_box& user_widget
75  = find_widget<ttext_box>(&window, "user_name", false);
76  tlistbox& list = find_widget<tlistbox>(&window, "method_list", false);
77 
78  choice_ = list.get_selected_row();
79 
80  user_widget.save_to_history();
81  user_name_ = user_widget.get_value();
83  }
84 }
85 
86 } // namespace gui2
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1806
int get_retval() const
Definition: dialog.hpp:161
This file contains the window object, this object is a top level container which has the event manage...
REGISTER_DIALOG(label_settings)
void set_login(const std::string &username)
Class for a single line text area.
Definition: text_box.hpp:118
std::string get_value() const
Definition: text.hpp:76
virtual void set_value(const std::string &text)
The set_value is virtual for the tpassword_box class.
Definition: text.cpp:95
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
void post_show(twindow &window)
Inherited from tdialog.
Dialog is closed with ok button.
Definition: window.hpp:125
This file contains the settings handling of the widget library.
int choice_
The selected method to `connect' to the MP server.
const size_t max_login_size
Definition: multiplayer.hpp:28
std::string login()
void save_to_history()
Saves the text in the widget to the history.
Definition: text_box.hpp:124
The listbox class.
Definition: listbox.hpp:39
-file mapgen.hpp
std::string user_name_
The name to use on the MP server.
void set_maximum_length(const size_t maximum_length)
Definition: text.cpp:73