-
-
Notifications
You must be signed in to change notification settings - Fork 990
/
render.hpp
126 lines (101 loc) · 3.25 KB
/
render.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
/*
Copyright (C) 2009 - 2014 by Ignacio R. Morelle <shadowm2006@gmail.com>
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.
*/
/**
* @file
* Storyscreen parts rendering interface.
* @todo Translate relevant parts to GUI2.
*/
#ifndef STORYSCREEN_RENDER_HPP_INCLUDED
#define STORYSCREEN_RENDER_HPP_INCLUDED
#include "key.hpp"
#include "storyscreen/part.hpp"
// #include "widgets/button.hpp"
class display;
class CVideo;
namespace gui { class button; }
namespace storyscreen {
/**
* Storyscreen part user interface.
* This works on the assumption, like the old one, that the screen
* cannot be resized while we are at this. More specifically, it is
* assumed that the screen dimensions remain constant between the
* constructor call, and the destruction of the objects.
*/
class part_ui
{
public:
/** Storyscreen result. */
enum RESULT {
NEXT, /**< The user pressed the go-next button. */
BACK, /**< The user pressed the go-back button. */
QUIT /**< The user selected quit. */
};
/**
* Constructor.
* @param p A storyscreen::part with the required information and parameters.
* @param disp Display.
* @param next_button Next button. Shouldn't be destroyed before the part_ui object.
*/
part_ui(part &p, display &disp, gui::button &next_button,
gui::button &back_button, gui::button& play_button);
/**
* Render and display the storyscreen, process and return user input.
*/
RESULT show();
private:
part& p_;
display& disp_;
CVideo& video_; // convenience, it's currently obtained from disp_
CKey keys_; // convenience
gui::button& next_button_;
gui::button& back_button_;
gui::button& play_button_;
RESULT ret_;
bool skip_, last_key_;
double x_scale_factor_;
double y_scale_factor_;
// Keeps the area occupied on the screen by the base layer
// (the background layer we align the images to)
SDL_Rect base_rect_;
#ifdef SDL_GPU
std::vector< sdl::ttexture > background_images_;
std::vector< std::pair<int, int> > background_positions_;
#else
surface background_;
#endif
std::vector< floating_image::render_input > imgs_;
bool has_background_;
int text_x_, text_y_, buttons_x_, buttons_y_;
/** Constructor implementation details. */
void prepare_background();
/** Constructor implementation details. */
void prepare_geometry();
/** Constructor implementation details. */
void prepare_floating_images();
void render_background();
void render_title_box();
void render_story_box();
void render_story_box_borders(SDL_Rect&);
/**
* Returns true if the user did an action. Modifies #ret_, #skip_,
* and #last_key_ accordingly.
*/
bool handle_interface();
/**
* Renders all floating images in sequence.
* @return 'true' if the user interrupted the operation; 'false' otherwise.
*/
bool render_floating_images();
void wait_for_input();
};
} // end namespace storyscreen
#endif /* !STORYSCREEN_RENDER_HPP_INCLUDED */