2011-08-22 09:45:53 +02:00
|
|
|
/* 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
|
2014-02-18 02:34:25 +01:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-08-22 09:45:53 +02:00
|
|
|
* 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 <FUiCtrlMessageBox.h>
|
2012-06-25 19:59:46 +02:00
|
|
|
#include <FLocales.h>
|
2011-08-22 09:45:53 +02:00
|
|
|
|
|
|
|
#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"
|
2013-06-25 21:08:55 +10:00
|
|
|
#include "backends/timer/tizen/timer.h"
|
2011-08-22 09:45:53 +02:00
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
#include "backends/platform/tizen/form.h"
|
|
|
|
#include "backends/platform/tizen/system.h"
|
|
|
|
#include "backends/platform/tizen/graphics.h"
|
|
|
|
#include "backends/platform/tizen/audio.h"
|
2011-08-22 09:45:53 +02:00
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
using namespace Tizen::Base;
|
|
|
|
using namespace Tizen::Base::Runtime;
|
|
|
|
using namespace Tizen::Locales;
|
|
|
|
using namespace Tizen::Ui;
|
|
|
|
using namespace Tizen::Ui::Controls;
|
|
|
|
using namespace Tizen::System;
|
2011-08-22 09:45:53 +02:00
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
#define DEFAULT_CONFIG_FILE "scummvm.ini"
|
2011-08-22 09:45:53 +02:00
|
|
|
#define MUTEX_BUFFER_SIZE 5
|
|
|
|
|
|
|
|
//
|
2013-06-25 21:08:55 +10:00
|
|
|
// TizenFilesystemFactory
|
2011-08-22 09:45:53 +02:00
|
|
|
//
|
2013-06-25 21:08:55 +10:00
|
|
|
class TizenFilesystemFactory : public FilesystemFactory {
|
2011-08-22 09:45:53 +02:00
|
|
|
AbstractFSNode *makeRootFileNode() const;
|
|
|
|
AbstractFSNode *makeCurrentDirectoryFileNode() const;
|
|
|
|
AbstractFSNode *makeFileNodePath(const Common::String &path) const;
|
|
|
|
};
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
AbstractFSNode *TizenFilesystemFactory::makeRootFileNode() const {
|
|
|
|
return new TizenFilesystemNode("/");
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
AbstractFSNode *TizenFilesystemFactory::makeCurrentDirectoryFileNode() const {
|
|
|
|
return new TizenFilesystemNode("/");
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
AbstractFSNode *TizenFilesystemFactory::makeFileNodePath(const Common::String &path) const {
|
2011-08-22 09:45:53 +02:00
|
|
|
AppAssert(!path.empty());
|
2013-06-25 21:08:55 +10:00
|
|
|
return new TizenFilesystemNode(path);
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2013-06-25 21:08:55 +10:00
|
|
|
// TizenSaveFileManager
|
2011-08-22 09:45:53 +02:00
|
|
|
//
|
2013-06-25 21:08:55 +10:00
|
|
|
struct TizenSaveFileManager : public DefaultSaveFileManager {
|
2011-08-22 09:45:53 +02:00
|
|
|
bool removeSavefile(const Common::String &filename);
|
|
|
|
};
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
bool TizenSaveFileManager::removeSavefile(const Common::String &filename) {
|
2011-08-22 09:45:53 +02:00
|
|
|
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);
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
switch (Tizen::Io::File::Remove(unicodeFileName)) {
|
2011-08-22 09:45:53 +02:00
|
|
|
case E_SUCCESS:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case E_ILLEGAL_ACCESS:
|
2011-08-22 09:46:30 +02:00
|
|
|
setError(Common::kWritePermissionDenied, "Search or write permission denied: " +
|
2013-06-25 21:08:55 +10:00
|
|
|
file.getName());
|
2011-08-22 09:45:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
setError(Common::kPathDoesNotExist, "removeSavefile: '" + file.getName() +
|
2013-06-25 21:08:55 +10:00
|
|
|
"' does not exist or path is invalid");
|
2011-08-22 09:45:53 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2013-06-25 21:08:55 +10:00
|
|
|
// TizenMutexManager
|
2011-08-22 09:45:53 +02:00
|
|
|
//
|
2013-06-25 21:08:55 +10:00
|
|
|
struct TizenMutexManager : public MutexManager {
|
|
|
|
TizenMutexManager();
|
|
|
|
~TizenMutexManager();
|
2011-08-22 09:45:53 +02:00
|
|
|
OSystem::MutexRef createMutex();
|
|
|
|
void lockMutex(OSystem::MutexRef mutex);
|
|
|
|
void unlockMutex(OSystem::MutexRef mutex);
|
|
|
|
void deleteMutex(OSystem::MutexRef mutex);
|
|
|
|
private:
|
2013-06-25 21:08:55 +10:00
|
|
|
Mutex *_buffer[MUTEX_BUFFER_SIZE];
|
2011-08-22 09:45:53 +02:00
|
|
|
};
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
TizenMutexManager::TizenMutexManager() {
|
2011-08-22 09:45:53 +02:00
|
|
|
for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) {
|
2013-06-25 21:08:55 +10:00
|
|
|
_buffer[i] = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
TizenMutexManager::~TizenMutexManager() {
|
2011-08-22 09:45:53 +02:00
|
|
|
for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) {
|
2013-06-25 21:08:55 +10:00
|
|
|
if (_buffer[i] != NULL) {
|
|
|
|
delete _buffer[i];
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
OSystem::MutexRef TizenMutexManager::createMutex() {
|
2011-08-22 09:45:53 +02:00
|
|
|
Mutex *mutex = new Mutex();
|
|
|
|
mutex->Create();
|
|
|
|
|
|
|
|
for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) {
|
2013-06-25 21:08:55 +10:00
|
|
|
if (_buffer[i] == NULL) {
|
|
|
|
_buffer[i] = mutex;
|
2011-08-22 09:45:53 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (OSystem::MutexRef) mutex;
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenMutexManager::lockMutex(OSystem::MutexRef mutex) {
|
2011-10-17 22:35:48 +10:00
|
|
|
Mutex *m = (Mutex *)mutex;
|
2011-08-22 09:45:53 +02:00
|
|
|
m->Acquire();
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenMutexManager::unlockMutex(OSystem::MutexRef mutex) {
|
2011-10-17 22:35:48 +10:00
|
|
|
Mutex *m = (Mutex *)mutex;
|
2011-08-22 09:45:53 +02:00
|
|
|
m->Release();
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenMutexManager::deleteMutex(OSystem::MutexRef mutex) {
|
2011-10-17 22:35:48 +10:00
|
|
|
Mutex *m = (Mutex *)mutex;
|
2011-08-22 09:45:53 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < MUTEX_BUFFER_SIZE; i++) {
|
2013-06-25 21:08:55 +10:00
|
|
|
if (_buffer[i] == m) {
|
|
|
|
_buffer[i] = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete m;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2013-06-25 21:08:55 +10:00
|
|
|
// TizenEventManager
|
2011-08-22 09:45:53 +02:00
|
|
|
//
|
2013-06-25 21:08:55 +10:00
|
|
|
struct TizenEventManager : public DefaultEventManager {
|
|
|
|
TizenEventManager(Common::EventSource *boss);
|
2011-08-22 09:45:53 +02:00
|
|
|
void init();
|
|
|
|
int shouldQuit() const;
|
|
|
|
};
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
TizenEventManager::TizenEventManager(Common::EventSource *boss) :
|
2011-08-22 09:45:53 +02:00
|
|
|
DefaultEventManager(boss) {
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenEventManager::init() {
|
2011-08-22 09:45:53 +02:00
|
|
|
DefaultEventManager::init();
|
|
|
|
|
|
|
|
// theme and vkbd should have now loaded - clear the splash screen
|
2013-06-25 21:08:55 +10:00
|
|
|
TizenSystem *system = (TizenSystem *)g_system;
|
|
|
|
TizenGraphicsManager *graphics = system->getGraphics();
|
2011-08-22 09:45:53 +02:00
|
|
|
if (graphics) {
|
|
|
|
graphics->setReady();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
int TizenEventManager::shouldQuit() const {
|
|
|
|
TizenSystem *system = (TizenSystem *)g_system;
|
2011-08-22 09:45:53 +02:00
|
|
|
return DefaultEventManager::shouldQuit() || system->isClosing();
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2013-06-25 21:08:55 +10:00
|
|
|
// TizenAppFrame - avoid drawing the misplaced UiTheme at startup
|
2011-08-22 09:45:53 +02:00
|
|
|
//
|
2013-06-25 21:08:55 +10:00
|
|
|
struct TizenAppFrame : Frame {
|
|
|
|
result OnDraw(void) {
|
|
|
|
logEntered();
|
|
|
|
TizenAppForm *form = (TizenAppForm *)GetCurrentForm();
|
|
|
|
if (form->isStarting()) {
|
|
|
|
Canvas *canvas = GetCanvasN();
|
|
|
|
canvas->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK));
|
|
|
|
canvas->Clear();
|
|
|
|
delete canvas;
|
|
|
|
}
|
|
|
|
return E_SUCCESS;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// TizenSystem
|
|
|
|
//
|
|
|
|
TizenSystem::TizenSystem(TizenAppForm *appForm) :
|
2011-08-22 09:45:53 +02:00
|
|
|
_appForm(appForm),
|
2011-08-22 09:46:30 +02:00
|
|
|
_audioThread(0),
|
2011-08-22 09:45:53 +02:00
|
|
|
_epoch(0) {
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
result TizenSystem::Construct(void) {
|
2011-08-22 09:45:53 +02:00
|
|
|
logEntered();
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
_fsFactory = new TizenFilesystemFactory();
|
2011-08-22 09:45:53 +02:00
|
|
|
if (!_fsFactory) {
|
|
|
|
return E_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
_resourcePath = fromString(App::GetInstance()->GetAppResourcePath());
|
2011-08-22 09:45:53 +02:00
|
|
|
return E_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
TizenSystem::~TizenSystem() {
|
2011-08-22 09:45:53 +02:00
|
|
|
logEntered();
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
result TizenSystem::initModules() {
|
2011-08-22 09:45:53 +02:00
|
|
|
logEntered();
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
_mutexManager = new TizenMutexManager();
|
2011-08-22 09:45:53 +02:00
|
|
|
if (!_mutexManager) {
|
|
|
|
return E_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
_timerManager = new TizenTimerManager();
|
2011-08-22 09:45:53 +02:00
|
|
|
if (!_timerManager) {
|
|
|
|
return E_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
_savefileManager = new TizenSaveFileManager();
|
2011-08-22 09:45:53 +02:00
|
|
|
if (!_savefileManager) {
|
|
|
|
return E_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
_graphicsManager = (GraphicsManager *)new TizenGraphicsManager(_appForm);
|
2013-10-19 19:40:10 +02:00
|
|
|
if (!_graphicsManager || graphicsManager->Construct() != E_SUCCESS) {
|
2011-08-22 09:45:53 +02:00
|
|
|
return E_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
// depends on _graphicsManager when ENABLE_VKEYBD enabled
|
2013-06-25 21:08:55 +10:00
|
|
|
_eventManager = new TizenEventManager(this);
|
2011-08-22 09:45:53 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-10-17 22:35:48 +10:00
|
|
|
_audiocdManager = (AudioCDManager *)new DefaultAudioCDManager();
|
2011-08-22 09:45:53 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::initBackend() {
|
2011-08-22 09:45:53 +02:00
|
|
|
logEntered();
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
Common::String dataPath = fromString(App::GetInstance()->GetAppDataPath());
|
|
|
|
|
2011-08-22 09:45:53 +02:00
|
|
|
// use the mobile device theme
|
2013-06-25 21:08:55 +10:00
|
|
|
ConfMan.set("gui_theme", _resourcePath + "scummmodern");
|
2011-08-22 09:45:53 +02:00
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
// allow tizen virtual keypad pack to be found
|
|
|
|
ConfMan.set("vkeybdpath", _resourcePath + "vkeybd_bada");
|
2011-08-22 09:45:53 +02:00
|
|
|
ConfMan.set("vkeybd_pack_name", "vkeybd_bada");
|
|
|
|
|
|
|
|
// set default save path to writable area
|
|
|
|
if (!ConfMan.hasKey("savepath")) {
|
2013-06-25 21:08:55 +10:00
|
|
|
ConfMan.set("savepath", dataPath);
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// default to no auto-save
|
|
|
|
if (!ConfMan.hasKey("autosave_period")) {
|
|
|
|
ConfMan.setInt("autosave_period", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfMan.registerDefault("fullscreen", true);
|
2011-10-17 22:35:48 +10:00
|
|
|
ConfMan.registerDefault("aspect_ratio", false);
|
2011-08-22 09:45:53 +02:00
|
|
|
ConfMan.setBool("confirm_exit", false);
|
|
|
|
|
2012-06-25 19:59:46 +02:00
|
|
|
SystemTime::GetTicks(_epoch);
|
2011-08-22 09:45:53 +02:00
|
|
|
|
|
|
|
if (E_SUCCESS != initModules()) {
|
|
|
|
AppLog("initModules failed");
|
|
|
|
} else {
|
|
|
|
OSystem::initBackend();
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
// replace kBigGUIFont for the vkbd and on-screen messages
|
|
|
|
Common::String fontCacheFile = dataPath + "helvR24.fcc";
|
|
|
|
TizenFilesystemNode file(fontCacheFile);
|
|
|
|
if (!file.exists()) {
|
|
|
|
Common::String bdfFile = _resourcePath + "fonts/helvR24.bdf";
|
|
|
|
TizenFilesystemNode file(bdfFile);
|
|
|
|
if (file.exists()) {
|
|
|
|
Common::SeekableReadStream *stream = file.createReadStream();
|
|
|
|
Common::File fontFile;
|
|
|
|
if (stream && fontFile.open(stream, bdfFile)) {
|
|
|
|
Graphics::BdfFont *font = Graphics::BdfFont::loadFont(fontFile);
|
|
|
|
Graphics::BdfFont::cacheFontData(*font, fontCacheFile);
|
|
|
|
FontMan.setFont(Graphics::FontManager::kBigGUIFont, font);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Common::SeekableReadStream *stream = file.createReadStream();
|
|
|
|
Common::File fontFile;
|
|
|
|
if (stream && fontFile.open(stream, fontCacheFile)) {
|
2011-08-22 09:45:53 +02:00
|
|
|
Graphics::BdfFont *font = Graphics::BdfFont::loadFromCache(fontFile);
|
|
|
|
if (font) {
|
|
|
|
FontMan.setFont(Graphics::FontManager::kBigGUIFont, font);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
logLeaving();
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
|
2011-10-17 22:35:48 +10:00
|
|
|
// allow translations.dat and game .DAT files to be found
|
2013-06-25 21:08:55 +10:00
|
|
|
s.addDirectory(_resourcePath, _resourcePath, priority);
|
2011-10-17 22:35:48 +10:00
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::destroyBackend() {
|
2011-08-22 09:45:53 +02:00
|
|
|
closeAudio();
|
|
|
|
|
|
|
|
delete _graphicsManager;
|
2013-06-25 21:08:55 +10:00
|
|
|
_graphicsManager = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
|
|
|
|
delete _savefileManager;
|
2013-06-25 21:08:55 +10:00
|
|
|
_savefileManager = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
|
|
|
|
delete _fsFactory;
|
2013-06-25 21:08:55 +10:00
|
|
|
_fsFactory = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
|
|
|
|
delete _mixer;
|
2013-06-25 21:08:55 +10:00
|
|
|
_mixer = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
|
|
|
|
delete _audiocdManager;
|
2013-06-25 21:08:55 +10:00
|
|
|
_audiocdManager = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
|
|
|
|
delete _timerManager;
|
2013-06-25 21:08:55 +10:00
|
|
|
_timerManager = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
|
|
|
|
delete _eventManager;
|
2013-06-25 21:08:55 +10:00
|
|
|
_eventManager = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
|
|
|
|
delete _mutexManager;
|
2013-06-25 21:08:55 +10:00
|
|
|
_mutexManager = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
bool TizenSystem::pollEvent(Common::Event &event) {
|
2011-08-22 09:45:53 +02:00
|
|
|
return _appForm->pollEvent(event);
|
|
|
|
}
|
|
|
|
|
2013-07-04 23:30:22 +02:00
|
|
|
uint32 TizenSystem::getMillis(bool skipRecord) {
|
2011-08-22 09:45:53 +02:00
|
|
|
long long result, ticks = 0;
|
2012-06-25 19:59:46 +02:00
|
|
|
SystemTime::GetTicks(ticks);
|
2011-08-22 09:45:53 +02:00
|
|
|
result = ticks - _epoch;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::delayMillis(uint msecs) {
|
2011-08-22 09:45:53 +02:00
|
|
|
if (!_appForm->isClosing()) {
|
|
|
|
Thread::Sleep(msecs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::updateScreen() {
|
2011-08-22 09:45:53 +02:00
|
|
|
if (_graphicsManager != NULL) {
|
|
|
|
_graphicsManager->updateScreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::getTimeAndDate(TimeDate &td) const {
|
2011-08-22 09:45:53 +02:00
|
|
|
DateTime currentTime;
|
|
|
|
|
2012-06-25 19:59:46 +02:00
|
|
|
if (E_SUCCESS == SystemTime::GetCurrentTime(WALL_TIME, currentTime)) {
|
2011-08-22 09:45:53 +02:00
|
|
|
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();
|
2012-06-25 19:59:46 +02:00
|
|
|
|
|
|
|
Calendar *calendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
|
|
|
|
calendar->SetTime(currentTime);
|
|
|
|
td.tm_wday = calendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK) - 1;
|
|
|
|
delete calendar;
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::fatalError() {
|
2011-08-22 09:45:53 +02:00
|
|
|
systemError("ScummVM: Fatal internal error.");
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::exitSystem() {
|
2011-08-22 09:45:53 +02:00
|
|
|
if (_appForm) {
|
|
|
|
closeAudio();
|
|
|
|
closeGraphics();
|
|
|
|
_appForm->exitSystem();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::logMessage(LogMessageType::Type type, const char *message) {
|
2011-08-22 09:45:53 +02:00
|
|
|
if (type == LogMessageType::kError) {
|
|
|
|
systemError(message);
|
|
|
|
} else {
|
|
|
|
AppLog(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
Common::SeekableReadStream *TizenSystem::createConfigReadStream() {
|
|
|
|
TizenFilesystemNode file(fromString(App::GetInstance()->GetAppDataPath()) + DEFAULT_CONFIG_FILE);
|
2011-08-22 09:45:53 +02:00
|
|
|
return file.createReadStream();
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
Common::WriteStream *TizenSystem::createConfigWriteStream() {
|
|
|
|
TizenFilesystemNode file(fromString(App::GetInstance()->GetAppDataPath()) + DEFAULT_CONFIG_FILE);
|
2011-08-22 09:45:53 +02:00
|
|
|
return file.createWriteStream();
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::closeAudio() {
|
2011-08-22 09:45:53 +02:00
|
|
|
if (_audioThread) {
|
2013-06-25 21:08:55 +10:00
|
|
|
_audioThread->Quit();
|
2011-08-22 09:45:53 +02:00
|
|
|
_audioThread->Join();
|
|
|
|
delete _audioThread;
|
2013-06-25 21:08:55 +10:00
|
|
|
_audioThread = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::closeGraphics() {
|
2011-08-22 09:45:53 +02:00
|
|
|
if (_graphicsManager) {
|
|
|
|
delete _graphicsManager;
|
2013-06-25 21:08:55 +10:00
|
|
|
_graphicsManager = NULL;
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
void TizenSystem::setMute(bool on) {
|
2011-10-17 22:35:48 +10:00
|
|
|
// only change mute after eventManager init() has completed
|
2011-08-22 09:45:53 +02:00
|
|
|
if (_audioThread) {
|
2013-06-25 21:08:55 +10:00
|
|
|
TizenGraphicsManager *graphics = getGraphics();
|
2011-10-17 22:35:48 +10:00
|
|
|
if (graphics && graphics->isReady()) {
|
|
|
|
_audioThread->setMute(on);
|
|
|
|
}
|
2011-08-22 09:45:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// create the ScummVM system
|
|
|
|
//
|
2013-06-25 21:08:55 +10:00
|
|
|
TizenAppForm *systemStart(Tizen::App::Application *app) {
|
2011-08-22 09:45:53 +02:00
|
|
|
logEntered();
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
Frame *appFrame = new (std::nothrow) TizenAppFrame();
|
|
|
|
if (!appFrame || appFrame->Construct() == E_FAILURE) {
|
|
|
|
AppLog("Failed to create appFrame");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
app->AddFrame(*appFrame);
|
|
|
|
|
|
|
|
TizenAppForm *appForm = new TizenAppForm();
|
2011-08-22 09:45:53 +02:00
|
|
|
if (!appForm) {
|
|
|
|
AppLog("Failed to create appForm");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (E_SUCCESS != appForm->Construct() ||
|
2013-08-17 08:52:14 +10:00
|
|
|
E_SUCCESS != appFrame->AddControl(appForm)) {
|
2011-08-22 09:45:53 +02:00
|
|
|
delete appForm;
|
|
|
|
AppLog("Failed to construct appForm");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
appFrame->SetCurrentForm(appForm);
|
2013-08-17 08:52:14 +10:00
|
|
|
appForm->GetVisualElement()->SetShowState(false);
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
logLeaving();
|
2011-08-22 09:45:53 +02:00
|
|
|
return appForm;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// display a fatal error notification
|
|
|
|
//
|
|
|
|
void systemError(const char *message) {
|
|
|
|
AppLog("Fatal system error: %s", message);
|
|
|
|
|
2013-06-25 21:08:55 +10:00
|
|
|
if (strspn(message, "Config file buggy:") > 0) {
|
2013-08-17 08:52:14 +10:00
|
|
|
Tizen::Io::File::Remove(App::GetInstance()->GetAppDataPath() + DEFAULT_CONFIG_FILE);
|
2013-06-25 21:08:55 +10:00
|
|
|
Application::GetInstance()->SendUserEvent(USER_MESSAGE_EXIT_ERR_CONFIG, NULL);
|
|
|
|
} else {
|
|
|
|
ArrayList *args = new ArrayList();
|
|
|
|
args->Construct();
|
|
|
|
args->Add(*(new String(message)));
|
|
|
|
Application::GetInstance()->SendUserEvent(USER_MESSAGE_EXIT_ERR, args);
|
|
|
|
}
|
2011-08-22 09:45:53 +02:00
|
|
|
|
|
|
|
if (g_system) {
|
2013-06-25 21:08:55 +10:00
|
|
|
TizenSystem *system = (TizenSystem *)g_system;
|
2011-08-22 09:45:53 +02:00
|
|
|
system->exitSystem();
|
|
|
|
}
|
|
|
|
}
|