-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
dialogs.hpp
145 lines (115 loc) · 4.21 KB
/
dialogs.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
Copyright (C) 2003 - 2016 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef DIALOGS_H_INCLUDED
#define DIALOGS_H_INCLUDED
class attack_type;
class config;
class display;
class game_display;
class unit;
class unit_map;
class unit_type;
class terrain_type;
class twesnothd_connection;
#include "map/location.hpp"
#include "construct_dialog.hpp"
#include "units/ptr.hpp"
#include "ai/lua/aspect_advancements.hpp"
#include <boost/shared_ptr.hpp>
namespace dialogs {
/**
* Lets the user to select a unit advancement. This should always be used
* from WML events, advance_unit can only be used safely for normal levels.
*/
int advance_unit_dialog(const map_location &loc);
/**
* Actually levels a unit up. This is the other part of the low-level
* interface to the advancing code (along with advance_unit_dialog). This needs
* to be used to implement advances from any nonstandard situation. It does
* not add a replay.
*/
bool animate_unit_advancement(const map_location &loc, size_t choice, const bool &fire_event = true, const bool animate = true);
void show_objectives(const std::string& scenarioname, const std::string &objectives);
void show_unit_list(display& gui);
int recruit_dialog(display& disp, std::vector<const unit_type*>& units, const std::vector<std::string>& items, int side, const std::string& title_suffix);
int recall_dialog(display& disp, const boost::shared_ptr<std::vector<unit_const_ptr > > & units, int side, const std::string& title_suffix, const int team_recall_cost);
/** Show unit-stats in a side-pane to unit-list, recall-list, etc. */
class unit_preview_pane : public gui::preview_pane
{
public:
enum TYPE { SHOW_ALL, SHOW_BASIC };
struct details {
details();
#ifdef SDL_GPU
sdl::timage image;
#else
surface image;
#endif
std::string name, type_name, race;
int level;
std::string alignment, traits;
std::vector<t_string> abilities;
int hitpoints, max_hitpoints;
int experience, max_experience;
std::string hp_color, xp_color;
int movement_left, total_movement;
std::vector<attack_type> attacks;
std::vector<std::string> overlays;
};
unit_preview_pane(const gui::filter_textbox *filter = nullptr,
TYPE type = SHOW_ALL, bool left_side = true);
bool show_above() const;
bool left_side() const;
void set_selection(int index);
sdl_handler_vector handler_members();
protected:
int index_;
gui::button details_button_;
private:
virtual size_t size() const = 0;
virtual const details get_details() const = 0;
virtual void process_event() = 0;
void draw_contents();
const gui::filter_textbox* filter_;
bool weapons_;
bool left_;
};
class units_list_preview_pane : public dialogs::unit_preview_pane
{
public:
units_list_preview_pane(unit_const_ptr u, TYPE type = SHOW_ALL, bool left_side = true);
units_list_preview_pane(const boost::shared_ptr<const std::vector<unit_const_ptr > > & units,
const gui::filter_textbox *filter = nullptr,
TYPE type = SHOW_ALL, bool left_side = true);
private:
size_t size() const;
const details get_details() const;
void process_event();
boost::shared_ptr<const std::vector<unit_const_ptr > > units_;
};
class unit_types_preview_pane : public dialogs::unit_preview_pane
{
public:
unit_types_preview_pane(
std::vector<const unit_type*>& unit_types, const gui::filter_textbox* filterbox=nullptr,
int side = 1, TYPE type=SHOW_ALL, bool left_side=true);
private:
size_t size() const;
const details get_details() const;
void process_event();
std::vector<const unit_type*>* unit_types_;
int side_;
};
bool network_receive_dialog(CVideo& video, const std::string& msg, config& cfg, twesnothd_connection& wesnothd_connection);
std::unique_ptr<twesnothd_connection> network_connect_dialog(CVideo& video, const std::string& msg, const std::string& hostname, int port);
} //end namespace dialogs
#endif