ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

system.cpp

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #define FORBIDDEN_SYMBOL_EXCEPTION_exit
00024 
00025 #include "common/system.h"
00026 #include "common/events.h"
00027 #include "common/fs.h"
00028 #include "common/savefile.h"
00029 #include "common/str.h"
00030 #include "common/taskbar.h"
00031 #include "common/updates.h"
00032 #include "common/dialogs.h"
00033 #include "common/textconsole.h"
00034 #include "common/text-to-speech.h"
00035 
00036 #include "backends/audiocd/default/default-audiocd.h"
00037 #include "backends/fs/fs-factory.h"
00038 #include "backends/timer/default/default-timer.h"
00039 
00040 OSystem *g_system = nullptr;
00041 
00042 OSystem::OSystem() {
00043     _audiocdManager = nullptr;
00044     _eventManager = nullptr;
00045     _timerManager = nullptr;
00046     _savefileManager = nullptr;
00047 #if defined(USE_TASKBAR)
00048     _taskbarManager = nullptr;
00049 #endif
00050 #if defined(USE_UPDATES)
00051     _updateManager = nullptr;
00052 #endif
00053 #if defined(USE_TTS)
00054     _textToSpeechManager = nullptr;
00055 #endif
00056 #if defined(USE_SYSDIALOGS)
00057     _dialogManager = nullptr;
00058 #endif
00059     _fsFactory = nullptr;
00060     _backendInitialized = false;
00061 }
00062 
00063 OSystem::~OSystem() {
00064     delete _audiocdManager;
00065     _audiocdManager = nullptr;
00066 
00067     delete _eventManager;
00068     _eventManager = nullptr;
00069 
00070     delete _timerManager;
00071     _timerManager = nullptr;
00072 
00073 #if defined(USE_TASKBAR)
00074     delete _taskbarManager;
00075     _taskbarManager = nullptr;
00076 #endif
00077 
00078 #if defined(USE_UPDATES)
00079     delete _updateManager;
00080     _updateManager = nullptr;
00081 #endif
00082 
00083 #if defined(USE_TTS)
00084     delete _textToSpeechManager;
00085     _textToSpeechManager = 0;
00086 #endif
00087 
00088 #if defined(USE_SYSDIALOGS)
00089     delete _dialogManager;
00090     _dialogManager = nullptr;
00091 #endif
00092 
00093     delete _savefileManager;
00094     _savefileManager = nullptr;
00095 
00096     delete _fsFactory;
00097     _fsFactory = nullptr;
00098 }
00099 
00100 void OSystem::initBackend() {
00101     // Verify all managers has been set
00102     if (!_audiocdManager)
00103         error("Backend failed to instantiate audio CD manager");
00104     if (!_eventManager)
00105         error("Backend failed to instantiate event manager");
00106     if (!getTimerManager())
00107         error("Backend failed to instantiate timer manager");
00108 
00109     // TODO: We currently don't check _savefileManager, because at least
00110     // on the Nintendo DS, it is possible that none is set. That should
00111     // probably be treated as "saving is not possible". Or else the NDS
00112     // port needs to be changed to always set a _savefileManager
00113 //  if (!_savefileManager)
00114 //      error("Backend failed to instantiate savefile manager");
00115 
00116     // TODO: We currently don't check _fsFactory because not all ports
00117     // set it.
00118 //  if (!_fsFactory)
00119 //      error("Backend failed to instantiate fs factory");
00120 
00121     _backendInitialized = true;
00122 }
00123 
00124 void OSystem::destroy() {
00125     _backendInitialized = false;
00126     Common::String::releaseMemoryPoolMutex();
00127     delete this;
00128 }
00129 
00130 bool OSystem::setGraphicsMode(const char *name) {
00131     return true; //ResidualVM not use it
00132     if (!name)
00133         return false;
00134 
00135     // Special case for the 'default' filter
00136     if (!scumm_stricmp(name, "normal") || !scumm_stricmp(name, "default")) {
00137         return setGraphicsMode(getDefaultGraphicsMode());
00138     }
00139 
00140     const GraphicsMode *gm = getSupportedGraphicsModes();
00141 
00142     while (gm->name) {
00143         if (!scumm_stricmp(gm->name, name)) {
00144             return setGraphicsMode(gm->id);
00145         }
00146         gm++;
00147     }
00148 
00149     return false;
00150 }
00151 
00152 bool OSystem::setShader(const char *name) {
00153     if (!name)
00154         return false;
00155 
00156     // Special case for the 'default' filter
00157     if (!scumm_stricmp(name, "default")) {
00158         return setShader(getDefaultShader());
00159     }
00160 
00161     const GraphicsMode *sm = getSupportedShaders();
00162 
00163     while (sm->name) {
00164         if (!scumm_stricmp(sm->name, name)) {
00165             return setShader(sm->id);
00166         }
00167         sm++;
00168     }
00169 
00170     return false;
00171 }
00172 
00173 bool OSystem::setStretchMode(const char *name) {
00174     if (!name)
00175         return false;
00176 
00177     // Special case for the 'default' filter
00178     if (!scumm_stricmp(name, "default")) {
00179         return setStretchMode(getDefaultStretchMode());
00180     }
00181 
00182     const GraphicsMode *sm = getSupportedStretchModes();
00183 
00184     while (sm->name) {
00185         if (!scumm_stricmp(sm->name, name)) {
00186             return setStretchMode(sm->id);
00187         }
00188         sm++;
00189     }
00190 
00191     return false;
00192 }
00193 
00194 void OSystem::fatalError() {
00195     quit();
00196     exit(1);
00197 }
00198 
00199 FilesystemFactory *OSystem::getFilesystemFactory() {
00200     assert(_fsFactory);
00201     return _fsFactory;
00202 }
00203 
00204 Common::SeekableReadStream *OSystem::createConfigReadStream() {
00205     Common::FSNode file(getDefaultConfigFileName());
00206     return file.createReadStream();
00207 }
00208 
00209 Common::WriteStream *OSystem::createConfigWriteStream() {
00210 #ifdef __DC__
00211     return nullptr;
00212 #else
00213     Common::FSNode file(getDefaultConfigFileName());
00214     return file.createWriteStream();
00215 #endif
00216 }
00217 
00218 Common::String OSystem::getDefaultConfigFileName() {
00219     return "residualvm.ini";
00220 }
00221 
00222 Common::String OSystem::getSystemLanguage() const {
00223     return "en_US";
00224 }
00225 
00226 bool OSystem::isConnectionLimited() {
00227     warning("OSystem::isConnectionLimited(): not limited by default");
00228     return false;
00229 }
00230 
00231 Common::TimerManager *OSystem::getTimerManager() {
00232     return _timerManager;
00233 }
00234 
00235 Common::SaveFileManager *OSystem::getSavefileManager() {
00236     return _savefileManager;
00237 }


Generated on Sat May 30 2020 05:00:43 for ResidualVM by doxygen 1.7.1
curved edge   curved edge