diff --git a/Makefile b/Makefile index f81f0a7c53a..b84a55c4729 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ ifeq "$(HAVE_GCC)" "1" # being helpful. #CXXFLAGS+= -Wmissing-format-attribute - # Disable exceptions (ResidualVM use RTTI) + # Disable exceptions, ResidualVM use RTTI: CXXFLAGS+= -fno-exceptions ifneq "$(HAVE_CLANG)" "1" diff --git a/Makefile.common b/Makefile.common index 80d5281cd0b..d24a087e5f9 100644 --- a/Makefile.common +++ b/Makefile.common @@ -12,6 +12,7 @@ all: $(EXECUTABLE) plugins ###################################################################### # Module settings ###################################################################### +#ResidualVM: do not include 'test' but add 'math': PLUGINS := MODULES := devtools base $(MODULES) @@ -241,7 +242,10 @@ endif DIST_FILES_THEMES:=$(addprefix $(srcdir)/gui/themes/,$(DIST_FILES_THEMES)) # Engine data files -DIST_FILES_ENGINEDATA=residualvm-grim-patch.lab +DIST_FILES_ENGINEDATA= +ifdef ENABLE_GRIM +DIST_FILES_ENGINEDATA+=residualvm-grim-patch.lab +endif DIST_FILES_ENGINEDATA:=$(addprefix $(srcdir)/dists/engine-data/,$(DIST_FILES_ENGINEDATA)) diff --git a/backends/graphics/graphics.h b/backends/graphics/graphics.h index a3997c83e25..f29eca6d9c7 100644 --- a/backends/graphics/graphics.h +++ b/backends/graphics/graphics.h @@ -33,6 +33,7 @@ * Abstract class for graphics manager. Subclasses * implement the real functionality. */ + // ResidualVM specific method class GraphicsManager : Common::NonCopyable { public: virtual ~GraphicsManager() {} @@ -41,7 +42,9 @@ public: virtual void setFeatureState(OSystem::Feature f, bool enable) = 0; virtual bool getFeatureState(OSystem::Feature f) = 0; + // ResidualVM specific method virtual void launcherInitSize(uint w, uint h) = 0; + // ResidualVM specific method virtual Graphics::PixelBuffer setupScreen(int screenW, int screenH, bool fullscreen, bool accel3d) = 0; virtual int getScreenChangeID() const = 0; virtual int16 getHeight() = 0; diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 025e9172737..38711343c2d 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -143,7 +143,7 @@ Keymap *Keymapper::getKeymap(const String& name, bool *globalReturn) { return keymap; } -bool Keymapper::pushKeymap(const String& name, bool inherit) { +bool Keymapper::pushKeymap(const String& name, bool transparent) { bool global; Keymap *newMap = getKeymap(name, &global); @@ -152,20 +152,30 @@ bool Keymapper::pushKeymap(const String& name, bool inherit) { return false; } - pushKeymap(newMap, inherit, global); + pushKeymap(newMap, transparent, global); return true; } -void Keymapper::pushKeymap(Keymap *newMap, bool inherit, bool global) { - MapRecord mr = {newMap, inherit, global}; +void Keymapper::pushKeymap(Keymap *newMap, bool transparent, bool global) { + MapRecord mr = {newMap, transparent, global}; _activeMaps.push(mr); } -void Keymapper::popKeymap() { - if (!_activeMaps.empty()) - _activeMaps.pop(); +void Keymapper::popKeymap(const char *name) { + if (!_activeMaps.empty()) { + if (name) { + String topKeymapName = _activeMaps.top().keymap->getName(); + if (topKeymapName.equals(name)) + _activeMaps.pop(); + else + warning("An attempt to pop wrong keymap was blocked (expected %s but was %s)", name, topKeymapName.c_str()); + } else { + _activeMaps.pop(); + } + } + } bool Keymapper::notifyEvent(const Common::Event &ev) { @@ -198,7 +208,7 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { debug(5, "Keymapper::mapKey keymap: %s", mr.keymap->getName().c_str()); action = mr.keymap->getMappedAction(key); - if (action || !mr.inherit) + if (action || !mr.transparent) break; } diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index d38109f2102..d2aa89cad65 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -37,13 +37,14 @@ namespace Common { const char *const kGuiKeymapName = "gui"; +const char *const kGlobalKeymapName = "global"; class Keymapper : public Common::EventMapper, private Common::ArtificialEventSource { public: struct MapRecord { Keymap* keymap; - bool inherit; + bool transparent; bool global; }; @@ -121,17 +122,20 @@ public: /** * Push a new keymap to the top of the active stack, activating * it for use. - * @param name name of the keymap to push - * @param inherit if true keymapper will iterate down the - * stack if it cannot find a key in the new map - * @return true if succesful + * @param name name of the keymap to push + * @param transparent if true keymapper will iterate down the + * stack if it cannot find a key in the new map + * @return true if succesful */ - bool pushKeymap(const String& name, bool inherit = false); + bool pushKeymap(const String& name, bool transparent = false); /** * Pop the top keymap off the active stack. + * @param name (optional) name of keymap expected to be popped + * if provided, will not pop unless name is the same + * as the top keymap */ - void popKeymap(); + void popKeymap(const char *name = 0); // Implementation of the EventMapper interface bool notifyEvent(const Common::Event &ev); @@ -182,7 +186,7 @@ private: HardwareKeySet *_hardwareKeys; - void pushKeymap(Keymap *newMap, bool inherit, bool global); + void pushKeymap(Keymap *newMap, bool transparent, bool global); Action *getAction(const KeyState& key); void executeAction(const Action *act, bool keyDown); diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index c0654fc0ea8..5c339f8c275 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -327,7 +327,7 @@ void RemapDialog::loadKeymap() { } // loop through remaining finding mappings for unmapped keys - if (top.inherit && topIndex >= 0) { + if (top.transparent && topIndex >= 0) { for (int i = topIndex - 1; i >= 0; --i) { Keymapper::MapRecord mr = activeKeymaps[i]; debug(3, "RemapDialog::loadKeymap keymap: %s", mr.keymap->getName().c_str()); @@ -345,7 +345,7 @@ void RemapDialog::loadKeymap() { } } - if (mr.inherit == false || freeKeys.empty()) + if (mr.transparent == false || freeKeys.empty()) break; } } diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index 3e1493f1338..9be44d93ff8 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -29,6 +29,7 @@ #include "audio/mixer.h" #include "graphics/pixelformat.h" +// ResidualVM specific: #include "graphics/pixelbuffer.h" ModularBackend::ModularBackend() @@ -65,10 +66,12 @@ GraphicsManager *ModularBackend::getGraphicsManager() { return (GraphicsManager *)_graphicsManager; } +// ResidualVM specific method void ModularBackend::launcherInitSize(uint w, uint h) { _graphicsManager->launcherInitSize(w, h); } +// ResidualVM specific method Graphics::PixelBuffer ModularBackend::setupScreen(int screenW, int screenH, bool fullscreen, bool accel3d) { return _graphicsManager->setupScreen(screenW, screenH, fullscreen, accel3d); } diff --git a/backends/modular-backend.h b/backends/modular-backend.h index 891f73e0ff8..c9ee8063a22 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -62,7 +62,9 @@ public: //@{ virtual GraphicsManager *getGraphicsManager(); +// ResidualVM specific method virtual void launcherInitSize(uint w, uint h); +// ResidualVM specific method virtual Graphics::PixelBuffer setupScreen(int screenW, int screenH, bool fullscreen, bool accel3d); virtual int getScreenChangeID() const; diff --git a/backends/platform/sdl/macosx/appmenu_osx.mm b/backends/platform/sdl/macosx/appmenu_osx.mm index a971de08f80..37d30625afc 100644 --- a/backends/platform/sdl/macosx/appmenu_osx.mm +++ b/backends/platform/sdl/macosx/appmenu_osx.mm @@ -35,6 +35,11 @@ - (void)setAppleMenu:(NSMenu *)menu; @end +NSString *constructNSStringFromCString(const char* rawCString, NSStringEncoding stringEncoding) { + NSData *nsData = [NSData dataWithBytes:rawCString length:strlen(rawCString)]; + return [[NSString alloc] initWithData:nsData encoding:stringEncoding]; +} + void replaceApplicationMenuItems() { // Code mainly copied and adapted from SDLmain.m @@ -50,34 +55,47 @@ void replaceApplicationMenuItems() { // Create new application menu appleMenu = [[NSMenu alloc] initWithTitle:@""]; + NSString *nsString = NULL; + // Get current encoding #ifdef USE_TRANSLATION - NSStringEncoding stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)[NSString stringWithCString:(TransMan.getCurrentCharset()).c_str() encoding:NSASCIIStringEncoding])); + nsString = constructNSStringFromCString((TransMan.getCurrentCharset()).c_str(), NSASCIIStringEncoding); + NSStringEncoding stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)nsString)); + [nsString release]; #else NSStringEncoding stringEncoding = NSASCIIStringEncoding; #endif - + // Add "About ScummVM" menu item - [appleMenu addItemWithTitle:[NSString stringWithCString:_("About ResidualVM") encoding:stringEncoding] action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; + nsString = constructNSStringFromCString(_("About ResidualVM"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; + [nsString release]; // Add separator [appleMenu addItem:[NSMenuItem separatorItem]]; // Add "Hide ScummVM" menu item - [appleMenu addItemWithTitle:[NSString stringWithCString:_("Hide ResidualVM") encoding:stringEncoding] action:@selector(hide:) keyEquivalent:@"h"]; + nsString = constructNSStringFromCString(_("Hide ResidualVM"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(hide:) keyEquivalent:@"h"]; + [nsString release]; // Add "Hide Others" menu item - menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:[NSString stringWithCString:_("Hide Others") encoding:stringEncoding] action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; + nsString = constructNSStringFromCString(_("Hide Others"), stringEncoding); + menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:nsString 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:@""]; + nsString = constructNSStringFromCString(_("Show All"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(unhideAllApplications:) keyEquivalent:@""]; + [nsString release]; // Add separator [appleMenu addItem:[NSMenuItem separatorItem]]; // Add "Quit ScummVM" menu item - [appleMenu addItemWithTitle:[NSString stringWithCString:_("Quit ResidualVM") encoding:stringEncoding] action:@selector(terminate:) keyEquivalent:@"q"]; + nsString = constructNSStringFromCString(_("Quit ResidualVM"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(terminate:) keyEquivalent:@"q"]; + [nsString release]; // Put application menu into the menubar menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; @@ -89,16 +107,22 @@ void replaceApplicationMenuItems() { // Create new "Window" menu - windowMenu = [[NSMenu alloc] initWithTitle:[NSString stringWithCString:_("Window") encoding:stringEncoding]]; + nsString = constructNSStringFromCString(_("Window"), stringEncoding); + windowMenu = [[NSMenu alloc] initWithTitle:nsString]; + [nsString release]; // Add "Minimize" menu item - menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:_("Minimize") encoding:stringEncoding] action:@selector(performMiniaturize:) keyEquivalent:@"m"]; + nsString = constructNSStringFromCString(_("Minimize"), stringEncoding); + menuItem = [[NSMenuItem alloc] initWithTitle:nsString action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [windowMenu addItem:menuItem]; + [nsString release]; // Put menu into the menubar - menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:_("Window") encoding:stringEncoding] action:nil keyEquivalent:@""]; + nsString = constructNSStringFromCString(_("Window"), stringEncoding); + menuItem = [[NSMenuItem alloc] initWithTitle:nsString action:nil keyEquivalent:@""]; [menuItem setSubmenu:windowMenu]; [[NSApp mainMenu] addItem:menuItem]; + [nsString release]; // Tell the application object that this is now the window menu. [NSApp setWindowsMenu:windowMenu]; diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 3ecbf237b5f..b09f338ac12 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -38,6 +38,7 @@ #include // For setting the icon #include "backends/platform/sdl/win32/win32.h" +#include "backends/saves/windows/windows-saves.h" #include "backends/fs/windows/windows-fs-factory.h" #include "backends/taskbar/win32/win32-taskbar.h" @@ -74,6 +75,10 @@ void OSystem_Win32::initBackend() { FreeConsole(); } + // Create the savefile manager + if (_savefileManager == 0) + _savefileManager = new WindowsSaveFileManager(); + // Invoke parent implementation of this method OSystem_SDL::initBackend(); } diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index 046ddb1cd0b..4cc451247ba 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -29,12 +29,8 @@ #if defined(WIN32) && defined(USE_TASKBAR) // Needed for taskbar functions -#if defined(__GNUC__) -#ifdef __MINGW32__ +#if defined(__GNUC__) && defined(__MINGW32__) && !defined(__MINGW64__) #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 @@ -44,9 +40,12 @@ #undef ARRAYSIZE #endif - // Default MSVC headers for ITaskbarList3 and IShellLink - #include + #if defined(_MSC_VER) + // Default MSVC headers for ITaskbarList3 and IShellLink + #include + #endif #endif + #include // For HWND diff --git a/common/archive.cpp b/common/archive.cpp index 36d6dc49c65..1323f148059 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -161,7 +161,7 @@ void SearchSet::addSubDirectoriesMatching(const FSNode &directory, String origPa } if (nextPattern.empty()) - addDirectory(i->getPath(), *i, priority); + addDirectory(name, *i, priority); else addSubDirectoriesMatching(*i, nextPattern, ignoreCase, priority); } diff --git a/common/events.h b/common/events.h index 42543dc336b..3d75cedd8f2 100644 --- a/common/events.h +++ b/common/events.h @@ -102,7 +102,7 @@ struct Event { /** * Mouse movement since the last mouse movement event. * - * This field is Residual specific + * This field is ResidualVM specific */ Common::Point relMouse; diff --git a/common/forbidden.h b/common/forbidden.h index 95c1a47d65d..8b5a2f738ea 100644 --- a/common/forbidden.h +++ b/common/forbidden.h @@ -182,7 +182,8 @@ #define putchar(a) FORBIDDEN_SYMBOL_REPLACEMENT #endif - +// mingw-w64 uses [set|long]jmp in system headers +#ifndef __MINGW64__ #ifndef FORBIDDEN_SYMBOL_EXCEPTION_setjmp #undef setjmp #define setjmp(a) FORBIDDEN_SYMBOL_REPLACEMENT @@ -192,6 +193,7 @@ #undef longjmp #define longjmp(a,b) FORBIDDEN_SYMBOL_REPLACEMENT #endif +#endif // __MINGW64__ #ifndef FORBIDDEN_SYMBOL_EXCEPTION_system #undef system diff --git a/common/util.h b/common/util.h index b1e52ee5351..a62559ed57b 100644 --- a/common/util.h +++ b/common/util.h @@ -78,6 +78,7 @@ template inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; } # define SCUMMVM_CURRENT_FUNCTION "" #endif +//ResidualVM specific #ifndef round #define round(x) ((x > 0.0) ? floor((x) + 0.5) : ceil((x) - 0.5)) #endif diff --git a/configure b/configure index 3b0572f5bf3..939ca88e820 100755 --- a/configure +++ b/configure @@ -80,10 +80,12 @@ add_engine() { add_engine grim "Grim" yes add_engine myst3 "Myst 3" yes - # # Default settings # +#ResidualVM defaults: mpeg2=no, faad=no, opengles=no +#mt32emu=no, translation=no +# # Default lib behaviour yes/no/auto _vorbis=auto _tremor=auto @@ -95,7 +97,9 @@ _seq_midi=auto _timidity=auto _zlib=auto _sparkle=auto +_png=no _mpeg2=no +_faad=no _fluidsynth=auto _opengl=auto _opengles=no @@ -646,7 +650,7 @@ get_saga_build_string() { # # Greet user # -echo "Running Residual configure..." +echo "Running ResidualVM configure..." echo "Configure run on" `date` > $TMPLOG # @@ -756,6 +760,15 @@ Optional Libraries: --disable-opengl disable OpenGL (ES) support [autodetect] + --with-png-prefix=DIR Prefix where libpng is installed (optional) + --disable-png disable PNG decoder [autodetect] + + --with-theoradec-prefix=DIR Prefix where libtheoradec is installed (optional) + --disable-theoradec disable Theora decoder [autodetect] + + --with-faad-prefix=DIR Prefix where libfaad is installed (optional) + --disable-faad disable AAC decoder [autodetect] + --with-fluidsynth-prefix=DIR Prefix where libfluidsynth is installed (optional) --disable-fluidsynth disable fluidsynth MIDI driver [autodetect] @@ -814,6 +827,12 @@ for ac_option in $@; do --enable-nasm) _nasm=yes ;; --disable-nasm) _nasm=no ;; --enable-mpeg2) _mpeg2=yes ;; + --disable-png) _png=no ;; + --enable-png) _png=yes ;; + --disable-theoradec) _theoradec=no ;; + --enable-theoradec) _theoradec=yes ;; + --disable-faad) _faad=no ;; + --enable-faad) _faad=yes ;; --disable-fluidsynth) _fluidsynth=no ;; --enable-readline) _readline=yes ;; --disable-readline) _readline=no ;; @@ -880,6 +899,21 @@ for ac_option in $@; do MAD_CFLAGS="-I$arg/include" MAD_LIBS="-L$arg/lib" ;; + --with-png-prefix=*) + arg=`echo $ac_option | cut -d '=' -f 2` + PNG_CFLAGS="-I$arg/include" + PNG_LIBS="-L$arg/lib" + ;; + --with-theoradec-prefix=*) + arg=`echo $ac_option | cut -d '=' -f 2` + THEORADEC_CFLAGS="-I$arg/include" + THEORADEC_LIBS="-L$arg/lib" + ;; + --with-faad-prefix=*) + arg=`echo $ac_option | cut -d '=' -f 2` + FAAD_CFLAGS="-I$arg/include" + FAAD_LIBS="-L$arg/lib" + ;; --with-zlib-prefix=*) arg=`echo $ac_option | cut -d '=' -f 2` ZLIB_CFLAGS="-I$arg/include" @@ -1516,7 +1550,7 @@ fi; # However, some platforms use GNU extensions in system header files, so # for these we must not use -pedantic. case $_host_os in -android | gamecube | psp | wii) +android | gamecube | psp | wii | webos) ;; *) # ICC does not support pedantic, while GCC and clang do. @@ -1579,7 +1613,7 @@ esac # Determine a data type with the given length # find_type_with_size() { - for datatype in int short char long unknown; do + for datatype in int short char long "long long" unknown; do cat > tmp_find_type_with_size.cpp << EOF typedef $datatype ac__type_sizeof_; int main() { @@ -1603,22 +1637,34 @@ EOF } # -# Determine a size of pointer type +# Check whether the system is 32-bit # -find_pointer_size() { - cat > tmp_find_pointer_size.cpp << EOF +pointer_is_32bit() { + cat > tmp_pointer_is_32bit.cpp << EOF int main() { - void *p; - int v = (int)p; + static int test_array[1 - 2 * !(sizeof(void *) == 4)]; + test_array[0] = 0; return 0; } EOF - $CXX $CXXFLAGS -c -o $TMPO.o tmp_find_pointer_size.cpp 2>/dev/null + $CXX $CXXFLAGS -c -o $TMPO.o tmp_pointer_is_32bit.cpp 2>/dev/null status=$? - cc_check_clean tmp_find_pointer_size.cpp + cc_check_clean tmp_pointer_is_32bit.cpp return $status } +echo_n "Checking 64-bitness... " +pointer_is_32bit +if test $? -eq 0; then + type_ptr=int32 + echo "no" + add_line_to_config_h "/* #define SCUMM_64BITS */" +else + type_ptr=int64 + echo "yes" + add_line_to_config_h "#define SCUMM_64BITS" +fi + # # Determine data type sizes # @@ -1651,18 +1697,6 @@ fi # force cleanup after check for 8 bytes type cc_check_clean tmp_find_type_with_size.cpp -echo_n "Target 64 bits... " -find_pointer_size -if test $? -eq 0; then - type_ptr=int32 - echo "no" - add_line_to_config_h "/* #define TARGET_64BITS */" -else - type_ptr=int64 - echo "yes" - add_line_to_config_h "#define TARGET_64BITS" -fi - # # Check whether memory alignment is required # @@ -1829,7 +1863,7 @@ case $_host_os in # Now we may have MacPorts or Fink installed # Which put libraries and headers in non-standard places # Checking them here - + # MacPorts # There is no way to get the prefix, so implementing a hack here macport_version=`port version 2>/dev/null` @@ -1985,6 +2019,7 @@ case $_host_os in LIBS="$LIBS -lnsl -lsocket" ;; webos) + CXXFLAGS="$CXXFLAGS --sysroot=$WEBOS_PDK/arm-gcc/sysroot" CXXFLAGS="$CXXFLAGS -I$WEBOS_PDK/include" CXXFLAGS="$CXXFLAGS -I$WEBOS_PDK/include/SDL" CXXFLAGS="$CXXFLAGS -I$WEBOS_PDK/device/usr/include" @@ -3062,6 +3097,76 @@ fi define_in_config_h_if_yes "$_alsa" 'USE_ALSA' echo "$_alsa" +# +# Check for PNG +# +echocheck "PNG >= 1.2.8" +if test "$_png" = auto ; then + _png=no + cat > $TMPC << EOF +#include +int main(void) { +#if PNG_LIBPNG_VER >= 10208 +#else + syntax error +#endif + return 0; +} +EOF + cc_check $PNG_CFLAGS $PNG_LIBS -lpng && _png=yes +fi +if test "$_png" = yes ; then + LIBS="$LIBS $PNG_LIBS -lpng" + INCLUDES="$INCLUDES $PNG_CFLAGS" +fi +define_in_config_if_yes "$_png" 'USE_PNG' +echo "$_png" + +# +# Check for Theora Decoder +# +echocheck "libtheoradec >= 1.0" +if test "$_vorbis" = no ; then + echo "skipping. no vorbis" + _theoradec=notsupported +fi +if test "$_theoradec" = auto ; then + _theoradec=no + cat > $TMPC << EOF +#include +#include +int main(void) { th_ycbcr_buffer yuv; th_decode_ycbcr_out(NULL, yuv); } +EOF + cc_check $THEORADEC_CFLAGS $THEORADEC_LIBS -ltheoradec && _theoradec=yes +fi +if test "$_theoradec" = yes ; then + LIBS="$LIBS $THEORADEC_LIBS -ltheoradec" + INCLUDES="$INCLUDES $THEORADEC_CFLAGS" +fi +define_in_config_if_yes "$_theoradec" 'USE_THEORADEC' +if test ! "$_theoradec" = notsupported ; then + echo "$_theoradec" +fi + +# +# Check for the AAC decoder +# +echocheck "libfaad" +if test "$_faad" = auto ; then + _faad=no + cat > $TMPC << EOF +#include +int main(void) { NeAACDecGetCapabilities(); return 0; } +EOF + cc_check $FAAD_CFLAGS $FAAD_LIBS -lfaad && _faad=yes +fi +if test "$_faad" = yes ; then + LIBS="$LIBS $FAAD_LIBS -lfaad" + INCLUDES="$INCLUDES $FAAD_CFLAGS" +fi +define_in_config_if_yes "$_faad" 'USE_FAAD' +echo "$_faad" + # # Check for SEQ MIDI # @@ -3355,6 +3460,14 @@ EOF fi fi +case $_host_os in + bada) + # components live in non-standard locations so just assume sane SDK + _opengl=yes + _opengles=yes + ;; +esac + if test "$_opengles" = "yes" ; then echo "yes (OpenGL ES)" else @@ -3754,8 +3867,12 @@ typedef unsigned $type_4_byte uint32; typedef signed $type_1_byte int8; typedef signed $type_2_byte int16; typedef signed $type_4_byte int32; +EOF -// Residual 64bit stuff +if test -n "$_def_64bit_type_unsigned" ; then +cat >> config.h << EOF + +/* 64-bit stuff */ $_def_64bit_type_signed #if defined(__APPLE__) && !defined(__ppc__) #ifndef _UINT64 @@ -3765,7 +3882,10 @@ $_def_64bit_type_unsigned #else $_def_64bit_type_unsigned #endif -typedef $type_ptr residualvmptr; +EOF +fi + +cat >> config.h << EOF #endif /* CONFIG_H */ EOF @@ -3789,6 +3909,7 @@ STAGINGPATH=$_stagingpath WIN32PATH=$_win32path AOS4PATH=$_aos4path STATICLIBPATH=$_staticlibpath +#ResidualVM specific: SDLCONFIG=$_sdlconfig BACKEND := $_backend diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index 80c325a06f4..acd8fcacd37 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -534,7 +534,7 @@ int main(int argc, char *argv[]) { projectWarnings["agos"].push_back("4511"); projectWarnings["dreamweb"].push_back("4355"); - + projectWarnings["lure"].push_back("4189"); projectWarnings["lure"].push_back("4355"); @@ -575,6 +575,8 @@ int main(int argc, char *argv[]) { globalWarnings.push_back("-Wwrite-strings"); // The following are not warnings at all... We should consider adding them to // a different list of parameters. + //ResidualVM: disabled: + globalWarnings.push_back("-fno-rtti"); globalWarnings.push_back("-fno-exceptions"); globalWarnings.push_back("-fcheck-new"); @@ -1212,6 +1214,7 @@ void ProjectProvider::createProject(const BuildSetup &setup) { createModuleList(setup.srcDir + "/gui", setup.defines, in, ex); createModuleList(setup.srcDir + "/audio", setup.defines, in, ex); createModuleList(setup.srcDir + "/audio/softsynth/mt32", setup.defines, in, ex); + //ResidualVM specific createModuleList(setup.srcDir + "/math", setup.defines, in, ex); #if HAS_VIDEO_FOLDER createModuleList(setup.srcDir + "/video", setup.defines, in, ex); diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 87706a36f52..e98f4aa761c 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -493,7 +493,6 @@ protected: uint32 _dynamicData; /**< Dynamic data from the GUI Theme that modifies the drawing of the current shape */ int _gradientFactor; /**< Multiplication factor of the active gradient */ - int _gradientBytes[3]; /**< Color bytes of the active gradient, used to speed up calculation */ }; } // End of namespace Graphics diff --git a/graphics/conversion.h b/graphics/conversion.h index 643288a7b9d..6babc763e22 100644 --- a/graphics/conversion.h +++ b/graphics/conversion.h @@ -18,19 +18,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/graphics/conversion.h $ - * $Id: conversion.h 43626 2009-08-22 00:27:13Z dhewg $ - * */ #ifndef GRAPHICS_CONVERSION_H #define GRAPHICS_CONVERSION_H #include "common/util.h" -#include "graphics/pixelformat.h" namespace Graphics { +struct PixelFormat; + /** Converting a color from YUV to RGB colorspace. */ inline static void YUV2RGB(byte y, byte u, byte v, byte &r, byte &g, byte &b) { r = CLIP(y + ((1357 * (v - 128)) >> 10), 0, 255); @@ -45,6 +43,32 @@ inline static void RGB2YUV(byte r, byte g, byte b, byte &y, byte &u, byte &v) { v = CLIP( ((r * 512) >> 10) - ((g * 429) >> 10) - ((b * 83) >> 10) + 128, 0, 255); } -} // end of namespace Graphics +// TODO: generic YUV to RGB blit + +/** + * Blits a rectangle from one graphical format to another. + * + * @param dstbuf the buffer which will recieve the converted graphics data + * @param srcbuf the buffer containing the original graphics data + * @param dstpitch width in bytes of one full line of the dest buffer + * @param srcpitch width in bytes of one full line of the source buffer + * @param w the width of the graphics data + * @param h the height of the graphics data + * @param dstFmt the desired pixel format + * @param srcFmt the original pixel format + * @return true if conversion completes successfully, + * false if there is an error. + * + * @note This implementation currently arbitrarily requires that the + * destination's format have at least as high a bytedepth as + * the source's. + * @note This can convert a rectangle in place, if the source and + * destination format have the same bytedepth. + * + */ +bool crossBlit(byte *dst, const byte *src, int dstpitch, int srcpitch, + int w, int h, const Graphics::PixelFormat &dstFmt, const Graphics::PixelFormat &srcFmt); + +} // End of namespace Graphics #endif // GRAPHICS_CONVERSION_H diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 9395a7e64b0..cab3d14bad4 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -136,23 +136,23 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, } bool CursorManager::supportsCursorPalettes() { - return false; + return false; //ResidualVM: not supported } void CursorManager::disableCursorPalette(bool disable) { - return; + return; //ResidualVM: not supported } void CursorManager::pushCursorPalette(const byte *colors, uint start, uint num) { - return; + return; //ResidualVM: not supported } void CursorManager::popCursorPalette() { - return; + return; //ResidualVM: not supported } void CursorManager::replaceCursorPalette(const byte *colors, uint start, uint num) { - return; + return; //ResidualVM: not supported } CursorManager::Cursor::Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, const Graphics::PixelFormat *format) { diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp index a10d27a2b06..8d967d595fa 100644 --- a/graphics/fontman.cpp +++ b/graphics/fontman.cpp @@ -72,6 +72,20 @@ const struct { { 0, FontManager::kConsoleFont } }; +bool FontManager::setLocalizedFont(const Common::String &name) { + Common::String lowercaseName = name; + lowercaseName.toLowercase(); + + // We only update the localized font in case the name is properly assigned + // to a font. + if (_fontMap.contains(lowercaseName) && _fontMap.getVal(lowercaseName) != 0) { + _localizedFontName = lowercaseName; + return true; + } else { + return false; + } +} + bool FontManager::assignFontToName(const Common::String &name, const Font *font) { Common::String lowercaseName = name; lowercaseName.toLowercase(); @@ -79,19 +93,19 @@ bool FontManager::assignFontToName(const Common::String &name, const Font *font) return true; } -bool FontManager::setFont(FontUsage usage, const Font *font) { +bool FontManager::setFont(FontUsage usage, const BdfFont *font) { switch (usage) { case kConsoleFont: delete g_consolefont; - g_consolefont = (const BdfFont *)font; + g_consolefont = font; break; case kGUIFont: delete g_sysfont; - g_sysfont = (const BdfFont *)font; + g_sysfont = font; break; case kBigGUIFont: delete g_sysfont_big; - g_sysfont_big = (const BdfFont *)font; + g_sysfont_big = font; break; default: return false; @@ -103,6 +117,11 @@ void FontManager::removeFontName(const Common::String &name) { Common::String lowercaseName = name; lowercaseName.toLowercase(); _fontMap.erase(lowercaseName); + + // In case the current localized font is removed, we fall back to the + // default font again. + if (_localizedFontName == lowercaseName) + _localizedFontName.clear(); } const Font *FontManager::getFontByName(const Common::String &name) const { @@ -126,51 +145,16 @@ const Font *FontManager::getFontByUsage(FontUsage usage) const { case kBigGUIFont: return g_sysfont_big; case kLocalizedFont: - { - // First try to find a kBigGUIFont - Common::String fontName = getLocalizedFontNameByUsage(kBigGUIFont); - if (!fontName.empty()) { - const Font *font = getFontByName(fontName); - if (font) - return font; - } - // Try kGUIFont - fontName = getLocalizedFontNameByUsage(kGUIFont); - if (!fontName.empty()) { - const Font *font = getFontByName(fontName); - if (font) - return font; - } -#ifdef USE_TRANSLATION - // Accept any other font that has the charset in its name - for (Common::HashMap::const_iterator it = _fontMap.begin() ; it != _fontMap.end() ; ++it) { - if (it->_key.contains(TransMan.getCurrentCharset())) - return it->_value; - } -#endif - // Fallback: return a non localized kGUIFont. - // Maybe we should return a null pointer instead? - return g_sysfont; - } + // By default use the big font as localized font + if (_localizedFontName.empty()) + return g_sysfont_big; + else + return _fontMap[_localizedFontName]; } return 0; } -Common::String FontManager::getLocalizedFontNameByUsage(FontUsage usage) const { - // We look for a name that matches the usage and that ends in .bdf. - // It should also not contain "-ascii" or "-iso-" in its name. - // We take the first name that matches. - for (int i = 0; builtinFontNames[i].name; i++) { - if (builtinFontNames[i].id == usage) { - Common::String fontName(builtinFontNames[i].name); - if (!fontName.contains("-ascii") && !fontName.contains("-iso-") && fontName.contains(".bdf")) - return genLocalizedFontFilename(fontName); - } - } - return Common::String(); -} - Common::String FontManager::genLocalizedFontFilename(const Common::String &filename) const { #ifndef USE_TRANSLATION return filename; diff --git a/graphics/fontman.h b/graphics/fontman.h index 09c1a198ff4..42f7d856fa5 100644 --- a/graphics/fontman.h +++ b/graphics/fontman.h @@ -32,6 +32,7 @@ namespace Graphics { class Font; +class BdfFont; class FontManager : public Common::Singleton { public: @@ -42,6 +43,14 @@ public: kBigGUIFont = 3 }; + /** + * Sets the localized font name. + * + * @param name the name of the localized font. + * @return true when the font was present, false otherwise. + */ + bool setLocalizedFont(const Common::String &name); + /** * Retrieve a font object based on its 'name'. * @@ -67,7 +76,7 @@ public: * @param font the font object * @return true on success, false on failure */ - bool setFont(FontUsage usage, const Font *font); + bool setFont(FontUsage usage, const BdfFont *font); /** * Removes binding from name to font @@ -96,22 +105,13 @@ public: //const Font *getFontBySize(int size???) const; -protected: - /** - * Get the name of the localized font for the given usage. There is no garanty that - * the font exists. If the usage is kLocalizedFont it returns an empty string. - * - * @param usage a FontUsage enum value indicating what the font will be used for. - * @return the name of a localized font or an empty string if no suitable font was found. - */ - Common::String getLocalizedFontNameByUsage(FontUsage usage) const; - private: friend class Common::Singleton; FontManager(); ~FontManager(); Common::HashMap _fontMap; + Common::String _localizedFontName; }; diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp index 6fa886a9051..6d4befa37c8 100644 --- a/graphics/fonts/bdf.cpp +++ b/graphics/fonts/bdf.cpp @@ -67,7 +67,7 @@ int BdfFont::getCharWidth(byte chr) const { template void drawCharIntern(byte *ptr, uint pitch, const byte *src, int h, int width, int minX, int maxX, const PixelType color) { - byte data; + byte data = 0; while (h--) { PixelType *dst = (PixelType *)ptr; diff --git a/graphics/imagedec.cpp b/graphics/imagedec.cpp index 355d9e6128c..226378cb270 100644 --- a/graphics/imagedec.cpp +++ b/graphics/imagedec.cpp @@ -117,7 +117,7 @@ Surface *BMPDecoder::decodeImage(Common::SeekableReadStream &stream, const Pixel assert(newSurf); newSurf->create(info.width, info.height, format); assert(newSurf->pixels); - byte *curPixel = (byte*)newSurf->pixels + (newSurf->h-1) * newSurf->pitch; + byte *curPixel = (byte *)newSurf->pixels + (newSurf->h - 1) * newSurf->pitch; int pitchAdd = info.width % 4; for (int i = 0; i < newSurf->h; ++i) { for (int i2 = 0; i2 < newSurf->w; ++i2) { diff --git a/graphics/jpeg.cpp b/graphics/jpeg.cpp index 70ffb06f6b6..88094774051 100644 --- a/graphics/jpeg.cpp +++ b/graphics/jpeg.cpp @@ -18,9 +18,6 @@ * 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$ - * */ #include "graphics/conversion.h" @@ -227,7 +224,7 @@ bool JPEG::read(Common::SeekableReadStream *stream) { bool JPEG::readJFIF() { uint16 length = _stream->readUint16BE(); uint32 tag = _stream->readUint32BE(); - if (tag != MKTAG('J','F','I','F')) { + if (tag != MKTAG('J', 'F', 'I', 'F')) { warning("JPEG::readJFIF() tag mismatch"); return false; } @@ -237,7 +234,7 @@ bool JPEG::readJFIF() { } byte majorVersion = _stream->readByte(); byte minorVersion = _stream->readByte(); - if(majorVersion != 1 || minorVersion != 1) + if (majorVersion != 1 || minorVersion != 1) warning("JPEG::readJFIF() Non-v1.1 JPEGs may not be handled correctly"); /* byte densityUnits = */ _stream->readByte(); /* uint16 xDensity = */ _stream->readUint16BE(); @@ -307,7 +304,7 @@ bool JPEG::readDHT() { // Free the Huffman table delete[] _huff[tableNum].values; _huff[tableNum].values = NULL; delete[] _huff[tableNum].sizes; _huff[tableNum].sizes = NULL; - delete[] _huff[tableNum].codes; _huff[tableNum].codes = NULL; + delete[] _huff[tableNum].codes; _huff[tableNum].codes = NULL; // Read the number of values for each length uint8 numValues[16]; @@ -514,13 +511,13 @@ void JPEG::idct8x8(float result[64], const int16 dct[64]) { for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { tmp[y + x * 8] = dct[0] * _idct8x8[x][0] - + dct[1] * _idct8x8[x][1] - + dct[2] * _idct8x8[x][2] - + dct[3] * _idct8x8[x][3] - + dct[4] * _idct8x8[x][4] - + dct[5] * _idct8x8[x][5] - + dct[6] * _idct8x8[x][6] - + dct[7] * _idct8x8[x][7]; + + dct[1] * _idct8x8[x][1] + + dct[2] * _idct8x8[x][2] + + dct[3] * _idct8x8[x][3] + + dct[4] * _idct8x8[x][4] + + dct[5] * _idct8x8[x][5] + + dct[6] * _idct8x8[x][6] + + dct[7] * _idct8x8[x][7]; } dct += 8; @@ -531,13 +528,13 @@ void JPEG::idct8x8(float result[64], const int16 dct[64]) { const float *u = tmp + x * 8; for (int y = 0; y < 8; y++) { result[y * 8 + x] = u[0] * _idct8x8[y][0] - + u[1] * _idct8x8[y][1] - + u[2] * _idct8x8[y][2] - + u[3] * _idct8x8[y][3] - + u[4] * _idct8x8[y][4] - + u[5] * _idct8x8[y][5] - + u[6] * _idct8x8[y][6] - + u[7] * _idct8x8[y][7]; + + u[1] * _idct8x8[y][1] + + u[2] * _idct8x8[y][2] + + u[3] * _idct8x8[y][3] + + u[4] * _idct8x8[y][4] + + u[5] * _idct8x8[y][5] + + u[6] * _idct8x8[y][6] + + u[7] * _idct8x8[y][7]; } } } @@ -657,8 +654,7 @@ int16 JPEG::readSignedBits(uint8 numBits) { ret = (ret << 1) + readBit(); // Extend sign bits (PAG109) - if (!(ret >> (numBits - 1))) - { + if (!(ret >> (numBits - 1))) { uint16 tmp = ((uint16)-1 << numBits) + 1; ret = ret + tmp; } diff --git a/graphics/jpeg.h b/graphics/jpeg.h index 3e26e9add29..27b91e87776 100644 --- a/graphics/jpeg.h +++ b/graphics/jpeg.h @@ -18,9 +18,6 @@ * 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 GRAPHICS_JPEG_H @@ -75,7 +72,7 @@ private: // Result image for this component Surface surface; }; - + Component *_components; // Scan components diff --git a/graphics/module.mk b/graphics/module.mk index 72c4a61639c..07eb658275a 100644 --- a/graphics/module.mk +++ b/graphics/module.mk @@ -9,6 +9,7 @@ MODULE_OBJS := \ fonts/newfont_big.o \ fonts/newfont.o \ imagedec.o \ + jpeg.o \ primitives.o \ surface.o \ thumbnail.o \ @@ -16,7 +17,6 @@ MODULE_OBJS := \ VectorRendererSpec.o \ yuv_to_rgb.o \ yuva_to_rgba.o \ - jpeg.o \ pixelbuffer.o \ tinygl/api.o \ tinygl/arrays.o \ diff --git a/graphics/scaler.h b/graphics/scaler.h index 6f369b388fa..61a3d4f6322 100644 --- a/graphics/scaler.h +++ b/graphics/scaler.h @@ -25,6 +25,41 @@ #include "common/scummsys.h" #include "graphics/surface.h" +extern void InitScalers(uint32 BitFormat); +extern void DestroyScalers(); + +typedef void ScalerProc(const uint8 *srcPtr, uint32 srcPitch, + uint8 *dstPtr, uint32 dstPitch, int width, int height); + +#define DECLARE_SCALER(x) \ + extern void x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, \ + uint32 dstPitch, int width, int height) + + +DECLARE_SCALER(Normal1x); + +#ifdef USE_SCALERS + +DECLARE_SCALER(Normal2x); +DECLARE_SCALER(Normal3x); +DECLARE_SCALER(Normal1o5x); + +DECLARE_SCALER(_2xSaI); +DECLARE_SCALER(Super2xSaI); +DECLARE_SCALER(SuperEagle); + +DECLARE_SCALER(AdvMame2x); +DECLARE_SCALER(AdvMame3x); + +DECLARE_SCALER(TV2x); +DECLARE_SCALER(DotMatrix); + +#ifdef USE_HQ_SCALERS +DECLARE_SCALER(HQ2x); +DECLARE_SCALER(HQ3x); +#endif + +#endif // #ifdef USE_SCALERS // creates a 160x100 thumbnail for 320x200 games // and 160x120 thumbnail for 320x240 and 640x480 games @@ -41,6 +76,7 @@ enum { * @param surf a surface (will always have 16 bpp after this for now) * @return false if a error occurred */ +//ResidualVM: not supported //extern bool createThumbnailFromScreen(Graphics::Surface *surf); /** @@ -52,6 +88,7 @@ enum { * @param h height * @param palette palette in RGB format */ +//ResidualVM: not supported //extern bool createThumbnail(Graphics::Surface *surf, const uint8 *pixels, int w, int h, const uint8 *palette); #endif diff --git a/graphics/thumbnail.cpp b/graphics/thumbnail.cpp index 5db0e6c5738..02324e767a8 100644 --- a/graphics/thumbnail.cpp +++ b/graphics/thumbnail.cpp @@ -126,6 +126,7 @@ Graphics::Surface *loadThumbnail(Common::SeekableReadStream &in) { bool saveThumbnail(Common::WriteStream &out) { Graphics::Surface thumb; +//ResidualVM: not supported // if (!createThumbnailFromScreen(&thumb)) { // warning("Couldn't create thumbnail from screen, aborting thumbnail save"); return false; diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index e64e5ea4ff3..e389e32a1f4 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -261,7 +261,8 @@ void ThemeItemBitmap::drawSelf(bool draw, bool restore) { ThemeEngine::ThemeEngine(Common::String id, GraphicsMode mode) : _system(0), _vectorRenderer(0), _buffering(false), _bytesPerPixel(0), _graphicsMode(kGfxDisabled), - _font(0), _initOk(false), _themeOk(false), _enabled(false), _cursor(0) { + _font(0), _initOk(false), _themeOk(false), _enabled(false), _themeFiles(), + _cursor(0) { _system = g_system; _parser = new ThemeParser(this); @@ -294,6 +295,9 @@ ThemeEngine::ThemeEngine(Common::String id, GraphicsMode mode) : _graphicsMode = mode; _themeArchive = 0; _initOk = false; + + // We prefer files in archive bundles over the common search paths. + _themeFiles.add("default", &SearchMan, 0, false); } ThemeEngine::~ThemeEngine() { @@ -317,7 +321,6 @@ ThemeEngine::~ThemeEngine() { delete _parser; delete _themeEval; delete[] _cursor; - delete _themeArchive; } @@ -406,6 +409,9 @@ bool ThemeEngine::init() { } } } + + if (_themeArchive) + _themeFiles.add("theme_archive", _themeArchive, 1, true); } // Load the theme @@ -564,35 +570,20 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &file) { _texts[textId]->_fontPtr = _font; } else { Common::String localized = FontMan.genLocalizedFontFilename(file); - // Try built-in fonts - _texts[textId]->_fontPtr = FontMan.getFontByName(localized); + // Try localized fonts + _texts[textId]->_fontPtr = loadFont(localized, textId == kTextDataDefault); if (!_texts[textId]->_fontPtr) { - // First try to load localized font - _texts[textId]->_fontPtr = loadFont(localized); + // Try standard fonts + _texts[textId]->_fontPtr = loadFont(file, textId == kTextDataDefault); - if (_texts[textId]->_fontPtr) - FontMan.assignFontToName(localized, _texts[textId]->_fontPtr); + if (!_texts[textId]->_fontPtr) + error("Couldn't load font '%s'", file.c_str()); - // Fallback to non-localized font and default translation - else { - // Try built-in fonts - _texts[textId]->_fontPtr = FontMan.getFontByName(file); - - // Try to load it - if (!_texts[textId]->_fontPtr) { - _texts[textId]->_fontPtr = loadFont(file); - - if (!_texts[textId]->_fontPtr) - error("Couldn't load font '%s'", file.c_str()); - - FontMan.assignFontToName(file, _texts[textId]->_fontPtr); - } #ifdef USE_TRANSLATION - TransMan.setLanguage("C"); + TransMan.setLanguage("C"); #endif - warning("Failed to load localized font '%s'. Using non-localized font and default GUI language instead", localized.c_str()); - } + warning("Failed to load localized font '%s'. Using non-localized font and default GUI language instead", localized.c_str()); } } @@ -623,12 +614,16 @@ bool ThemeEngine::addBitmap(const Common::String &filename) { return true; // If not, try to load the bitmap via the ImageDecoder class. - surf = Graphics::ImageDecoder::loadFile(filename, _overlayFormat); - if (!surf && _themeArchive) { - Common::SeekableReadStream *stream = _themeArchive->createReadStreamForMember(filename); + Common::ArchiveMemberList members; + _themeFiles.listMatchingMembers(members, filename); + for (Common::ArchiveMemberList::const_iterator i = members.begin(), end = members.end(); i != end; ++i) { + Common::SeekableReadStream *stream = (*i)->createReadStream(); if (stream) { surf = Graphics::ImageDecoder::loadFile(*stream, _overlayFormat); delete stream; + + if (surf) + break; } } @@ -1390,68 +1385,45 @@ DrawData ThemeEngine::parseDrawDataId(const Common::String &name) const { * External data loading *********************************************************/ -const Graphics::Font *ThemeEngine::loadFontFromArchive(const Common::String &filename) { - Common::SeekableReadStream *stream = 0; - const Graphics::Font *font = 0; +const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename, const bool makeLocalizedFont) { + // Try already loaded fonts. + const Graphics::Font *font = FontMan.getFontByName(filename); + if (font) + return font; - if (_themeArchive) - stream = _themeArchive->createReadStreamForMember(filename); - if (stream) { - font = Graphics::BdfFont::loadFont(*stream); - delete stream; - } - - return font; -} - -const Graphics::Font *ThemeEngine::loadCachedFontFromArchive(const Common::String &filename) { - Common::SeekableReadStream *stream = 0; - const Graphics::Font *font = 0; - - if (_themeArchive) - stream = _themeArchive->createReadStreamForMember(filename); - if (stream) { - font = Graphics::BdfFont::loadFromCache(*stream); - delete stream; - } - - return font; -} - -const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename) { - const Graphics::Font *font = 0; Common::String cacheFilename = genCacheFilename(filename); - Common::File fontFile; - if (!cacheFilename.empty()) { - if (fontFile.open(cacheFilename)) { - font = Graphics::BdfFont::loadFromCache(fontFile); + Common::ArchiveMemberList members; + _themeFiles.listMatchingMembers(members, cacheFilename); + _themeFiles.listMatchingMembers(members, filename); + + for (Common::ArchiveMemberList::const_iterator i = members.begin(), end = members.end(); i != end; ++i) { + Common::SeekableReadStream *stream = (*i)->createReadStream(); + if (stream) { + if ((*i)->getName().equalsIgnoreCase(cacheFilename)) { + font = Graphics::BdfFont::loadFromCache(*stream); + } else { + font = Graphics::BdfFont::loadFont(*stream); + if (font && !cacheFilename.empty()) { + if (!Graphics::BdfFont::cacheFontData(*(const Graphics::BdfFont *)font, cacheFilename)) + warning("Couldn't create cache file for font '%s'", filename.c_str()); + } + } + delete stream; } if (font) - return font; - - if ((font = loadCachedFontFromArchive(cacheFilename))) - return font; - } - - // normal open - if (fontFile.open(filename)) { - font = Graphics::BdfFont::loadFont(fontFile); - } - - if (!font) { - font = loadFontFromArchive(filename); + break; } + // If the font is successfully loaded store it in the font manager. if (font) { - if (!cacheFilename.empty()) { - if (!Graphics::BdfFont::cacheFontData(*(const Graphics::BdfFont *)font, cacheFilename)) { - warning("Couldn't create cache file for font '%s'", filename.c_str()); - } - } + FontMan.assignFontToName(filename, font); + // If this font should be the new default localized font, we set it up + // for that. + if (makeLocalizedFont) + FontMan.setLocalizedFont(filename); } - return font; } diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 5281e994199..b9cc1f5e058 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -536,9 +536,7 @@ protected: */ void unloadTheme(); - const Graphics::Font *loadFont(const Common::String &filename); - const Graphics::Font *loadFontFromArchive(const Common::String &filename); - const Graphics::Font *loadCachedFontFromArchive(const Common::String &filename); + const Graphics::Font *loadFont(const Common::String &filename, const bool makeLocalizedFont); Common::String genCacheFilename(const Common::String &filename) const; /** @@ -658,6 +656,7 @@ protected: Common::String _themeId; Common::String _themeFile; Common::Archive *_themeArchive; + Common::SearchSet _themeFiles; bool _useCursor; int _cursorHotspotX, _cursorHotspotY; diff --git a/gui/browser_osx.mm b/gui/browser_osx.mm index 290fe6ca37b..5728fef55a1 100644 --- a/gui/browser_osx.mm +++ b/gui/browser_osx.mm @@ -54,11 +54,7 @@ int BrowserDialog::runModal() { NSOpenPanel * panel = [NSOpenPanel openPanel]; [panel setCanChooseDirectories:YES]; if ([panel runModalForTypes:nil] == NSOKButton) { -#ifdef __POWERPC__ - const char *filename = [[panel filename] cString]; -#else - const char *filename = [[panel filename] cStringUsingEncoding:NSUTF8StringEncoding]; -#endif + const char *filename = [[panel filename] UTF8String]; _choice = Common::FSNode(filename); choiceMade = true; } diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index 7c8d7f2548c..17de3864097 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -132,15 +132,7 @@ void GuiManager::pushKeymap() { } void GuiManager::popKeymap() { - Common::Keymapper *keymapper = _system->getEventManager()->getKeymapper(); - if (!keymapper->getActiveStack().empty()) { - Common::Keymapper::MapRecord topKeymap = keymapper->getActiveStack().top(); - // TODO: Don't use the keymap name as a way to discriminate GUI maps - if(topKeymap.keymap->getName().equals(Common::kGuiKeymapName)) - keymapper->popKeymap(); - else - warning("An attempt to pop non-gui keymap %s was blocked", topKeymap.keymap->getName().c_str()); - } + _system->getEventManager()->getKeymapper()->popKeymap(Common::kGuiKeymapName); } #endif @@ -285,15 +277,6 @@ void GuiManager::runLoop() { uint32 lastRedraw = 0; const uint32 waitTime = 1000 / 45; -#ifdef ENABLE_KEYMAPPER - // Due to circular reference with event manager and GUI - // we cannot init keymap on the GUI creation. Thus, let's - // try to do it on every launch, checking whether the - // map is already existing - initKeymap(); - pushKeymap(); -#endif - bool tooltipCheck = false; while (!_dialogStack.empty() && activeDialog == getTopDialog()) { @@ -405,10 +388,6 @@ void GuiManager::runLoop() { _system->delayMillis(10); } -#ifdef ENABLE_KEYMAPPER - popKeymap(); -#endif - if (didSaveState) { _theme->disable(); restoreState(); @@ -419,6 +398,10 @@ void GuiManager::runLoop() { #pragma mark - void GuiManager::saveState() { +#ifdef ENABLE_KEYMAPPER + initKeymap(); + pushKeymap(); +#endif // Backup old cursor _lastClick.x = _lastClick.y = 0; _lastClick.time = 0; @@ -428,6 +411,9 @@ void GuiManager::saveState() { } void GuiManager::restoreState() { +#ifdef ENABLE_KEYMAPPER + popKeymap(); +#endif if (_useStdCursor) { CursorMan.popCursor(); CursorMan.popCursorPalette(); diff --git a/gui/themes/modern.zip b/gui/themes/modern.zip index 6c8fb0391ab..d55e2af9188 100644 Binary files a/gui/themes/modern.zip and b/gui/themes/modern.zip differ diff --git a/gui/themes/modern/eraser.bmp b/gui/themes/modern/eraser.bmp index 782b13dc62d..b927a6384fb 100644 Binary files a/gui/themes/modern/eraser.bmp and b/gui/themes/modern/eraser.bmp differ diff --git a/ports.mk b/ports.mk index 9fd2a878119..8cfd92a33bb 100644 --- a/ports.mk +++ b/ports.mk @@ -16,8 +16,7 @@ install: $(INSTALL) -d "$(DESTDIR)$(docdir)" $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) "$(DESTDIR)$(docdir)" $(INSTALL) -d "$(DESTDIR)$(datadir)" - $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) "$(DESTDIR)$(datadir)/" - $(INSTALL) -c -m 644 $(DIST_FILES_ENGINEDATA) "$(DESTDIR)$(datadir)/" + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) "$(DESTDIR)$(datadir)/" ifdef DYNAMIC_MODULES $(INSTALL) -d "$(DESTDIR)$(libdir)/residualvm/" $(INSTALL) -c -s -m 644 $(PLUGINS) "$(DESTDIR)$(libdir)/residualvm/" @@ -82,6 +81,7 @@ endif # Location of static libs for the iPhone ifneq ($(BACKEND), iphone) # Static libaries, used for the residualvm-static and iphone targets +#ResidualVM path for SDL OSX_STATIC_LIBS := `$(SDLCONFIG) --static-libs` endif @@ -122,7 +122,7 @@ OSX_STATIC_LIBS += $(STATICLIBPATH)/lib/libfaad.a endif ifdef USE_ZLIB -OSX_ZLIB ?= -lz +OSX_ZLIB ?= $(STATICLIBPATH)/lib/libz.a endif ifdef USE_SPARKLE @@ -163,6 +163,7 @@ osxsnap: bundle cp $(srcdir)/COPYRIGHT ./ResidualVM-snapshot/Copyright\ Holders cp $(srcdir)/NEWS ./ResidualVM-snapshot/News cp $(srcdir)/README ./ResidualVM-snapshot/Residual\ ReadMe + mkdir ScummVM-snapshot/doc /Developer/Tools/SetFile -t ttro -c ttxt ./ResidualVM-snapshot/* /Developer/Tools/CpMac -r $(bundle_name) ./ResidualVM-snapshot/ #cp $(srcdir)/dists/macosx/DS_Store ./ResidualVM-snapshot/.DS_Store @@ -186,6 +187,7 @@ residualvmwinres.o: $(srcdir)/icons/residualvm.ico $(DIST_FILES_THEMES) $(DIST_F win32dist: $(EXECUTABLE) mkdir -p $(WIN32PATH) mkdir -p $(WIN32PATH)/graphics + mkdir -p $(WIN32PATH)/doc $(STRIP) $(EXECUTABLE) -o $(WIN32PATH)/$(EXECUTABLE) cp $(DIST_FILES_THEMES) $(WIN32PATH) ifdef DIST_FILES_ENGINEDATA @@ -202,6 +204,7 @@ endif cp $(srcdir)/icons/residualvm.ico $(WIN32PATH) cp $(srcdir)/dists/win32/residualvm.iss $(WIN32PATH) unix2dos $(WIN32PATH)/*.txt + unix2dos $(WIN32PATH)/doc/*.txt # Special target to create a win32 NSIS installer win32setup: $(EXECUTABLE) mkdir -p $(srcdir)/$(STAGINGPATH) diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp index 691c75d75f0..106ecd90b24 100644 --- a/video/bink_decoder.cpp +++ b/video/bink_decoder.cpp @@ -515,7 +515,7 @@ void BinkDecoder::mergeHuffmanSymbols(VideoFrame &video, byte *dst, const byte * } bool BinkDecoder::loadStream(Common::SeekableReadStream *stream) { - Graphics::PixelFormat format = g_system->getOverlayFormat(); // residual FIXME: getScreenFormat(); + Graphics::PixelFormat format = g_system->getOverlayFormat(); // ResidualVM specific: getScreenFormat(); return loadStream(stream, format); } diff --git a/video/bink_decoder.h b/video/bink_decoder.h index 7f7a90d48cf..e033ab9d022 100644 --- a/video/bink_decoder.h +++ b/video/bink_decoder.h @@ -66,7 +66,6 @@ public: // VideoDecoder API bool loadStream(Common::SeekableReadStream *stream); - bool loadStream(Common::SeekableReadStream *stream, const Graphics::PixelFormat &format); void close(); bool isVideoLoaded() const { return _bink != 0; } uint16 getWidth() const { return _surface.w; } @@ -79,6 +78,8 @@ public: // FixedRateVideoDecoder Common::Rational getFrameRate() const { return _frameRate; } + // Bink specific + bool loadStream(Common::SeekableReadStream *stream, const Graphics::PixelFormat &format); protected: static const int kAudioChannelsMax = 2; static const int kAudioBlockSizeMax = (kAudioChannelsMax << 11); @@ -263,7 +264,7 @@ protected: /** * Decode a video packet. * - * This method is virtual because it is overriden in Residual + * This method is virtual because it is overriden in ResidualVM * to export the alpha channel of the video */ virtual void videoPacket(VideoFrame &video);