ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
113  int gameType;
114  Common::String name;
115  int gender;
116  Common::String className;
117  int str;
118  int dex;
119  int intelligence;
120  int magic;
121  int exp;
122  int level;
123 };
124 
125 void nscript_init_cutscene(lua_State *L, Configuration *cfg, GUI *gui, SoundManager *sm);
126 
127 class ScriptCutscene : public GUI_Widget {
128 private:
129  Configuration *config;
130  GUI *gui;
131  Cursor *cursor;
132  Std::list<CSSprite *> sprite_list; // in paint order
133  Screen *screen;
134  uint8 *palette;
135  SoundManager *sound_manager;
136  WOUFont *font;
137  Common::Rect clip_rect;
138  uint16 x_off, y_off;
139  uint32 next_time;
140  uint32 loop_interval;
141  uint8 screen_opacity;
142  uint8 bg_color;
143  bool solid_bg;
144  bool rotate_game_palette;
145 
146 public:
148  ~ScriptCutscene() override;
149 
150  Std::vector<Std::string> load_text(const char *filename, uint8 idx);
151 
152  Std::vector<CSMidGameData> load_midgame_file(const char *filename);
153 
154  TransferSaveData load_transfer_save();
155 
156  CSImage *load_image(const char *filename, int idx, int sub_idx = 0);
157  Std::vector<Std::vector<CSImage *> > load_all_images(const char *filename);
158  void add_sprite(CSSprite *s) {
159  sprite_list.push_back(s);
160  }
161  void remove_sprite(CSSprite *s) {
162  sprite_list.remove(s);
163  }
164 
165  void load_palette(const char *filename, int idx);
166  void set_palette_entry(uint8 idx, uint8 r, uint8 g, uint8 b);
167  void rotate_palette(uint8 idx, uint8 length);
168  void set_screen_opacity(uint8 new_opacity);
169  void enable_game_palette_rotation(bool val) {
170  rotate_game_palette = val;
171  }
172 
173  void set_update_interval(uint16 interval);
174  void update();
175 
176  void wait();
177  void Display(bool full_redraw) override;
178  void Hide() override;
179 
180  void print_text(CSImage *image, const char *string, uint16 *x, uint16 *y, uint16 startx, uint16 width, uint8 color);
181  void print_text_raw(CSImage *image, const char *string, uint16 x, uint16 y, uint8 color) const;
182 
183  SoundManager *get_sound_manager() {
184  return sound_manager;
185  }
186 
187  uint16 get_x_off() const {
188  return x_off;
189  }
190  uint16 get_y_off() const {
191  return y_off;
192  }
193 
194  Font *get_font() {
195  return (Font *)font;
196  }
197  Configuration *get_config() {
198  return config;
199  }
200 
201  void hide_sprites();
202 
203  void set_bg_color(uint8 new_color) {
204  bg_color = new_color;
205  }
206  void set_solid_bg(bool value) {
207  solid_bg = value;
208  }
209 
210  Screen *get_screen() {
211  return screen;
212  }
213 
214  uint16 get_text_width(const char *text) {
215  return font->getStringWidth(text);
216  }
217 
218 private:
219  bool is_lzc(const char *filename);
220  CSImage *load_image_from_lzc(const Common::Path &filename, uint16 idx, uint16 sub_idx);
221  void display_wrapped_text(CSSprite *s);
222  int display_wrapped_text_line(Std::string str, uint8 text_color, int x, int y, uint8 align_val);
223 
224  bool load_u4_save_file(TransferSaveData &saveData);
225  bool load_u5_save_file(TransferSaveData &saveData);
226 };
227 
228 ScriptCutscene *get_cutscene();
229 
230 } // End of namespace Nuvie
231 } // End of namespace Ultima
232 
233 #endif
Definition: str.h:59
Definition: script_cutscene.h:107
Definition: gui_widget.h:38
Definition: configuration.h:61
Definition: script_cutscene.h:127
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:142
Definition: containers.h:200
Definition: script_cutscene.h:112
void push_back(const T &element)
Definition: list.h:174
Definition: containers.h:38
Definition: wou_font.h:34
Definition: font.h:42