The Battle for Wesnoth
1.13.4+dev
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
gui
dialogs
depcheck_select_new.cpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2012 - 2016 by Boldizsár Lipka <
[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
17
#include "
gui/dialogs/depcheck_select_new.hpp
"
18
19
#include "
gui/auxiliary/find_widget.hpp
"
20
#include "
gui/widgets/settings.hpp
"
21
#include "
gui/widgets/window.hpp
"
22
#ifdef GUI2_EXPERIMENTAL_LISTBOX
23
#include "
gui/widgets/list.hpp
"
24
#else
25
#include "
gui/widgets/listbox.hpp
"
26
#endif
27
#include "
gettext.hpp
"
28
29
namespace
gui2
30
{
31
32
/*WIKI
33
* @page = GUIWindowDefinitionWML
34
* @order = 2_depcheck_select_new
35
*
36
* == SP/MP Dependency Check: Select New ==
37
*
38
* Offers a list of compatible items if a currently selected one is
39
* incompatible. Currently used for switching era or map.
40
*
41
* @begin{table}{dialog_widgets}
42
*
43
* message & & label & m &
44
* displays the details of the required changes $
45
*
46
* itemlist & & listbox & m &
47
* displays the available items to choose from $
48
*
49
* cancel & & button & m &
50
* refuse to apply any changes $
51
*
52
* ok & & button & m &
53
* select the chosen item $
54
*
55
* @end{table}
56
*
57
*/
58
59
REGISTER_DIALOG
(depcheck_select_new)
60
61
tdepcheck_select_new
::
tdepcheck_select_new
(
62
ng
::depcheck::
component_type
name
,
63
const
std
::vector<
std
::
string
>&
items
)
64
:
items_
(
items
), result_(-1)
65
{
66
67
std::string
message
;
68
69
switch
(name) {
70
case
ng::depcheck::SCENARIO
:
71
message =
_
(
"The currently chosen scenario "
72
"is not compatible with your setup."
73
"\nPlease select a compatible one."
);
74
break
;
75
case
ng::depcheck::ERA
:
76
message =
_
(
"The currently chosen era "
77
"is not compatible with your setup."
78
"\nPlease select a compatible one."
);
79
break
;
80
case
ng::depcheck::MODIFICATION
:
81
// currently this can't happen, but be prepared for anything...
82
message =
_
(
"The currently chosen modification "
83
"is not compatible with your setup."
84
"\nPlease select a compatible one."
);
85
}
86
87
register_label(
"message"
,
false
, message);
88
}
89
90
void
tdepcheck_select_new::pre_show
(
twindow
& window)
91
{
92
tlistbox
& listbox = find_widget<tlistbox>(&window,
"itemlist"
,
false
);
93
94
for
(
const
auto
& item :
items_
)
95
{
96
string_map
current;
97
current.insert(std::make_pair(
"label"
, item));
98
99
listbox.
add_row
(current);
100
}
101
102
listbox.
select_row
(0);
103
}
104
105
void
tdepcheck_select_new::post_show
(
twindow
& window)
106
{
107
if
(
get_retval
() ==
twindow::OK
) {
108
tlistbox
& listbox = find_widget<tlistbox>(&window,
"itemlist"
,
false
);
109
result_
= listbox.
get_selected_row
();
110
}
111
}
112
}
gettext.hpp
ng::depcheck::MODIFICATION
Definition:
depcheck.hpp:36
find_widget.hpp
depcheck_select_new.hpp
gui2::tdialog::get_retval
int get_retval() const
Definition:
dialog.hpp:161
list.hpp
window.hpp
This file contains the window object, this object is a top level container which has the event manage...
gui2::tlistbox::select_row
bool select_row(const unsigned row, const bool select=true)
Selectes a row.
Definition:
listbox.cpp:228
gui2::REGISTER_DIALOG
REGISTER_DIALOG(label_settings)
std
STL namespace.
mp_ui_alerts::items
const std::vector< std::string > items
Definition:
mp_ui_alerts.cpp:56
gui2::tdepcheck_select_new::result_
int result_
the index of the selected item
Definition:
depcheck_select_new.hpp:64
ng
Definition:
configure_engine.cpp:12
gui2::tdepcheck_select_new::post_show
virtual void post_show(twindow &window)
Inherited from tdialog.
Definition:
depcheck_select_new.cpp:105
gui2::twindow
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition:
window.hpp:62
gui2
A class inherited from ttext_box that displays its input as stars.
Definition:
field-fwd.hpp:23
_
static UNUSEDNOWARN std::string _(const char *str)
Definition:
gettext.hpp:82
gui2::twindow::OK
Dialog is closed with ok button.
Definition:
window.hpp:125
settings.hpp
This file contains the settings handling of the widget library.
gui2::tlistbox::add_row
void add_row(const string_map &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
Definition:
listbox.cpp:74
ng::depcheck::SCENARIO
Definition:
depcheck.hpp:35
gui2::tdepcheck_select_new::pre_show
virtual void pre_show(twindow &window)
Inherited from tdialog.
Definition:
depcheck_select_new.cpp:90
string_map
std::map< std::string, t_string > string_map
Definition:
generator.hpp:23
gui2::tdepcheck_select_new::items_
std::vector< std::string > items_
the options available
Definition:
depcheck_select_new.hpp:61
gui2::tdepcheck_select_new
Definition:
depcheck_select_new.hpp:26
gui2::tlistbox
The listbox class.
Definition:
listbox.hpp:39
items_
std::vector< expression_ptr > items_
Definition:
formula.cpp:119
name
GLuint const GLchar * name
Definition:
glew.h:1782
ng::depcheck::component_type
component_type
Definition:
depcheck.hpp:32
listbox.hpp
message
GLsizei GLenum GLuint GLuint GLsizei char * message
Definition:
glew.h:2499
gui2::tlistbox::get_selected_row
int get_selected_row() const
Returns the first selected row.
Definition:
listbox.cpp:237
string
GLsizei const GLcharARB ** string
Definition:
glew.h:4503
ng::depcheck::ERA
Definition:
depcheck.hpp:34
Generated by
1.8.8