diff options
author | Paul Gilbert | 2017-12-10 07:17:36 -0500 |
---|---|---|
committer | Paul Gilbert | 2017-12-10 07:17:36 -0500 |
commit | f0a87ed8ad0c0b6e923d9b34ee4fd02907328602 (patch) | |
tree | ba5dc362d0395e5d854393ed051d72cfa188e2a8 /engines/xeen/town.h | |
parent | 65ecb6e56f91c3ea92a7001d80337efb4a93e004 (diff) | |
download | scummvm-rg350-f0a87ed8ad0c0b6e923d9b34ee4fd02907328602.tar.gz scummvm-rg350-f0a87ed8ad0c0b6e923d9b34ee4fd02907328602.tar.bz2 scummvm-rg350-f0a87ed8ad0c0b6e923d9b34ee4fd02907328602.zip |
XEEN: Objectifying town locations code
Diffstat (limited to 'engines/xeen/town.h')
-rw-r--r-- | engines/xeen/town.h | 241 |
1 files changed, 216 insertions, 25 deletions
diff --git a/engines/xeen/town.h b/engines/xeen/town.h index 8b05ee221b..a8d03f3d62 100644 --- a/engines/xeen/town.h +++ b/engines/xeen/town.h @@ -34,20 +34,22 @@ namespace Xeen { enum TownAction { BANK = 0, BLACKSMITH = 1, GUILD = 2, TAVERN = 3, TEMPLE = 4, TRAINING = 5, ARENA = 6, NO_ACTION = 7, REAPER = 8, GOLEM = 9, - DWARF1 = 10, SPHINX = 11, ACTION12 = 12, DWARF2 = 13 + DWARF1 = 10, SPHINX = 11, PYRAMID = 12, DWARF2 = 13 }; class XeenEngine; class TownMessage; -class Town: public ButtonContainer { - friend class TownMessage; -private: +class TownLocation : public ButtonContainer { +protected: + TownAction _townActionId; + Common::Array<SpriteResource> _townSprites; SpriteResource _icons1, _icons2; Common::StringArray _textStrings; - Common::Array<SpriteResource> _townSprites; int _townMaxId; - TownAction _townActionId; + const bool &_isDarkCc; + int _animFrame; + Common::String _vocName, _songName; int _v1, _v2; int _donation; int _healCost; @@ -68,26 +70,213 @@ private: uint _experienceToNextLevel; int _drawFrameIndex; int _drawCtr1, _drawCtr2; - +protected: + /** + * Load a set of text strings from the given resource + */ void loadStrings(const Common::String &name); - void pyramidEvent(); + /** + * Draw the window + */ + void drawWindow(); - void arenaEvent(); + /** + * Waits for a brief pause, checking for any key or mouse events + */ + int wait(); - void reaperEvent(); + /** + * Generates the display text for the location, for a given character + */ + virtual Common::String createLocationText(Character &ch) { return ""; } - void golemEvent(); + /** + * Draw the visual background + */ + virtual void drawBackground(); - void sphinxEvent(); + /** + * Handles options for the particular location + */ + virtual Character *doOptions(Character *c) { return c; } - void dwarfEvent(); + /** + * Handle any farewell + */ + virtual void farewell() {} +public: + TownLocation(TownAction action); + virtual ~TownLocation(); - Common::String createTownText(Character &ch); + /** + * Show the town location + */ + virtual int show(); - int townWait(); + /** + * Draws the animated parts + */ + void drawAnim(bool flag); +}; - Character *doTownOptions(Character *c); +class BankLocation : public TownLocation { +private: + /** + * Handles deposits or withdrawls fro the bank + */ + void depositWithdrawl(PartyBank whereId); +protected: + /** + * Generates the display text for the location, for a given character + */ + virtual Common::String createLocationText(Character &ch); + + /** + * Draw the visual background + */ + virtual void drawBackground(); + + /** + * Handles options for the particular location + */ + virtual Character *doOptions(Character *c); +public: + BankLocation(); + virtual ~BankLocation() {} +}; + +class BlacksmithLocation : public TownLocation { +protected: + /** + * Generates the display text for the location, for a given character + */ + virtual Common::String createLocationText(Character &ch); + + /** + * Handle any farewell + */ + virtual void farewell(); + + /** + * Handles options for the particular location + */ + virtual Character *doOptions(Character *c); +public: + BlacksmithLocation(); + virtual ~BlacksmithLocation() {} +}; + +class GuildLocation : public TownLocation { +protected: + /** + * Generates the display text for the location, for a given character + */ + virtual Common::String createLocationText(Character &ch); + + /** + * Handles options for the particular location + */ + virtual Character *doOptions(Character *c); +public: + GuildLocation(); + virtual ~GuildLocation() {} +}; + +class TavernLocation : public TownLocation { +protected: + /** + * Generates the display text for the location, for a given character + */ + virtual Common::String createLocationText(Character &ch); + + /** + * Handle any farewell + */ + virtual void farewell(); + + /** + * Handles options for the particular location + */ + virtual Character *doOptions(Character *c); +public: + TavernLocation(); + virtual ~TavernLocation() {} +}; + +class TempleLocation : public TownLocation { +protected: + /** + * Generates the display text for the location, for a given character + */ + virtual Common::String createLocationText(Character &ch); + + /** + * Handles options for the particular location + */ + virtual Character *doOptions(Character *c); +public: + TempleLocation(); + virtual ~TempleLocation() {} +}; + +class TrainingLocation : public TownLocation { +protected: + /** + * Generates the display text for the location, for a given character + */ + virtual Common::String createLocationText(Character &ch); + + /** + * Handles options for the particular location + */ + virtual Character *doOptions(Character *c); +public: + TrainingLocation(); + virtual ~TrainingLocation() {} +}; + +class ArenaLocation : public TownLocation { +public: + ArenaLocation(); + virtual ~ArenaLocation() {} +}; + +class ReaperLocation : public TownLocation { +public: + ReaperLocation(); + virtual ~ReaperLocation() {} +}; + +class GolemLocation : public TownLocation { +public: + GolemLocation(); + virtual ~GolemLocation() {} +}; + +class DwarfLocation : public TownLocation { +public: + DwarfLocation(bool isDwarf1); + virtual ~DwarfLocation() {} +}; + +class SphinxLocation : public TownLocation { +public: + SphinxLocation(); + virtual ~SphinxLocation() {} +}; + +class PyramidLocation : public TownLocation { +public: + PyramidLocation(); + virtual ~PyramidLocation() {} +}; + +class Town { +private: + TownLocation *_location; +private: + int townWait(); Character *doBankOptions(Character *c); @@ -100,35 +289,37 @@ private: Character *doTempleOptions(Character *c); Character *doTrainingOptions(Character *c); - - void depositWithdrawl(PartyBank whereId); public: - Town(XeenEngine *vm); + Town(); + /** + * Show a given location, and return any result + */ int townAction(TownAction actionId); - void drawTownAnim(bool flag); - /** * Returns true if a town location (bank, blacksmith, etc.) is currently active */ bool isActive() const; - void clearSprites(); + /** + * Draws a currently active town location's animation + */ + void drawAnim(bool flag); }; -class TownMessage : public ButtonContainer { +class TownMessage : public TownLocation { private: SpriteResource _iconSprites; - TownMessage(XeenEngine *vm) : ButtonContainer(vm) {} + TownMessage() : TownLocation(NO_ACTION) {} bool execute(int portrait, const Common::String &name, const Common::String &text, int confirm); void loadButtons(); public: - static bool show(XeenEngine *vm, int portrait, const Common::String &name, + static bool show(int portrait, const Common::String &name, const Common::String &text, int confirm); }; |