1 /*
2 Copyright © 2012-2013 Henrik Andersson
3 Copyright © 2013 Kurt Rinnert
4 Copyright © 2013-2016 Justin Jacobs
5 
6 This file is part of FLARE.
7 
8 FLARE is free software: you can redistribute it and/or modify it under the terms
9 of the GNU General Public License as published by the Free Software Foundation,
10 either version 3 of the License, or (at your option) any later version.
11 
12 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License along with
17 FLARE.  If not, see http://www.gnu.org/licenses/
18 */
19 
20 #ifndef GAMESTATECUTSCENE_H
21 #define GAMESTATECUTSCENE_H
22 
23 #include "CommonIncludes.h"
24 #include "GameState.h"
25 #include "Utils.h"
26 
27 class WidgetButton;
28 class WidgetLabel;
29 class WidgetScrollBox;
30 
31 class CutsceneSettings {
32 public:
33 	FPoint caption_margins;
34 	Color caption_background;
35 	float vscroll_speed;
36 	float vscroll_speed_fast;
37 	CutsceneSettings();
38 };
39 
40 class SceneComponent {
41 public:
42 	std::string type;
43 	std::string s;
44 	int x,y,z;
SceneComponent()45 	SceneComponent()
46 		: type("")
47 		, s("")
48 		, x(0)
49 		, y(0)
50 		, z(0) {
51 	}
52 };
53 
54 class VScrollComponent {
55 public:
56 	Point pos;
57 	Sprite *image;
58 	Point image_size;
59 	WidgetLabel *text;
60 	int separator_h;
61 
VScrollComponent()62 	VScrollComponent()
63 		: image(NULL)
64 		, text(NULL)
65 		, separator_h(0)
66 	{}
67 };
68 
69 class Scene {
70 private:
71 	// skip modes
72 	enum {
73 		SKIP_NONE = 0,
74 		SKIP_SUBSCENE = 1,
75 		SKIP_PREV = 2,
76 		SKIP_NEXT = 3,
77 		SKIP_VSCROLL_BACK = 4
78 	};
79 
80 	void clearArt();
81 	void clearSound();
82 
83 	CutsceneSettings cutscene_settings;
84 	int frame_counter;
85 	int pause_frames;
86 	std::string caption;
87 	Sprite *art;
88 	Sprite *art_scaled;
89 	int art_scale_type;
90 	Point art_size;
91 	SoundID sid;
92 	WidgetScrollBox *caption_box;
93 	WidgetButton *button_prev;
94 	WidgetButton *button_next;
95 	WidgetButton *button_close;
96 	WidgetButton *button_advance;
97 	int vscroll_offset;
98 	float vscroll_y;
99 	size_t sub_index;
100 	size_t prev_sub_index;
101 
102 public:
103 	// logic() return state
104 	enum {
105 		NO_CHANGE = 0,
106 		PREV = 1,
107 		NEXT = 2,
108 		DONE = 3
109 	};
110 
111 	Scene(const CutsceneSettings& _settings, short _cutscene_type);
112 	Scene(const Scene& other);
113 	Scene& operator=(const Scene& other);
114 	~Scene();
115 
116 	void refreshWidgets();
117 	void reset();
118 	int logic();
119 	void render();
120 
121 	short cutscene_type;
122 	bool is_first_scene;
123 	bool is_last_scene;
124 	std::vector<size_t> subscenes;
125 	std::vector<SceneComponent> components;
126 	std::vector<VScrollComponent> vscroll_components;
127 
128 	enum {
129 		CUTSCENE_SCALE_NONE = 0,
130 		CUTSCENE_SCALE_HEIGHT = 1,
131 		CUTSCENE_SCALE_SCREEN = 2
132 	};
133 
134 	enum {
135 		CUTSCENE_STATIC = 0,
136 		CUTSCENE_VSCROLL = 1
137 	};
138 
139 };
140 
141 class GameStateCutscene : public GameState {
142 private:
143 	GameState *previous_gamestate;
144 	std::string dest_map;
145 	Point dest_pos;
146 
147 	size_t scene_index;
148 	std::vector<Scene*> scenes;
149 	std::string music;
150 	bool initialized;
151 	int status;
152 
153 public:
154 	explicit GameStateCutscene(GameState *game_state);
155 	~GameStateCutscene();
156 
157 	bool load(const std::string& filename);
158 	void logic();
159 	void render();
160 
161 	int game_slot;
162 };
163 
164 #endif
165 
166