diff options
Diffstat (limited to 'backends')
120 files changed, 3288 insertions, 667 deletions
diff --git a/backends/audiocd/audiocd.h b/backends/audiocd/audiocd.h index 92b7598cb5..0afc6af991 100644 --- a/backends/audiocd/audiocd.h +++ b/backends/audiocd/audiocd.h @@ -113,7 +113,7 @@ public: * @return true if the CD drive was inited succesfully */ virtual bool openCD(int drive) = 0; - + /** * Poll CD status. * @return true if CD audio is playing diff --git a/backends/events/ps3sdl/ps3sdl-events.cpp b/backends/events/ps3sdl/ps3sdl-events.cpp new file mode 100644 index 0000000000..eefc641844 --- /dev/null +++ b/backends/events/ps3sdl/ps3sdl-events.cpp @@ -0,0 +1,163 @@ +/* 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 "common/scummsys.h" + +#if defined(PLAYSTATION3) + +#include "backends/events/ps3sdl/ps3sdl-events.h" +#include "backends/platform/sdl/sdl.h" +#include "engines/engine.h" + +#include "common/util.h" +#include "common/events.h" + +enum { + BTN_LEFT = 0, + BTN_DOWN = 1, + BTN_RIGHT = 2, + BTN_UP = 3, + + BTN_START = 4, + BTN_R3 = 5, + BTN_L3 = 6, + BTN_SELECT = 7, + + BTN_SQUARE = 8, + BTN_CROSS = 9, + BTN_CIRCLE = 10, + BTN_TRIANGLE = 11, + + BTN_R1 = 12, + BTN_L1 = 13, + BTN_R2 = 14, + BTN_L2 = 15 +}; + +bool PS3SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { + + event.kbd.flags = 0; + + switch (ev.jbutton.button) { + case BTN_CROSS: // Left mouse button + event.type = Common::EVENT_LBUTTONDOWN; + fillMouseEvent(event, _km.x, _km.y); + break; + case BTN_CIRCLE: // Right mouse button + event.type = Common::EVENT_RBUTTONDOWN; + fillMouseEvent(event, _km.x, _km.y); + break; + case BTN_TRIANGLE: // Game menu + event.type = Common::EVENT_KEYDOWN; + event.kbd.keycode = Common::KEYCODE_F5; + event.kbd.ascii = mapKey(SDLK_F5, (SDLMod) ev.key.keysym.mod, 0); + break; + case BTN_SELECT: // Virtual keyboard + event.type = Common::EVENT_KEYDOWN; + event.kbd.keycode = Common::KEYCODE_F7; + event.kbd.ascii = mapKey(SDLK_F7, (SDLMod) ev.key.keysym.mod, 0); + break; + case BTN_SQUARE: // Escape + event.type = Common::EVENT_KEYDOWN; + event.kbd.keycode = Common::KEYCODE_ESCAPE; + event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod) ev.key.keysym.mod, 0); + break; + case BTN_L1: // Predictive input dialog + event.type = Common::EVENT_PREDICTIVE_DIALOG; + break; + case BTN_START: // ScummVM in game menu + event.type = Common::EVENT_MAINMENU; + break; + } + return true; +} + +bool PS3SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { + + event.kbd.flags = 0; + + switch (ev.jbutton.button) { + case BTN_CROSS: // Left mouse button + event.type = Common::EVENT_LBUTTONUP; + fillMouseEvent(event, _km.x, _km.y); + break; + case BTN_CIRCLE: // Right mouse button + event.type = Common::EVENT_RBUTTONUP; + fillMouseEvent(event, _km.x, _km.y); + break; + case BTN_TRIANGLE: // Game menu + event.type = Common::EVENT_KEYUP; + event.kbd.keycode = Common::KEYCODE_F5; + event.kbd.ascii = mapKey(SDLK_F5, (SDLMod) ev.key.keysym.mod, 0); + break; + case BTN_SELECT: // Virtual keyboard + event.type = Common::EVENT_KEYUP; + event.kbd.keycode = Common::KEYCODE_F7; + event.kbd.ascii = mapKey(SDLK_F7, (SDLMod) ev.key.keysym.mod, 0); + break; + case BTN_SQUARE: // Escape + event.type = Common::EVENT_KEYUP; + event.kbd.keycode = Common::KEYCODE_ESCAPE; + event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod) ev.key.keysym.mod, 0); + break; + } + return true; +} + +/** + * The XMB (PS3 in game menu) needs the screen buffers to be constantly flip while open. + * This pauses execution and keeps redrawing the screen until the XMB is closed. + */ +void PS3SdlEventSource::preprocessEvents(SDL_Event *event) { + if (event->type == SDL_ACTIVEEVENT) { + if (event->active.state == SDL_APPMOUSEFOCUS && !event->active.gain) { + // XMB opened + if (g_engine) + g_engine->pauseEngine(true); + + for (;;) { + if (!SDL_PollEvent(event)) { + // Locking the screen forces a full redraw + Graphics::Surface* screen = g_system->lockScreen(); + if (screen) { + g_system->unlockScreen(); + g_system->updateScreen(); + } + SDL_Delay(10); + continue; + } + if (event->type == SDL_QUIT) + return; + if (event->type != SDL_ACTIVEEVENT) + continue; + if (event->active.state == SDL_APPMOUSEFOCUS && event->active.gain) { + // XMB closed + if (g_engine) + g_engine->pauseEngine(false); + return; + } + } + } + } +} + +#endif diff --git a/backends/events/ps3sdl/ps3sdl-events.h b/backends/events/ps3sdl/ps3sdl-events.h new file mode 100644 index 0000000000..8cf2f43426 --- /dev/null +++ b/backends/events/ps3sdl/ps3sdl-events.h @@ -0,0 +1,38 @@ +/* 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. + * + */ + +#if !defined(BACKEND_EVENTS_PS3_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER) +#define BACKEND_EVENTS_PS3_H + +#include "backends/events/sdl/sdl-events.h" + +/** + * SDL Events manager for the PS3. + */ +class PS3SdlEventSource : public SdlEventSource { +protected: + void preprocessEvents(SDL_Event *event); + bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event); + bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event); +}; + +#endif /* BACKEND_EVENTS_PS3_H */ diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 835d98e718..4489a2e580 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -206,7 +206,6 @@ bool SdlEventSource::pollEvent(Common::Event &event) { } SDL_Event ev; - ev.type = SDL_NOEVENT; while (SDL_PollEvent(&ev)) { preprocessEvents(&ev); if (dispatchSDLEvent(ev, event)) @@ -304,7 +303,7 @@ bool SdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_KEYDOWN; event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; - event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); + event.kbd.ascii = mapKey(ev.key.keysym.sym, (SDLMod)ev.key.keysym.mod, (Uint16)ev.key.keysym.unicode); return true; } @@ -348,7 +347,7 @@ bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_KEYUP; event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym; - event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); + event.kbd.ascii = mapKey(ev.key.keysym.sym, (SDLMod)ev.key.keysym.mod, (Uint16)ev.key.keysym.unicode); // Ctrl-Alt-<key> will change the GFX mode SDLModToOSystemKeyFlags(mod, event); @@ -418,19 +417,19 @@ bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { switch (ev.jbutton.button) { case JOY_BUT_ESCAPE: event.kbd.keycode = Common::KEYCODE_ESCAPE; - event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0); + event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod)ev.key.keysym.mod, 0); break; case JOY_BUT_PERIOD: event.kbd.keycode = Common::KEYCODE_PERIOD; - event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0); + event.kbd.ascii = mapKey(SDLK_PERIOD, (SDLMod)ev.key.keysym.mod, 0); break; case JOY_BUT_SPACE: event.kbd.keycode = Common::KEYCODE_SPACE; - event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0); + event.kbd.ascii = mapKey(SDLK_SPACE, (SDLMod)ev.key.keysym.mod, 0); break; case JOY_BUT_F5: event.kbd.keycode = Common::KEYCODE_F5; - event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0); + event.kbd.ascii = mapKey(SDLK_F5, (SDLMod)ev.key.keysym.mod, 0); break; } } @@ -449,19 +448,19 @@ bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { switch (ev.jbutton.button) { case JOY_BUT_ESCAPE: event.kbd.keycode = Common::KEYCODE_ESCAPE; - event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0); + event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod)ev.key.keysym.mod, 0); break; case JOY_BUT_PERIOD: event.kbd.keycode = Common::KEYCODE_PERIOD; - event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0); + event.kbd.ascii = mapKey(SDLK_PERIOD, (SDLMod)ev.key.keysym.mod, 0); break; case JOY_BUT_SPACE: event.kbd.keycode = Common::KEYCODE_SPACE; - event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0); + event.kbd.ascii = mapKey(SDLK_SPACE, (SDLMod)ev.key.keysym.mod, 0); break; case JOY_BUT_F5: event.kbd.keycode = Common::KEYCODE_F5; - event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0); + event.kbd.ascii = mapKey(SDLK_F5, (SDLMod)ev.key.keysym.mod, 0); break; } } diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index 227d6e1607..805b76b108 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -20,19 +20,19 @@ * */ -#if !defined(BACKEND_EVENTS_SDL_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER) +#ifndef BACKEND_EVENTS_SDL_H #define BACKEND_EVENTS_SDL_H -#include "backends/events/default/default-events.h" - #include "backends/platform/sdl/sdl-sys.h" +#include "common/events.h" + /** * The SDL event source. */ class SdlEventSource : public Common::EventSource { -public: +public: SdlEventSource(); virtual ~SdlEventSource(); @@ -69,7 +69,7 @@ protected: /** Scroll lock state - since SDL doesn't track it */ bool _scrollLock; - + /** Joystick */ SDL_Joystick *_joystick; diff --git a/backends/events/webossdl/webossdl-events.cpp b/backends/events/webossdl/webossdl-events.cpp index 4a17bc2066..102eb5802e 100644 --- a/backends/events/webossdl/webossdl-events.cpp +++ b/backends/events/webossdl/webossdl-events.cpp @@ -89,7 +89,7 @@ void WebOSSdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, event.kbd.flags |= Common::KBD_SHIFT; if (mod & KMOD_CTRL) event.kbd.flags |= Common::KBD_CTRL; - + // Holding down the gesture area emulates the ALT key if (gestureDown) event.kbd.flags |= Common::KBD_ALT; diff --git a/backends/events/wincesdl/wincesdl-events.cpp b/backends/events/wincesdl/wincesdl-events.cpp index 4fab47a58e..1116cbbb8d 100644 --- a/backends/events/wincesdl/wincesdl-events.cpp +++ b/backends/events/wincesdl/wincesdl-events.cpp @@ -183,7 +183,8 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) { if (_tapTime) { // second tap if (_closeClick && (GetTickCount() - _tapTime < 1000)) { if (event.mouse.y <= 20 && - _graphicsMan->_panelInitialized) { + _graphicsMan->_panelInitialized && + !_graphicsMan->_noDoubleTapPT) { // top of screen (show panel) _graphicsMan->swap_panel_visibility(); } else if (!_graphicsMan->_noDoubleTapRMB) { diff --git a/backends/fs/ds/ds-fs-factory.cpp b/backends/fs/ds/ds-fs-factory.cpp index 3fd97d07eb..4e09c3446b 100644 --- a/backends/fs/ds/ds-fs-factory.cpp +++ b/backends/fs/ds/ds-fs-factory.cpp @@ -27,7 +27,9 @@ #include "backends/fs/ds/ds-fs.h" #include "dsmain.h" //for the isGBAMPAvailable() function +namespace Common { DECLARE_SINGLETON(DSFilesystemFactory); +} AbstractFSNode *DSFilesystemFactory::makeRootFileNode() const { if (DS::isGBAMPAvailable()) { diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp index 829355be84..776ea86155 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/fs/posix/posix-fs-factory.cpp @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if defined(POSIX) +#if defined(POSIX) || defined(PLAYSTATION3) // Re-enable some forbidden symbols to avoid clashes with stat.h and unistd.h. // Also with clock() in sys/time.h in some Mac OS X SDKs. diff --git a/backends/fs/posix/posix-fs-factory.h b/backends/fs/posix/posix-fs-factory.h index a7075db94c..c7cec6fab5 100644 --- a/backends/fs/posix/posix-fs-factory.h +++ b/backends/fs/posix/posix-fs-factory.h @@ -30,6 +30,7 @@ * Parts of this class are documented in the base interface class, FilesystemFactory. */ class POSIXFilesystemFactory : public FilesystemFactory { +protected: virtual AbstractFSNode *makeRootFileNode() const; virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 0b94c37b16..320c5a6f39 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if defined(POSIX) +#if defined(POSIX) || defined(PLAYSTATION3) // Re-enable some forbidden symbols to avoid clashes with stat.h and unistd.h. // Also with clock() in sys/time.h in some Mac OS X SDKs. diff --git a/backends/fs/ps2/ps2-fs-factory.cpp b/backends/fs/ps2/ps2-fs-factory.cpp index cad92b5dec..ef7b2013a3 100644 --- a/backends/fs/ps2/ps2-fs-factory.cpp +++ b/backends/fs/ps2/ps2-fs-factory.cpp @@ -27,7 +27,9 @@ #include "backends/fs/ps2/ps2-fs-factory.h" #include "backends/fs/ps2/ps2-fs.h" +namespace Common { DECLARE_SINGLETON(Ps2FilesystemFactory); +} AbstractFSNode *Ps2FilesystemFactory::makeRootFileNode() const { return new Ps2FilesystemNode(); diff --git a/backends/fs/ps3/ps3-fs-factory.cpp b/backends/fs/ps3/ps3-fs-factory.cpp new file mode 100644 index 0000000000..3257246c50 --- /dev/null +++ b/backends/fs/ps3/ps3-fs-factory.cpp @@ -0,0 +1,26 @@ +/* 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 "backends/fs/ps3/ps3-fs-factory.h" + +AbstractFSNode *PS3FilesystemFactory::makeCurrentDirectoryFileNode() const { + return makeRootFileNode(); +} diff --git a/backends/fs/ps3/ps3-fs-factory.h b/backends/fs/ps3/ps3-fs-factory.h new file mode 100644 index 0000000000..6c1988b1c9 --- /dev/null +++ b/backends/fs/ps3/ps3-fs-factory.h @@ -0,0 +1,36 @@ +/* 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. + */ + +#ifndef PS3_FILESYSTEM_FACTORY_H +#define PS3_FILESYSTEM_FACTORY_H + +#include "backends/fs/posix/posix-fs-factory.h" + +/** + * Creates PS3FilesystemFactory objects. + * + * Parts of this class are documented in the base interface class, FilesystemFactory. + */ +class PS3FilesystemFactory : public POSIXFilesystemFactory { + virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; +}; + +#endif /*PS3_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/psp/psp-fs-factory.cpp b/backends/fs/psp/psp-fs-factory.cpp index ef1df246ba..bb3aca8ee6 100644 --- a/backends/fs/psp/psp-fs-factory.cpp +++ b/backends/fs/psp/psp-fs-factory.cpp @@ -43,7 +43,9 @@ #include <unistd.h> +namespace Common { DECLARE_SINGLETON(PSPFilesystemFactory); +} AbstractFSNode *PSPFilesystemFactory::makeRootFileNode() const { return new PSPFilesystemNode(); diff --git a/backends/fs/wii/wii-fs-factory.cpp b/backends/fs/wii/wii-fs-factory.cpp index 34cde8ef46..fbc9ef1da8 100644 --- a/backends/fs/wii/wii-fs-factory.cpp +++ b/backends/fs/wii/wii-fs-factory.cpp @@ -40,7 +40,9 @@ #include <smb.h> #endif +namespace Common { DECLARE_SINGLETON(WiiFilesystemFactory); +} WiiFilesystemFactory::WiiFilesystemFactory() : _dvdMounted(false), diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index 9e864753c9..c32ad2da94 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -54,7 +54,7 @@ bool WindowsFilesystemNode::isWritable() const { return _access(_path.c_str(), W_OK) == 0; } -void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data) { +void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const char *base, bool hidden, WIN32_FIND_DATA* find_data) { WindowsFilesystemNode entry; char *asciiName = toAscii(find_data->cFileName); bool isDirectory; @@ -63,6 +63,10 @@ void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const c if (!strcmp(asciiName, ".") || !strcmp(asciiName, "..")) return; + // Skip hidden files if asked + if ((find_data->dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) && !hidden) + return; + isDirectory = (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? true : false); if ((!isDirectory && mode == Common::FSNode::kListDirectoriesOnly) || @@ -163,8 +167,6 @@ AbstractFSNode *WindowsFilesystemNode::getChild(const Common::String &n) const { bool WindowsFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const { assert(_isDirectory); - //TODO: honor the hidden flag - if (_isPseudoRoot) { #ifndef _WIN32_WCE // Drives enumeration @@ -200,10 +202,10 @@ bool WindowsFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b if (handle == INVALID_HANDLE_VALUE) return false; - addFile(myList, mode, _path.c_str(), &desc); + addFile(myList, mode, _path.c_str(), hidden, &desc); while (FindNextFile(handle, &desc)) - addFile(myList, mode, _path.c_str(), &desc); + addFile(myList, mode, _path.c_str(), hidden, &desc); FindClose(handle); } diff --git a/backends/fs/windows/windows-fs.h b/backends/fs/windows/windows-fs.h index 37d1e9099b..351307bef0 100644 --- a/backends/fs/windows/windows-fs.h +++ b/backends/fs/windows/windows-fs.h @@ -93,12 +93,13 @@ private: * Adds a single WindowsFilesystemNode to a given list. * This method is used by getChildren() to populate the directory entries list. * - * @param list List to put the file entry node in. - * @param mode Mode to use while adding the file entry to the list. - * @param base Common::String with the directory being listed. - * @param find_data Describes a file that the FindFirstFile, FindFirstFileEx, or FindNextFile functions find. + * @param list List to put the file entry node in. + * @param mode Mode to use while adding the file entry to the list. + * @param base Common::String with the directory being listed. + * @param hidden true if hidden files should be added, false otherwise + * @param find_data Describes a file that the FindFirstFile, FindFirstFileEx, or FindNextFile functions find. */ - static void addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data); + static void addFile(AbstractFSList &list, ListMode mode, const char *base, bool hidden, WIN32_FIND_DATA* find_data); /** * Converts a Unicode string to Ascii format. diff --git a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp index 8a141e97a5..8075d0d45b 100644 --- a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp +++ b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp @@ -36,7 +36,7 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { }; DINGUXSdlGraphicsManager::DINGUXSdlGraphicsManager(SdlEventSource *boss) - : SdlGraphicsManager(boss) { + : SurfaceSdlGraphicsManager(boss) { } const OSystem::GraphicsMode *DINGUXSdlGraphicsManager::getSupportedGraphicsModes() const { @@ -415,7 +415,7 @@ void DINGUXSdlGraphicsManager::showOverlay() { _mouseCurState.x = _mouseCurState.x / 2; _mouseCurState.y = _mouseCurState.y / 2; } - SdlGraphicsManager::showOverlay(); + SurfaceSdlGraphicsManager::showOverlay(); } void DINGUXSdlGraphicsManager::hideOverlay() { @@ -423,7 +423,7 @@ void DINGUXSdlGraphicsManager::hideOverlay() { _mouseCurState.x = _mouseCurState.x * 2; _mouseCurState.y = _mouseCurState.y * 2; } - SdlGraphicsManager::hideOverlay(); + SurfaceSdlGraphicsManager::hideOverlay(); } bool DINGUXSdlGraphicsManager::loadGFXMode() { @@ -462,7 +462,7 @@ bool DINGUXSdlGraphicsManager::loadGFXMode() { } - return SdlGraphicsManager::loadGFXMode(); + return SurfaceSdlGraphicsManager::loadGFXMode(); } bool DINGUXSdlGraphicsManager::hasFeature(OSystem::Feature f) { @@ -492,11 +492,11 @@ bool DINGUXSdlGraphicsManager::getFeatureState(OSystem::Feature f) { } } -SdlGraphicsManager::MousePos* DINGUXSdlGraphicsManager::getMouseCurState() { +SurfaceSdlGraphicsManager::MousePos *DINGUXSdlGraphicsManager::getMouseCurState() { return &_mouseCurState; } -SdlGraphicsManager::VideoState* DINGUXSdlGraphicsManager::getVideoMode() { +SurfaceSdlGraphicsManager::VideoState *DINGUXSdlGraphicsManager::getVideoMode() { return &_videoMode; } @@ -507,7 +507,7 @@ void DINGUXSdlGraphicsManager::warpMouse(int x, int y) { y = y / 2; } } - SdlGraphicsManager::warpMouse(x, y); + SurfaceSdlGraphicsManager::warpMouse(x, y); } void DINGUXSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) { diff --git a/backends/graphics/dinguxsdl/dinguxsdl-graphics.h b/backends/graphics/dinguxsdl/dinguxsdl-graphics.h index 9fb1170503..84a784b771 100644 --- a/backends/graphics/dinguxsdl/dinguxsdl-graphics.h +++ b/backends/graphics/dinguxsdl/dinguxsdl-graphics.h @@ -23,16 +23,16 @@ #ifndef BACKENDS_GRAPHICS_SDL_DINGUX_H #define BACKENDS_GRAPHICS_SDL_DINGUX_H -#include "backends/graphics/sdl/sdl-graphics.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" -#include "graphics/scaler/aspect.h" // for aspect2Real +#include "graphics/scaler/aspect.h" // for aspect2Real #include "graphics/scaler/downscaler.h" enum { GFX_HALF = 12 }; -class DINGUXSdlGraphicsManager : public SdlGraphicsManager { +class DINGUXSdlGraphicsManager : public SurfaceSdlGraphicsManager { public: DINGUXSdlGraphicsManager(SdlEventSource *boss); @@ -54,8 +54,8 @@ public: void undrawMouse(); virtual void warpMouse(int x, int y); - SdlGraphicsManager::MousePos *getMouseCurState(); - SdlGraphicsManager::VideoState *getVideoMode(); + SurfaceSdlGraphicsManager::MousePos *getMouseCurState(); + SurfaceSdlGraphicsManager::VideoState *getVideoMode(); virtual void adjustMouseEvent(const Common::Event &event); }; diff --git a/backends/graphics/gph/gph-graphics.cpp b/backends/graphics/gph/gph-graphics.cpp index eb748f2fc2..82a32203fb 100644 --- a/backends/graphics/gph/gph-graphics.cpp +++ b/backends/graphics/gph/gph-graphics.cpp @@ -36,7 +36,7 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { }; GPHGraphicsManager::GPHGraphicsManager(SdlEventSource *sdlEventSource) - : SdlGraphicsManager(sdlEventSource) { + : SurfaceSdlGraphicsManager(sdlEventSource) { } const OSystem::GraphicsMode *GPHGraphicsManager::getSupportedGraphicsModes() const { @@ -443,7 +443,7 @@ void GPHGraphicsManager::showOverlay() { _mouseCurState.x = _mouseCurState.x / 2; _mouseCurState.y = _mouseCurState.y / 2; } - SdlGraphicsManager::showOverlay(); + SurfaceSdlGraphicsManager::showOverlay(); } void GPHGraphicsManager::hideOverlay() { @@ -451,7 +451,7 @@ void GPHGraphicsManager::hideOverlay() { _mouseCurState.x = _mouseCurState.x * 2; _mouseCurState.y = _mouseCurState.y * 2; } - SdlGraphicsManager::hideOverlay(); + SurfaceSdlGraphicsManager::hideOverlay(); } @@ -503,7 +503,7 @@ void GPHGraphicsManager::hideOverlay() { // // } -// return SdlGraphicsManager::loadGFXMode(); +// return SurfaceSdlGraphicsManager::loadGFXMode(); //} bool GPHGraphicsManager::loadGFXMode() { @@ -531,7 +531,7 @@ bool GPHGraphicsManager::loadGFXMode() { _videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor; _videoMode.hardwareHeight = effectiveScreenHeight(); } - return SdlGraphicsManager::loadGFXMode(); + return SurfaceSdlGraphicsManager::loadGFXMode(); } bool GPHGraphicsManager::hasFeature(OSystem::Feature f) { @@ -561,11 +561,11 @@ bool GPHGraphicsManager::getFeatureState(OSystem::Feature f) { } } -SdlGraphicsManager::MousePos* GPHGraphicsManager::getMouseCurState() { +SurfaceSdlGraphicsManager::MousePos *GPHGraphicsManager::getMouseCurState() { return &_mouseCurState; } -SdlGraphicsManager::VideoState* GPHGraphicsManager::getVideoMode() { +SurfaceSdlGraphicsManager::VideoState *GPHGraphicsManager::getVideoMode() { return &_videoMode; } @@ -576,7 +576,7 @@ void GPHGraphicsManager::warpMouse(int x, int y) { y = y / 2; } } - SdlGraphicsManager::warpMouse(x, y); + SurfaceSdlGraphicsManager::warpMouse(x, y); } void GPHGraphicsManager::adjustMouseEvent(const Common::Event &event) { diff --git a/backends/graphics/gph/gph-graphics.h b/backends/graphics/gph/gph-graphics.h index fc3dc5730d..45b8618569 100644 --- a/backends/graphics/gph/gph-graphics.h +++ b/backends/graphics/gph/gph-graphics.h @@ -23,7 +23,7 @@ #ifndef BACKENDS_GRAPHICS_GPH_H #define BACKENDS_GRAPHICS_GPH_H -#include "backends/graphics/sdl/sdl-graphics.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" #include "graphics/scaler/aspect.h" // for aspect2Real #include "graphics/scaler/downscaler.h" @@ -31,7 +31,7 @@ enum { GFX_HALF = 12 }; -class GPHGraphicsManager : public SdlGraphicsManager { +class GPHGraphicsManager : public SurfaceSdlGraphicsManager { public: GPHGraphicsManager(SdlEventSource *boss); @@ -53,8 +53,8 @@ public: void undrawMouse(); virtual void warpMouse(int x, int y); - SdlGraphicsManager::MousePos *getMouseCurState(); - SdlGraphicsManager::VideoState *getVideoMode(); + SurfaceSdlGraphicsManager::MousePos *getMouseCurState(); + SurfaceSdlGraphicsManager::VideoState *getVideoMode(); virtual void adjustMouseEvent(const Common::Event &event); }; diff --git a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp index 42db89ee33..732074b7e2 100644 --- a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp +++ b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp @@ -46,7 +46,7 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { }; LinuxmotoSdlGraphicsManager::LinuxmotoSdlGraphicsManager(SdlEventSource *sdlEventSource) - : SdlGraphicsManager(sdlEventSource) { + : SurfaceSdlGraphicsManager(sdlEventSource) { } const OSystem::GraphicsMode *LinuxmotoSdlGraphicsManager::getSupportedGraphicsModes() const { @@ -166,7 +166,7 @@ bool LinuxmotoSdlGraphicsManager::loadGFXMode() { _videoMode.hardwareHeight = effectiveScreenHeight(); } - return SdlGraphicsManager::loadGFXMode(); + return SurfaceSdlGraphicsManager::loadGFXMode(); } void LinuxmotoSdlGraphicsManager::drawMouse() { @@ -457,7 +457,7 @@ void LinuxmotoSdlGraphicsManager::showOverlay() { _mouseCurState.x = _mouseCurState.x / 2; _mouseCurState.y = _mouseCurState.y / 2; } - SdlGraphicsManager::showOverlay(); + SurfaceSdlGraphicsManager::showOverlay(); } void LinuxmotoSdlGraphicsManager::hideOverlay() { @@ -465,7 +465,7 @@ void LinuxmotoSdlGraphicsManager::hideOverlay() { _mouseCurState.x = _mouseCurState.x * 2; _mouseCurState.y = _mouseCurState.y * 2; } - SdlGraphicsManager::hideOverlay(); + SurfaceSdlGraphicsManager::hideOverlay(); } void LinuxmotoSdlGraphicsManager::warpMouse(int x, int y) { @@ -475,7 +475,7 @@ void LinuxmotoSdlGraphicsManager::warpMouse(int x, int y) { y = y / 2; } } - SdlGraphicsManager::warpMouse(x, y); + SurfaceSdlGraphicsManager::warpMouse(x, y); } void LinuxmotoSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) { diff --git a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h index c428f00447..938512f323 100644 --- a/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h +++ b/backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h @@ -23,9 +23,9 @@ #ifndef BACKENDS_GRAPHICS_SDL_LINUXMOTO_H #define BACKENDS_GRAPHICS_SDL_LINUXMOTO_H -#include "backends/graphics/sdl/sdl-graphics.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" -class LinuxmotoSdlGraphicsManager : public SdlGraphicsManager { +class LinuxmotoSdlGraphicsManager : public SurfaceSdlGraphicsManager { public: LinuxmotoSdlGraphicsManager(SdlEventSource *sdlEventSource); diff --git a/backends/graphics/opengl/gltexture.cpp b/backends/graphics/opengl/gltexture.cpp index 3d1027b44f..b7f5c90105 100644 --- a/backends/graphics/opengl/gltexture.cpp +++ b/backends/graphics/opengl/gltexture.cpp @@ -108,7 +108,7 @@ void GLTexture::refresh() { void GLTexture::allocBuffer(GLuint w, GLuint h) { _realWidth = w; _realHeight = h; - + if (w <= _textureWidth && h <= _textureHeight && !_refresh) // Already allocated a sufficiently large buffer return; diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index c0551de386..046be4c669 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -179,7 +179,7 @@ bool OpenGLGraphicsManager::setGraphicsMode(int mode) { } int OpenGLGraphicsManager::getGraphicsMode() const { - assert (_transactionMode == kTransactionNone); + assert(_transactionMode == kTransactionNone); return _videoMode.mode; } @@ -420,12 +420,12 @@ void OpenGLGraphicsManager::fillScreen(uint32 col) { } void OpenGLGraphicsManager::updateScreen() { - assert (_transactionMode == kTransactionNone); + assert(_transactionMode == kTransactionNone); internUpdateScreen(); } void OpenGLGraphicsManager::setShakePos(int shakeOffset) { - assert (_transactionMode == kTransactionNone); + assert(_transactionMode == kTransactionNone); _shakePos = shakeOffset; } @@ -440,7 +440,7 @@ void OpenGLGraphicsManager::clearFocusRectangle() { // void OpenGLGraphicsManager::showOverlay() { - assert (_transactionMode == kTransactionNone); + assert(_transactionMode == kTransactionNone); if (_overlayVisible) return; @@ -451,7 +451,7 @@ void OpenGLGraphicsManager::showOverlay() { } void OpenGLGraphicsManager::hideOverlay() { - assert (_transactionMode == kTransactionNone); + assert(_transactionMode == kTransactionNone); if (!_overlayVisible) return; @@ -483,7 +483,7 @@ void OpenGLGraphicsManager::grabOverlay(OverlayColor *buf, int pitch) { } void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { - assert (_transactionMode == kTransactionNone); + assert(_transactionMode == kTransactionNone); if (_overlayTexture == NULL) return; @@ -642,7 +642,7 @@ void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int void OpenGLGraphicsManager::setCursorPalette(const byte *colors, uint start, uint num) { assert(colors); - + // Save the cursor palette memcpy(_cursorPalette + start * 3, colors, num * 3); @@ -1315,7 +1315,7 @@ bool OpenGLGraphicsManager::notifyEvent(const Common::Event &event) { bool OpenGLGraphicsManager::saveScreenshot(const char *filename) { int width = _videoMode.hardwareWidth; int height = _videoMode.hardwareHeight; - + // A line of a BMP image must have a size divisible by 4. // We calculate the padding bytes needed here. // Since we use a 3 byte per pixel mode, we can use width % 4 here, since @@ -1358,7 +1358,7 @@ bool OpenGLGraphicsManager::saveScreenshot(const char *filename) { out.writeUint32LE(0); out.writeUint32LE(0); out.writeUint32LE(0); - out.writeUint32LE(0); + out.writeUint32LE(0); // Write pixel data to BMP out.write(pixels, lineSize * height); @@ -1413,7 +1413,7 @@ void OpenGLGraphicsManager::updateOSD() { int dstX = (_osdSurface.w - width) / 2; int dstY = (_osdSurface.h - height) / 2; - // Draw a dark gray rect + // Draw a dark gray rect (R = 40, G = 40, B = 40) const uint16 color = 0x294B; _osdSurface.fillRect(Common::Rect(dstX, dstY, dstX + width, dstY + height), color); @@ -1423,9 +1423,9 @@ void OpenGLGraphicsManager::updateOSD() { dstX, dstY + i * lineHeight + vOffset + lineSpacing, width, 0xFFFF, Graphics::kTextAlignCenter); } - + // Update the texture - _osdTexture->updateBuffer(_osdSurface.pixels, _osdSurface.pitch, 0, 0, + _osdTexture->updateBuffer(_osdSurface.pixels, _osdSurface.pitch, 0, 0, _osdSurface.w, _osdSurface.h); } #endif diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 463715aad8..56f7d92a12 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -185,7 +185,7 @@ protected: /** * Set the scale factor. - * + * * This can only be used in a GFX transaction. * * @param newScale New scale factor. @@ -332,7 +332,7 @@ protected: GLTexture *_osdTexture; Graphics::Surface _osdSurface; uint8 _osdAlpha; - uint32 _osdFadeStartTime; + uint32 _osdFadeStartTime; bool _requireOSDUpdate; enum { kOSDFadeOutDelay = 2 * 1000, diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 87457c3c08..bd7dd32e3b 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -54,6 +54,10 @@ OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager() SDL_ShowCursor(SDL_DISABLE); // Get desktop resolution + // TODO: In case the OpenGL manager is created *after* a plain SDL manager + // has been used, this will return the last setup graphics mode rather + // than the desktop resolution. We should really look into a way to + // properly retrieve the desktop resolution. const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo(); if (videoInfo->current_w > 0 && videoInfo->current_h > 0) { _desktopWidth = videoInfo->current_w; @@ -110,16 +114,16 @@ void OpenGLSdlGraphicsManager::detectSupportedFormats() { // use. const Graphics::PixelFormat RGBList[] = { #if defined(ENABLE_32BIT) - Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), // RGBA8888 + Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), // RGBA8888 #ifndef USE_GLES Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24), // ARGB8888 #endif - Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0), // RGB888 + Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0), // RGB888 #endif - Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), // RGB565 - Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0), // RGB5551 - Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), // RGB555 - Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), // RGBA4444 + Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), // RGB565 + Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0), // RGB5551 + Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), // RGB555 + Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), // RGBA4444 #ifndef USE_GLES Graphics::PixelFormat(2, 4, 4, 4, 4, 8, 4, 0, 12) // ARGB4444 #endif @@ -302,7 +306,7 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { int screenAspectRatio = _videoMode.screenWidth * 10000 / _videoMode.screenHeight; int desiredAspectRatio = getAspectRatio(); - + // Do not downscale dimensions, only enlarge them if needed if (screenAspectRatio > desiredAspectRatio) _videoMode.hardwareHeight = (_videoMode.overlayWidth * 10000 + 5000) / desiredAspectRatio; @@ -385,7 +389,7 @@ void OpenGLSdlGraphicsManager::internUpdateScreen() { OpenGLGraphicsManager::internUpdateScreen(); // Swap OpenGL buffers - SDL_GL_SwapBuffers(); + SDL_GL_SwapBuffers(); } #ifdef USE_OSD @@ -394,27 +398,27 @@ void OpenGLSdlGraphicsManager::displayModeChangedMsg() { if (newModeName) { const int scaleFactor = getScale(); - char buffer[128]; - sprintf(buffer, "%s: %s\n%d x %d -> %d x %d", + Common::String osdMessage = Common::String::format( + "%s: %s\n%d x %d -> %d x %d", _("Current display mode"), newModeName, _videoMode.screenWidth * scaleFactor, _videoMode.screenHeight * scaleFactor, _hwscreen->w, _hwscreen->h ); - displayMessageOnOSD(buffer); + displayMessageOnOSD(osdMessage.c_str()); } } void OpenGLSdlGraphicsManager::displayScaleChangedMsg() { - char buffer[128]; const int scaleFactor = getScale(); - sprintf(buffer, "%s: x%d\n%d x %d -> %d x %d", + Common::String osdMessage = Common::String::format( + "%s: x%d\n%d x %d -> %d x %d", _("Current scale"), scaleFactor, _videoMode.screenWidth, _videoMode.screenHeight, _videoMode.overlayWidth, _videoMode.overlayHeight ); - displayMessageOnOSD(buffer); + displayMessageOnOSD(osdMessage.c_str()); } #endif @@ -450,18 +454,18 @@ void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) { _ignoreResizeFrames = 10; #ifdef USE_OSD - char buffer[128]; + Common::String osdMessage; if (getFullscreenMode()) - sprintf(buffer, "%s\n%d x %d", + osdMessage = Common::String::format("%s\n%d x %d", _("Fullscreen mode"), _hwscreen->w, _hwscreen->h ); else - sprintf(buffer, "%s\n%d x %d", + osdMessage = Common::String::format("%s\n%d x %d", _("Windowed mode"), _hwscreen->w, _hwscreen->h ); - displayMessageOnOSD(buffer); + displayMessageOnOSD(osdMessage.c_str()); #endif } @@ -478,19 +482,19 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { // Alt-S create a screenshot if (event.kbd.keycode == 's') { - char filename[20]; + Common::String filename; for (int n = 0;; n++) { SDL_RWops *file; - sprintf(filename, "scummvm%05d.bmp", n); - file = SDL_RWFromFile(filename, "r"); + filename = Common::String::format("scummvm%05d.bmp", n); + file = SDL_RWFromFile(filename.c_str(), "r"); if (!file) break; SDL_RWclose(file); } - if (saveScreenshot(filename)) - debug("Saved screenshot '%s'", filename); + if (saveScreenshot(filename.c_str())) + debug("Saved screenshot '%s'", filename.c_str()); else warning("Could not save screenshot"); return true; @@ -511,18 +515,18 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { setFeatureState(OSystem::kFeatureAspectRatioCorrection, !getFeatureState(OSystem::kFeatureAspectRatioCorrection)); endGFXTransaction(); #ifdef USE_OSD - char buffer[128]; + Common::String osdMessage; if (getFeatureState(OSystem::kFeatureAspectRatioCorrection)) - sprintf(buffer, "%s\n%d x %d -> %d x %d", - _("Enabled aspect ratio correction"), + osdMessage = Common::String::format("%s\n%d x %d -> %d x %d", + _("Enabled aspect ratio correction"), _videoMode.screenWidth, _videoMode.screenHeight, _hwscreen->w, _hwscreen->h); else - sprintf(buffer, "%s\n%d x %d -> %d x %d", - _("Disabled aspect ratio correction"), + osdMessage = Common::String::format("%s\n%d x %d -> %d x %d", + _("Disabled aspect ratio correction"), _videoMode.screenWidth, _videoMode.screenHeight, _hwscreen->w, _hwscreen->h); - displayMessageOnOSD(buffer); + displayMessageOnOSD(osdMessage.c_str()); #endif internUpdateScreen(); return true; @@ -557,7 +561,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { // Check if the desktop resolution has been detected if (_desktopWidth > 0 && _desktopHeight > 0) // If the new scale factor is too big, do not scale - if (_videoMode.screenWidth * factor > _desktopWidth || + if (_videoMode.screenWidth * factor > _desktopWidth || _videoMode.screenHeight * factor > _desktopHeight) return false; @@ -607,7 +611,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { break; case Common::EVENT_KEYUP: return isHotkey(event); - // HACK: Handle special SDL event + // HACK: Handle special SDL event // The new screen size is saved on the mouse event as part of HACK, // there is no common resize event. case OSystem_SDL::kSdlEventResize: diff --git a/backends/graphics/openpandora/op-graphics.cpp b/backends/graphics/openpandora/op-graphics.cpp index c8617635a5..5f0301a0c8 100644 --- a/backends/graphics/openpandora/op-graphics.cpp +++ b/backends/graphics/openpandora/op-graphics.cpp @@ -32,7 +32,7 @@ #include "common/textconsole.h" OPGraphicsManager::OPGraphicsManager(SdlEventSource *sdlEventSource) - : SdlGraphicsManager(sdlEventSource) { + : SurfaceSdlGraphicsManager(sdlEventSource) { } bool OPGraphicsManager::loadGFXMode() { @@ -47,7 +47,7 @@ bool OPGraphicsManager::loadGFXMode() { if (_videoMode.screenHeight != 200 && _videoMode.screenHeight != 400) _videoMode.aspectRatioCorrection = false; - return SdlGraphicsManager::loadGFXMode(); + return SurfaceSdlGraphicsManager::loadGFXMode(); } #endif diff --git a/backends/graphics/openpandora/op-graphics.h b/backends/graphics/openpandora/op-graphics.h index 4bb89ca1e6..ed26df7475 100644 --- a/backends/graphics/openpandora/op-graphics.h +++ b/backends/graphics/openpandora/op-graphics.h @@ -23,7 +23,7 @@ #ifndef BACKENDS_GRAPHICS_OP_H #define BACKENDS_GRAPHICS_OP_H -#include "backends/graphics/sdl/sdl-graphics.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" #include "graphics/scaler/aspect.h" // for aspect2Real #include "graphics/scaler/downscaler.h" @@ -31,7 +31,7 @@ enum { GFX_HALF = 12 }; -class OPGraphicsManager : public SdlGraphicsManager { +class OPGraphicsManager : public SurfaceSdlGraphicsManager { public: OPGraphicsManager(SdlEventSource *sdlEventSource); @@ -53,8 +53,8 @@ public: // void undrawMouse(); // virtual void warpMouse(int x, int y); -// SdlGraphicsManager::MousePos *getMouseCurState(); -// SdlGraphicsManager::VideoState *getVideoMode(); +// SurfaceSdlGraphicsManager::MousePos *getMouseCurState(); +// SurfaceSdlGraphicsManager::VideoState *getVideoMode(); // virtual void adjustMouseEvent(const Common::Event &event); }; diff --git a/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp b/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp index f6832978a8..95e0875f55 100644 --- a/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp +++ b/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp @@ -29,7 +29,7 @@ #include "backends/graphics/samsungtvsdl/samsungtvsdl-graphics.h" SamsungTVSdlGraphicsManager::SamsungTVSdlGraphicsManager(SdlEventSource *sdlEventSource) - : SdlGraphicsManager(sdlEventSource) { + : SurfaceSdlGraphicsManager(sdlEventSource) { } bool SamsungTVSdlGraphicsManager::hasFeature(OSystem::Feature f) { @@ -41,7 +41,7 @@ bool SamsungTVSdlGraphicsManager::hasFeature(OSystem::Feature f) { void SamsungTVSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { switch (f) { case OSystem::kFeatureAspectRatioCorrection: - SdlGraphicsManager::setFeatureState(f, enable); + SurfaceSdlGraphicsManager::setFeatureState(f, enable); break; default: break; @@ -51,7 +51,7 @@ void SamsungTVSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enabl bool SamsungTVSdlGraphicsManager::getFeatureState(OSystem::Feature f) { switch (f) { case OSystem::kFeatureAspectRatioCorrection: - return SdlGraphicsManager::getFeatureState(f); + return SurfaceSdlGraphicsManager::getFeatureState(f); default: return false; } diff --git a/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.h b/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.h index dc65c3a696..2d0ff636f4 100644 --- a/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.h +++ b/backends/graphics/samsungtvsdl/samsungtvsdl-graphics.h @@ -25,9 +25,9 @@ #if defined(SAMSUNGTV) -#include "backends/graphics/sdl/sdl-graphics.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" -class SamsungTVSdlGraphicsManager : public SdlGraphicsManager { +class SamsungTVSdlGraphicsManager : public SurfaceSdlGraphicsManager { public: SamsungTVSdlGraphicsManager(SdlEventSource *sdlEventSource); diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 9063f55744..2d41ecead4 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -24,7 +24,7 @@ #if defined(SDL_BACKEND) -#include "backends/graphics/sdl/sdl-graphics.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" #include "backends/events/sdl/sdl-events.h" #include "backends/platform/sdl/sdl.h" #include "common/config-manager.h" @@ -120,7 +120,7 @@ static AspectRatio getDesiredAspectRatio() { } #endif -SdlGraphicsManager::SdlGraphicsManager(SdlEventSource *sdlEventSource) +SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource) : _sdlEventSource(sdlEventSource), #ifdef USE_OSD @@ -195,7 +195,7 @@ SdlGraphicsManager::SdlGraphicsManager(SdlEventSource *sdlEventSource) #endif } -SdlGraphicsManager::~SdlGraphicsManager() { +SurfaceSdlGraphicsManager::~SurfaceSdlGraphicsManager() { // Unregister the event observer if (g_system->getEventManager()->getEventDispatcher() != NULL) g_system->getEventManager()->getEventDispatcher()->unregisterObserver(this); @@ -214,12 +214,12 @@ SdlGraphicsManager::~SdlGraphicsManager() { free(_mouseData); } -void SdlGraphicsManager::initEventObserver() { +void SurfaceSdlGraphicsManager::initEventObserver() { // Register the graphics manager as a event observer g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 10, false); } -bool SdlGraphicsManager::hasFeature(OSystem::Feature f) { +bool SurfaceSdlGraphicsManager::hasFeature(OSystem::Feature f) { return (f == OSystem::kFeatureFullscreenMode) || (f == OSystem::kFeatureAspectRatioCorrection) || @@ -227,7 +227,7 @@ bool SdlGraphicsManager::hasFeature(OSystem::Feature f) { (f == OSystem::kFeatureIconifyWindow); } -void SdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { +void SurfaceSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { switch (f) { case OSystem::kFeatureFullscreenMode: setFullscreenMode(enable); @@ -248,7 +248,7 @@ void SdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { } } -bool SdlGraphicsManager::getFeatureState(OSystem::Feature f) { +bool SurfaceSdlGraphicsManager::getFeatureState(OSystem::Feature f) { assert(_transactionMode == kTransactionNone); switch (f) { @@ -263,23 +263,23 @@ bool SdlGraphicsManager::getFeatureState(OSystem::Feature f) { } } -const OSystem::GraphicsMode *SdlGraphicsManager::supportedGraphicsModes() { +const OSystem::GraphicsMode *SurfaceSdlGraphicsManager::supportedGraphicsModes() { return s_supportedGraphicsModes; } -const OSystem::GraphicsMode *SdlGraphicsManager::getSupportedGraphicsModes() const { +const OSystem::GraphicsMode *SurfaceSdlGraphicsManager::getSupportedGraphicsModes() const { return s_supportedGraphicsModes; } -int SdlGraphicsManager::getDefaultGraphicsMode() const { +int SurfaceSdlGraphicsManager::getDefaultGraphicsMode() const { return GFX_DOUBLESIZE; } -void SdlGraphicsManager::resetGraphicsScale() { +void SurfaceSdlGraphicsManager::resetGraphicsScale() { setGraphicsMode(s_gfxModeSwitchTable[_scalerType][0]); } -void SdlGraphicsManager::beginGFXTransaction() { +void SurfaceSdlGraphicsManager::beginGFXTransaction() { assert(_transactionMode == kTransactionNone); _transactionMode = kTransactionActive; @@ -297,7 +297,7 @@ void SdlGraphicsManager::beginGFXTransaction() { _oldVideoMode = _videoMode; } -OSystem::TransactionError SdlGraphicsManager::endGFXTransaction() { +OSystem::TransactionError SurfaceSdlGraphicsManager::endGFXTransaction() { int errors = OSystem::kTransactionSuccess; assert(_transactionMode != kTransactionNone); @@ -398,12 +398,12 @@ OSystem::TransactionError SdlGraphicsManager::endGFXTransaction() { } #ifdef USE_RGB_COLOR -Common::List<Graphics::PixelFormat> SdlGraphicsManager::getSupportedFormats() const { +Common::List<Graphics::PixelFormat> SurfaceSdlGraphicsManager::getSupportedFormats() const { assert(!_supportedFormats.empty()); return _supportedFormats; } -void SdlGraphicsManager::detectSupportedFormats() { +void SurfaceSdlGraphicsManager::detectSupportedFormats() { // Clear old list _supportedFormats.clear(); @@ -487,7 +487,7 @@ void SdlGraphicsManager::detectSupportedFormats() { } #endif -bool SdlGraphicsManager::setGraphicsMode(int mode) { +bool SurfaceSdlGraphicsManager::setGraphicsMode(int mode) { Common::StackLock lock(_graphicsMutex); assert(_transactionMode == kTransactionActive); @@ -557,7 +557,7 @@ bool SdlGraphicsManager::setGraphicsMode(int mode) { return true; } -void SdlGraphicsManager::setGraphicsModeIntern() { +void SurfaceSdlGraphicsManager::setGraphicsModeIntern() { Common::StackLock lock(_graphicsMutex); ScalerProc *newScalerProc = 0; @@ -630,12 +630,12 @@ void SdlGraphicsManager::setGraphicsModeIntern() { blitCursor(); } -int SdlGraphicsManager::getGraphicsMode() const { - assert (_transactionMode == kTransactionNone); +int SurfaceSdlGraphicsManager::getGraphicsMode() const { + assert(_transactionMode == kTransactionNone); return _videoMode.mode; } -void SdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) { +void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) { assert(_transactionMode == kTransactionActive); #ifdef USE_RGB_COLOR @@ -665,7 +665,7 @@ void SdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *f _transactionDetails.sizeChanged = true; } -int SdlGraphicsManager::effectiveScreenHeight() const { +int SurfaceSdlGraphicsManager::effectiveScreenHeight() const { return _videoMode.scaleFactor * (_videoMode.aspectRatioCorrection ? real2Aspect(_videoMode.screenHeight) @@ -713,7 +713,7 @@ static void fixupResolutionForAspectRatio(AspectRatio desiredAspectRatio, int &w height = bestMode->h; } -bool SdlGraphicsManager::loadGFXMode() { +bool SurfaceSdlGraphicsManager::loadGFXMode() { _forceFull = true; #if !defined(__MAEMO__) && !defined(DINGUX) && !defined(GPH_DEVICE) && !defined(LINUXMOTO) && !defined(OPENPANDORA) @@ -752,6 +752,12 @@ bool SdlGraphicsManager::loadGFXMode() { error("allocating _screen failed"); #endif + // SDL 1.2 palettes default to all black, + // SDL 1.3 palettes default to all white, + // Thus set our own default palette to all black. + // SDL_SetColors does nothing for non indexed surfaces. + SDL_SetColors(_screen, _currentPalette, 0, 256); + // // Create the surface that contains the scaled graphics in 16 bit mode // @@ -853,7 +859,7 @@ bool SdlGraphicsManager::loadGFXMode() { return true; } -void SdlGraphicsManager::unloadGFXMode() { +void SurfaceSdlGraphicsManager::unloadGFXMode() { if (_screen) { SDL_FreeSurface(_screen); _screen = NULL; @@ -888,7 +894,7 @@ void SdlGraphicsManager::unloadGFXMode() { DestroyScalers(); } -bool SdlGraphicsManager::hotswapGFXMode() { +bool SurfaceSdlGraphicsManager::hotswapGFXMode() { if (!_screen) return false; @@ -940,15 +946,15 @@ bool SdlGraphicsManager::hotswapGFXMode() { return true; } -void SdlGraphicsManager::updateScreen() { - assert (_transactionMode == kTransactionNone); +void SurfaceSdlGraphicsManager::updateScreen() { + assert(_transactionMode == kTransactionNone); Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends internUpdateScreen(); } -void SdlGraphicsManager::internUpdateScreen() { +void SurfaceSdlGraphicsManager::internUpdateScreen() { SDL_Surface *srcSurf, *origSurf; int height, width; ScalerProc *scalerProc; @@ -1191,14 +1197,14 @@ void SdlGraphicsManager::internUpdateScreen() { _mouseNeedsRedraw = false; } -bool SdlGraphicsManager::saveScreenshot(const char *filename) { +bool SurfaceSdlGraphicsManager::saveScreenshot(const char *filename) { assert(_hwscreen != NULL); Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends return SDL_SaveBMP(_hwscreen, filename) == 0; } -void SdlGraphicsManager::setFullscreenMode(bool enable) { +void SurfaceSdlGraphicsManager::setFullscreenMode(bool enable) { Common::StackLock lock(_graphicsMutex); if (_oldVideoMode.setup && _oldVideoMode.fullscreen == enable) @@ -1210,7 +1216,7 @@ void SdlGraphicsManager::setFullscreenMode(bool enable) { } } -void SdlGraphicsManager::setAspectRatioCorrection(bool enable) { +void SurfaceSdlGraphicsManager::setAspectRatioCorrection(bool enable) { Common::StackLock lock(_graphicsMutex); if (_oldVideoMode.setup && _oldVideoMode.aspectRatioCorrection == enable) @@ -1222,12 +1228,12 @@ void SdlGraphicsManager::setAspectRatioCorrection(bool enable) { } } -void SdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) { - assert (_transactionMode == kTransactionNone); +void SurfaceSdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int x, int y, int w, int h) { + assert(_transactionMode == kTransactionNone); assert(src); if (_screen == NULL) { - warning("SdlGraphicsManager::copyRectToScreen: _screen == NULL"); + warning("SurfaceSdlGraphicsManager::copyRectToScreen: _screen == NULL"); return; } @@ -1272,8 +1278,8 @@ void SdlGraphicsManager::copyRectToScreen(const byte *src, int pitch, int x, int SDL_UnlockSurface(_screen); } -Graphics::Surface *SdlGraphicsManager::lockScreen() { - assert (_transactionMode == kTransactionNone); +Graphics::Surface *SurfaceSdlGraphicsManager::lockScreen() { + assert(_transactionMode == kTransactionNone); // Lock the graphics mutex g_system->lockMutex(_graphicsMutex); @@ -1299,8 +1305,8 @@ Graphics::Surface *SdlGraphicsManager::lockScreen() { return &_framebuffer; } -void SdlGraphicsManager::unlockScreen() { - assert (_transactionMode == kTransactionNone); +void SurfaceSdlGraphicsManager::unlockScreen() { + assert(_transactionMode == kTransactionNone); // paranoia check assert(_screenIsLocked); @@ -1316,14 +1322,14 @@ void SdlGraphicsManager::unlockScreen() { g_system->unlockMutex(_graphicsMutex); } -void SdlGraphicsManager::fillScreen(uint32 col) { +void SurfaceSdlGraphicsManager::fillScreen(uint32 col) { Graphics::Surface *screen = lockScreen(); if (screen && screen->pixels) memset(screen->pixels, col, screen->h * screen->pitch); unlockScreen(); } -void SdlGraphicsManager::addDirtyRect(int x, int y, int w, int h, bool realCoordinates) { +void SurfaceSdlGraphicsManager::addDirtyRect(int x, int y, int w, int h, bool realCoordinates) { if (_forceFull) return; @@ -1391,15 +1397,15 @@ void SdlGraphicsManager::addDirtyRect(int x, int y, int w, int h, bool realCoord } } -int16 SdlGraphicsManager::getHeight() { +int16 SurfaceSdlGraphicsManager::getHeight() { return _videoMode.screenHeight; } -int16 SdlGraphicsManager::getWidth() { +int16 SurfaceSdlGraphicsManager::getWidth() { return _videoMode.screenWidth; } -void SdlGraphicsManager::setPalette(const byte *colors, uint start, uint num) { +void SurfaceSdlGraphicsManager::setPalette(const byte *colors, uint start, uint num) { assert(colors); #ifdef USE_RGB_COLOR @@ -1411,7 +1417,7 @@ void SdlGraphicsManager::setPalette(const byte *colors, uint start, uint num) { // But it could indicate a programming error, so let's warn about it. if (!_screen) - warning("SdlGraphicsManager::setPalette: _screen == NULL"); + warning("SurfaceSdlGraphicsManager::setPalette: _screen == NULL"); const byte *b = colors; uint i; @@ -1433,7 +1439,7 @@ void SdlGraphicsManager::setPalette(const byte *colors, uint start, uint num) { blitCursor(); } -void SdlGraphicsManager::grabPalette(byte *colors, uint start, uint num) { +void SurfaceSdlGraphicsManager::grabPalette(byte *colors, uint start, uint num) { assert(colors); #ifdef USE_RGB_COLOR @@ -1449,7 +1455,7 @@ void SdlGraphicsManager::grabPalette(byte *colors, uint start, uint num) { } } -void SdlGraphicsManager::setCursorPalette(const byte *colors, uint start, uint num) { +void SurfaceSdlGraphicsManager::setCursorPalette(const byte *colors, uint start, uint num) { assert(colors); const byte *b = colors; uint i; @@ -1464,13 +1470,13 @@ void SdlGraphicsManager::setCursorPalette(const byte *colors, uint start, uint n blitCursor(); } -void SdlGraphicsManager::setShakePos(int shake_pos) { - assert (_transactionMode == kTransactionNone); +void SurfaceSdlGraphicsManager::setShakePos(int shake_pos) { + assert(_transactionMode == kTransactionNone); _newShakePos = shake_pos; } -void SdlGraphicsManager::setFocusRectangle(const Common::Rect &rect) { +void SurfaceSdlGraphicsManager::setFocusRectangle(const Common::Rect &rect) { #ifdef USE_SDL_DEBUG_FOCUSRECT // Only enable focus rectangle debug code, when the user wants it if (!_enableFocusRectDebugCode) @@ -1480,7 +1486,7 @@ void SdlGraphicsManager::setFocusRectangle(const Common::Rect &rect) { _focusRect = rect; if (rect.left < 0 || rect.top < 0 || rect.right > _videoMode.screenWidth || rect.bottom > _videoMode.screenHeight) - warning("SdlGraphicsManager::setFocusRectangle: Got a rect which does not fit inside the screen bounds: %d,%d,%d,%d", rect.left, rect.top, rect.right, rect.bottom); + warning("SurfaceSdlGraphicsManager::setFocusRectangle: Got a rect which does not fit inside the screen bounds: %d,%d,%d,%d", rect.left, rect.top, rect.right, rect.bottom); // It's gross but we actually sometimes get rects, which are not inside the screen bounds, // thus we need to clip the rect here... @@ -1492,7 +1498,7 @@ void SdlGraphicsManager::setFocusRectangle(const Common::Rect &rect) { #endif } -void SdlGraphicsManager::clearFocusRectangle() { +void SurfaceSdlGraphicsManager::clearFocusRectangle() { #ifdef USE_SDL_DEBUG_FOCUSRECT // Only enable focus rectangle debug code, when the user wants it if (!_enableFocusRectDebugCode) @@ -1510,8 +1516,8 @@ void SdlGraphicsManager::clearFocusRectangle() { #pragma mark --- Overlays --- #pragma mark - -void SdlGraphicsManager::showOverlay() { - assert (_transactionMode == kTransactionNone); +void SurfaceSdlGraphicsManager::showOverlay() { + assert(_transactionMode == kTransactionNone); int x, y; @@ -1533,8 +1539,8 @@ void SdlGraphicsManager::showOverlay() { clearOverlay(); } -void SdlGraphicsManager::hideOverlay() { - assert (_transactionMode == kTransactionNone); +void SurfaceSdlGraphicsManager::hideOverlay() { + assert(_transactionMode == kTransactionNone); if (!_overlayVisible) return; @@ -1557,8 +1563,8 @@ void SdlGraphicsManager::hideOverlay() { _forceFull = true; } -void SdlGraphicsManager::clearOverlay() { - //assert (_transactionMode == kTransactionNone); +void SurfaceSdlGraphicsManager::clearOverlay() { + //assert(_transactionMode == kTransactionNone); Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends @@ -1590,8 +1596,8 @@ void SdlGraphicsManager::clearOverlay() { _forceFull = true; } -void SdlGraphicsManager::grabOverlay(OverlayColor *buf, int pitch) { - assert (_transactionMode == kTransactionNone); +void SurfaceSdlGraphicsManager::grabOverlay(OverlayColor *buf, int pitch) { + assert(_transactionMode == kTransactionNone); if (_overlayscreen == NULL) return; @@ -1610,8 +1616,8 @@ void SdlGraphicsManager::grabOverlay(OverlayColor *buf, int pitch) { SDL_UnlockSurface(_overlayscreen); } -void SdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { - assert (_transactionMode == kTransactionNone); +void SurfaceSdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { + assert(_transactionMode == kTransactionNone); if (_overlayscreen == NULL) return; @@ -1660,7 +1666,7 @@ void SdlGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch, i #pragma mark --- Mouse --- #pragma mark - -bool SdlGraphicsManager::showMouse(bool visible) { +bool SurfaceSdlGraphicsManager::showMouse(bool visible) { if (_mouseVisible == visible) return visible; @@ -1671,7 +1677,7 @@ bool SdlGraphicsManager::showMouse(bool visible) { return last; } -void SdlGraphicsManager::setMousePos(int x, int y) { +void SurfaceSdlGraphicsManager::setMousePos(int x, int y) { if (x != _mouseCurState.x || y != _mouseCurState.y) { _mouseNeedsRedraw = true; _mouseCurState.x = x; @@ -1679,7 +1685,7 @@ void SdlGraphicsManager::setMousePos(int x, int y) { } } -void SdlGraphicsManager::warpMouse(int x, int y) { +void SurfaceSdlGraphicsManager::warpMouse(int x, int y) { int y1 = y; // Don't change actual mouse position, when mouse is outside of our window (in case of windowed mode) @@ -1708,7 +1714,7 @@ void SdlGraphicsManager::warpMouse(int x, int y) { } } -void SdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { +void SurfaceSdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { #ifdef USE_RGB_COLOR if (!format) _cursorFormat = Graphics::PixelFormat::createFormatCLUT8(); @@ -1765,7 +1771,7 @@ void SdlGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hot blitCursor(); } -void SdlGraphicsManager::blitCursor() { +void SurfaceSdlGraphicsManager::blitCursor() { byte *dstPtr; const byte *srcPtr = _mouseData; #ifdef USE_RGB_COLOR @@ -1956,7 +1962,7 @@ static int cursorStretch200To240(uint8 *buf, uint32 pitch, int width, int height } #endif -void SdlGraphicsManager::undrawMouse() { +void SurfaceSdlGraphicsManager::undrawMouse() { const int x = _mouseBackup.x; const int y = _mouseBackup.y; @@ -1969,7 +1975,7 @@ void SdlGraphicsManager::undrawMouse() { addDirtyRect(x, y - _currentShakePos, _mouseBackup.w, _mouseBackup.h); } -void SdlGraphicsManager::drawMouse() { +void SurfaceSdlGraphicsManager::drawMouse() { if (!_mouseVisible || !_mouseSurface) { _mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0; return; @@ -2036,8 +2042,8 @@ void SdlGraphicsManager::drawMouse() { #pragma mark - #ifdef USE_OSD -void SdlGraphicsManager::displayMessageOnOSD(const char *msg) { - assert (_transactionMode == kTransactionNone); +void SurfaceSdlGraphicsManager::displayMessageOnOSD(const char *msg) { + assert(_transactionMode == kTransactionNone); assert(msg); Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends @@ -2123,7 +2129,7 @@ void SdlGraphicsManager::displayMessageOnOSD(const char *msg) { } #endif -bool SdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) { +bool SurfaceSdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) { // Ctrl-Alt-a toggles aspect ratio correction if (key == 'a') { @@ -2212,7 +2218,7 @@ bool SdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) { } } -bool SdlGraphicsManager::isScalerHotkey(const Common::Event &event) { +bool SurfaceSdlGraphicsManager::isScalerHotkey(const Common::Event &event) { if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { const bool isNormalNumber = (Common::KEYCODE_1 <= event.kbd.keycode && event.kbd.keycode <= Common::KEYCODE_9); const bool isKeypadNumber = (Common::KEYCODE_KP1 <= event.kbd.keycode && event.kbd.keycode <= Common::KEYCODE_KP9); @@ -2229,7 +2235,7 @@ bool SdlGraphicsManager::isScalerHotkey(const Common::Event &event) { return false; } -void SdlGraphicsManager::adjustMouseEvent(const Common::Event &event) { +void SurfaceSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) { if (!event.synthetic) { Common::Event newEvent(event); newEvent.synthetic = true; @@ -2243,7 +2249,7 @@ void SdlGraphicsManager::adjustMouseEvent(const Common::Event &event) { } } -void SdlGraphicsManager::toggleFullScreen() { +void SurfaceSdlGraphicsManager::toggleFullScreen() { beginGFXTransaction(); setFullscreenMode(!_videoMode.fullscreen); endGFXTransaction(); @@ -2255,7 +2261,7 @@ void SdlGraphicsManager::toggleFullScreen() { #endif } -bool SdlGraphicsManager::notifyEvent(const Common::Event &event) { +bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) { switch ((int)event.type) { case Common::EVENT_KEYDOWN: // Alt-Return and Alt-Enter toggle full screen mode diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index 9627ab23a3..cd8710d443 100644 --- a/backends/graphics/sdl/sdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -20,8 +20,8 @@ * */ -#ifndef BACKENDS_GRAPHICS_SDL_H -#define BACKENDS_GRAPHICS_SDL_H +#ifndef BACKENDS_GRAPHICS_SURFACESDL_GRAPHICS_H +#define BACKENDS_GRAPHICS_SURFACESDL_GRAPHICS_H #include "backends/graphics/graphics.h" #include "graphics/pixelformat.h" @@ -74,10 +74,10 @@ public: /** * SDL graphics manager */ -class SdlGraphicsManager : public GraphicsManager, public Common::EventObserver { +class SurfaceSdlGraphicsManager : public GraphicsManager, public Common::EventObserver { public: - SdlGraphicsManager(SdlEventSource *sdlEventSource); - virtual ~SdlGraphicsManager(); + SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource); + virtual ~SurfaceSdlGraphicsManager(); virtual void initEventObserver(); @@ -100,7 +100,7 @@ public: virtual void beginGFXTransaction(); virtual OSystem::TransactionError endGFXTransaction(); - + virtual int16 getHeight(); virtual int16 getWidth(); @@ -132,7 +132,7 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); virtual void setCursorPalette(const byte *colors, uint start, uint num); - + #ifdef USE_OSD virtual void displayMessageOnOSD(const char *msg); #endif @@ -149,7 +149,7 @@ protected: /** Transparency level of the OSD */ uint8 _osdAlpha; /** When to start the fade out */ - uint32 _osdFadeStartTime; + uint32 _osdFadeStartTime; /** Enum with OSD options */ enum { kOSDFadeOutDelay = 2 * 1000, /** < Delay before the OSD is faded out (in milliseconds) */ diff --git a/backends/graphics/symbiansdl/symbiansdl-graphics.cpp b/backends/graphics/symbiansdl/symbiansdl-graphics.cpp index a88c8a8ffe..4a9a219641 100644 --- a/backends/graphics/symbiansdl/symbiansdl-graphics.cpp +++ b/backends/graphics/symbiansdl/symbiansdl-graphics.cpp @@ -28,7 +28,7 @@ #include "backends/platform/symbian/src/SymbianActions.h" SymbianSdlGraphicsManager::SymbianSdlGraphicsManager(SdlEventSource *sdlEventSource) - : SdlGraphicsManager(sdlEventSource) { + : SurfaceSdlGraphicsManager(sdlEventSource) { } int SymbianSdlGraphicsManager::getDefaultGraphicsMode() const { @@ -47,7 +47,7 @@ const OSystem::GraphicsMode *SymbianSdlGraphicsManager::getSupportedGraphicsMode // make sure we always go to normal, even if the string might be set wrong! bool SymbianSdlGraphicsManager::setGraphicsMode(int /*name*/) { // let parent OSystem_SDL handle it - return SdlGraphicsManager::setGraphicsMode(getDefaultGraphicsMode()); + return SurfaceSdlGraphicsManager::setGraphicsMode(getDefaultGraphicsMode()); } bool SymbianSdlGraphicsManager::hasFeature(OSystem::Feature f) { @@ -72,7 +72,7 @@ void SymbianSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) GUI::Actions::Instance()->beginMapping(enable); break; default: - SdlGraphicsManager::setFeatureState(f, enable); + SurfaceSdlGraphicsManager::setFeatureState(f, enable); } } diff --git a/backends/graphics/symbiansdl/symbiansdl-graphics.h b/backends/graphics/symbiansdl/symbiansdl-graphics.h index 1bad32a9b6..404ca87a0a 100644 --- a/backends/graphics/symbiansdl/symbiansdl-graphics.h +++ b/backends/graphics/symbiansdl/symbiansdl-graphics.h @@ -23,9 +23,9 @@ #ifndef BACKENDS_GRAPHICS_SYMBIAN_SDL_H #define BACKENDS_GRAPHICS_SYMBIAN_SDL_H -#include "backends/graphics/sdl/sdl-graphics.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" -class SymbianSdlGraphicsManager : public SdlGraphicsManager { +class SymbianSdlGraphicsManager : public SurfaceSdlGraphicsManager { public: SymbianSdlGraphicsManager(SdlEventSource *sdlEventSource); diff --git a/backends/graphics/wincesdl/wincesdl-graphics.cpp b/backends/graphics/wincesdl/wincesdl-graphics.cpp index 8ba7b5821d..2ca78cedde 100644 --- a/backends/graphics/wincesdl/wincesdl-graphics.cpp +++ b/backends/graphics/wincesdl/wincesdl-graphics.cpp @@ -43,8 +43,8 @@ #include "backends/platform/wince/CEgui/ItemAction.h" WINCESdlGraphicsManager::WINCESdlGraphicsManager(SdlEventSource *sdlEventSource) - : SdlGraphicsManager(sdlEventSource), - _panelInitialized(false), _noDoubleTapRMB(false), + : SurfaceSdlGraphicsManager(sdlEventSource), + _panelInitialized(false), _noDoubleTapRMB(false), _noDoubleTapPT(false), _toolbarHighDrawn(false), _newOrientation(0), _orientationLandscape(0), _panelVisible(true), _saveActiveToolbar(NAME_MAIN_PANEL), _panelStateForced(false), _canBeAspectScaled(false), _scalersChanged(false), _saveToolbarState(false), @@ -149,7 +149,7 @@ void WINCESdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { return; default: - SdlGraphicsManager::setFeatureState(f, enable); + SurfaceSdlGraphicsManager::setFeatureState(f, enable); } } @@ -160,7 +160,7 @@ bool WINCESdlGraphicsManager::getFeatureState(OSystem::Feature f) { case OSystem::kFeatureVirtualKeyboard: return (_panelStateForced); default: - return SdlGraphicsManager::getFeatureState(f); + return SurfaceSdlGraphicsManager::getFeatureState(f); } } @@ -204,7 +204,7 @@ void WINCESdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelForm _videoMode.overlayWidth = w; _videoMode.overlayHeight = h; - SdlGraphicsManager::initSize(w, h, format); + SurfaceSdlGraphicsManager::initSize(w, h, format); if (_scalersChanged) { unloadGFXMode(); @@ -478,6 +478,9 @@ void WINCESdlGraphicsManager::update_game_settings() { if (ConfMan.hasKey("no_doubletap_rightclick")) _noDoubleTapRMB = ConfMan.getBool("no_doubletap_rightclick"); + + if (ConfMan.hasKey("no_doubletap_paneltoggle")) + _noDoubleTapPT = ConfMan.getBool("no_doubletap_paneltoggle"); } void WINCESdlGraphicsManager::internUpdateScreen() { @@ -1185,7 +1188,7 @@ void WINCESdlGraphicsManager::setMousePos(int x, int y) { Graphics::Surface *WINCESdlGraphicsManager::lockScreen() { // Make sure mouse pointer is not painted over the playfield at the time of locking undrawMouse(); - return SdlGraphicsManager::lockScreen(); + return SurfaceSdlGraphicsManager::lockScreen(); } void WINCESdlGraphicsManager::showOverlay() { @@ -1293,7 +1296,7 @@ void WINCESdlGraphicsManager::warpMouse(int x, int y) { } void WINCESdlGraphicsManager::unlockScreen() { - SdlGraphicsManager::unlockScreen(); + SurfaceSdlGraphicsManager::unlockScreen(); } void WINCESdlGraphicsManager::internDrawMouse() { @@ -1468,7 +1471,7 @@ void WINCESdlGraphicsManager::addDirtyRect(int x, int y, int w, int h, bool mous if (_forceFull || _paletteDirtyEnd) return; - SdlGraphicsManager::addDirtyRect(x, y, w, h, false); + SurfaceSdlGraphicsManager::addDirtyRect(x, y, w, h, false); } void WINCESdlGraphicsManager::swap_panel_visibility() { @@ -1599,6 +1602,19 @@ void WINCESdlGraphicsManager::swap_mouse_visibility() { undrawMouse(); } +void WINCESdlGraphicsManager::init_panel() { + _panelVisible = true; + if (_panelInitialized) { + _toolbarHandler.setVisible(true); + _toolbarHandler.setActive(NAME_MAIN_PANEL); + } +} + +void WINCESdlGraphicsManager::reset_panel() { + _panelVisible = false; + _toolbarHandler.setVisible(false); +} + // Smartphone actions void WINCESdlGraphicsManager::initZones() { int i; diff --git a/backends/graphics/wincesdl/wincesdl-graphics.h b/backends/graphics/wincesdl/wincesdl-graphics.h index 2727bc0d27..92894e0dcd 100644 --- a/backends/graphics/wincesdl/wincesdl-graphics.h +++ b/backends/graphics/wincesdl/wincesdl-graphics.h @@ -23,7 +23,7 @@ #ifndef BACKENDS_GRAPHICS_WINCE_SDL_H #define BACKENDS_GRAPHICS_WINCE_SDL_H -#include "backends/graphics/sdl/sdl-graphics.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" #include "backends/platform/wince/CEgui/CEGUI.h" // Internal GUI names @@ -39,7 +39,7 @@ extern bool _hasSmartphoneResolution; -class WINCESdlGraphicsManager : public SdlGraphicsManager { +class WINCESdlGraphicsManager : public SurfaceSdlGraphicsManager { public: WINCESdlGraphicsManager(SdlEventSource *sdlEventSource); @@ -90,6 +90,8 @@ public: void swap_zoom_up(); void swap_zoom_down(); void swap_mouse_visibility(); + void init_panel(); + void reset_panel(); void swap_freeLook(); bool getFreeLookState(); @@ -115,6 +117,7 @@ public: bool _panelInitialized; // only initialize the toolbar once bool _noDoubleTapRMB; // disable double tap -> rmb click + bool _noDoubleTapPT; // disable double tap for toolbar toggling CEGUI::ToolbarHandler _toolbarHandler; diff --git a/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp b/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp index 001389b1c0..3e5b9940e0 100644 --- a/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp +++ b/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp @@ -28,7 +28,7 @@ DoubleBufferSDLMixerManager::DoubleBufferSDLMixerManager() : _soundMutex(0), _soundCond(0), _soundThread(0), _soundThreadIsRunning(false), _soundThreadShouldQuit(false) { - + } DoubleBufferSDLMixerManager::~DoubleBufferSDLMixerManager() { diff --git a/backends/mixer/sdl/sdl-mixer.cpp b/backends/mixer/sdl/sdl-mixer.cpp index f0b0885dd7..001309a777 100644 --- a/backends/mixer/sdl/sdl-mixer.cpp +++ b/backends/mixer/sdl/sdl-mixer.cpp @@ -70,7 +70,7 @@ void SdlMixerManager::init() { warning("Could not open audio device: %s", SDL_GetError()); _mixer = new Audio::MixerImpl(g_system, desired.freq); - assert(_mixer); + assert(_mixer); _mixer->setReady(false); } else { debug(1, "Output sample rate: %d Hz", _obtained.freq); @@ -84,8 +84,12 @@ void SdlMixerManager::init() { if (_obtained.format != desired.format) warning("SDL mixer sound format: %d differs from desired: %d", _obtained.format, desired.format); +#ifndef __SYMBIAN32__ + // The SymbianSdlMixerManager does stereo->mono downmixing, + // but otherwise we require stereo output. if (_obtained.channels != 2) error("SDL mixer output requires stereo output device"); +#endif _mixer = new Audio::MixerImpl(g_system, _obtained.freq); assert(_mixer); diff --git a/backends/mixer/sdl/sdl-mixer.h b/backends/mixer/sdl/sdl-mixer.h index 82ffa4f901..6fee26bd1f 100644 --- a/backends/mixer/sdl/sdl-mixer.h +++ b/backends/mixer/sdl/sdl-mixer.h @@ -73,7 +73,7 @@ protected: bool _audioSuspended; /** - * Returns the desired audio specification + * Returns the desired audio specification */ virtual SDL_AudioSpec getAudioSpec(uint32 rate); diff --git a/backends/mixer/sdl13/sdl13-mixer.cpp b/backends/mixer/sdl13/sdl13-mixer.cpp new file mode 100644 index 0000000000..84777c8bab --- /dev/null +++ b/backends/mixer/sdl13/sdl13-mixer.cpp @@ -0,0 +1,109 @@ +/* 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 "common/scummsys.h" + +#if defined(SDL_BACKEND) + +#include "backends/mixer/sdl13/sdl13-mixer.h" +#include "common/debug.h" +#include "common/system.h" +#include "common/config-manager.h" +#include "common/textconsole.h" + +#ifdef GP2X +#define SAMPLES_PER_SEC 11025 +#else +#define SAMPLES_PER_SEC 22050 +#endif +//#define SAMPLES_PER_SEC 44100 + +Sdl13MixerManager::Sdl13MixerManager() + : + SdlMixerManager(), + _device(0) { + +} + +Sdl13MixerManager::~Sdl13MixerManager() { + _mixer->setReady(false); + + SDL_CloseAudioDevice(_device); + + delete _mixer; +} + +void Sdl13MixerManager::init() { + // Start SDL Audio subsystem + if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) { + error("Could not initialize SDL: %s", SDL_GetError()); + } + + // Get the desired audio specs + SDL_AudioSpec desired = getAudioSpec(SAMPLES_PER_SEC); + + // Start SDL audio with the desired specs + _device = SDL_OpenAudioDevice(NULL, 0, &desired, &_obtained, + SDL_AUDIO_ALLOW_FREQUENCY_CHANGE); + + if (_device <= 0) { + warning("Could not open audio device: %s", SDL_GetError()); + + _mixer = new Audio::MixerImpl(g_system, desired.freq); + assert(_mixer); + _mixer->setReady(false); + } else { + debug(1, "Output sample rate: %d Hz", _obtained.freq); + + _mixer = new Audio::MixerImpl(g_system, _obtained.freq); + assert(_mixer); + _mixer->setReady(true); + + startAudio(); + } +} + +void Sdl13MixerManager::startAudio() { + // Start the sound system + SDL_PauseAudioDevice(_device, 0); +} + +void Sdl13MixerManager::suspendAudio() { + SDL_CloseAudioDevice(_device); + _audioSuspended = true; +} + +int Sdl13MixerManager::resumeAudio() { + if (!_audioSuspended) + return -2; + + _device = SDL_OpenAudioDevice(NULL, 0, &_obtained, NULL, 0); + if (_device <= 0) { + return -1; + } + + SDL_PauseAudioDevice(_device, 0); + _audioSuspended = false; + return 0; +} + +#endif diff --git a/backends/mixer/sdl13/sdl13-mixer.h b/backends/mixer/sdl13/sdl13-mixer.h new file mode 100644 index 0000000000..9e07ea8673 --- /dev/null +++ b/backends/mixer/sdl13/sdl13-mixer.h @@ -0,0 +1,67 @@ +/* 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. + * + */ + +#ifndef BACKENDS_MIXER_SDL13_H +#define BACKENDS_MIXER_SDL13_H + +#include "backends/mixer/sdl/sdl-mixer.h" + +/** + * SDL mixer manager. It wraps the actual implementation + * of the Audio:Mixer used by the engine, and setups + * the SDL audio subsystem and the callback for the + * audio mixer implementation. + */ +class Sdl13MixerManager : public SdlMixerManager { +public: + Sdl13MixerManager(); + virtual ~Sdl13MixerManager(); + + /** + * Initialize and setups the mixer + */ + virtual void init(); + + /** + * Pauses the audio system + */ + virtual void suspendAudio(); + + /** + * Resumes the audio system + */ + virtual int resumeAudio(); + +protected: + + /** + * The opened SDL audio device + */ + SDL_AudioDeviceID _device; + + /** + * Starts SDL audio + */ + virtual void startAudio(); +}; + +#endif diff --git a/backends/mixer/wincesdl/wincesdl-mixer.cpp b/backends/mixer/wincesdl/wincesdl-mixer.cpp index 36ac310ad9..c7659cb0f5 100644 --- a/backends/mixer/wincesdl/wincesdl-mixer.cpp +++ b/backends/mixer/wincesdl/wincesdl-mixer.cpp @@ -131,15 +131,20 @@ uint32 WINCESdlMixerManager::compute_sample_rate() { ConfMan.setBool("FM_medium_quality", true); ConfMan.flushToDisk(); } + } else { + if (!ConfMan.hasKey("FM_high_quality") && !ConfMan.hasKey("FM_medium_quality")) { + ConfMan.setBool("FM_high_quality", true); + ConfMan.flushToDisk(); + } } // See if the output frequency is forced by the game if (gameid == "ft" || gameid == "dig" || gameid == "comi" || gameid == "queen" || gameid == "sword" || gameid == "agi") sampleRate = SAMPLES_PER_SEC_NEW; else { - if (ConfMan.hasKey("high_sample_rate") && ConfMan.getBool("high_sample_rate")) - sampleRate = SAMPLES_PER_SEC_NEW; - else + if (ConfMan.hasKey("high_sample_rate") && !ConfMan.getBool("high_sample_rate")) sampleRate = SAMPLES_PER_SEC_OLD; + else + sampleRate = SAMPLES_PER_SEC_NEW; } #ifdef USE_VORBIS diff --git a/backends/modular-backend.h b/backends/modular-backend.h index 3593130bf5..b864da0df5 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -30,17 +30,17 @@ class MutexManager; /** * Base class for modular backends. - * + * * It wraps most functions to their manager equivalent, but not * all OSystem functions are implemented here. - * + * * A backend derivated from this class, will need to implement * these functions on its own: * OSystem::pollEvent() * OSystem::getMillis() * OSystem::delayMillis() * OSystem::getTimeAndDate() - * + * * And, it should also initialize all the managers variables * declared in this class, or override their related functions. */ @@ -107,11 +107,11 @@ public: /** @name Events and Time */ //@{ - + virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; } //@} - + /** @name Mutex handling */ //@{ diff --git a/backends/module.mk b/backends/module.mk index d1feae4317..63774cc4d0 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -60,14 +60,19 @@ endif # derive from the SDL backend, and they all need the following files. ifdef SDL_BACKEND MODULE_OBJS += \ - audiocd/sdl/sdl-audiocd.o \ events/sdl/sdl-events.o \ - graphics/sdl/sdl-graphics.o \ + graphics/surfacesdl/surfacesdl-graphics.o \ mixer/doublebuffersdl/doublebuffersdl-mixer.o \ mixer/sdl/sdl-mixer.o \ mutex/sdl/sdl-mutex.o \ plugins/sdl/sdl-provider.o \ timer/sdl/sdl-timer.o + +# SDL 1.3 removed audio CD support +ifndef USE_SDL13 +MODULE_OBJS += \ + audiocd/sdl/sdl-audiocd.o +endif endif ifdef POSIX @@ -75,7 +80,8 @@ MODULE_OBJS += \ fs/posix/posix-fs.o \ fs/posix/posix-fs-factory.o \ plugins/posix/posix-provider.o \ - saves/posix/posix-saves.o + saves/posix/posix-saves.o \ + taskbar/unity/unity-taskbar.o endif ifdef MACOSX @@ -89,7 +95,8 @@ MODULE_OBJS += \ fs/windows/windows-fs.o \ fs/windows/windows-fs-factory.o \ midi/windows.o \ - plugins/win32/win32-provider.o + plugins/win32/win32-provider.o \ + taskbar/win32/win32-taskbar.o endif ifdef AMIGAOS @@ -99,6 +106,15 @@ MODULE_OBJS += \ midi/camd.o endif +ifdef PLAYSTATION3 +MODULE_OBJS += \ + fs/posix/posix-fs.o \ + fs/posix/posix-fs-factory.o \ + fs/ps3/ps3-fs-factory.o \ + events/ps3sdl/ps3sdl-events.o \ + mixer/sdl13/sdl13-mixer.o +endif + ifeq ($(BACKEND),ds) MODULE_OBJS += \ fs/ds/ds-fs.o \ diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 90660cf82c..17c7d4f9cb 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -423,7 +423,7 @@ void OSystem_Android::setFeatureState(Feature f, bool enable) { showVirtualKeyboard(enable); break; case kFeatureCursorPalette: - _use_mouse_palette = !enable; + _use_mouse_palette = enable; if (!enable) disableCursorPalette(); break; diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp index c4daf24e16..e3b4ef7401 100644 --- a/backends/platform/android/jni.cpp +++ b/backends/platform/android/jni.cpp @@ -22,8 +22,9 @@ #if defined(__ANDROID__) -// Allow use of stuff in <time.h> +// Allow use of stuff in <time.h> and abort() #define FORBIDDEN_SYMBOL_EXCEPTION_time_h +#define FORBIDDEN_SYMBOL_EXCEPTION_abort // Disable printf override in common/forbidden.h to avoid // clashes with log.h from the Android SDK. diff --git a/backends/platform/dc/dc-fs.cpp b/backends/platform/dc/dc-fs.cpp index ac709f62b9..c46f9df093 100644 --- a/backends/platform/dc/dc-fs.cpp +++ b/backends/platform/dc/dc-fs.cpp @@ -124,7 +124,7 @@ bool RoninCDDirectoryNode::getChildren(AbstractFSList &myList, ListMode mode, bo if (mode == Common::FSNode::kListFilesOnly) continue; - myList.push_back(new RoninCDDirectoryNode(newPath+"/")); + myList.push_back(new RoninCDDirectoryNode(newPath)); } else { // Honor the chosen mode if (mode == Common::FSNode::kListDirectoriesOnly) diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp index 3faf0185ad..06738a687d 100644 --- a/backends/platform/dc/dcmain.cpp +++ b/backends/platform/dc/dcmain.cpp @@ -234,7 +234,7 @@ void OSystem_Dreamcast::logMessage(LogMessageType::Type type, const char *messag namespace DC_Flash { static int syscall_info_flash(int sect, int *info) { - return (*(int (**)(int, void*, int, int))0x8c0000b8)(sect,info,0,0); + return (*(int (**)(int, void*, int, int))0x8c0000b8)(sect,info,0,0); } static int syscall_read_flash(int offs, void *buf, int cnt) @@ -255,24 +255,24 @@ namespace DC_Flash { } return (unsigned short)~n; } - + static int flash_read_sector(int partition, int sec, unsigned char *dst) { int s, r, n, b, bmb, got=0; int info[2]; char buf[64]; char bm[64]; - + if((r = syscall_info_flash(partition, info))<0) return r; - + if((r = syscall_read_flash(info[0], buf, 64))<0) return r; - + if(memcmp(buf, "KATANA_FLASH", 12) || buf[16] != partition || buf[17] != 0) return -2; - + n = (info[1]>>6)-1-((info[1] + 0x7fff)>>15); bmb = n+1; for(b = 0; b < n; b++) { diff --git a/backends/platform/dc/plugins.cpp b/backends/platform/dc/plugins.cpp index fff3c147ec..2942a4f155 100644 --- a/backends/platform/dc/plugins.cpp +++ b/backends/platform/dc/plugins.cpp @@ -51,7 +51,7 @@ static void drawPluginProgress(const Common::String &filename) ta_begin_frame(); draw_solid_quad(80.0, 270.0, 560.0, 300.0, 0xff808080, 0xff808080, 0xff808080, 0xff808080); - draw_solid_quad(85.0, 275.0, 555.0, 295.0, + draw_solid_quad(85.0, 275.0, 555.0, 295.0, 0xff202020, 0xff202020, 0xff202020, 0xff202020); draw_solid_quad(85.0, 275.0, 85.0+470.0*ffree, 295.0, fcol, fcol, fcol, fcol); diff --git a/backends/platform/dc/selector.cpp b/backends/platform/dc/selector.cpp index 859f2a40ed..339e5df62d 100644 --- a/backends/platform/dc/selector.cpp +++ b/backends/platform/dc/selector.cpp @@ -185,12 +185,24 @@ static void makeDefIcon(Icon &icon) icon.load(scummvm_icon, sizeof(scummvm_icon)); } +static bool sameOrSubdir(const char *dir1, const char *dir2) +{ + int l1 = strlen(dir1), l2 = strlen(dir2); + if (l1<=l2) + return !strcmp(dir1, dir2); + else + return !memcmp(dir1, dir2, l2); +} + static bool uniqueGame(const char *base, const char *dir, Common::Language lang, Common::Platform plf, Game *games, int cnt) { while (cnt--) - if (!strcmp(dir, games->dir) && + if (/*Don't detect the same game in a subdir, + this is a workaround for the detector bug in toon... */ + sameOrSubdir(dir, games->dir) && + /*!strcmp(dir, games->dir) &&*/ !stricmp(base, games->filename_base) && lang == games->language && plf == games->platform) @@ -237,19 +249,24 @@ static int findGames(Game *games, int max, bool use_ini) } while ((curr_game < max || use_ini) && curr_dir < num_dirs) { - strncpy(dirs[curr_dir].name, dirs[curr_dir].node.getPath().c_str(), 252); - dirs[curr_dir].name[251] = '\0'; + strncpy(dirs[curr_dir].name, dirs[curr_dir].node.getPath().c_str(), 251); + dirs[curr_dir].name[250] = '\0'; + if (!dirs[curr_dir].name[0] || + dirs[curr_dir].name[strlen(dirs[curr_dir].name)-1] != '/') + strcat(dirs[curr_dir].name, "/"); dirs[curr_dir].deficon[0] = '\0'; Common::FSList files, fslist; dirs[curr_dir++].node.getChildren(fslist, Common::FSNode::kListAll); for (Common::FSList::const_iterator entry = fslist.begin(); entry != fslist.end(); ++entry) { if (entry->isDirectory()) { - if (!use_ini && num_dirs < MAX_DIR && - strcasecmp(entry->getDisplayName().c_str(), "install")) { + if (!use_ini && num_dirs < MAX_DIR) { dirs[num_dirs].node = *entry; num_dirs++; } + /* Toonstruck detector needs directories to be present too */ + if(!use_ini) + files.push_back(*entry); } else if (isIcon(*entry)) strcpy(dirs[curr_dir-1].deficon, entry->getDisplayName().c_str()); diff --git a/backends/platform/dingux/dingux.cpp b/backends/platform/dingux/dingux.cpp index 1af53aeae1..674c2ea780 100644 --- a/backends/platform/dingux/dingux.cpp +++ b/backends/platform/dingux/dingux.cpp @@ -33,7 +33,7 @@ void OSystem_SDL_Dingux::initBackend() { // Create the graphics manager if (_graphicsManager == 0) { - _graphicsManager = new DINGUXSdlGraphicsManager(_eventSource); + _graphicsManager = new DINGUXSdlGraphicsManager(_eventSource); } // Call parent implementation of this method diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp index db9b1c2609..03729c5e6e 100644 --- a/backends/platform/ds/arm9/source/gbampsave.cpp +++ b/backends/platform/ds/arm9/source/gbampsave.cpp @@ -52,7 +52,7 @@ Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &f fileSpec += filename; // consolePrintf("Opening the file: %s\n", fileSpec.c_str()); - + Common::WriteStream *stream = DS::DSFileStream::makeFromPath(fileSpec, true); // Use a write buffer stream = Common::wrapBufferedWriteStream(stream, SAVE_BUFFER_SIZE); @@ -66,7 +66,7 @@ Common::InSaveFile *GBAMPSaveFileManager::openForLoading(const Common::String &f fileSpec += filename; // consolePrintf("Opening the file: %s\n", fileSpec.c_str()); - + return DS::DSFileStream::makeFromPath(fileSpec, false); } diff --git a/backends/platform/gph/devices/gp2x/mmuhack/readme.txt b/backends/platform/gph/devices/gp2x/mmuhack/README index bea49d7d6d..6db7d81845 100644 --- a/backends/platform/gph/devices/gp2x/mmuhack/readme.txt +++ b/backends/platform/gph/devices/gp2x/mmuhack/README @@ -1,3 +1,10 @@ +PLEASE NOTE: + +The binary object 'mmuhack.o' is stored in the source tree as it is very awkward to +build it manually each time and would require the use of 2 toolchains to do so. + +Notes on how to rebuild from the included source can be found below. + About ----- @@ -107,4 +114,3 @@ Credits Original idea/implementation: Squidge (this whole thing is also known as squidgehack) Kernel module: NK Documentation: notaz - diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 9325ed50bf..4bc567c39d 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -242,6 +242,18 @@ void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priorit } } +void OSystem_IPHONE::logMessage(LogMessageType::Type type, const char *message) { + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); +} + void iphone_main(int argc, char *argv[]) { //OSystem_IPHONE::migrateApp(); diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 14325f8090..37896cceeb 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -180,6 +180,8 @@ public: virtual Common::String getDefaultConfigFileName(); + virtual void logMessage(LogMessageType::Type type, const char *message); + protected: void internUpdateScreen(); void dirtyFullScreen(); diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index dfa8f58cce..354f25a1cf 100644 --- a/backends/platform/n64/osys_n64.h +++ b/backends/platform/n64/osys_n64.h @@ -107,7 +107,7 @@ protected: // FIXME: This must be left as "int" for now, to fix the sign-comparison problem // there is a little more work involved than an int->uint change int _cursorWidth, _cursorHeight; - + int _cursorKeycolor; uint16 _overlayHeight, _overlayWidth; @@ -199,6 +199,7 @@ public: virtual Audio::Mixer *getMixer(); virtual void getTimeAndDate(TimeDate &t) const; virtual void setTimerCallback(TimerProc callback, int interval); + virtual void logMessage(LogMessageType::Type type, const char *message); void rebuildOffscreenGameBuffer(void); void rebuildOffscreenMouseBuffer(void); diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp index 69e8da3526..4bc3780fe2 100644 --- a/backends/platform/n64/osys_n64_base.cpp +++ b/backends/platform/n64/osys_n64_base.cpp @@ -870,6 +870,18 @@ void OSystem_N64::getTimeAndDate(TimeDate &t) const { return; } +void OSystem_N64::logMessage(LogMessageType::Type type, const char *message) { + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); +} + void OSystem_N64::setTimerCallback(TimerProc callback, int interval) { assert (interval > 0); diff --git a/backends/platform/n64/osys_n64_events.cpp b/backends/platform/n64/osys_n64_events.cpp index 2645cfea2a..62f11aef64 100644 --- a/backends/platform/n64/osys_n64_events.cpp +++ b/backends/platform/n64/osys_n64_events.cpp @@ -162,7 +162,7 @@ bool OSystem_N64::pollEvent(Common::Event &event) { uint16 newButtons = 0; if (_controllerPort >= 0) newButtons = _ctrlData.c[_controllerPort].buttons; // Read from controller - + uint16 newMouseButtons = 0; if (_mousePort >= 0) newMouseButtons = _ctrlData.c[_mousePort].buttons; diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp index 106cde1699..4690a67c55 100644 --- a/backends/platform/null/null.cpp +++ b/backends/platform/null/null.cpp @@ -52,6 +52,8 @@ public: virtual uint32 getMillis(); virtual void delayMillis(uint msecs); virtual void getTimeAndDate(TimeDate &t) const {} + + virtual void logMessage(LogMessageType::Type type, const char *message); }; OSystem_NULL::OSystem_NULL() { @@ -97,6 +99,18 @@ uint32 OSystem_NULL::getMillis() { void OSystem_NULL::delayMillis(uint msecs) { } +void OSystem_NULL::logMessage(LogMessageType::Type type, const char *message) { + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); +} + OSystem *OSystem_NULL_create() { return new OSystem_NULL(); } diff --git a/backends/platform/openpandora/build/PXML.xml b/backends/platform/openpandora/build/PXML.xml index f4d2e2a595..a87c49e2b8 100755 --- a/backends/platform/openpandora/build/PXML.xml +++ b/backends/platform/openpandora/build/PXML.xml @@ -1,34 +1,55 @@ <?xml version="1.0" encoding="UTF-8"?> <PXML xmlns="http://openpandora.org/namespaces/PXML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PXML_schema.xsd"> - - <application id="scummvm.djwillis.0001" appdata="scummvm"> - - <title lang="en_US">ScummVM</title> - - <exec command="./runscummvm.sh"/> - <icon src="icon/scummvm.png"/> - - <previewpics> - <pic src="icon/preview-pic.png"/> - </previewpics> - - <info name="ScummVM Documentation" type="text/html" src="docs/index.html"/> - - <description lang="en_US">Point & click game interpreter.</description> - - <author name="DJWillis" website="http://www.scummvm.org/"/> - - <version major="1" minor="1" release="1" build="1"/><!--This programs version--> - <osversion major="1" minor="0" release="0" build="0"/><!--The minimum OS version required--> - - <categories> - <category name="Game"><!--category like "Games", "Graphics", "Internet" etc--> - <subcategory name="Adventure Games"/><!--subcategory, like "Board Games", "Strategy", "First Person Shooters"--> - </category> - </categories> - - <clockspeed frequency="500"/><!--Frequency in Hz--> - - </application> - + <!-- This is the package, in our case ScummVM --> + <package id="scummvm.djwillis.0001"> + <author name="DJWillis" website="http://www.scummvm.org/"/> + <!-- version type can be alpha, beta or release, set to release in branch --> + <version major="1" minor="4" release="0" build="1" type="alpha"/> + <!-- Both title and titles are needed --> + <title lang="en_US">ScummVM</title> + <titles> + <title lang="en_US">ScummVM</title> + </titles> + <descriptions> + <description lang="en_US"> + ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed! + + ScummVM supports many adventure games, including LucasArts SCUMM games (such as Monkey Island 1-3, Day of the Tentacle, Sam & Max, ...), many of Sierra's AGI and SCI games (such as King's Quest 1-6, Space Quest 1-5, ...), Discworld 1 and 2, Simon the Sorcerer 1 and 2, Beneath A Steel Sky, Lure of the Temptress, Broken Sword 1 and 2, Flight of the Amazon Queen, Gobliiins 1-3, The Legend of Kyrandia 1-3, many of Humongous Entertainment's children's SCUMM games (including Freddi Fish and Putt Putt games) and many more. + </description> + </descriptions> + <icon src="icon/scummvm.png"/> + </package> + + <!-- This is the application, the ScummVM binary --> + <application id="scummvm.djwillis.0001" appdata="scummvm"> + <exec command="./runscummvm.sh"/> + <author name="DJWillis" website="http://www.scummvm.org/"/> + <!-- version type can be alpha, beta or release, set to release in branch --> + <version major="1" minor="4" release="0" build="1" type="alpha"/> + <!-- Both title and titles are needed --> + <title lang="en_US">ScummVM</title> + <titles> + <title lang="en_US">ScummVM</title> + </titles> + <descriptions> + <description lang="en_US"> + ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed! + + ScummVM supports many adventure games, including LucasArts SCUMM games (such as Monkey Island 1-3, Day of the Tentacle, Sam & Max, ...), many of Sierra's AGI and SCI games (such as King's Quest 1-6, Space Quest 1-5, ...), Discworld 1 and 2, Simon the Sorcerer 1 and 2, Beneath A Steel Sky, Lure of the Temptress, Broken Sword 1 and 2, Flight of the Amazon Queen, Gobliiins 1-3, The Legend of Kyrandia 1-3, many of Humongous Entertainment's children's SCUMM games (including Freddi Fish and Putt Putt games) and many more. + </description> + </descriptions> + <licenses> + <license name="GPLv2" url="http://www.gnu.org/licenses/gpl-2.0.html" sourcecodeurl="http://www.scummvm.org"/> + </licenses> + <icon src="icon/scummvm.png"/> + <previewpics> + <pic src="icon/preview-pic.png"/> + </previewpics> + <info name="ScummVM Documentation" type="text/html" src="docs/index.html"/> + <categories> + <category name="Game"> + <subcategory name="AdventureGame"/> + </category> + </categories> + </application> </PXML> diff --git a/backends/platform/openpandora/build/PXML_schema.xsd b/backends/platform/openpandora/build/PXML_schema.xsd new file mode 100644 index 0000000000..335efe5002 --- /dev/null +++ b/backends/platform/openpandora/build/PXML_schema.xsd @@ -0,0 +1,341 @@ +<?xml version="1.0" encoding="utf-8"?> +<xs:schema targetNamespace="http://openpandora.org/namespaces/PXML" xmlns="http://openpandora.org/namespaces/PXML" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified"> + + + <!-- declare some simpleTypes for later usage --> + + <!-- Specify params allows with the 'x11' entry in exec --> + <xs:simpleType name="x11Param"> + <xs:restriction base="xs:string"> + <xs:enumeration value="req" /> + <xs:enumeration value="stop" /> + <xs:enumeration value="ignore" /> + </xs:restriction> + </xs:simpleType> + + <!-- Specify the valid documentation formats in the <info> block --> + <xs:simpleType name="docType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="text/html" /> + <xs:enumeration value="text/plain" /> + </xs:restriction> + </xs:simpleType> + + <!-- Make sure that version numbers only consist of letters, numbers and + as well as - --> + <xs:simpleType name="versionNumber"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:pattern value="[a-zA-Z0-9+-]*" /> + </xs:restriction> + </xs:simpleType> + + <!-- Specify what is valid as release type --> + <xs:simpleType name="releaseType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="alpha" /> + <xs:enumeration value="beta" /> + <xs:enumeration value="release" /> + </xs:restriction> + </xs:simpleType> + + <!-- Specify what makes an email address "valid" --> + <xs:simpleType name="emailAddress"> + <xs:restriction base="xs:string"> + <xs:pattern value="[^@]+@[^\.]+\..+"/> + </xs:restriction> + </xs:simpleType> + + <!-- some restrictions regarding file names that are eg not allowed/possible when using sd cards formated as fat32 --> + <xs:simpleType name="dumbPath"> + <xs:restriction base="xs:normalizedString"> + <xs:pattern value="[^?>:]+" /> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="dumbFolderName"> + <xs:restriction base="xs:normalizedString"> + <xs:pattern value="[^?>:/]+" /> + </xs:restriction> + </xs:simpleType> + + <!-- Specify lang codes --> + <xs:simpleType name="isoLangcode"> + <xs:restriction base="xs:string"> + <xs:minLength value="2"/> + <xs:pattern value="[a-zA-Z]{2,3}(_[a-zA-Z0-9]{2,3})*" /> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="isoLangcode_en_US"> + <xs:restriction base="xs:string"> + <xs:enumeration value="en_US" /> + </xs:restriction> + </xs:simpleType> + + <!-- Definition of all allowed categories following the FDO specs --> + <xs:simpleType name="fdoCategory"> + <xs:restriction base="xs:string"> + <xs:pattern value="AudioVideo|Audio|Video|Development|Education|Game|Graphics|Network|Office|Settings|System|Utility"/> + </xs:restriction> + </xs:simpleType> + <!-- Definition of all allowed subcategories following the FDO specs (should be based upon the given main categories, but would significantly increase complexity of the schema) --> + <xs:simpleType name="fdoSubCategory"> + <xs:restriction base="xs:string"> + <xs:pattern value="Building|Debugger|IDE|GUIDesigner|Profiling|RevisionControl|Translation|Calendar|ContactManagement|Database|Dictionary|Chart|Email|Finance|FlowChart|PDA|ProjectManagement|Presentation|Spreadsheet|WordProcessor|2DGraphics|VectorGraphics|RasterGraphics|3DGraphics|Scanning|OCR|Photography|Publishing|Viewer|TextTools|DesktopSettings|HardwareSettings|Printing|PackageManager|Dialup|InstantMessaging|Chat|IRCClient|FileTransfer|HamRadio|News|P2P|RemoteAccess|Telephony|TelephonyTools|VideoConference|WebBrowser|WebDevelopment|Midi|Mixer|Sequencer|Tuner|TV|AudioVideoEditing|Player|Recorder|DiscBurning|ActionGame|AdventureGame|ArcadeGame|BoardGame|BlocksGame|CardGame|KidsGame|LogicGame|RolePlaying|Simulation|SportsGame|StrategyGame|Art|Construction|Music|Languages|Science|ArtificialIntelligence|Astronomy|Biology|Chemistry|ComputerScience|DataVisualization|Economy|Electricity|Geography|Geology|Geoscience|History|ImageProcessing|Literature|Math|NumericalAnalysis|MedicalSoftware|Physics|Robotics|Sports|ParallelComputing|Amusement|Archiving|Compression|Electronics|Emulator|Engineering|FileTools|FileManager|TerminalEmulator|Filesystem|Monitor|Security|Accessibility|Calculator|Clock|TextEditor|Documentation|Core|KDE|GNOME|GTK|Qt|Motif|Java|ConsoleOnly"/> + </xs:restriction> + </xs:simpleType> + + <!-- Create some way to enforce entries to be nonempty --> + <xs:simpleType name="nonempty_token"> + <xs:restriction base="xs:token"> + <xs:minLength value="1"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="nonempty_string"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="nonempty_normalizedString"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + </xs:restriction> + </xs:simpleType> + + + + <!-- declare some complexTypes for later usage --> + + <!-- type used for file associations --> + <xs:complexType name="association_data"> + <xs:attribute name="name" use="required" type="nonempty_normalizedString" /> + <xs:attribute name="filetype" use="required" type="nonempty_token" /> + <xs:attribute name="exec" use="required" type="nonempty_token" /> + </xs:complexType> + + <!-- type used for author info --> + <xs:complexType name="author_data"> + <xs:attribute name="name" use="required" type="nonempty_normalizedString" /> + <xs:attribute name="website" use="optional" type="xs:anyURI" /> + <xs:attribute name="email" use="optional" type="emailAddress" /> + </xs:complexType> + + <!-- type used for version informations (full entry as well as os version) --> + <xs:complexType name="app_version_info"> + <xs:attribute name="major" use="required" type="versionNumber" /> + <xs:attribute name="minor" use="required" type="versionNumber" /> + <xs:attribute name="release" use="required" type="versionNumber" /> + <xs:attribute name="build" use="required" type="versionNumber" /> + <xs:attribute name="type" use="optional" type="releaseType" /> + </xs:complexType> + <xs:complexType name="os_version_info"> + <xs:attribute name="major" use="required" type="versionNumber" /> + <xs:attribute name="minor" use="required" type="versionNumber" /> + <xs:attribute name="release" use="required" type="versionNumber" /> + <xs:attribute name="build" use="required" type="versionNumber" /> + </xs:complexType> + + <!-- type used for exec entries --> + <xs:complexType name="exec_params"> + <xs:attribute name="command" use="required" type="nonempty_token" /> + <xs:attribute name="arguments" use="optional" type="nonempty_token" /> + <xs:attribute name="background" use="optional" type="xs:boolean" /> + <xs:attribute name="startdir" use="optional" type="dumbPath" /> + <xs:attribute name="standalone" use="optional" type="xs:boolean" /> + <xs:attribute name="x11" use="optional" type="x11Param" /> + </xs:complexType> + + <!-- type used for tiles or descriptions, once in 'normal' version, once enforcing usage of en_US --> + <xs:complexType name="title_or_description"> + <xs:simpleContent> + <xs:extension base="nonempty_string"> + <xs:attribute name="lang" use="required" type="isoLangcode" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + <xs:complexType name="title_or_description_enUS"> + <xs:simpleContent> + <xs:extension base="nonempty_string"> + <xs:attribute name="lang" use="required" type="isoLangcode_en_US" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <!-- type used for referencing images --> + <xs:complexType name="image_entry"> + <xs:attribute name="src" use="required" type="dumbPath" /> + </xs:complexType> + + <!-- type for referencing manuals/readme docs --> + <xs:complexType name="information_entry"> + <xs:attribute name="name" use="required" type="nonempty_normalizedString" /> + <xs:attribute name="type" use="required" type="docType" /> + <xs:attribute name="src" use="required" type="dumbPath" /> + </xs:complexType> + + <!-- type used for the license information --> + <xs:complexType name="license_info"> + <xs:attribute name="name" use="required" type="nonempty_normalizedString" /> + <xs:attribute name="url" use="optional" type="xs:anyURI" /> + <xs:attribute name="sourcecodeurl" use="optional" type="xs:anyURI" /> + </xs:complexType> + + + + <!-- Combine the symple and complex types into the "real" PXML specification --> + + <xs:element name="PXML"> + <xs:complexType> + <xs:sequence> + <!-- specify the <package> tag with info about the complete package, information providable: + author + version + title(s) + description(s) + icon + --> + <xs:element name="package" minOccurs="1" maxOccurs="1"> + <xs:complexType> + <xs:all> + <!--Author info--> + <xs:element name="author" type="author_data" minOccurs="1" /> + <!--App version info--> + <xs:element name="version" type="app_version_info" minOccurs="1" /> + <!--Title--> + <xs:element name="titles" minOccurs="1"> + <xs:complexType> + <xs:sequence> + <xs:element name="title" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" /> + <xs:element name="title" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + </xs:element> + <!--Description--> + <xs:element name="descriptions" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="title" type="title_or_description_enUS" minOccurs="0" maxOccurs="1" /> + <xs:element name="description" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + </xs:element> + <!--Icon--> + <xs:element name="icon" type="image_entry" minOccurs="0" /> + </xs:all> + <!--Package ID--> + <xs:attribute name="id" use="required" type="dumbFolderName" /> + </xs:complexType> + </xs:element> + <!-- specify the <application> tag with info about a single program + executable call + author + version (of the application) + osversion (min OS version supported) + title(s) (allowing compatibility to <HF6, too!) + description(s) (allowing compatibility to <HF6, too!) + icon + license + preview pictures + info/manual/readme entry + categories + associations to file types + clockspeed + --> + <xs:element name="application" minOccurs="1" maxOccurs="unbounded"> + <xs:complexType> + <xs:all> + <!--Execution params --> + <xs:element name="exec" type="exec_params" minOccurs="1" /> + <!--Author info--> + <xs:element name="author" type="author_data" minOccurs="1" /> + <!--App version info--> + <xs:element name="version" type="app_version_info" minOccurs="1" /> + <!--OS Version info--> + <xs:element name="osversion" type="os_version_info" minOccurs="0" /> + <!--Title--> + <!-- via <titles> element, used for HF6+ --> + <xs:element name="titles" minOccurs="1"> + <xs:complexType> + <xs:sequence> + <xs:element name="title" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" /> + <xs:element name="title" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + </xs:element> + <!--Title--> + <!-- via <title> element, only one for en_US allowed, meant for backwards compatibility with libpnd from <HF6 --> + <xs:element name="title" type="title_or_description_enUS" minOccurs="0" /> + <!--Description--> + <!-- via <descriptions> element, used for HF6+ --> + <xs:element name="descriptions" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="description" type="title_or_description_enUS" minOccurs="1" maxOccurs="1" /> + <xs:element name="description" type="title_or_description" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + </xs:element> + <!--Description--> + <!-- via <description> element, only one for en_US allowed, meant for backwards compatibility with libpnd from <HF6 --> + <xs:element name="description" type="title_or_description_enUS" minOccurs="0" /> + <!--Icon--> + <xs:element name="icon" type="image_entry" minOccurs="0" /> + <!--License--> + <xs:element name="licenses" minOccurs="1"> + <xs:complexType> + <xs:sequence> + <xs:element name="license" type="license_info" minOccurs="1" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + </xs:element> + <!--Preview pics--> + <xs:element name="previewpics" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="pic" type="image_entry" minOccurs="0" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + </xs:element> + <!--Info (aka manual or readme entry)--> + <xs:element name="info" type="information_entry" minOccurs="0" /> + <!--Categories--> + <xs:element name="categories" minOccurs="1"> + <xs:complexType> + <xs:sequence> + <xs:element name="category" minOccurs="1" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="subcategory" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:attribute name="name" type="fdoSubCategory" /> + </xs:complexType> + </xs:element> + </xs:sequence> + <xs:attribute name="name" use="required" type="fdoCategory" /> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <!--Associations--> + <xs:element name="associations" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="association" type="association_data" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + </xs:element> + <!--Clockspeed--> + <xs:element name="clockspeed" minOccurs="0"> + <xs:complexType> + <xs:attribute name="frequency" use="required" type="xs:positiveInteger" /> + </xs:complexType> + </xs:element> + </xs:all> + <!--AppID--> + <xs:attribute name="id" use="required" type="dumbFolderName" /> + <xs:attribute name="appdata" use="optional" type="dumbFolderName" /> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema>
\ No newline at end of file diff --git a/backends/platform/openpandora/build/pnd_make.sh b/backends/platform/openpandora/build/pnd_make.sh index b19de87bb4..0c03e8154d 100755 --- a/backends/platform/openpandora/build/pnd_make.sh +++ b/backends/platform/openpandora/build/pnd_make.sh @@ -1,65 +1,321 @@ -#!/bin/sh +#!/bin/bash +# +# pnd_make.sh +# +# This script is meant to ease generation of a pnd file. Please consult the output +# when running --help for a list of available parameters and an explaination of +# those. +# +# Required tools when running the script: +# bash +# echo, cat, mv, rm +# mkisofs or mksquashfs (the latter when using the -c param!) +# xmllint (optional, only for validation of the PXML against the schema) -######adjust path of genpxml.sh if you want to use that "feture"##### -TEMP=`getopt -o p:d:x:i:c -- "$@"` +PXML_schema=$(dirname ${0})/PXML_schema.xsd +GENPXML_PATH=$(dirname ${0})/genpxml.sh -if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi +# useful functions ... +black='\E[30m' +red='\E[31m' +green='\E[32m' +yellow='\E[33m' +blue='\E[34m' +magenta='\E[35m' +cyan='\E[36m' +white='\E[37m' -eval set -- "$TEMP" -while true ; do - case "$1" in - -p) echo "PNDNAME set to $2" ;PNDNAME=$2;shift 2;; - -d) echo "FOLDER set to $2" ;FOLDER=$2;shift 2 ;; - -x) echo "PXML set to $2" ;PXML=$2;shift 2 ;; - -i) echo "ICON set to $2" ;ICON=$2;shift 2 ;; - -c) echo "-c set, will create compressed squasfs image instead of iso $2" ;SQUASH=1;shift 1 ;; - --) shift ; break ;; - *) echo "Error while parsing arguments! $2" ; exit 1 ;; - esac +check_for_tool() +{ + which $1 &> /dev/null + if [ "$?" -ne "0" ]; + then + cecho "ERROR: Could not find the program '$1'. Please make sure +that it is available in your PATH since it is required to complete your request." $red + exit 1 + fi +} + +cecho () # Color-echo. Argument $1 = message, Argument $2 = color +{ + local default_msg="No message passed." # Doesn't really need to be a local variable. + message=${1:-$default_msg} # Defaults to default message. + color=${2:-$black} # Defaults to black, if not specified. + echo -e "$color$message" + tput sgr0 # Reset to normal. + return +} + + +print_help() +{ + cat << EOSTREAM +pnd_make.sh - A script to package "something" into a PND. + +Usage: + $(basename ${0}) {--directory|-d} <folder> {--pndname|-p} <file> [{--compress-squashfs|-c}] + [{--genpxml} <file>] [{--icon|-i} <file>] [{--pxml|-x} <file>] + [{--schema|-s} <file>] [{--help|-h}] + + +Switches: + --compress-squashfs / -c Define whether or not the pnd should be compressed using + squashfs. If this parameter is selected, a compressed pnd + will be created. + + --directory / -d Sets the folder that is to be used for the resulting pnd + to <folder>. This option is mandatory for the script to + function correctly. + + --genpxml Sets the script used for generating a PXML file (if none + is available already) to <file>. Please make sure to either + provide a full path or prefix a script in the current folder + with './' so that the script can actually be executed. If + this variable is not specified, $GENPXML_PATH + will be used. + + --help / -h Displays this help text. + + --icon / -i Sets the icon that will be appended in the pnd to <file>. + + --pndname / -p Sets the output filename of the resulting pnd to <file>. + This option is mandatory for the script to function + correctly. + + --pxml / -x Sets the PXML file that is to be used to <file>. If you + neither provide a PXML file or set this entry to 'guess', + an existing 'PXML.xml' in your selected '--directory' + will be used, or the script $GENPXML_PATH + will be called to try to generate a basic PXML file for you. + + --schema / -s Sets the schema file, that is to be used for validation, + to <file. If this is not defined, the script will try to + use the file '$PXML_schema'. If this fails, + a warning is issued. + +If you select the option to create a compressed squashfs, a version >=4.0 of squashfs +is required to be available in your PATH. +EOSTREAM +} + + +# Parse command line parameters +while [ "${1}" != "" ]; do + if [ "${1}" = "--compress-squashfs" ] || [ "${1}" = "-c" ]; + then + SQUASH=1 + shift 1 + elif [ "${1}" = "--directory" ] || [ "${1}" = "-d" ]; + then + FOLDER=$2 + shift 2 + elif [ "${1}" = "--genpxml" ]; + then + GENPXML_PATH=$2 + shift 2 + elif [ "${1}" = "--help" ] || [ "${1}" = "-h" ]; + then + print_help + exit 0 + elif [ "${1}" = "--icon" ] || [ "${1}" = "-i" ]; + then + ICON=$2 + shift 2 + elif [ "${1}" = "--pndname" ] || [ "${1}" = "-p" ]; + then + PNDNAME=$2 + shift 2 + elif [ "${1}" = "--pxml" ] || [ "${1}" = "-x" ]; + then + PXML=$2 + shift 2 + elif [ "${1}" = "--schema" ] || [ "${1}" = "-f" ] + then + PXML_schema=$2 + shift 2 + else + cecho "ERROR: '$1' is not a known argument. Printing --help and aborting." $red + print_help + exit 1 + fi done -rnd=$RANDOM; # random number for genpxml and index$rnd.xml -#generate pxml if guess or empty -if [ ! $PXML ] || [ $PXML = "guess" ] && [ $PNDNAME ] && [ $FOLDER ]; then - PXMLtxt=$(/home/user/libpnd/pandora-libraries/testdata/scripts/genpxml.sh $FOLDER $ICON) - PXML=$FOLDER/PXML.xml - echo "$PXMLtxt" > $FOLDER/PXML.xml +# Generate a PXML if the param is set to Guess or it is empty. +if [ ! $PXML ] || [ $PXML = "guess" ] && [ $PNDNAME ] && [ $FOLDER ]; +then + if [ -f $FOLDER/PXML.xml ]; # use the already existing PXML.xml file if there is one... + then + PXML=$FOLDER/PXML.xml + PXML_ALREADY_EXISTING="true" + else + if [ -f $GENPXML_PATH ]; + then + $GENPXML_PATH --src $FOLDER --dest $FOLDER --author $USER + if [ -f $FOLDER/PXML.xml ]; + then + PXML_GENERATED="true" + else + cecho "ERROR: Generating a PXML file using '$GENPXML_PATH' failed. +Please generate a PXML file manually." $red + exit 1 + fi + else + cecho "ERROR: Could not find '$GENPXML_PATH' for generating a PXML file." $red + exit 1 + fi + fi fi -#check arguments -if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ]; then - echo " Usage: pnd_make.sh -p your.pnd -d folder/containing/your/app/ -x - your.pxml (or \"guess\" to try to generate it from the folder) -i icon.png" + +# Probe if required variables were set +echo -e +cecho "Checking if all required variables were set." $green +if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ]; +then + echo -e + cecho "ERROR: Not all required options were set! Please see the --help information below." $red + echo -e + print_help exit 1 +else + echo "PNDNAME set to '$PNDNAME'." +fi +# Check if the selected folder actually exists +if [ ! -d $FOLDER ]; +then + echo -e + cecho "ERROR: '$FOLDER' doesn't exist or is not a folder." $red + exit 1 +else + echo "FOLDER set to '$FOLDER'." +fi +# Check if the selected PXML file actually exists +if [ ! -f $PXML ]; +then + echo -e + cecho "ERROR: '$PXML' doesn't exist or is not a file." $red + exit 1 +else + if [ $PXML_ALREADY_EXISTING ]; + then + echo "You have not explicitly specified a PXML to use, but an existing file was +found. Will be using this one." + elif [ $PXML_GENERATED ]; + then + echo "A PXML file was generated for you using '$GENPXML_PATH'. This file will +not be removed at the end of this script because you might want to review it, adjust +single entries and rerun the script to generate a pnd with a PXML file with all the +information you want to have listed." + fi + echo "PXML set to '$PXML'." fi -if [ ! -d $FOLDER ]; then echo "$FOLDER doesnt exist"; exit 1; fi #check if folder actually exists -if [ ! -f $PXML ]; then echo "$PXML doesnt exist"; exit 1; fi #check if pxml actually exists -#make iso from folder -if [ ! $SQUASH ]; then - mkisofs -o $PNDNAME.iso -R $FOLDER +# Print the other variables: +if [ $ICON ]; +then + if [ ! -f $ICON ] + then + cecho "WARNING: '$ICON' doesn't exist, will not append the selected icon to the pnd." $red + else + echo "ICON set to '$ICON'." + USE_ICON="true" + fi +fi +if [ $SQUASH ]; +then + echo "Will use a squashfs for '$PNDNAME'." +fi + + +# Validate the PXML file (if xmllint is available) +# Errors and problems in this section will be shown but are not fatal. +echo -e +cecho "Trying to validate '$PXML' now. Will be using '$PXML_schema' to do so." $green +which xmllint &> /dev/null +if [ "$?" -ne "0" ]; +then + VALIDATED=false + cecho "WARNING: Could not find 'xmllint'. Validity check of '$PXML' is not possible!" $red else - if [ $(mksquashfs -version | awk '{if ($3 >= 4) print 1}') = 1 ]; then - echo "your squashfs version is older then version 4, please upgrade to 4.0 or later" + if [ ! -f "$PXML_schema" ]; + then + VALIDATED=false + cecho "WARNING: Could not find '$PXML_schema'. If you want to validate your +PXML file please make sure to provide a schema using the --schema option." $red + else + xmllint --noout --schema $PXML_schema $PXML + if [ "$?" -ne "0" ]; then VALIDATED=false; else VALIDATED=true; fi + fi +fi +# Print some message at the end about the validation in case the user missed the output above +if [ $VALIDATED = "false" ] +then + cecho "WARNING: Could not successfully validate '$PXML'. Please check the output +above. This does not mean that your pnd will be broken. Either you are not following the strict +syntax required for validation or you don't have all files/programs required for validating." $red +else + cecho "Your file '$PXML' was validated successfully. The resulting pnd should +work nicely with libpnd." $green +fi + + +# Make iso from folder +echo -e +cecho "Creating an iso file based on '$FOLDER'." $green +if [ $SQUASH ]; +then + check_for_tool mksquashfs + if [ $(mksquashfs -version | awk 'BEGIN{r=0} $3>=4{r=1} END{print r}') -eq 0 ]; + then + cecho "ERROR: Your squashfs version is older then version 4, please upgrade to 4.0 or later" $red exit 1 fi - mksquashfs -no-recovery -nopad $FOLDER $PNDNAME.iso + mksquashfs $FOLDER $PNDNAME.iso -nopad -no-recovery +else + check_for_tool mkisofs + mkisofs -o $PNDNAME.iso -R $FOLDER +fi + +# Check that the iso file was actually created before continuing +if [ ! -f $PNDNAME.iso ]; +then + cecho "ERROR: The temporary file '$PNDNAME.iso' could not be created. +Please check the output above for any errors and retry after fixing them. Aborting." $red + exit 1 fi -#append pxml to iso -cat $PNDNAME.iso $PXML > $PNDNAME + + +# Append pxml to iso +echo -e +cecho "Appending '$PXML' to the created iso file." $green +cat $PNDNAME.iso $PXML > $PNDNAME rm $PNDNAME.iso #cleanup -#append icon if specified -if [ $ICON ]; then # check if we want to add an icon - if [ ! -f $ICON ]; then #does the icon actually exist? - echo "$ICON doesnt exist" - else # yes + +# Append icon if specified and available +if [ $USE_ICON ]; +then + echo -e + cecho "Appending the icon '$ICON' to the pnd." $green mv $PNDNAME $PNDNAME.tmp cat $PNDNAME.tmp $ICON > $PNDNAME # append icon rm $PNDNAME.tmp #cleanup - fi fi -if [ $PXML = "guess" ];then rm $FOLDER/PXML.xml; fi #cleanup + +# Final message +echo -e +if [ -f $PNDNAME ]; +then + cecho "Successfully finished creating the pnd '$PNDNAME'." $green +else + cecho "There seems to have been a problem and '$PNDNAME' was not created. Please check +the output above for any error messages. A possible cause for this is that there was +not enough space available." $red + exit 1 +fi + + +#if [ $PXML = "guess" ];then rm $FOLDER/PXML.xml; fi #cleanup diff --git a/backends/platform/openpandora/build/runscummvm.sh b/backends/platform/openpandora/build/runscummvm.sh index 48d24a2b81..c641235219 100755 --- a/backends/platform/openpandora/build/runscummvm.sh +++ b/backends/platform/openpandora/build/runscummvm.sh @@ -11,4 +11,5 @@ mkdir saves mkdir runtime cd runtime -../bin/scummvm --fullscreen --gfx-mode=2x --config=../scummvm.config +../bin/scummvm --fullscreen --gfx-mode=2x --config=../scummvm.config --themepath=../data + diff --git a/backends/platform/openpandora/op-bundle.mk b/backends/platform/openpandora/op-bundle.mk index 163f4711ce..089430f43c 100755 --- a/backends/platform/openpandora/op-bundle.mk +++ b/backends/platform/openpandora/op-bundle.mk @@ -75,11 +75,10 @@ endif $(CP) $(libloc)/../arm-angstrom-linux-gnueabi/usr/lib/libFLAC.so.8.2.0 $(bundle_name)/scummvm/lib/libFLAC.so.8 - $(srcdir)/backends/platform/openpandora/build/pnd_make.sh -p $(bundle_name).pnd -d $(bundle_name)/scummvm -x $(bundle_name)/scummvm/data/PXML.xml -i $(bundle_name)/scummvm/icon/scummvm.png + $(srcdir)/backends/platform/openpandora/build/pnd_make.sh -p $(bundle_name).pnd -c -d $(bundle_name)/scummvm -x $(bundle_name)/scummvm/data/PXML.xml -i $(bundle_name)/scummvm/icon/scummvm.png $(CP) $(srcdir)/backends/platform/openpandora/build/README-PND.txt $(bundle_name) tar -cvjf $(bundle_name)-pnd.tar.bz2 $(bundle_name).pnd $(bundle_name)/README-PND.txt rm -R ./$(bundle_name) -# rm $(bundle_name).pnd .PHONY: op-bundle op-pnd diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index d3acd06089..c75d7493a2 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -66,7 +66,7 @@ #include "engines/engine.h" -#include "graphics/font.h" +#include "graphics/fonts/bdf.h" #include "graphics/surface.h" #include "icon.h" @@ -96,7 +96,7 @@ OSystem_PS2 *g_systemPs2; #define FOREVER 2147483647 namespace Graphics { - extern const NewFont g_sysfont; + extern const BdfFont g_sysfont; }; PS2Device detectBootPath(const char *elfPath, char *bootPath); diff --git a/backends/platform/psp/cursor.cpp b/backends/platform/psp/cursor.cpp index 18a61f3df4..b295507de1 100644 --- a/backends/platform/psp/cursor.cpp +++ b/backends/platform/psp/cursor.cpp @@ -324,18 +324,18 @@ inline void Cursor::setRendererModePalettized(bool palettized) { _renderer.setAlphaReverse(false); _renderer.setColorTest(false); } else { // 16 bits, no palette - // Color test is an easy way for the hardware to make our keycolor + // Color test is an easy way for the hardware to make our keycolor // transparent. - _renderer.setColorTest(true); - + _renderer.setColorTest(true); + // Alpha blending is not strictly required, but makes the cursor look // much better _renderer.setAlphaBlending(true); - + // Pixel formats without alpha (5650) are considered to have their alpha set. // Since pixel formats with alpha don't have their alpha bits set, we reverse // the alpha format for them so that 0 alpha is 1. - if (_buffer.getPixelFormat() != PSPPixelFormat::Type_5650) + if (_buffer.getPixelFormat() != PSPPixelFormat::Type_5650) _renderer.setAlphaReverse(true); else _renderer.setAlphaReverse(false); diff --git a/backends/platform/psp/display_client.cpp b/backends/platform/psp/display_client.cpp index 14b96d9cae..bc29166895 100644 --- a/backends/platform/psp/display_client.cpp +++ b/backends/platform/psp/display_client.cpp @@ -389,31 +389,31 @@ void Buffer::copyToArray(byte *dst, int pitch) { void Buffer::setSize(uint32 width, uint32 height, HowToSize textureOrSource/*=kSizeByTextureSize*/) { DEBUG_ENTER_FUNC(); - + // We can size the buffer either by texture size (multiple of 2^n) or source size. // At higher sizes, increasing the texture size to 2^n is a waste of space. At these sizes kSizeBySourceSize should be used. - + _sourceSize.width = width; _sourceSize.height = height; _textureSize.width = scaleUpToPowerOfTwo(width); // can only scale up to 512 _textureSize.height = scaleUpToPowerOfTwo(height); - + if (textureOrSource == kSizeByTextureSize) { _width = _textureSize.width; _height = _textureSize.height; } else { // sizeBySourceSize _width = _sourceSize.width; _height = _sourceSize.height; - - // adjust allocated width to be divisible by 32. + + // adjust allocated width to be divisible by 32. // The GU can only handle multiples of 16 bytes. A 4 bit image x 32 will give us 16 bytes // We don't necessarily know the depth of the pixels here. So just make it divisible by 32. uint32 checkDiv = _width & 31; if (checkDiv) _width += 32 - checkDiv; } - + PSP_DEBUG_PRINT("width[%u], height[%u], texW[%u], texH[%u], sourceW[%d], sourceH[%d] %s\n", _width, _height, _textureSize.width, _textureSize.height, _sourceSize.width, _sourceSize.height, textureOrSource ? "size by source" : "size by texture"); } @@ -558,10 +558,10 @@ void GuRenderer::render() { // Loop over patches of 512x512 pixel textures and draw them for (uint32 j = 0; j < _buffer->getSourceHeight(); j += 512) { _textureLoadOffset.y = j; - + for (uint32 i = 0; i < _buffer->getSourceWidth(); i += 512) { _textureLoadOffset.x = i; - + guLoadTexture(); Vertex *vertices = guGetVertices(); fillVertices(vertices); @@ -573,8 +573,8 @@ void GuRenderer::render() { inline void GuRenderer::guProgramDrawBehavior() { DEBUG_ENTER_FUNC(); - PSP_DEBUG_PRINT("blending[%s] colorTest[%s] reverseAlpha[%s] keyColor[%u]\n", - _blending ? "on" : "off", _colorTest ? "on" : "off", + PSP_DEBUG_PRINT("blending[%s] colorTest[%s] reverseAlpha[%s] keyColor[%u]\n", + _blending ? "on" : "off", _colorTest ? "on" : "off", _alphaReverse ? "on" : "off", _keyColor); if (_blending) { @@ -591,7 +591,7 @@ inline void GuRenderer::guProgramDrawBehavior() { if (_colorTest) { sceGuEnable(GU_COLOR_TEST); sceGuColorFunc(GU_NOTEQUAL, // show only colors not equal to this color - _keyColor, + _keyColor, 0x00ffffff); // match everything but alpha } else sceGuDisable(GU_COLOR_TEST); @@ -663,10 +663,10 @@ inline void GuRenderer::guLoadTexture() { byte *startPoint = _buffer->getPixels(); if (_textureLoadOffset.x) startPoint += _buffer->_pixelFormat.pixelsToBytes(_textureLoadOffset.x); - if (_textureLoadOffset.y) + if (_textureLoadOffset.y) startPoint += _buffer->getWidthInBytes() * _textureLoadOffset.y; - - sceGuTexImage(0, + + sceGuTexImage(0, _buffer->getTextureWidth(), // texture width (must be power of 2) _buffer->getTextureHeight(), // texture height (must be power of 2) _buffer->getWidth(), // width of a line of the image (to get to the next line) @@ -698,7 +698,7 @@ void GuRenderer::fillVertices(Vertex *vertices) { // These coordinates describe an area within the texture. ie. we already loaded a square of texture, // now the coordinates within it are 0 to the edge of the area of the texture we want to draw float textureStartX = textureFix + _offsetInBuffer.x; - float textureStartY = textureFix + _offsetInBuffer.y; + float textureStartY = textureFix + _offsetInBuffer.y; int textureLeftX = _drawSize.width - _textureLoadOffset.x; if (textureLeftX > 512) @@ -720,7 +720,7 @@ void GuRenderer::fillVertices(Vertex *vertices) { float imageStartY = gapY + scaledOffsetOnScreenY + (scaleSourceToOutput(false, stretch(false, _textureLoadOffset.y))); float imageEndX, imageEndY; - + imageEndX = imageStartX + scaleSourceToOutput(true, stretch(true, textureLeftX)); imageEndY = imageStartY + scaleSourceToOutput(false, stretch(false, textureLeftY)); diff --git a/backends/platform/psp/display_client.h b/backends/platform/psp/display_client.h index f190658a26..e384bfb82b 100644 --- a/backends/platform/psp/display_client.h +++ b/backends/platform/psp/display_client.h @@ -171,12 +171,12 @@ protected: class GuRenderer { public: // Constructors - GuRenderer() : _useGlobalScaler(false), _buffer(0), _palette(0), - _blending(false), _alphaReverse(false), _colorTest(false), + GuRenderer() : _useGlobalScaler(false), _buffer(0), _palette(0), + _blending(false), _alphaReverse(false), _colorTest(false), _keyColor(0), _fullScreen(false), _stretch(false), _stretchX(1.0f), _stretchY(1.0f) {} - GuRenderer(Buffer *buffer, Palette *palette) : - _useGlobalScaler(false), _buffer(buffer), _palette(palette), - _blending(false), _alphaReverse(false), _colorTest(false), + GuRenderer(Buffer *buffer, Palette *palette) : + _useGlobalScaler(false), _buffer(buffer), _palette(palette), + _blending(false), _alphaReverse(false), _colorTest(false), _keyColor(0), _fullScreen(false), _stretch(false), _stretchX(1.0f), _stretchY(1.0f) {} static void setDisplayManager(DisplayManager *dm) { _displayManager = dm; } // Called by the Display Manager diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp index 899b79727f..422805714f 100644 --- a/backends/platform/psp/display_manager.cpp +++ b/backends/platform/psp/display_manager.cpp @@ -62,7 +62,9 @@ const OSystem::GraphicsMode DisplayManager::_supportedModes[] = { // Class VramAllocator ----------------------------------- +namespace Common { DECLARE_SINGLETON(VramAllocator); +} //#define __PSP_DEBUG_FUNCS__ /* For debugging the stack */ //#define __PSP_DEBUG_PRINT__ @@ -299,7 +301,7 @@ void DisplayManager::init() { #endif // Init overlay since we never change the size - _overlay->deallocate(); + _overlay->deallocate(); _overlay->setBytesPerPixel(sizeof(OverlayColor)); _overlay->setSize(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); _overlay->allocate(); @@ -432,13 +434,13 @@ bool DisplayManager::renderAll() { _screen->render(); _screen->setClean(); // clean out dirty bit - + if (_imageViewer->isVisible()) _imageViewer->render(); _imageViewer->setClean(); if (_overlay->isVisible()) - _overlay->render(); + _overlay->render(); _overlay->setClean(); if (_cursor->isVisible()) @@ -448,7 +450,7 @@ bool DisplayManager::renderAll() { if (_keyboard->isVisible()) _keyboard->render(); _keyboard->setClean(); - + _masterGuRenderer.guPostRender(); return true; // rendered successfully diff --git a/backends/platform/psp/display_manager.h b/backends/platform/psp/display_manager.h index 5176bee3fe..38c43d60a3 100644 --- a/backends/platform/psp/display_manager.h +++ b/backends/platform/psp/display_manager.h @@ -72,7 +72,7 @@ private: */ class MasterGuRenderer : public PspThreadable { public: - MasterGuRenderer() : _lastRenderTime(0), _renderFinished(true), + MasterGuRenderer() : _lastRenderTime(0), _renderFinished(true), _renderSema(1, 1), _callbackId(-1) {} void guInit(); void guPreRender(); @@ -108,7 +108,7 @@ public: KEEP_ASPECT_RATIO, STRETCHED_FULL_SCREEN }; - DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0), + DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0), _imageViewer(0), _lastUpdateTime(0), _graphicsMode(0) {} ~DisplayManager(); @@ -127,7 +127,7 @@ public: void setOverlay(Overlay *overlay) { _overlay = overlay; } void setKeyboard(PSPKeyboard *keyboard) { _keyboard = keyboard; } void setImageViewer(ImageViewer *imageViewer) { _imageViewer = imageViewer; } - + void setSizeAndPixelFormat(uint width, uint height, const Graphics::PixelFormat *format); // Getters diff --git a/backends/platform/psp/dummy.cpp b/backends/platform/psp/dummy.cpp index 86ab30b3e2..748ac8cbf3 100644 --- a/backends/platform/psp/dummy.cpp +++ b/backends/platform/psp/dummy.cpp @@ -26,31 +26,31 @@ #include <stdio.h> #include <png.h> #include <sys/socket.h> - + //void userWriteFn(png_structp png_ptr, png_bytep data, png_size_t length) { //} //void userFlushFn(png_structp png_ptr) { //} - + // Dummy functions are pulled in so that we don't need to build the plugins with certain libs - + int dummyFunc() { // For Broken Sword 2.5 volatile int i; i = clock(); rename("dummyA", "dummyB"); - + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_set_write_fn(png_ptr, NULL, NULL, NULL); png_infop info_ptr; png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); png_destroy_write_struct(&png_ptr, &info_ptr); - + // For lua's usage of libc: very heavy usage so it pulls in sockets? setsockopt(0, 0, 0, NULL, 0); getsockopt(0, 0, 0, NULL, NULL); - + return i; }
\ No newline at end of file diff --git a/backends/platform/psp/image_viewer.cpp b/backends/platform/psp/image_viewer.cpp index 97d582b63a..1ed7698bc8 100644 --- a/backends/platform/psp/image_viewer.cpp +++ b/backends/platform/psp/image_viewer.cpp @@ -34,45 +34,45 @@ #include "backends/platform/psp/input.h" #include "backends/platform/psp/display_manager.h" #include "backends/platform/psp/display_client.h" -#include "backends/platform/psp/image_viewer.h" -#include "backends/platform/psp/png_loader.h" +#include "backends/platform/psp/image_viewer.h" +#include "backends/platform/psp/png_loader.h" #include "backends/platform/psp/thread.h" static const char *imageName = "psp_image"; #define PSP_SCREEN_HEIGHT 272 #define PSP_SCREEN_WIDTH 480 - + bool ImageViewer::load(int imageNum) { if (_init) unload(); - + // build string char number[8]; sprintf(number, "%d", imageNum); - Common::String imageNameStr(imageName); + Common::String imageNameStr(imageName); Common::String specificImageName = imageNameStr + Common::String(number) + Common::String(".png"); - + // search for image file if (!SearchMan.hasFile(specificImageName)) { PSP_ERROR("file %s not found\n", specificImageName.c_str()); return false; } - + Common::ScopedPtr<Common::SeekableReadStream> file(SearchMan.createReadStreamForMember(specificImageName)); - + _buffer = new Buffer(); _palette = new Palette(); _renderer = new GuRenderer(); - + assert(_buffer); assert(_palette); assert(_renderer); - + // Load a PNG into our buffer and palette. Size it by the actual size of the image PngLoader image(file, *_buffer, *_palette, Buffer::kSizeBySourceSize); - + PngLoader::Status status = image.allocate(); // allocate the buffers for the file - + char error[100]; if (status == PngLoader::BAD_FILE) { sprintf(error, "Cannot display %s. Not a proper PNG file", specificImageName.c_str()); @@ -89,29 +89,29 @@ bool ImageViewer::load(int imageNum) { if (!image.load()) { sprintf(error, "Cannot display %s. Not a proper PNG file", specificImageName.c_str()); GUI::TimedMessageDialog dialog(error, 4000); - dialog.runModal(); + dialog.runModal(); return false; } - + setConstantRendererOptions(); setFullScreenImageParams(); // prepare renderer for full screen view - + _imageNum = imageNum; // now we can say we displayed this image _init = true; - + return true; } void ImageViewer::setConstantRendererOptions() { _renderer->setBuffer(_buffer); _renderer->setPalette(_palette); - + _renderer->setAlphaBlending(false); _renderer->setColorTest(false); _renderer->setUseGlobalScaler(false); _renderer->setStretch(true); _renderer->setOffsetInBuffer(0, 0); - _renderer->setDrawWholeBuffer(); + _renderer->setDrawWholeBuffer(); } void ImageViewer::unload() { @@ -130,32 +130,32 @@ void ImageViewer::resetOnEngineDone() { void ImageViewer::setVisible(bool visible) { DEBUG_ENTER_FUNC(); - + if (_visible == visible) return; - + // from here on, we're making the loader visible if (visible && g_engine) { // we can only run the image viewer when there's an engine g_engine->pauseEngine(true); - + load(_imageNum ? _imageNum : 1); // load the 1st image or the current } if (visible && _init) { // we managed to load _visible = true; setViewerButtons(true); - + { // so dialog goes out of scope, destroying all allocations GUI::TimedMessageDialog dialog("Image Viewer", 1000); dialog.runModal(); } - + runLoop(); // only listen to viewer events } else { // we were asked to make invisible or failed to load _visible = false; unload(); setViewerButtons(false); - + if (g_engine && g_engine->isPaused()) g_engine->pauseEngine(false); } @@ -175,7 +175,7 @@ void ImageViewer::runLoop() { void ImageViewer::setViewerButtons(bool active) { _inputHandler->setImageViewerMode(active); -} +} void ImageViewer::loadNextImage() { if (!load(_imageNum+1)) { // try to load the next image @@ -190,21 +190,21 @@ void ImageViewer::loadLastImage() { if (!load(_imageNum-1)) if (!load(_imageNum)) setVisible(false); // we can't even show the old image so hide - } + } setDirty(); } void ImageViewer::setFullScreenImageParams() { // we try to fit the image fullscreen at least in one dimension uint32 width = _buffer->getSourceWidth(); - uint32 height = _buffer->getSourceHeight(); + uint32 height = _buffer->getSourceHeight(); _centerX = PSP_SCREEN_WIDTH / 2.0f; _centerY = PSP_SCREEN_HEIGHT / 2.0f; - + // see if we fit width wise if (PSP_SCREEN_HEIGHT >= (int)((height * PSP_SCREEN_WIDTH) / (float)width)) { - setZoom(PSP_SCREEN_WIDTH / (float)width); + setZoom(PSP_SCREEN_WIDTH / (float)width); } else { setZoom(PSP_SCREEN_HEIGHT / (float)height); } @@ -233,32 +233,32 @@ void ImageViewer::render() { break; } _renderer->render(); - } + } } void ImageViewer::modifyZoom(bool up) { float factor = _zoomFactor; - if (up) + if (up) factor += 0.1f; else // down factor -= 0.1f; - - setZoom(factor); + + setZoom(factor); } -void ImageViewer::setZoom(float value) { +void ImageViewer::setZoom(float value) { if (value <= 0.0f) // don't want 0 or negative zoom return; _zoomFactor = value; - _renderer->setStretchXY(value, value); + _renderer->setStretchXY(value, value); setOffsetParams(); } void ImageViewer::moveImageX(float val) { float newVal = _centerX + val; - - if (newVal - (_visibleWidth / 2) > PSP_SCREEN_WIDTH - 4 || newVal + (_visibleWidth / 2) < 4) + + if (newVal - (_visibleWidth / 2) > PSP_SCREEN_WIDTH - 4 || newVal + (_visibleWidth / 2) < 4) return; _centerX = newVal; setOffsetParams(); @@ -266,22 +266,22 @@ void ImageViewer::moveImageX(float val) { void ImageViewer::moveImageY(float val) { float newVal = _centerY + val; - - if (newVal - (_visibleHeight / 2) > PSP_SCREEN_HEIGHT - 4 || newVal + (_visibleHeight / 2) < 4) + + if (newVal - (_visibleHeight / 2) > PSP_SCREEN_HEIGHT - 4 || newVal + (_visibleHeight / 2) < 4) return; _centerY = newVal; setOffsetParams(); } -// Set the renderer with the proper offset on the screen +// Set the renderer with the proper offset on the screen // void ImageViewer::setOffsetParams() { _visibleWidth = _zoomFactor * _buffer->getSourceWidth(); - _visibleHeight = _zoomFactor * _buffer->getSourceHeight(); - + _visibleHeight = _zoomFactor * _buffer->getSourceHeight(); + int offsetX = _centerX - (int)(_visibleWidth * 0.5f); int offsetY = _centerY - (int)(_visibleHeight * 0.5f); - + _renderer->setOffsetOnScreen(offsetX, offsetY); setDirty(); } @@ -290,8 +290,8 @@ void ImageViewer::setOffsetParams() { // void ImageViewer::handleEvent(uint32 event) { DEBUG_ENTER_FUNC(); - - switch (event) { + + switch (event) { case EVENT_HIDE: setVisible(false); break; diff --git a/backends/platform/psp/image_viewer.h b/backends/platform/psp/image_viewer.h index 4c3eaf7b4a..ad188536a3 100644 --- a/backends/platform/psp/image_viewer.h +++ b/backends/platform/psp/image_viewer.h @@ -54,10 +54,10 @@ private: float _visibleHeight, _visibleWidth; float _centerX, _centerY; Event _movement; - + InputHandler *_inputHandler; DisplayManager *_displayManager; - + void setFullScreenImageParams(); void loadNextImage(); void loadLastImage(); @@ -66,19 +66,19 @@ private: void moveImageX(float val); void moveImageY(float val); bool load(int imageNum); - void unload(); + void unload(); void runLoop(); // to get total pausing we have to do our own loop - + void setZoom(float value); void setOffsetParams(); void modifyZoom(bool up); // up or down void setVisible(bool visible); - + public: - ImageViewer() : _buffer(0), _palette(0), _visible(false), - _dirty(false), _init(false), _imageNum(0), - _zoomFactor(0.0f), _visibleHeight(0.0f), _visibleWidth(0.0f), + ImageViewer() : _buffer(0), _palette(0), _visible(false), + _dirty(false), _init(false), _imageNum(0), + _zoomFactor(0.0f), _visibleHeight(0.0f), _visibleWidth(0.0f), _centerX(0.0f), _centerY(0.0f), _movement(EVENT_MOVE_STOP), _inputHandler(0), _displayManager(0) {} ~ImageViewer() { unload(); } // deallocate images @@ -88,15 +88,15 @@ public: bool isDirty() { return _dirty; } void setDirty() { _dirty = true; } void setClean() { if (!_visible) // otherwise we want to keep rendering - _dirty = false; - } + _dirty = false; + } void resetOnEngineDone(); - + void handleEvent(uint32 event); - + // pointer setters - void setInputHandler(InputHandler *inputHandler) { _inputHandler = inputHandler; } + void setInputHandler(InputHandler *inputHandler) { _inputHandler = inputHandler; } void setDisplayManager(DisplayManager *displayManager) { _displayManager = displayManager; } }; -#endif /* PSP_IMAGE_VIEWER_H */
\ No newline at end of file +#endif /* PSP_IMAGE_VIEWER_H */
\ No newline at end of file diff --git a/backends/platform/psp/input.cpp b/backends/platform/psp/input.cpp index 17f8954e3b..a9ad441b4d 100644 --- a/backends/platform/psp/input.cpp +++ b/backends/platform/psp/input.cpp @@ -198,7 +198,7 @@ bool ButtonPad::getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData & uint32 curButtonState = PSP_ALL_BUTTONS & pad.Buttons; // we only care about these if (_combosEnabled) - modifyButtonsForCombos(pad); // change buttons for combos + modifyButtonsForCombos(pad); // change buttons for combos return getEventFromButtonState(event, pspEvent, curButtonState); } @@ -460,7 +460,7 @@ bool InputHandler::handlePspEvent(Common::Event &event, PspEvent &pspEvent) { /*case PSP_EVENT_CHANGE_SPEED: handleSpeedChange(pspEvent.data); break;*/ - case PSP_EVENT_IMAGE_VIEWER: + case PSP_EVENT_IMAGE_VIEWER: _imageViewer->handleEvent(pspEvent.data); break; case PSP_EVENT_IMAGE_VIEWER_SET_BUTTONS: @@ -530,7 +530,7 @@ void InputHandler::setImageViewerMode(bool active) { _nub.init(); _buttonPad.enableCombos(true); // re-enable combos _buttonPad.initButtons(); - } + } } void InputHandler::setButtonsForImageViewer() { @@ -538,32 +538,32 @@ void InputHandler::setButtonsForImageViewer() { // Dpad _buttonPad.clearButtons(); - _buttonPad.getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_IN, + _buttonPad.getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_IN, + PSP_EVENT_NONE, false); + _buttonPad.getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_OUT, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_ZOOM_OUT, + _buttonPad.getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_LAST_IMAGE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_LAST_IMAGE, + _buttonPad.getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_NEXT_IMAGE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_NEXT_IMAGE, - PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_LTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_LTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_RTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_RTRIGGER, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_START, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_START, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); - _buttonPad.getButton(ButtonPad::BTN_SELECT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, + _buttonPad.getButton(ButtonPad::BTN_SELECT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_HIDE, PSP_EVENT_NONE, false); //Nub _nub.getPad().clearButtons(); - _nub.getPad().getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_UP, + _nub.getPad().getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_UP, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); - _nub.getPad().getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_DOWN, + _nub.getPad().getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_DOWN, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); - _nub.getPad().getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_LEFT, + _nub.getPad().getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_LEFT, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); - _nub.getPad().getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_RIGHT, + _nub.getPad().getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_RIGHT, PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); } diff --git a/backends/platform/psp/input.h b/backends/platform/psp/input.h index 8315a3766c..ef2e1b84a4 100644 --- a/backends/platform/psp/input.h +++ b/backends/platform/psp/input.h @@ -122,16 +122,16 @@ public: ButtonPad(); void initButtons(); // set the buttons to the mode that's selected void clearButtons(); // empty the buttons of all events - + bool getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad); bool getEventFromButtonState(Common::Event &event, PspEvent &pspEvent, uint32 buttonState); - + void setShifted(ShiftMode shifted) { _shifted = shifted; } void setPadMode(PspPadMode mode) { _padMode = mode; } bool isButtonDown() { return _prevButtonState; } - + void enableCombos(bool value) { _combosEnabled = value; } - Button &getButton(ButtonType type, ShiftMode mode) { return _button[type][mode]; } + Button &getButton(ButtonType type, ShiftMode mode) { return _button[type][mode]; } }; class Nub { @@ -140,17 +140,17 @@ private: ShiftMode _shifted; bool _dpadMode; - + ButtonPad _buttonPad; // private buttonpad for dpad mode - + int32 modifyNubAxisMotion(int32 input); void translateToDpadState(int dpadX, int dpadY, uint32 &buttonState); // convert nub data to dpad data public: Nub() : _shifted(UNSHIFTED), _dpadMode(false) { } - void init() { _buttonPad.initButtons(); } + void init() { _buttonPad.initButtons(); } void setCursor(Cursor *cursor) { _cursor = cursor; } - + // setters void setDpadMode(bool active) { _dpadMode = active; } void setShifted(ShiftMode shifted) { _shifted = shifted; } @@ -163,7 +163,7 @@ public: class InputHandler { public: - InputHandler() : _keyboard(0), _cursor(0), _imageViewer(0), _padMode(PAD_MODE_NORMAL), + InputHandler() : _keyboard(0), _cursor(0), _imageViewer(0), _padMode(PAD_MODE_NORMAL), _lastPadCheckTime(0) {} // pointer setters void setKeyboard(PSPKeyboard *keyboard) { _keyboard = keyboard; } @@ -175,7 +175,7 @@ public: void setImageViewerMode(bool active); private: - Nub _nub; + Nub _nub; ButtonPad _buttonPad; // Pointers to relevant other classes diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index 01124b420e..5fa5110684 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -20,8 +20,7 @@ * */ -// Allow use of stuff in <time.h> -#define FORBIDDEN_SYMBOL_EXCEPTION_time_h +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include <pspuser.h> #include <pspgu.h> @@ -84,7 +83,7 @@ void OSystem_PSP::initBackend() { _inputHandler.setKeyboard(&_keyboard); _inputHandler.setImageViewer(&_imageViewer); _inputHandler.init(); - + // Set pointers for image viewer _imageViewer.setInputHandler(&_inputHandler); _imageViewer.setDisplayManager(&_displayManager); @@ -422,7 +421,15 @@ void OSystem_PSP::quit() { } void OSystem_PSP::logMessage(LogMessageType::Type type, const char *message) { - EventsBaseBackend::logMessage(type, message); + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); if (type == LogMessageType::kError) PspDebugTrace(false, "%s", message); // write to file diff --git a/backends/platform/psp/png_loader.cpp b/backends/platform/psp/png_loader.cpp index 2f4857569e..16377539c8 100644 --- a/backends/platform/psp/png_loader.cpp +++ b/backends/platform/psp/png_loader.cpp @@ -36,7 +36,7 @@ PngLoader::Status PngLoader::allocate() { DEBUG_ENTER_FUNC(); - + if (!findImageDimensions()) { PSP_ERROR("failed to get image dimensions\n"); return BAD_FILE; @@ -45,7 +45,7 @@ PngLoader::Status PngLoader::allocate() { _buffer->setSize(_width, _height, _sizeBy); uint32 bitsPerPixel = _bitDepth * _channels; - + if (_paletteSize) { // 8 or 4-bit image if (bitsPerPixel == 4) { _buffer->setPixelFormat(PSPPixelFormat::Type_Palette_4bit); @@ -130,7 +130,7 @@ bool PngLoader::basicImageLoad() { png_get_IHDR(_pngPtr, _infoPtr, (png_uint_32 *)&_width, (png_uint_32 *)&_height, &_bitDepth, &_colorType, &interlaceType, int_p_NULL, int_p_NULL); _channels = png_get_channels(_pngPtr, _infoPtr); - + if (_colorType & PNG_COLOR_MASK_PALETTE) _paletteSize = _infoPtr->num_palette; @@ -141,7 +141,7 @@ bool PngLoader::basicImageLoad() { bool PngLoader::findImageDimensions() { DEBUG_ENTER_FUNC(); - bool status = basicImageLoad(); + bool status = basicImageLoad(); PSP_DEBUG_PRINT("width[%d], height[%d], paletteSize[%d], bitDepth[%d], channels[%d], rowBytes[%d]\n", _width, _height, _paletteSize, _bitDepth, _channels, _infoPtr->rowbytes); png_destroy_read_struct(&_pngPtr, &_infoPtr, png_infopp_NULL); @@ -157,7 +157,7 @@ bool PngLoader::loadImageIntoBuffer() { if (!basicImageLoad()) { png_destroy_read_struct(&_pngPtr, &_infoPtr, png_infopp_NULL); return false; - } + } png_set_strip_16(_pngPtr); // Strip off 16 bit channels in case they occur if (_paletteSize) { @@ -178,16 +178,16 @@ bool PngLoader::loadImageIntoBuffer() { } uint32 rowBytes = png_get_rowbytes(_pngPtr, _infoPtr); - - // there seems to be a bug in libpng where it doesn't increase the rowbytes or the + + // there seems to be a bug in libpng where it doesn't increase the rowbytes or the // channel even after we add the alpha channel if (_channels == 3 && (rowBytes / _width) == 3) { _channels = 4; - rowBytes = _width * _channels; - } - + rowBytes = _width * _channels; + } + PSP_DEBUG_PRINT("rowBytes[%d], channels[%d]\n", rowBytes, _channels); - + unsigned char *line = (unsigned char*) malloc(rowBytes); if (!line) { png_destroy_read_struct(&_pngPtr, png_infopp_NULL, png_infopp_NULL); diff --git a/backends/platform/psp/png_loader.h b/backends/platform/psp/png_loader.h index 616a79405e..0ff9d8a65d 100644 --- a/backends/platform/psp/png_loader.h +++ b/backends/platform/psp/png_loader.h @@ -61,7 +61,7 @@ public: Buffer::HowToSize sizeBy = Buffer::kSizeByTextureSize) : _file(file), _buffer(&buffer), _palette(&palette), _width(0), _height(0), _paletteSize(0), - _bitDepth(0), _sizeBy(sizeBy), _pngPtr(0), + _bitDepth(0), _sizeBy(sizeBy), _pngPtr(0), _infoPtr(0), _colorType(0), _channels(0) {} PngLoader::Status allocate(); diff --git a/backends/platform/psp/powerman.cpp b/backends/platform/psp/powerman.cpp index fe9dcfa673..b72d05809d 100644 --- a/backends/platform/psp/powerman.cpp +++ b/backends/platform/psp/powerman.cpp @@ -30,7 +30,9 @@ //#define __PSP_DEBUG_PRINT__ #include "backends/platform/psp/trace.h" +namespace Common { DECLARE_SINGLETON(PowerManager); +} // Function to debug the Power Manager (we have no output to screen) inline void PowerManager::debugPM() { diff --git a/backends/platform/psp/rtc.cpp b/backends/platform/psp/rtc.cpp index 3d6d4295a6..6c8e919986 100644 --- a/backends/platform/psp/rtc.cpp +++ b/backends/platform/psp/rtc.cpp @@ -34,7 +34,9 @@ // Class PspRtc --------------------------------------------------------------- +namespace Common { DECLARE_SINGLETON(PspRtc); +} void PspRtc::init() { // init our starting ticks uint32 ticks[2]; diff --git a/backends/platform/psp/trace.cpp b/backends/platform/psp/trace.cpp index 373e00415b..b799b4e870 100644 --- a/backends/platform/psp/trace.cpp +++ b/backends/platform/psp/trace.cpp @@ -75,38 +75,38 @@ void PspDebugTrace(bool alsoToScreen, const char *format, ...) { #define GET_RET(retAddr) \ asm volatile ("move %0,$ra\n\t" \ : "=&r" (retAddr) : ) - + #define GET_SP(stackPtr) \ asm volatile ("move %0,$sp\n\t" \ : "=&r" (stackPtr) : ) // Function to retrieve a backtrace for the MIPS processor -// This is not trivial since the MIPS doesn't use a frame pointer. +// This is not trivial since the MIPS doesn't use a frame pointer. // Takes the number of levels wanted above the calling function (included) and an array of void * -// +// void mipsBacktrace(uint32 levels, void **addresses) { - // get the current return address + // get the current return address register byte *retAddr; register byte *stackPointer; - GET_RET(retAddr); + GET_RET(retAddr); GET_SP(stackPointer); char string[100]; - + if (!levels) return; - + memset(addresses, 0, sizeof(void *) * levels); - + uint32 curLevel = 0; - + const uint32 SP_SUBTRACT = 0x27bd8000; // The instruction to subtract from the SP looks like this const uint32 SP_SUB_HIGH_MASK = 0xffff8000; // The mask to check for the subtract SP instruction const uint32 SP_SUB_LOW_MASK = 0x0000ffff; // The mask that gives us how much was subtracted - + // make sure we go out of the stack of this current level // we already have the return address for this level from the register if (curLevel < levels) { - void *thisFunc = (void *)mipsBacktrace; + void *thisFunc = (void *)mipsBacktrace; for (uint32 *seekPtr = (uint32 *)thisFunc; ; seekPtr++) { if ((*seekPtr & SP_SUB_HIGH_MASK) == SP_SUBTRACT) { // we found the $sp subtraction at the beginning of the function @@ -120,10 +120,10 @@ void mipsBacktrace(uint32 levels, void **addresses) { fputs(string, stderr); } break; - } - } + } + } } - + // keep scanning while more levels are requested while (curLevel < levels) { // now scan backwards from the return address to find the size of the stack @@ -139,13 +139,13 @@ void mipsBacktrace(uint32 levels, void **addresses) { sprintf(string, "invalid retAddr %p\n", retAddr); fputs(string, stderr); return; - } + } //sprintf(string, "retAddr[%p]\n", retAddr); //fputs(string, stderr); addresses[curLevel++] = retAddr; break; - } - } + } + } } -} +} diff --git a/backends/platform/sdl/macosx/appmenu_osx.h b/backends/platform/sdl/macosx/appmenu_osx.h new file mode 100755 index 0000000000..005414b789 --- /dev/null +++ b/backends/platform/sdl/macosx/appmenu_osx.h @@ -0,0 +1,32 @@ +/* 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. + * + */ + +#ifndef APPMENU_OSX_H +#define APPMENU_OSX_H + +#if defined(MACOSX) + +void replaceApplicationMenuItems(); + +#endif // MACOSX + +#endif diff --git a/backends/platform/sdl/macosx/appmenu_osx.mm b/backends/platform/sdl/macosx/appmenu_osx.mm new file mode 100755 index 0000000000..bb089a6b61 --- /dev/null +++ b/backends/platform/sdl/macosx/appmenu_osx.mm @@ -0,0 +1,110 @@ +/* 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. + * + */ + +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "backends/platform/sdl/macosx/appmenu_osx.h" +#include "common/translation.h" + +#include <Cocoa/Cocoa.h> + +// Apple removed setAppleMenu from the header files in 10.4, +// but as the method still exists we declare it ourselves here. +// Yes, this works :) +@interface NSApplication(MissingFunction) +- (void)setAppleMenu:(NSMenu *)menu; +@end + +void replaceApplicationMenuItems() { + + // Code mainly copied and adapted from SDLmain.m + NSMenu *appleMenu; + NSMenu *windowMenu; + NSMenuItem *menuItem; + + // For some reason [[NSApp mainMenu] removeAllItems] doesn't work and crashes, so we need + // to remove the SDL generated menus one by one + [[NSApp mainMenu] removeItemAtIndex:0]; // Remove application menu + [[NSApp mainMenu] removeItemAtIndex:0]; // Remove "Windows" menu + + // Create new application menu + appleMenu = [[NSMenu alloc] initWithTitle:@""]; + + // Get current encoding +#ifdef USE_TRANSLATION + NSStringEncoding stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)[NSString stringWithCString:(TransMan.getCurrentCharset()).c_str() encoding:NSASCIIStringEncoding])); +#else + NSStringEncoding stringEncoding = NSASCIIStringEncoding; +#endif + + // Add "About ScummVM" menu item + [appleMenu addItemWithTitle:[NSString stringWithCString:_("About ScummVM") encoding:stringEncoding] action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; + + // Add separator + [appleMenu addItem:[NSMenuItem separatorItem]]; + + // Add "Hide ScummVM" menu item + [appleMenu addItemWithTitle:[NSString stringWithCString:_("Hide ScummVM") encoding:stringEncoding] action:@selector(hide:) keyEquivalent:@"h"]; + + // Add "Hide Others" menu item + menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:[NSString stringWithCString:_("Hide Others") encoding:stringEncoding] action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; + [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; + + // Add "Show All" menu item + [appleMenu addItemWithTitle:[NSString stringWithCString:_("Show All") encoding:stringEncoding] action:@selector(unhideAllApplications:) keyEquivalent:@""]; + + // Add separator + [appleMenu addItem:[NSMenuItem separatorItem]]; + + // Add "Quit ScummVM" menu item + [appleMenu addItemWithTitle:[NSString stringWithCString:_("Quit ScummVM") encoding:stringEncoding] action:@selector(terminate:) keyEquivalent:@"q"]; + + // Put application menu into the menubar + menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; + [menuItem setSubmenu:appleMenu]; + [[NSApp mainMenu] addItem:menuItem]; + + // Tell the application object that this is now the application menu + [NSApp setAppleMenu:appleMenu]; + + + // Create new "Window" menu + windowMenu = [[NSMenu alloc] initWithTitle:[NSString stringWithCString:_("Window") encoding:stringEncoding]]; + + // Add "Minimize" menu item + menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:_("Minimize") encoding:stringEncoding] action:@selector(performMiniaturize:) keyEquivalent:@"m"]; + [windowMenu addItem:menuItem]; + + // Put menu into the menubar + menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:_("Window") encoding:stringEncoding] action:nil keyEquivalent:@""]; + [menuItem setSubmenu:windowMenu]; + [[NSApp mainMenu] addItem:menuItem]; + + // Tell the application object that this is now the window menu. + [NSApp setWindowsMenu:windowMenu]; + + // Finally give up our references to the objects + [appleMenu release]; + [windowMenu release]; + [menuItem release]; +} diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 9b11eb2c09..ddfc99570a 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -29,9 +29,12 @@ #include "backends/platform/sdl/macosx/macosx.h" #include "backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h" +#include "backends/platform/sdl/macosx/appmenu_osx.h" #include "common/archive.h" +#include "common/config-manager.h" #include "common/fs.h" +#include "common/translation.h" #include "ApplicationServices/ApplicationServices.h" // for LSOpenFSRef #include "CoreFoundation/CoreFoundation.h" // for CF* stuff @@ -51,6 +54,15 @@ void OSystem_MacOSX::initBackend() { _mixerManager->init(); } +#ifdef USE_TRANSLATION + // We need to initialize the translataion manager here for the following + // call to replaceApplicationMenuItems() work correctly + TransMan.setLanguage(ConfMan.get("gui_language").c_str()); +#endif // USE_TRANSLATION + + // Replace the SDL generated menu items with our own translated ones on Mac OS X + replaceApplicationMenuItems(); + // Invoke parent implementation of this method OSystem_POSIX::initBackend(); } @@ -74,7 +86,7 @@ void OSystem_MacOSX::addSysArchivesToSearchSet(Common::SearchSet &s, int priorit } void OSystem_MacOSX::setupIcon() { - // Don't set icon on OS X, as we use a nicer external icon there. + // Don't set icon on OS X, as we use a nicer external icon there. } bool OSystem_MacOSX::hasFeature(Feature f) { diff --git a/backends/platform/sdl/main.cpp b/backends/platform/sdl/main.cpp index 1992bdd3f2..3947d010c4 100644 --- a/backends/platform/sdl/main.cpp +++ b/backends/platform/sdl/main.cpp @@ -34,6 +34,7 @@ !defined(CAANOO) && \ !defined(LINUXMOTO) && \ !defined(SAMSUNGTV) && \ + !defined(PLAYSTATION3) && \ !defined(OPENPANDORA) #include "backends/platform/sdl/sdl.h" diff --git a/backends/platform/sdl/module.mk b/backends/platform/sdl/module.mk index efc5168d5b..f1afe37349 100644 --- a/backends/platform/sdl/module.mk +++ b/backends/platform/sdl/module.mk @@ -14,7 +14,8 @@ endif ifdef MACOSX MODULE_OBJS += \ macosx/macosx-main.o \ - macosx/macosx.o + macosx/macosx.o \ + macosx/appmenu_osx.o endif ifdef WIN32 @@ -29,6 +30,12 @@ MODULE_OBJS += \ amigaos/amigaos.o endif +ifdef PLAYSTATION3 +MODULE_OBJS += \ + ps3/ps3-main.o \ + ps3/ps3.o +endif + # We don't use rules.mk but rather manually update OBJS and MODULE_DIRS. MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) OBJS := $(MODULE_OBJS) $(OBJS) diff --git a/backends/platform/sdl/posix/posix-main.cpp b/backends/platform/sdl/posix/posix-main.cpp index f78e001398..3bf7a5138a 100644 --- a/backends/platform/sdl/posix/posix-main.cpp +++ b/backends/platform/sdl/posix/posix-main.cpp @@ -22,7 +22,7 @@ #include "common/scummsys.h" -#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) +#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) && !defined(PLAYSTATION3) #include "backends/platform/sdl/posix/posix.h" #include "backends/plugins/sdl/sdl-provider.h" diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index d757186134..05c779a4e0 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -33,6 +33,7 @@ #include "backends/platform/sdl/posix/posix.h" #include "backends/saves/posix/posix-saves.h" #include "backends/fs/posix/posix-fs-factory.h" +#include "backends/taskbar/unity/unity-taskbar.h" #include <errno.h> #include <sys/stat.h> @@ -49,6 +50,11 @@ void OSystem_POSIX::init() { // Initialze File System Factory _fsFactory = new POSIXFilesystemFactory(); +#if defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) + // Initialize taskbar manager + _taskbarManager = new UnityTaskbarManager(); +#endif + // Invoke parent implementation of this method OSystem_SDL::init(); } @@ -60,6 +66,11 @@ void OSystem_POSIX::initBackend() { // Invoke parent implementation of this method OSystem_SDL::initBackend(); + +#if defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) + // Register the taskbar manager as an event source (this is necessary for the glib event loop to be run) + _eventManager->getEventDispatcher()->registerSource((UnityTaskbarManager *)_taskbarManager, false); +#endif } bool OSystem_POSIX::hasFeature(Feature f) { diff --git a/backends/platform/sdl/ps3/ps3-main.cpp b/backends/platform/sdl/ps3/ps3-main.cpp new file mode 100644 index 0000000000..ba548a3749 --- /dev/null +++ b/backends/platform/sdl/ps3/ps3-main.cpp @@ -0,0 +1,49 @@ +/* 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 "common/scummsys.h" + +#include "backends/platform/sdl/ps3/ps3.h" +#include "backends/plugins/sdl/sdl-provider.h" +#include "base/main.h" + +int main(int argc, char *argv[]) { + + // Create our OSystem instance + g_system = new OSystem_PS3(); + assert(g_system); + + // Pre initialize the backend + ((OSystem_PS3 *)g_system)->init(); + +#ifdef DYNAMIC_MODULES + PluginManager::instance().addPluginProvider(new SDLPluginProvider()); +#endif + + // Invoke the actual ScummVM main entry point: + int res = scummvm_main(argc, argv); + + // Free OSystem + delete (OSystem_PS3 *)g_system; + + return res; +} diff --git a/backends/platform/sdl/ps3/ps3.cpp b/backends/platform/sdl/ps3/ps3.cpp new file mode 100644 index 0000000000..33586ce693 --- /dev/null +++ b/backends/platform/sdl/ps3/ps3.cpp @@ -0,0 +1,94 @@ +/* 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. + * + */ + +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_time_h // sys/stat.h includes sys/time.h +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h + +#include "common/scummsys.h" +#include "common/config-manager.h" +#include "backends/platform/sdl/ps3/ps3.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" +#include "backends/saves/default/default-saves.h" +#include "backends/fs/ps3/ps3-fs-factory.h" +#include "backends/events/ps3sdl/ps3sdl-events.h" +#include "backends/mixer/sdl13/sdl13-mixer.h" + +#include <dirent.h> +#include <sys/stat.h> + +int access(const char *pathname, int mode) { + struct stat sb; + + if (stat(pathname, &sb) == -1) { + return -1; + } + + return 0; +} + +OSystem_PS3::OSystem_PS3(Common::String baseConfigName) + : _baseConfigName(baseConfigName) { +} + +void OSystem_PS3::init() { + // Initialze File System Factory + _fsFactory = new PS3FilesystemFactory(); + + // Invoke parent implementation of this method + OSystem_SDL::init(); +} + +void OSystem_PS3::initBackend() { + ConfMan.set("joystick_num", 0); + ConfMan.set("vkeybdpath", PREFIX "/data"); + ConfMan.registerDefault("fullscreen", true); + ConfMan.registerDefault("aspect_ratio", true); + + // Create the savefile manager + if (_savefileManager == 0) + _savefileManager = new DefaultSaveFileManager(PREFIX "/saves"); + + // Create the mixer manager + if (_mixer == 0) { + _mixerManager = new Sdl13MixerManager(); + + // Setup and start mixer + _mixerManager->init(); + } + + // Event source + if (_eventSource == 0) + _eventSource = new PS3SdlEventSource(); + + // Invoke parent implementation of this method + OSystem_SDL::initBackend(); +} + +Common::String OSystem_PS3::getDefaultConfigFileName() { + return PREFIX "/" + _baseConfigName; +} + +Common::WriteStream *OSystem_PS3::createLogFile() { + Common::FSNode file(PREFIX "/scummvm.log"); + return file.createWriteStream(); +} diff --git a/backends/platform/sdl/ps3/ps3.h b/backends/platform/sdl/ps3/ps3.h new file mode 100644 index 0000000000..daed7599a9 --- /dev/null +++ b/backends/platform/sdl/ps3/ps3.h @@ -0,0 +1,47 @@ +/* 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. + * + */ + +#ifndef PLATFORM_SDL_PS3_H +#define PLATFORM_SDL_PS3_H + +#include "backends/platform/sdl/sdl.h" + +class OSystem_PS3 : public OSystem_SDL { +public: + // Let the subclasses be able to change _baseConfigName in the constructor + OSystem_PS3(Common::String baseConfigName = "scummvm.ini"); + virtual ~OSystem_PS3() {} + + virtual void init(); + virtual void initBackend(); + +protected: + // Base string for creating the default path and filename + // for the configuration file + Common::String _baseConfigName; + + virtual Common::String getDefaultConfigFileName(); + + virtual Common::WriteStream *createLogFile(); +}; + +#endif diff --git a/backends/platform/sdl/sdl-sys.h b/backends/platform/sdl/sdl-sys.h index 77515ff4e5..ca3c586e03 100644 --- a/backends/platform/sdl/sdl-sys.h +++ b/backends/platform/sdl/sdl-sys.h @@ -27,7 +27,7 @@ // fashion, even on the Symbian port. // Moreover, it contains a workaround for the fact that SDL_rwops.h uses // a FILE pointer in one place, which conflicts with common/forbidden.h. - +// The SDL 1.3 headers also include strings.h #include "common/scummsys.h" @@ -39,6 +39,16 @@ typedef struct { int FAKE; } FAKE_FILE; #define FILE FAKE_FILE #endif +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strcasecmp) +#undef strcasecmp +#define strcasecmp FAKE_strcasecmp +#endif + +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strncasecmp) +#undef strncasecmp +#define strncasecmp FAKE_strncasecmp +#endif + #if defined(__SYMBIAN32__) #include <esdl\SDL.h> #else @@ -47,8 +57,19 @@ typedef struct { int FAKE; } FAKE_FILE; // Finally forbid FILE again (if it was forbidden to start with) #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_FILE) -#undef FILE +#undef FILE #define FILE FORBIDDEN_SYMBOL_REPLACEMENT #endif +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strcasecmp) +#undef strcasecmp +#define strcasecmp FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strncasecmp) +#undef strncasecmp +#define strncasecmp FORBIDDEN_SYMBOL_REPLACEMENT +#endif + + #endif diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index afc6c850d9..d05cca4d1f 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -31,14 +31,22 @@ #include "backends/platform/sdl/sdl.h" #include "common/config-manager.h" #include "common/EventRecorder.h" +#include "common/taskbar.h" #include "common/textconsole.h" #include "backends/saves/default/default-saves.h" + +// Audio CD support was removed with SDL 1.3 +#if SDL_VERSION_ATLEAST(1, 3, 0) +#include "backends/audiocd/default/default-audiocd.h" +#else #include "backends/audiocd/sdl/sdl-audiocd.h" +#endif + #include "backends/events/sdl/sdl-events.h" #include "backends/mutex/sdl/sdl-mutex.h" #include "backends/timer/sdl/sdl-timer.h" -#include "backends/graphics/sdl/sdl-graphics.h" +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" #ifdef USE_OPENGL #include "backends/graphics/openglsdl/openglsdl-graphics.h" #endif @@ -125,6 +133,11 @@ void OSystem_SDL::init() { if (_timerManager == 0) _timerManager = new SdlTimerManager(); +#if defined(USE_TASKBAR) + if (_taskbarManager == 0) + _taskbarManager = new Common::TaskbarManager(); +#endif + #ifdef USE_OPENGL // Setup a list with both SDL and OpenGL graphics modes setupGraphicsModes(); @@ -167,27 +180,11 @@ void OSystem_SDL::initBackend() { } #endif if (_graphicsManager == 0) { - _graphicsManager = new SdlGraphicsManager(_eventSource); + _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); graphicsManagerType = 0; } } - // Creates the backend managers, if they don't exist yet (we check - // for this to allow subclasses to provide their own). - if (_eventManager == 0) - _eventManager = new DefaultEventManager(_eventSource); - - // We have to initialize the graphics manager before the event manager - // so the virtual keyboard can be initialized, but we have to add the - // graphics manager as an event observer after initializing the event - // manager. - if (graphicsManagerType == 0) - ((SdlGraphicsManager *)_graphicsManager)->initEventObserver(); -#ifdef USE_OPENGL - else if (graphicsManagerType == 1) - ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); -#endif - if (_savefileManager == 0) _savefileManager = new DefaultSaveFileManager(); @@ -198,8 +195,15 @@ void OSystem_SDL::initBackend() { _mixerManager->init(); } - if (_audiocdManager == 0) + if (_audiocdManager == 0) { + // Audio CD support was removed with SDL 1.3 +#if SDL_VERSION_ATLEAST(1, 3, 0) + _audiocdManager = new DefaultAudioCDManager(); +#else _audiocdManager = new SdlAudioCDManager(); +#endif + + } // Setup a custom program icon. setupIcon(); @@ -207,7 +211,34 @@ void OSystem_SDL::initBackend() { _inited = true; ModularBackend::initBackend(); + + // We have to initialize the graphics manager before the event manager + // so the virtual keyboard can be initialized, but we have to add the + // graphics manager as an event observer after initializing the event + // manager. + if (graphicsManagerType == 0) + ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); +#ifdef USE_OPENGL + else if (graphicsManagerType == 1) + ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); +#endif + +} + +#if defined(USE_TASKBAR) +void OSystem_SDL::engineInit() { + // Add the started engine to the list of recent tasks + _taskbarManager->addRecent(ConfMan.getActiveDomainName(), ConfMan.get("description")); + + // Set the overlay icon the current running engine + _taskbarManager->setOverlayIcon(ConfMan.getActiveDomainName(), ConfMan.get("description")); +} + +void OSystem_SDL::engineDone() { + // Remove overlay icon + _taskbarManager->setOverlayIcon("", ""); } +#endif void OSystem_SDL::initSDL() { // Check if SDL has not been initialized @@ -275,10 +306,22 @@ void OSystem_SDL::fatalError() { void OSystem_SDL::logMessage(LogMessageType::Type type, const char *message) { - ModularBackend::logMessage(type, message); + // First log to stdout/stderr + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); + + // Then log into file (via the logger) if (_logger) _logger->print(message); + // Finally, some Windows / WinCE specific logging code. #if defined( USE_WINDBG ) #if defined( _WIN32_WCE ) TCHAR buf_unicode[1024]; @@ -301,7 +344,7 @@ void OSystem_SDL::logMessage(LogMessageType::Type type, const char *message) { } Common::String OSystem_SDL::getSystemLanguage() const { -#ifdef USE_DETECTLANG +#if defined(USE_DETECTLANG) && !defined(_WIN32_WCE) #ifdef WIN32 // We can not use "setlocale" (at least not for MSVC builds), since it // will return locales like: "English_USA.1252", thus we need a special @@ -368,7 +411,7 @@ void OSystem_SDL::setupIcon() { if (sscanf(scummvm_icon[0], "%d %d %d %d", &w, &h, &ncols, &nbytes) != 4) { warning("Wrong format of scummvm_icon[0] (%s)", scummvm_icon[0]); - + return; } if ((w > 512) || (h > 512) || (ncols > 255) || (nbytes > 1)) { @@ -384,6 +427,7 @@ void OSystem_SDL::setupIcon() { for (i = 0; i < ncols; i++) { unsigned char code; char color[32]; + memset(color, 0, sizeof(color)); unsigned int col; if (sscanf(scummvm_icon[1 + i], "%c c %s", &code, color) != 2) { warning("Wrong format of scummvm_icon[%d] (%s)", 1 + i, scummvm_icon[1 + i]); @@ -472,7 +516,7 @@ bool OSystem_SDL::setGraphicsMode(int mode) { // Check if mode is from SDL or OpenGL if (mode < _sdlModesCount) { - srcMode = SdlGraphicsManager::supportedGraphicsModes(); + srcMode = SurfaceSdlGraphicsManager::supportedGraphicsModes(); i = 0; } else { srcMode = OpenGLSdlGraphicsManager::supportedGraphicsModes(); @@ -487,8 +531,8 @@ bool OSystem_SDL::setGraphicsMode(int mode) { if (_graphicsMode >= _sdlModesCount && mode < _sdlModesCount) { debug(1, "switching to plain SDL graphics"); delete _graphicsManager; - _graphicsManager = new SdlGraphicsManager(_eventSource); - ((SdlGraphicsManager *)_graphicsManager)->initEventObserver(); + _graphicsManager = new SurfaceSdlGraphicsManager(_eventSource); + ((SurfaceSdlGraphicsManager *)_graphicsManager)->initEventObserver(); _graphicsManager->beginGFXTransaction(); } else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) { debug(1, "switching to OpenGL graphics"); @@ -514,7 +558,7 @@ int OSystem_SDL::getGraphicsMode() const { } void OSystem_SDL::setupGraphicsModes() { - const OSystem::GraphicsMode *sdlGraphicsModes = SdlGraphicsManager::supportedGraphicsModes(); + const OSystem::GraphicsMode *sdlGraphicsModes = SurfaceSdlGraphicsManager::supportedGraphicsModes(); const OSystem::GraphicsMode *openglGraphicsModes = OpenGLSdlGraphicsManager::supportedGraphicsModes(); _sdlModesCount = 0; _glModesCount = 0; diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 9c08752054..395b2b3aac 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -30,7 +30,7 @@ #include "backends/events/sdl/sdl-events.h" #include "backends/log/log.h" -/** +/** * Base OSystem class for all SDL ports. */ class OSystem_SDL : public ModularBackend { @@ -38,7 +38,7 @@ public: OSystem_SDL(); virtual ~OSystem_SDL(); - /** + /** * Pre-initialize backend. It should be called after * instantiating the backend. Early needed managers are * created here. @@ -54,6 +54,10 @@ public: // Override functions from ModularBackend and OSystem virtual void initBackend(); +#if defined(USE_TASKBAR) + virtual void engineInit(); + virtual void engineDone(); +#endif virtual Common::HardwareKeySet *getHardwareKeySet(); virtual void quit(); virtual void fatalError(); diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 5b14be4417..a2c8e43424 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -23,10 +23,6 @@ // Disable symbol overrides so that we can use system headers. #define FORBIDDEN_SYMBOL_ALLOW_ALL -#include "common/scummsys.h" -#include "common/error.h" -#include "common/textconsole.h" - #ifdef WIN32 #define WIN32_LEAN_AND_MEAN @@ -34,58 +30,52 @@ #undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one... #include <shellapi.h> +#include "common/scummsys.h" +#include "common/config-manager.h" +#include "common/error.h" +#include "common/textconsole.h" + +#include <SDL_syswm.h> // For setting the icon + #include "backends/platform/sdl/win32/win32.h" #include "backends/fs/windows/windows-fs-factory.h" +#include "backends/taskbar/win32/win32-taskbar.h" #include "common/memstream.h" #define DEFAULT_CONFIG_FILE "scummvm.ini" -//#define HIDE_CONSOLE +void OSystem_Win32::init() { + // Initialize File System Factory + _fsFactory = new WindowsFilesystemFactory(); -#ifdef HIDE_CONSOLE -struct SdlConsoleHidingWin32 { - DWORD myPid; - DWORD myTid; - HWND consoleHandle; -}; +#if defined(USE_TASKBAR) + // Initialize taskbar manager + _taskbarManager = new Win32TaskbarManager(); +#endif -// console hiding for win32 -static BOOL CALLBACK initBackendFindConsoleWin32Proc(HWND hWnd, LPARAM lParam) { - DWORD pid, tid; - SdlConsoleHidingWin32 *variables = (SdlConsoleHidingWin32 *)lParam; - tid = GetWindowThreadProcessId(hWnd, &pid); - if ((tid == variables->myTid) && (pid == variables->myPid)) { - variables->consoleHandle = hWnd; - return FALSE; - } - return TRUE; + // Invoke parent implementation of this method + OSystem_SDL::init(); } -#endif +void OSystem_Win32::initBackend() { + // Console window is enabled by default on Windows + ConfMan.registerDefault("console", true); -void OSystem_Win32::init() { -#ifdef HIDE_CONSOLE - // console hiding for win32 - SdlConsoleHidingWin32 consoleHidingWin32; - consoleHidingWin32.consoleHandle = 0; - consoleHidingWin32.myPid = GetCurrentProcessId(); - consoleHidingWin32.myTid = GetCurrentThreadId(); - EnumWindows (initBackendFindConsoleWin32Proc, (LPARAM)&consoleHidingWin32); - - if (!ConfMan.getBool("show_console")) { - if (consoleHidingWin32.consoleHandle) { - // We won't find a window with our TID/PID in case we were started from command-line - ShowWindow(consoleHidingWin32.consoleHandle, SW_HIDE); + // Enable or disable the window console window + if (ConfMan.getBool("console")) { + if (AllocConsole()) { + freopen("CONIN$","r",stdin); + freopen("CONOUT$","w",stdout); + freopen("CONOUT$","w",stderr); } + SetConsoleTitle("ScummVM Status Window"); + } else { + FreeConsole(); } -#endif - - // Initialze File System Factory - _fsFactory = new WindowsFilesystemFactory(); // Invoke parent implementation of this method - OSystem_SDL::init(); + OSystem_SDL::initBackend(); } @@ -131,6 +121,28 @@ bool OSystem_Win32::displayLogFile() { return false; } +void OSystem_Win32::setupIcon() { + HMODULE handle = GetModuleHandle(NULL); + HICON ico = LoadIcon(handle, MAKEINTRESOURCE(1001 /* IDI_ICON */)); + if (ico) { + SDL_SysWMinfo wminfo; + SDL_VERSION(&wminfo.version); + if (SDL_GetWMInfo(&wminfo)) { + // Replace the handle to the icon associated with the window class by our custom icon + SetClassLongPtr(wminfo.window, GCLP_HICON, (ULONG_PTR)ico); + + // Since there wasn't any default icon, we can't use the return value from SetClassLong + // to check for errors (it would be 0 in both cases: error or no previous value for the + // icon handle). Instead we check for the last-error code value. + if (GetLastError() == ERROR_SUCCESS) + return; + } + } + + // If no icon has been set, fallback to default path + OSystem_SDL::setupIcon(); +} + Common::String OSystem_Win32::getDefaultConfigFileName() { char configFile[MAXPATHLEN]; @@ -149,18 +161,31 @@ Common::String OSystem_Win32::getDefaultConfigFileName() { error("Unable to access user profile directory"); strcat(configFile, "\\Application Data"); - CreateDirectory(configFile, NULL); + + // If the directory already exists (as it should in most cases), + // we don't want to fail, but we need to stop on other errors (such as ERROR_PATH_NOT_FOUND) + if (!CreateDirectory(configFile, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) + error("Cannot create Application data folder"); + } } strcat(configFile, "\\ScummVM"); - CreateDirectory(configFile, NULL); + if (!CreateDirectory(configFile, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) + error("Cannot create ScummVM application data folder"); + } + strcat(configFile, "\\" DEFAULT_CONFIG_FILE); FILE *tmp = NULL; if ((tmp = fopen(configFile, "r")) == NULL) { // Check windows directory char oldConfigFile[MAXPATHLEN]; - GetWindowsDirectory(oldConfigFile, MAXPATHLEN); + uint ret = GetWindowsDirectory(oldConfigFile, MAXPATHLEN); + if (ret == 0 || ret > MAXPATHLEN) + error("Cannot retrieve the path of the Windows directory"); + strcat(oldConfigFile, "\\" DEFAULT_CONFIG_FILE); if ((tmp = fopen(oldConfigFile, "r"))) { strcpy(configFile, oldConfigFile); @@ -172,7 +197,10 @@ Common::String OSystem_Win32::getDefaultConfigFileName() { } } else { // Check windows directory - GetWindowsDirectory(configFile, MAXPATHLEN); + uint ret = GetWindowsDirectory(configFile, MAXPATHLEN); + if (ret == 0 || ret > MAXPATHLEN) + error("Cannot retrieve the path of the Windows directory"); + strcat(configFile, "\\" DEFAULT_CONFIG_FILE); } @@ -300,7 +328,7 @@ Common::SeekableReadStream *Win32ResourceArchive::createReadStreamForMember(cons } // End of anonymous namespace void OSystem_Win32::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { - s.add("Win32Res", new Win32ResourceArchive()); + s.add("Win32Res", new Win32ResourceArchive(), priority); OSystem_SDL::addSysArchivesToSearchSet(s, priority); } diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h index ef7b6af3f1..b56997a63b 100644 --- a/backends/platform/sdl/win32/win32.h +++ b/backends/platform/sdl/win32/win32.h @@ -28,6 +28,7 @@ class OSystem_Win32 : public OSystem_SDL { public: virtual void init(); + virtual void initBackend(); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); @@ -46,6 +47,7 @@ protected: */ Common::String _logFilePath; + virtual void setupIcon(); virtual Common::String getDefaultConfigFileName(); virtual Common::WriteStream *createLogFile(); }; diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index 9cccc81d19..b1bd976f9e 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -57,7 +57,7 @@ char *GetExecutablePath() { OSystem_SDL_Symbian::OSystem_SDL_Symbian() : _RFs(0) { - + } void OSystem_SDL_Symbian::init() { @@ -171,7 +171,7 @@ Common::String OSystem_SDL_Symbian::getDefaultConfigFileName() { } void OSystem_SDL_Symbian::setupIcon() { - // Don't for Symbian: it uses the EScummVM.aif file for the icon. + // Don't for Symbian: it uses the EScummVM.aif file for the icon. } RFs& OSystem_SDL_Symbian::FsSession() { diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp index c6b23783b8..258a782cc4 100644 --- a/backends/platform/wii/osystem.cpp +++ b/backends/platform/wii/osystem.cpp @@ -19,11 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -// Allow use of stuff in <time.h> -#define FORBIDDEN_SYMBOL_EXCEPTION_time_h - -#define FORBIDDEN_SYMBOL_EXCEPTION_printf -#define FORBIDDEN_SYMBOL_EXCEPTION_getcwd +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include <unistd.h> @@ -291,6 +287,18 @@ void OSystem_Wii::showOptionsDialog() { _padAcceleration = 9 - ConfMan.getInt("wii_pad_acceleration"); } +void OSystem_Wii::logMessage(LogMessageType::Type type, const char *message) { + FILE *output = 0; + + if (type == LogMessageType::kInfo || type == LogMessageType::kDebug) + output = stdout; + else + output = stderr; + + fputs(message, output); + fflush(output); +} + #ifndef GAMECUBE Common::String OSystem_Wii::getSystemLanguage() const { const char *wiiCountries[] = { diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h index 6863a6840e..64197f913a 100644 --- a/backends/platform/wii/osystem.h +++ b/backends/platform/wii/osystem.h @@ -211,6 +211,8 @@ public: virtual FilesystemFactory *getFilesystemFactory(); virtual void getTimeAndDate(TimeDate &t) const; + virtual void logMessage(LogMessageType::Type type, const char *message); + #ifndef GAMECUBE virtual Common::String getSystemLanguage() const; #endif // GAMECUBE diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index 859e3a1395..443e738a4a 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -20,6 +20,7 @@ */ #define FORBIDDEN_SYMBOL_EXCEPTION_printf +#define FORBIDDEN_SYMBOL_EXCEPTION_abort #include <malloc.h> diff --git a/backends/platform/wince/CEActionsPocket.cpp b/backends/platform/wince/CEActionsPocket.cpp index a4786d330d..5980a41caa 100644 --- a/backends/platform/wince/CEActionsPocket.cpp +++ b/backends/platform/wince/CEActionsPocket.cpp @@ -137,6 +137,7 @@ void CEActionsPocket::initInstanceGame() { bool is_tinsel = (gameid == "tinsel"); bool is_cruise = (gameid == "cruise"); bool is_made = (gameid == "made"); + bool is_sci = (gameid == "sci"); GUI_Actions::initInstanceGame(); @@ -214,12 +215,14 @@ void CEActionsPocket::initInstanceGame() { _key_action[POCKET_ACTION_MULTI].setKey(Common::ASCII_F1, SDLK_F1); // bargon : F1 to start else if (gameid == "atlantis") _key_action[POCKET_ACTION_MULTI].setKey(0, SDLK_KP0); // fate of atlantis : Ins to sucker-punch + else if (is_simon) + _key_action[POCKET_ACTION_MULTI].setKey(Common::ASCII_F10, SDLK_F10); // F10 else _key_action[POCKET_ACTION_MULTI].setKey('V', SDLK_v, KMOD_SHIFT); // FT cheat : shift-V // Key bind method _action_enabled[POCKET_ACTION_BINDKEYS] = true; // Disable double-tap right-click for convenience - if (is_tinsel || is_cruise) + if (is_tinsel || is_cruise || is_sci) if (!ConfMan.hasKey("no_doubletap_rightclick")) { ConfMan.setBool("no_doubletap_rightclick", true); ConfMan.flushToDisk(); @@ -267,6 +270,15 @@ bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) { else _key_action[action].setKey(SDLK_s); } + if (action == POCKET_ACTION_SKIP && ConfMan.get("gameid") == "agi") { + // In several AGI games (for example SQ2) it is needed to press F10 to exit from + // a screen. But we still want be able to skip normally with the skip button. + // Because of this, we inject a F10 keystroke here (this works and doesn't seem + // to have side-effects) + _key_action[action].setKey(Common::ASCII_F10, SDLK_F10); // F10 + EventsBuffer::simulateKey(&_key_action[action], true); + _key_action[action].setKey(KEY_ALL_SKIP); + } EventsBuffer::simulateKey(&_key_action[action], true); return true; case POCKET_ACTION_KEYBOARD: diff --git a/backends/platform/wince/CEActionsSmartphone.cpp b/backends/platform/wince/CEActionsSmartphone.cpp index b12dadabb6..2cce288323 100644 --- a/backends/platform/wince/CEActionsSmartphone.cpp +++ b/backends/platform/wince/CEActionsSmartphone.cpp @@ -128,6 +128,7 @@ void CEActionsSmartphone::initInstanceGame() { bool is_tinsel = (gameid == "tinsel"); bool is_cruise = (gameid == "cruise"); bool is_made = (gameid == "made"); + bool is_sci = (gameid == "sci"); GUI_Actions::initInstanceGame(); @@ -180,12 +181,14 @@ void CEActionsSmartphone::initInstanceGame() { _key_action[SMARTPHONE_ACTION_MULTI].setKey(Common::ASCII_F1, SDLK_F1); // bargon : F1 to start else if (gameid == "atlantis") _key_action[SMARTPHONE_ACTION_MULTI].setKey(0, SDLK_KP0); // fate of atlantis : Ins to sucker-punch + else if (is_simon) + _key_action[SMARTPHONE_ACTION_MULTI].setKey(Common::ASCII_F10, SDLK_F10); // F10 else _key_action[SMARTPHONE_ACTION_MULTI].setKey('V', SDLK_v, KMOD_SHIFT); // FT cheat : shift-V // Bind keys _action_enabled[SMARTPHONE_ACTION_BINDKEYS] = true; // Disable double-tap right-click for convenience - if (is_tinsel || is_cruise) + if (is_tinsel || is_cruise || is_sci) if (!ConfMan.hasKey("no_doubletap_rightclick")) { ConfMan.setBool("no_doubletap_rightclick", true); ConfMan.flushToDisk(); @@ -231,6 +234,15 @@ bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) { else _key_action[action].setKey(SDLK_s); } + if (action == SMARTPHONE_ACTION_SKIP && ConfMan.get("gameid") == "agi") { + // In several AGI games (for example SQ2) it is needed to press F10 to exit from + // a screen. But we still want be able to skip normally with the skip button. + // Because of this, we inject a F10 keystroke here (this works and doesn't seem + // to have side-effects) + _key_action[action].setKey(Common::ASCII_F10, SDLK_F10); // F10 + EventsBuffer::simulateKey(&_key_action[action], true); + _key_action[action].setKey(KEY_ALL_SKIP); + } EventsBuffer::simulateKey(&_key_action[action], true); return true; case SMARTPHONE_ACTION_RIGHTCLICK: diff --git a/backends/platform/wince/CELauncherDialog.cpp b/backends/platform/wince/CELauncherDialog.cpp index 9c832dd585..dd6076e0af 100644 --- a/backends/platform/wince/CELauncherDialog.cpp +++ b/backends/platform/wince/CELauncherDialog.cpp @@ -24,6 +24,7 @@ #define FORBIDDEN_SYMBOL_ALLOW_ALL #include "backends/platform/wince/wince-sdl.h" +#include "backends/graphics/wincesdl/wincesdl-graphics.h" #include "CELauncherDialog.h" @@ -34,6 +35,7 @@ #include "gui/browser.h" #include "gui/message.h" #include "gui/ThemeEval.h" +#include "gui/widgets/list.h" #include "common/config-manager.h" @@ -63,9 +65,13 @@ public: }; CELauncherDialog::CELauncherDialog() : GUI::LauncherDialog() { + ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->reset_panel(); } void CELauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { + if ((cmd == 'STRT') || (cmd == kListItemActivatedCmd) || (cmd == kListItemDoubleClickedCmd)) { + ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->init_panel(); + } LauncherDialog::handleCommand(sender, cmd, data); if (cmd == 'ABOU') { CEAboutDialog about; diff --git a/backends/platform/wince/README-WinCE.txt b/backends/platform/wince/README-WinCE.txt index c48d9ca998..60bcf710bb 100644 --- a/backends/platform/wince/README-WinCE.txt +++ b/backends/platform/wince/README-WinCE.txt @@ -1,10 +1,35 @@ ScummVM Windows CE FAQ -Last updated: 2011-05-27 -Release version: 1.3.0 +Last updated: 2011-07-20 +Release version: x.x.x ------------------------------------------------------------------------ New in this version ------------------- +x.x.x: +- Changed default values for "high_sample_rate" & "FM_high_quality" to "true" as + most devices today are fast enough to handle this. It's still possible to set + this to "false" if you have a slower device. +- Fix for TeenAgent & Hugo engines (both weren't running at all, crashed right + at the beginning) +- Replaced the game mass-adding functionality with the functionality used on all + other platforms. It now shows progress while searching for games. + +1.3.1: +- Fix for Normal2xAspect scaler which was causing screen update issues in some + games. +- Fix for Normal1xAspect scaler which caused problems in the bottom part of the + screen when toolbar was hidden. +- Fix for freelook mode. +- Fix for timer manager, caused timing issues in some games. +- Activated runtime language detection for ScummVM gui. +- Toolbar is now hidden when returning to the game list. +- Double-tap right-click emulation is now turned off for SCI games by default. +- Added a new option "no_doubletap_paneltoggle" for scummvm.ini to disable + toolbar toggling when double-tapping on the top part of the screen. +- SDL library related fixes: + * Fix for screen/mouse-cursor rotation issues (fixes erratic touchscreen + behaviour) + * Fix for hardware keyboard on some devices (HTC Touch Pro, etc.) 1.3.0: This is the first official Windows CE release since 1.1.1. @@ -345,14 +370,13 @@ Some parameters are specific to this port : Game specific sections (f.e. [monkey2]) - performance options * high_sample_rate bool Desktop quality (22 kHz) sound output if - set. The default is 11 kHz. - If you have a fast device, you can set this - to true to enjoy better sound effects and - music. + set. This is the default. + If you have a slow device, you can set this + to false to prevent lags/delays in the game. * FM_high_quality bool Desktop quality FM synthesis if set. Lower - quality otherwise. The default is low + quality otherwise. The default is high quality. You can change this if you have a - fast device. + slow device. * sound_thread_priority int Set the priority of the sound thread (0, 1, 2). Depending on the release, this is set to 1 internally (above normal). diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index 3ab9dc8aa4..1abc3cb350 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -42,6 +42,7 @@ #include "audio/mixer_intern.h" #include "audio/fmopl.h" +#include "backends/mutex/sdl/sdl-mutex.h" #include "backends/timer/sdl/sdl-timer.h" #include "gui/Actions.h" @@ -353,9 +354,9 @@ void drawError(char *error) { } // ******************************************************************************************** -static DefaultTimerManager *_int_timer = NULL; static Uint32 timer_handler_wrapper(Uint32 interval) { - _int_timer->handler(); + DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager(); + tm->handler(); return interval; } @@ -379,21 +380,7 @@ void OSystem_WINCE3::initBackend() { ((WINCESdlEventSource *)_eventSource)->init((WINCESdlGraphicsManager *)_graphicsManager); - - // FIXME: This timer manager is *not accesible* from the outside. - // Instead the timer manager setup by OSystem_SDL is visible on the outside. - // Since the WinCE backend actually seems to work, my guess is that - // SDL_AddTimer works after all and the following code is redundant. - // However it may be, this must be resolved one way or another. - - // Create the timer. CE SDL does not support multiple timers (SDL_AddTimer). - // We work around this by using the SetTimer function, since we only use - // one timer in scummvm (for the time being) - _int_timer = new DefaultTimerManager(); - //_timerID = NULL; // OSystem_SDL will call removetimer with this, it's ok - SDL_SetTimer(10, &timer_handler_wrapper); - - // Chain init + // Call parent implementation of this method OSystem_SDL::initBackend(); // Initialize global key mapping @@ -404,9 +391,6 @@ void OSystem_WINCE3::initBackend() { GUI_Actions::Instance()->saveMapping(); // write defaults } - // Call parent implementation of this method - //OSystem_SDL::initBackend(); - _inited = true; } @@ -555,6 +539,24 @@ void OSystem_WINCE3::initSDL() { } } +void OSystem_WINCE3::init() { + // Create SdlMutexManager instance as the TimerManager relies on the + // MutexManager being already initialized + if (_mutexManager == 0) + _mutexManager = new SdlMutexManager(); + + // Create the timer. CE SDL does not support multiple timers (SDL_AddTimer). + // We work around this by using the SetTimer function, since we only use + // one timer in scummvm (for the time being) + if (_timerManager == 0) { + _timerManager = new DefaultTimerManager(); + SDL_SetTimer(10, &timer_handler_wrapper); + } + + // Call parent implementation of this method + OSystem_SDL::init(); +} + void OSystem_WINCE3::quit() { fclose(stdout_file); fclose(stderr_file); @@ -578,6 +580,73 @@ void OSystem_WINCE3::getTimeAndDate(TimeDate &t) const { t.tm_sec = systime.wSecond; } +Common::String OSystem_WINCE3::getSystemLanguage() const { +#ifdef USE_DETECTLANG + // We can not use "setlocale" (at least not for MSVC builds), since it + // will return locales like: "English_USA.1252", thus we need a special + // way to determine the locale string for Win32. + char langName[9]; + char ctryName[9]; + TCHAR langNameW[32]; + TCHAR ctryNameW[32]; + int i = 0; + bool localeFound = false; + Common::String localeName; + + // Really not nice, but the only way to map Windows CE language/country codes to posix NLS names, + // because Windows CE doesn't support LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME, + // according to this: http://msdn.microsoft.com/en-us/library/aa912934.aspx + // + // See http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx for a translation table + // This table has to be updated manually when new translations are added + const char *posixMappingTable[][3] = { + {"CAT", "ESP", "ca_ES"}, + {"CSY", "CZE", "cs_CZ"}, + {"DAN", "DNK", "da_DA"}, + {"DEU", "DEU", "de_DE"}, + {"ESN", "ESP", "es_ES"}, + {"ESP", "ESP", "es_ES"}, + {"FRA", "FRA", "fr_FR"}, + {"HUN", "HUN", "hu_HU"}, + {"ITA", "ITA", "it_IT"}, + {"NOR", "NOR", "nb_NO"}, + {"NON", "NOR", "nn_NO"}, + {"PLK", "POL", "pl_PL"}, + {"PTB", "BRA", "pt_BR"}, + {"RUS", "RUS", "ru_RU"}, + {"SVE", "SWE", "se_SE"}, + {"UKR", "UKR", "uk_UA"}, + {NULL, NULL, NULL} + }; + + if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, langNameW, sizeof(langNameW)) != 0 && + GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, ctryNameW, sizeof(ctryNameW)) != 0) { + WideCharToMultiByte(CP_ACP, 0, langNameW, -1, langName, (wcslen(langNameW) + 1), NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, ctryNameW, -1, ctryName, (wcslen(ctryNameW) + 1), NULL, NULL); + + debug(1, "Trying to find posix locale name for %s_%s", langName, ctryName); + while (posixMappingTable[i][0] && !localeFound) { + if ( (!strcmp(posixMappingTable[i][0], langName) || !strcmp(posixMappingTable[i][0], "*")) && + (!strcmp(posixMappingTable[i][1], ctryName) || !strcmp(posixMappingTable[i][0], "*")) ) { + localeFound = true; + localeName = posixMappingTable[i][2]; + } + i++; + } + if (!localeFound) warning("No posix locale name found for %s_%s", langName, ctryName); + } + + if (localeFound) { + debug(1, "Found posix locale name: %s", localeName.c_str()); + return localeName; + } else { + return ModularBackend::getSystemLanguage(); + } +#else // USE_DETECTLANG + return ModularBackend::getSystemLanguage(); +#endif // USE_DETECTLANG +} + int OSystem_WINCE3::_platformScreenWidth; int OSystem_WINCE3::_platformScreenHeight; bool OSystem_WINCE3::_isOzone; diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h index adb63eb936..b4f323c9e2 100644 --- a/backends/platform/wince/wince-sdl.h +++ b/backends/platform/wince/wince-sdl.h @@ -52,7 +52,10 @@ public: void initBackend(); // Overloaded from SDL backend + void init(); void quit(); + virtual Common::String getSystemLanguage() const; + // Overloaded from OSystem void engineInit(); void getTimeAndDate(TimeDate &t) const; diff --git a/backends/plugins/elf/elf-loader.cpp b/backends/plugins/elf/elf-loader.cpp index b25bcf835b..4335ea6108 100644 --- a/backends/plugins/elf/elf-loader.cpp +++ b/backends/plugins/elf/elf-loader.cpp @@ -169,7 +169,7 @@ bool DLObject::loadSegment(Elf32_Phdr *phdr) { warning("elfloader: Out of memory."); return false; } - + debug(2, "elfloader: Allocated segment @ %p", _segment); // Get offset to load segment into @@ -222,7 +222,7 @@ Elf32_Shdr * DLObject::loadSectionHeaders(Elf32_Ehdr *ehdr) { int DLObject::findSymbolTableSection(Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) { int SymbolTableSection = -1; - + // Loop over sections, looking for symbol table linked to a string table for (uint32 i = 0; i < ehdr->e_shnum; i++) { if (shdr[i].sh_type == SHT_SYMTAB && @@ -233,7 +233,7 @@ int DLObject::findSymbolTableSection(Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) { break; } } - + return SymbolTableSection; } @@ -315,12 +315,12 @@ void DLObject::relocateSymbols(ptrdiff_t offset) { } // Track the size of the plugin through memory manager without loading -// the plugin into memory. +// the plugin into memory. // void DLObject::trackSize(const char *path) { - + _file = Common::FSNode(path).createReadStream(); - + if (!_file) { warning("elfloader: File %s not found.", path); return; @@ -334,11 +334,11 @@ void DLObject::trackSize(const char *path) { _file = 0; return; } - + ELFMemMan.trackPlugin(true); // begin tracking the plugin size - + // Load the segments - for (uint32 i = 0; i < ehdr.e_phnum; i++) { + for (uint32 i = 0; i < ehdr.e_phnum; i++) { debug(2, "elfloader: Loading segment %d", i); if (!readProgramHeaders(&ehdr, &phdr, i)) { @@ -351,7 +351,7 @@ void DLObject::trackSize(const char *path) { ELFMemMan.trackAlloc(phdr.p_align, phdr.p_memsz); } } - + ELFMemMan.trackPlugin(false); // we're done tracking the plugin size delete _file; @@ -367,7 +367,7 @@ bool DLObject::load() { return false; //Load the segments - for (uint32 i = 0; i < ehdr.e_phnum; i++) { + for (uint32 i = 0; i < ehdr.e_phnum; i++) { debug(2, "elfloader: Loading segment %d", i); if (readProgramHeaders(&ehdr, &phdr, i) == false) @@ -386,12 +386,12 @@ bool DLObject::load() { free(shdr); return false; } - + if (!loadStringTable(shdr)) { free(shdr); return false; } - + // Offset by our segment allocated address // must use _segmentVMA here for multiple segments (MIPS) _segmentOffset = ptrdiff_t(_segment) - _segmentVMA; diff --git a/backends/plugins/elf/elf-provider.cpp b/backends/plugins/elf/elf-provider.cpp index 480f7068c4..84054f44cb 100644 --- a/backends/plugins/elf/elf-provider.cpp +++ b/backends/plugins/elf/elf-provider.cpp @@ -100,7 +100,7 @@ DynamicPlugin::VoidFunc ELFPlugin::findSymbol(const char *symbol) { void ELFPlugin::trackSize() { // All we need to do is create our object, track its size, then delete it DLObject *obj = makeDLObject(); - + obj->trackSize(_filename.c_str()); delete obj; } @@ -180,7 +180,7 @@ void ELFPlugin::unloadPlugin() { PluginList ELFPluginProvider::getPlugins() { PluginList pl = FilePluginProvider::getPlugins(); -#if defined(UNCACHED_PLUGINS) && !defined(ELF_NO_MEM_MANAGER) +#if defined(UNCACHED_PLUGINS) && !defined(ELF_NO_MEM_MANAGER) // This static downcast is safe because all of the plugins must // be ELF plugins for (PluginList::iterator p = pl.begin(); p != pl.end(); ++p) { @@ -190,8 +190,8 @@ PluginList ELFPluginProvider::getPlugins() { // The Memory Manager should now allocate space based on the information // it collected ELFMemMan.allocateHeap(); -#endif - +#endif + return pl; } diff --git a/backends/plugins/elf/memory-manager.cpp b/backends/plugins/elf/memory-manager.cpp index 39f5e9071d..058d818dc4 100644 --- a/backends/plugins/elf/memory-manager.cpp +++ b/backends/plugins/elf/memory-manager.cpp @@ -20,7 +20,7 @@ * */ -#include "common/scummsys.h" +#include "common/scummsys.h" #if defined(DYNAMIC_MODULES) && defined(USE_ELF_LOADER) @@ -28,12 +28,14 @@ #include "common/debug.h" #include "common/util.h" #include <malloc.h> - -DECLARE_SINGLETON(ELFMemoryManager); -ELFMemoryManager::ELFMemoryManager() : - _heap(0), _heapSize(0), _heapAlign(0), - _trackAllocs(false), _measuredSize(0), _measuredAlign(0), +namespace Common { +DECLARE_SINGLETON(ELFMemoryManager); +} + +ELFMemoryManager::ELFMemoryManager() : + _heap(0), _heapSize(0), _heapAlign(0), + _trackAllocs(false), _measuredSize(0), _measuredAlign(0), _bytesAllocated(0) {} ELFMemoryManager::~ELFMemoryManager() { @@ -46,23 +48,23 @@ void ELFMemoryManager::trackPlugin(bool value) { if (value == _trackAllocs) return; - + _trackAllocs = value; - + if (_trackAllocs) { // start measuring // start tracking allocations _measuredAlign = 0; - + } else { // we're done measuring // get the total allocated size uint32 measuredSize = _allocList.back().end() - _allocList.front().start; _heapSize = MAX(_heapSize, measuredSize); _heapAlign = MAX(_heapAlign, _measuredAlign); - + _allocList.clear(); _bytesAllocated = 0; // reset - + debug(2, "measured a plugin of size %d. Max size %d. Max align %d", measuredSize, _heapSize, _heapAlign); } } @@ -70,7 +72,7 @@ void ELFMemoryManager::trackPlugin(bool value) { void ELFMemoryManager::trackAlloc(uint32 align, uint32 size) { if (!_measuredAlign) _measuredAlign = align; - + // use the allocate function to simulate allocation allocateOnHeap(align, size); } @@ -79,20 +81,20 @@ void ELFMemoryManager::allocateHeap() { // The memory manager should only allocate once assert (!_heap); assert (_heapSize); - + // clear the list _allocList.clear(); _bytesAllocated = 0; - + debug(2, "ELFMemoryManager: allocating %d bytes aligned at %d as the \ plugin heap", _heapSize, _heapAlign); - + // prepare the heap - if (_heapAlign) + if (_heapAlign) _heap = ::memalign(_heapAlign, _heapSize); else _heap = ::malloc(_heapSize); - + assert(_heap); } @@ -106,7 +108,7 @@ void *ELFMemoryManager::pluginAllocate(uint32 size) { void *ELFMemoryManager::pluginAllocate(uint32 align, uint32 size) { if (_heap) { return allocateOnHeap(align, size); - } + } return ::memalign(align, size); } @@ -120,16 +122,16 @@ void ELFMemoryManager::pluginDeallocate(void *ptr) { // Allocate space for the request in our heap void *ELFMemoryManager::allocateOnHeap(uint32 align, uint32 size) { byte *lastAddress = (byte *)_heap; - + // We can't allow allocations smaller than sizeof(Allocation). This could - // only be from non-plugin allocations and would cause infinite recursion + // only be from non-plugin allocations and would cause infinite recursion // when allocating our Allocation in the list. if (size <= sizeof(Allocation)) return 0; - + Common::List<Allocation>::iterator i; for (i = _allocList.begin(); i != _allocList.end(); i++) { - if (i->start - lastAddress > (int)size) + if (i->start - lastAddress > (int)size) break; lastAddress = i->end(); // align to desired alignment @@ -137,20 +139,20 @@ void *ELFMemoryManager::allocateOnHeap(uint32 align, uint32 size) { lastAddress = (byte *)( ((uint32)lastAddress + align - 1) & ~(align - 1) ); } } - + // Check if we exceeded our heap limit // We skip this case if we're only tracking allocations if (!_trackAllocs && ((uint32)lastAddress + size > (uint32)_heap + _heapSize)) { debug(2, "failed to find space to allocate %d bytes", size); return 0; } - + _allocList.insert(i, Allocation(lastAddress, size)); _bytesAllocated += size; - - debug(7, "ELFMemoryManager: allocated %d bytes at %p. Total %d bytes", + + debug(7, "ELFMemoryManager: allocated %d bytes at %p. Total %d bytes", size, lastAddress, _bytesAllocated); - + return lastAddress; } @@ -159,14 +161,14 @@ void ELFMemoryManager::deallocateFromHeap(void *ptr) { for (i = _allocList.begin(); i != _allocList.end(); i++) { if (i->start == ptr) { _bytesAllocated -= (*i).size; - - debug(7, "ELFMemoryManager: freed %d bytes at %p. Total %d bytes", + + debug(7, "ELFMemoryManager: freed %d bytes at %p. Total %d bytes", (*i).size, (*i).start, _bytesAllocated); - + _allocList.erase(i); break; } - } + } } #endif /* defined(DYNAMIC_MODULES) && defined(USE_ELF_LOADER) */ diff --git a/backends/plugins/elf/memory-manager.h b/backends/plugins/elf/memory-manager.h index ac70e5e3bb..032ecb2be5 100644 --- a/backends/plugins/elf/memory-manager.h +++ b/backends/plugins/elf/memory-manager.h @@ -30,17 +30,17 @@ #include "common/singleton.h" #include "common/list.h" #include "common/mutex.h" - + /** - * A 'foolproof' way to prevent memory fragmentation. This class is used to - * serve as a permanent allocation to prevent the process of loading and + * A 'foolproof' way to prevent memory fragmentation. This class is used to + * serve as a permanent allocation to prevent the process of loading and * unloading plugins from causing heavy fragmentation. **/ - + #define ELFMemMan ELFMemoryManager::instance() - + class ELFMemoryManager : public Common::Singleton<ELFMemoryManager> { -public: +public: void trackPlugin(bool value); void trackAlloc(uint32 align, uint32 size); @@ -49,7 +49,7 @@ public: void *pluginAllocate(uint32 size); void *pluginAllocate(uint32 align, uint32 size); void pluginDeallocate(void *ptr); - + private: friend class Common::Singleton<ELFMemoryManager>; @@ -58,7 +58,7 @@ private: void *allocateOnHeap(uint32 align, uint32 size); void deallocateFromHeap(void *ptr); - + struct Allocation { byte *start; uint32 size; @@ -70,17 +70,17 @@ private: void *_heap; uint32 _heapAlign; // alignment of the heap uint32 _heapSize; // size of the heap - + // tracking allocations bool _trackAllocs; // whether we are currently tracking - uint32 _measuredSize; - uint32 _measuredAlign; - + uint32 _measuredSize; + uint32 _measuredAlign; + // real allocations Common::List<Allocation> _allocList; uint32 _bytesAllocated; }; - + #endif /* defined(DYNAMIC_MODULES) && defined(USE_ELF_LOADER) */ #endif /* ELF_MEMORY_MANAGER_H */ diff --git a/backends/plugins/elf/mips-loader.cpp b/backends/plugins/elf/mips-loader.cpp index 8ce1a69583..e043c9647f 100644 --- a/backends/plugins/elf/mips-loader.cpp +++ b/backends/plugins/elf/mips-loader.cpp @@ -53,7 +53,7 @@ bool MIPSDLObject::relocate(Elf32_Off offset, Elf32_Word size, byte *relSegment) debug(2, "elfloader: Loaded relocation table. %d entries. base address=%p", cnt, relSegment); Elf32_Addr adjustedMainSegment = Elf32_Addr(_segment) - _segmentVMA; // adjust for VMA offset - + bool seenHi16 = false; // For treating HI/LO16 commands int32 firstHi16 = -1; // Mark the point of the first hi16 seen Elf32_Addr ahl = 0; // Calculated addend @@ -259,7 +259,7 @@ void MIPSDLObject::relocateSymbols(ptrdiff_t offset) { if (!ShortsMan.inGeneralSegment((char *)s->st_value)) { if (s->st_value < _segmentVMA) s->st_value = _segmentVMA; // deal with symbols referring to sections, which start before the VMA - + s->st_value += offset; if (s->st_value < Elf32_Addr(_segment) || s->st_value > Elf32_Addr(_segment) + _segmentSize) @@ -287,7 +287,7 @@ bool MIPSDLObject::loadSegment(Elf32_Phdr *phdr) { } debug(2, "elfloader: Allocated segment @ %p", _segment); - + // Get offset to load segment into baseAddress = _segment; _segmentSize = phdr->p_memsz; diff --git a/backends/plugins/elf/shorts-segment-manager.cpp b/backends/plugins/elf/shorts-segment-manager.cpp index b3a9531c2d..caa328a4f2 100644 --- a/backends/plugins/elf/shorts-segment-manager.cpp +++ b/backends/plugins/elf/shorts-segment-manager.cpp @@ -33,7 +33,9 @@ extern char __plugin_hole_start; // Indicates start of hole in program file for extern char __plugin_hole_end; // Indicates end of hole in program file extern char _gp[]; // Value of gp register +namespace Common { DECLARE_SINGLETON(ShortSegmentManager); // For singleton +} ShortSegmentManager::ShortSegmentManager() { _shortsStart = &__plugin_hole_start ; //shorts segment begins at the plugin hole we made when linking diff --git a/backends/taskbar/unity/unity-taskbar.cpp b/backends/taskbar/unity/unity-taskbar.cpp new file mode 100644 index 0000000000..da053734d2 --- /dev/null +++ b/backends/taskbar/unity/unity-taskbar.cpp @@ -0,0 +1,114 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h +#define FORBIDDEN_SYMBOL_EXCEPTION_time_h +#include "common/scummsys.h" + +#if defined(POSIX) && defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) + +#include "backends/taskbar/unity/unity-taskbar.h" + +#include "common/textconsole.h" + +#include <unity.h> + +UnityTaskbarManager::UnityTaskbarManager() { + g_type_init(); + + _loop = g_main_loop_new(NULL, FALSE); + + _launcher = unity_launcher_entry_get_for_desktop_id("scummvm.desktop"); +} + +UnityTaskbarManager::~UnityTaskbarManager() { + g_main_loop_unref(_loop); + _loop = NULL; +} + +void UnityTaskbarManager::setProgressValue(int completed, int total) { + if (_launcher == NULL) + return; + + double percentage = (double)completed / (double)total; + unity_launcher_entry_set_progress(_launcher, percentage); + unity_launcher_entry_set_progress_visible(_launcher, TRUE); +} + +void UnityTaskbarManager::setProgressState(TaskbarProgressState state) { + if (_launcher == NULL) + return; + + switch (state) { + default: + warning("[UnityTaskbarManager::setProgressState] Unknown state / Not implemented (%d)", state); + // fallback to noprogress state + + case kTaskbarNoProgress: + unity_launcher_entry_set_progress_visible(_launcher, FALSE); + break; + + // Unity only support two progress states as of 3.0: visible or not visible + // We show progress in all of those states + case kTaskbarIndeterminate: + case kTaskbarNormal: + case kTaskbarError: + case kTaskbarPaused: + unity_launcher_entry_set_progress_visible(_launcher, TRUE); + break; + } +} + +void UnityTaskbarManager::addRecent(const Common::String &name, const Common::String &description) { + warning("[UnityTaskbarManager::addRecent] Not implemented"); +} + +void UnityTaskbarManager::setCount(int count) { + if (_launcher == NULL) + return; + + unity_launcher_entry_set_count(_launcher, count); + + unity_launcher_entry_set_count_visible(_launcher, (count == 0) ? FALSE : TRUE); +} + +// Unity requires the glib event loop to the run to function properly +// as events are sent asynchronously +bool UnityTaskbarManager::pollEvent(Common::Event &event) { + if (!_loop) + return false; + + // Get context + GMainContext *context = g_main_loop_get_context(_loop); + if (!context) + return false; + + // Dispatch events + g_main_context_iteration(context, FALSE); + + return false; +} + +#endif diff --git a/backends/taskbar/unity/unity-taskbar.h b/backends/taskbar/unity/unity-taskbar.h new file mode 100644 index 0000000000..06ea0ca769 --- /dev/null +++ b/backends/taskbar/unity/unity-taskbar.h @@ -0,0 +1,58 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#ifndef BACKEND_UNITY_TASKBAR_H +#define BACKEND_UNITY_TASKBAR_H + +#if defined(POSIX) && defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) + +#include "common/events.h" +#include "common/str.h" +#include "common/taskbar.h" + +typedef struct _GMainLoop GMainLoop; +typedef struct _UnityLauncherEntry UnityLauncherEntry; + +class UnityTaskbarManager : public Common::TaskbarManager, public Common::EventSource { +public: + UnityTaskbarManager(); + virtual ~UnityTaskbarManager(); + + virtual void setProgressValue(int completed, int total); + virtual void setProgressState(TaskbarProgressState state); + virtual void addRecent(const Common::String &name, const Common::String &description); + virtual void setCount(int count); + + // Implementation of the EventSource interface + virtual bool pollEvent(Common::Event &event); + +private: + GMainLoop *_loop; + UnityLauncherEntry *_launcher; +}; + +#endif + +#endif // BACKEND_UNITY_TASKBAR_H diff --git a/backends/taskbar/win32/mingw-compat.h b/backends/taskbar/win32/mingw-compat.h new file mode 100644 index 0000000000..30ce818141 --- /dev/null +++ b/backends/taskbar/win32/mingw-compat.h @@ -0,0 +1,154 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +// TODO: Remove header when the latest changes to the Windows SDK have been integrated into MingW +// For reference, the interface definitions here are imported the SDK headers and from the +// EcWin7 project (https://code.google.com/p/dukto/) + +#ifndef BACKEND_WIN32_TASKBAR_MINGW_H +#define BACKEND_WIN32_TASKBAR_MINGW_H + +#if defined(WIN32) +#if defined(__GNUC__) +#ifdef __MINGW32__ + +#ifdef _WIN32_WINNT + #undef _WIN32_WINNT +#endif +#define _WIN32_WINNT 0x0501 +#include <windows.h> +#include <commctrl.h> +#include <initguid.h> +#include <shlwapi.h> +#include <shlguid.h> +#define CMIC_MASK_ASYNCOK SEE_MASK_ASYNCOK + +extern const GUID CLSID_ShellLink; + +// Shard enumeration value +#define SHARD_LINK 0x00000006 + +// Taskbar GUID definitions +DEFINE_GUID(CLSID_TaskbarList,0x56fdf344,0xfd6d,0x11d0,0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90); +DEFINE_GUID(IID_ITaskbarList3,0xea1afb91,0x9e28,0x4b86,0x90,0xE9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf); +DEFINE_GUID(IID_IPropertyStore,0x886d8eeb,0x8cf2,0x4446,0x8d,0x02,0xcd,0xba,0x1d,0xbd,0xcf,0x99); + +// Property key +typedef struct _tagpropertykey { + GUID fmtid; + DWORD pid; +} PROPERTYKEY; + +#define REFPROPERTYKEY const PROPERTYKEY & + +typedef struct tagPROPVARIANT PROPVARIANT; +#define REFPROPVARIANT const PROPVARIANT & + +// Property store +DECLARE_INTERFACE_(IPropertyStore, IUnknown) { + STDMETHOD (GetCount) (DWORD *cProps) PURE; + STDMETHOD (GetAt) (DWORD iProp, PROPERTYKEY *pkey) PURE; + STDMETHOD (GetValue) (REFPROPERTYKEY key, PROPVARIANT *pv) PURE; + STDMETHOD (SetValue) (REFPROPERTYKEY key, REFPROPVARIANT propvar) PURE; + STDMETHOD (Commit) (void) PURE; + +private: + ~IPropertyStore(); +}; +typedef IPropertyStore *LPIPropertyStore; + +// Mingw-specific defines for taskbar integration +typedef enum THUMBBUTTONMASK { + THB_BITMAP = 0x1, + THB_ICON = 0x2, + THB_TOOLTIP = 0x4, + THB_FLAGS = 0x8 +} THUMBBUTTONMASK; + +typedef enum THUMBBUTTONFLAGS { + THBF_ENABLED = 0, + THBF_DISABLED = 0x1, + THBF_DISMISSONCLICK = 0x2, + THBF_NOBACKGROUND = 0x4, + THBF_HIDDEN = 0x8, + THBF_NONINTERACTIVE = 0x10 +} THUMBBUTTONFLAGS; + +typedef struct THUMBBUTTON { + THUMBBUTTONMASK dwMask; + UINT iId; + UINT iBitmap; + HICON hIcon; + WCHAR szTip[260]; + THUMBBUTTONFLAGS dwFlags; +} THUMBBUTTON; +typedef struct THUMBBUTTON *LPTHUMBBUTTON; + +typedef enum TBPFLAG { + TBPF_NOPROGRESS = 0, + TBPF_INDETERMINATE = 0x1, + TBPF_NORMAL = 0x2, + TBPF_ERROR = 0x4, + TBPF_PAUSED = 0x8 +} TBPFLAG; + +// Taskbar interface +DECLARE_INTERFACE_(ITaskbarList3, IUnknown) { + // IUnknown + STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + // ITaskbarList + STDMETHOD(HrInit) (THIS) PURE; + STDMETHOD(AddTab) (THIS_ HWND hwnd) PURE; + STDMETHOD(DeleteTab) (THIS_ HWND hwnd) PURE; + STDMETHOD(ActivateTab) (THIS_ HWND hwnd) PURE; + STDMETHOD(SetActiveAlt) (THIS_ HWND hwnd) PURE; + STDMETHOD (MarkFullscreenWindow) (THIS_ HWND hwnd, int fFullscreen) PURE; + // ITaskbarList3 + STDMETHOD (SetProgressValue) (THIS_ HWND hwnd, ULONGLONG ullCompleted, ULONGLONG ullTotal) PURE; + STDMETHOD (SetProgressState) (THIS_ HWND hwnd, TBPFLAG tbpFlags) PURE; + STDMETHOD (RegisterTab) (THIS_ HWND hwndTab, HWND hwndMDI) PURE; + STDMETHOD (UnregisterTab) (THIS_ HWND hwndTab) PURE; + STDMETHOD (SetTabOrder) (THIS_ HWND hwndTab, HWND hwndInsertBefore) PURE; + STDMETHOD (SetTabActive) (THIS_ HWND hwndTab, HWND hwndMDI, DWORD dwReserved) PURE; + STDMETHOD (ThumbBarAddButtons) (THIS_ HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton) PURE; + STDMETHOD (ThumbBarUpdateButtons) (THIS_ HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton) PURE; + STDMETHOD (ThumbBarSetImageList) (THIS_ HWND hwnd, HIMAGELIST himl) PURE; + STDMETHOD (SetOverlayIcon) (THIS_ HWND hwnd, HICON hIcon, LPCWSTR pszDescription) PURE; + STDMETHOD (SetThumbnailTooltip) (THIS_ HWND hwnd, LPCWSTR pszTip) PURE; + STDMETHOD (SetThumbnailClip) (THIS_ HWND hwnd, RECT *prcClip) PURE; + +private: + ~ITaskbarList3(); +}; + +typedef ITaskbarList3 *LPITaskbarList3; + +#endif // __MINGW32__ +#endif // __GNUC__ +#endif // WIN32 + +#endif // BACKEND_WIN32_TASKBAR_MINGW_H diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp new file mode 100644 index 0000000000..04889f3dd7 --- /dev/null +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -0,0 +1,414 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +// We cannot use common/scummsys.h directly as it will include +// windows.h and we need to do it by hand to allow excluded functions +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#if defined(WIN32) && defined(USE_TASKBAR) + +// Needed for taskbar functions +#if defined(__GNUC__) +#ifdef __MINGW32__ + #include "backends/taskbar/win32/mingw-compat.h" +#else + #error Only compilation with MingW is supported +#endif +#else + // We need certain functions that are excluded by default + #undef NONLS + #undef NOICONS + #include <windows.h> + #if defined(ARRAYSIZE) + #undef ARRAYSIZE + #endif + + // Default MSVC headers for ITaskbarList3 and IShellLink + #include <SDKDDKVer.h> +#endif +#include <shlobj.h> + +// For HWND +#include <SDL_syswm.h> + +#include "common/scummsys.h" + +#include "backends/taskbar/win32/win32-taskbar.h" + +#include "common/config-manager.h" +#include "common/textconsole.h" +#include "common/file.h" + +// System.Title property key, values taken from http://msdn.microsoft.com/en-us/library/bb787584.aspx +const PROPERTYKEY PKEY_Title = { /* fmtid = */ { 0xF29F85E0, 0x4FF9, 0x1068, { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 } }, /* propID = */ 2 }; + +Win32TaskbarManager::Win32TaskbarManager() : _taskbar(NULL), _count(0), _icon(NULL) { + // Do nothing if not running on Windows 7 or later + if (!isWin7OrLater()) + return; + + CoInitialize(NULL); + + // Try creating instance (on fail, _taskbar will contain NULL) + HRESULT hr = CoCreateInstance(CLSID_TaskbarList, + 0, + CLSCTX_INPROC_SERVER, + IID_ITaskbarList3, + reinterpret_cast<void**> (&(_taskbar))); + + if (SUCCEEDED(hr)) { + // Initialize taskbar object + if (FAILED(_taskbar->HrInit())) { + _taskbar->Release(); + _taskbar = NULL; + } + } else { + warning("[Win32TaskbarManager::init] Cannot create taskbar instance"); + } +} + +Win32TaskbarManager::~Win32TaskbarManager() { + if (_taskbar) + _taskbar->Release(); + _taskbar = NULL; + + if (_icon) + DestroyIcon(_icon); + + CoUninitialize(); +} + +void Win32TaskbarManager::setOverlayIcon(const Common::String &name, const Common::String &description) { + //warning("[Win32TaskbarManager::setOverlayIcon] Setting overlay icon to: %s (%s)", name.c_str(), description.c_str()); + + if (_taskbar == NULL) + return; + + if (name.empty()) { + _taskbar->SetOverlayIcon(getHwnd(), NULL, L""); + return; + } + + // Compute full icon path + Common::String path = getIconPath(name); + if (path.empty()) + return; + + HICON pIcon = (HICON)::LoadImage(NULL, path.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE); + if (!pIcon) { + warning("[Win32TaskbarManager::setOverlayIcon] Cannot load icon!"); + return; + } + + // Sets the overlay icon + LPWSTR desc = ansiToUnicode(description.c_str()); + _taskbar->SetOverlayIcon(getHwnd(), pIcon, desc); + + DestroyIcon(pIcon); + + delete[] desc; +} + +void Win32TaskbarManager::setProgressValue(int completed, int total) { + if (_taskbar == NULL) + return; + + _taskbar->SetProgressValue(getHwnd(), completed, total); +} + +void Win32TaskbarManager::setProgressState(TaskbarProgressState state) { + if (_taskbar == NULL) + return; + + _taskbar->SetProgressState(getHwnd(), (TBPFLAG)state); +} + +void Win32TaskbarManager::setCount(int count) { + if (_taskbar == NULL) + return; + + if (count == 0) { + _taskbar->SetOverlayIcon(getHwnd(), NULL, L""); + return; + } + + // FIXME: This isn't really nice and could use a cleanup. + // The only good thing is that it doesn't use GDI+ + // and thus does not have a dependancy on it, + // with the downside of being a lot more ugly. + // Maybe replace it by a Graphic::Surface, use + // ScummVM font drawing and extract the contents at + // the end? + + if (_count != count || _icon == NULL) { + // Cleanup previous icon + _count = count; + if (_icon) + DestroyIcon(_icon); + + Common::String countString = (count < 100 ? Common::String::format("%d", count) : "9+"); + + // Create transparent background + BITMAPV5HEADER bi; + ZeroMemory(&bi, sizeof(BITMAPV5HEADER)); + bi.bV5Size = sizeof(BITMAPV5HEADER); + bi.bV5Width = 16; + bi.bV5Height = 16; + bi.bV5Planes = 1; + bi.bV5BitCount = 32; + bi.bV5Compression = BI_RGB; + // Set 32 BPP alpha format + bi.bV5RedMask = 0x00FF0000; + bi.bV5GreenMask = 0x0000FF00; + bi.bV5BlueMask = 0x000000FF; + bi.bV5AlphaMask = 0xFF000000; + + // Get DC + HDC hdc; + hdc = GetDC(NULL); + HDC hMemDC = CreateCompatibleDC(hdc); + ReleaseDC(NULL, hdc); + + // Create a bitmap mask + HBITMAP hBitmapMask = CreateBitmap(16, 16, 1, 1, NULL); + + // Create the DIB section with an alpha channel + void *lpBits; + HBITMAP hBitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, (void **)&lpBits, NULL, 0); + HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap); + + // Load the icon background + HICON hIconBackground = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(1002 /* IDI_COUNT */)); + DrawIconEx(hMemDC, 0, 0, hIconBackground, 16, 16, 0, 0, DI_NORMAL); + DeleteObject(hIconBackground); + + // Draw the count + LOGFONT lFont; + memset(&lFont, 0, sizeof(LOGFONT)); + lFont.lfHeight = 10; + lFont.lfWeight = FW_BOLD; + lFont.lfItalic = 1; + strcpy(lFont.lfFaceName, "Arial"); + + HFONT hFont = CreateFontIndirect(&lFont); + SelectObject(hMemDC, hFont); + + RECT rect; + SetRect(&rect, 4, 4, 12, 12); + SetTextColor(hMemDC, RGB(48, 48, 48)); + SetBkMode(hMemDC, TRANSPARENT); + DrawText(hMemDC, countString.c_str(), -1, &rect, DT_NOCLIP|DT_CENTER); + + // Set the text alpha to fully opaque (we consider the data inside the text rect) + DWORD *lpdwPixel = (DWORD *)lpBits; + for (int x = 3; x < 12; x++) { + for(int y = 3; y < 12; y++) { + unsigned char *p = (unsigned char *)(lpdwPixel + x * 16 + y); + + if (p[0] != 0 && p[1] != 0 && p[2] != 0) + p[3] = 255; + } + } + + // Cleanup DC + DeleteObject(hFont); + SelectObject(hMemDC, hOldBitmap); + DeleteDC(hMemDC); + + // Prepare our new icon + ICONINFO ii; + ii.fIcon = FALSE; + ii.xHotspot = 0; + ii.yHotspot = 0; + ii.hbmMask = hBitmapMask; + ii.hbmColor = hBitmap; + + _icon = CreateIconIndirect(&ii); + + DeleteObject(hBitmap); + DeleteObject(hBitmapMask); + + if (!_icon) { + warning("[Win32TaskbarManager::setCount] Cannot create icon for count"); + return; + } + } + + // Sets the overlay icon + LPWSTR desc = ansiToUnicode(Common::String::format("Found games: %d", count).c_str()); + _taskbar->SetOverlayIcon(getHwnd(), _icon, desc); + delete[] desc; +} + +void Win32TaskbarManager::addRecent(const Common::String &name, const Common::String &description) { + //warning("[Win32TaskbarManager::addRecent] Adding recent list entry: %s (%s)", name.c_str(), description.c_str()); + + if (_taskbar == NULL) + return; + + // ANSI version doesn't seem to work correctly with Win7 jump lists, so explicitly use Unicode interface. + IShellLinkW *link; + + // Get the ScummVM executable path. + WCHAR path[MAX_PATH]; + GetModuleFileNameW(NULL, path, MAX_PATH); + + // Create a shell link. + if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC, IID_IShellLinkW, reinterpret_cast<void**> (&link)))) { + // Convert game name and description to Unicode. + LPWSTR game = ansiToUnicode(name.c_str()); + LPWSTR desc = ansiToUnicode(description.c_str()); + + // Set link properties. + link->SetPath(path); + link->SetArguments(game); + + Common::String iconPath = getIconPath(name); + if (iconPath.empty()) { + link->SetIconLocation(path, 0); // No game-specific icon available + } else { + LPWSTR icon = ansiToUnicode(iconPath.c_str()); + + link->SetIconLocation(icon, 0); + + delete[] icon; + } + + // The link's display name must be set via property store. + IPropertyStore* propStore; + HRESULT hr = link->QueryInterface(IID_IPropertyStore, reinterpret_cast<void**> (&(propStore))); + if (SUCCEEDED(hr)) { + PROPVARIANT pv; + pv.vt = VT_LPWSTR; + pv.pwszVal = desc; + + hr = propStore->SetValue(PKEY_Title, pv); + + propStore->Commit(); + propStore->Release(); + } + + // SHAddToRecentDocs will cause the games to be added to the Recent list, allowing the user to pin them. + SHAddToRecentDocs(SHARD_LINK, link); + link->Release(); + delete[] game; + delete[] desc; + } +} + +Common::String Win32TaskbarManager::getIconPath(Common::String target) { + // We first try to look for a iconspath configuration variable then + // fallback to the extra path + // + // Icons can be either in a subfolder named "icons" or directly in the path + + Common::String iconsPath = ConfMan.get("iconspath"); + Common::String extraPath = ConfMan.get("extrapath"); + +#define TRY_ICON_PATH(path) { \ + Common::FSNode node((path)); \ + if (node.exists()) \ + return (path); \ +} + + if (!iconsPath.empty()) { + TRY_ICON_PATH(iconsPath + "/" + target + ".ico"); + TRY_ICON_PATH(iconsPath + "/" + ConfMan.get("gameid") + ".ico"); + TRY_ICON_PATH(iconsPath + "/icons/" + target + ".ico"); + TRY_ICON_PATH(iconsPath + "/icons/" + ConfMan.get("gameid") + ".ico"); + } + + if (!extraPath.empty()) { + TRY_ICON_PATH(extraPath + "/" + target + ".ico"); + TRY_ICON_PATH(extraPath + "/" + ConfMan.get("gameid") + ".ico"); + TRY_ICON_PATH(extraPath + "/icons/" + target + ".ico"); + TRY_ICON_PATH(extraPath + "/icons/" + ConfMan.get("gameid") + ".ico"); + } + + return ""; +} + +// VerSetConditionMask and VerifyVersionInfo didn't appear until Windows 2000, +// so we need to check for them at runtime +LONGLONG VerSetConditionMaskFunc(ULONGLONG dwlConditionMask, DWORD dwTypeMask, BYTE dwConditionMask) { + typedef BOOL (WINAPI *VerSetConditionMaskFunction)(ULONGLONG conditionMask, DWORD typeMask, BYTE conditionOperator); + + VerSetConditionMaskFunction verSetConditionMask = (VerSetConditionMaskFunction)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "VerSetConditionMask"); + if (verSetConditionMask == NULL) + return 0; + + return verSetConditionMask(dwlConditionMask, dwTypeMask, dwConditionMask); +} + +BOOL VerifyVersionInfoFunc(LPOSVERSIONINFOEXA lpVersionInformation, DWORD dwTypeMask, DWORDLONG dwlConditionMask) { + typedef BOOL (WINAPI *VerifyVersionInfoFunction)(LPOSVERSIONINFOEXA versionInformation, DWORD typeMask, DWORDLONG conditionMask); + + VerifyVersionInfoFunction verifyVersionInfo = (VerifyVersionInfoFunction)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "VerifyVersionInfoA"); + if (verifyVersionInfo == NULL) + return FALSE; + + return verifyVersionInfo(lpVersionInformation, dwTypeMask, dwlConditionMask); +} + +bool Win32TaskbarManager::isWin7OrLater() { + OSVERSIONINFOEX versionInfo; + DWORDLONG conditionMask = 0; + + ZeroMemory(&versionInfo, sizeof(OSVERSIONINFOEX)); + versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + versionInfo.dwMajorVersion = 6; + versionInfo.dwMinorVersion = 1; + + conditionMask = VerSetConditionMaskFunc(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL); + conditionMask = VerSetConditionMaskFunc(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL); + + return VerifyVersionInfoFunc(&versionInfo, VER_MAJORVERSION | VER_MINORVERSION, conditionMask); +} + +LPWSTR Win32TaskbarManager::ansiToUnicode(const char *s) { + DWORD size = MultiByteToWideChar(0, 0, s, -1, NULL, 0); + + if (size > 0) { + LPWSTR result = new WCHAR[size]; + if (MultiByteToWideChar(0, 0, s, -1, result, size) != 0) + return result; + } + + return NULL; +} + +HWND Win32TaskbarManager::getHwnd() { + SDL_SysWMinfo wmi; + SDL_VERSION(&wmi.version); + + if(!SDL_GetWMInfo(&wmi)) + return NULL; + + return wmi.window; +} + +#endif diff --git a/backends/taskbar/win32/win32-taskbar.h b/backends/taskbar/win32/win32-taskbar.h new file mode 100644 index 0000000000..c9d1761017 --- /dev/null +++ b/backends/taskbar/win32/win32-taskbar.h @@ -0,0 +1,71 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#ifndef BACKEND_WIN32_TASKBAR_H +#define BACKEND_WIN32_TASKBAR_H + +#if defined(WIN32) && defined(USE_TASKBAR) + +#include "common/str.h" +#include "common/taskbar.h" + +struct ITaskbarList3; + +class Win32TaskbarManager : public Common::TaskbarManager { +public: + Win32TaskbarManager(); + virtual ~Win32TaskbarManager(); + + virtual void setOverlayIcon(const Common::String &name, const Common::String &description); + virtual void setProgressValue(int completed, int total); + virtual void setProgressState(TaskbarProgressState state); + virtual void setCount(int count); + virtual void addRecent(const Common::String &name, const Common::String &description); + +private: + ITaskbarList3 *_taskbar; + + // Count handling + HICON _icon; + int _count; + + /** + * Get the path to an icon for the game + * + * @param target The game target + * + * @return The icon path (or "" if no icon was found) + */ + Common::String getIconPath(Common::String target); + + // Helper functions + bool isWin7OrLater(); + LPWSTR ansiToUnicode(const char *s); + HWND getHwnd(); +}; + +#endif + +#endif // BACKEND_WIN32_TASKBAR_H diff --git a/backends/vkeybd/virtual-keyboard-parser.cpp b/backends/vkeybd/virtual-keyboard-parser.cpp index 5e4ce11fe4..58f0c468f6 100644 --- a/backends/vkeybd/virtual-keyboard-parser.cpp +++ b/backends/vkeybd/virtual-keyboard-parser.cpp @@ -205,6 +205,9 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { evt->type = VirtualKeyboard::kVKEventModifier; byte *flags = (byte*) malloc(sizeof(byte)); + if (!flags) + error("[VirtualKeyboardParser::parserCallback_event] Cannot allocate memory"); + *(flags) = parseFlags(node->values["modifiers"]); evt->data = flags; @@ -217,6 +220,9 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { evt->type = VirtualKeyboard::kVKEventSwitchMode; String& mode = node->values["mode"]; char *str = (char*) malloc(sizeof(char) * mode.size() + 1); + if (!str) + error("[VirtualKeyboardParser::parserCallback_event] Cannot allocate memory"); + memcpy(str, mode.c_str(), sizeof(char) * mode.size()); str[mode.size()] = 0; evt->data = str; |