38 #include "widgets/button.hpp"
41 #include <boost/scoped_ptr.hpp>
58 static std::map<std::string , std::string>
images;
68 if(split_multiline_headers) {
71 const std::vector<std::string>& lines =
utils::split(c[
"title"],
'\n');
75 res.push_back(
"+" + line);
84 res.push_back(
"+" + title);
88 std::vector<std::string> lines =
utils::split(c[
"text"],
'\n');
91 if (line.size() > 1 && line[0] ==
'+')
92 line =
"+ " + line.substr(1);
105 res.push_back(
"- "+ entry[
"name"].str());
112 std::vector< std::string >
res;
116 if (!campaign.empty()) {
119 if (campaign ==
about[
"id"]) {
144 if (images_default.empty())
147 images_default +=
',' + im;
154 if (abouts.first == abouts.second)
continue;
157 std::ostringstream text;
159 temp[
"title"] = campaign[
"name"];
166 if (!subtitle.empty())
169 if (subtitle[0] ==
'_')
178 text <<
" " << line <<
'\n';
181 for (
const config &entry :
about.child_range(
"entry"))
183 text <<
" " << entry[
"name"] <<
'\n';
189 if (campaign_images.empty())
190 campaign_images = im;
192 campaign_images +=
',' + im;
196 images[
id] = campaign_images;
197 temp[
"text"] = text.str();
212 if (screen ==
nullptr)
return;
224 std::vector<std::string> image_list;
225 if(campaign.size() && !images[campaign].empty()){
231 surface map_image, map_image_scaled;
233 if(!image_list.empty()) {
236 image_list.push_back(
"");
253 for(
unsigned i = 0;
i < text.size(); ++
i) {
255 if (s.empty())
continue;
259 else if (first ==
'+') {
261 text.insert(text.begin() +
i, before_header);
265 text.insert(text.begin(), 10, before_header);
271 const int top_margin = 60;
273 const int bottom_margin = 40;
275 const int text_left_padding = screen->w/32;
278 bool is_new_line =
true;
280 int first_line_height = 0;
289 SDL_Rect text_rect = { 0, 0, 0, 0 };
291 SDL_Rect text_rect_blit;
302 bool redraw_mapimage =
true;
303 bool update_dimensions =
true;
304 int max_text_width = 0;
307 last_escape = key[SDLK_ESCAPE] != 0;
310 if(text.size() && (image_count <
311 ((startline *
static_cast<int>(image_list.size())) /
312 static_cast<int>(text.size())))){
316 map_image=temp?temp:map_image;
317 redraw_mapimage =
true;
320 if (update_dimensions) {
322 map_image_scaled =
scale_surface(map_image, screen->w, screen->h);
324 redraw_mapimage =
true;
330 , screen->w * 13 / 16
331 , screen->h - top_margin - bottom_margin);
336 text_rect.x += text_left_padding;
337 text_rect.w -= text_left_padding;
338 text_rect_blit = text_rect;
341 SDL_SetAlpha(text_surf, SDL_RLEACCEL, SDL_ALPHA_OPAQUE);
346 update_dimensions =
false;
349 if (redraw_mapimage) {
351 sdl_blit(map_image_scaled,
nullptr, screen,
nullptr);
358 sdl_blit(screen, &text_rect, text_surf,
nullptr);
359 redraw_mapimage =
false;
364 sdl_blit(text_surf, &modified, screen, &text_rect_blit);
369 int line = startline;
376 const int line_spacing = 5;
381 text[line], text_rect.x, y).w;
382 max_text_width = std::max<int>(max_text_width,
w);
386 const int line_height =
font::draw_text(
nullptr, text_rect, def_size, def_color,
391 first_line_height = line_height + line_spacing;
394 if(
size_t(line) > text.size()-1)
396 y += line_height + line_spacing;
397 }
while(y < text_rect.y + text_rect.h);
402 if (offset>=first_line_height) {
403 offset -= first_line_height;
406 if(
size_t(startline) == text.size()){
413 if (key[SDLK_UP] && scroll_speed < 20) {
416 if (key[SDLK_DOWN] && scroll_speed > 0) {
419 if (screen->w != screen_rect.w || screen->h != screen_rect.h) {
420 update_dimensions =
true;
431 }
while(!close.
pressed() && (last_escape || !key[SDLK_ESCAPE]));
void show_about(CVideo &video, const std::string &campaign)
Show credits with list of contributors.
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
child_itors child_range(const std::string &key)
static void add_lines(std::vector< std::string > &res, config const &c, bool split_multiline_headers)
Given a vector of strings, and a config representing an [about] section, add all the credits lines fr...
std::vector< std::string > get_text(const std::string &campaign, bool split_multiline_headers)
const char LARGE_TEXT
Standard markups for color, size, font, images.
GLint GLint GLint GLint GLint GLint y
surface scale_surface(const surface &surf, int w, int h)
const SDL_Color NORMAL_COLOR
Definitions for the interface to Wesnoth Markup Language (WML).
std::pair< const_child_iterator, const_child_iterator > const_child_itors
Display credits about all contributors.
dimension_measurements layout(int x, int y, int w, int h)
static UNUSEDNOWARN std::string _(const char *str)
static std::string images_default
GLubyte GLubyte GLubyte GLubyte w
std::string game_title_background
config & add_child(const std::string &key)
static UNUSEDNOWARN std::string gettext(const char *str)
SDL_Rect draw_text(surface &dst, const SDL_Rect &area, int size, const SDL_Color &color, const std::string &txt, int x, int y, bool use_tooltips, int style)
Function to draw text on a surface.
void raise_process_event()
static const style titlescreen_style
std::pair< child_iterator, child_iterator > child_itors
void set_about(const config &cfg)
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
Creates an empty SDL_Rect.
std::vector< std::string > parenthetical_split(std::string const &val, const char separator, std::string const &left, std::string const &right, const int flags)
Splits a string based either on a separator where text within parenthesis is protected from splitting...
static std::map< std::string, std::string > images
Contains the SDL_Rect helper code.
surface create_compatible_surface(const surface &surf, int width, int height)
static void delay(unsigned int milliseconds)
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
void sdl_blit(const surface &src, SDL_Rect *src_rect, surface &dst, SDL_Rect *dst_rect)
int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha)
A config object defines a single node in a WML file, with access to child nodes.
Class that keeps track of all the keys on the keyboard.
Compatibility layer for using SDL 1.2 and 2.0.
void update_rect(const SDL_Rect &)
GLsizei const GLcharARB ** string