From 59739a7a0e3e4826ba7b27d5270a8d7a26b787ef Mon Sep 17 00:00:00 2001 From: Chris Warren-Smith Date: Sun, 7 Aug 2011 21:33:32 +1000 Subject: BADA: Initial BADA port implementation --- backends/platform/bada/system.cpp | 500 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 500 insertions(+) create mode 100755 backends/platform/bada/system.cpp (limited to 'backends/platform/bada/system.cpp') diff --git a/backends/platform/bada/system.cpp b/backends/platform/bada/system.cpp new file mode 100755 index 0000000000..9b137d059a --- /dev/null +++ b/backends/platform/bada/system.cpp @@ -0,0 +1,500 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * 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, + * 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. + * + */ + +#include + +#include "common/config-manager.h" +#include "common/file.h" +#include "engines/engine.h" +#include "graphics/font.h" +#include "graphics/fontman.h" +#include "graphics/fonts/bdf.h" +#include "backends/saves/default/default-saves.h" +#include "backends/events/default/default-events.h" +#include "backends/audiocd/default/default-audiocd.h" +#include "backends/mutex/mutex.h" +#include "backends/fs/fs-factory.h" + +#include "backends/platform/bada/form.h" +#include "backends/platform/bada/system.h" +#include "backends/platform/bada/graphics.h" +#include "backends/platform/bada/audio.h" +#include "backends/platform/bada/timer.h" + +using namespace Osp::Base; +using namespace Osp::Base::Runtime; +using namespace Osp::Ui::Controls; + +#define DEFAULT_CONFIG_FILE "/Home/scummvm.ini" +#define MUTEX_BUFFER_SIZE 5 + +// +// BadaFilesystemFactory +// +class BadaFilesystemFactory : public FilesystemFactory { + AbstractFSNode *makeRootFileNode() const; + AbstractFSNode *makeCurrentDirectoryFileNode() const; + AbstractFSNode *makeFileNodePath(const Common::String &path) const; +}; + +AbstractFSNode *BadaFilesystemFactory::makeRootFileNode() const { + return new BadaFilesystemNode("/"); +} + +AbstractFSNode *BadaFilesystemFactory::makeCurrentDirectoryFileNode() const { + return new BadaFilesystemNode("/Home"); +} + +AbstractFSNode *BadaFilesystemFactory::makeFileNodePath(const Common::String &path) const { + AppAssert(!path.empty()); + return new BadaFilesystemNode(path); +} + +// +// BadaSaveFileManager +// +struct BadaSaveFileManager : public DefaultSaveFileManager { + bool removeSavefile(const Common::String &filename); +}; + +bool BadaSaveFileManager::removeSavefile(const Common::String &filename) { + Common::String savePathName = getSavePath(); + + checkPath(Common::FSNode(savePathName)); + if (getError().getCode() != Common::kNoError) { + return false; + } + + // recreate FSNode since checkPath may have changed/created the directory + Common::FSNode savePath(savePathName); + Common::FSNode file = savePath.getChild(filename); + + String unicodeFileName; + StringUtil::Utf8ToString(file.getPath().c_str(), unicodeFileName); + + switch (Osp::Io::File::Remove(unicodeFileName)) { + case E_SUCCESS: + return true; + + case E_ILLEGAL_ACCESS: + setError(Common::kWritePermissionDenied, "Search or write permission denied: " + + file.getName()); + break; + + default: + setError(Common::kPathDoesNotExist, "removeSavefile: '" + file.getName() + + "' does not exist or path is invalid"); + break; + } + + return false; +} + +// +// BadaMutexManager +// +struct BadaMutexManager : public MutexManager { + BadaMutexManager(); + ~BadaMutexManager(); + OSystem::MutexRef createMutex(); + void lockMutex(OSystem::MutexRef mutex); + void unlockMutex(OSystem::MutexRef mutex); + void deleteMutex(OSystem::MutexRef mutex); +private: + Mutex *buffer[MUTEX_BUFFER_SIZE]; +}; + +BadaMutexManager::BadaMutexManager() { + for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { + buffer[i] = null; + } +} + +BadaMutexManager::~BadaMutexManager() { + for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { + if (buffer[i] != null) { + delete buffer[i]; + } + } +} + +OSystem::MutexRef BadaMutexManager::createMutex() { + Mutex *mutex = new Mutex(); + mutex->Create(); + + for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { + if (buffer[i] == null) { + buffer[i] = mutex; + break; + } + } + + return (OSystem::MutexRef) mutex; +} + +void BadaMutexManager::lockMutex(OSystem::MutexRef mutex) { + Mutex *m = (Mutex*)mutex; + m->Acquire(); +} + +void BadaMutexManager::unlockMutex(OSystem::MutexRef mutex) { + Mutex *m = (Mutex*)mutex; + m->Release(); +} + +void BadaMutexManager::deleteMutex(OSystem::MutexRef mutex) { + Mutex *m = (Mutex*)mutex; + + for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { + if (buffer[i] == m) { + buffer[i] = null; + } + } + + delete m; +} + +// +// BadaEventManager +// +struct BadaEventManager : public DefaultEventManager { + BadaEventManager(Common::EventSource *boss); + void init(); + int shouldQuit() const; +}; + +BadaEventManager::BadaEventManager(Common::EventSource *boss) : + DefaultEventManager(boss) { +} + +void BadaEventManager::init() { + DefaultEventManager::init(); + + // theme and vkbd should have now loaded - clear the splash screen + BadaSystem *system = (BadaSystem*)g_system; + BadaGraphicsManager *graphics = system->getGraphics(); + if (graphics) { + graphics->setReady(); + graphics->updateScreen(); + } +} + +int BadaEventManager::shouldQuit() const { + BadaSystem *system = (BadaSystem*)g_system; + return system->isClosing(); +} + +// +// BadaSystem +// +BadaSystem::BadaSystem(BadaAppForm *appForm) : + _appForm(appForm), + _audioThread(0), + _epoch(0) { +} + +result BadaSystem::Construct(void) { + logEntered(); + + _fsFactory = new BadaFilesystemFactory(); + if (!_fsFactory) { + return E_OUT_OF_MEMORY; + } + + return E_SUCCESS; +} + +BadaSystem::~BadaSystem() { + logEntered(); +} + +result BadaSystem::initModules() { + logEntered(); + + _mutexManager = new BadaMutexManager(); + if (!_mutexManager) { + return E_OUT_OF_MEMORY; + } + + _timerManager = new BadaTimerManager(); + if (!_timerManager) { + return E_OUT_OF_MEMORY; + } + + _savefileManager = new BadaSaveFileManager(); + if (!_savefileManager) { + return E_OUT_OF_MEMORY; + } + + _graphicsManager = (GraphicsManager*) new BadaGraphicsManager(_appForm); + if (!_graphicsManager) { + return E_OUT_OF_MEMORY; + } + + // depends on _graphicsManager when ENABLE_VKEYBD enabled + _eventManager = new BadaEventManager(this); + if (!_eventManager) { + return E_OUT_OF_MEMORY; + } + + _audioThread = new AudioThread(); + if (!_audioThread) { + return E_OUT_OF_MEMORY; + } + + _mixer = _audioThread->Construct(this); + if (!_mixer) { + return E_OUT_OF_MEMORY; + } + + _audiocdManager = (AudioCDManager*) new DefaultAudioCDManager(); + if (!_audiocdManager) { + return E_OUT_OF_MEMORY; + } + + if (IsFailed(_audioThread->Start())) { + AppLog("Failed to start audio thread"); + return E_OUT_OF_MEMORY; + } + + logLeaving(); + return E_SUCCESS; +} + +void BadaSystem::initBackend() { + logEntered(); + + // allow translations to be found + ConfMan.set("themepath", "/Res"); + + // use the mobile device theme + ConfMan.set("gui_theme", "/Res/scummmobile"); + + // allow virtual keypad pack to be found + ConfMan.set("vkeybdpath", "/Res/vkeybd_default"); + + // set default save path to writable area + if (!ConfMan.hasKey("savepath")) { + ConfMan.set("savepath", "/Home/Share"); + } + + // default to no auto-save + if (!ConfMan.hasKey("autosave_period")) { + ConfMan.setInt("autosave_period", 0); + } + + ConfMan.registerDefault("fullscreen", true); + ConfMan.registerDefault("aspect_ratio", true); + ConfMan.setBool("confirm_exit", false); + + Osp::System::SystemTime::GetTicks(_epoch); + + if (E_SUCCESS != initModules()) { + AppLog("initModules failed"); + } else { + OSystem::initBackend(); + } + + // replace kBigGUIFont using the large font from the scummmobile theme + Common::File fontFile; + Common::String fileName = "/Res/scummmobile/helvB14-ASCII.fcc"; + BadaFilesystemNode file(fileName); + if (file.exists()) { + Common::SeekableReadStream *stream = file.createReadStream(); + if (stream) { + if (fontFile.open(stream, fileName)) { + Graphics::BdfFont *font = Graphics::BdfFont::loadFromCache(fontFile); + if (font) { + // use this font for the vkbd and on-screen messages + FontMan.assignFontToUsage(Graphics::FontManager::kBigGUIFont, font); + } + } + } + } + + logLeaving(); +} + +void BadaSystem::destroyBackend() { + closeAudio(); + + delete _graphicsManager; + _graphicsManager = 0; + + delete _savefileManager; + _savefileManager = 0; + + delete _fsFactory; + _fsFactory = 0; + + delete _mixer; + _mixer = 0; + + delete _audiocdManager; + _audiocdManager = 0; + + delete _timerManager; + _timerManager = 0; + + delete _eventManager; + _eventManager = 0; + + delete _mutexManager; + _mutexManager = 0; + + delete g_engine; +} + +bool BadaSystem::pollEvent(Common::Event &event) { + return _appForm->pollEvent(event); +} + +uint32 BadaSystem::getMillis() { + long long result, ticks = 0; + Osp::System::SystemTime::GetTicks(ticks); + result = ticks - _epoch; + return result; +} + +void BadaSystem::delayMillis(uint msecs) { + if (!_appForm->isClosing()) { + Thread::Sleep(msecs); + } +} + +void BadaSystem::updateScreen() { + if (_graphicsManager != null) { + _graphicsManager->updateScreen(); + } +} + +void BadaSystem::getTimeAndDate(TimeDate &td) const { + DateTime currentTime; + + if (E_SUCCESS == Osp::System::SystemTime::GetCurrentTime(currentTime)) { + td.tm_sec = currentTime.GetSecond(); + td.tm_min = currentTime.GetMinute(); + td.tm_hour = currentTime.GetHour(); + td.tm_mday = currentTime.GetDay(); + td.tm_mon = currentTime.GetMonth(); + td.tm_year = currentTime.GetYear(); + } +} + +void BadaSystem::fatalError() { + systemError("ScummVM: Fatal internal error."); +} + +void BadaSystem::exitSystem() { + if (_appForm) { + closeAudio(); + closeGraphics(); + _appForm->exitSystem(); + } +} + +void BadaSystem::logMessage(LogMessageType::Type /*type*/, const char *message) { + AppLog(message); +} + +Common::SeekableReadStream *BadaSystem::createConfigReadStream() { + BadaFilesystemNode file(DEFAULT_CONFIG_FILE); + return file.createReadStream(); +} + +Common::WriteStream *BadaSystem::createConfigWriteStream() { + BadaFilesystemNode file(DEFAULT_CONFIG_FILE); + return file.createWriteStream(); +} + +void BadaSystem::closeAudio() { + if (_audioThread) { + _audioThread->Stop(); + _audioThread->Join(); + delete _audioThread; + _audioThread = 0; + } +} + +void BadaSystem::closeGraphics() { + if (_graphicsManager) { + delete _graphicsManager; + _graphicsManager = 0; + } +} + +void BadaSystem::setMute(bool on) { + if (_audioThread) { + _audioThread->setMute(on); + } +} + +int BadaSystem::setVolume(bool up, bool minMax) { + int level = -1; + if (_audioThread) { + level = _audioThread->setVolume(up, minMax); + } + return level; +} + +// +// create the scummVM system +// +BadaAppForm *systemStart(Osp::App::Application *app) { + logEntered(); + + BadaAppForm *appForm = new BadaAppForm(); + if (!appForm) { + AppLog("Failed to create appForm"); + return null; + } + + if (E_SUCCESS != appForm->Construct() || + E_SUCCESS != app->GetAppFrame()->GetFrame()->AddControl(*appForm)) { + delete appForm; + AppLog("Failed to construct appForm"); + return null; + } + + return appForm; +} + +// +// display a fatal error notification +// +void systemError(const char *message) { + AppLog("Fatal system error: %s", message); + + ArrayList *args = new ArrayList(); + args->Construct(); + args->Add(*(new String(message))); + Application::GetInstance()->SendUserEvent(USER_MESSAGE_EXIT_ERR, args); + + if (g_system) { + BadaSystem *system = (BadaSystem*)g_system; + system->exitSystem(); + } +} + +// +// end of system.cpp +// -- cgit v1.2.3 From fecce484ce39ddd1d09e8d7a45f6ae22e63f30c0 Mon Sep 17 00:00:00 2001 From: Chris Warren-Smith Date: Mon, 8 Aug 2011 20:20:43 +1000 Subject: BADA: Renamed the customised vkeybd layout to vkeybd_bada --- backends/platform/bada/system.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'backends/platform/bada/system.cpp') diff --git a/backends/platform/bada/system.cpp b/backends/platform/bada/system.cpp index 9b137d059a..f3f3083e5a 100755 --- a/backends/platform/bada/system.cpp +++ b/backends/platform/bada/system.cpp @@ -289,8 +289,9 @@ void BadaSystem::initBackend() { // use the mobile device theme ConfMan.set("gui_theme", "/Res/scummmobile"); - // allow virtual keypad pack to be found - ConfMan.set("vkeybdpath", "/Res/vkeybd_default"); + // allow bada virtual keypad pack to be found + ConfMan.set("vkeybdpath", "/Res/vkeybd_bada"); + ConfMan.set("vkeybd_pack_name", "vkeybd_bada"); // set default save path to writable area if (!ConfMan.hasKey("savepath")) { -- cgit v1.2.3 From 46a8304b730e35dee340ac2ab665725f8f7f78b5 Mon Sep 17 00:00:00 2001 From: Chris Warren-Smith Date: Sat, 13 Aug 2011 07:35:50 +1000 Subject: BADA: Allow clean shutdown when encountering an error --- backends/platform/bada/system.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'backends/platform/bada/system.cpp') diff --git a/backends/platform/bada/system.cpp b/backends/platform/bada/system.cpp index f3f3083e5a..9cc7f450fe 100755 --- a/backends/platform/bada/system.cpp +++ b/backends/platform/bada/system.cpp @@ -361,8 +361,6 @@ void BadaSystem::destroyBackend() { delete _mutexManager; _mutexManager = 0; - - delete g_engine; } bool BadaSystem::pollEvent(Common::Event &event) { @@ -413,8 +411,12 @@ void BadaSystem::exitSystem() { } } -void BadaSystem::logMessage(LogMessageType::Type /*type*/, const char *message) { - AppLog(message); +void BadaSystem::logMessage(LogMessageType::Type type, const char *message) { + if (type == LogMessageType::kError) { + systemError(message); + } else { + AppLog(message); + } } Common::SeekableReadStream *BadaSystem::createConfigReadStream() { -- cgit v1.2.3 From 2e77b97b1984e32690ab3864af931553d5272767 Mon Sep 17 00:00:00 2001 From: Chris Warren-Smith Date: Sun, 14 Aug 2011 09:42:31 +1000 Subject: BADA: Code formatting; replace tab before else with space --- backends/platform/bada/system.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends/platform/bada/system.cpp') diff --git a/backends/platform/bada/system.cpp b/backends/platform/bada/system.cpp index 9cc7f450fe..8192ae8bbd 100755 --- a/backends/platform/bada/system.cpp +++ b/backends/platform/bada/system.cpp @@ -311,7 +311,7 @@ void BadaSystem::initBackend() { if (E_SUCCESS != initModules()) { AppLog("initModules failed"); - } else { + } else { OSystem::initBackend(); } @@ -414,7 +414,7 @@ void BadaSystem::exitSystem() { void BadaSystem::logMessage(LogMessageType::Type type, const char *message) { if (type == LogMessageType::kError) { systemError(message); - } else { + } else { AppLog(message); } } -- cgit v1.2.3 From a31b74f3e98a083c8d5e20facf06d126b9504c76 Mon Sep 17 00:00:00 2001 From: Chris Warren-Smith Date: Tue, 16 Aug 2011 11:58:43 +1000 Subject: BADA: Code formatting and style changes following review --- backends/platform/bada/system.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'backends/platform/bada/system.cpp') diff --git a/backends/platform/bada/system.cpp b/backends/platform/bada/system.cpp index 8192ae8bbd..d174b99a67 100755 --- a/backends/platform/bada/system.cpp +++ b/backends/platform/bada/system.cpp @@ -125,13 +125,13 @@ private: BadaMutexManager::BadaMutexManager() { for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { - buffer[i] = null; + buffer[i] = NULL; } } BadaMutexManager::~BadaMutexManager() { for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { - if (buffer[i] != null) { + if (buffer[i] != NULL) { delete buffer[i]; } } @@ -142,7 +142,7 @@ OSystem::MutexRef BadaMutexManager::createMutex() { mutex->Create(); for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { - if (buffer[i] == null) { + if (buffer[i] == NULL) { buffer[i] = mutex; break; } @@ -166,7 +166,7 @@ void BadaMutexManager::deleteMutex(OSystem::MutexRef mutex) { for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { if (buffer[i] == m) { - buffer[i] = null; + buffer[i] = NULL; } } @@ -190,7 +190,7 @@ void BadaEventManager::init() { DefaultEventManager::init(); // theme and vkbd should have now loaded - clear the splash screen - BadaSystem *system = (BadaSystem*)g_system; + BadaSystem *system = (BadaSystem *)g_system; BadaGraphicsManager *graphics = system->getGraphics(); if (graphics) { graphics->setReady(); @@ -199,7 +199,7 @@ void BadaEventManager::init() { } int BadaEventManager::shouldQuit() const { - BadaSystem *system = (BadaSystem*)g_system; + BadaSystem *system = (BadaSystem *)g_system; return system->isClosing(); } @@ -283,8 +283,8 @@ result BadaSystem::initModules() { void BadaSystem::initBackend() { logEntered(); - // allow translations to be found - ConfMan.set("themepath", "/Res"); + // allow translations and game .DAT files to be found + ConfMan.set("extrapath", "/Res"); // use the mobile device theme ConfMan.set("gui_theme", "/Res/scummmobile"); @@ -326,7 +326,7 @@ void BadaSystem::initBackend() { Graphics::BdfFont *font = Graphics::BdfFont::loadFromCache(fontFile); if (font) { // use this font for the vkbd and on-screen messages - FontMan.assignFontToUsage(Graphics::FontManager::kBigGUIFont, font); + FontMan.setFont(Graphics::FontManager::kBigGUIFont, font); } } } @@ -381,7 +381,7 @@ void BadaSystem::delayMillis(uint msecs) { } void BadaSystem::updateScreen() { - if (_graphicsManager != null) { + if (_graphicsManager != NULL) { _graphicsManager->updateScreen(); } } @@ -460,7 +460,7 @@ int BadaSystem::setVolume(bool up, bool minMax) { } // -// create the scummVM system +// create the ScummVM system // BadaAppForm *systemStart(Osp::App::Application *app) { logEntered(); @@ -468,14 +468,14 @@ BadaAppForm *systemStart(Osp::App::Application *app) { BadaAppForm *appForm = new BadaAppForm(); if (!appForm) { AppLog("Failed to create appForm"); - return null; + return NULL; } if (E_SUCCESS != appForm->Construct() || E_SUCCESS != app->GetAppFrame()->GetFrame()->AddControl(*appForm)) { delete appForm; AppLog("Failed to construct appForm"); - return null; + return NULL; } return appForm; @@ -493,11 +493,7 @@ void systemError(const char *message) { Application::GetInstance()->SendUserEvent(USER_MESSAGE_EXIT_ERR, args); if (g_system) { - BadaSystem *system = (BadaSystem*)g_system; + BadaSystem *system = (BadaSystem *)g_system; system->exitSystem(); } } - -// -// end of system.cpp -// -- cgit v1.2.3 From f01882a6e0bedce7c7d4411ba956681d7e3aa163 Mon Sep 17 00:00:00 2001 From: Chris Warren-Smith Date: Wed, 17 Aug 2011 21:23:40 +1000 Subject: BADA: Fix for menu based quit handling --- backends/platform/bada/system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/platform/bada/system.cpp') diff --git a/backends/platform/bada/system.cpp b/backends/platform/bada/system.cpp index d174b99a67..33318a1e61 100755 --- a/backends/platform/bada/system.cpp +++ b/backends/platform/bada/system.cpp @@ -200,7 +200,7 @@ void BadaEventManager::init() { int BadaEventManager::shouldQuit() const { BadaSystem *system = (BadaSystem *)g_system; - return system->isClosing(); + return DefaultEventManager::shouldQuit() || system->isClosing(); } // -- cgit v1.2.3 From 43059b18787cda6dfb6b13b90af276930c52d6d1 Mon Sep 17 00:00:00 2001 From: Chris Warren-Smith Date: Sat, 20 Aug 2011 10:41:32 +1000 Subject: BADA: Moved timer manager to backends/timer/bada --- backends/platform/bada/system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/platform/bada/system.cpp') diff --git a/backends/platform/bada/system.cpp b/backends/platform/bada/system.cpp index 33318a1e61..4503b8fa6b 100755 --- a/backends/platform/bada/system.cpp +++ b/backends/platform/bada/system.cpp @@ -33,12 +33,12 @@ #include "backends/audiocd/default/default-audiocd.h" #include "backends/mutex/mutex.h" #include "backends/fs/fs-factory.h" +#include "backends/timer/bada/timer.h" #include "backends/platform/bada/form.h" #include "backends/platform/bada/system.h" #include "backends/platform/bada/graphics.h" #include "backends/platform/bada/audio.h" -#include "backends/platform/bada/timer.h" using namespace Osp::Base; using namespace Osp::Base::Runtime; -- cgit v1.2.3 From 911de33e8946de479149e9dc7e16385298815b46 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Mon, 22 Aug 2011 09:45:19 +0200 Subject: BADA: Remove executable flag from files --- backends/platform/bada/system.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 backends/platform/bada/system.cpp (limited to 'backends/platform/bada/system.cpp') diff --git a/backends/platform/bada/system.cpp b/backends/platform/bada/system.cpp old mode 100755 new mode 100644 -- cgit v1.2.3 From b406ba58847780d346093d881eb544a3c7b81506 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Mon, 22 Aug 2011 09:45:53 +0200 Subject: BADA: Strip off windows-style line endings --- backends/platform/bada/system.cpp | 998 +++++++++++++++++++------------------- 1 file changed, 499 insertions(+), 499 deletions(-) (limited to 'backends/platform/bada/system.cpp') diff --git a/backends/platform/bada/system.cpp b/backends/platform/bada/system.cpp index 4503b8fa6b..bc921e0dff 100644 --- a/backends/platform/bada/system.cpp +++ b/backends/platform/bada/system.cpp @@ -1,499 +1,499 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * 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, - * 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. - * - */ - -#include - -#include "common/config-manager.h" -#include "common/file.h" -#include "engines/engine.h" -#include "graphics/font.h" -#include "graphics/fontman.h" -#include "graphics/fonts/bdf.h" -#include "backends/saves/default/default-saves.h" -#include "backends/events/default/default-events.h" -#include "backends/audiocd/default/default-audiocd.h" -#include "backends/mutex/mutex.h" -#include "backends/fs/fs-factory.h" -#include "backends/timer/bada/timer.h" - -#include "backends/platform/bada/form.h" -#include "backends/platform/bada/system.h" -#include "backends/platform/bada/graphics.h" -#include "backends/platform/bada/audio.h" - -using namespace Osp::Base; -using namespace Osp::Base::Runtime; -using namespace Osp::Ui::Controls; - -#define DEFAULT_CONFIG_FILE "/Home/scummvm.ini" -#define MUTEX_BUFFER_SIZE 5 - -// -// BadaFilesystemFactory -// -class BadaFilesystemFactory : public FilesystemFactory { - AbstractFSNode *makeRootFileNode() const; - AbstractFSNode *makeCurrentDirectoryFileNode() const; - AbstractFSNode *makeFileNodePath(const Common::String &path) const; -}; - -AbstractFSNode *BadaFilesystemFactory::makeRootFileNode() const { - return new BadaFilesystemNode("/"); -} - -AbstractFSNode *BadaFilesystemFactory::makeCurrentDirectoryFileNode() const { - return new BadaFilesystemNode("/Home"); -} - -AbstractFSNode *BadaFilesystemFactory::makeFileNodePath(const Common::String &path) const { - AppAssert(!path.empty()); - return new BadaFilesystemNode(path); -} - -// -// BadaSaveFileManager -// -struct BadaSaveFileManager : public DefaultSaveFileManager { - bool removeSavefile(const Common::String &filename); -}; - -bool BadaSaveFileManager::removeSavefile(const Common::String &filename) { - Common::String savePathName = getSavePath(); - - checkPath(Common::FSNode(savePathName)); - if (getError().getCode() != Common::kNoError) { - return false; - } - - // recreate FSNode since checkPath may have changed/created the directory - Common::FSNode savePath(savePathName); - Common::FSNode file = savePath.getChild(filename); - - String unicodeFileName; - StringUtil::Utf8ToString(file.getPath().c_str(), unicodeFileName); - - switch (Osp::Io::File::Remove(unicodeFileName)) { - case E_SUCCESS: - return true; - - case E_ILLEGAL_ACCESS: - setError(Common::kWritePermissionDenied, "Search or write permission denied: " + - file.getName()); - break; - - default: - setError(Common::kPathDoesNotExist, "removeSavefile: '" + file.getName() + - "' does not exist or path is invalid"); - break; - } - - return false; -} - -// -// BadaMutexManager -// -struct BadaMutexManager : public MutexManager { - BadaMutexManager(); - ~BadaMutexManager(); - OSystem::MutexRef createMutex(); - void lockMutex(OSystem::MutexRef mutex); - void unlockMutex(OSystem::MutexRef mutex); - void deleteMutex(OSystem::MutexRef mutex); -private: - Mutex *buffer[MUTEX_BUFFER_SIZE]; -}; - -BadaMutexManager::BadaMutexManager() { - for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { - buffer[i] = NULL; - } -} - -BadaMutexManager::~BadaMutexManager() { - for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { - if (buffer[i] != NULL) { - delete buffer[i]; - } - } -} - -OSystem::MutexRef BadaMutexManager::createMutex() { - Mutex *mutex = new Mutex(); - mutex->Create(); - - for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { - if (buffer[i] == NULL) { - buffer[i] = mutex; - break; - } - } - - return (OSystem::MutexRef) mutex; -} - -void BadaMutexManager::lockMutex(OSystem::MutexRef mutex) { - Mutex *m = (Mutex*)mutex; - m->Acquire(); -} - -void BadaMutexManager::unlockMutex(OSystem::MutexRef mutex) { - Mutex *m = (Mutex*)mutex; - m->Release(); -} - -void BadaMutexManager::deleteMutex(OSystem::MutexRef mutex) { - Mutex *m = (Mutex*)mutex; - - for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { - if (buffer[i] == m) { - buffer[i] = NULL; - } - } - - delete m; -} - -// -// BadaEventManager -// -struct BadaEventManager : public DefaultEventManager { - BadaEventManager(Common::EventSource *boss); - void init(); - int shouldQuit() const; -}; - -BadaEventManager::BadaEventManager(Common::EventSource *boss) : - DefaultEventManager(boss) { -} - -void BadaEventManager::init() { - DefaultEventManager::init(); - - // theme and vkbd should have now loaded - clear the splash screen - BadaSystem *system = (BadaSystem *)g_system; - BadaGraphicsManager *graphics = system->getGraphics(); - if (graphics) { - graphics->setReady(); - graphics->updateScreen(); - } -} - -int BadaEventManager::shouldQuit() const { - BadaSystem *system = (BadaSystem *)g_system; - return DefaultEventManager::shouldQuit() || system->isClosing(); -} - -// -// BadaSystem -// -BadaSystem::BadaSystem(BadaAppForm *appForm) : - _appForm(appForm), - _audioThread(0), - _epoch(0) { -} - -result BadaSystem::Construct(void) { - logEntered(); - - _fsFactory = new BadaFilesystemFactory(); - if (!_fsFactory) { - return E_OUT_OF_MEMORY; - } - - return E_SUCCESS; -} - -BadaSystem::~BadaSystem() { - logEntered(); -} - -result BadaSystem::initModules() { - logEntered(); - - _mutexManager = new BadaMutexManager(); - if (!_mutexManager) { - return E_OUT_OF_MEMORY; - } - - _timerManager = new BadaTimerManager(); - if (!_timerManager) { - return E_OUT_OF_MEMORY; - } - - _savefileManager = new BadaSaveFileManager(); - if (!_savefileManager) { - return E_OUT_OF_MEMORY; - } - - _graphicsManager = (GraphicsManager*) new BadaGraphicsManager(_appForm); - if (!_graphicsManager) { - return E_OUT_OF_MEMORY; - } - - // depends on _graphicsManager when ENABLE_VKEYBD enabled - _eventManager = new BadaEventManager(this); - if (!_eventManager) { - return E_OUT_OF_MEMORY; - } - - _audioThread = new AudioThread(); - if (!_audioThread) { - return E_OUT_OF_MEMORY; - } - - _mixer = _audioThread->Construct(this); - if (!_mixer) { - return E_OUT_OF_MEMORY; - } - - _audiocdManager = (AudioCDManager*) new DefaultAudioCDManager(); - if (!_audiocdManager) { - return E_OUT_OF_MEMORY; - } - - if (IsFailed(_audioThread->Start())) { - AppLog("Failed to start audio thread"); - return E_OUT_OF_MEMORY; - } - - logLeaving(); - return E_SUCCESS; -} - -void BadaSystem::initBackend() { - logEntered(); - - // allow translations and game .DAT files to be found - ConfMan.set("extrapath", "/Res"); - - // use the mobile device theme - ConfMan.set("gui_theme", "/Res/scummmobile"); - - // allow bada virtual keypad pack to be found - ConfMan.set("vkeybdpath", "/Res/vkeybd_bada"); - ConfMan.set("vkeybd_pack_name", "vkeybd_bada"); - - // set default save path to writable area - if (!ConfMan.hasKey("savepath")) { - ConfMan.set("savepath", "/Home/Share"); - } - - // default to no auto-save - if (!ConfMan.hasKey("autosave_period")) { - ConfMan.setInt("autosave_period", 0); - } - - ConfMan.registerDefault("fullscreen", true); - ConfMan.registerDefault("aspect_ratio", true); - ConfMan.setBool("confirm_exit", false); - - Osp::System::SystemTime::GetTicks(_epoch); - - if (E_SUCCESS != initModules()) { - AppLog("initModules failed"); - } else { - OSystem::initBackend(); - } - - // replace kBigGUIFont using the large font from the scummmobile theme - Common::File fontFile; - Common::String fileName = "/Res/scummmobile/helvB14-ASCII.fcc"; - BadaFilesystemNode file(fileName); - if (file.exists()) { - Common::SeekableReadStream *stream = file.createReadStream(); - if (stream) { - if (fontFile.open(stream, fileName)) { - Graphics::BdfFont *font = Graphics::BdfFont::loadFromCache(fontFile); - if (font) { - // use this font for the vkbd and on-screen messages - FontMan.setFont(Graphics::FontManager::kBigGUIFont, font); - } - } - } - } - - logLeaving(); -} - -void BadaSystem::destroyBackend() { - closeAudio(); - - delete _graphicsManager; - _graphicsManager = 0; - - delete _savefileManager; - _savefileManager = 0; - - delete _fsFactory; - _fsFactory = 0; - - delete _mixer; - _mixer = 0; - - delete _audiocdManager; - _audiocdManager = 0; - - delete _timerManager; - _timerManager = 0; - - delete _eventManager; - _eventManager = 0; - - delete _mutexManager; - _mutexManager = 0; -} - -bool BadaSystem::pollEvent(Common::Event &event) { - return _appForm->pollEvent(event); -} - -uint32 BadaSystem::getMillis() { - long long result, ticks = 0; - Osp::System::SystemTime::GetTicks(ticks); - result = ticks - _epoch; - return result; -} - -void BadaSystem::delayMillis(uint msecs) { - if (!_appForm->isClosing()) { - Thread::Sleep(msecs); - } -} - -void BadaSystem::updateScreen() { - if (_graphicsManager != NULL) { - _graphicsManager->updateScreen(); - } -} - -void BadaSystem::getTimeAndDate(TimeDate &td) const { - DateTime currentTime; - - if (E_SUCCESS == Osp::System::SystemTime::GetCurrentTime(currentTime)) { - td.tm_sec = currentTime.GetSecond(); - td.tm_min = currentTime.GetMinute(); - td.tm_hour = currentTime.GetHour(); - td.tm_mday = currentTime.GetDay(); - td.tm_mon = currentTime.GetMonth(); - td.tm_year = currentTime.GetYear(); - } -} - -void BadaSystem::fatalError() { - systemError("ScummVM: Fatal internal error."); -} - -void BadaSystem::exitSystem() { - if (_appForm) { - closeAudio(); - closeGraphics(); - _appForm->exitSystem(); - } -} - -void BadaSystem::logMessage(LogMessageType::Type type, const char *message) { - if (type == LogMessageType::kError) { - systemError(message); - } else { - AppLog(message); - } -} - -Common::SeekableReadStream *BadaSystem::createConfigReadStream() { - BadaFilesystemNode file(DEFAULT_CONFIG_FILE); - return file.createReadStream(); -} - -Common::WriteStream *BadaSystem::createConfigWriteStream() { - BadaFilesystemNode file(DEFAULT_CONFIG_FILE); - return file.createWriteStream(); -} - -void BadaSystem::closeAudio() { - if (_audioThread) { - _audioThread->Stop(); - _audioThread->Join(); - delete _audioThread; - _audioThread = 0; - } -} - -void BadaSystem::closeGraphics() { - if (_graphicsManager) { - delete _graphicsManager; - _graphicsManager = 0; - } -} - -void BadaSystem::setMute(bool on) { - if (_audioThread) { - _audioThread->setMute(on); - } -} - -int BadaSystem::setVolume(bool up, bool minMax) { - int level = -1; - if (_audioThread) { - level = _audioThread->setVolume(up, minMax); - } - return level; -} - -// -// create the ScummVM system -// -BadaAppForm *systemStart(Osp::App::Application *app) { - logEntered(); - - BadaAppForm *appForm = new BadaAppForm(); - if (!appForm) { - AppLog("Failed to create appForm"); - return NULL; - } - - if (E_SUCCESS != appForm->Construct() || - E_SUCCESS != app->GetAppFrame()->GetFrame()->AddControl(*appForm)) { - delete appForm; - AppLog("Failed to construct appForm"); - return NULL; - } - - return appForm; -} - -// -// display a fatal error notification -// -void systemError(const char *message) { - AppLog("Fatal system error: %s", message); - - ArrayList *args = new ArrayList(); - args->Construct(); - args->Add(*(new String(message))); - Application::GetInstance()->SendUserEvent(USER_MESSAGE_EXIT_ERR, args); - - if (g_system) { - BadaSystem *system = (BadaSystem *)g_system; - system->exitSystem(); - } -} +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * 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, + * 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. + * + */ + +#include + +#include "common/config-manager.h" +#include "common/file.h" +#include "engines/engine.h" +#include "graphics/font.h" +#include "graphics/fontman.h" +#include "graphics/fonts/bdf.h" +#include "backends/saves/default/default-saves.h" +#include "backends/events/default/default-events.h" +#include "backends/audiocd/default/default-audiocd.h" +#include "backends/mutex/mutex.h" +#include "backends/fs/fs-factory.h" +#include "backends/timer/bada/timer.h" + +#include "backends/platform/bada/form.h" +#include "backends/platform/bada/system.h" +#include "backends/platform/bada/graphics.h" +#include "backends/platform/bada/audio.h" + +using namespace Osp::Base; +using namespace Osp::Base::Runtime; +using namespace Osp::Ui::Controls; + +#define DEFAULT_CONFIG_FILE "/Home/scummvm.ini" +#define MUTEX_BUFFER_SIZE 5 + +// +// BadaFilesystemFactory +// +class BadaFilesystemFactory : public FilesystemFactory { + AbstractFSNode *makeRootFileNode() const; + AbstractFSNode *makeCurrentDirectoryFileNode() const; + AbstractFSNode *makeFileNodePath(const Common::String &path) const; +}; + +AbstractFSNode *BadaFilesystemFactory::makeRootFileNode() const { + return new BadaFilesystemNode("/"); +} + +AbstractFSNode *BadaFilesystemFactory::makeCurrentDirectoryFileNode() const { + return new BadaFilesystemNode("/Home"); +} + +AbstractFSNode *BadaFilesystemFactory::makeFileNodePath(const Common::String &path) const { + AppAssert(!path.empty()); + return new BadaFilesystemNode(path); +} + +// +// BadaSaveFileManager +// +struct BadaSaveFileManager : public DefaultSaveFileManager { + bool removeSavefile(const Common::String &filename); +}; + +bool BadaSaveFileManager::removeSavefile(const Common::String &filename) { + Common::String savePathName = getSavePath(); + + checkPath(Common::FSNode(savePathName)); + if (getError().getCode() != Common::kNoError) { + return false; + } + + // recreate FSNode since checkPath may have changed/created the directory + Common::FSNode savePath(savePathName); + Common::FSNode file = savePath.getChild(filename); + + String unicodeFileName; + StringUtil::Utf8ToString(file.getPath().c_str(), unicodeFileName); + + switch (Osp::Io::File::Remove(unicodeFileName)) { + case E_SUCCESS: + return true; + + case E_ILLEGAL_ACCESS: + setError(Common::kWritePermissionDenied, "Search or write permission denied: " + + file.getName()); + break; + + default: + setError(Common::kPathDoesNotExist, "removeSavefile: '" + file.getName() + + "' does not exist or path is invalid"); + break; + } + + return false; +} + +// +// BadaMutexManager +// +struct BadaMutexManager : public MutexManager { + BadaMutexManager(); + ~BadaMutexManager(); + OSystem::MutexRef createMutex(); + void lockMutex(OSystem::MutexRef mutex); + void unlockMutex(OSystem::MutexRef mutex); + void deleteMutex(OSystem::MutexRef mutex); +private: + Mutex *buffer[MUTEX_BUFFER_SIZE]; +}; + +BadaMutexManager::BadaMutexManager() { + for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { + buffer[i] = NULL; + } +} + +BadaMutexManager::~BadaMutexManager() { + for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { + if (buffer[i] != NULL) { + delete buffer[i]; + } + } +} + +OSystem::MutexRef BadaMutexManager::createMutex() { + Mutex *mutex = new Mutex(); + mutex->Create(); + + for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { + if (buffer[i] == NULL) { + buffer[i] = mutex; + break; + } + } + + return (OSystem::MutexRef) mutex; +} + +void BadaMutexManager::lockMutex(OSystem::MutexRef mutex) { + Mutex *m = (Mutex*)mutex; + m->Acquire(); +} + +void BadaMutexManager::unlockMutex(OSystem::MutexRef mutex) { + Mutex *m = (Mutex*)mutex; + m->Release(); +} + +void BadaMutexManager::deleteMutex(OSystem::MutexRef mutex) { + Mutex *m = (Mutex*)mutex; + + for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) { + if (buffer[i] == m) { + buffer[i] = NULL; + } + } + + delete m; +} + +// +// BadaEventManager +// +struct BadaEventManager : public DefaultEventManager { + BadaEventManager(Common::EventSource *boss); + void init(); + int shouldQuit() const; +}; + +BadaEventManager::BadaEventManager(Common::EventSource *boss) : + DefaultEventManager(boss) { +} + +void BadaEventManager::init() { + DefaultEventManager::init(); + + // theme and vkbd should have now loaded - clear the splash screen + BadaSystem *system = (BadaSystem *)g_system; + BadaGraphicsManager *graphics = system->getGraphics(); + if (graphics) { + graphics->setReady(); + graphics->updateScreen(); + } +} + +int BadaEventManager::shouldQuit() const { + BadaSystem *system = (BadaSystem *)g_system; + return DefaultEventManager::shouldQuit() || system->isClosing(); +} + +// +// BadaSystem +// +BadaSystem::BadaSystem(BadaAppForm *appForm) : + _appForm(appForm), + _audioThread(0), + _epoch(0) { +} + +result BadaSystem::Construct(void) { + logEntered(); + + _fsFactory = new BadaFilesystemFactory(); + if (!_fsFactory) { + return E_OUT_OF_MEMORY; + } + + return E_SUCCESS; +} + +BadaSystem::~BadaSystem() { + logEntered(); +} + +result BadaSystem::initModules() { + logEntered(); + + _mutexManager = new BadaMutexManager(); + if (!_mutexManager) { + return E_OUT_OF_MEMORY; + } + + _timerManager = new BadaTimerManager(); + if (!_timerManager) { + return E_OUT_OF_MEMORY; + } + + _savefileManager = new BadaSaveFileManager(); + if (!_savefileManager) { + return E_OUT_OF_MEMORY; + } + + _graphicsManager = (GraphicsManager*) new BadaGraphicsManager(_appForm); + if (!_graphicsManager) { + return E_OUT_OF_MEMORY; + } + + // depends on _graphicsManager when ENABLE_VKEYBD enabled + _eventManager = new BadaEventManager(this); + if (!_eventManager) { + return E_OUT_OF_MEMORY; + } + + _audioThread = new AudioThread(); + if (!_audioThread) { + return E_OUT_OF_MEMORY; + } + + _mixer = _audioThread->Construct(this); + if (!_mixer) { + return E_OUT_OF_MEMORY; + } + + _audiocdManager = (AudioCDManager*) new DefaultAudioCDManager(); + if (!_audiocdManager) { + return E_OUT_OF_MEMORY; + } + + if (IsFailed(_audioThread->Start())) { + AppLog("Failed to start audio thread"); + return E_OUT_OF_MEMORY; + } + + logLeaving(); + return E_SUCCESS; +} + +void BadaSystem::initBackend() { + logEntered(); + + // allow translations and game .DAT files to be found + ConfMan.set("extrapath", "/Res"); + + // use the mobile device theme + ConfMan.set("gui_theme", "/Res/scummmobile"); + + // allow bada virtual keypad pack to be found + ConfMan.set("vkeybdpath", "/Res/vkeybd_bada"); + ConfMan.set("vkeybd_pack_name", "vkeybd_bada"); + + // set default save path to writable area + if (!ConfMan.hasKey("savepath")) { + ConfMan.set("savepath", "/Home/Share"); + } + + // default to no auto-save + if (!ConfMan.hasKey("autosave_period")) { + ConfMan.setInt("autosave_period", 0); + } + + ConfMan.registerDefault("fullscreen", true); + ConfMan.registerDefault("aspect_ratio", true); + ConfMan.setBool("confirm_exit", false); + + Osp::System::SystemTime::GetTicks(_epoch); + + if (E_SUCCESS != initModules()) { + AppLog("initModules failed"); + } else { + OSystem::initBackend(); + } + + // replace kBigGUIFont using the large font from the scummmobile theme + Common::File fontFile; + Common::String fileName = "/Res/scummmobile/helvB14-ASCII.fcc"; + BadaFilesystemNode file(fileName); + if (file.exists()) { + Common::SeekableReadStream *stream = file.createReadStream(); + if (stream) { + if (fontFile.open(stream, fileName)) { + Graphics::BdfFont *font = Graphics::BdfFont::loadFromCache(fontFile); + if (font) { + // use this font for the vkbd and on-screen messages + FontMan.setFont(Graphics::FontManager::kBigGUIFont, font); + } + } + } + } + + logLeaving(); +} + +void BadaSystem::destroyBackend() { + closeAudio(); + + delete _graphicsManager; + _graphicsManager = 0; + + delete _savefileManager; + _savefileManager = 0; + + delete _fsFactory; + _fsFactory = 0; + + delete _mixer; + _mixer = 0; + + delete _audiocdManager; + _audiocdManager = 0; + + delete _timerManager; + _timerManager = 0; + + delete _eventManager; + _eventManager = 0; + + delete _mutexManager; + _mutexManager = 0; +} + +bool BadaSystem::pollEvent(Common::Event &event) { + return _appForm->pollEvent(event); +} + +uint32 BadaSystem::getMillis() { + long long result, ticks = 0; + Osp::System::SystemTime::GetTicks(ticks); + result = ticks - _epoch; + return result; +} + +void BadaSystem::delayMillis(uint msecs) { + if (!_appForm->isClosing()) { + Thread::Sleep(msecs); + } +} + +void BadaSystem::updateScreen() { + if (_graphicsManager != NULL) { + _graphicsManager->updateScreen(); + } +} + +void BadaSystem::getTimeAndDate(TimeDate &td) const { + DateTime currentTime; + + if (E_SUCCESS == Osp::System::SystemTime::GetCurrentTime(currentTime)) { + td.tm_sec = currentTime.GetSecond(); + td.tm_min = currentTime.GetMinute(); + td.tm_hour = currentTime.GetHour(); + td.tm_mday = currentTime.GetDay(); + td.tm_mon = currentTime.GetMonth(); + td.tm_year = currentTime.GetYear(); + } +} + +void BadaSystem::fatalError() { + systemError("ScummVM: Fatal internal error."); +} + +void BadaSystem::exitSystem() { + if (_appForm) { + closeAudio(); + closeGraphics(); + _appForm->exitSystem(); + } +} + +void BadaSystem::logMessage(LogMessageType::Type type, const char *message) { + if (type == LogMessageType::kError) { + systemError(message); + } else { + AppLog(message); + } +} + +Common::SeekableReadStream *BadaSystem::createConfigReadStream() { + BadaFilesystemNode file(DEFAULT_CONFIG_FILE); + return file.createReadStream(); +} + +Common::WriteStream *BadaSystem::createConfigWriteStream() { + BadaFilesystemNode file(DEFAULT_CONFIG_FILE); + return file.createWriteStream(); +} + +void BadaSystem::closeAudio() { + if (_audioThread) { + _audioThread->Stop(); + _audioThread->Join(); + delete _audioThread; + _audioThread = 0; + } +} + +void BadaSystem::closeGraphics() { + if (_graphicsManager) { + delete _graphicsManager; + _graphicsManager = 0; + } +} + +void BadaSystem::setMute(bool on) { + if (_audioThread) { + _audioThread->setMute(on); + } +} + +int BadaSystem::setVolume(bool up, bool minMax) { + int level = -1; + if (_audioThread) { + level = _audioThread->setVolume(up, minMax); + } + return level; +} + +// +// create the ScummVM system +// +BadaAppForm *systemStart(Osp::App::Application *app) { + logEntered(); + + BadaAppForm *appForm = new BadaAppForm(); + if (!appForm) { + AppLog("Failed to create appForm"); + return NULL; + } + + if (E_SUCCESS != appForm->Construct() || + E_SUCCESS != app->GetAppFrame()->GetFrame()->AddControl(*appForm)) { + delete appForm; + AppLog("Failed to construct appForm"); + return NULL; + } + + return appForm; +} + +// +// display a fatal error notification +// +void systemError(const char *message) { + AppLog("Fatal system error: %s", message); + + ArrayList *args = new ArrayList(); + args->Construct(); + args->Add(*(new String(message))); + Application::GetInstance()->SendUserEvent(USER_MESSAGE_EXIT_ERR, args); + + if (g_system) { + BadaSystem *system = (BadaSystem *)g_system; + system->exitSystem(); + } +} -- cgit v1.2.3 From 58ab4cdab79c2f55a96f373f948d47fabded68b4 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Mon, 22 Aug 2011 09:46:30 +0200 Subject: BADA: Strip trailing whitespace --- backends/platform/bada/system.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'backends/platform/bada/system.cpp') diff --git a/backends/platform/bada/system.cpp b/backends/platform/bada/system.cpp index bc921e0dff..37d7028687 100644 --- a/backends/platform/bada/system.cpp +++ b/backends/platform/bada/system.cpp @@ -96,7 +96,7 @@ bool BadaSaveFileManager::removeSavefile(const Common::String &filename) { return true; case E_ILLEGAL_ACCESS: - setError(Common::kWritePermissionDenied, "Search or write permission denied: " + + setError(Common::kWritePermissionDenied, "Search or write permission denied: " + file.getName()); break; @@ -206,9 +206,9 @@ int BadaEventManager::shouldQuit() const { // // BadaSystem // -BadaSystem::BadaSystem(BadaAppForm *appForm) : +BadaSystem::BadaSystem(BadaAppForm *appForm) : _appForm(appForm), - _audioThread(0), + _audioThread(0), _epoch(0) { } @@ -251,7 +251,7 @@ result BadaSystem::initModules() { } // depends on _graphicsManager when ENABLE_VKEYBD enabled - _eventManager = new BadaEventManager(this); + _eventManager = new BadaEventManager(this); if (!_eventManager) { return E_OUT_OF_MEMORY; } -- cgit v1.2.3