ScummVM API documentation
onceupon.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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_PREGOB_ONCEUPON_ONCEUPON_H
29 #define GOB_PREGOB_ONCEUPON_ONCEUPON_H
30 
31 #include "common/system.h"
32 #include "common/str.h"
33 
34 #include "gob/pregob/pregob.h"
35 
36 #include "gob/pregob/onceupon/stork.h"
37 
38 namespace Gob {
39 
40 class Surface;
41 class Font;
42 
43 class ANIObject;
44 
45 namespace OnceUpon {
46 
47 class OnceUpon : public PreGob {
48 public:
50  static const uint kLanguageCount = 5;
51 
52 
53  OnceUpon(GobEngine *vm);
54  ~OnceUpon() override;
55 
56 
57 protected:
59  struct MenuButton {
60  bool needDraw;
61 
62  int16 left;
63  int16 top;
64  int16 right;
65  int16 bottom;
66 
67  int16 srcLeft;
68  int16 srcTop;
69  int16 srcRight;
70  int16 srcBottom;
71 
72  int16 dstX;
73  int16 dstY;
74 
75  uint id;
76  };
77 
79  struct StorkParam {
80  const char *backdrop;
81 
82  uint houseCount;
83  const MenuButton *houses;
84 
86  };
87 
88  void init();
89  void deinit();
90 
98  bool doCopyProtection(const uint8 colors[7], const uint8 shapes[7 * 20], const uint8 obfuscate[4]);
99 
101  void showIntro();
102 
110  void doStartMenu(const MenuButton *animalsButton, uint animalCount,
111  const MenuButton *animalButtons, const char * const *animalNames);
112 
114  void playGame();
115 
116 
118  virtual const StorkParam &getStorkParameters() const = 0;
119 
120 
121 private:
123  enum MenuAction {
124  kMenuActionNone = 0,
125  kMenuActionAnimals ,
126  kMenuActionPlay ,
127  kMenuActionRestart ,
128  kMenuActionMainMenu,
129  kMenuActionQuit
130  };
131 
133  enum Difficulty {
134  kDifficultyBeginner = 0,
135  kDifficultyIntermediate = 1,
136  kDifficultyAdvanced = 2,
137  kDifficultyCount
138  };
139 
141  enum Sound {
142  kSoundClick = 0,
143  kSoundStork ,
144  kSoundJump ,
145  kSoundCount
146  };
147 
149  enum CharGenAction {
150  kCharGenDone = 0,
151  kCharGenAbort ,
152  kCharGenRestart
153  };
154 
156  struct ScreenBackup {
157  Surface *screen;
158  int palette;
159 
160  bool changedCursor;
161  bool cursorVisible;
162 
163  ScreenBackup();
164  ~ScreenBackup();
165  };
166 
167 
169  static const int kSectionCount = 15;
170 
171  static const MenuButton kMainMenuDifficultyButton[];
172  static const MenuButton kSectionButtons[];
173 
174  static const MenuButton kIngameButtons[];
175 
176  static const MenuButton kAnimalNamesBack;
177  static const MenuButton kLanguageButtons[];
178 
179  static const MenuButton kSectionStorkHouses[];
180 
181  static const MenuButton kCharGenHeadButtons[];
182  static const MenuButton kCharGenHeads[];
183  static const MenuButton kCharGenHairButtons[];
184  static const MenuButton kCharGenJacketButtons[];
185  static const MenuButton kCharGenTrousersButtons[];
186  static const MenuButton kCharGenNameEntry[];
187 
189  static const char *kSound[kSoundCount];
190 
191 
192  static const AnimProperties kClownAnimations[];
193  static const AnimProperties kTitleAnimation;
194  static const AnimProperties kSectionStorkAnimations[];
195  static const AnimProperties kSectionEndAnimations[];
196 
197 
199  typedef bool (OnceUpon::*SectionFunc)();
201  static const SectionFunc kSectionFuncs[kSectionCount];
202 
203 
205  bool _openedArchives;
206 
207  // Fonts
208  Font *_jeudak;
209  Font *_lettre;
210  Font *_plettre;
211  Font *_glettre;
212 
214  int _palette;
215 
216  bool _quit;
217 
218  Difficulty _difficulty;
219  int _section;
220 
221  Common::String _name;
222 
223  uint8 _house;
224 
225  uint8 _head;
226  uint8 _colorHair;
227  uint8 _colorJacket;
228  uint8 _colorTrousers;
229 
230 
231  // -- General helpers --
232 
233  void setGamePalette(uint palette);
234  void setGameCursor();
235 
237  void drawLineByLine(const Surface &src, int16 left, int16 top, int16 right, int16 bottom,
238  int16 x, int16 y) const;
239 
241  void backupScreen(ScreenBackup &backup, bool setDefaultCursor = false);
243  void restoreScreen(ScreenBackup &backup);
244 
245  Common::String fixString(const Common::String &str) const;
246  void fixTXTStrings(TXTFile &txt) const override;
247 
248 
249  // -- Copy protection helpers --
250 
252  int8 cpSetup(const uint8 colors[7], const uint8 shapes[7 * 20],
253  const uint8 obfuscate[4], const Surface sprites[2]);
255  int8 cpFindShape(int16 x, int16 y) const;
257  void cpWrong();
258 
259 
260  // -- Show different game screens --
261 
262  void showWait(uint palette = 0xFFFF);
263  void showQuote();
264  void showTitle();
265  void showChapter(int chapter);
266  void showByeBye();
267 
269  void handleAnimalNames(uint count, const MenuButton *buttons, const char * const *names);
270 
271 
272  // -- Menu helpers --
273 
274  MenuAction handleStartMenu(const MenuButton *animalsButton);
275  MenuAction handleMainMenu();
276  MenuAction handleIngameMenu();
277 
278  void drawStartMenu(const MenuButton *animalsButton);
279  void drawMainMenu();
280  void drawIngameMenu();
281 
283  void drawMenuDifficulty();
284 
286  void clearIngameMenu(const Surface &background);
287 
289  MenuAction doIngameMenu();
291  MenuAction doIngameMenu(int16 &key, MouseButtons &mouseButtons);
292 
293 
294  // -- Menu button helpers --
295 
297  int checkButton(const MenuButton *buttons, uint count, int16 x, int16 y, int failValue = -1) const;
298 
300  void drawButton (Surface &dest, const Surface &src, const MenuButton &button, int transp = -1) const;
302  void drawButtons(Surface &dest, const Surface &src, const MenuButton *buttons, uint count, int transp = -1) const;
303 
305  void drawButtonBorder(const MenuButton &button, uint8 color);
306 
307 
308  // -- Animal names helpers --
309 
311  void anSetupChooser();
313  void anSetupNames(const MenuButton &animal);
315  void anPlayAnimalName(const Common::String &animal, uint language);
316 
317 
318  // -- Game sections --
319 
320  bool playSection();
321 
322  bool sectionStork();
323  bool sectionChapter1();
324  bool sectionParents();
325  bool sectionChapter2();
326  bool sectionForest0();
327  bool sectionChapter3();
328  bool sectionEvilCastle();
329  bool sectionChapter4();
330  bool sectionForest1();
331  bool sectionChapter5();
332  bool sectionBossFight();
333  bool sectionChapter6();
334  bool sectionForest2();
335  bool sectionChapter7();
336  bool sectionEnd();
337 
338  CharGenAction characterGenerator();
339  void charGenSetup(uint stage);
340  void charGenDrawName();
341 
342  static bool enterString(Common::String &name, int16 key, uint maxLength, const Font &font);
343 };
344 
345 } // End of namespace OnceUpon
346 
347 } // End of namespace Gob
348 
349 #endif // GOB_PREGOB_ONCEUPON_ONCEUPON_H
int16 bottom
Bottom coordinate of the button.
Definition: onceupon.h:65
Definition: pregob.h:48
virtual const StorkParam & getStorkParameters() const =0
int16 dstX
Destination X coordinate of the button&#39;s sprite.
Definition: onceupon.h:72
int16 srcRight
Right coordinate of the button&#39;s sprite.
Definition: onceupon.h:69
Definition: gob.h:163
Definition: str.h:59
int16 srcBottom
Right coordinate of the button&#39;s sprite.
Definition: onceupon.h:70
int16 dstY
Destination Y coordinate of the button&#39;s sprite.
Definition: onceupon.h:73
int16 top
Top coordinate of the button.
Definition: onceupon.h:63
int16 right
Right coordinate of the button.
Definition: onceupon.h:64
Definition: stork.h:52
Definition: onceupon.h:47
const Stork::BundleDrop * drops
The bundle drop parameters.
Definition: onceupon.h:85
Definition: video.h:40
static const uint kLanguageCount
Definition: onceupon.h:50
const char * backdrop
Backdrop image file.
Definition: onceupon.h:80
const MenuButton * houses
House button definitions.
Definition: onceupon.h:83
Definition: onceupon.h:79
int16 srcTop
Top coordinate of the button&#39;s sprite.
Definition: onceupon.h:68
void doStartMenu(const MenuButton *animalsButton, uint animalCount, const MenuButton *animalButtons, const char *const *animalNames)
Definition: anifile.h:40
Definition: onceupon.h:59
Definition: txtfile.h:46
int16 srcLeft
Left coordinate of the button&#39;s sprite.
Definition: onceupon.h:67
Definition: surface.h:100
int16 left
Left coordinate of the button.
Definition: onceupon.h:62
bool doCopyProtection(const uint8 colors[7], const uint8 shapes[7 *20], const uint8 obfuscate[4])
bool needDraw
Does the button need drawing?
Definition: onceupon.h:60
uint houseCount
Number of houses.
Definition: onceupon.h:82
uint id
The button&#39;s ID.
Definition: onceupon.h:75
Definition: pregob.h:55