The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
render.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2016 by Ignacio R. Morelle <[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 
15 /**
16  * @file
17  * Storyscreen parts rendering interface.
18  * @todo Translate relevant parts to GUI2.
19  */
20 
21 #ifndef STORYSCREEN_RENDER_HPP_INCLUDED
22 #define STORYSCREEN_RENDER_HPP_INCLUDED
23 
24 #include "key.hpp"
25 #include "storyscreen/part.hpp"
26 #include "events.hpp"
27 // #include "widgets/button.hpp"
28 
29 class CVideo;
30 class display;
31 
32 namespace gui { class button; }
33 
34 namespace storyscreen {
35 
36 /**
37  * Storyscreen part user interface.
38  * This works on the assumption, like the old one, that the screen
39  * cannot be resized while we are at this. More specifically, it is
40  * assumed that the screen dimensions remain constant between the
41  * constructor call, and the destruction of the objects.
42  */
44 {
45 public:
46  /** Storyscreen result. */
47  enum RESULT {
48  NEXT, /**< The user pressed the go-next button. */
49  BACK, /**< The user pressed the go-back button. */
50  QUIT /**< The user selected quit. */
51  };
52 
53  /**
54  * Constructor.
55  * @param p A storyscreen::part with the required information and parameters.
56  * @param disp Display.
57  * @param next_button Next button. Shouldn't be destroyed before the part_ui object.
58  */
59  part_ui(part &p, CVideo& video, gui::button &next_button,
60  gui::button &back_button, gui::button& play_button);
61 
62  /**
63  * Render and display the storyscreen, process and return user input.
64  */
65  RESULT show();
66 
67  virtual void handle_event(const SDL_Event&);
68 
69  virtual void handle_window_event(const SDL_Event& event);
70 
71 private:
72  part& p_;
74  CKey keys_; // convenience
75 
79 
80  bool dirty_;
81 
84 
87 
88  // Keeps the area occupied on the screen by the base layer
89  // (the background layer we align the images to)
90  SDL_Rect base_rect_;
91 
92 #ifdef SDL_GPU
93  std::vector< sdl::timage > background_images_;
94  std::vector< std::pair<int, int> > background_positions_;
95 #else
97 #endif
98  std::vector< floating_image::render_input > imgs_;
100 
102 
103  /** Constructor implementation details. */
104  void prepare_background();
105  /** Constructor implementation details. */
106  void prepare_geometry();
107  /** Constructor implementation details. */
109 
110  void render_background();
111  void render_title_box();
112  void render_story_box();
113  void render_story_box_borders(SDL_Rect&);
114 
115  /**
116  * Returns true if the user did an action. Modifies #ret_, #skip_,
117  * and #last_key_ accordingly.
118  */
119  bool handle_interface();
120 
121  /**
122  * Renders all floating images in sequence.
123  * @return 'true' if the user interrupted the operation; 'false' otherwise.
124  */
125  bool render_floating_images();
126 
127  void wait_for_input();
128 };
129 
130 } // end namespace storyscreen
131 
132 #endif /* !STORYSCREEN_RENDER_HPP_INCLUDED */
SDL_Rect base_rect_
Definition: render.hpp:90
bool handle_interface()
Returns true if the user did an action.
Definition: render.cpp:923
void render_story_box()
Definition: render.cpp:625
Storyscreen parts and floating images representation.
virtual void handle_window_event(const SDL_Event &event)
Definition: render.cpp:1001
The user pressed the go-next button.
Definition: render.hpp:48
Definition: video.hpp:58
General purpose widgets.
void prepare_background()
Constructor implementation details.
Definition: render.cpp:118
void render_title_box()
Definition: render.cpp:388
void render_background()
Definition: render.cpp:309
The user pressed the go-back button.
Definition: render.hpp:49
RESULT
Storyscreen result.
Definition: render.hpp:47
Storyscreen part user interface.
Definition: render.hpp:43
surface background_
Definition: render.hpp:96
The user selected quit.
Definition: render.hpp:50
GLfloat GLfloat p
Definition: glew.h:12766
gui::button & play_button_
Definition: render.hpp:78
Represents and contains information about a single storyscreen part.
Definition: part.hpp:244
bool render_floating_images()
Renders all floating images in sequence.
Definition: render.cpp:320
gui::button & next_button_
Definition: render.hpp:76
RESULT show()
Render and display the storyscreen, process and return user input.
Definition: render.cpp:965
virtual void handle_event(const SDL_Event &)
Definition: render.cpp:992
gui::button & back_button_
Definition: render.hpp:77
void render_story_box_borders(SDL_Rect &)
Definition: render.cpp:537
cl_event event
Definition: glew.h:3070
double y_scale_factor_
Definition: render.hpp:86
std::vector< floating_image::render_input > imgs_
Definition: render.hpp:98
part_ui(part &p, CVideo &video, gui::button &next_button, gui::button &back_button, gui::button &play_button)
Constructor.
Definition: render.cpp:88
Class that keeps track of all the keys on the keyboard.
Definition: key.hpp:27
double x_scale_factor_
Definition: render.hpp:85
void prepare_floating_images()
Constructor implementation details.
Definition: render.cpp:301
void prepare_geometry()
Constructor implementation details.
Definition: render.cpp:269