The Battle for Wesnoth
1.17.21+dev
gui
dialogs
unit_list.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2016 - 2023
3
Part of the Battle for Wesnoth Project https://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
#pragma once
16
17
#include "
gettext.hpp
"
18
#include "
gui/dialogs/modal_dialog.hpp
"
19
#include "
gui/dialogs/transient_message.hpp
"
20
#include "
map/location.hpp
"
21
#include "
units/ptr.hpp
"
22
23
#include <memory>
24
#include <string>
25
#include <vector>
26
27
class
display
;
28
29
namespace
gui2::dialogs
30
{
31
void
show_unit_list
(
display
&
gui
);
32
33
class
unit_list
:
public
modal_dialog
34
{
35
public
:
36
explicit
unit_list
(std::vector<unit_const_ptr>&
unit_list
,
map_location
& scroll_to);
37
38
static
bool
execute
(std::vector<unit_const_ptr>& units,
map_location
& scroll_to)
39
{
40
if
(units.empty()) {
41
show_transient_message
(
""
,
_
(
"No units found."
));
42
return
false
;
43
}
44
45
return
unit_list
(units, scroll_to).show();
46
}
47
48
private
:
49
std::vector<unit_const_ptr>&
unit_list_
;
50
51
map_location
&
scroll_to_
;
52
53
/** Callbacks */
54
void
list_item_clicked
();
55
56
virtual
const
std::string&
window_id
()
const override
;
57
58
virtual
void
pre_show
(
window
&
window
)
override
;
59
60
virtual
void
post_show
(
window
&
window
)
override
;
61
};
62
63
}
// namespace dialogs
display
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Definition:
display.hpp:87
gui2::dialogs::modal_dialog
Abstract base class for all modal dialogs.
Definition:
modal_dialog.hpp:146
gui2::dialogs::unit_list
Definition:
unit_list.hpp:34
gui2::dialogs::unit_list::window_id
virtual const std::string & window_id() const override
The ID of the window to build.
gui2::dialogs::unit_list::pre_show
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition:
unit_list.cpp:91
gui2::dialogs::unit_list::unit_list
unit_list(std::vector< unit_const_ptr > &unit_list, map_location &scroll_to)
Definition:
unit_list.cpp:47
gui2::dialogs::unit_list::post_show
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition:
unit_list.cpp:190
gui2::dialogs::unit_list::scroll_to_
map_location & scroll_to_
Definition:
unit_list.hpp:51
gui2::dialogs::unit_list::unit_list_
std::vector< unit_const_ptr > & unit_list_
Definition:
unit_list.hpp:49
gui2::dialogs::unit_list::list_item_clicked
void list_item_clicked()
Callbacks.
Definition:
unit_list.cpp:177
gui2::dialogs::unit_list::execute
static bool execute(std::vector< unit_const_ptr > &units, map_location &scroll_to)
Definition:
unit_list.hpp:38
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
gettext.hpp
_
static std::string _(const char *str)
Definition:
gettext.hpp:93
location.hpp
modal_dialog.hpp
gui2::dialogs
Definition:
achievements_dialog.cpp:37
gui2::dialogs::show_unit_list
void show_unit_list(display &gui)
Definition:
unit_list.cpp:199
gui2::show_transient_message
void show_transient_message(const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup)
Shows a transient message to the user.
Definition:
transient_message.cpp:62
gui
General purpose widgets.
Definition:
tristate_button.cpp:30
ptr.hpp
map_location
Encapsulates the map of the game.
Definition:
location.hpp:38
transient_message.hpp
Generated by
1.9.1