diff options
Diffstat (limited to 'engines/gob/pregob/onceupon/onceupon.h')
-rw-r--r-- | engines/gob/pregob/onceupon/onceupon.h | 221 |
1 files changed, 152 insertions, 69 deletions
diff --git a/engines/gob/pregob/onceupon/onceupon.h b/engines/gob/pregob/onceupon/onceupon.h index 6f8b67a627..08c8803c67 100644 --- a/engines/gob/pregob/onceupon/onceupon.h +++ b/engines/gob/pregob/onceupon/onceupon.h @@ -38,18 +38,67 @@ namespace OnceUpon { class OnceUpon : public PreGob { public: + /** Number of languages we support. */ static const uint kLanguageCount = 5; + OnceUpon(GobEngine *vm); ~OnceUpon(); + protected: - enum MenuType { - kMenuTypeMainStart = 0, ///< The big main menu at game start. - kMenuTypeMainIngame, ///< The big main menu during the game. - kMenuTypeIngame ///< The small popup menu during the game. + /** A description of a menu button. */ + struct MenuButton { + bool needDraw; ///< Does the button need drawing? + + int16 left; ///< Left coordinate of the button. + int16 top; ///< Top coordinate of the button. + int16 right; ///< Right coordinate of the button. + int16 bottom; ///< Bottom coordinate of the button. + + int16 srcLeft; ///< Left coordinate of the button's sprite. + int16 srcTop; ///< Top coordinate of the button's sprite. + int16 srcRight; ///< Right coordinate of the button's sprite. + int16 srcBottom; ///< Right coordinate of the button's sprite. + + int16 dstX; ///< Destination X coordinate of the button's sprite. + int16 dstY; ///< Destination Y coordinate of the button's sprite. + + uint id; ///< The button's ID. }; + + void init(); + void deinit(); + + /** Handle the copy protection. + * + * @param colors Colors the copy protection animals can be. + * @param shapes The shape that's the correct answer for each animal in each color. + * @param obfuscate Extra obfuscate table. correctShape = shapes[colors][obfuscate[animal]]. + * @return true if the user guessed the correct shape, false otherwise. + */ + bool doCopyProtection(const uint8 colors[7], const uint8 shapes[7 * 20], const uint8 obfuscate[4]); + + /** Show the intro. */ + void showIntro(); + + /** Handle the start menu. + * + * @param animalsButton Definition of the menu button that leads to the animal names screen. Can be 0. + * @param animalCount Number of animals in the animal names screen. + * @param animalButtons Definition of the buttons that make up the animals in the animal names screen. + * @param animalNames File prefixes for the name of each animal. + */ + void doStartMenu(const MenuButton *animalsButton, uint animalCount, + const MenuButton *animalButtons, const char * const *animalNames); + + /** Play the game proper. */ + void playGame(); + + +private: + /** All actions a user can request in a menu. */ enum MenuAction { kMenuActionNone = 0, ///< No action. kMenuActionAnimals , ///< Do the animal names. @@ -59,6 +108,7 @@ protected: kMenuActionQuit ///< Quit the game. }; + /** Difficulty levels. */ enum Difficulty { kDifficultyBeginner = 0, kDifficultyIntermediate = 1, @@ -66,115 +116,148 @@ protected: kDifficultyMAX }; + /** The different sounds common in the game. */ enum Sound { kSoundClick = 0, kSoundMAX }; - struct MenuButton { - bool needDraw; - int16 left, top, right, bottom; - int16 srcLeft, srcTop, srcRight, srcBottom; - int16 dstX, dstY; - uint id; - }; + /** A complete screen backup. */ + struct ScreenBackup { + Surface *screen; ///< Screen contents. + int palette; ///< Screen palette. - static const uint kSectionCount = 15; + bool changedCursor; ///< Did we change the cursor? + bool cursorVisible; ///< Was the cursor visible? + ScreenBackup(); + ~ScreenBackup(); + }; - void init(); - void deinit(); - void setAnimalsButton(const MenuButton *animalsButton); + /** The number of game sections. */ + static const uint kSectionCount = 15; - void setGamePalette(uint palette); - void setGameCursor(); + static const MenuButton kMainMenuDifficultyButton[]; ///< Difficulty buttons. + static const MenuButton kSectionButtons[]; ///< Section buttons. - Common::String fixString(const Common::String &str) const; - void fixTXTStrings(TXTFile &txt) const; + static const MenuButton kIngameButtons[]; ///< Ingame menu buttons. - bool doCopyProtection(const uint8 colors[7], const uint8 shapes[7 * 20], const uint8 obfuscate[4]); + static const MenuButton kAnimalNamesBack; ///< "Back" button in the animal names screens. + static const MenuButton kLanguageButtons[]; ///< Language buttons in the animal names screen. - void showWait(uint palette = 0xFFFF); ///< Show the wait / loading screen. - void showIntro(); ///< Show the whole intro. + /** All general game sounds we know about. */ + static const char *kSound[kSoundMAX]; - void showChapter(int chapter); ///< Show a chapter intro text. - void showByeBye(); ///< Show the "bye bye" screen + // -- General helpers -- - MenuAction doMenu(MenuType type); + void setGamePalette(uint palette); ///< Set a game palette. + void setGameCursor(); ///< Set the default game cursor. - void doAnimalNames(uint count, const MenuButton *buttons, const char * const *names); + /** Set the state of an ANIObject. */ + void setAnimState(ANIObject &ani, uint16 state, bool once, bool pause) const; + /** Draw this sprite in a fancy, animated line-by-line way. */ void drawLineByLine(const Surface &src, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y) const; + /** Backup the screen contents. */ + void backupScreen(ScreenBackup &backup, bool setDefaultCursor = false); + /** Restore the screen contents with a previously made backup. */ + void restoreScreen(ScreenBackup &backup); - // Fonts - Font *_jeudak; - Font *_lettre; - Font *_plettre; - Font *_glettre; + Common::String fixString(const Common::String &str) const; ///< Fix a string if necessary. + void fixTXTStrings(TXTFile &txt) const; ///< Fix all strings in a TXT. - Difficulty _difficulty; - uint8 _section; -private: - static const MenuButton kMainMenuDifficultyButton[]; - static const MenuButton kSectionButtons[]; - static const MenuButton kIngameButtons[]; + // -- Copy protection helpers -- - static const MenuButton kAnimalNamesBack; - static const MenuButton kLanguageButtons[]; + /** Set up the copy protection. */ + int8 cpSetup(const uint8 colors[7], const uint8 shapes[7 * 20], + const uint8 obfuscate[4], const Surface sprites[2]); + /** Find the shape under these coordinates. */ + int8 cpFindShape(int16 x, int16 y) const; + /** Display the "You are wrong" screen. */ + void cpWrong(); - static const char *kSound[kSoundMAX]; + // -- Show different game screens -- - void setCopyProtectionPalette(); + void showWait(uint palette = 0xFFFF); ///< Show the wait / loading screen. + void showQuote(); ///< Show the quote about fairytales. + void showTitle(); ///< Show the Once Upon A Time title. + void showChapter(int chapter); ///< Show a chapter intro text. + void showByeBye(); ///< Show the "bye bye" screen. - void setAnimState(ANIObject &ani, uint16 state, bool once, bool pause) const; + /** Handle the "listen to animal names" part. */ + void handleAnimalNames(uint count, const MenuButton *buttons, const char * const *names); - // Copy protection helpers - int8 cpSetup(const uint8 colors[7], const uint8 shapes[7 * 20], const uint8 obfuscate[4], const Surface sprites[2]); - int8 cpFindShape(int16 x, int16 y) const; - void cpWrong(); - // Intro parts - void showQuote(); - void showTitle(); - - // Title music - void playTitleMusic(); - void playTitleMusicDOS(); - void playTitleMusicAmiga(); - void playTitleMusicAtariST(); - void stopTitleMusic(); - - // Menu helpers - MenuAction doMenuMainStart(); - MenuAction doMenuMainIngame(); - MenuAction doMenuIngame(); - - void drawMenuMainStart(); - void drawMenuMainIngame(); - void drawMenuIngame(); + // -- Title music helpers -- + + void playTitleMusic(); ///< Play the title music. + void playTitleMusicDOS(); ///< Play the title music of the DOS version. + void playTitleMusicAmiga(); ///< Play the title music of the Amiga version. + void playTitleMusicAtariST(); ///< Play the title music of the Atari ST version. + void stopTitleMusic(); ///< Stop the title music. + + + // -- Menu helpers -- + + MenuAction handleStartMenu(const MenuButton *animalsButton); ///< Handle the start menu. + MenuAction handleMainMenu(); ///< Handle the main menu. + MenuAction handleIngameMenu(); ///< Handle the ingame menu. + + void drawStartMenu(const MenuButton *animalsButton); ///< Draw the start menu. + void drawMainMenu(); ///< Draw the main menu. + void drawIngameMenu(); ///< Draw the ingame menu. + + /** Draw the difficulty label. */ void drawMenuDifficulty(); - void clearMenuIngame(const Surface &background); + /** Clear the ingame menu in an animated way. */ + void clearIngameMenu(const Surface &background); + + // -- Menu button helpers -- + + /** Find the button under these coordinates. */ int checkButton(const MenuButton *buttons, uint count, int16 x, int16 y, int failValue = -1) const; - void drawButton(Surface &dest, const Surface &src, const MenuButton &button) const; + + /** Draw a menu button. */ + void drawButton (Surface &dest, const Surface &src, const MenuButton &button) const; + /** Draw multiple menu buttons. */ void drawButtons(Surface &dest, const Surface &src, const MenuButton *buttons, uint count) const; + + /** Draw a border around a button. */ void drawButtonBorder(const MenuButton &button, uint8 color); - // Animal names helpers + + // -- Animal names helpers -- + + /** Set up the animal chooser. */ void anSetupChooser(); + /** Set up the language chooser for one animal. */ void anSetupNames(const MenuButton &animal); + /** Play / Display the name of an animal in one language. */ void anPlayAnimalName(const Common::String &animal, uint language); + + /** Did we open the game archives? */ bool _openedArchives; - const MenuButton *_animalsButton; + // Fonts + Font *_jeudak; + Font *_lettre; + Font *_plettre; + Font *_glettre; + + /** The current palette. */ + int _palette; + + Difficulty _difficulty; ///< The current difficulty. + uint8 _section; ///< The current game section. }; } // End of namespace OnceUpon |