aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-09 21:03:21 -0400
committerPaul Gilbert2016-07-10 16:39:01 -0400
commit0820c3ffaee211270ab75a14cd1d42047354aa34 (patch)
tree3c97672d3fb1f1f7b534e6013d53cbcf64f6bcb8 /engines
parentb99fa6ba8c7f4a5407ff59812e5e6023c8a3301c (diff)
downloadscummvm-rg350-0820c3ffaee211270ab75a14cd1d42047354aa34.tar.gz
scummvm-rg350-0820c3ffaee211270ab75a14cd1d42047354aa34.tar.bz2
scummvm-rg350-0820c3ffaee211270ab75a14cd1d42047354aa34.zip
TITANIC: Refactor CTitleEngine to use CFilesManager for PE resources
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/core/game_object.cpp6
-rw-r--r--engines/titanic/core/resource_key.cpp2
-rw-r--r--engines/titanic/game_manager.cpp2
-rw-r--r--engines/titanic/input_handler.cpp2
-rw-r--r--engines/titanic/main_game_window.cpp2
-rw-r--r--engines/titanic/support/files_manager.cpp16
-rw-r--r--engines/titanic/support/files_manager.h2
-rw-r--r--engines/titanic/support/font.cpp2
-rw-r--r--engines/titanic/support/mouse_cursor.cpp2
-rw-r--r--engines/titanic/titanic.cpp3
-rw-r--r--engines/titanic/titanic.h2
-rw-r--r--engines/titanic/true_talk/title_engine.cpp4
-rw-r--r--engines/titanic/true_talk/title_engine.h1
13 files changed, 21 insertions, 25 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index b27b461b48..5a214871c6 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -240,7 +240,7 @@ void CGameObject::loadResource(const CString &name) {
}
void CGameObject::loadMovie(const CString &name, bool pendingFlag) {
- g_vm->_filesManager.preload(name);
+ g_vm->_filesManager->preload(name);
// Create the surface if it doesn't already exist
if (!_surface) {
@@ -273,7 +273,7 @@ void CGameObject::loadImage(const CString &name, bool pendingFlag) {
_surface = nullptr;
}
- g_vm->_filesManager.preload(name);
+ g_vm->_filesManager->preload(name);
if (!name.empty()) {
_surface = new OSVideoSurface(screenManager, CResourceKey(name), pendingFlag);
@@ -464,7 +464,7 @@ void CGameObject::sound8(bool flag) const {
void CGameObject::loadSound(const CString &name) {
CGameManager *gameManager = getGameManager();
if (gameManager) {
- g_vm->_filesManager.preload(name);
+ g_vm->_filesManager->preload(name);
if (!name.empty())
gameManager->_sound.loadSound(name);
}
diff --git a/engines/titanic/core/resource_key.cpp b/engines/titanic/core/resource_key.cpp
index 537dd432f0..a6a06153de 100644
--- a/engines/titanic/core/resource_key.cpp
+++ b/engines/titanic/core/resource_key.cpp
@@ -75,7 +75,7 @@ CString CResourceKey::exists() const {
}
bool CResourceKey::scanForFile() const {
- return g_vm->_filesManager.scanForFile(_value);
+ return g_vm->_filesManager->scanForFile(_value);
}
FileType CResourceKey::fileTypeSuffix() const {
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp
index fd2f553b8e..d0400a4b21 100644
--- a/engines/titanic/game_manager.cpp
+++ b/engines/titanic/game_manager.cpp
@@ -41,7 +41,7 @@ CGameManager::CGameManager(CProjectItem *project, CGameView *gameView):
_videoSurface1 = nullptr;
_videoSurface2 = CScreenManager::_screenManagerPtr->createSurface(600, 340);
_project->setGameManager(this);
- g_vm->_filesManager.setGameManager(this);
+ g_vm->_filesManager->setGameManager(this);
}
void CGameManager::load(SimpleFile *file) {
diff --git a/engines/titanic/input_handler.cpp b/engines/titanic/input_handler.cpp
index 3d3541b1dd..289e707bb0 100644
--- a/engines/titanic/input_handler.cpp
+++ b/engines/titanic/input_handler.cpp
@@ -53,7 +53,7 @@ void CInputHandler::handleMessage(CMessage &msg, bool respectLock) {
if (_gameManager->_gameState._mode == GSMODE_SELECTED) {
processMessage(&msg);
} else if (!msg.isMouseMsg()) {
- g_vm->_filesManager.loadDrive();
+ g_vm->_filesManager->loadDrive();
}
}
}
diff --git a/engines/titanic/main_game_window.cpp b/engines/titanic/main_game_window.cpp
index a524529492..73ce375881 100644
--- a/engines/titanic/main_game_window.cpp
+++ b/engines/titanic/main_game_window.cpp
@@ -134,7 +134,7 @@ void CMainGameWindow::draw() {
break;
case GSMODE_5:
- g_vm->_filesManager.debug(scrManager);
+ g_vm->_filesManager->debug(scrManager);
break;
default:
diff --git a/engines/titanic/support/files_manager.cpp b/engines/titanic/support/files_manager.cpp
index 8e70387a5f..eb2f95e92e 100644
--- a/engines/titanic/support/files_manager.cpp
+++ b/engines/titanic/support/files_manager.cpp
@@ -26,13 +26,12 @@
namespace Titanic {
-CFilesManager::CFilesManager() : _gameManager(nullptr),
- _assetsPath("Assets"), _exeResources(nullptr), _field0(0),
- _drive(-1), _field18(0), _field1C(0), _field3C(0) {
+CFilesManager::CFilesManager() : _gameManager(nullptr), _assetsPath("Assets"),
+ _field0(0), _drive(-1), _field18(0), _field1C(0), _field3C(0) {
+ _exeResources.loadFromEXE("st.exe");
}
CFilesManager::~CFilesManager() {
- delete _exeResources;
}
bool CFilesManager::fileExists(const CString &name) {
@@ -94,13 +93,8 @@ void CFilesManager::preload(const CString &name) {
}
Common::SeekableReadStream *CFilesManager::getResource(
- Common::WinResourceID area, Common::WinResourceID name) {
- if (!_exeResources) {
- _exeResources = new Common::PEResources();
- _exeResources->loadFromEXE("st.exe");
- }
-
- return _exeResources->getResource(area, name);
+ Common::WinResourceID area, Common::WinResourceID name) {
+ return _exeResources.getResource(area, name);
}
} // End of namespace Titanic
diff --git a/engines/titanic/support/files_manager.h b/engines/titanic/support/files_manager.h
index 185670c764..6be6a13166 100644
--- a/engines/titanic/support/files_manager.h
+++ b/engines/titanic/support/files_manager.h
@@ -37,7 +37,7 @@ class CFilesManagerList : public List<ListItem> {
class CFilesManager {
private:
CGameManager *_gameManager;
- Common::PEResources *_exeResources;
+ Common::PEResources _exeResources;
CFilesManagerList _list;
CString _string1;
CString _string2;
diff --git a/engines/titanic/support/font.cpp b/engines/titanic/support/font.cpp
index cc93bbb3c2..916f02097b 100644
--- a/engines/titanic/support/font.cpp
+++ b/engines/titanic/support/font.cpp
@@ -41,7 +41,7 @@ STFont::~STFont() {
void STFont::load(int fontNumber) {
assert(!_dataPtr);
- Common::SeekableReadStream *stream = g_vm->_filesManager.getResource(
+ Common::SeekableReadStream *stream = g_vm->_filesManager->getResource(
Common::WinResourceID("STFONT"), fontNumber);
if (!stream)
error("Could not locate the specified font");
diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp
index 6ddfecfd2a..6ebf4f2164 100644
--- a/engines/titanic/support/mouse_cursor.cpp
+++ b/engines/titanic/support/mouse_cursor.cpp
@@ -63,7 +63,7 @@ CMouseCursor::~CMouseCursor() {
void CMouseCursor::loadCursorImages() {
const CString name("ycursors.avi");
- g_vm->_filesManager.fn4(name);
+ g_vm->_filesManager->fn4(name);
// WORKAROUND: We need to manipulate ycursors.avi file so it can be read
// by the ScummVM AVIDecoder, by removing the redundant second video track
diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp
index e70a208552..c2c1f18f54 100644
--- a/engines/titanic/titanic.cpp
+++ b/engines/titanic/titanic.cpp
@@ -50,6 +50,7 @@ TitanicEngine::TitanicEngine(OSystem *syst, const TitanicGameDescription *gameDe
g_vm = this;
_debugger = nullptr;
_events = nullptr;
+ _filesManager = nullptr;
_window = nullptr;
_screen = nullptr;
_screenManager = nullptr;
@@ -63,6 +64,7 @@ TitanicEngine::~TitanicEngine() {
delete _screen;
delete _window;
delete _screenManager;
+ delete _filesManager;
CSaveableObject::freeClassList();
_activeMovies.clear();
}
@@ -95,6 +97,7 @@ void TitanicEngine::initialize() {
_debugger = new Debugger(this);
_events = new Events(this);
+ _filesManager = new CFilesManager();
_screen = new Graphics::Screen(0, 0);
_screenManager = new OSScreenManager(this);
_window = new CMainGameWindow(this);
diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h
index 653ace534b..71e8fcdf2c 100644
--- a/engines/titanic/titanic.h
+++ b/engines/titanic/titanic.h
@@ -111,9 +111,9 @@ protected:
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
public:
- CFilesManager _filesManager;
Debugger *_debugger;
Events *_events;
+ CFilesManager *_filesManager;
Graphics::Screen *_screen;
OSScreenManager *_screenManager;
CMainGameWindow *_window;
diff --git a/engines/titanic/true_talk/title_engine.cpp b/engines/titanic/true_talk/title_engine.cpp
index d4462c5bcd..511ee0a8f7 100644
--- a/engines/titanic/true_talk/title_engine.cpp
+++ b/engines/titanic/true_talk/title_engine.cpp
@@ -21,6 +21,7 @@
*/
#include "titanic/true_talk/title_engine.h"
+#include "titanic/titanic.h"
namespace Titanic {
@@ -40,7 +41,6 @@ void CTitleEngine::setup(int val1, int val2) {
/*------------------------------------------------------------------------*/
STtitleEngine::STtitleEngine(): CTitleEngine(), _field58(0) {
- _resources.loadFromEXE("ST.exe");
}
STtitleEngine::~STtitleEngine() {
@@ -66,7 +66,7 @@ void STtitleEngine::dump(int val1, int val2) {
}
SimpleFile *STtitleEngine::open(const CString &name) {
- Common::SeekableReadStream *stream = _resources.getResource(
+ Common::SeekableReadStream *stream = g_vm->_filesManager->getResource(
Common::WinResourceID("TEXT"), name);
assert(stream);
diff --git a/engines/titanic/true_talk/title_engine.h b/engines/titanic/true_talk/title_engine.h
index fda35ac7bf..87491bf7b6 100644
--- a/engines/titanic/true_talk/title_engine.h
+++ b/engines/titanic/true_talk/title_engine.h
@@ -68,7 +68,6 @@ public:
class STtitleEngine : public CTitleEngine {
private:
- Common::PEResources _resources;
Common::SeekableReadStream *_stream;
int _field58;
public: