diff --git a/.gitignore b/.gitignore index a6b4df65b97..45ee942b0d7 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,23 @@ lib*.a .deps +/config.log +/residual +/residual-static +/config.h +/config.mk +/.gdb_history +/dumps +/Credits.rtf +/*.mshark +/*.dSYM +/MT32_CONTROL.ROM +/MT32_PCM.ROM +/Residual.app +/*.ipk +/.project +/.cproject +/.settings /dists/codeblocks/*.cbp /dists/codeblocks/*.depend /dists/codeblocks/*.layout @@ -18,6 +35,7 @@ lib*.a /dists/msvc*/*.dat /dists/msvc*/*.dll +/plugins /devtools/create_project/create_project #ignore thumbnails created by windows diff --git a/Makefile.common b/Makefile.common index ac4f9eac165..996662486ec 100644 --- a/Makefile.common +++ b/Makefile.common @@ -25,6 +25,7 @@ MODULES += \ gui \ backends \ engines \ + video \ graphics \ audio \ common \ diff --git a/audio/audiostream.cpp b/audio/audiostream.cpp index 0c41a382543..776f904e77a 100644 --- a/audio/audiostream.cpp +++ b/audio/audiostream.cpp @@ -24,14 +24,14 @@ */ #include "common/debug.h" -#include "common/endian.h" #include "common/file.h" +#include "common/mutex.h" +#include "common/textconsole.h" #include "common/queue.h" #include "common/util.h" #include "audio/audiostream.h" #include "audio/decoders/flac.h" -#include "audio/mixer.h" #include "audio/decoders/mp3.h" #include "audio/decoders/raw.h" #include "audio/decoders/vorbis.h" diff --git a/audio/audiostream.h b/audio/audiostream.h index cd6456cc70a..22de21cb34e 100644 --- a/audio/audiostream.h +++ b/audio/audiostream.h @@ -26,16 +26,14 @@ #ifndef SOUND_AUDIOSTREAM_H #define SOUND_AUDIOSTREAM_H -#include "common/util.h" #include "common/scummsys.h" +#include "common/str.h" #include "common/types.h" #include "audio/timestamp.h" namespace Audio { -class SeekableAudioStream; - /** * Generic audio input stream. Subclasses of this are used to feed arbitrary * sampled audio data into ScummVM's audio mixer. diff --git a/audio/decoders/flac.cpp b/audio/decoders/flac.cpp index 76b6d354198..fe15877ac6c 100644 --- a/audio/decoders/flac.cpp +++ b/audio/decoders/flac.cpp @@ -32,6 +32,7 @@ #include "common/debug.h" #include "common/stream.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/audiostream.h" diff --git a/audio/decoders/flac.h b/audio/decoders/flac.h index 17f95ec1fb0..69222f22a16 100644 --- a/audio/decoders/flac.h +++ b/audio/decoders/flac.h @@ -49,12 +49,11 @@ #ifdef USE_FLAC namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace Audio { -class AudioStream; class SeekableAudioStream; /** diff --git a/audio/decoders/mp3.cpp b/audio/decoders/mp3.cpp index 53d68fa9dbb..91bd49873a0 100644 --- a/audio/decoders/mp3.cpp +++ b/audio/decoders/mp3.cpp @@ -29,6 +29,7 @@ #include "common/debug.h" #include "common/stream.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/audiostream.h" diff --git a/audio/decoders/mp3.h b/audio/decoders/mp3.h index 72bc6e1b3ed..d3a5b70d454 100644 --- a/audio/decoders/mp3.h +++ b/audio/decoders/mp3.h @@ -50,12 +50,11 @@ #ifdef USE_MAD namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace Audio { -class AudioStream; class SeekableAudioStream; /** diff --git a/audio/decoders/raw.cpp b/audio/decoders/raw.cpp index 8b833c78389..cf787f9b12b 100644 --- a/audio/decoders/raw.cpp +++ b/audio/decoders/raw.cpp @@ -25,9 +25,10 @@ #include "common/endian.h" #include "common/memstream.h" +#include "common/textconsole.h" +#include "common/util.h" #include "audio/audiostream.h" -#include "audio/mixer.h" #include "audio/decoders/raw.h" namespace Audio { diff --git a/audio/decoders/raw.h b/audio/decoders/raw.h index 3e9426012c1..23ed02182dd 100644 --- a/audio/decoders/raw.h +++ b/audio/decoders/raw.h @@ -32,12 +32,12 @@ #include "common/list.h" -namespace Common { class SeekableReadStream; } - +namespace Common { +class SeekableReadStream; +} namespace Audio { -class AudioStream; class SeekableAudioStream; /** diff --git a/audio/decoders/vorbis.cpp b/audio/decoders/vorbis.cpp index dc37e852d36..63f7ba82079 100644 --- a/audio/decoders/vorbis.cpp +++ b/audio/decoders/vorbis.cpp @@ -32,15 +32,15 @@ #ifdef USE_VORBIS -#include "common/debug.h" #include "common/stream.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/audiostream.h" #ifdef USE_TREMOR -#if defined(__GP32__) // custom libtremor locations -#include +#ifdef USE_TREMOLO +#include #else #include #endif diff --git a/audio/decoders/vorbis.h b/audio/decoders/vorbis.h index 7cc395cccb8..51d0b82d5fa 100644 --- a/audio/decoders/vorbis.h +++ b/audio/decoders/vorbis.h @@ -49,12 +49,11 @@ #ifdef USE_VORBIS namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace Audio { -class AudioStream; class SeekableAudioStream; /** diff --git a/audio/fmopl.cpp b/audio/fmopl.cpp index 1f61e161018..5952a987a7a 100644 --- a/audio/fmopl.cpp +++ b/audio/fmopl.cpp @@ -28,6 +28,7 @@ #include "audio/softsynth/opl/mame.h" #include "common/config-manager.h" +#include "common/textconsole.h" #include "common/translation.h" namespace OPL { diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp index a1487ff69dc..6cc3366847a 100644 --- a/audio/mididrv.cpp +++ b/audio/mididrv.cpp @@ -23,14 +23,14 @@ * */ -#include "engines/engine.h" #include "common/config-manager.h" +#include "common/error.h" #include "common/str.h" #include "common/system.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/mididrv.h" #include "audio/musicplugin.h" -#include "common/translation.h" const byte MidiDriver::_mt32ToGm[128] = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F diff --git a/audio/mididrv.h b/audio/mididrv.h index 8d6f9424558..c6c51790514 100644 --- a/audio/mididrv.h +++ b/audio/mididrv.h @@ -27,15 +27,10 @@ #define SOUND_MIDIDRV_H #include "common/scummsys.h" +#include "common/str.h" #include "common/timer.h" class MidiChannel; -class MusicDevice; - -namespace Audio { - class Mixer; -} -namespace Common { class String; } /** * Music types that music drivers can implement and engines can rely on. diff --git a/audio/midiparser.cpp b/audio/midiparser.cpp index a6df6024cd2..a1399d0c309 100644 --- a/audio/midiparser.cpp +++ b/audio/midiparser.cpp @@ -25,6 +25,7 @@ #include "audio/midiparser.h" #include "audio/mididrv.h" +#include "common/textconsole.h" #include "common/util.h" ////////////////////////////////////////////////// diff --git a/audio/midiparser.h b/audio/midiparser.h index eeeee981e43..24f2ba79636 100644 --- a/audio/midiparser.h +++ b/audio/midiparser.h @@ -31,7 +31,6 @@ #include "common/scummsys.h" #include "common/endian.h" -class MidiParser; class MidiDriver_BASE; diff --git a/audio/mixer.cpp b/audio/mixer.cpp index dc0287e3fbc..4d23487e713 100644 --- a/audio/mixer.cpp +++ b/audio/mixer.cpp @@ -25,6 +25,7 @@ #include "common/util.h" #include "common/system.h" +#include "common/textconsole.h" #include "audio/mixer_intern.h" #include "audio/rate.h" @@ -162,16 +163,11 @@ private: MixerImpl::MixerImpl(OSystem *system, uint sampleRate) - : _syst(system), _sampleRate(sampleRate), _mixerReady(false), _handleSeed(0) { + : _syst(system), _mutex(), _sampleRate(sampleRate), _mixerReady(false), _handleSeed(0), _soundTypeSettings() { assert(sampleRate > 0); - int i; - - for (i = 0; i < ARRAYSIZE(_volumeForSoundType); i++) - _volumeForSoundType[i] = kMaxMixerVolume; - - for (i = 0; i != NUM_CHANNELS; i++) + for (int i = 0; i != NUM_CHANNELS; i++) _channels[i] = 0; } @@ -322,6 +318,21 @@ void MixerImpl::stopHandle(SoundHandle handle) { _channels[index] = 0; } +void MixerImpl::muteSoundType(SoundType type, bool mute) { + assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings)); + _soundTypeSettings[type].mute = mute; + + for (int i = 0; i != NUM_CHANNELS; ++i) { + if (_channels[i] && _channels[i]->getType() == type) + _channels[i]->notifyGlobalVolChange(); + } +} + +bool MixerImpl::isSoundTypeMuted(SoundType type) const { + assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings)); + return _soundTypeSettings[type].mute; +} + void MixerImpl::setChannelVolume(SoundHandle handle, byte volume) { Common::StackLock lock(_mutex); @@ -417,7 +428,7 @@ bool MixerImpl::hasActiveChannelOfType(SoundType type) { } void MixerImpl::setVolumeForSoundType(SoundType type, int volume) { - assert(0 <= type && type < ARRAYSIZE(_volumeForSoundType)); + assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings)); // Check range if (volume > kMaxMixerVolume) @@ -429,7 +440,7 @@ void MixerImpl::setVolumeForSoundType(SoundType type, int volume) { // scaling? See also Player_V2::setMasterVolume Common::StackLock lock(_mutex); - _volumeForSoundType[type] = volume; + _soundTypeSettings[type].volume = volume; for (int i = 0; i != NUM_CHANNELS; ++i) { if (_channels[i] && _channels[i]->getType() == type) @@ -438,9 +449,9 @@ void MixerImpl::setVolumeForSoundType(SoundType type, int volume) { } int MixerImpl::getVolumeForSoundType(SoundType type) const { - assert(0 <= type && type < ARRAYSIZE(_volumeForSoundType)); + assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings)); - return _volumeForSoundType[type]; + return _soundTypeSettings[type].volume; } @@ -486,17 +497,21 @@ void Channel::updateChannelVolumes() { // volume is in the range 0 - kMaxMixerVolume. // Hence, the vol_l/vol_r values will be in that range, too - int vol = _mixer->getVolumeForSoundType(_type) * _volume; + if (!_mixer->isSoundTypeMuted(_type)) { + int vol = _mixer->getVolumeForSoundType(_type) * _volume; - if (_balance == 0) { - _volL = vol / Mixer::kMaxChannelVolume; - _volR = vol / Mixer::kMaxChannelVolume; - } else if (_balance < 0) { - _volL = vol / Mixer::kMaxChannelVolume; - _volR = ((127 + _balance) * vol) / (Mixer::kMaxChannelVolume * 127); + if (_balance == 0) { + _volL = vol / Mixer::kMaxChannelVolume; + _volR = vol / Mixer::kMaxChannelVolume; + } else if (_balance < 0) { + _volL = vol / Mixer::kMaxChannelVolume; + _volR = ((127 + _balance) * vol) / (Mixer::kMaxChannelVolume * 127); + } else { + _volL = ((127 - _balance) * vol) / (Mixer::kMaxChannelVolume * 127); + _volR = vol / Mixer::kMaxChannelVolume; + } } else { - _volL = ((127 - _balance) * vol) / (Mixer::kMaxChannelVolume * 127); - _volR = vol / Mixer::kMaxChannelVolume; + _volL = _volR = 0; } } diff --git a/audio/mixer.h b/audio/mixer.h index a048124ca37..5802abdd6b8 100644 --- a/audio/mixer.h +++ b/audio/mixer.h @@ -27,20 +27,13 @@ #define SOUND_MIXER_H #include "common/types.h" -#include "common/mutex.h" #include "common/noncopyable.h" -#include "audio/timestamp.h" - -class OSystem; - - namespace Audio { class AudioStream; class Channel; -class Mixer; -class MixerImpl; +class Timestamp; /** * A SoundHandle instances corresponds to a specific sound @@ -197,6 +190,20 @@ public: virtual bool isSoundHandleActive(SoundHandle handle) = 0; + /** + * Set the mute state for a given sound type. + * + * @param type the sound type + * @param mute Whether to mute (= true) or not (= false). + */ + virtual void muteSoundType(SoundType type, bool mute) = 0; + + /** + * Query the mute state for a given sound type. + * + * @param type the sound type + */ + virtual bool isSoundTypeMuted(SoundType type) const = 0; /** * Set the channel volume for the given handle. diff --git a/audio/mixer_intern.h b/audio/mixer_intern.h index eb6f4052146..9c1f4620640 100644 --- a/audio/mixer_intern.h +++ b/audio/mixer_intern.h @@ -64,7 +64,14 @@ private: bool _mixerReady; uint32 _handleSeed; - int _volumeForSoundType[4]; + struct SoundTypeSettings { + SoundTypeSettings() : mute(false), volume(kMaxMixerVolume) {} + + bool mute; + int volume; + }; + + SoundTypeSettings _soundTypeSettings[4]; Channel *_channels[NUM_CHANNELS]; @@ -97,6 +104,9 @@ public: virtual bool isSoundHandleActive(SoundHandle handle); + virtual void muteSoundType(SoundType type, bool mute); + virtual bool isSoundTypeMuted(SoundType type) const; + virtual void setChannelVolume(SoundHandle handle, byte volume); virtual void setChannelBalance(SoundHandle handle, int8 balance); diff --git a/audio/mpu401.h b/audio/mpu401.h index 07e2817381e..5f1a5108ac6 100644 --- a/audio/mpu401.h +++ b/audio/mpu401.h @@ -34,8 +34,6 @@ // //////////////////////////////////////// -class MidiDriver_MPU401; - class MidiChannel_MPU401 : public MidiChannel { private: diff --git a/audio/musicplugin.h b/audio/musicplugin.h index da0e0ff816f..53a2ae426d2 100644 --- a/audio/musicplugin.h +++ b/audio/musicplugin.h @@ -29,6 +29,10 @@ #include "audio/mididrv.h" #include "common/list.h" +namespace Common { +class Error; +} + class MusicPluginObject; /** diff --git a/audio/null.cpp b/audio/null.cpp index 152f5da03e9..2066a6d048c 100644 --- a/audio/null.cpp +++ b/audio/null.cpp @@ -22,6 +22,7 @@ * $Id$ */ +#include "common/error.h" #include "audio/null.h" Common::Error NullMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const { diff --git a/audio/rate.cpp b/audio/rate.cpp index 1fcf0ade2e0..fd52503b8c6 100644 --- a/audio/rate.cpp +++ b/audio/rate.cpp @@ -35,6 +35,7 @@ #include "audio/rate.h" #include "audio/mixer.h" #include "common/frac.h" +#include "common/textconsole.h" #include "common/util.h" namespace Audio { diff --git a/audio/rate.h b/audio/rate.h index fb231e4c4a0..af37994d022 100644 --- a/audio/rate.h +++ b/audio/rate.h @@ -27,13 +27,11 @@ #define SOUND_RATE_H #include "common/scummsys.h" -#include "engines/engine.h" - -class AudioStream; - namespace Audio { +class AudioStream; + typedef int16 st_sample_t; typedef uint16 st_volume_t; typedef uint32 st_size_t; diff --git a/audio/rate_arm.cpp b/audio/rate_arm.cpp index 43172f64c83..1eb55d0dc37 100644 --- a/audio/rate_arm.cpp +++ b/audio/rate_arm.cpp @@ -48,6 +48,7 @@ #include "audio/rate.h" #include "audio/mixer.h" #include "common/util.h" +#include "common/textconsole.h" //#define DEBUG_RATECONV @@ -129,13 +130,11 @@ SimpleRateConverter::SimpleRateConverter(st_rate_t inrate sr.inLen = 0; } -extern "C" { #ifndef IPHONE #define ARM_SimpleRate_M _ARM_SimpleRate_M #define ARM_SimpleRate_S _ARM_SimpleRate_S #define ARM_SimpleRate_R _ARM_SimpleRate_R #endif -} extern "C" st_sample_t *ARM_SimpleRate_M( AudioStream &input, diff --git a/audio/softsynth/adlib.cpp b/audio/softsynth/adlib.cpp index 9e863471f00..0b5215e5d68 100644 --- a/audio/softsynth/adlib.cpp +++ b/audio/softsynth/adlib.cpp @@ -24,6 +24,11 @@ #include "audio/softsynth/emumidi.h" #include "common/debug.h" +#include "common/error.h" +#include "common/scummsys.h" +#include "common/system.h" +#include "common/textconsole.h" +#include "common/types.h" #include "common/util.h" #include "audio/fmopl.h" #include "audio/musicplugin.h" diff --git a/audio/softsynth/fluidsynth.cpp b/audio/softsynth/fluidsynth.cpp index f6f66ce5e86..a4877a4ec1b 100644 --- a/audio/softsynth/fluidsynth.cpp +++ b/audio/softsynth/fluidsynth.cpp @@ -27,6 +27,9 @@ #ifdef USE_FLUIDSYNTH #include "common/config-manager.h" +#include "common/error.h" +#include "common/system.h" +#include "common/textconsole.h" #include "audio/musicplugin.h" #include "audio/mpu401.h" #include "audio/softsynth/emumidi.h" diff --git a/audio/softsynth/mt32.cpp b/audio/softsynth/mt32.cpp index 279ec86e2ef..a9ea3665d72 100644 --- a/audio/softsynth/mt32.cpp +++ b/audio/softsynth/mt32.cpp @@ -34,15 +34,19 @@ #include "common/config-manager.h" #include "common/debug.h" +#include "common/error.h" #include "common/events.h" #include "common/file.h" #include "common/system.h" #include "common/util.h" #include "common/archive.h" +#include "common/textconsole.h" #include "common/translation.h" #include "graphics/fontman.h" #include "graphics/surface.h" +#include "graphics/pixelformat.h" +#include "graphics/font.h" class MidiChannel_MT32 : public MidiChannel_MPU401 { void effectLevel(byte value) { } diff --git a/audio/softsynth/mt32/part.cpp b/audio/softsynth/mt32/part.cpp index eb087f7ea03..9f9269cba5f 100644 --- a/audio/softsynth/mt32/part.cpp +++ b/audio/softsynth/mt32/part.cpp @@ -100,7 +100,7 @@ void RhythmPart::setBend(unsigned int midiBend) { } void Part::setBend(unsigned int midiBend) { - // FIXME:KG: Slightly unbalanced increments, but I wanted min -1.0, centre 0.0 and max 1.0 + // FIXME:KG: Slightly unbalanced increments, but I wanted min -1.0, center 0.0 and max 1.0 if (midiBend <= 0x2000) { bend = ((signed int)midiBend - 0x2000) / (float)0x2000; } else { @@ -413,7 +413,7 @@ void RhythmPart::setPan(unsigned int midiPan) } void Part::setPan(unsigned int midiPan) { - // FIXME:KG: Tweaked this a bit so that we have a left 100%, centre and right 100% + // FIXME:KG: Tweaked this a bit so that we have a left 100%, center and right 100% // (But this makes the range somewhat skewed) // Check against the real thing // NOTE: Panning is inverted compared to GM. diff --git a/audio/softsynth/mt32/part.h b/audio/softsynth/mt32/part.h index 54c49996531..967298258cb 100644 --- a/audio/softsynth/mt32/part.h +++ b/audio/softsynth/mt32/part.h @@ -24,7 +24,6 @@ namespace MT32Emu { -class PartialManager; class Synth; class Part { diff --git a/audio/softsynth/mt32/synth.cpp b/audio/softsynth/mt32/synth.cpp index 16460795a54..4d1c612942e 100644 --- a/audio/softsynth/mt32/synth.cpp +++ b/audio/softsynth/mt32/synth.cpp @@ -25,8 +25,6 @@ #include "mt32emu.h" -#include "common/str.h" - #if defined(MACOSX) || defined(SOLARIS) || defined(__MINGW32__) // Older versions of Mac OS X didn't supply a powf function, so using it // will cause a binary incompatibility when trying to run a binary built diff --git a/audio/softsynth/mt32/synth.h b/audio/softsynth/mt32/synth.h index 3fc303d3227..edda4462879 100644 --- a/audio/softsynth/mt32/synth.h +++ b/audio/softsynth/mt32/synth.h @@ -29,7 +29,6 @@ class revmodel; namespace MT32Emu { class File; -class TableInitialiser; class Partial; class PartialManager; class Part; diff --git a/audio/softsynth/opl/dosbox.cpp b/audio/softsynth/opl/dosbox.cpp index 29993ce3d8a..7a494d70ec1 100644 --- a/audio/softsynth/opl/dosbox.cpp +++ b/audio/softsynth/opl/dosbox.cpp @@ -36,6 +36,7 @@ #include "common/system.h" #include "common/scummsys.h" +#include "common/util.h" #include #include diff --git a/audio/softsynth/opl/mame.cpp b/audio/softsynth/opl/mame.cpp index b4bbcb5ab39..5d790f924f1 100644 --- a/audio/softsynth/opl/mame.cpp +++ b/audio/softsynth/opl/mame.cpp @@ -33,6 +33,9 @@ #include "mame.h" +#include "common/textconsole.h" +#include "common/util.h" + #if defined (_WIN32_WCE) || defined (__SYMBIAN32__) || defined(__GP32__) || defined(GP2X) || defined (__MAEMO__) || defined(__DS__) || defined (__MINT__) || defined(__N64__) #include "common/config-manager.h" #endif diff --git a/audio/softsynth/opl/mame.h b/audio/softsynth/opl/mame.h index 58ef5f18dce..4314aa6dba6 100644 --- a/audio/softsynth/opl/mame.h +++ b/audio/softsynth/opl/mame.h @@ -30,7 +30,6 @@ #define SOUND_SOFTSYNTH_OPL_MAME_H #include "common/scummsys.h" -#include "common/util.h" #include "common/random.h" #include "audio/fmopl.h" diff --git a/audio/softsynth/pcspk.h b/audio/softsynth/pcspk.h index c0d85bbceb2..8f01fa852ba 100644 --- a/audio/softsynth/pcspk.h +++ b/audio/softsynth/pcspk.h @@ -26,7 +26,6 @@ #define SOUND_SOFTSYNTH_PCSPK_H #include "audio/audiostream.h" -#include "audio/mixer.h" #include "common/mutex.h" namespace Audio { diff --git a/audio/softsynth/sid.cpp b/audio/softsynth/sid.cpp index 241766fa0a9..de8f0eeac5f 100644 --- a/audio/softsynth/sid.cpp +++ b/audio/softsynth/sid.cpp @@ -32,7 +32,6 @@ #include "sid.h" #include "audio/null.h" -#include namespace Resid { diff --git a/audio/softsynth/ym2612.cpp b/audio/softsynth/ym2612.cpp index 6b3c2aab732..162c92f05a4 100644 --- a/audio/softsynth/ym2612.cpp +++ b/audio/softsynth/ym2612.cpp @@ -27,7 +27,11 @@ #include "audio/softsynth/ym2612.h" #include "common/util.h" #include "audio/musicplugin.h" +#include "common/error.h" +#include "common/system.h" +#include "common/textconsole.h" #include "common/translation.h" +#include "common/types.h" //////////////////////////////////////// // diff --git a/backends/events/default/default-events.h b/backends/events/default/default-events.h index 06db1dc0271..73dc60695b5 100644 --- a/backends/events/default/default-events.h +++ b/backends/events/default/default-events.h @@ -31,10 +31,10 @@ namespace Common { #ifdef ENABLE_KEYMAPPER - class Keymapper; +class Keymapper; #endif #ifdef ENABLE_VKEYBD - class VirtualKeyboard; +class VirtualKeyboard; #endif } diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index b01ed32a554..12441b907e7 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -31,6 +31,7 @@ #include "backends/platform/sdl/sdl.h" #include "backends/graphics/graphics.h" #include "common/config-manager.h" +#include "common/textconsole.h" // FIXME move joystick defines out and replace with confile file options // we should really allow users to map any key to a joystick button diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h index 36756a1f607..3995e894655 100644 --- a/backends/graphics/sdl/sdl-graphics.h +++ b/backends/graphics/sdl/sdl-graphics.h @@ -31,6 +31,7 @@ #endif #include "backends/graphics/graphics.h" +#include "graphics/pixelformat.h" #include "graphics/scaler.h" #include "common/events.h" #include "common/system.h" diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 7c608a53fce..b6d9dbf0423 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -31,6 +31,7 @@ #ifdef ENABLE_KEYMAPPER #include "backends/keymapper/types.h" +#include "common/textconsole.h" namespace Common { diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 2f913055fc7..8edc26a5267 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -26,6 +26,7 @@ #ifdef ENABLE_KEYMAPPER +#include "common/system.h" #include "gui/gui-manager.h" #include "gui/widgets/popup.h" #include "gui/widgets/scrollbar.h" diff --git a/backends/keymapper/remap-dialog.h b/backends/keymapper/remap-dialog.h index 2c0e79a79dd..5721d368a49 100644 --- a/backends/keymapper/remap-dialog.h +++ b/backends/keymapper/remap-dialog.h @@ -33,8 +33,10 @@ #include "gui/dialog.h" namespace GUI { - class PopupWidget; - class ScrollBarWidget; +class ButtonWidget; +class PopUpWidget; +class ScrollBarWidget; +class StaticTextWidget; } namespace Common { diff --git a/backends/midi/alsa.cpp b/backends/midi/alsa.cpp index 4b90aabdc86..5b0d25f4ea6 100644 --- a/backends/midi/alsa.cpp +++ b/backends/midi/alsa.cpp @@ -30,6 +30,8 @@ #if defined(USE_ALSA) #include "common/config-manager.h" +#include "common/error.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/musicplugin.h" #include "audio/mpu401.h" diff --git a/backends/midi/camd.cpp b/backends/midi/camd.cpp index 2f3c2516162..2f4407eea49 100644 --- a/backends/midi/camd.cpp +++ b/backends/midi/camd.cpp @@ -29,6 +29,8 @@ #if defined(__amigaos4__) +#include "common/textconsole.h" +#include "common/error.h" #include "common/endian.h" #include "common/util.h" #include "audio/musicplugin.h" @@ -135,8 +137,8 @@ void MidiDriver_CAMD::sysEx(const byte *msg, uint16 length) { char *MidiDriver_CAMD::getDevice() { char *retname = NULL; - APTR key; - if (key = _ICamd->LockCAMD(CD_Linkages)) { + APTR key = _ICamd->LockCAMD(CD_Linkages); + if (key != NULL) { struct MidiCluster *cluster = _ICamd->NextCluster(NULL); while (cluster && !retname) { diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 0158cc4a1d3..52d32cb5e3f 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -41,6 +41,8 @@ #include "common/config-manager.h" +#include "common/error.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/musicplugin.h" #include "audio/mpu401.h" diff --git a/backends/midi/coremidi.cpp b/backends/midi/coremidi.cpp index 4f992d7d62c..c9e51de05ca 100644 --- a/backends/midi/coremidi.cpp +++ b/backends/midi/coremidi.cpp @@ -30,6 +30,8 @@ #ifdef MACOSX #include "common/config-manager.h" +#include "common/error.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/musicplugin.h" #include "audio/mpu401.h" diff --git a/backends/midi/seq.cpp b/backends/midi/seq.cpp index fe2b3a6cccd..47e6fba9941 100644 --- a/backends/midi/seq.cpp +++ b/backends/midi/seq.cpp @@ -35,6 +35,8 @@ #if defined(USE_SEQ_MIDI) +#include "common/error.h" +#include "common/textconsole.h" #include "common/util.h" #include "audio/musicplugin.h" #include "audio/mpu401.h" diff --git a/backends/midi/timidity.cpp b/backends/midi/timidity.cpp index 37be116890a..97e41ea5db9 100644 --- a/backends/midi/timidity.cpp +++ b/backends/midi/timidity.cpp @@ -41,13 +41,13 @@ #if defined(USE_TIMIDITY) -#include "common/util.h" #include "common/endian.h" +#include "common/error.h" #include "common/str.h" +#include "common/textconsole.h" #include "audio/musicplugin.h" #include "audio/mpu401.h" -#include #include #include #include diff --git a/backends/midi/windows.cpp b/backends/midi/windows.cpp index aad7f48d94d..292bbea79e0 100644 --- a/backends/midi/windows.cpp +++ b/backends/midi/windows.cpp @@ -38,6 +38,8 @@ #include "audio/mpu401.h" #include "common/config-manager.h" #include "common/translation.h" +#include "common/textconsole.h" +#include "common/error.h" #include diff --git a/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp b/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp index 6b0074862e3..93c779ea5f1 100644 --- a/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp +++ b/backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp @@ -23,7 +23,7 @@ * */ -#if defined(MACOSX) || defined(GP2X) +#if defined(MACOSX) || defined(GP2X) || defined(CAANOO) || defined(GP2XWIZ) #include "backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h" diff --git a/backends/mixer/sdl/sdl-mixer.cpp b/backends/mixer/sdl/sdl-mixer.cpp index fa2bf3e2324..90629954c58 100644 --- a/backends/mixer/sdl/sdl-mixer.cpp +++ b/backends/mixer/sdl/sdl-mixer.cpp @@ -26,8 +26,10 @@ #if defined(SDL_BACKEND) #include "backends/mixer/sdl/sdl-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 diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index 63b3ce7ccfc..450c7017076 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -26,12 +26,14 @@ #include "backends/modular-backend.h" #include "backends/fs/fs-factory.h" -#include "backends/events/default/default-events.h" -#include "backends/audiocd/default/default-audiocd.h" -#include "backends/mutex/mutex.h" +#include "backends/audiocd/audiocd.h" #include "backends/graphics/graphics.h" +#include "backends/mutex/mutex.h" +#include "audio/mixer.h" +#include "common/events.h" #include "gui/message.h" +#include "graphics/pixelformat.h" ModularBackend::ModularBackend() : diff --git a/backends/module.mk b/backends/module.mk index 551a595d38a..561c17fdebb 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -43,11 +43,6 @@ MODULE_OBJS := \ vkeybd/virtual-keyboard-gui.o \ vkeybd/virtual-keyboard-parser.o -ifeq ($(BACKEND),dc) -MODULE_OBJS += \ - plugins/dc/dc-provider.o -endif - ifeq ($(BACKEND),ds) MODULE_OBJS += \ fs/ds/ds-fs-factory.o \ diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index ebab9a11059..acb93663dfe 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -32,6 +32,7 @@ #include "backends/platform/sdl/sdl.h" #include "common/config-manager.h" #include "common/EventRecorder.h" +#include "common/textconsole.h" #include "backends/saves/default/default-saves.h" #include "backends/audiocd/sdl/sdl-audiocd.h" @@ -333,7 +334,11 @@ void OSystem_SDL::setupIcon() { unsigned int rgba[256]; unsigned int *icon; - sscanf(residual_icon[0], "%d %d %d %d", &w, &h, &ncols, &nbytes); + if (sscanf(residual_icon[0], "%d %d %d %d", &w, &h, &ncols, &nbytes) != 4) { + warning("Wrong format of residual_icon[0] (%s)", scummvm_icon[0]); + + return; + } if ((w > 512) || (h > 512) || (ncols > 255) || (nbytes > 1)) { warning("Could not load the built-in icon (%d %d %d %d)", w, h, ncols, nbytes); return; @@ -348,13 +353,17 @@ void OSystem_SDL::setupIcon() { unsigned char code; char color[32]; unsigned int col; - sscanf(residual_icon[1 + i], "%c c %s", &code, color); + if (sscanf(residual_icon[1 + i], "%c c %s", &code, color) != 2) { + warning("Wrong format of residual_icon[%d] (%s)", 1 + i, residual_icon[1 + i]); + } if (!strcmp(color, "None")) col = 0x00000000; else if (!strcmp(color, "black")) col = 0xFF000000; else if (color[0] == '#') { - sscanf(color + 1, "%06x", &col); + if (sscanf(color + 1, "%06x", &col) != 1) { + warning("Wrong format of color (%s)", color + 1); + } col |= 0xFF000000; } else { warning("Could not load the built-in icon (%d %s - %s) ", code, color, residual_icon[1 + i]); diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 0deb0a37b8d..45dea72ee79 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -27,6 +27,8 @@ #define FORBIDDEN_SYMBOL_ALLOW_ALL #include "common/scummsys.h" +#include "common/error.h" +#include "common/textconsole.h" #ifdef WIN32 diff --git a/backends/plugins/dynamic-plugin.h b/backends/plugins/dynamic-plugin.h index 32d411656c4..775e887105f 100644 --- a/backends/plugins/dynamic-plugin.h +++ b/backends/plugins/dynamic-plugin.h @@ -27,6 +27,7 @@ #define BACKENDS_PLUGINS_DYNAMICPLUGIN_H #include "base/plugins.h" +#include "common/textconsole.h" class DynamicPlugin : public Plugin { diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp index 0e16f165b38..75e10cf810a 100644 --- a/backends/saves/default/default-saves.cpp +++ b/backends/saves/default/default-saves.cpp @@ -60,7 +60,7 @@ void DefaultSaveFileManager::checkPath(const Common::FSNode &dir) { Common::StringArray DefaultSaveFileManager::listSavefiles(const Common::String &pattern) { Common::String savePathName = getSavePath(); checkPath(Common::FSNode(savePathName)); - if (getError() != Common::kNoError) + if (getError().getCode() != Common::kNoError) return Common::StringArray(); // recreate FSNode since checkPath may have changed/created the directory @@ -84,7 +84,7 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const Common::String // Ensure that the savepath is valid. If not, generate an appropriate error. Common::String savePathName = getSavePath(); checkPath(Common::FSNode(savePathName)); - if (getError() != Common::kNoError) + if (getError().getCode() != Common::kNoError) return 0; // recreate FSNode since checkPath may have changed/created the directory @@ -104,7 +104,7 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String // Ensure that the savepath is valid. If not, generate an appropriate error. Common::String savePathName = getSavePath(); checkPath(Common::FSNode(savePathName)); - if (getError() != Common::kNoError) + if (getError().getCode() != Common::kNoError) return 0; // recreate FSNode since checkPath may have changed/created the directory @@ -121,7 +121,7 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) { Common::String savePathName = getSavePath(); checkPath(Common::FSNode(savePathName)); - if (getError() != Common::kNoError) + if (getError().getCode() != Common::kNoError) return false; // recreate FSNode since checkPath may have changed/created the directory diff --git a/backends/saves/posix/posix-saves.cpp b/backends/saves/posix/posix-saves.cpp index 01bcce3c7f8..11799214bad 100644 --- a/backends/saves/posix/posix-saves.cpp +++ b/backends/saves/posix/posix-saves.cpp @@ -31,6 +31,7 @@ #include "common/config-manager.h" #include "common/savefile.h" +#include "common/textconsole.h" #include #include diff --git a/backends/saves/savefile.cpp b/backends/saves/savefile.cpp index 7b7d6b0c0c1..98881460497 100644 --- a/backends/saves/savefile.cpp +++ b/backends/saves/savefile.cpp @@ -25,9 +25,7 @@ #include "common/util.h" #include "common/savefile.h" - -#include -#include +#include "common/str.h" namespace Common { diff --git a/backends/timer/default/default-timer.h b/backends/timer/default/default-timer.h index a4c7385ef9a..9a353f58c39 100644 --- a/backends/timer/default/default-timer.h +++ b/backends/timer/default/default-timer.h @@ -28,8 +28,6 @@ #include "common/timer.h" #include "common/mutex.h" -class OSystem; - struct TimerSlot; class DefaultTimerManager : public Common::TimerManager { diff --git a/backends/timer/sdl/sdl-timer.cpp b/backends/timer/sdl/sdl-timer.cpp index 0a4cd428dee..647ddba2d3b 100644 --- a/backends/timer/sdl/sdl-timer.cpp +++ b/backends/timer/sdl/sdl-timer.cpp @@ -30,6 +30,8 @@ #include "backends/timer/sdl/sdl-timer.h" +#include "common/textconsole.h" + static Uint32 timer_handler(Uint32 interval, void *param) { ((DefaultTimerManager *)param)->handler(); return interval; diff --git a/backends/vkeybd/image-map.cpp b/backends/vkeybd/image-map.cpp index b0a77b52207..f4b4541d7e8 100644 --- a/backends/vkeybd/image-map.cpp +++ b/backends/vkeybd/image-map.cpp @@ -27,6 +27,8 @@ #ifdef ENABLE_VKEYBD +#include "common/textconsole.h" + #include "backends/vkeybd/image-map.h" #include "backends/vkeybd/polygon.h" diff --git a/backends/vkeybd/packs/vkeybd_default/vkeybd_default.xml b/backends/vkeybd/packs/vkeybd_default/vkeybd_default.xml index 86f39d3d4db..85a27c71ca0 100644 --- a/backends/vkeybd/packs/vkeybd_default/vkeybd_default.xml +++ b/backends/vkeybd/packs/vkeybd_default/vkeybd_default.xml @@ -1,5 +1,5 @@ - + diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp index c5ab39e46b6..050ab5c5a2d 100644 --- a/backends/vkeybd/virtual-keyboard-gui.cpp +++ b/backends/vkeybd/virtual-keyboard-gui.cpp @@ -203,7 +203,7 @@ void VirtualKeyboardGUI::moveToDefaultPosition() case VirtualKeyboard::kAlignLeft: x = 0; break; - case VirtualKeyboard::kAlignCentre: + case VirtualKeyboard::kAlignCenter: x = (_screenW - kbdW) / 2; break; case VirtualKeyboard::kAlignRight: diff --git a/backends/vkeybd/virtual-keyboard-parser.cpp b/backends/vkeybd/virtual-keyboard-parser.cpp index a81258b25fe..3ebdfdc6534 100644 --- a/backends/vkeybd/virtual-keyboard-parser.cpp +++ b/backends/vkeybd/virtual-keyboard-parser.cpp @@ -84,7 +84,7 @@ bool VirtualKeyboardParser::parserCallback_keyboard(ParserNode *node) { if (h.equalsIgnoreCase("left")) _keyboard->_hAlignment = VirtualKeyboard::kAlignLeft; else if (h.equalsIgnoreCase("centre") || h.equalsIgnoreCase("center")) - _keyboard->_hAlignment = VirtualKeyboard::kAlignCentre; + _keyboard->_hAlignment = VirtualKeyboard::kAlignCenter; else if (h.equalsIgnoreCase("right")) _keyboard->_hAlignment = VirtualKeyboard::kAlignRight; } diff --git a/backends/vkeybd/virtual-keyboard-parser.h b/backends/vkeybd/virtual-keyboard-parser.h index 9723744dc4d..1327008a80e 100644 --- a/backends/vkeybd/virtual-keyboard-parser.h +++ b/backends/vkeybd/virtual-keyboard-parser.h @@ -51,7 +51,7 @@ keyboard layouts for different screen resolutions. ** Example keyboard pack description file ** ******************************************** - + diff --git a/backends/vkeybd/virtual-keyboard.cpp b/backends/vkeybd/virtual-keyboard.cpp index 31fde8c0fae..2971c8d528f 100644 --- a/backends/vkeybd/virtual-keyboard.cpp +++ b/backends/vkeybd/virtual-keyboard.cpp @@ -33,6 +33,7 @@ #include "backends/vkeybd/virtual-keyboard-parser.h" #include "backends/vkeybd/keycode-descriptions.h" #include "common/config-manager.h" +#include "common/textconsole.h" #include "common/unzip.h" #define KEY_START_CHAR ('[') @@ -71,7 +72,7 @@ void VirtualKeyboard::reset() { deleteEvents(); _modes.clear(); _initialMode = _currentMode = 0; - _hAlignment = kAlignCentre; + _hAlignment = kAlignCenter; _vAlignment = kAlignBottom; _keyQueue.clear(); _loaded = false; diff --git a/backends/vkeybd/virtual-keyboard.h b/backends/vkeybd/virtual-keyboard.h index db94cbe4765..169cd678334 100644 --- a/backends/vkeybd/virtual-keyboard.h +++ b/backends/vkeybd/virtual-keyboard.h @@ -134,7 +134,7 @@ protected: enum HorizontalAlignment { kAlignLeft, - kAlignCentre, + kAlignCenter, kAlignRight }; diff --git a/base/commandLine.cpp b/base/commandLine.cpp index e7dbbd62615..b4566d2cea2 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -30,6 +30,7 @@ #include "common/config-manager.h" #include "common/system.h" +#include "common/textconsole.h" #include "common/fs.h" #include "gui/ThemeEngine.h" @@ -59,9 +60,12 @@ static const char HELP_STRING[] = " -h, --help Display a brief help text and exit\n" " -z, --list-games Display list of supported games and exit\n" " -t, --list-targets Display list of configured targets and exit\n" + " --list-saves=TARGET Display a list of savegames for the game (TARGET) specified\n" "\n" " -c, --config=CONFIG Use alternate configuration file\n" " -p, --path=PATH Path to where the game is installed\n" + " -f, --fullscreen Force full-screen mode\n" + " -F, --no-fullscreen Force windowed mode\n" " --gui-theme=THEME Select GUI theme\n" " --themepath=PATH Path to where GUI themes are stored\n" " --list-themes Display list of all usable GUI themes\n" @@ -147,6 +151,7 @@ void registerDefaults() { ConfMan.registerDefault("dimuse_tempo", 10); // Miscellaneous + ConfMan.registerDefault("joystick_num", -1); ConfMan.registerDefault("confirm_exit", false); ConfMan.registerDefault("disable_sdl_parachute", false); @@ -193,7 +198,7 @@ void registerDefaults() { #define DO_OPTION_INT(shortCmd, longCmd) \ DO_OPTION(shortCmd, longCmd) \ char *endptr = 0; \ - int intValue; intValue = (int)strtol(option, &endptr, 0); \ + strtol(option, &endptr, 0); \ if (endptr == NULL || *endptr != 0) usage("--%s: Invalid number '%s'", longCmd, option); // Use this for boolean options; this distinguishes between "-x" and "-X", @@ -285,6 +290,13 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha END_OPTION #endif + DO_LONG_OPTION("list-saves") + // FIXME: Need to document this. + // TODO: Make the argument optional. If no argument is given, list all savegames + // for all configured targets. + return "list-saves"; + END_OPTION + DO_OPTION('c', "config") END_OPTION @@ -300,6 +312,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha DO_LONG_OPTION_INT("output-rate") END_OPTION + DO_OPTION_BOOL('f', "fullscreen") + END_OPTION + DO_LONG_OPTION("opl-driver") END_OPTION @@ -511,6 +526,67 @@ static void listTargets() { printf("%s\n", i->c_str()); } +/** List all saves states for the given target. */ +static Common::Error listSaves(const char *target) { + Common::Error result = Common::kNoError; + + // FIXME HACK + g_system->initBackend(); + + // Grab the "target" domain, if any + const Common::ConfigManager::Domain *domain = ConfMan.getDomain(target); + + // Set up the game domain as newly active domain, so + // target specific savepath will be checked + Common::String oldDomain = ConfMan.getActiveDomainName(); + ConfMan.setActiveDomain(target); + + // Grab the gameid from the domain resp. use the target as gameid + Common::String gameid; + if (domain) + gameid = domain->getVal("gameid"); + if (gameid.empty()) + gameid = target; + gameid.toLowercase(); // Normalize it to lower case + + // Find the plugin that will handle the specified gameid + const EnginePlugin *plugin = 0; + GameDescriptor game = EngineMan.findGame(gameid, &plugin); + + if (!plugin) { + return Common::Error(Common::kEnginePluginNotFound, + Common::String::format("target '%s', gameid '%s", target, gameid.c_str())); + } + + if (!(*plugin)->hasFeature(MetaEngine::kSupportsListSaves)) { + // TODO: Include more info about the target (desc, engine name, ...) ??? + return Common::Error(Common::kEnginePluginNotSupportSaves, + Common::String::format("target '%s', gameid '%s", target, gameid.c_str())); + } else { + // Query the plugin for a list of savegames + SaveStateList saveList = (*plugin)->listSaves(target); + + if (saveList.size() > 0) { + // TODO: Include more info about the target (desc, engine name, ...) ??? + printf("Save states for target '%s' (gameid '%s'):\n", target, gameid.c_str()); + printf(" Slot Description \n" + " ---- ------------------------------------------------------\n"); + + for (SaveStateList::const_iterator x = saveList.begin(); x != saveList.end(); ++x) { + printf(" %-4s %s\n", x->save_slot().c_str(), x->description().c_str()); + // TODO: Could also iterate over the full hashmap, printing all key-value pairs + } + } else { + printf("There are no save states for target '%s' (gameid '%s'):\n", target, gameid.c_str()); + } + } + + // Revert to the old active domain + ConfMan.setActiveDomain(oldDomain); + + return result; +} + /** Lists all usable themes */ static void listThemes() { typedef Common::List ThList; @@ -560,7 +636,7 @@ static void runDetectorTest() { bool gameidDiffers = false; GameList::iterator x; for (x = candidates.begin(); x != candidates.end(); ++x) { - gameidDiffers |= (strcasecmp(gameid.c_str(), x->gameid().c_str()) != 0); + gameidDiffers |= (scumm_stricmp(gameid.c_str(), x->gameid().c_str()) != 0); } if (candidates.empty()) { @@ -734,6 +810,8 @@ Common::Error processSettings(Common::String &command, Common::StringMap &settin } else if (command == "list-games") { listGames(); return Common::kNoError; + } else if (command == "list-saves") { + return listSaves(settings["list-saves"].c_str()); } else if (command == "list-themes") { listThemes(); return Common::kNoError; diff --git a/base/commandLine.h b/base/commandLine.h index cf5df1e694f..6205c914e0f 100644 --- a/base/commandLine.h +++ b/base/commandLine.h @@ -23,12 +23,15 @@ * */ -#ifndef BASE_OPTIONS_H -#define BASE_OPTIONS_H +#ifndef COMMON_COMMAND_LINE_H +#define COMMON_COMMAND_LINE_H -#include "common/str.h" -#include "common/error.h" -#include "common/config-manager.h" +#include "common/hash-str.h" + +namespace Common { +class Error; +class String; +} namespace Base { diff --git a/base/main.cpp b/base/main.cpp index bbb75853bba..434a3b2df2c 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -43,14 +43,13 @@ #include "common/debug-channels.h" /* for debug manager */ #include "common/events.h" #include "common/EventRecorder.h" -#include "common/file.h" #include "common/fs.h" #include "common/system.h" +#include "common/textconsole.h" #include "common/tokenizer.h" #include "common/translation.h" #include "gui/gui-manager.h" -#include "gui/message.h" #include "gui/error.h" #include "audio/mididrv.h" @@ -111,13 +110,12 @@ static const EnginePlugin *detectPlugin() { if (plugin == 0) { printf("failed\n"); warning("%s is an invalid gameid. Use the --list-games option to list supported gameid", gameid.c_str()); - return 0; } else { printf("%s\n", plugin->getName()); - } - // FIXME: Do we really need this one? - printf(" Starting '%s'\n", game.description().c_str()); + // FIXME: Do we really need this one? + printf(" Starting '%s'\n", game.description().c_str()); + } return plugin; } @@ -131,24 +129,20 @@ static Common::Error runGame(const EnginePlugin *plugin, OSystem &system, const // Verify that the game path refers to an actual directory if (!(dir.exists() && dir.isDirectory())) - err = Common::kInvalidPathError; + err = Common::kPathNotDirectory; // Create the game engine - if (err == Common::kNoError) + if (err.getCode() == Common::kNoError) err = (*plugin)->createInstance(&system, &engine); // Check for errors - if (!engine || err != Common::kNoError) { - - // TODO: An errorDialog for this and engine related errors is displayed already in the scummvm_main function - // Is a separate dialog here still required? - - //GUI::displayErrorDialog("ScummVM could not find any game in the specified directory!"); - const char *errMsg = _(Common::errorToString(err)); + if (!engine || err.getCode() != Common::kNoError) { + // Print a warning; note that scummvm_main will also + // display an error dialog, so we don't have to do this here. warning("%s failed to instantiate engine: %s (target '%s', path '%s')", plugin->getName(), - errMsg, + err.getDesc().c_str(), ConfMan.getActiveDomainName().c_str(), dir.getPath().c_str() ); @@ -344,8 +338,11 @@ extern "C" int residual_main(int argc, const char * const argv[]) { Common::Error res; // TODO: deal with settings that require plugins to be loaded - if ((res = Base::processSettings(command, settings)) != Common::kArgumentNotProcessed) - return res; + res = Base::processSettings(command, settings); + if (res.getCode() != Common::kArgumentNotProcessed) { + warning("%s", res.getDesc().c_str()); + return res.getCode(); + } // Init the backend. Must take place after all config data (including // the command line params) was read. @@ -400,14 +397,14 @@ extern "C" int residual_main(int argc, const char * const argv[]) { #endif // Did an error occur ? - if (result != Common::kNoError) { + if (result.getCode() != Common::kNoError) { // Shows an informative error dialog if starting the selected game failed. GUI::displayErrorDialog(result, _("Error running game:")); } // Quit unless an error occurred, or Return to launcher was requested #ifndef FORCE_RTL - if (result == 0 && !g_system->getEventManager()->shouldRTL()) + if (result.getCode() == Common::kNoError && !g_system->getEventManager()->shouldRTL()) break; #endif // Reset RTL flag in case we want to load another engine diff --git a/base/plugins.h b/base/plugins.h index bd72cd30bd9..24f67306198 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -27,16 +27,10 @@ #define BASE_PLUGINS_H #include "common/array.h" -#include "common/error.h" -#include "common/singleton.h" -#include "common/util.h" +#include "common/fs.h" +#include "common/str.h" //#include "backends/plugins/elf/version.h" -namespace Common { - class FSList; - class FSNode; -} - /** * @page pagePlugins An overview of the ScummVM plugin system diff --git a/common/EventRecorder.cpp b/common/EventRecorder.cpp index 1dedbb50592..d2ad4bc4751 100644 --- a/common/EventRecorder.cpp +++ b/common/EventRecorder.cpp @@ -28,6 +28,7 @@ #include "common/config-manager.h" #include "common/random.h" #include "common/savefile.h" +#include "common/textconsole.h" DECLARE_SINGLETON(Common::EventRecorder); diff --git a/common/archive.cpp b/common/archive.cpp index c65408b56e2..c2c9c8e7026 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -25,8 +25,8 @@ #include "common/archive.h" #include "common/fs.h" -#include "common/util.h" #include "common/system.h" +#include "common/textconsole.h" namespace Common { diff --git a/common/archive.h b/common/archive.h index c12ca79be0c..375136fa15f 100644 --- a/common/archive.h +++ b/common/archive.h @@ -27,7 +27,6 @@ #define COMMON_ARCHIVE_H #include "common/str.h" -#include "common/hash-str.h" #include "common/list.h" #include "common/ptr.h" #include "common/singleton.h" diff --git a/common/bufferedstream.h b/common/bufferedstream.h index dc074422bb7..bb09e77d1d2 100644 --- a/common/bufferedstream.h +++ b/common/bufferedstream.h @@ -27,6 +27,7 @@ #define COMMON_BUFFEREDSTREAM_H #include "common/stream.h" +#include "common/types.h" namespace Common { diff --git a/common/config-file.cpp b/common/config-file.cpp index 09687e2ee74..cd8f0989fc0 100644 --- a/common/config-file.cpp +++ b/common/config-file.cpp @@ -27,7 +27,7 @@ #include "common/file.h" #include "common/savefile.h" #include "common/system.h" -#include "common/util.h" +#include "common/textconsole.h" #define MAXLINELEN 256 @@ -101,11 +101,7 @@ bool ConfigFile::loadFromStream(SeekableReadStream &stream) { // of the 'comment' variable with that entity. The semicolon and // C++-style comments are used for Living Books games in Mohawk. comment += line; -#ifdef _WIN32 - comment += "\r\n"; -#else comment += "\n"; -#endif } else if (line[0] == '(') { // HACK: The following is a hack added by Kirben to support the // "map.ini" used in the HE SCUMM game "SPY Fox in Hold the Mustard". diff --git a/common/config-file.h b/common/config-file.h index 2f7d9cb6501..231162fb3c6 100644 --- a/common/config-file.h +++ b/common/config-file.h @@ -26,13 +26,15 @@ #ifndef COMMON_CONFIG_FILE_H #define COMMON_CONFIG_FILE_H -#include "common/config-manager.h" +#include "common/hash-str.h" #include "common/list.h" #include "common/str.h" -#include "common/stream.h" namespace Common { +class SeekableReadStream; +class WriteStream; + /** * This class allows reading/writing INI style config files. * It is used by the ConfigManager for storage, but can also diff --git a/common/config-manager.cpp b/common/config-manager.cpp index 7b7598959fc..8f25326242c 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -24,10 +24,11 @@ */ #include "common/config-manager.h" +#include "common/debug.h" #include "common/file.h" #include "common/fs.h" -#include "common/util.h" #include "common/system.h" +#include "common/textconsole.h" DECLARE_SINGLETON(Common::ConfigManager); @@ -179,11 +180,7 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) { // of a new domain, or a key-value-pair, we associate the value // of the 'comment' variable with that entity. comment += line; -#ifdef _WIN32 - comment += "\r\n"; -#else comment += "\n"; -#endif } else if (line[0] == '[') { // It's a new domain which begins here. // Determine where the previously accumulated domain goes, if we accumulated anything. diff --git a/common/debug.cpp b/common/debug.cpp index c87d195b764..a8711055fde 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -24,8 +24,8 @@ #include "common/debug.h" #include "common/debug-channels.h" -#include "common/util.h" #include "common/system.h" +#include "common/textconsole.h" #include // For va_list etc. diff --git a/common/endian.h b/common/endian.h index 98d98f43ed1..87e279ac424 100644 --- a/common/endian.h +++ b/common/endian.h @@ -48,7 +48,7 @@ */ // Sanity check -#if !defined(SYSTEM_LITTLE_ENDIAN) && !defined(SYSTEM_BIG_ENDIAN) +#if !defined(SCUMM_LITTLE_ENDIAN) && !defined(SCUMM_BIG_ENDIAN) # error No endianness defined #endif @@ -152,7 +152,7 @@ // Functions for reading/writing native Integers, // this transparently handles the need for alignment -#if !defined(SYSTEM_NEED_ALIGNMENT) +#if !defined(SCUMM_NEED_ALIGNMENT) FORCEINLINE uint16 READ_UINT16(const void *ptr) { return *(const uint16 *)(ptr); @@ -197,7 +197,7 @@ // use software fallback by loading each byte explicitely #else -# if defined(SYSTEM_LITTLE_ENDIAN) +# if defined(SCUMM_LITTLE_ENDIAN) inline uint16 READ_UINT16(const void *ptr) { const uint8 *b = (const uint8 *)ptr; @@ -220,7 +220,7 @@ b[3] = (uint8)(value >> 24); } -# elif defined(SYSTEM_BIG_ENDIAN) +# elif defined(SCUMM_BIG_ENDIAN) inline uint16 READ_UINT16(const void *ptr) { const uint8 *b = (const uint8 *)ptr; @@ -249,7 +249,7 @@ // Map Funtions for reading/writing BE/LE integers depending on native endianess -#if defined(SYSTEM_LITTLE_ENDIAN) +#if defined(SCUMM_LITTLE_ENDIAN) #define READ_LE_UINT16(a) READ_UINT16(a) #define READ_LE_UINT32(a) READ_UINT32(a) @@ -276,7 +276,7 @@ #define CONSTANT_BE_16(a) SWAP_CONSTANT_16(a) // if the unaligned load and the byteswap take alot instructions its better to directly read and invert -# if defined(SYSTEM_NEED_ALIGNMENT) && !defined(__mips__) +# if defined(SCUMM_NEED_ALIGNMENT) && !defined(__mips__) inline uint16 READ_BE_UINT16(const void *ptr) { const uint8 *b = (const uint8 *)ptr; @@ -313,9 +313,9 @@ WRITE_UINT32(ptr, SWAP_BYTES_32(value)); } -# endif // if defined(SYSTEM_NEED_ALIGNMENT) +# endif // if defined(SCUMM_NEED_ALIGNMENT) -#elif defined(SYSTEM_BIG_ENDIAN) +#elif defined(SCUMM_BIG_ENDIAN) #define READ_BE_UINT16(a) READ_UINT16(a) #define READ_BE_UINT32(a) READ_UINT32(a) @@ -342,7 +342,7 @@ #define CONSTANT_BE_16(a) ((uint16)(a)) // if the unaligned load and the byteswap take alot instructions its better to directly read and invert -# if defined(SYSTEM_NEED_ALIGNMENT) && !defined(__mips__) +# if defined(SCUMM_NEED_ALIGNMENT) && !defined(__mips__) inline uint16 READ_LE_UINT16(const void *ptr) { const uint8 *b = (const uint8 *)ptr; @@ -379,9 +379,9 @@ WRITE_UINT32(ptr, SWAP_BYTES_32(value)); } -# endif // if defined(SYSTEM_NEED_ALIGNMENT) +# endif // if defined(SCUMM_NEED_ALIGNMENT) -#endif // if defined(SYSTEM_LITTLE_ENDIAN) +#endif // if defined(SCUMM_LITTLE_ENDIAN) inline uint32 READ_LE_UINT24(const void *ptr) { const uint8 *b = (const uint8 *)ptr; @@ -393,7 +393,7 @@ inline uint32 READ_BE_UINT24(const void *ptr) { return (b[0] << 16) | (b[1] << 8) | (b[2]); } -#if defined(SYSTEM_BIG_ENDIAN) +#if defined(SCUMM_BIG_ENDIAN) inline float get_float(const char *data) { const unsigned char *udata = reinterpret_cast(data); diff --git a/common/error.cpp b/common/error.cpp index 6d1e3492873..b07e5ebd741 100644 --- a/common/error.cpp +++ b/common/error.cpp @@ -24,51 +24,68 @@ */ #include "common/error.h" -#include "common/util.h" #include "common/translation.h" namespace Common { /** - * Error Table: Maps error codes to their default descriptions + * Maps an error code to equivalent string description. + * + * @param errorCode error code to be converted + * @return a pointer to string description of the error */ +static String errorToString(ErrorCode errorCode) { + switch (errorCode) { + case kNoError: + return _s("No error"); + case kNoGameDataFoundError: + return _s("Game data not found"); + case kUnsupportedGameidError: + return _s("Game id not supported"); + case kUnsupportedColorMode: + return _s("Unsupported color mode"); -struct ErrorMessage { - Error error; - const char *errMsg; -}; + case kReadPermissionDenied: + return _s("Read permission denied"); + case kWritePermissionDenied: + return _s("Write permission denied"); -static const ErrorMessage _errMsgTable[] = { - { kInvalidPathError, _s("Invalid Path") }, - { kNoGameDataFoundError, _s("Game Data not found") }, - { kUnsupportedGameidError, _s("Game Id not supported") }, - { kUnsupportedColorMode, _s("Unsupported Color Mode") }, + case kPathDoesNotExist: + return _s("Path does not exist"); + case kPathNotDirectory: + return _s("Path not a directory"); + case kPathNotFile: + return _s("Path not a file"); - { kReadPermissionDenied, _s("Read permission denied") }, - { kWritePermissionDenied, _s("Write permission denied") }, + case kCreatingFileFailed: + return _s("Cannot create file"); + case kReadingFailed: + return _s("Reading data failed"); + case kWritingFailed: + return _s("Writing data failed"); - // The following three overlap a bit with kInvalidPathError and each other. Which to keep? - { kPathDoesNotExist, _s("Path not exists") }, - { kPathNotDirectory, _s("Path not a directory") }, - { kPathNotFile, _s("Path not a file") }, + case kEnginePluginNotFound: + return _s("Could not find suitable engine plugin"); + case kEnginePluginNotSupportSaves: + return _s("Engine plugin does not support save states"); - { kCreatingFileFailed, _s("Cannot create file") }, - { kReadingFailed, _s("Reading failed") }, - { kWritingFailed, _s("Writing data failed") }, + case kArgumentNotProcessed: + return _s("Command line argument not processed"); - { kUnknownError, _s("Unknown Error") } -}; - -const char *errorToString(Error error) { - - for (int i = 0; i < ARRAYSIZE(_errMsgTable); i++) { - if (error == _errMsgTable[i].error) { - return _errMsgTable[i].errMsg; - } + case kUnknownError: + default: + return _s("Unknown error"); } - - return _("Unknown Error"); } +Error::Error(ErrorCode code) + : _code(code), _desc(errorToString(code)) { +} + +Error::Error(ErrorCode code, const String &desc) + : _code(code), _desc(errorToString(code) + " (" + desc + ")") { +} + + } // End of namespace Common diff --git a/common/error.h b/common/error.h index 58343114a2b..1ffbba723a9 100644 --- a/common/error.h +++ b/common/error.h @@ -26,6 +26,8 @@ #ifndef COMMON_ERROR_H #define COMMON_ERROR_H +#include "common/str.h" + namespace Common { /** @@ -37,15 +39,13 @@ namespace Common { /** * Error codes which may be reported by plugins under various circumstances. * - * @todo Clarify the names; add more codes, resp. verify all existing ones are acutally useful. - * Also, try to avoid overlap. - * @todo Maybe introduce a naming convention? E.g. k-NOUN/ACTION-CONDITION-Error, so - * kPathInvalidError would be correct, but these would not be: kInvalidPath, - * kPathInvalid, kPathIsInvalid, kInvalidPathError + * @note Error names should follow the pattern k-NOUN/ACTION-CONDITION-Error. + * So kPathInvalidError would be correct, but these would not be: + * kInvalidPath, kPathInvalid, kPathIsInvalid, kInvalidPathError. + * @todo Adjust all error codes to comply with these conventions. */ -enum Error { +enum ErrorCode { kNoError = 0, ///< No error occurred - kInvalidPathError, ///< Engine initialization: Invalid game path was passed kNoGameDataFoundError, ///< Engine initialization: No game data was found in the specified location kUnsupportedGameidError, ///< Engine initialization: Gameid not supported by this (Meta)Engine kUnsupportedColorMode, ///< Engine initialization: Engine does not support backend's color mode @@ -54,7 +54,6 @@ enum Error { kReadPermissionDenied, ///< Unable to read data due to missing read permission kWritePermissionDenied, ///< Unable to write data due to missing write permission - // The following three overlap a bit with kInvalidPathError and each other. Which to keep? kPathDoesNotExist, ///< The specified path does not exist kPathNotDirectory, ///< The specified path does not point to a directory kPathNotFile, ///< The specified path does not point to a file @@ -64,21 +63,48 @@ enum Error { kWritingFailed, ///< Failure to write data -- disk full? // The following are used by --list-saves - kPluginNotFound, ///< Failed to find plugin to handle tager - kPluginNotSupportSaves, ///< Failed if plugin does not support saves - kNoSavesError, ///< There are no saves to show + kEnginePluginNotFound, ///< Failed to find plugin to handle target + kEnginePluginNotSupportSaves, ///< Failed if plugin does not support listing save states kArgumentNotProcessed, ///< Used in command line parsing + kUnknownError ///< Catch-all error, used if no other error code matches }; /** - * Maps an error code to equivalent string description. - * - * @param error error code to be converted - * @return a pointer to string description of the error + * An Error instance pairs an error code with string description providing more + * details about the error. For every error code, a default description is + * provided, but it is possible to optionally augment that description with + * extra information when creating a new Error instance. */ -const char *errorToString(Error error); +class Error { +protected: + ErrorCode _code; + String _desc; +public: + /** + * Construct a new Error with the specified error code and the default + * error message. + */ + Error(ErrorCode code = kUnknownError); + + /** + * Construct a new Error with the specified error code and an augmented + * error message. Specifically, the provided extra text is suitably + * appended to the default message. + */ + Error(ErrorCode code, const String &extra); + + /** + * Get the description of this error. + */ + const String &getDesc() const { return _desc; } + + /** + * Get the error code of this error. + */ + ErrorCode getCode() const { return _code; } +}; } // End of namespace Common diff --git a/common/file.cpp b/common/file.cpp index dec0f2a9538..485255bbdb2 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -27,8 +27,7 @@ #include "common/debug.h" #include "common/file.h" #include "common/fs.h" -#include "common/util.h" -#include "common/system.h" +#include "common/textconsole.h" namespace Common { diff --git a/common/file.h b/common/file.h index d28cd9c3087..c3805baed73 100644 --- a/common/file.h +++ b/common/file.h @@ -27,6 +27,7 @@ #define COMMON_FILE_H #include "common/scummsys.h" +#include "common/fs.h" #include "common/noncopyable.h" #include "common/str.h" #include "common/stream.h" @@ -34,7 +35,6 @@ namespace Common { class Archive; -class FSNode; /** * TODO: vital to document this core class properly!!! For both users and implementors diff --git a/common/fs.cpp b/common/fs.cpp index 87067df2ccb..d3cdc0697f8 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -22,8 +22,8 @@ * $Id$ */ -#include "common/util.h" #include "common/system.h" +#include "common/textconsole.h" #include "backends/fs/abstract-fs.h" #include "backends/fs/fs-factory.h" diff --git a/common/fs.h b/common/fs.h index 6b20a050133..f93c11159ef 100644 --- a/common/fs.h +++ b/common/fs.h @@ -27,6 +27,8 @@ #include "common/array.h" #include "common/archive.h" +#include "common/hash-str.h" +#include "common/hashmap.h" #include "common/ptr.h" #include "common/str.h" diff --git a/common/hashmap.h b/common/hashmap.h index 233d7f5b16f..907a107163c 100644 --- a/common/hashmap.h +++ b/common/hashmap.h @@ -47,8 +47,6 @@ #include "common/func.h" -#include "common/str.h" -#include "common/util.h" #ifdef DEBUG_HASH_COLLISIONS #include "common/debug.h" diff --git a/common/macresman.cpp b/common/macresman.cpp index e7d4a307899..489f8f93ce0 100644 --- a/common/macresman.cpp +++ b/common/macresman.cpp @@ -31,7 +31,7 @@ #include "common/macresman.h" #include "common/md5.h" #include "common/substream.h" -#include "common/memstream.h" +#include "common/textconsole.h" #ifdef MACOSX #include "common/config-manager.h" @@ -623,6 +623,11 @@ void MacResManager::convertCrsrCursor(SeekableReadStream *data, byte **cursor, i // Pixel data for cursor int iconDataSize = iconRowBytes * (iconBounds[3] - iconBounds[1]); byte *iconData = new byte[iconDataSize]; + + if (!iconData) { + error("Cannot allocate iconData in macresman.cpp"); + } + data->read(iconData, iconDataSize); // Color table diff --git a/common/macresman.h b/common/macresman.h index 2ad0b608a15..fdb3ce491d1 100644 --- a/common/macresman.h +++ b/common/macresman.h @@ -33,15 +33,14 @@ */ #include "common/array.h" -#include "common/file.h" +#include "common/fs.h" +#include "common/str.h" #ifndef COMMON_MACRESMAN_H #define COMMON_MACRESMAN_H namespace Common { -class FSNode; - typedef Array MacResIDArray; typedef Array MacResTagArray; diff --git a/common/md5.cpp b/common/md5.cpp index e4736e85ca6..bea9ca0dc58 100644 --- a/common/md5.cpp +++ b/common/md5.cpp @@ -28,10 +28,10 @@ * this program is licensed under the GPL. */ -#include "common/file.h" -#include "common/fs.h" #include "common/md5.h" #include "common/endian.h" +#include "common/str.h" +#include "common/stream.h" namespace Common { diff --git a/common/md5.h b/common/md5.h index 29f3aeeb4c4..e613028a5e7 100644 --- a/common/md5.h +++ b/common/md5.h @@ -26,11 +26,11 @@ #define COMMON_MD5_H #include "common/scummsys.h" -#include "common/str.h" namespace Common { class ReadStream; +class String; /** * Compute the MD5 checksum of the content of the given ReadStream. diff --git a/common/memstream.h b/common/memstream.h index 13b8e26e8a0..ac42e1bad9f 100644 --- a/common/memstream.h +++ b/common/memstream.h @@ -27,6 +27,7 @@ #define COMMON_MEMSTREAM_H #include "common/stream.h" +#include "common/types.h" namespace Common { diff --git a/common/scummsys.h b/common/scummsys.h index ae79abc9b73..aa074bfa7ea 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -120,13 +120,13 @@ // which can't use our "configure" tool and hence don't use config.h. // // Some #defines that occur here frequently: -// SYSTEM_LITTLE_ENDIAN +// SCUMM_LITTLE_ENDIAN // - Define this on a little endian target -// SYSTEM_BIG_ENDIAN +// SCUMM_BIG_ENDIAN // - Define this on a big endian target -// SYSTEM_NEED_ALIGNMENT +// SCUMM_NEED_ALIGNMENT // - Define this if your system has problems reading e.g. an int32 from an odd address -// SYSTEM_DONT_DEFINE_TYPES +// SCUMMVM_DONT_DEFINE_TYPES // - Define this if you need to provide your own typedefs, e.g. because your // system headers conflict with our typenames, or because you have odd // type requirements. @@ -137,7 +137,7 @@ // We define all types in config.h, so we don't want to typedef those types // here again! #ifdef HAVE_CONFIG_H -#define SYSTEM_DONT_DEFINE_TYPES +#define SCUMMVM_DONT_DEFINE_TYPES #endif @@ -152,22 +152,25 @@ // If neither is possible, tough luck. Try to contact the team, maybe we can // come up with a solution, though I wouldn't hold my breath on it :-/. // -#define SYSTEM_USE_PRAGMA_PACK +#define SCUMMVM_USE_PRAGMA_PACK #if defined(__SYMBIAN32__) - #define SYSTEM_LITTLE_ENDIAN - #define SYSTEM_NEED_ALIGNMENT + #define scumm_stricmp strcasecmp + #define scumm_strnicmp strncasecmp + + #define SCUMM_LITTLE_ENDIAN + #define SCUMM_NEED_ALIGNMENT #define SMALL_SCREEN_DEVICE // Enable Symbians own datatypes // This is done for two reasons // a) uint is already defined by Symbians libc component - // b) Symbian is using its "own" datatyping, and the Residual port + // b) Symbian is using its "own" datatyping, and the Scummvm port // should follow this to ensure the best compability possible. - #define SYSTEM_DONT_DEFINE_TYPES + #define SCUMMVM_DONT_DEFINE_TYPES typedef unsigned char byte; typedef unsigned char uint8; @@ -181,11 +184,11 @@ #elif defined(_WIN32_WCE) - #define strcasecmp stricmp - #define strncasecmp strnicmp + #define scumm_stricmp stricmp + #define scumm_strnicmp _strnicmp #define snprintf _snprintf - #define SYSTEM_LITTLE_ENDIAN + #define SCUMM_LITTLE_ENDIAN #ifndef __GNUC__ #define FORCEINLINE __forceinline @@ -199,11 +202,11 @@ #elif defined(_MSC_VER) - #define strcasecmp stricmp - #define strncasecmp strnicmp + #define scumm_stricmp stricmp + #define scumm_strnicmp _strnicmp #define snprintf _snprintf - #define SYSTEM_LITTLE_ENDIAN + #define SCUMM_LITTLE_ENDIAN #define FORCEINLINE __forceinline #define NORETURN_PRE __declspec(noreturn) @@ -212,15 +215,18 @@ #elif defined(__MINGW32__) - #define strcasecmp stricmp - #define strncasecmp strnicmp + #define scumm_stricmp stricmp + #define scumm_strnicmp strnicmp - #define SYSTEM_LITTLE_ENDIAN + #define SCUMM_LITTLE_ENDIAN #define PLUGIN_EXPORT __declspec(dllexport) #elif defined(UNIX) + #define scumm_stricmp strcasecmp + #define scumm_strnicmp strncasecmp + #ifndef CONFIG_H /* need this for the SDL_BYTEORDER define */ #include @@ -235,7 +241,7 @@ #endif // You need to set this manually if necessary -// #define SYSTEM_NEED_ALIGNMENT +// #define SCUMM_NEED_ALIGNMENT // Very BAD hack following, used to avoid triggering an assert in uClibc dingux library // "toupper" when pressing keyboard function keys. @@ -246,19 +252,22 @@ #elif defined(__DC__) - #define SYSTEM_LITTLE_ENDIAN - #define SYSTEM_NEED_ALIGNMENT + #define scumm_stricmp strcasecmp + #define scumm_strnicmp strncasecmp + + #define SCUMM_LITTLE_ENDIAN + #define SCUMM_NEED_ALIGNMENT #elif defined(__GP32__) - #define strcasecmp stricmp - #define strncasecmp strnicmp + #define scumm_stricmp stricmp + #define scumm_strnicmp strnicmp - #define SYSTEM_LITTLE_ENDIAN - #define SYSTEM_NEED_ALIGNMENT + #define SCUMM_LITTLE_ENDIAN + #define SCUMM_NEED_ALIGNMENT // Override typenames. uint is already defined by system header files. - #define SYSTEM_DONT_DEFINE_TYPES + #define SCUMMVM_DONT_DEFINE_TYPES typedef unsigned char byte; typedef unsigned char uint8; @@ -272,16 +281,23 @@ #elif defined(__PLAYSTATION2__) - #define SYSTEM_LITTLE_ENDIAN - #define SYSTEM_NEED_ALIGNMENT + #define scumm_stricmp strcasecmp + #define scumm_strnicmp strncasecmp + + #define SCUMM_LITTLE_ENDIAN + #define SCUMM_NEED_ALIGNMENT + #elif defined(__N64__) - #define SYSTEM_BIG_ENDIAN - #define SYSTEM_NEED_ALIGNMENT + #define scumm_stricmp strcasecmp + #define scumm_strnicmp strncasecmp + + #define SCUMM_BIG_ENDIAN + #define SCUMM_NEED_ALIGNMENT #define STRINGBUFLEN 256 - #define SYSTEM_DONT_DEFINE_TYPES + #define SCUMMVM_DONT_DEFINE_TYPES typedef unsigned char byte; typedef unsigned char uint8; @@ -301,31 +317,43 @@ #include #include "backends/platform/psp/memory.h" - #define SYSTEM_LITTLE_ENDIAN - #define SYSTEM_NEED_ALIGNMENT + #define scumm_stricmp strcasecmp + #define scumm_strnicmp strncasecmp + + #define SCUMM_LITTLE_ENDIAN + #define SCUMM_NEED_ALIGNMENT + + /* to make an efficient, inlined memcpy implementation */ + #define memcpy(dst, src, size) psp_memcpy(dst, src, size) #elif defined(__amigaos4__) - #define SYSTEM_BIG_ENDIAN - #define SYSTEM_NEED_ALIGNMENT + #define scumm_stricmp strcasecmp + #define scumm_strnicmp strncasecmp + + #define SCUMM_BIG_ENDIAN + #define SCUMM_NEED_ALIGNMENT #elif defined (__DS__) - #define strcasecmp stricmp - #define strncasecmp strnicmp + #define scumm_stricmp stricmp + #define scumm_strnicmp strnicmp - #define SYSTEM_NEED_ALIGNMENT - #define SYSTEM_LITTLE_ENDIAN + #define SCUMM_NEED_ALIGNMENT + #define SCUMM_LITTLE_ENDIAN - #define SYSTEM_DONT_DEFINE_TYPES + #define SCUMMVM_DONT_DEFINE_TYPES #define STRINGBUFLEN 256 // #define printf(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__) #elif defined(__WII__) - #define SYSTEM_BIG_ENDIAN - #define SYSTEM_NEED_ALIGNMENT + #define scumm_stricmp strcasecmp + #define scumm_strnicmp strncasecmp + + #define SCUMM_BIG_ENDIAN + #define SCUMM_NEED_ALIGNMENT #else #error No system type defined @@ -387,9 +415,9 @@ // -// Typedef our system types unless SYSTEM_DONT_DEFINE_TYPES is set. +// Typedef our system types unless SCUMMVM_DONT_DEFINE_TYPES is set. // -#ifndef SYSTEM_DONT_DEFINE_TYPES +#ifndef SCUMMVM_DONT_DEFINE_TYPES typedef unsigned char byte; typedef unsigned char uint8; typedef signed char int8; diff --git a/common/str.cpp b/common/str.cpp index 8164dc7db99..c21e4412dbb 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -563,7 +563,7 @@ int String::compareToIgnoreCase(const String &x) const { int String::compareToIgnoreCase(const char *x) const { assert(x != 0); - return strcasecmp(c_str(), x); + return scumm_stricmp(c_str(), x); } #pragma mark - diff --git a/common/stream.cpp b/common/stream.cpp index c0783b2352e..e870e68b2df 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -26,9 +26,7 @@ #include "common/stream.h" #include "common/memstream.h" #include "common/substream.h" -#include "common/bufferedstream.h" #include "common/str.h" -#include "common/util.h" namespace Common { @@ -205,7 +203,6 @@ uint32 SubReadStream::read(void *dataPtr, uint32 dataSize) { } dataSize = _parentStream->read(dataPtr, dataSize); - _eos |= _parentStream->eos(); _pos += dataSize; return dataSize; diff --git a/common/stream.h b/common/stream.h index 65b4971a723..530b50e4316 100644 --- a/common/stream.h +++ b/common/stream.h @@ -26,12 +26,12 @@ #ifndef COMMON_STREAM_H #define COMMON_STREAM_H -#include "common/types.h" #include "common/endian.h" +#include "common/scummsys.h" +#include "common/str.h" namespace Common { -class String; class SeekableReadStream; /** diff --git a/common/substream.h b/common/substream.h index dc49ce9ecfd..ecf11c54c94 100644 --- a/common/substream.h +++ b/common/substream.h @@ -27,6 +27,7 @@ #define COMMON_SUBSTREAM_H #include "common/stream.h" +#include "common/types.h" namespace Common { @@ -59,7 +60,7 @@ public: delete _parentStream; } - virtual bool eos() const { return _eos; } + virtual bool eos() const { return _eos | _parentStream->eos(); } virtual bool err() const { return _parentStream->err(); } virtual void clearErr() { _eos = false; _parentStream->clearErr(); } virtual uint32 read(void *dataPtr, uint32 dataSize); diff --git a/common/system.cpp b/common/system.cpp index 0b27a6bb4cf..c41f1aa236b 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -28,6 +28,7 @@ #define FORBIDDEN_SYMBOL_ALLOW_ALL #include "common/system.h" +#include "common/str.h" #ifdef __PLAYSTATION2__ // for those replaced fopen/fread/etc functions diff --git a/common/system.h b/common/system.h index d2dca5706dd..cb2d959bd01 100644 --- a/common/system.h +++ b/common/system.h @@ -28,32 +28,32 @@ #include "common/scummsys.h" #include "common/noncopyable.h" -#include "common/rect.h" #include "common/list.h" // For OSystem::getSupportedFormats() - #include "graphics/pixelformat.h" namespace Audio { - class Mixer; +class Mixer; } namespace Graphics { - struct Surface; +struct Surface; } namespace Common { - struct Event; - class EventManager; - class SaveFileManager; - class SearchSet; - class TimerManager; - class SeekableReadStream; - class WriteStream; - class HardwareKeySet; +class EventManager; +struct Rect; +class SaveFileManager; +class SearchSet; +class String; +class TimerManager; +class SeekableReadStream; +class WriteStream; +class HardwareKeySet; } class AudioCDManager; class FilesystemFactory; +class PaletteManager; /** * A structure describing time and date. This is a clone of struct tm diff --git a/common/textconsole.cpp b/common/textconsole.cpp index 9c72699914d..8d62cd4cb20 100644 --- a/common/textconsole.cpp +++ b/common/textconsole.cpp @@ -24,6 +24,7 @@ #include "common/textconsole.h" #include "common/system.h" +#include "common/str.h" namespace Common { diff --git a/common/translation.cpp b/common/translation.cpp index b8d709797fd..cdf8a456b8d 100644 --- a/common/translation.cpp +++ b/common/translation.cpp @@ -32,11 +32,11 @@ #define TRANSLATIONS_DAT_VER 2 #include "common/translation.h" -#include "common/archive.h" #include "common/config-manager.h" #include "common/file.h" #include "common/fs.h" #include "common/system.h" +#include "common/textconsole.h" #ifdef USE_TRANSLATION diff --git a/common/translation.h b/common/translation.h index 523f2f4de71..f8183b63501 100644 --- a/common/translation.h +++ b/common/translation.h @@ -25,6 +25,9 @@ #ifndef COMMON_TRANSLATION_H #define COMMON_TRANSLATION_H +#include "common/array.h" +#include "common/fs.h" +#include "common/str.h" #include "common/singleton.h" #include "common/str-array.h" @@ -33,7 +36,6 @@ namespace Common { class File; -class FSNode; enum TranslationIDs { kTranslationAutodetectId = 0, diff --git a/common/unzip.cpp b/common/unzip.cpp index 0464f05e6ea..a55dfd1cad2 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -105,7 +105,6 @@ typedef struct { #include "common/fs.h" #include "common/unzip.h" -#include "common/file.h" #include "common/memstream.h" #include "common/hashmap.h" @@ -455,7 +454,7 @@ int unzStringFileNameCompare(const char* fileName1, const char* fileName2, int i if (iCaseSensitivity==1) return strcmp(fileName1,fileName2); - return strcasecmp(fileName1,fileName2); + return scumm_stricmp(fileName1,fileName2); } #define BUFREADCOMMENT (0x400) @@ -1470,11 +1469,13 @@ int ZipArchive::listMembers(Common::ArchiveMemberList &list) { while (err == UNZ_OK) { char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; - unzGetCurrentFileInfo(_zipFile, NULL, - szCurrentFileName, sizeof(szCurrentFileName)-1, - NULL, 0, NULL, 0); - list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(szCurrentFileName, this))); - matches++; + if (unzGetCurrentFileInfo(_zipFile, NULL, + szCurrentFileName, sizeof(szCurrentFileName)-1, + NULL, 0, NULL, 0) == UNZ_OK) { + list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(szCurrentFileName, this))); + matches++; + } + err = unzGoToNextFile(_zipFile); } @@ -1493,18 +1494,31 @@ Common::SeekableReadStream *ZipArchive::createReadStreamForMember(const Common:: return 0; unz_file_info fileInfo; - unzOpenCurrentFile(_zipFile); - unzGetCurrentFileInfo(_zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0); + if (unzOpenCurrentFile(_zipFile) != UNZ_OK) + return 0; + + if (unzGetCurrentFileInfo(_zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0) != UNZ_OK) + return 0; + byte *buffer = (byte *)malloc(fileInfo.uncompressed_size); assert(buffer); - unzReadCurrentFile(_zipFile, buffer, fileInfo.uncompressed_size); - unzCloseCurrentFile(_zipFile); + + if (unzReadCurrentFile(_zipFile, buffer, fileInfo.uncompressed_size) != (int)fileInfo.uncompressed_size) { + free(buffer); + return 0; + } + + if (unzCloseCurrentFile(_zipFile) != UNZ_OK) { + free(buffer); + return 0; + } + return new Common::MemoryReadStream(buffer, fileInfo.uncompressed_size, DisposeAfterUse::YES); // FIXME: instead of reading all into a memory stream, we could // instead create a new ZipStream class. But then we have to be // careful to handle the case where the client code opens multiple - // files in the archive and tries to use them indepenendtly. + // files in the archive and tries to use them independently. } Archive *makeZipArchive(const String &name) { diff --git a/common/unzip.h b/common/unzip.h index c460840f129..fe7acdcc54c 100644 --- a/common/unzip.h +++ b/common/unzip.h @@ -25,12 +25,13 @@ #ifndef COMMON_UNZIP_H #define COMMON_UNZIP_H +#include "common/str.h" + namespace Common { class Archive; class FSNode; class SeekableReadStream; -class String; /** * This factory method creates an Archive instance corresponding to the content diff --git a/common/util.cpp b/common/util.cpp index 0f9ec27d4bc..a41e943981b 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -23,9 +23,9 @@ */ #include "common/util.h" -#include "common/system.h" #include "common/translation.h" #include "common/config-manager.h" +#include "common/debug.h" namespace Common { diff --git a/common/util.h b/common/util.h index 82a9508cba0..b487494a9de 100644 --- a/common/util.h +++ b/common/util.h @@ -26,14 +26,8 @@ #define COMMON_UTIL_H #include "common/scummsys.h" -#include "common/textconsole.h" #include "common/str.h" -#ifdef WIN32 -#ifdef ARRAYSIZE -#undef ARRAYSIZE // winnt.h defines ARRAYSIZE, but we want our own one... -#endif -#endif /** * Check whether a given pointer is aligned correctly. diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp index b53a9a33c27..7a6e794e11e 100644 --- a/common/xmlparser.cpp +++ b/common/xmlparser.cpp @@ -24,7 +24,6 @@ */ #include "common/xmlparser.h" -#include "common/util.h" #include "common/archive.h" #include "common/fs.h" #include "common/memstream.h" diff --git a/common/xmlparser.h b/common/xmlparser.h index ec8f3716819..c456fd08265 100644 --- a/common/xmlparser.h +++ b/common/xmlparser.h @@ -29,6 +29,7 @@ #include "common/scummsys.h" #include "common/types.h" +#include "common/fs.h" #include "common/list.h" #include "common/hashmap.h" #include "common/hash-str.h" @@ -37,7 +38,6 @@ namespace Common { -class FSNode; class SeekableReadStream; #define MAX_XML_DEPTH 8 diff --git a/configure b/configure index ad8892caae8..2d09723dc34 100755 --- a/configure +++ b/configure @@ -84,12 +84,14 @@ add_engine grim "Grim" yes # Default lib behaviour yes/no/auto _vorbis=auto _tremor=auto +_tremolo=no _flac=auto _mad=auto _alsa=auto _seq_midi=auto _timidity=auto _zlib=auto +_mpeg2=no _theoradec=auto _fluidsynth=auto _opengl=auto @@ -100,6 +102,7 @@ _debug_build=auto _release_build=auto _text_console=no _mt32emu=no +_arm_asm=no _enable_prof=no _unix=no _global_constructors=no @@ -648,6 +651,8 @@ Optional Libraries: --with-zlib-prefix=DIR Prefix where zlib is installed (optional) + --with-mpeg2-prefix=DIR Prefix where libmpeg2 is installed (optional) + --enable-mpeg2 enable mpeg2 codec for cutscenes [no] --disable-opengl disable OpenGL (ES) support [autodetect] --with-theoradec-prefix=DIR Prefix where libtheoradec is installed (optional) @@ -699,6 +704,7 @@ for ac_option in $@; do --disable-mad) _mad=no ;; --enable-nasm) _nasm=yes ;; --disable-nasm) _nasm=no ;; + --enable-mpeg2) _mpeg2=yes ;; --disable-theoradec) _theoradec=no ;; --enable-theoradec) _theoradec=yes ;; --disable-fluidsynth) _fluidsynth=no ;; @@ -724,6 +730,11 @@ for ac_option in $@; do FLUIDSYNTH_CFLAGS="-I$arg/include" FLUIDSYNTH_LIBS="-L$arg/lib" ;; + --with-mpeg2-prefix=*) + arg=`echo $ac_option | cut -d '=' -f 2` + MPEG2_CFLAGS="-I$arg/include" + MPEG2_LIBS="-L$arg/lib" + ;; --with-alsa-prefix=*) arg=`echo $ac_option | cut -d '=' -f 2` ALSA_CFLAGS="-I$arg/include" @@ -1576,6 +1587,8 @@ case $_host_os in _unix=yes ;; webos) + CXXFLAGS="$CXXFLAGS -I$WEBOS_PDK/include -I$WEBOS_PDK/include/SDL -I$WEBOS_PDK/device/usr/include" + CXXFLAGS="$CXXFLAGS -mcpu=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp" LDFLAGS="$LDFLAGS -L$WEBOS_PDK/device/lib -L$WEBOS_PDK/device/usr/lib" LDFLAGS="$LDFLAGS -Wl,--allow-shlib-undefined" LDFLAGS="$LDFLAGS --sysroot=$WEBOS_PDK/arm-gcc/sysroot" @@ -1618,11 +1631,9 @@ if test -n "$_host"; then LDFLAGS="$LDFLAGS -shared -Wl,-Bsymbolic,--no-undefined" HOSTEXEPRE=lib HOSTEXEEXT=.so - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' _backend="android" _port_mk="backends/platform/android/android.mk" + _arm_asm=yes _build_scalers=no _seq_midi=no _mt32emu=no @@ -1631,9 +1642,7 @@ if test -n "$_host"; then arm-linux|arm*-linux-gnueabi|arm-*-linux) _unix=yes _need_memalign=yes - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' + _arm_asm=yes ;; arm-riscos|linupy) DEFINES="$DEFINES -DLINUPY" @@ -1657,9 +1666,7 @@ if test -n "$_host"; then ASFLAGS="$ASFLAGS" _unix=yes _need_memalign=yes - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' + _arm_asm=yes _backend="gph" _build_hq_scalers=no _vkeybd=yes @@ -1707,9 +1714,7 @@ if test -n "$_host"; then DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL -DDISABLE_SID -DDISABLE_NES_APU" DEFINES="$DEFINES -DDISABLE_COMMAND_LINE" _need_memalign=yes - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' + _arm_asm=yes add_line_to_config_h '#define DISABLE_TEXT_CONSOLE' _backend="ds" _build_scalers=no @@ -1743,9 +1748,7 @@ if test -n "$_host"; then LDFLAGS="$LDFLAGS -static" _unix=yes _need_memalign=yes - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' + _arm_asm=yes _backend="gph" _build_hq_scalers=no _vkeybd=yes @@ -1765,9 +1768,7 @@ if test -n "$_host"; then ASFLAGS="$ASFLAGS -mfloat-abi=soft" _unix=yes _need_memalign=yes - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' + _arm_asm=yes _backend="gph" _build_hq_scalers=no _vkeybd=yes @@ -1780,8 +1781,7 @@ if test -n "$_host"; then DEFINES="$DEFINES -DIPHONE" _unix=yes _need_memalign=yes - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' + _arm_asm=yes _backend="iphone" _build_hq_scalers=no _seq_midi=no @@ -1812,9 +1812,7 @@ if test -n "$_host"; then ASFLAGS="$ASFLAGS -mfpu=vfp" _unix=yes _need_memalign=yes - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' + _arm_asm=yes _backend="linuxmoto" _build_hq_scalers=no _mt32emu=no @@ -1827,9 +1825,7 @@ if test -n "$_host"; then ASFLAGS="$ASFLAGS -mfpu=vfp" _unix=yes _need_memalign=yes - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' + _arm_asm=yes _backend="linuxmoto" _build_hq_scalers=no _mt32emu=no @@ -1880,9 +1876,7 @@ if test -n "$_host"; then ASFLAGS="$ASFLAGS -mfloat-abi=soft" _unix=yes _need_memalign=yes - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' + _arm_asm=yes _backend="openpandora" _build_hq_scalers=yes _vkeybd=no @@ -1892,6 +1886,7 @@ if test -n "$_host"; then ;; ppc-amigaos) _endian=big + # AmigaOS exec allocates memory always in an aligned way _need_memalign=yes ;; ps2) @@ -1937,9 +1932,7 @@ if test -n "$_host"; then HOSTEXEEXT=".so" _unix=yes _need_memalign=yes - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' + _arm_asm=yes _backend="samsungtv" _mt32emu=no _vkeybd=yes @@ -1947,11 +1940,7 @@ if test -n "$_host"; then webos) _unix=yes _need_memalign=yes - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' - add_line_to_config_mk 'USE_ARM_COSTUME_ASM = 1' - add_line_to_config_mk 'USE_ARM_SCALER_ASM = 1' + _arm_asm=yes _backend="webos" _port_mk="backends/platform/webos/webos.mk" _build_scalers=no @@ -1979,10 +1968,8 @@ if test -n "$_host"; then wince) LDFLAGS="$LDFLAGS -Wl,-Map,scummvm.exe.map -Wl,--stack,65536" _need_memalign=yes - add_line_to_config_mk 'USE_TREMOLO = 1' - add_line_to_config_mk 'USE_ARM_SOUND_ASM = 1' - add_line_to_config_mk 'USE_ARM_SMUSH_ASM = 1' - add_line_to_config_mk 'USE_ARM_GFX_ASM = 1' + _arm_asm=yes + _tremolo=yes _backend="wince" _mt32emu=no _port_mk="backends/platform/wince/wince.mk" @@ -2046,12 +2033,12 @@ fi # case $_endian in big) - add_line_to_config_h '#undef SYSTEM_LITTLE_ENDIAN' - add_line_to_config_h '#define SYSTEM_BIG_ENDIAN' + add_line_to_config_h '#undef SCUMM_LITTLE_ENDIAN' + add_line_to_config_h '#define SCUMM_BIG_ENDIAN' ;; little) - add_line_to_config_h '#define SYSTEM_LITTLE_ENDIAN' - add_line_to_config_h '#undef SYSTEM_BIG_ENDIAN' + add_line_to_config_h '#define SCUMM_LITTLE_ENDIAN' + add_line_to_config_h '#undef SCUMM_BIG_ENDIAN' ;; *) exit 1 @@ -2060,7 +2047,7 @@ esac define_in_config_h_if_yes $_have_x86 'HAVE_X86' -define_in_config_h_if_yes $_need_memalign 'SYSTEM_NEED_ALIGNMENT' +define_in_config_h_if_yes $_need_memalign 'SCUMM_NEED_ALIGNMENT' if test "$_unix" = yes ; then DEFINES="$DEFINES -DUNIX" @@ -2280,6 +2267,13 @@ fi define_in_config_if_yes "$_mt32emu" 'USE_MT32EMU' +# +# Check whether to use optimized ARM asm +# +define_in_config_if_yes "$_arm_asm" 'USE_ARM_SOUND_ASM' +define_in_config_if_yes "$_arm_asm" 'USE_ARM_SMUSH_ASM' +define_in_config_if_yes "$_arm_asm" 'USE_ARM_GFX_ASM' + # # Check for math lib @@ -2313,6 +2307,10 @@ echo "$_vorbis" # Check for Tremor # echocheck "Tremor" +if test "$_tremolo" = yes ; then + _tremor=yes +fi + if test "$_tremor" = auto ; then _tremor=no cat > $TMPC << EOF @@ -2325,7 +2323,12 @@ fi if test "$_tremor" = yes && test "$_vorbis" = no; then add_line_to_config_h '#define USE_TREMOR' add_line_to_config_h '#define USE_VORBIS' - LIBS="$LIBS $TREMOR_LIBS -lvorbisidec" + if test "$_tremolo" = yes ; then + add_line_to_config_h '#define USE_TREMOLO' + LIBS="$LIBS $TREMOR_LIBS -ltremolo" + else + LIBS="$LIBS $TREMOR_LIBS -lvorbisidec" + fi INCLUDES="$INCLUDES $TREMOR_CFLAGS" else if test "$_vorbis" = yes; then @@ -2479,6 +2482,49 @@ fi define_in_config_if_yes "$_zlib" 'USE_ZLIB' echo "$_zlib" +# +# Check for LibMPEG2 +# +echocheck "libmpeg2 >= 0.3.2" +if test "$_mpeg2" = auto ; then + _mpeg2=no + cat > $TMPC << EOF +typedef signed $type_1_byte int8_t; +typedef signed $type_2_byte int16_t; +typedef signed $type_4_byte int32_t; + +typedef unsigned $type_1_byte uint8_t; +typedef unsigned $type_2_byte uint16_t; +typedef unsigned $type_4_byte uint32_t; + +#include +int main(void) { + /* mpeg2_state_t first appears in 0.4.0 */ + mpeg2_state_t state; + + #ifdef MPEG2_RELEASE + if (MPEG2_RELEASE >= MPEG2_VERSION(0, 3, 2)) + return 0; + #endif + return 1; +} +EOF + + if test -n "$_host"; then + # don't execute while cross compiling + cc_check $MPEG2_CFLAGS $MPEG2_LIBS -lmpeg2 && _mpeg2=yes + else + cc_check_no_clean $MPEG2_CFLAGS $MPEG2_LIBS -lmpeg2 && $TMPO$HOSTEXEEXT && _mpeg2=yes + cc_check_clean + fi +fi +if test "$_mpeg2" = yes ; then + INCLUDES="$INCLUDES $MPEG2_CFLAGS" + LIBS="$LIBS $MPEG2_LIBS -lmpeg2" +fi +define_in_config_if_yes "$_mpeg2" 'USE_MPEG2' +echo "$_mpeg2" + # # Check for libfluidsynth # @@ -2897,7 +2943,6 @@ case $_backend in DEFINES="$DEFINES -DSDL_BACKEND" ;; webos) - INCLUDES="$INCLUDES -I$WEBOS_PDK/include -I$WEBOS_PDK/include/SDL -I$WEBOS_PDK/device/usr/include" LIBS="$LIBS -lSDL -lpdl" DEFINES="$DEFINES -DSDL_BACKEND -DWEBOS" MODULES="$MODULES backends/platform/sdl" diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index a597ba36e9b..35f68a12c0b 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -295,20 +295,12 @@ int main(int argc, char *argv[]) { setup.libraries.push_back(ADDITIONAL_LIBRARY); #endif -// Initialize global & project-specific warnings -#define SET_GLOBAL_WARNINGS(...) \ - { \ - std::string global[PP_NARG(__VA_ARGS__)] = { __VA_ARGS__ }; \ - globalWarnings.assign(global, global + (sizeof(global) / sizeof(global[0]))); \ - } - -#define SET_WARNINGS(name, ...) \ - { \ - std::string project[PP_NARG(__VA_ARGS__)] = { __VA_ARGS__ }; \ - projectWarnings[name].assign(project, project + (sizeof(project) / sizeof(project[0]))); \ - } - // List of global warnings and map of project-specific warnings + // FIXME: As shown below these two structures have different behavior for + // Code::Blocks and MSVC. In Code::Blocks this is used to enable *and* + // disable certain warnings (and some other not warning related flags + // actually...). While in MSVC this is solely for disabling warnings. + // That is really not nice. We should consider a nicer way of doing this. StringList globalWarnings; std::map projectWarnings; @@ -342,9 +334,23 @@ int main(int argc, char *argv[]) { // //////////////////////////////////////////////////////////////////////////// - SET_GLOBAL_WARNINGS("-Wall", "-Wno-long-long", "-Wno-multichar", "-Wno-unknown-pragmas", "-Wno-reorder", - "-Wpointer-arith", "-Wcast-qual", "-Wcast-align", "-Wshadow", "-Wimplicit", - "-Wnon-virtual-dtor", "-Wwrite-strings", "-fno-rtti", "-fno-exceptions", "-fcheck-new"); + globalWarnings.push_back("-Wall"); + globalWarnings.push_back("-Wno-long-long"); + globalWarnings.push_back("-Wno-multichar"); + globalWarnings.push_back("-Wno-unknown-pragmas"); + globalWarnings.push_back("-Wno-reorder"); + globalWarnings.push_back("-Wpointer-arith"); + globalWarnings.push_back("-Wcast-qual"); + globalWarnings.push_back("-Wcast-align"); + globalWarnings.push_back("-Wshadow"); + globalWarnings.push_back("-Wimplicit"); + globalWarnings.push_back("-Wnon-virtual-dtor"); + globalWarnings.push_back("-Wwrite-strings"); + // The following are not warnings at all... We should consider adding them to + // a different list of parameters. + globalWarnings.push_back("-fno-rtti"); + globalWarnings.push_back("-fno-exceptions"); + globalWarnings.push_back("-fcheck-new"); provider = new CreateProjectTool::CodeBlocksProvider(globalWarnings, projectWarnings); @@ -421,12 +427,35 @@ int main(int argc, char *argv[]) { // //////////////////////////////////////////////////////////////////////////// - SET_GLOBAL_WARNINGS("4068", "4100", "4103", "4127", "4244", "4250", "4310", "4351", "4512", "4702", "4706", "4800", "4996", "6204", "6211", "6385", "6386"); - SET_WARNINGS("agi", "4510", "4610"); - SET_WARNINGS("agos", "4511"); - SET_WARNINGS("lure", "4189", "4355"); - SET_WARNINGS("kyra", "4355"); - SET_WARNINGS("m4", "4355"); + globalWarnings.push_back("4068"); + globalWarnings.push_back("4100"); + globalWarnings.push_back("4103"); + globalWarnings.push_back("4127"); + globalWarnings.push_back("4244"); + globalWarnings.push_back("4250"); + globalWarnings.push_back("4310"); + globalWarnings.push_back("4351"); + globalWarnings.push_back("4512"); + globalWarnings.push_back("4702"); + globalWarnings.push_back("4706"); + globalWarnings.push_back("4800"); + globalWarnings.push_back("4996"); + globalWarnings.push_back("6204"); + globalWarnings.push_back("6211"); + globalWarnings.push_back("6385"); + globalWarnings.push_back("6386"); + + projectWarnings["agi"].push_back("4510"); + projectWarnings["agi"].push_back("4610"); + + projectWarnings["agos"].push_back("4511"); + + projectWarnings["lure"].push_back("4189"); + projectWarnings["lure"].push_back("4355"); + + projectWarnings["kyra"].push_back("4355"); + + projectWarnings["m4"].push_back("4355"); if (msvcVersion == 8 || msvcVersion == 9) provider = new CreateProjectTool::VisualStudioProvider(globalWarnings, projectWarnings, msvcVersion); @@ -709,6 +738,7 @@ const Feature s_features[] = { { "opengl", "USE_OPENGL", "opengl32", true, "OpenGL support" }, { "indeo3", "USE_INDEO3", "", true, "Indeo3 codec support"}, { "translation", "USE_TRANSLATION", "", true, "Translation support" }, + { "vkeybd", "ENABLE_VKEYBD", "", false, "Virtual keyboard support"}, { "langdetect", "USE_DETECTLANG", "", true, "System language detection support" } // This feature actually depends on "translation", there // is just no current way of properly detecting this... }; @@ -797,9 +827,10 @@ bool producesObjectFile(const std::string &fileName) { * Checks whether the give file in the specified directory is present in the given * file list. * - * This function does as special match against the file list. It will not take file - * extensions into consideration, when the extension of a file in the specified - * directory is one of "h", "cpp", "c" or "asm". + * This function does as special match against the file list. Object files (.o) are + * excluded by default and it will not take file extensions into consideration, + * when the extension of a file in the specified directory is one of "h", "cpp", + * "c" or "asm". * * @param dir Parent directory of the file. * @param fileName File name to match. @@ -829,7 +860,9 @@ bool isInList(const std::string &dir, const std::string &fileName, const StringL } const std::string lastPathComponent = getLastPathComponent(*i); - if (!producesObjectFile(fileName) && extensionName != "h") { + if (extensionName == "o") { + return false; + } else if (!producesObjectFile(fileName) && extensionName != "h") { if (fileName == lastPathComponent) return true; } else { diff --git a/devtools/create_project/create_project.h b/devtools/create_project/create_project.h index c228c34898e..f4d2a0a66a4 100644 --- a/devtools/create_project/create_project.h +++ b/devtools/create_project/create_project.h @@ -32,34 +32,6 @@ #include -// The PP_NARG macro returns the number of arguments that have been passed to it. -#define PP_NARG(...) \ - PP_NARG_(__VA_ARGS__,PP_RSEQ_N()) -#define PP_NARG_(...) \ - PP_ARG_N(__VA_ARGS__) -#define PP_ARG_N( \ - _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \ - _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \ - _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \ - _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \ - _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \ - _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \ - _61,_62,_63,N,...) N -#define PP_RSEQ_N() \ - 63,62,61,60, \ - 59,58,57,56,55,54,53,52,51,50, \ - 49,48,47,46,45,44,43,42,41,40, \ - 39,38,37,36,35,34,33,32,31,30, \ - 29,28,27,26,25,24,23,22,21,20, \ - 19,18,17,16,15,14,13,12,11,10, \ - 9,8,7,6,5,4,3,2,1,0 - -#define SET_VALUES(list, ...) \ - { \ - std::string values[PP_NARG(__VA_ARGS__)] = { __VA_ARGS__ }; \ - list.assign(values, values + (sizeof(values) / sizeof(values[0]))); \ - } - typedef std::list StringList; /** diff --git a/devtools/create_project/msbuild.cpp b/devtools/create_project/msbuild.cpp index 9d8b9c04072..06425dd4aac 100644 --- a/devtools/create_project/msbuild.cpp +++ b/devtools/create_project/msbuild.cpp @@ -52,22 +52,29 @@ int MSBuildProvider::getVisualStudioVersion() { return 2010; } -#define OUTPUT_CONFIGURATION_MSBUILD(config, platform) \ - (project << "\t\t\n" \ - "\t\t\t" << config << "\n" \ - "\t\t\t" << platform << "\n" \ - "\t\t\n") +namespace { -#define OUTPUT_CONFIGURATION_TYPE_MSBUILD(config) \ - (project << "\t\n" \ - "\t\t" << (name == PROJECT_NAME ? "Application" : "StaticLibrary") << "\n" \ - "\t\n") +inline void outputConfiguration(std::ostream &project, const std::string &config, const std::string &platform) { + project << "\t\t\n" + "\t\t\t" << config << "\n" + "\t\t\t" << platform << "\n" + "\t\t\n"; +} -#define OUTPUT_PROPERTIES_MSBUILD(config, properties) \ - (project << "\t\n" \ - "\t\t\n" \ - "\t\t\n" \ - "\t\n") +inline void outputConfigurationType(std::ostream &project, const std::string &name, const std::string &config) { + project << "\t\n" + "\t\t" << (name == PROJECT_NAME ? "Application" : "StaticLibrary") << "\n" + "\t\n"; +} + +inline void outputProperties(std::ostream &project, const std::string &config, const std::string &properties) { + project << "\t\n" + "\t\t\n" + "\t\t\n" + "\t\n"; +} + +} // End of anonymous namespace void MSBuildProvider::createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, const StringList &includeList, const StringList &excludeList) { @@ -80,12 +87,12 @@ void MSBuildProvider::createProjectFile(const std::string &name, const std::stri "\n" "\t\n"; - OUTPUT_CONFIGURATION_MSBUILD("Debug", "Win32"); - OUTPUT_CONFIGURATION_MSBUILD("Debug", "x64"); - OUTPUT_CONFIGURATION_MSBUILD("Analysis", "Win32"); - OUTPUT_CONFIGURATION_MSBUILD("Analysis", "x64"); - OUTPUT_CONFIGURATION_MSBUILD("Release", "Win32"); - OUTPUT_CONFIGURATION_MSBUILD("Release", "x64"); + outputConfiguration(project, "Debug", "Win32"); + outputConfiguration(project, "Debug", "x64"); + outputConfiguration(project, "Analysis", "Win32"); + outputConfiguration(project, "Analysis", "x64"); + outputConfiguration(project, "Release", "Win32"); + outputConfiguration(project, "Release", "x64"); project << "\t\n"; @@ -99,23 +106,23 @@ void MSBuildProvider::createProjectFile(const std::string &name, const std::stri // Shared configuration project << "\t\n"; - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Release|Win32"); - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Analysis|Win32"); - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Debug|Win32"); - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Release|x64"); - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Analysis|x64"); - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Debug|x64"); + outputConfigurationType(project, name, "Release|Win32"); + outputConfigurationType(project, name, "Analysis|Win32"); + outputConfigurationType(project, name, "Debug|Win32"); + outputConfigurationType(project, name, "Release|x64"); + outputConfigurationType(project, name, "Analysis|x64"); + outputConfigurationType(project, name, "Debug|x64"); project << "\t\n" "\t\n" "\t\n"; - OUTPUT_PROPERTIES_MSBUILD("Release|Win32", PROJECT_DESCRIPTION "_Release.props"); - OUTPUT_PROPERTIES_MSBUILD("Analysis|Win32", PROJECT_DESCRIPTION "_Analysis.props"); - OUTPUT_PROPERTIES_MSBUILD("Debug|Win32", PROJECT_DESCRIPTION "_Debug.props"); - OUTPUT_PROPERTIES_MSBUILD("Release|x64", PROJECT_DESCRIPTION "_Release64.props"); - OUTPUT_PROPERTIES_MSBUILD("Analysis|x64", PROJECT_DESCRIPTION "_Analysis64.props"); - OUTPUT_PROPERTIES_MSBUILD("Debug|x64", PROJECT_DESCRIPTION "_Debug64.props"); + outputProperties(project, "Release|Win32", PROJECT_DESCRIPTION "_Release.props"); + outputProperties(project, "Analysis|Win32", PROJECT_DESCRIPTION "_Analysis.props"); + outputProperties(project, "Debug|Win32", PROJECT_DESCRIPTION "_Debug.props"); + outputProperties(project, "Release|x64", PROJECT_DESCRIPTION "_Release64.props"); + outputProperties(project, "Analysis|x64", PROJECT_DESCRIPTION "_Analysis64.props"); + outputProperties(project, "Debug|x64", PROJECT_DESCRIPTION "_Debug64.props"); project << "\t\n"; @@ -153,21 +160,6 @@ void MSBuildProvider::createProjectFile(const std::string &name, const std::stri createFiltersFile(setup, name); } -#define OUTPUT_FILTER_MSBUILD(files, action) \ - if (!files.empty()) { \ - filters << "\t\n"; \ - for (std::list::const_iterator entry = files.begin(); entry != files.end(); ++entry) { \ - if ((*entry).filter != "") { \ - filters << "\t\t<" action " Include=\"" << (*entry).path << "\">\n" \ - "\t\t\t" << (*entry).filter << "\n" \ - "\t\t\n"; \ - } else { \ - filters << "\t\t<" action " Include=\"" << (*entry).path << "\" />\n"; \ - } \ - } \ - filters << "\t\n"; \ - } - void MSBuildProvider::createFiltersFile(const BuildSetup &setup, const std::string &name) { // No filters => no need to create a filter file if (_filters.empty()) @@ -199,15 +191,31 @@ void MSBuildProvider::createFiltersFile(const BuildSetup &setup, const std::stri filters << "\t\n"; // Output files - OUTPUT_FILTER_MSBUILD(_compileFiles, "ClCompile") - OUTPUT_FILTER_MSBUILD(_includeFiles, "ClInclude") - OUTPUT_FILTER_MSBUILD(_otherFiles, "None") - OUTPUT_FILTER_MSBUILD(_resourceFiles, "ResourceCompile") - OUTPUT_FILTER_MSBUILD(_asmFiles, "CustomBuild") + outputFilter(filters, _compileFiles, "ClCompile"); + outputFilter(filters, _includeFiles, "ClInclude"); + outputFilter(filters, _otherFiles, "None"); + outputFilter(filters, _resourceFiles, "ResourceCompile"); + outputFilter(filters, _asmFiles, "CustomBuild"); filters << ""; } +void MSBuildProvider::outputFilter(std::ostream &filters, const FileEntries &files, const std::string &action) { + if (!files.empty()) { + filters << "\t\n"; + for (FileEntries::const_iterator entry = files.begin(), end = files.end(); entry != end; ++entry) { + if ((*entry).filter != "") { + filters << "\t\t<" << action << " Include=\"" << (*entry).path << "\">\n" + "\t\t\t" << (*entry).filter << "\n" + "\t\t\n"; + } else { + filters << "\t\t<" << action << " Include=\"" << (*entry).path << "\" />\n"; + } + } + filters << "\t\n"; + } +} + void MSBuildProvider::writeReferences(std::ofstream &output) { output << "\t\n"; @@ -398,19 +406,6 @@ void MSBuildProvider::createBuildProp(const BuildSetup &setup, bool isRelease, b properties.close(); } -#define OUTPUT_NASM_COMMAND_MSBUILD(config) \ - projectFile << "\t\t\tnasm.exe -f win32 -g -o \"$(IntDir)" << (isDuplicate ? (*entry).prefix : "") << "%(Filename).obj\" \"%(FullPath)\"\n" \ - "\t\t\t$(IntDir)" << (isDuplicate ? (*entry).prefix : "") << "%(Filename).obj;%(Outputs)\n"; - -#define OUPUT_FILES_MSBUILD(files, action) \ - if (!files.empty()) { \ - projectFile << "\t\n"; \ - for (std::list::const_iterator entry = files.begin(); entry != files.end(); ++entry) { \ - projectFile << "\t\t<" action " Include=\"" << (*entry).path << "\" />\n"; \ - } \ - projectFile << "\t\n"; \ - } - bool hasEnding(std::string const &fullString, std::string const &ending) { if (fullString.length() > ending.length()) { return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending)); @@ -419,6 +414,14 @@ bool hasEnding(std::string const &fullString, std::string const &ending) { } } +namespace { + +inline void outputNasmCommand(std::ostream &projectFile, const std::string &config, const std::string &prefix) { + projectFile << "\t\t\tnasm.exe -f win32 -g -o \"$(IntDir)" << prefix << "%(Filename).obj\" \"%(FullPath)\"\n" + "\t\t\t$(IntDir)" << prefix << "%(Filename).obj;%(Outputs)\n"; +} + +} // End of anonymous namespace void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int, const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) { @@ -455,9 +458,9 @@ void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream } // Output include, other and resource files - OUPUT_FILES_MSBUILD(_includeFiles, "ClInclude") - OUPUT_FILES_MSBUILD(_otherFiles, "None") - OUPUT_FILES_MSBUILD(_resourceFiles, "ResourceCompile") + outputFiles(projectFile, _includeFiles, "ClInclude"); + outputFiles(projectFile, _otherFiles, "None"); + outputFiles(projectFile, _resourceFiles, "ResourceCompile"); // Output asm files if (!_asmFiles.empty()) { @@ -469,9 +472,9 @@ void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream projectFile << "\t\t\n" "\t\t\tDocument\n"; - OUTPUT_NASM_COMMAND_MSBUILD("Debug") - OUTPUT_NASM_COMMAND_MSBUILD("Analysis") - OUTPUT_NASM_COMMAND_MSBUILD("Release") + outputNasmCommand(projectFile, "Debug", (isDuplicate ? (*entry).prefix : "")); + outputNasmCommand(projectFile, "Analysis", (isDuplicate ? (*entry).prefix : "")); + outputNasmCommand(projectFile, "Release", (isDuplicate ? (*entry).prefix : "")); projectFile << "\t\t\n"; } @@ -479,6 +482,16 @@ void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream } } +void MSBuildProvider::outputFiles(std::ostream &projectFile, const FileEntries &files, const std::string &action) { + if (!files.empty()) { + projectFile << "\t\n"; + for (FileEntries::const_iterator entry = files.begin(), end = files.end(); entry != end; ++entry) { + projectFile << "\t\t<" << action << " Include=\"" << (*entry).path << "\" />\n"; + } + projectFile << "\t\n"; + } +} + void MSBuildProvider::computeFileList(const FileNode &dir, const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) { for (FileNode::NodeList::const_iterator i = dir.children.begin(); i != dir.children.end(); ++i) { const FileNode *node = *i; diff --git a/devtools/create_project/msbuild.h b/devtools/create_project/msbuild.h index cc545e47559..98bb65e19be 100644 --- a/devtools/create_project/msbuild.h +++ b/devtools/create_project/msbuild.h @@ -75,6 +75,9 @@ private: void computeFileList(const FileNode &dir, const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix); void createFiltersFile(const BuildSetup &setup, const std::string &name); + + void outputFilter(std::ostream &filters, const FileEntries &files, const std::string &action); + void outputFiles(std::ostream &projectFile, const FileEntries &files, const std::string &action); }; } // End of CreateProjectTool namespace diff --git a/devtools/create_project/scripts/postbuild.cmd b/devtools/create_project/scripts/postbuild.cmd index 4bb352140a0..c5ecc3889c9 100644 --- a/devtools/create_project/scripts/postbuild.cmd +++ b/devtools/create_project/scripts/postbuild.cmd @@ -29,6 +29,8 @@ xcopy /F /Y "%~1/dists/engine-data/README" %~2 > NUL 2>&1 xcopy /F /Y "%~1/gui/themes/*.zip" %~2 > NUL 2>&1 xcopy /F /Y "%~1/gui/themes/translations.dat" %~2 > NUL 2>&1 xcopy /F /Y "%~4/lib/%~3/SDL.dll" %~2 > NUL 2>&1 + +xcopy /F /Y "%~1/backends/vkeybd/packs/vkeybd_default.zip" %~2 > NUL 2>&1 goto done :error_root diff --git a/devtools/create_project/visualstudio.cpp b/devtools/create_project/visualstudio.cpp index 2997e3096ad..77af8aeca13 100644 --- a/devtools/create_project/visualstudio.cpp +++ b/devtools/create_project/visualstudio.cpp @@ -57,42 +57,6 @@ int VisualStudioProvider::getVisualStudioVersion() { error("Unsupported version passed to getVisualStudioVersion"); } -#define OUTPUT_BUILD_EVENTS(isWin32) \ - if (setup.runBuildEvents) { \ - project << "\t\t\t\n" \ - "\t\t\t\n"; \ - } - -#define OUTPUT_CONFIGURATION_MAIN(config, platform, props, isWin32) { \ - project << "\t\t\n" \ - "\t\t\t\n" \ - "\t\t\t\n"; \ - OUTPUT_BUILD_EVENTS(isWin32) \ - project << "\t\t\n"; \ -} - -#define OUTPUT_CONFIGURATION_DEBUG(config, platform, props, isWin32) { \ - project << "\t\t\n" \ - "\t\t\t\n" \ - "\t\t\t\n"; \ - OUTPUT_BUILD_EVENTS(isWin32) \ - project << "\t\t\n"; \ -} - -#define OUTPUT_CONFIGURATION(config, platform, props) { \ - project << "\t\t\n" \ - "\t\t\t\n" \ - "\t\t\n"; \ -} - void VisualStudioProvider::createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, const StringList &includeList, const StringList &excludeList) { const std::string projectFile = setup.outputDir + '/' + name + getProjectExtension(); @@ -129,17 +93,17 @@ void VisualStudioProvider::createProjectFile(const std::string &name, const std: libraries += ' ' + *i + ".lib"; // Win32 - OUTPUT_CONFIGURATION_DEBUG("Debug", "Win32", "", true); - OUTPUT_CONFIGURATION_DEBUG("Analysis", "Win32", "", true); - OUTPUT_CONFIGURATION_MAIN("Release", "Win32", "", true); + outputConfiguration(project, setup, libraries, "Debug", "Win32", "", true); + outputConfiguration(project, setup, libraries, "Analysis", "Win32", "", true); + outputConfiguration(project, setup, libraries, "Release", "Win32", "", true); // x64 // For 'x64' we must disable NASM support. Usually we would need to disable the "nasm" feature for that and // re-create the library list, BUT since NASM doesn't link any additional libraries, we can just use the // libraries list created for IA-32. If that changes in the future, we need to adjust this part! - OUTPUT_CONFIGURATION_DEBUG("Debug", "x64", "64", false); - OUTPUT_CONFIGURATION_DEBUG("Analysis", "x64", "64", false); - OUTPUT_CONFIGURATION_MAIN("Release", "x64", "64", false); + outputConfiguration(project, setup, libraries, "Debug", "x64", "64", false); + outputConfiguration(project, setup, libraries, "Analysis", "x64", "64", false); + outputConfiguration(project, setup, libraries, "Release", "x64", "64", false); } else { std::string warnings = ""; @@ -154,12 +118,12 @@ void VisualStudioProvider::createProjectFile(const std::string &name, const std: toolConfig += (name == "grim" ? "DisableLanguageExtensions=\"false\" " : ""); // Win32 - OUTPUT_CONFIGURATION("Debug", "Win32", ""); - OUTPUT_CONFIGURATION("Analysis", "Win32", ""); - OUTPUT_CONFIGURATION("Release", "Win32", ""); - OUTPUT_CONFIGURATION("Debug", "x64", "64"); - OUTPUT_CONFIGURATION("Analysis", "x64", "64"); - OUTPUT_CONFIGURATION("Release", "x64", "64"); + outputConfiguration(project, toolConfig, "Debug", "Win32", ""); + outputConfiguration(project, toolConfig, "Analysis", "Win32", ""); + outputConfiguration(project, toolConfig, "Release", "Win32", ""); + outputConfiguration(project, toolConfig, "Debug", "x64", "64"); + outputConfiguration(project, toolConfig, "Analysis", "x64", "64"); + outputConfiguration(project, toolConfig, "Release", "x64", "64"); } project << "\t\n" @@ -181,6 +145,33 @@ void VisualStudioProvider::createProjectFile(const std::string &name, const std: "\n"; } +void VisualStudioProvider::outputConfiguration(std::ostream &project, const BuildSetup &setup, const std::string &libraries, const std::string &config, const std::string &platform, const std::string &props, const bool isWin32) { + project << "\t\t\n" + "\t\t\t\n" + "\t\t\t\n"; + outputBuildEvents(project, setup, isWin32); + project << "\t\t\n"; +} + +void VisualStudioProvider::outputConfiguration(std::ostream &project, const std::string &toolConfig, const std::string &config, const std::string &platform, const std::string &props) { + project << "\t\t\n" + "\t\t\t\n" + "\t\t\n"; +} + +void VisualStudioProvider::outputBuildEvents(std::ostream &project, const BuildSetup &setup, const bool isWin32) { + if (setup.runBuildEvents) { + project << "\t\t\t\n" + "\t\t\t\n"; + } +} + void VisualStudioProvider::writeReferences(std::ofstream &output) { output << "\tProjectSection(ProjectDependencies) = postProject\n"; @@ -298,7 +289,7 @@ void VisualStudioProvider::createBuildProp(const BuildSetup &setup, bool isRelea "\t\tRuntimeLibrary=\"1\"\n" "\t\tEnableFunctionLevelLinking=\"true\"\n" "\t\tWarnAsError=\"false\"\n" - "\t\tDebugInformationFormat=\"" << (isWin32 ? "4" : "3") << "\"\n" // For x64 format "4" (Edit and continue) is not supported, thus we default to "3" + "\t\tDebugInformationFormat=\"" << (isWin32 ? "4" : "3") << "\"\n" // For x64 format "4" (Edit and continue) is not supported, thus we default to "3" "\t\tAdditionalOption=\"" << (enableAnalysis ? "/analyze" : "") << "\"\n" "\t/>\n" "\tgameid) { - if (0 == strcasecmp(params.singleid, g->gameid)) { + if (0 == scumm_stricmp(params.singleid, g->gameid)) { gl.push_back(GameDescriptor(g->gameid, g->description)); return gl; @@ -124,7 +123,7 @@ GameDescriptor findGameID( if (obsoleteList != 0) { const ADObsoleteGameID *o = obsoleteList; while (o->from) { - if (0 == strcasecmp(gameid, o->from)) { + if (0 == scumm_stricmp(gameid, o->from)) { g = findPlainGameDescriptor(o->to, list); if (g && g->description) return GameDescriptor(gameid, "Obsolete game ID (" + Common::String(g->description) + ")"); @@ -150,7 +149,7 @@ static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGa extra = ""; } else { while (sg->gameid) { - if (!strcasecmp(g.gameid, sg->gameid)) + if (!scumm_stricmp(g.gameid, sg->gameid)) title = sg->description; sg++; } diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h index 515127b23db..757fb12f336 100644 --- a/engines/advancedDetector.h +++ b/engines/advancedDetector.h @@ -25,11 +25,13 @@ #ifndef ENGINES_ADVANCED_DETECTOR_H #define ENGINES_ADVANCED_DETECTOR_H -#include "common/fs.h" -#include "common/error.h" - #include "engines/metaengine.h" +namespace Common { +class Error; +class FSList; +} + struct ADGameFileDescription { const char *fileName; @@ -62,8 +64,8 @@ struct ADGameDescription { Common::Platform platform; /** - * A bitmask of extra flags. The top 8 bits are reserved for generic flags - * defined in the ADGameFlags. This leaves 24 flags to be used by client + * A bitmask of extra flags. The top 16 bits are reserved for generic flags + * defined in the ADGameFlags. This leaves 16 bits to be used by client * code. */ uint32 flags; diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp index 482126ae8ab..4a0d35a9823 100644 --- a/engines/dialogs.cpp +++ b/engines/dialogs.cpp @@ -25,21 +25,21 @@ #include "base/version.h" #include "common/config-manager.h" -#include "common/savefile.h" -#include "common/system.h" #include "common/events.h" +#include "common/str.h" +#include "common/system.h" #include "common/translation.h" -#include "graphics/scaler.h" - #include "gui/about.h" #include "gui/gui-manager.h" -#include "gui/launcher.h" -#include "gui/widgets/list.h" #include "gui/message.h" #include "gui/options.h" #include "gui/saveload.h" +#include "gui/ThemeEngine.h" #include "gui/ThemeEval.h" +#include "gui/widget.h" + +#include "graphics/font.h" #include "engines/dialogs.h" #include "engines/engine.h" diff --git a/engines/dialogs.h b/engines/dialogs.h index 6e5338b3171..587e91a2bbd 100644 --- a/engines/dialogs.h +++ b/engines/dialogs.h @@ -25,15 +25,15 @@ #ifndef GLOBAL_DIALOGS_H #define GLOBAL_DIALOGS_H -#include "common/str.h" #include "gui/dialog.h" class Engine; namespace GUI { - class ButtonWidget; - class GraphicsWidget; - class SaveLoadChooser; +class ButtonWidget; +class CommandSender; +class GraphicsWidget; +class SaveLoadChooser; } class MainMenuDialog : public GUI::Dialog { diff --git a/engines/engine.cpp b/engines/engine.cpp index c9228bdeb63..a0e94e0572a 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -32,25 +32,26 @@ #include "engines/engine.h" #include "engines/dialogs.h" -#include "engines/metaengine.h" -#include "engines/util.h" #include "common/config-manager.h" -#include "common/debug.h" #include "common/events.h" #include "common/file.h" -#include "common/timer.h" -#include "common/savefile.h" #include "common/system.h" #include "common/str.h" +#include "common/error.h" +#include "common/list.h" +#include "common/list_intern.h" +#include "common/scummsys.h" +#include "common/textconsole.h" #include "gui/debugger.h" +#include "gui/dialog.h" #include "gui/message.h" -#include "gui/gui-manager.h" #include "audio/mixer.h" #include "graphics/cursorman.h" +#include "graphics/pixelformat.h" #ifdef _WIN32_WCE extern bool isSmartphone(); @@ -275,10 +276,14 @@ void Engine::syncSoundSettings() { if (ConfMan.hasKey("mute")) mute = ConfMan.getBool("mute"); - _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, (mute ? 0 : Audio::Mixer::kMaxMixerVolume)); - _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, (mute ? 0 : soundVolumeMusic)); - _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, (mute ? 0 : soundVolumeSFX)); - _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, (mute ? 0 : soundVolumeSpeech)); + _mixer->muteSoundType(Audio::Mixer::kPlainSoundType, mute); + _mixer->muteSoundType(Audio::Mixer::kMusicSoundType, mute); + _mixer->muteSoundType(Audio::Mixer::kSFXSoundType, mute); + _mixer->muteSoundType(Audio::Mixer::kSpeechSoundType, mute); + _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, Audio::Mixer::kMaxMixerVolume); + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic); + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolumeSFX); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech); } void Engine::flipMute() { diff --git a/engines/engine.h b/engines/engine.h index 168a1dc2a0c..b7afc0f09dc 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -26,22 +26,22 @@ #define ENGINES_ENGINE_H #include "common/scummsys.h" -#include "common/error.h" #include "common/str.h" class OSystem; namespace Audio { - class Mixer; +class Mixer; } namespace Common { - class EventManager; - class SaveFileManager; - class TimerManager; +class Error; +class EventManager; +class SaveFileManager; +class TimerManager; } namespace GUI { - class Debugger; - class Dialog; +class Debugger; +class Dialog; } /** diff --git a/engines/game.cpp b/engines/game.cpp index 47cb5d895ea..a27080cbf87 100644 --- a/engines/game.cpp +++ b/engines/game.cpp @@ -24,13 +24,12 @@ */ #include "engines/game.h" -#include "base/plugins.h" const PlainGameDescriptor *findPlainGameDescriptor(const char *gameid, const PlainGameDescriptor *list) { const PlainGameDescriptor *g = list; while (g->gameid) { - if (0 == strcasecmp(gameid, g->gameid)) + if (0 == scumm_stricmp(gameid, g->gameid)) return g; g++; } diff --git a/engines/game.h b/engines/game.h index 3e5d7f262c2..c9a3b258539 100644 --- a/engines/game.h +++ b/engines/game.h @@ -28,6 +28,8 @@ #include "common/array.h" #include "common/hash-str.h" +#include "common/str.h" +#include "common/util.h" /** * A simple structure used to map gameids (like "monkey", "sword1", ...) to diff --git a/engines/metaengine.h b/engines/metaengine.h index 2afed0703bb..ef34506991d 100644 --- a/engines/metaengine.h +++ b/engines/metaengine.h @@ -37,8 +37,8 @@ class Engine; class OSystem; namespace Common { - class FSList; - class String; +class FSList; +class String; } /** diff --git a/engines/savestate.cpp b/engines/savestate.cpp index 368f59ef51c..bed19ba3e53 100644 --- a/engines/savestate.cpp +++ b/engines/savestate.cpp @@ -25,6 +25,7 @@ #include "engines/savestate.h" #include "graphics/surface.h" +#include "common/textconsole.h" void SaveStateDescriptor::setThumbnail(Graphics::Surface *t) { if (_thumbnail.get() == t) diff --git a/engines/savestate.h b/engines/savestate.h index 37f2b9bdd44..9b64a96aeed 100644 --- a/engines/savestate.h +++ b/engines/savestate.h @@ -32,7 +32,7 @@ namespace Graphics { - struct Surface; +struct Surface; } /** diff --git a/graphics/font.cpp b/graphics/font.cpp index 359374436c1..9d450e881c5 100644 --- a/graphics/font.cpp +++ b/graphics/font.cpp @@ -25,7 +25,11 @@ #include "common/stream.h" #include "common/file.h" #include "common/endian.h" +#include "common/array.h" +#include "common/textconsole.h" +#include "common/util.h" #include "graphics/font.h" +#include "graphics/surface.h" namespace Graphics { diff --git a/graphics/font.h b/graphics/font.h index b1a47352491..9e6e180ec39 100644 --- a/graphics/font.h +++ b/graphics/font.h @@ -26,15 +26,16 @@ #define GRAPHICS_FONT_H #include "common/str.h" -#include "common/array.h" -#include "graphics/surface.h" namespace Common { class SeekableReadStream; +template class Array; } namespace Graphics { +struct Surface; + /** Text alignment modes */ enum TextAlign { kTextAlignInvalid, diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp index 64a7dc48226..bbd75bfca2b 100644 --- a/graphics/fontman.cpp +++ b/graphics/fontman.cpp @@ -22,6 +22,7 @@ * $Id$ */ +#include "graphics/font.h" #include "graphics/fontman.h" DECLARE_SINGLETON(Graphics::FontManager); @@ -76,7 +77,7 @@ const struct { const Font *FontManager::getFontByName(const Common::String &name) const { for (int i = 0; builtinFontNames[i].name; i++) - if (!strcasecmp(name.c_str(), builtinFontNames[i].name)) + if (!scumm_stricmp(name.c_str(), builtinFontNames[i].name)) return getFontByUsage(builtinFontNames[i].id); if (!_fontMap.contains(name)) diff --git a/graphics/fontman.h b/graphics/fontman.h index 7871f32ba9b..34b457ae83c 100644 --- a/graphics/fontman.h +++ b/graphics/fontman.h @@ -30,11 +30,12 @@ #include "common/str.h" #include "common/hashmap.h" #include "common/hash-str.h" -#include "graphics/font.h" namespace Graphics { +class Font; + class FontManager : public Common::Singleton { public: enum FontUsage { diff --git a/graphics/fonts/scummfont.cpp b/graphics/fonts/scummfont.cpp index 87078e1475c..ea1935cea55 100644 --- a/graphics/fonts/scummfont.cpp +++ b/graphics/fonts/scummfont.cpp @@ -23,6 +23,7 @@ */ #include "graphics/font.h" +#include "graphics/surface.h" namespace Graphics { diff --git a/graphics/imagedec.cpp b/graphics/imagedec.cpp index a4d2fbc1cf9..91da83cc634 100644 --- a/graphics/imagedec.cpp +++ b/graphics/imagedec.cpp @@ -23,6 +23,7 @@ */ #include "graphics/imagedec.h" +#include "graphics/pixelformat.h" #include "graphics/surface.h" #include "common/file.h" diff --git a/graphics/imagedec.h b/graphics/imagedec.h index 13aa63a153d..7ea987b1e42 100644 --- a/graphics/imagedec.h +++ b/graphics/imagedec.h @@ -28,14 +28,13 @@ #include "common/scummsys.h" #include "common/str.h" -#include "graphics/pixelformat.h" - namespace Common{ class SeekableReadStream; } namespace Graphics { +struct PixelFormat; struct Surface; class ImageDecoder { diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 2ccabfcb1bb..83a69387547 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -24,7 +24,6 @@ */ #include "common/system.h" -#include "common/events.h" #include "common/config-manager.h" #include "common/file.h" #include "common/fs.h" @@ -32,14 +31,13 @@ #include "common/tokenizer.h" #include "common/translation.h" -#include "graphics/colormasks.h" #include "graphics/cursorman.h" #include "graphics/fontman.h" #include "graphics/imagedec.h" #include "graphics/surface.h" #include "graphics/VectorRenderer.h" -#include "gui/launcher.h" +#include "gui/widget.h" #include "gui/ThemeEngine.h" #include "gui/ThemeEval.h" #include "gui/ThemeParser.h" @@ -791,6 +789,7 @@ bool ThemeEngine::loadThemeXML(const Common::String &themeId) { } + /********************************************************** * Drawing Queue management *********************************************************/ @@ -1500,6 +1499,12 @@ Common::String ThemeEngine::genLocalizedFontFilename(const Common::String &filen *********************************************************/ bool ThemeEngine::themeConfigParseHeader(Common::String header, Common::String &themeName) { + // Check that header is not corrupted + if ((byte)header[0] > 127) { + warning("Corrupted theme header found"); + return false; + } + header.trim(); if (header.empty()) diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index a2b0ee872f8..27d4e37740a 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -27,13 +27,25 @@ #define GUI_THEME_ENGINE_H #include "common/scummsys.h" -#include "common/system.h" #include "common/fs.h" +#include "common/hash-str.h" +#include "common/hashmap.h" +#include "common/list.h" +#include "common/str.h" + #include "graphics/surface.h" #include "graphics/font.h" +#include "graphics/pixelformat.h" + #define RESIDUAL_THEME_VERSION_STR "RESIDUAL_STX0.8.3" +class OSystem; + +namespace Common { +struct Rect; +} + namespace Graphics { struct DrawStep; class VectorRenderer; @@ -42,8 +54,6 @@ class VectorRenderer; namespace GUI { struct WidgetDrawData; -struct DrawDataInfo; -struct TextDataInfo; struct TextDrawData; struct TextColorData; class Dialog; diff --git a/gui/ThemeEval.cpp b/gui/ThemeEval.cpp index 017d47fd298..64e18f93a3c 100644 --- a/gui/ThemeEval.cpp +++ b/gui/ThemeEval.cpp @@ -24,10 +24,10 @@ */ #include "gui/ThemeEval.h" -#include "gui/widget.h" #include "graphics/scaler.h" +#include "common/system.h" #include "common/tokenizer.h" namespace GUI { diff --git a/gui/ThemeLayout.cpp b/gui/ThemeLayout.cpp index 3c930db73c2..fbfc498bcb3 100644 --- a/gui/ThemeLayout.cpp +++ b/gui/ThemeLayout.cpp @@ -25,14 +25,12 @@ #include "common/util.h" #include "common/system.h" -#include "common/events.h" -#include "common/xmlparser.h" -#include "gui/ThemeEval.h" #include "gui/ThemeLayout.h" -#ifdef LAYOUT_DEBUG_DIALOG #include "graphics/font.h" + +#ifdef LAYOUT_DEBUG_DIALOG #include "graphics/surface.h" #endif diff --git a/gui/ThemeLayout.h b/gui/ThemeLayout.h index 3d367df147d..76d3f7d3802 100644 --- a/gui/ThemeLayout.h +++ b/gui/ThemeLayout.h @@ -26,12 +26,13 @@ #ifndef THEME_LAYOUT_H #define THEME_LAYOUT_H +#include "common/array.h" #include "common/rect.h" +#include "graphics/font.h" #ifdef LAYOUT_DEBUG_DIALOG namespace Graphics { - class Font; - class Surface; +class Surface; } #endif diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp index e3523d11e83..230dad8cc57 100644 --- a/gui/ThemeParser.cpp +++ b/gui/ThemeParser.cpp @@ -26,10 +26,10 @@ #include "gui/ThemeEngine.h" #include "gui/ThemeEval.h" #include "gui/ThemeParser.h" -#include "gui/gui-manager.h" #include "graphics/VectorRenderer.h" +#include "common/system.h" #include "common/tokenizer.h" namespace GUI { diff --git a/gui/Tooltip.cpp b/gui/Tooltip.cpp index 7dec12d522a..a7cb0610e7f 100644 --- a/gui/Tooltip.cpp +++ b/gui/Tooltip.cpp @@ -23,7 +23,6 @@ */ #include "common/util.h" -#include "graphics/fontman.h" #include "gui/widget.h" #include "gui/dialog.h" #include "gui/gui-manager.h" diff --git a/gui/Tooltip.h b/gui/Tooltip.h index d228ca8a49a..f5e2bb08a88 100644 --- a/gui/Tooltip.h +++ b/gui/Tooltip.h @@ -25,11 +25,14 @@ #ifndef GUI_TOOLTIP_H #define GUI_TOOLTIP_H +#include "common/keyboard.h" +#include "common/str-array.h" #include "gui/dialog.h" -#include "gui/widget.h" namespace GUI { +class Widget; + class Tooltip : public Dialog { public: Tooltip(); diff --git a/gui/about.cpp b/gui/about.cpp index 7005f067348..239319deb7c 100644 --- a/gui/about.cpp +++ b/gui/about.cpp @@ -31,8 +31,6 @@ #include "common/util.h" #include "gui/about.h" #include "gui/gui-manager.h" -#include "gui/widget.h" - #include "gui/ThemeEval.h" namespace GUI { diff --git a/gui/about.h b/gui/about.h index fc216a78dc9..b49365c5e5a 100644 --- a/gui/about.h +++ b/gui/about.h @@ -27,7 +27,8 @@ #include "gui/dialog.h" #include "common/str.h" -#include "graphics/surface.h" +#include "common/array.h" +#include "common/keyboard.h" namespace GUI { diff --git a/gui/browser.cpp b/gui/browser.cpp index 4ee6bafdded..2c7459623fc 100644 --- a/gui/browser.cpp +++ b/gui/browser.cpp @@ -23,7 +23,6 @@ */ #include "gui/browser.h" -#include "gui/gui-manager.h" #include "gui/widgets/list.h" #include "common/config-manager.h" diff --git a/gui/browser.h b/gui/browser.h index 1fef041a5a1..eb3498e654a 100644 --- a/gui/browser.h +++ b/gui/browser.h @@ -26,13 +26,13 @@ #define BROWSER_DIALOG_H #include "gui/dialog.h" -#include "common/str.h" #include "common/fs.h" namespace GUI { class ListWidget; class StaticTextWidget; +class CommandSender; class BrowserDialog : public Dialog { public: diff --git a/gui/chooser.cpp b/gui/chooser.cpp index f5e7d26a32b..ecc8ebd8941 100644 --- a/gui/chooser.cpp +++ b/gui/chooser.cpp @@ -22,10 +22,9 @@ * $Id$ */ -#include "common/system.h" #include "common/translation.h" #include "gui/chooser.h" -#include "gui/gui-manager.h" +#include "gui/widget.h" #include "gui/widgets/list.h" namespace GUI { diff --git a/gui/chooser.h b/gui/chooser.h index ce67c008df0..79a20383c5d 100644 --- a/gui/chooser.h +++ b/gui/chooser.h @@ -25,12 +25,14 @@ #ifndef CHOOSER_DIALOG_H #define CHOOSER_DIALOG_H +#include "common/array.h" #include "common/str.h" #include "gui/dialog.h" namespace GUI { class ButtonWidget; +class CommandSender; class ListWidget; /* diff --git a/gui/console.cpp b/gui/console.cpp index c5728324fb3..85ca1da291b 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -27,10 +27,8 @@ #include "gui/ThemeEval.h" #include "gui/gui-manager.h" -#include "engines/engine.h" #include "base/version.h" -#include "common/events.h" #include "common/system.h" #include "graphics/fontman.h" diff --git a/gui/debugger.cpp b/gui/debugger.cpp index f113206ea11..2282bc3a1ca 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -26,7 +26,6 @@ // NB: This is really only necessary if USE_READLINE is defined #define FORBIDDEN_SYMBOL_ALLOW_ALL -#include "common/debug.h" #include "common/debug-channels.h" #include "common/system.h" diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 2c2b0603d65..15e47141c81 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -22,14 +22,11 @@ * $Id$ */ -#include "common/events.h" +#include "common/rect.h" #include "gui/gui-manager.h" #include "gui/dialog.h" #include "gui/widget.h" -#include "gui/widgets/popup.h" - -#include "common/system.h" namespace GUI { diff --git a/gui/dialog.h b/gui/dialog.h index 18457860440..c298ef107bd 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -27,14 +27,14 @@ #include "common/scummsys.h" #include "common/str.h" +#include "common/keyboard.h" #include "gui/object.h" -#include "gui/widget.h" +#include "gui/ThemeEngine.h" namespace GUI { -class GuiManager; -class PopUpWidget; +class Widget; // Some "common" commands sent to handleCommand() enum { diff --git a/gui/error.cpp b/gui/error.cpp index 3332eb533a7..f6da795d402 100644 --- a/gui/error.cpp +++ b/gui/error.cpp @@ -36,10 +36,10 @@ void displayErrorDialog(const char *text) { alert.runModal(); } -void displayErrorDialog(Common::Error error, const char *extraText) { +void displayErrorDialog(const Common::Error &error, const char *extraText) { Common::String errorText(extraText); errorText += " "; - errorText += _(Common::errorToString(error)); + errorText += _(error.getDesc()); GUI::MessageDialog alert(errorText); alert.runModal(); } diff --git a/gui/error.h b/gui/error.h index a55f555bed3..f048a0cd09e 100644 --- a/gui/error.h +++ b/gui/error.h @@ -36,7 +36,7 @@ namespace GUI { * @param error error code * @param extraText extra text to be displayed in addition to default string description(optional) */ -void displayErrorDialog(Common::Error error, const char *extraText = ""); +void displayErrorDialog(const Common::Error &error, const char *extraText = ""); /** * Displays an error dialog for a given message. diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index 7c87cc2798e..1453024c388 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -27,7 +27,8 @@ #include "common/util.h" #include "common/config-manager.h" #include "common/algorithm.h" -#include "common/timer.h" +#include "common/rect.h" +#include "common/textconsole.h" #include "common/translation.h" #include "backends/keymapper/keymapper.h" @@ -37,6 +38,7 @@ #include "gui/ThemeEngine.h" #include "gui/ThemeEval.h" #include "gui/Tooltip.h" +#include "gui/widget.h" #include "graphics/cursorman.h" diff --git a/gui/gui-manager.h b/gui/gui-manager.h index a6c90bfe8dc..ac4118bb06f 100644 --- a/gui/gui-manager.h +++ b/gui/gui-manager.h @@ -30,13 +30,14 @@ #include "common/stack.h" #include "common/str.h" -#include "graphics/font.h" - -#include "gui/widget.h" #include "gui/ThemeEngine.h" class OSystem; +namespace Graphics { +class Font; +} + namespace GUI { class Dialog; diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 429b784d5b7..3c91647ccbd 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -28,7 +28,6 @@ #include "common/events.h" #include "common/fs.h" #include "common/util.h" -#include "common/savefile.h" #include "common/system.h" #include "common/translation.h" @@ -49,9 +48,6 @@ #include "graphics/cursorman.h" -#include "audio/mididrv.h" - - using Common::ConfigManager; namespace GUI { @@ -701,7 +697,7 @@ void LauncherDialog::updateListing() { // Insert the game into the launcher list int pos = 0, size = l.size(); - while (pos < size && (strcasecmp(description.c_str(), l[pos].c_str()) > 0)) + while (pos < size && (scumm_stricmp(description.c_str(), l[pos].c_str()) > 0)) pos++; l.insert_at(pos, description); _domains.insert_at(pos, iter->_key); diff --git a/gui/launcher.h b/gui/launcher.h index df9a6fb6390..274fc45bb48 100644 --- a/gui/launcher.h +++ b/gui/launcher.h @@ -31,10 +31,13 @@ namespace GUI { class BrowserDialog; +class CommandSender; class ListWidget; +class ButtonWidget; class GraphicsWidget; -class SaveLoadChooser; +class StaticTextWidget; class EditTextWidget; +class SaveLoadChooser; Common::String addGameToConf(const GameDescriptor &result); diff --git a/gui/massadd.cpp b/gui/massadd.cpp index 197caae6755..c5af6c6bb4e 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -24,14 +24,13 @@ #include "engines/metaengine.h" #include "common/algorithm.h" -#include "common/events.h" -#include "common/func.h" #include "common/config-manager.h" +#include "common/debug.h" +#include "common/system.h" #include "common/translation.h" #include "gui/launcher.h" // For addGameToConf() #include "gui/massadd.h" -#include "gui/gui-manager.h" #include "gui/widget.h" #include "gui/widgets/list.h" diff --git a/gui/massadd.h b/gui/massadd.h index 31a8821a262..3dbab43df18 100644 --- a/gui/massadd.h +++ b/gui/massadd.h @@ -30,7 +30,6 @@ #include "common/hashmap.h" #include "common/stack.h" #include "common/str.h" -#include "common/hash-str.h" namespace GUI { diff --git a/gui/message.cpp b/gui/message.cpp index 2d097a75a96..5cb4cec3d3c 100644 --- a/gui/message.cpp +++ b/gui/message.cpp @@ -22,7 +22,6 @@ * $Id$ */ -#include "common/events.h" #include "common/str.h" #include "common/system.h" #include "gui/message.h" diff --git a/gui/message.h b/gui/message.h index 912e3b07857..5c3308e4256 100644 --- a/gui/message.h +++ b/gui/message.h @@ -30,6 +30,8 @@ namespace GUI { +class CommandSender; + enum { kMessageOK = 1, kMessageCancel = 0 diff --git a/gui/object.cpp b/gui/object.cpp index bf8e7a86426..6564fe2b68c 100644 --- a/gui/object.cpp +++ b/gui/object.cpp @@ -22,7 +22,8 @@ * $Id$ */ -#include "common/system.h" +#include "common/textconsole.h" + #include "gui/object.h" #include "gui/widget.h" #include "gui/gui-manager.h" diff --git a/gui/object.h b/gui/object.h index fb5ff18290e..3b181fd8a34 100644 --- a/gui/object.h +++ b/gui/object.h @@ -25,9 +25,11 @@ #ifndef GUI_OBJECT_H #define GUI_OBJECT_H +#include "common/scummsys.h" +#include "common/str.h" + namespace GUI { -class CommandReceiver; class CommandSender; class CommandReceiver { diff --git a/gui/options.cpp b/gui/options.cpp index e2367efb23a..deaf5f09bf1 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -24,10 +24,8 @@ #include "gui/browser.h" #include "gui/themebrowser.h" -#include "gui/chooser.h" #include "gui/message.h" #include "gui/gui-manager.h" -#include "gui/ThemeEval.h" #include "gui/options.h" #include "gui/widgets/popup.h" #include "gui/widgets/tab.h" @@ -35,10 +33,9 @@ #include "common/fs.h" #include "common/config-manager.h" #include "common/system.h" +#include "common/textconsole.h" #include "common/translation.h" -#include "graphics/scaler.h" - #include "audio/mididrv.h" #include "audio/musicplugin.h" #include "audio/mixer.h" @@ -144,6 +141,7 @@ void OptionsDialog::init() { _subSpeedDesc = 0; _subSpeedSlider = 0; _subSpeedLabel = 0; + _oldTheme = ConfMan.get("gui_theme"); // Retrieve game GUI options _guioptions = 0; @@ -363,6 +361,13 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data setResult(1); close(); break; + case kCloseCmd: + if (g_gui.theme()->getThemeId() != _oldTheme) { + g_gui.loadNewTheme(_oldTheme); + ConfMan.set("gui_theme", _oldTheme); + } + close(); + break; default: Dialog::handleCommand(sender, cmd, data); } @@ -1127,7 +1132,6 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 #ifdef USE_TRANSLATION Common::String lang = TransMan.getCurrentLanguage(); #endif - Common::String oldTheme = g_gui.theme()->getThemeId(); if (g_gui.loadNewTheme(theme)) { #ifdef USE_TRANSLATION // If the charset has changed, it means the font were not found for the @@ -1135,7 +1139,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 // language without restarting, we let the user know about this. if (lang != TransMan.getCurrentLanguage()) { TransMan.setLanguage(lang.c_str()); - g_gui.loadNewTheme(oldTheme); + g_gui.loadNewTheme(_oldTheme); MessageDialog error(_("The theme you selected does not support your current language. If you want to use this theme you need to switch to another language first.")); error.runModal(); } else { diff --git a/gui/options.h b/gui/options.h index eba1779b69a..c097a3a9e9a 100644 --- a/gui/options.h +++ b/gui/options.h @@ -27,7 +27,7 @@ #include "gui/dialog.h" #include "common/str.h" -#include "audio/musicplugin.h" +#include "audio/mididrv.h" #ifdef SMALL_SCREEN_DEVICE #include "gui/KeysDialog.h" @@ -35,13 +35,16 @@ namespace GUI { -class BrowserDialog; class CheckboxWidget; class PopUpWidget; class SliderWidget; class StaticTextWidget; -class ListWidget; class TabWidget; +class ButtonWidget; +class CommandSender; +class GuiObject; +class RadiobuttonGroup; +class RadiobuttonWidget; class OptionsDialog : public Dialog { public: @@ -174,6 +177,11 @@ protected: // uint32 _guioptions; Common::String _guioptionsString; + + // + //Theme Options + // + Common::String _oldTheme; }; diff --git a/gui/saveload.h b/gui/saveload.h index b3622c1f138..06f1251e11d 100644 --- a/gui/saveload.h +++ b/gui/saveload.h @@ -32,6 +32,10 @@ namespace GUI { class ListWidget; class GraphicsWidget; +class ButtonWidget; +class CommandSender; +class ContainerWidget; +class StaticTextWidget; class SaveLoadChooser : GUI::Dialog { typedef Common::String String; diff --git a/gui/themebrowser.h b/gui/themebrowser.h index aba519886d5..bd6b11fb46e 100644 --- a/gui/themebrowser.h +++ b/gui/themebrowser.h @@ -33,8 +33,8 @@ namespace GUI { +class CommandSender; class ListWidget; -class StaticTextWidget; class ThemeBrowser : public Dialog { public: diff --git a/gui/themes/modern.zip b/gui/themes/modern.zip index 6a6e6038642..eef119ba6b0 100644 Binary files a/gui/themes/modern.zip and b/gui/themes/modern.zip differ diff --git a/gui/themes/modern/modern_gfx.stx b/gui/themes/modern/modern_gfx.stx index f41bb4650ca..6ee70adf232 100644 --- a/gui/themes/modern/modern_gfx.stx +++ b/gui/themes/modern/modern_gfx.stx @@ -1,8 +1,8 @@ -