scummvm/common/system.cpp

134 lines
3.4 KiB
C++
Raw Normal View History

2011-04-16 14:08:33 +02:00
/* ScummVM - Graphic Adventure Engine
2009-05-07 19:06:31 +00:00
*
2011-04-16 14:08:33 +02:00
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
2009-05-07 19:06:31 +00:00
* 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.
* This program is distributed in the hope that it will be useful,
2009-05-07 19:06:31 +00:00
* 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.
* 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.
2009-05-07 19:06:31 +00:00
*
*/
2011-06-09 11:17:15 +02:00
#define FORBIDDEN_SYMBOL_EXCEPTION_exit
2011-04-14 12:41:26 +02:00
2009-05-07 19:06:31 +00:00
#include "common/system.h"
2011-06-09 11:17:15 +02:00
#include "common/events.h"
#include "common/fs.h"
#include "common/savefile.h"
2011-05-01 17:49:40 +02:00
#include "common/str.h"
2011-07-20 06:58:19 +02:00
#include "common/taskbar.h"
2012-01-06 22:56:21 +01:00
#include "common/updates.h"
2011-06-09 11:17:15 +02:00
#include "common/textconsole.h"
2009-05-07 19:06:31 +00:00
2011-06-09 11:17:15 +02:00
#include "backends/audiocd/default/default-audiocd.h"
#include "backends/fs/fs-factory.h"
#include "backends/timer/default/default-timer.h"
2011-04-14 12:41:26 +02:00
2009-06-18 11:52:26 +00:00
OSystem *g_system = 0;
2009-05-07 19:06:31 +00:00
OSystem::OSystem() {
2011-06-09 11:17:15 +02:00
_audiocdManager = 0;
_eventManager = 0;
_timerManager = 0;
_savefileManager = 0;
2011-07-20 06:58:19 +02:00
#if defined(USE_TASKBAR)
_taskbarManager = 0;
2012-01-06 22:56:21 +01:00
#endif
#if defined(USE_UPDATES)
_updateManager = 0;
2011-07-20 06:58:19 +02:00
#endif
2011-06-09 11:17:15 +02:00
_fsFactory = 0;
2009-05-07 19:06:31 +00:00
}
OSystem::~OSystem() {
2011-06-09 11:17:15 +02:00
delete _audiocdManager;
_audiocdManager = 0;
delete _eventManager;
_eventManager = 0;
delete _timerManager;
_timerManager = 0;
2011-07-20 06:58:19 +02:00
#if defined(USE_TASKBAR)
delete _taskbarManager;
_taskbarManager = 0;
#endif
2012-01-06 22:56:21 +01:00
#if defined(USE_UPDATES)
delete _updateManager;
_updateManager = 0;
#endif
2011-06-09 11:17:15 +02:00
delete _savefileManager;
_savefileManager = 0;
delete _fsFactory;
_fsFactory = 0;
}
void OSystem::initBackend() {
// Verify all managers has been set
if (!_audiocdManager)
error("Backend failed to instantiate audio CD manager");
if (!_eventManager)
error("Backend failed to instantiate event manager");
if (!_timerManager)
error("Backend failed to instantiate timer manager");
// TODO: We currently don't check _savefileManager, because at least
// on the Nintendo DS, it is possible that none is set. That should
// probably be treated as "saving is not possible". Or else the NDS
// port needs to be changed to always set a _savefileManager
// if (!_savefileManager)
// error("Backend failed to instantiate savefile manager");
// TODO: We currently don't check _fsFactory because not all ports
// set it.
// if (!_fsFactory)
// error("Backend failed to instantiate fs factory");
2009-05-07 19:06:31 +00:00
}
2009-06-18 11:52:26 +00:00
2011-04-14 12:41:26 +02:00
void OSystem::fatalError() {
quit();
exit(1);
}
2011-06-09 11:17:15 +02:00
FilesystemFactory *OSystem::getFilesystemFactory() {
assert(_fsFactory);
return _fsFactory;
}
Common::SeekableReadStream *OSystem::createConfigReadStream() {
Common::FSNode file(getDefaultConfigFileName());
return file.createReadStream();
}
Common::WriteStream *OSystem::createConfigWriteStream() {
#ifdef __DC__
return 0;
#else
Common::FSNode file(getDefaultConfigFileName());
return file.createWriteStream();
#endif
}
Common::String OSystem::getDefaultConfigFileName() {
return "residual.ini";
}
2011-04-14 12:41:26 +02:00
Common::String OSystem::getSystemLanguage() const {
return "en_US";
2009-06-18 11:52:26 +00:00
}