ScummVM API documentation
intro_controller.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 ULTIMA4_CONTROLLERS_INTRO_CONTROLLER_H
23 #define ULTIMA4_CONTROLLERS_INTRO_CONTROLLER_H
24 
25 #include "ultima/ultima4/controllers/controller.h"
26 #include "ultima/ultima4/core/observer.h"
27 #include "ultima/ultima4/filesys/savegame.h"
28 #include "ultima/ultima4/views/menu.h"
29 #include "ultima/ultima4/views/textview.h"
30 #include "ultima/ultima4/views/imageview.h"
31 #include "ultima/ultima4/views/tileview.h"
32 #include "ultima/shared/core/file.h"
33 
34 namespace Ultima {
35 namespace Ultima4 {
36 
37 class IntroObjectState;
38 class Tile;
39 
43 class IntroBinData {
44 private:
45  // disallow assignments, copy contruction
46  IntroBinData(const IntroBinData &);
47  const IntroBinData &operator=(const IntroBinData &);
48  void openFile(Shared::File &f, const Common::String &name);
49 public:
50  IntroBinData();
51  ~IntroBinData();
52 
53  bool load();
54 
55  Std::vector<MapTile> _introMap;
56  byte *_sigData;
57  byte *_scriptTable;
58  Tile **_baseTileTable;
59  byte *_beastie1FrameTable;
60  byte *_beastie2FrameTable;
61  Std::vector<Common::String> _introText;
62  Std::vector<Common::String> _introQuestions;
63  Std::vector<Common::String> _introGypsy;
64 };
65 
66 
81 class IntroController : public Controller, public Observer<Menu *, MenuEvent &> {
82 public:
84  ~IntroController() override;
85 
90  bool init();
91  bool hasInitiatedNewGame();
92 
96  void deleteIntro();
97 
101  bool keyPressed(int key) override;
102 
106  bool mousePressed(const Common::Point &mousePos) override;
107 
108  byte *getSigData();
109 
113  void updateScreen();
114 
119  void timerFired() override;
120 
124  void preloadMap();
125 
131  void update(Menu *menu, MenuEvent &event) override;
132  void updateConfMenu(MenuEvent &event);
133  void updateVideoMenu(MenuEvent &event);
134  void updateGfxMenu(MenuEvent &event);
135  void updateSoundMenu(MenuEvent &event);
136  void updateInputMenu(MenuEvent &event);
137  void updateSpeedMenu(MenuEvent &event);
138  void updateGameplayMenu(MenuEvent &event);
139  void updateInterfaceMenu(MenuEvent &event);
140 
141  //
142  // Title methods
143  //
147  void initTitles();
148 
152  bool updateTitle();
153 
154 private:
158  void drawMap();
159  void drawMapStatic();
160  void drawMapAnimated();
161 
165  void drawBeasties();
166 
174  void drawBeastie(int beast, int vertoffset, int frame);
175 
184  void animateTree(const Common::String &frame);
185 
189  void drawCard(int pos, int card);
190 
194  void drawAbacusBeads(int row, int selectedVirtue, int rejectedVirtue);
195 
200  void initQuestionTree();
201 
207  bool doQuestion(int answer);
208 
213  void initPlayers(SaveGame *saveGame);
214 
219  Common::String getQuestion(int v1, int v2);
220 #ifdef IOS_ULTIMA4
221 public:
226  void tryTriggerIntroMusic();
227 #endif
228 
233  void initiateNewGame();
234  void finishInitiateGame(const Common::String &nameBuffer, SexType sex);
235 
240  void startQuestions();
241  void showStory();
242 
246  void journeyOnward();
247 
251  void about();
252 #ifdef IOS_ULTIMA4
253 private:
254 #endif
255 
258  void showText(const Common::String &text);
259 
264  void runMenu(Menu *menu, TextView *view, bool withBeasties);
265 
269  enum {
270  INTRO_TITLES, // displaying the animated intro titles
271  INTRO_MAP, // displaying the animated intro map
272  INTRO_MENU, // displaying the main menu: journey onward, etc.
273  INTRO_ABOUT
274  } _mode;
275 
276  enum MenuConstants {
277  MI_CONF_VIDEO,
278  MI_CONF_SOUND,
279  MI_CONF_INPUT,
280  MI_CONF_SPEED,
281  MI_CONF_GAMEPLAY,
282  MI_CONF_INTERFACE,
283  MI_CONF_01,
284  MI_VIDEO_CONF_GFX,
285  MI_VIDEO_02,
286  MI_VIDEO_03,
287  MI_VIDEO_07,
288  MI_VIDEO_08,
289  MI_GFX_SCHEME,
290  MI_GFX_TILE_TRANSPARENCY,
291  MI_GFX_TILE_TRANSPARENCY_SHADOW_SIZE,
292  MI_GFX_TILE_TRANSPARENCY_SHADOW_OPACITY,
293  MI_GFX_RETURN,
294  MI_SOUND_03,
295  MI_INPUT_03,
296  MI_SPEED_01,
297  MI_SPEED_02,
298  MI_SPEED_03,
299  MI_SPEED_04,
300  MI_SPEED_05,
301  MI_SPEED_06,
302  MI_SPEED_07,
303  MI_GAMEPLAY_01,
304  MI_GAMEPLAY_02,
305  MI_GAMEPLAY_03,
306  MI_GAMEPLAY_04,
307  MI_GAMEPLAY_05,
308  MI_GAMEPLAY_06,
309  MI_INTERFACE_01,
310  MI_INTERFACE_02,
311  MI_INTERFACE_03,
312  MI_INTERFACE_04,
313  MI_INTERFACE_05,
314  MI_INTERFACE_06,
315  USE_SETTINGS = 0xFE,
316  CANCEL = 0xFF
317  };
318 
319  ImageView _backgroundArea;
320  TextView _menuArea;
321  TextView _extendedMenuArea;
322  TextView _questionArea;
323  TileView _mapArea;
324  Image *_mapScreen;
325 
326  // menus
327  Menu _mainMenu;
328  Menu _confMenu;
329  Menu _videoMenu;
330  Menu _gfxMenu;
331  Menu _soundMenu;
332  Menu _inputMenu;
333  Menu _speedMenu;
334  Menu _gameplayMenu;
335  Menu _interfaceMenu;
336 
337  // data loaded in from title.exe
338  IntroBinData *_binData;
339 
340  // additional introduction state data
341  Common::String _errorMessage;
342  int _answerInd;
343  int _questionRound;
344  int _questionTree[15];
345  int _beastie1Cycle;
346  int _beastie2Cycle;
347  int _beastieOffset;
348  bool _beastiesVisible;
349  int _sleepCycles;
350  int _scrPos; /* current position in the script table */
351  IntroObjectState *_objectStateTable;
352 
353  bool _justInitiatedNewGame;
354  Common::String _profileName;
355  bool _useProfile;
356 
357  //
358  // Title defs, structs, methods, and data members
359  //
360  enum AnimType {
361  SIGNATURE,
362  AND,
363  BAR,
364  ORIGIN,
365  PRESENT,
366  TITLE,
367  SUBTITLE,
368  MAP
369  };
370 
371  struct AnimPlot {
372  uint8 x, y;
373  uint8 r, g, b, a;
374  };
375 
376  struct AnimElement {
377  void shufflePlotData();
378 
379  int _rx, _ry; // screen/source x and y
380  int _rw, _rh; // source width and height
381  AnimType _method; // render method
382  int _animStep; // tracks animation position
383  int _animStepMax;
384  int _timeBase; // initial animation time
385  uint32 _timeDelay; // delay before rendering begins
386  int _timeDuration; // total animation time
387  Image *_srcImage; // storage for the source image
388  Image *_destImage; // storage for the animation frame
389  Std::vector <AnimPlot> _plotData; // plot data
390  bool _prescaled;
391  };
392 
396  void addTitle(int x, int y, int w, int h, AnimType method, uint32 delay, int duration);
397 
402  void compactTitle();
403 
407  void drawTitle();
408 
412  void getTitleSourceData();
413 
417  void skipTitles();
418 
419  Std::vector<AnimElement> _titles; // list of title elements
420  Std::vector<AnimElement>::iterator _title; // current title element
421 
422  int _transparentIndex; // palette index for transparency
423  RGBA _transparentColor; // palette color for transparency
424 
425  bool _bSkipTitles;
426 
427  // Temporary place-holder for settings changes
428  SettingsData _settingsChanged;
429 };
430 
431 extern IntroController *g_intro;
432 
433 } // End of namespace Ultima4
434 } // End of namespace Ultima
435 
436 #endif
Definition: savegame.h:270
Definition: str.h:59
Definition: image.h:36
Definition: menu.h:37
Definition: observer.h:37
T * iterator
Definition: array.h:54
Definition: textview.h:41
Definition: controller.h:35
Definition: detection.h:27
Definition: tileview.h:42
Definition: menu.h:72
Definition: intro_controller.h:43
Definition: rect.h:45
Definition: file.h:34
Definition: imageview.h:33
Definition: settings.h:104
Definition: intro_controller.h:81
Definition: tile.h:65
Definition: movie_decoder.h:32