2009-12-29 23:18:24 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 01:34:22 +00:00
|
|
|
*
|
2009-12-29 23:18:24 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 01:34:22 +00:00
|
|
|
*
|
2009-12-29 23:18:24 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/error.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/textconsole.h"
|
2016-10-02 19:26:26 +00:00
|
|
|
#include "common/translation.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
#include "mohawk/mohawk.h"
|
2010-11-25 11:18:20 +00:00
|
|
|
#include "mohawk/cursors.h"
|
2009-12-30 23:02:14 +00:00
|
|
|
#include "mohawk/dialogs.h"
|
|
|
|
#include "mohawk/sound.h"
|
2010-05-23 18:33:55 +00:00
|
|
|
#include "mohawk/video.h"
|
2009-12-30 23:02:14 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
namespace Mohawk {
|
|
|
|
|
|
|
|
MohawkEngine::MohawkEngine(OSystem *syst, const MohawkGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) {
|
2011-03-19 14:03:39 +00:00
|
|
|
// Setup mixer
|
|
|
|
syncSoundSettings();
|
2010-11-25 04:49:11 +00:00
|
|
|
|
2018-03-31 10:52:08 +00:00
|
|
|
_pauseDialog = nullptr;
|
|
|
|
_cursor = nullptr;
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MohawkEngine::~MohawkEngine() {
|
|
|
|
delete _pauseDialog;
|
2010-11-25 04:49:11 +00:00
|
|
|
delete _cursor;
|
2020-03-24 18:13:10 +00:00
|
|
|
closeAllArchives();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error MohawkEngine::run() {
|
2016-10-02 18:57:25 +00:00
|
|
|
_pauseDialog = new PauseDialog(this, _("The game is paused. Press any key to continue."));
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine::pauseGame() {
|
|
|
|
runDialog(*_pauseDialog);
|
|
|
|
}
|
|
|
|
|
2010-11-20 23:53:14 +00:00
|
|
|
Common::SeekableReadStream *MohawkEngine::getResource(uint32 tag, uint16 id) {
|
2009-12-29 23:18:24 +00:00
|
|
|
for (uint32 i = 0; i < _mhk.size(); i++)
|
|
|
|
if (_mhk[i]->hasResource(tag, id))
|
2010-11-20 23:53:14 +00:00
|
|
|
return _mhk[i]->getResource(tag, id);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-20 23:53:14 +00:00
|
|
|
error("Could not find a '%s' resource with ID %04x", tag2str(tag), id);
|
|
|
|
}
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
bool MohawkEngine::hasResource(uint32 tag, uint16 id) {
|
|
|
|
for (uint32 i = 0; i < _mhk.size(); i++)
|
|
|
|
if (_mhk[i]->hasResource(tag, id))
|
|
|
|
return true;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-11-20 23:53:14 +00:00
|
|
|
bool MohawkEngine::hasResource(uint32 tag, const Common::String &resName) {
|
|
|
|
for (uint32 i = 0; i < _mhk.size(); i++)
|
|
|
|
if (_mhk[i]->hasResource(tag, resName))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-31 00:37:40 +00:00
|
|
|
uint32 MohawkEngine::getResourceOffset(uint32 tag, uint16 id) {
|
|
|
|
for (uint32 i = 0; i < _mhk.size(); i++)
|
|
|
|
if (_mhk[i]->hasResource(tag, id))
|
|
|
|
return _mhk[i]->getOffset(tag, id);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-11-20 23:53:14 +00:00
|
|
|
error("Could not find a '%s' resource with ID %04x", tag2str(tag), id);
|
2009-12-31 00:37:40 +00:00
|
|
|
}
|
|
|
|
|
2010-11-22 17:50:30 +00:00
|
|
|
uint16 MohawkEngine::findResourceID(uint32 tag, const Common::String &resName) {
|
|
|
|
for (uint32 i = 0; i < _mhk.size(); i++)
|
|
|
|
if (_mhk[i]->hasResource(tag, resName))
|
|
|
|
return _mhk[i]->findResourceID(tag, resName);
|
|
|
|
|
|
|
|
error("Could not find a '%s' resource matching name '%s'", tag2str(tag), resName.c_str());
|
|
|
|
}
|
|
|
|
|
2010-11-29 20:49:42 +00:00
|
|
|
Common::String MohawkEngine::getResourceName(uint32 tag, uint16 id) {
|
|
|
|
for (uint32 i = 0; i < _mhk.size(); i++)
|
|
|
|
if (_mhk[i]->hasResource(tag, id)) {
|
|
|
|
return _mhk[i]->getName(tag, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
error("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id);
|
|
|
|
}
|
|
|
|
|
2020-03-24 18:13:10 +00:00
|
|
|
void MohawkEngine::closeAllArchives() {
|
|
|
|
for (uint32 i = 0; i < _mhk.size(); i++)
|
|
|
|
delete _mhk[i];
|
|
|
|
|
|
|
|
_mhk.clear();
|
|
|
|
}
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
} // End of namespace Mohawk
|