The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
dialogs.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[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 #ifndef DIALOGS_H_INCLUDED
15 #define DIALOGS_H_INCLUDED
16 
17 class attack_type;
18 class config;
19 class display;
20 class game_display;
21 class unit;
22 class unit_map;
23 class unit_type;
24 class terrain_type;
26 #include "map/location.hpp"
27 #include "construct_dialog.hpp"
28 #include "units/ptr.hpp"
30 
31 #include <boost/shared_ptr.hpp>
32 namespace dialogs {
33 
34 
35 /**
36  * Lets the user to select a unit advancement. This should always be used
37  * from WML events, advance_unit can only be used safely for normal levels.
38  */
39 int advance_unit_dialog(const map_location &loc);
40 
41 /**
42  * Actually levels a unit up. This is the other part of the low-level
43  * interface to the advancing code (along with advance_unit_dialog). This needs
44  * to be used to implement advances from any nonstandard situation. It does
45  * not add a replay.
46  */
47 bool animate_unit_advancement(const map_location &loc, size_t choice, const bool &fire_event = true, const bool animate = true);
48 
49 void show_objectives(const std::string& scenarioname, const std::string &objectives);
50 
52 
53 int recruit_dialog(display& disp, std::vector<const unit_type*>& units, const std::vector<std::string>& items, int side, const std::string& title_suffix);
54 
55 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);
56 
57 /** Show unit-stats in a side-pane to unit-list, recall-list, etc. */
59 {
60 public:
62  struct details {
63  details();
64 
65 #ifdef SDL_GPU
66  sdl::timage image;
67 #else
69 #endif
71  int level;
73  std::vector<t_string> abilities;
78  std::vector<attack_type> attacks;
79  std::vector<std::string> overlays;
80  };
81 
83  TYPE type = SHOW_ALL, bool left_side = true);
84 
85  bool show_above() const;
86  bool left_side() const;
87  void set_selection(int index);
88 
90 
91 protected:
92  int index_;
94 
95 private:
96  virtual size_t size() const = 0;
97  virtual const details get_details() const = 0;
98  virtual void process_event() = 0;
99 
100  void draw_contents();
101 
103  bool weapons_;
104  bool left_;
105 };
106 
108 {
109 public:
111  units_list_preview_pane(const boost::shared_ptr<const std::vector<unit_const_ptr > > & units,
112  const gui::filter_textbox *filter = nullptr,
113  TYPE type = SHOW_ALL, bool left_side = true);
114 
115 private:
116  size_t size() const;
117  const details get_details() const;
118  void process_event();
119 
121 };
122 
123 
125 {
126 public:
128  std::vector<const unit_type*>& unit_types, const gui::filter_textbox* filterbox=nullptr,
129  int side = 1, TYPE type=SHOW_ALL, bool left_side=true);
130 
131 private:
132  size_t size() const;
133  const details get_details() const;
134  void process_event();
135 
136  std::vector<const unit_type*>* unit_types_;
137  int side_;
138 };
139 
140 bool network_receive_dialog(CVideo& video, const std::string& msg, config& cfg, twesnothd_connection& wesnothd_connection);
141 std::unique_ptr<twesnothd_connection> network_connect_dialog(CVideo& video, const std::string& msg, const std::string& hostname, int port);
142 
143 } //end namespace dialogs
144 
145 #endif
sdl_handler_vector handler_members()
Definition: dialogs.cpp:642
std::unique_ptr< twesnothd_connection > network_connect_dialog(CVideo &video, const std::string &msg, const std::string &hostname, int port)
Definition: dialogs.cpp:1195
Definition: unit.hpp:95
std::vector< events::sdl_handler * > sdl_handler_vector
Definition: events.hpp:163
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)
Definition: dialogs.cpp:466
int recruit_dialog(display &disp, std::vector< const unit_type * > &units, const std::vector< std::string > &items, int side, const std::string &title_suffix)
Definition: dialogs.cpp:432
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)
Definition: dialogs.cpp:1066
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1221
Definition: video.hpp:58
const details get_details() const
Definition: dialogs.cpp:999
General purpose widgets.
unit_type_data unit_types
Definition: types.cpp:1314
const std::vector< std::string > items
int advance_unit_dialog(const map_location &loc)
Lets the user to select a unit advancement.
Definition: dialogs.cpp:172
units_list_preview_pane(unit_const_ptr u, TYPE type=SHOW_ALL, bool left_side=true)
Definition: dialogs.cpp:981
A class that represents a TCP/IP connection to the wesnothd server.
bool animate_unit_advancement(const map_location &loc, size_t choice, const bool &fire_event, const bool animate)
Actually levels a unit up.
Definition: dialogs.cpp:233
unit_preview_pane(const gui::filter_textbox *filter=nullptr, TYPE type=SHOW_ALL, bool left_side=true)
Definition: dialogs.cpp:629
void show_unit_list(display &gui)
Definition: dialogs.cpp:294
Show unit-stats in a side-pane to unit-list, recall-list, etc.
Definition: dialogs.hpp:58
Various uncategorised dialogs.
Definition: dialogs.cpp:85
Encapsulates the map of the game.
Definition: location.hpp:38
bool network_receive_dialog(CVideo &video, const std::string &msg, config &cfg, twesnothd_connection &wesnothd_connection)
Definition: dialogs.cpp:1179
std::vector< std::string > overlays
Definition: dialogs.hpp:79
boost::shared_ptr< const std::vector< unit_const_ptr > > units_
Definition: dialogs.hpp:120
GLuint index
Definition: glew.h:1782
gui::button details_button_
Definition: dialogs.hpp:93
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:112
bool fire_event(const tevent event, std::vector< std::pair< twidget *, tevent > > &event_chain, twidget *dispatcher, twidget *widget, F functor)
Helper function for fire_event.
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glew.h:3448
void set_selection(int index)
Definition: dialogs.cpp:659
virtual size_t size() const =0
std::vector< const unit_type * > * unit_types_
Definition: dialogs.hpp:136
const details get_details() const
Definition: dialogs.cpp:1078
virtual const details get_details() const =0
bool left_side() const
Definition: dialogs.cpp:654
std::vector< t_string > abilities
Definition: dialogs.hpp:73
virtual void process_event()=0
std::vector< attack_type > attacks
Definition: dialogs.hpp:78
Container associating units to locations.
Definition: map.hpp:90
const gui::filter_textbox * filter_
Definition: dialogs.hpp:102
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503
unit_map * units
Definition: resources.cpp:35
bool show_above() const
Definition: dialogs.cpp:649
void show_objectives(const std::string &scenarioname, const std::string &objectives)
Definition: dialogs.cpp:425