diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/xeen/dialogs_input.cpp | 6 | ||||
-rw-r--r-- | engines/xeen/dialogs_query.cpp | 6 | ||||
-rw-r--r-- | engines/xeen/dialogs_whowill.cpp | 4 | ||||
-rw-r--r-- | engines/xeen/locations.cpp (renamed from engines/xeen/town.cpp) | 73 | ||||
-rw-r--r-- | engines/xeen/locations.h (renamed from engines/xeen/town.h) | 69 | ||||
-rw-r--r-- | engines/xeen/module.mk | 2 | ||||
-rw-r--r-- | engines/xeen/scripts.cpp | 4 | ||||
-rw-r--r-- | engines/xeen/xeen.cpp | 6 | ||||
-rw-r--r-- | engines/xeen/xeen.h | 4 |
9 files changed, 90 insertions, 84 deletions
diff --git a/engines/xeen/dialogs_input.cpp b/engines/xeen/dialogs_input.cpp index 2f4a1742b5..a0573d20ef 100644 --- a/engines/xeen/dialogs_input.cpp +++ b/engines/xeen/dialogs_input.cpp @@ -225,7 +225,7 @@ int Choose123::show(XeenEngine *vm, int numOptions) { int Choose123::execute(int numOptions) { EventsManager &events = *_vm->_events; Interface &intf = *_vm->_interface; - Town &town = *_vm->_town; + LocationManager &loc = *_vm->_locations; Windows &windows = *_vm->_windows; Mode oldMode = _vm->_mode; @@ -241,8 +241,8 @@ int Choose123::execute(int numOptions) { do { events.updateGameCounter(); int delay; - if (town.isActive()) { - town.drawAnim(true); + if (loc.isActive()) { + loc.drawAnim(true); delay = 3; } else { intf.draw3d(true); diff --git a/engines/xeen/dialogs_query.cpp b/engines/xeen/dialogs_query.cpp index 7dd35a13c5..fd466938b3 100644 --- a/engines/xeen/dialogs_query.cpp +++ b/engines/xeen/dialogs_query.cpp @@ -102,7 +102,7 @@ bool YesNo::execute(bool type, bool townFlag) { Map &map = *_vm->_map; Party &party = *_vm->_party; Resources &res = *_vm->_resources; - Town &town = *_vm->_town; + LocationManager &loc = *_vm->_locations; Windows &windows = *_vm->_windows; SpriteResource confirmSprites; bool result = false; @@ -127,8 +127,8 @@ bool YesNo::execute(bool type, bool townFlag) { while (!_vm->shouldQuit()) { events.updateGameCounter(); - if (town.isActive()) { - town.drawAnim(townFlag); + if (loc.isActive()) { + loc.drawAnim(townFlag); //numFrames = 3; } else { intf.draw3d(true); diff --git a/engines/xeen/dialogs_whowill.cpp b/engines/xeen/dialogs_whowill.cpp index 36451dcea4..a2be4e3a94 100644 --- a/engines/xeen/dialogs_whowill.cpp +++ b/engines/xeen/dialogs_whowill.cpp @@ -40,7 +40,7 @@ int WhoWill::execute(int message, int action, bool type) { Map &map = *_vm->_map; Party &party = *_vm->_party; Scripts &scripts = *_vm->_scripts; - Town &town = *_vm->_town; + LocationManager &loc = *_vm->_locations; Windows &windows = *_vm->_windows; int numFrames; @@ -66,7 +66,7 @@ int WhoWill::execute(int message, int action, bool type) { events.updateGameCounter(); if (windows[11]._enabled) { - town.drawAnim(false); + loc.drawAnim(false); windows[36].frame(); numFrames = 3; } else { diff --git a/engines/xeen/town.cpp b/engines/xeen/locations.cpp index 4a635c71a3..cc2320a7d9 100644 --- a/engines/xeen/town.cpp +++ b/engines/xeen/locations.cpp @@ -20,7 +20,7 @@ * */ -#include "xeen/town.h" +#include "xeen/locations.h" #include "xeen/dialogs_input.h" #include "xeen/dialogs_items.h" #include "xeen/dialogs_query.h" @@ -29,9 +29,10 @@ #include "xeen/xeen.h" namespace Xeen { +namespace Locations { -BaseLocation::BaseLocation(TownAction action) : ButtonContainer(g_vm), - _townActionId(action), _isDarkCc(g_vm->_files->_isDarkCc), +BaseLocation::BaseLocation(LocationAction action) : ButtonContainer(g_vm), + _LocationActionId(action), _isDarkCc(g_vm->_files->_isDarkCc), _vocName("hello1.voc") { _townMaxId = (action >= SPHINX) ? 0 : Res.TOWN_MAXES[_isDarkCc][action]; if (action < NO_ACTION) { @@ -67,7 +68,7 @@ int BaseLocation::show() { // Load the needed sprite sets for the location for (uint idx = 0; idx < _townSprites.size(); ++idx) { Common::String shapesName = Common::String::format("%s%d.twn", - Res.TOWN_ACTION_SHAPES[_townActionId], idx + 1); + Res.TOWN_ACTION_SHAPES[_LocationActionId], idx + 1); _townSprites[idx].load(shapesName); } @@ -143,7 +144,7 @@ void BaseLocation::drawAnim(bool flag) { Windows &windows = *g_vm->_windows; // TODO: Figure out a clean way to split method into individual location classes - if (_townActionId == BLACKSMITH) { + if (_LocationActionId == BLACKSMITH) { if (sound.isPlaying()) { if (_isDarkCc) { _townSprites[_drawFrameIndex / 8].draw(0, _drawFrameIndex % 8, _townPos); @@ -159,12 +160,12 @@ void BaseLocation::drawAnim(bool flag) { Common::Point(34, 33)); } } - } else if (!_isDarkCc || _townActionId != TRAINING) { + } else if (!_isDarkCc || _LocationActionId != TRAINING) { if (!_townSprites[_drawFrameIndex / 8].empty()) _townSprites[_drawFrameIndex / 8].draw(0, _drawFrameIndex % 8, _townPos); } - switch (_townActionId) { + switch (_LocationActionId) { case BANK: if (sound.isPlaying() || (_isDarkCc && _animFrame)) { if (_isDarkCc) { @@ -251,10 +252,10 @@ void BaseLocation::drawAnim(bool flag) { } if (_isDarkCc) { - if (_townActionId == BLACKSMITH && (_drawFrameIndex == 4 || _drawFrameIndex == 13)) + if (_LocationActionId == BLACKSMITH && (_drawFrameIndex == 4 || _drawFrameIndex == 13)) sound.playFX(45); - if (_townActionId == TRAINING && _drawFrameIndex == 23) { + if (_LocationActionId == TRAINING && _drawFrameIndex == 23) { sound.playSound("spit1.voc"); } } else { @@ -262,13 +263,13 @@ void BaseLocation::drawAnim(bool flag) { _drawFrameIndex = 17; if (_townMaxId == 26 && _drawFrameIndex == 0) _drawFrameIndex = 20; - if (_townActionId == BLACKSMITH && (_drawFrameIndex == 3 || _drawFrameIndex == 9)) + if (_LocationActionId == BLACKSMITH && (_drawFrameIndex == 3 || _drawFrameIndex == 9)) sound.playFX(45); } windows[3].update(); - if (_townActionId == BANK) + if (_LocationActionId == BANK) _animFrame = 2; } @@ -685,8 +686,8 @@ Character *TavernLocation::doOptions(Character *c) { // Sign In idx = _isDarkCc ? (party._mazeId - 29) >> 1 : party._mazeId - 28; assert(idx >= 0); - party._mazePosition.x = Res.TAVERN_EXIT_LIST[_isDarkCc ? 1 : 0][_townActionId][idx][0]; - party._mazePosition.y = Res.TAVERN_EXIT_LIST[_isDarkCc ? 1 : 0][_townActionId][idx][1]; + party._mazePosition.x = Res.TAVERN_EXIT_LIST[_isDarkCc ? 1 : 0][_LocationActionId][idx][0]; + party._mazePosition.y = Res.TAVERN_EXIT_LIST[_isDarkCc ? 1 : 0][_LocationActionId][idx][1]; if (!_isDarkCc || party._mazeId == 29) party._mazeDirection = DIR_WEST; @@ -1107,7 +1108,7 @@ ArenaLocation::ArenaLocation() : BaseLocation(ARENA) { /*------------------------------------------------------------------------*/ -CutsceneLocation::CutsceneLocation(TownAction action) : BaseLocation(action), +CutsceneLocation::CutsceneLocation(LocationAction action) : BaseLocation(action), _animCtr(0), _mazeFlag(false) { Party &party = *g_vm->_party; _mazeId = party._mazeId; @@ -1461,52 +1462,54 @@ int PyramidLocation::show() { return 0; } +} // End of namespace Locations + /*------------------------------------------------------------------------*/ -Town::Town() : _location(nullptr) { +LocationManager::LocationManager() : _location(nullptr) { } -int Town::townAction(TownAction actionId) { +int LocationManager::doAction(LocationAction actionId) { // Create the desired location switch (actionId) { case BANK: - _location = new BankLocation(); + _location = new Locations::BankLocation(); break; case BLACKSMITH: - _location = new BlacksmithLocation(); + _location = new Locations::BlacksmithLocation(); break; case GUILD: - _location = new GuildLocation(); + _location = new Locations::GuildLocation(); break; case TAVERN: - _location = new TavernLocation(); + _location = new Locations::TavernLocation(); break; case TEMPLE: - _location = new TempleLocation(); + _location = new Locations::TempleLocation(); break; case TRAINING: - _location = new TrainingLocation(); + _location = new Locations::TrainingLocation(); break; case ARENA: - _location = new ArenaLocation(); + _location = new Locations::ArenaLocation(); break; case REAPER: - _location = new ReaperCutscene(); + _location = new Locations::ReaperCutscene(); break; case GOLEM: - _location = new GolemCutscene(); + _location = new Locations::GolemCutscene(); break; case DWARF1: - _location = new DwarfCutscene(true); + _location = new Locations::DwarfCutscene(true); break; case DWARF2: - _location = new DwarfCutscene(false); + _location = new Locations::DwarfCutscene(false); break; case SPHINX: - _location = new SphinxCutscene(); + _location = new Locations::SphinxCutscene(); break; case PYRAMID: - _location = new PyramidLocation(); + _location = new Locations::PyramidLocation(); break; default: return 0; @@ -1520,27 +1523,27 @@ int Town::townAction(TownAction actionId) { return result; } -bool Town::isActive() const { +bool LocationManager::isActive() const { return _location != nullptr; } -void Town::drawAnim(bool flag) { +void LocationManager::drawAnim(bool flag) { if (_location) _location->drawAnim(flag); } /*------------------------------------------------------------------------*/ -bool TownMessage::show(int portrait, const Common::String &name, +bool LocationMessage::show(int portrait, const Common::String &name, const Common::String &text, int confirm) { - TownMessage *dlg = new TownMessage(); + LocationMessage *dlg = new LocationMessage(); bool result = dlg->execute(portrait, name, text, confirm); delete dlg; return result; } -bool TownMessage::execute(int portrait, const Common::String &name, const Common::String &text, +bool LocationMessage::execute(int portrait, const Common::String &name, const Common::String &text, int confirm) { EventsManager &events = *g_vm->_events; Interface &intf = *g_vm->_interface; @@ -1647,7 +1650,7 @@ bool TownMessage::execute(int portrait, const Common::String &name, const Common return result == 1; } -void TownMessage::loadButtons() { +void LocationMessage::loadButtons() { _iconSprites.load("confirm.icn"); addButton(Common::Rect(235, 75, 259, 95), Common::KEYCODE_y, &_iconSprites); diff --git a/engines/xeen/town.h b/engines/xeen/locations.h index 925bac9e7a..e0f4838fd6 100644 --- a/engines/xeen/town.h +++ b/engines/xeen/locations.h @@ -20,8 +20,8 @@ * */ -#ifndef XEEN_TOWN_H -#define XEEN_TOWN_H +#ifndef XEEN_LOCATIONS_H +#define XEEN_LOCATIONS_H #include "common/scummsys.h" #include "common/str-array.h" @@ -31,18 +31,19 @@ namespace Xeen { -enum TownAction { +enum LocationAction { 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, PYRAMID = 12, DWARF2 = 13 }; class XeenEngine; -class TownMessage; + +namespace Locations { class BaseLocation : public ButtonContainer { protected: - TownAction _townActionId; + LocationAction _LocationActionId; Common::Array<SpriteResource> _townSprites; SpriteResource _icons1, _icons2; int _townMaxId; @@ -84,7 +85,7 @@ protected: */ virtual void farewell() {} public: - BaseLocation(TownAction action); + BaseLocation(LocationAction action); virtual ~BaseLocation(); /** @@ -259,7 +260,7 @@ protected: */ void setNewLocation(); public: - CutsceneLocation(TownAction action); + CutsceneLocation(LocationAction action); }; class ReaperCutscene : public CutsceneLocation { @@ -312,9 +313,26 @@ public: virtual int show(); }; -class Town { +} // End of namespace Locations + +class LocationMessage : public Locations::BaseLocation { private: - BaseLocation *_location; + SpriteResource _iconSprites; + + LocationMessage() : Locations::BaseLocation(NO_ACTION) {} + + bool execute(int portrait, const Common::String &name, + const Common::String &text, int confirm); + + void loadButtons(); +public: + static bool show(int portrait, const Common::String &name, + const Common::String &text, int confirm); +}; + +class LocationManager { +private: + Locations::BaseLocation *_location; private: int townWait(); @@ -330,39 +348,24 @@ private: Character *doTrainingOptions(Character *c); public: - Town(); + LocationManager(); /** - * Show a given location, and return any result - */ - int townAction(TownAction actionId); + * Show a given location, and return any result + */ + int doAction(LocationAction actionId); /** - * Returns true if a town location (bank, blacksmith, etc.) is currently active - */ + * Returns true if a town location (bank, blacksmith, etc.) is currently active + */ bool isActive() const; /** - * Draws a currently active town location's animation - */ + * Draws a currently active town location's animation + */ void drawAnim(bool flag); }; -class TownMessage : public BaseLocation { -private: - SpriteResource _iconSprites; - - TownMessage() : BaseLocation(NO_ACTION) {} - - bool execute(int portrait, const Common::String &name, - const Common::String &text, int confirm); - - void loadButtons(); -public: - static bool show(int portrait, const Common::String &name, - const Common::String &text, int confirm); -}; - } // End of namespace Xeen -#endif /* XEEN_SPELLS_H */ +#endif /* XEEN_LOCATIONS_H */ diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk index 7656f4cac0..2e11e1936e 100644 --- a/engines/xeen/module.mk +++ b/engines/xeen/module.mk @@ -35,6 +35,7 @@ MODULE_OBJS := \ interface.o \ interface_minimap.o \ interface_scene.o \ + locations.o \ map.o \ music.o \ party.o \ @@ -45,7 +46,6 @@ MODULE_OBJS := \ sound.o \ spells.o \ sprites.o \ - town.o \ window.o \ xeen.o \ xsurface.o diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index e630893f41..cfdd9b7d42 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -442,7 +442,7 @@ bool Scripts::cmdNPC(ParamsIterator ¶ms) { int confirm = params.readByte(); int lineNum = params.readByte(); - if (TownMessage::show(portrait, _message, map._events._text[textNum], + if (LocationMessage::show(portrait, _message, map._events._text[textNum], confirm)) { _lineNum = lineNum; return false; @@ -839,7 +839,7 @@ bool Scripts::cmdSpawn(ParamsIterator ¶ms) { } bool Scripts::cmdDoTownEvent(ParamsIterator ¶ms) { - _scriptResult = _vm->_town->townAction((TownAction)params.readByte()); + _scriptResult = _vm->_locations->doAction((LocationAction)params.readByte()); _vm->_party->_stepped = true; _refreshIcons = true; diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index ddecc9a6f7..67fb977572 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -48,6 +48,7 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) _events = nullptr; _files = nullptr; _interface = nullptr; + _locations = nullptr; _map = nullptr; _party = nullptr; _resources = nullptr; @@ -56,7 +57,6 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) _scripts = nullptr; _sound = nullptr; _spells = nullptr; - _town = nullptr; _windows = nullptr; _eventData = nullptr; _noDirectionSense = false; @@ -73,6 +73,7 @@ XeenEngine::~XeenEngine() { delete _debugger; delete _events; delete _interface; + delete _locations; delete _map; delete _party; delete _saves; @@ -80,7 +81,6 @@ XeenEngine::~XeenEngine() { delete _scripts; delete _sound; delete _spells; - delete _town; delete _windows; delete _eventData; delete _resources; @@ -96,6 +96,7 @@ void XeenEngine::initialize() { _debugger = new Debugger(this); _events = new EventsManager(this); _interface = new Interface(this); + _locations = new LocationManager(); _map = new Map(this); _party = new Party(this); _saves = new SavesManager(this, *_party); @@ -103,7 +104,6 @@ void XeenEngine::initialize() { _scripts = new Scripts(this); _sound = new Sound(this, _mixer); _spells = new Spells(this); - _town = new Town(); _windows = new Windows(); File f("029.obj"); diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index cc187c9527..022ad6673a 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -37,6 +37,7 @@ #include "xeen/events.h" #include "xeen/files.h" #include "xeen/interface.h" +#include "xeen/locations.h" #include "xeen/map.h" #include "xeen/party.h" #include "xeen/resources.h" @@ -45,7 +46,6 @@ #include "xeen/scripts.h" #include "xeen/sound.h" #include "xeen/spells.h" -#include "xeen/town.h" #include "xeen/window.h" /** @@ -144,6 +144,7 @@ public: EventsManager *_events; FileManager *_files; Interface *_interface; + LocationManager *_locations; Map *_map; Party *_party; Resources *_resources; @@ -152,7 +153,6 @@ public: Scripts *_scripts; Sound *_sound; Spells *_spells; - Town *_town; Windows *_windows; Mode _mode; GameEvent _gameEvent; |