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