ScummVM API documentation
script_cutscene.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NUVIE_SCRIPT_SCRIPT_CUTSCENE_H
23 #define NUVIE_SCRIPT_SCRIPT_CUTSCENE_H
24 
25 #include "common/lua/lua.h"
26 
27 #include "ultima/nuvie/gui/gui.h"
28 #include "ultima/nuvie/gui/widgets/gui_widget.h"
29 #include "ultima/nuvie/files/u6_shape.h"
30 #include "ultima/nuvie/fonts/wou_font.h"
31 #include "ultima/nuvie/conf/configuration.h"
32 
33 namespace Ultima {
34 namespace Nuvie {
35 
36 class SoundManager;
37 class Font;
38 class U6LineWalker;
39 class Cursor;
40 
41 class CSImage {
42 public:
43  U6Shape *orig_shp;
44  U6Shape *scaled_shp;
45  U6Shape *shp;
46  uint16 scale;
47  uint16 refcount;
48 
49  CSImage(U6Shape *shape) {
50  orig_shp = shape;
51  scaled_shp = nullptr;
52  shp = shape;
53  scale = 100;
54  refcount = 0;
55  }
56  virtual ~CSImage() {}
57 
58  void setScale(uint16 percentage);
59  uint16 getScale() {
60  return scale;
61  }
62 
63  virtual void updateEffect() { };
64 };
65 
66 #define STAR_FIELD_NUM_STARS 70
67 
68 class CSStarFieldImage : public CSImage {
69 
70 private:
71  uint16 w;
72  uint16 h;
73  struct {
74  uint8 color;
75  U6LineWalker *line;
76  } stars[STAR_FIELD_NUM_STARS];
77 public:
78  CSStarFieldImage(U6Shape *shape);
79  ~CSStarFieldImage() override {}
80  void updateEffect() override;
81 };
82 
83 struct CSSprite {
84  sint16 x;
85  sint16 y;
86  uint8 opacity;
87  CSImage *image;
88  bool visible;
89  Common::Rect clip_rect;
90  Std::string text;
91  uint16 text_color;
92  uint8 text_align;
93 
94  CSSprite() {
95  x = 0;
96  y = 0;
97  opacity = 255;
98  image = nullptr;
99  visible = false;
100  clip_rect = Common::Rect();
101  text = "";
102  text_color = 0xffff;
103  text_align = 0;
104  }
105 };
106 
109  Std::vector<CSImage *> images;
110 };
111 
112 void nscript_init_cutscene(lua_State *L, Configuration *cfg, GUI *gui, SoundManager *sm);
113 
114 class ScriptCutscene : public GUI_Widget {
115 private:
116  Configuration *config;
117  GUI *gui;
118  Cursor *cursor;
119  Std::list<CSSprite *> sprite_list; // in paint order
120  Screen *screen;
121  uint8 *palette;
122  SoundManager *sound_manager;
123  WOUFont *font;
124  Common::Rect clip_rect;
125  uint16 x_off, y_off;
126  uint32 next_time;
127  uint32 loop_interval;
128  uint8 screen_opacity;
129  uint8 bg_color;
130  bool solid_bg;
131  bool rotate_game_palette;
132 
133 public:
135  ~ScriptCutscene() override;
136 
137  Std::vector<Std::string> load_text(const char *filename, uint8 idx);
138 
139  Std::vector<CSMidGameData> load_midgame_file(const char *filename);
140 
141  CSImage *load_image(const char *filename, int idx, int sub_idx = 0);
142  Std::vector<Std::vector<CSImage *> > load_all_images(const char *filename);
143  void add_sprite(CSSprite *s) {
144  sprite_list.push_back(s);
145  }
146  void remove_sprite(CSSprite *s) {
147  sprite_list.remove(s);
148  }
149 
150  void load_palette(const char *filename, int idx);
151  void set_palette_entry(uint8 idx, uint8 r, uint8 g, uint8 b);
152  void rotate_palette(uint8 idx, uint8 length);
153  void set_screen_opacity(uint8 new_opacity);
154  void enable_game_palette_rotation(bool val) {
155  rotate_game_palette = val;
156  }
157 
158  void set_update_interval(uint16 interval);
159  void update();
160 
161  void wait();
162  void Display(bool full_redraw) override;
163  void Hide() override;
164 
165  void print_text(CSImage *image, const char *string, uint16 *x, uint16 *y, uint16 startx, uint16 width, uint8 color);
166 
167  SoundManager *get_sound_manager() {
168  return sound_manager;
169  }
170 
171  uint16 get_x_off() const {
172  return x_off;
173  }
174  uint16 get_y_off() const {
175  return y_off;
176  }
177 
178  Font *get_font() {
179  return (Font *)font;
180  }
181  Configuration *get_config() {
182  return config;
183  }
184 
185  void hide_sprites();
186 
187  void set_bg_color(uint8 new_color) {
188  bg_color = new_color;
189  }
190  void set_solid_bg(bool value) {
191  solid_bg = value;
192  }
193 
194  Screen *get_screen() {
195  return screen;
196  }
197 
198  uint16 get_text_width(const char *text) {
199  return font->getStringWidth(text);
200  }
201 
202 private:
203  bool is_lzc(const char *filename);
204  CSImage *load_image_from_lzc(const Common::Path &filename, uint16 idx, uint16 sub_idx);
205  void display_wrapped_text(CSSprite *s);
206  int display_wrapped_text_line(Std::string str, uint8 text_color, int x, int y, uint8 align_val);
207 };
208 
209 ScriptCutscene *get_cutscene();
210 
211 } // End of namespace Nuvie
212 } // End of namespace Ultima
213 
214 #endif
Definition: script_cutscene.h:107
Definition: gui_widget.h:38
Definition: configuration.h:61
Definition: script_cutscene.h:114
Definition: rect.h:144
Definition: path.h:52
Definition: lstate.h:100
Definition: system.h:46
Definition: script_cutscene.h:68
Definition: script_cutscene.h:83
Definition: screen.h:41
Definition: u6_shape.h:47
Definition: detection.h:27
Definition: script_cutscene.h:41
Definition: u6_line_walker.h:30
Definition: atari-cursor.h:38
Definition: string.h:30
Definition: cursor.h:46
Definition: sound_manager.h:62
void remove(const T &val)
Definition: list.h:125
Definition: containers.h:200
void push_back(const T &element)
Definition: list.h:140
Definition: containers.h:38
Definition: wou_font.h:34
Definition: font.h:42