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 
00035 #include "backends/audiocd/default/default-audiocd.h"
00036 #include "backends/fs/fs-factory.h"
00037 #include "backends/timer/default/default-timer.h"
00038 
00039 OSystem *g_system = nullptr;
00040 
00041 OSystem::OSystem() {
00042     _audiocdManager = nullptr;
00043     _eventManager = nullptr;
00044     _timerManager = nullptr;
00045     _savefileManager = nullptr;
00046 #if defined(USE_TASKBAR)
00047     _taskbarManager = nullptr;
00048 #endif
00049 #if defined(USE_UPDATES)
00050     _updateManager = nullptr;
00051 #endif
00052 #if defined(USE_SYSDIALOGS)
00053     _dialogManager = nullptr;
00054 #endif
00055     _fsFactory = nullptr;
00056     _backendInitialized = false;
00057 }
00058 
00059 OSystem::~OSystem() {
00060     delete _audiocdManager;
00061     _audiocdManager = nullptr;
00062 
00063     delete _eventManager;
00064     _eventManager = nullptr;
00065 
00066     delete _timerManager;
00067     _timerManager = nullptr;
00068 
00069 #if defined(USE_TASKBAR)
00070     delete _taskbarManager;
00071     _taskbarManager = nullptr;
00072 #endif
00073 
00074 #if defined(USE_UPDATES)
00075     delete _updateManager;
00076     _updateManager = nullptr;
00077 #endif
00078 
00079 #if defined(USE_SYSDIALOGS)
00080     delete _dialogManager;
00081     _dialogManager = nullptr;
00082 #endif
00083 
00084     delete _savefileManager;
00085     _savefileManager = nullptr;
00086 
00087     delete _fsFactory;
00088     _fsFactory = nullptr;
00089 }
00090 
00091 void OSystem::initBackend() {
00092     // Verify all managers has been set
00093     if (!_audiocdManager)
00094         error("Backend failed to instantiate audio CD manager");
00095     if (!_eventManager)
00096         error("Backend failed to instantiate event manager");
00097     if (!getTimerManager())
00098         error("Backend failed to instantiate timer manager");
00099 
00100     // TODO: We currently don't check _savefileManager, because at least
00101     // on the Nintendo DS, it is possible that none is set. That should
00102     // probably be treated as "saving is not possible". Or else the NDS
00103     // port needs to be changed to always set a _savefileManager
00104 //  if (!_savefileManager)
00105 //      error("Backend failed to instantiate savefile manager");
00106 
00107     // TODO: We currently don't check _fsFactory because not all ports
00108     // set it.
00109 //  if (!_fsFactory)
00110 //      error("Backend failed to instantiate fs factory");
00111 
00112     _backendInitialized = true;
00113 }
00114 
00115 void OSystem::destroy() {
00116     _backendInitialized = false;
00117     Common::String::releaseMemoryPoolMutex();
00118     delete this;
00119 }
00120 
00121 bool OSystem::setGraphicsMode(const char *name) {
00122     return true; //ResidualVM not use it
00123     if (!name)
00124         return false;
00125 
00126     // Special case for the 'default' filter
00127     if (!scumm_stricmp(name, "normal") || !scumm_stricmp(name, "default")) {
00128         return setGraphicsMode(getDefaultGraphicsMode());
00129     }
00130 
00131     const GraphicsMode *gm = getSupportedGraphicsModes();
00132 
00133     while (gm->name) {
00134         if (!scumm_stricmp(gm->name, name)) {
00135             return setGraphicsMode(gm->id);
00136         }
00137         gm++;
00138     }
00139 
00140     return false;
00141 }
00142 
00143 bool OSystem::setStretchMode(const char *name) {
00144     if (!name)
00145         return false;
00146 
00147     // Special case for the 'default' filter
00148     if (!scumm_stricmp(name, "default")) {
00149         return setStretchMode(getDefaultStretchMode());
00150     }
00151 
00152     const GraphicsMode *sm = getSupportedStretchModes();
00153 
00154     while (sm->name) {
00155         if (!scumm_stricmp(sm->name, name)) {
00156             return setStretchMode(sm->id);
00157         }
00158         sm++;
00159     }
00160 
00161     return false;
00162 }
00163 
00164 void OSystem::fatalError() {
00165     quit();
00166     exit(1);
00167 }
00168 
00169 FilesystemFactory *OSystem::getFilesystemFactory() {
00170     assert(_fsFactory);
00171     return _fsFactory;
00172 }
00173 
00174 Common::SeekableReadStream *OSystem::createConfigReadStream() {
00175     Common::FSNode file(getDefaultConfigFileName());
00176     return file.createReadStream();
00177 }
00178 
00179 Common::WriteStream *OSystem::createConfigWriteStream() {
00180 #ifdef __DC__
00181     return nullptr;
00182 #else
00183     Common::FSNode file(getDefaultConfigFileName());
00184     return file.createWriteStream();
00185 #endif
00186 }
00187 
00188 Common::String OSystem::getDefaultConfigFileName() {
00189     return "residualvm.ini";
00190 }
00191 
00192 Common::String OSystem::getSystemLanguage() const {
00193     return "en_US";
00194 }
00195 
00196 bool OSystem::isConnectionLimited() {
00197     warning("OSystem::isConnectionLimited(): not limited by default");
00198     return false;
00199 }
00200 
00201 Common::TimerManager *OSystem::getTimerManager() {
00202     return _timerManager;
00203 }
00204 
00205 Common::SaveFileManager *OSystem::getSavefileManager() {
00206     return _savefileManager;
00207 }


Generated on Sat Aug 17 2019 05:00:35 for ResidualVM by doxygen 1.7.1
curved edge   curved edge