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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "common/scummsys.h"
24 #include "common/error.h"
25 #include "common/system.h"
26 #include "common/textconsole.h"
27 #include "common/translation.h"
28 
29 #include "mohawk/mohawk.h"
30 #include "mohawk/cursors.h"
31 #include "mohawk/dialogs.h"
32 #include "mohawk/sound.h"
33 #include "mohawk/video.h"
34 
35 namespace Mohawk {
36 
MohawkEngine(OSystem * syst,const MohawkGameDescription * gamedesc)37 MohawkEngine::MohawkEngine(OSystem *syst, const MohawkGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) {
38 	// Setup mixer
39 	syncSoundSettings();
40 
41 	_pauseDialog = nullptr;
42 	_cursor = nullptr;
43 }
44 
~MohawkEngine()45 MohawkEngine::~MohawkEngine() {
46 	delete _pauseDialog;
47 	delete _cursor;
48 	closeAllArchives();
49 }
50 
run()51 Common::Error MohawkEngine::run() {
52 	_pauseDialog = new PauseDialog(this, _("The game is paused. Press any key to continue."));
53 
54 	return Common::kNoError;
55 }
56 
pauseGame()57 void MohawkEngine::pauseGame() {
58 	runDialog(*_pauseDialog);
59 }
60 
getResource(uint32 tag,uint16 id)61 Common::SeekableReadStream *MohawkEngine::getResource(uint32 tag, uint16 id) {
62 	for (uint32 i = 0; i < _mhk.size(); i++)
63 		if (_mhk[i]->hasResource(tag, id))
64 			return _mhk[i]->getResource(tag, id);
65 
66 	error("Could not find a '%s' resource with ID %04x", tag2str(tag), id);
67 }
68 
hasResource(uint32 tag,uint16 id)69 bool MohawkEngine::hasResource(uint32 tag, uint16 id) {
70 	for (uint32 i = 0; i < _mhk.size(); i++)
71 		if (_mhk[i]->hasResource(tag, id))
72 			return true;
73 
74 	return false;
75 }
76 
hasResource(uint32 tag,const Common::String & resName)77 bool MohawkEngine::hasResource(uint32 tag, const Common::String &resName) {
78 	for (uint32 i = 0; i < _mhk.size(); i++)
79 		if (_mhk[i]->hasResource(tag, resName))
80 			return true;
81 
82 	return false;
83 }
84 
getResourceOffset(uint32 tag,uint16 id)85 uint32 MohawkEngine::getResourceOffset(uint32 tag, uint16 id) {
86 	for (uint32 i = 0; i < _mhk.size(); i++)
87 		if (_mhk[i]->hasResource(tag, id))
88 			return _mhk[i]->getOffset(tag, id);
89 
90 	error("Could not find a '%s' resource with ID %04x", tag2str(tag), id);
91 }
92 
findResourceID(uint32 tag,const Common::String & resName)93 uint16 MohawkEngine::findResourceID(uint32 tag, const Common::String &resName) {
94 	for (uint32 i = 0; i < _mhk.size(); i++)
95 		if (_mhk[i]->hasResource(tag, resName))
96 			return _mhk[i]->findResourceID(tag, resName);
97 
98 	error("Could not find a '%s' resource matching name '%s'", tag2str(tag), resName.c_str());
99 }
100 
getResourceName(uint32 tag,uint16 id)101 Common::String MohawkEngine::getResourceName(uint32 tag, uint16 id) {
102 	for (uint32 i = 0; i < _mhk.size(); i++)
103 		if (_mhk[i]->hasResource(tag, id)) {
104 			return _mhk[i]->getName(tag, id);
105 		}
106 
107 	error("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id);
108 }
109 
closeAllArchives()110 void MohawkEngine::closeAllArchives() {
111 	for (uint32 i = 0; i < _mhk.size(); i++)
112 		delete _mhk[i];
113 
114 	_mhk.clear();
115 }
116 
117 } // End of namespace Mohawk
118