The Battle for Wesnoth
1.17.17+dev
gui
dialogs
depcheck_select_new.cpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2012 - 2023
3
by Boldizsár Lipka <lipkab@zoho.com>
4
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY.
12
13
See the COPYING file for more details.
14
*/
15
16
#define GETTEXT_DOMAIN "wesnoth-lib"
17
18
#include "
gui/dialogs/depcheck_select_new.hpp
"
19
20
#include "
gui/auxiliary/find_widget.hpp
"
21
#include "
gui/widgets/settings.hpp
"
22
#include "
gui/widgets/window.hpp
"
23
#include "
gui/widgets/listbox.hpp
"
24
#include "
gettext.hpp
"
25
26
namespace
gui2::dialogs
27
{
28
29
REGISTER_DIALOG
(depcheck_select_new)
30
31
depcheck_select_new
::
depcheck_select_new
(
32
ng
::depcheck::
component_type
name,
33
const std::vector<std::
string
>&
items
)
34
:
modal_dialog
(window_id())
35
, items_(
items
)
36
, result_(-1)
37
{
38
std::string
message
;
39
40
switch
(name) {
41
case
ng::depcheck::SCENARIO
:
42
message
=
_
(
"The currently chosen scenario "
43
"is not compatible with your setup."
44
"\nPlease select a compatible one."
);
45
break
;
46
case
ng::depcheck::ERA
:
47
message
=
_
(
"The currently chosen era "
48
"is not compatible with your setup."
49
"\nPlease select a compatible one."
);
50
break
;
51
case
ng::depcheck::MODIFICATION
:
52
// currently this can't happen, but be prepared for anything...
53
message
=
_
(
"The currently chosen modification "
54
"is not compatible with your setup."
55
"\nPlease select a compatible one."
);
56
}
57
58
register_label(
"message"
,
false
,
message
);
59
}
60
61
void
depcheck_select_new::pre_show
(
window
&
window
)
62
{
63
listbox
&
items
= find_widget<listbox>(&
window
,
"itemlist"
,
false
);
64
65
for
(
const
auto
&
item
:
items_
)
66
{
67
widget_data
data
;
68
data
[
"option"
][
"label"
] =
item
;
69
70
items
.add_row(
data
);
71
}
72
73
items
.select_row(0);
74
}
75
76
void
depcheck_select_new::post_show
(
window
&
window
)
77
{
78
if
(
get_retval
() ==
retval::OK
) {
79
listbox
&
items
= find_widget<listbox>(&
window
,
"itemlist"
,
false
);
80
result_
=
items
.get_selected_row();
81
}
82
}
83
}
// namespace dialogs
gui2::dialogs::depcheck_select_new
Offers a list of compatible items if a currently selected one is incompatible.
Definition:
depcheck_select_new.hpp:38
gui2::dialogs::depcheck_select_new::pre_show
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition:
depcheck_select_new.cpp:61
gui2::dialogs::depcheck_select_new::result_
int result_
the index of the selected item
Definition:
depcheck_select_new.hpp:72
gui2::dialogs::depcheck_select_new::items_
std::vector< std::string > items_
the options available
Definition:
depcheck_select_new.hpp:69
gui2::dialogs::depcheck_select_new::post_show
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition:
depcheck_select_new.cpp:76
gui2::dialogs::message
Main class to show messages to the user.
Definition:
message.hpp:36
gui2::dialogs::modal_dialog
Abstract base class for all modal dialogs.
Definition:
modal_dialog.hpp:146
gui2::dialogs::modal_dialog::get_retval
int get_retval() const
Returns the cached window exit code.
Definition:
modal_dialog.hpp:187
gui2::listbox
The listbox class.
Definition:
listbox.hpp:46
gui2::window
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition:
window.hpp:67
depcheck_select_new.hpp
find_widget.hpp
gettext.hpp
_
static std::string _(const char *str)
Definition:
gettext.hpp:93
window.hpp
This file contains the window object, this object is a top level container which has the event manage...
listbox.hpp
REGISTER_DIALOG
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
Definition:
modal_dialog.hpp:89
gui2::dialogs
Definition:
achievements_dialog.cpp:37
gui2::widget_data
std::map< std::string, widget_item > widget_data
Definition:
widget.hpp:35
gui2::OK
@ OK
Dialog was closed with the OK button.
Definition:
retval.hpp:35
help::item
std::pair< std::string, unsigned > item
Definition:
help_impl.hpp:414
mp::ui_alerts::items
const std::vector< std::string > items
Definition:
mp_ui_alerts.cpp:64
ng::depcheck::component_type
component_type
Definition:
depcheck.hpp:32
ng::depcheck::SCENARIO
@ SCENARIO
Definition:
depcheck.hpp:34
ng::depcheck::ERA
@ ERA
Definition:
depcheck.hpp:33
ng::depcheck::MODIFICATION
@ MODIFICATION
Definition:
depcheck.hpp:35
ng
Definition:
configure_engine.cpp:28
data
std::string_view data
Definition:
picture.cpp:199
settings.hpp
This file contains the settings handling of the widget library.
Generated by
1.9.1