~ubuntu-branches/ubuntu/raring/scummvm/raring

« back to all changes in this revision

Viewing changes to engines/engine.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Moritz Muehlenhoff
  • Date: 2011-05-25 19:02:23 UTC
  • mto: (21.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: james.westby@ubuntu.com-20110525190223-fiqm0oaec714xk31
Tags: upstream-1.3.0
ImportĀ upstreamĀ versionĀ 1.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * along with this program; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
20
 *
21
 
 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-1-2-1/engines/engine.cpp $
22
 
 * $Id: engine.cpp 50963 2010-07-17 18:38:42Z fingolfin $
 
21
 * $URL$
 
22
 * $Id$
23
23
 */
24
24
 
25
25
#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
32
32
 
33
33
#include "engines/engine.h"
34
34
#include "engines/dialogs.h"
35
 
#include "engines/metaengine.h"
36
 
#include "engines/util.h"
37
35
 
38
36
#include "common/config-manager.h"
39
 
#include "common/debug.h"
40
37
#include "common/events.h"
41
38
#include "common/file.h"
42
 
#include "common/timer.h"
43
 
#include "common/savefile.h"
44
39
#include "common/system.h"
45
40
#include "common/str.h"
 
41
#include "common/error.h"
 
42
#include "common/list.h"
 
43
#include "common/list_intern.h"
 
44
#include "common/scummsys.h"
 
45
#include "common/textconsole.h"
46
46
 
47
47
#include "gui/debugger.h"
 
48
#include "gui/dialog.h"
48
49
#include "gui/message.h"
49
 
#include "gui/GuiManager.h"
50
50
 
51
 
#include "sound/mixer.h"
 
51
#include "audio/mixer.h"
52
52
 
53
53
#include "graphics/cursorman.h"
 
54
#include "graphics/pixelformat.h"
54
55
 
55
56
#ifdef _WIN32_WCE
56
57
extern bool isSmartphone();
94
95
                _saveFileMan(_system->getSavefileManager()),
95
96
                _targetName(ConfMan.getActiveDomainName()),
96
97
                _pauseLevel(0),
 
98
                _pauseStartTime(0),
 
99
                _engineStartTime(_system->getMillis()),
97
100
                _mainMenuDialog(NULL) {
98
101
 
99
102
        g_engine = this;
100
 
        Common::setDebugOutputFormatter(defaultOutputFormatter);
101
103
        Common::setErrorOutputFormatter(defaultOutputFormatter);
102
104
        Common::setErrorHandler(defaultErrorHandler);
103
105
 
110
112
        // heaps of (sound) memory get allocated but never freed. Of course,
111
113
        // there still would be problems with many games...
112
114
        if (!_mixer->isReady())
113
 
                warning("Sound initialization failed. This may cause severe problems in some games.");
 
115
                warning("Sound initialization failed. This may cause severe problems in some games");
114
116
 
115
117
        // Setup a dummy cursor and palette, so that all engines can use
116
118
        // CursorMan.replace without having any headaches about memory leaks.
144
146
        assert(transientDomain);
145
147
 
146
148
        const bool useDefaultGraphicsMode =
147
 
                !transientDomain->contains("gfx_mode") &&
 
149
                (!transientDomain->contains("gfx_mode") ||
 
150
                !scumm_stricmp(transientDomain->getVal("gfx_mode").c_str(), "normal") ||
 
151
                !scumm_stricmp(transientDomain->getVal("gfx_mode").c_str(), "default")
 
152
                )
 
153
                 &&
148
154
                (
149
155
                !gameDomain ||
150
156
                !gameDomain->contains("gfx_mode") ||
154
160
 
155
161
        // See if the game should default to 1x scaler
156
162
        if (useDefaultGraphicsMode && defaultTo1XScaler) {
157
 
                // FIXME: As a hack, we use "1x" here. Would be nicer to use
158
 
                // getDefaultGraphicsMode() instead, but right now, we do not specify
159
 
                // whether that is a 1x scaler or not...
160
 
                g_system->setGraphicsMode("1x");
 
163
                g_system->resetGraphicsScale();
161
164
        } else {
162
165
                // Override global scaler with any game-specific define
163
166
                if (ConfMan.hasKey("gfx_mode")) {
279
282
        initGraphics(width, height, defaultTo1xScaler, &format);
280
283
}
281
284
 
282
 
void GUIErrorMessage(const Common::String msg) {
 
285
void GUIErrorMessage(const Common::String &msg) {
283
286
        g_system->setWindowCaption("Error");
284
287
        g_system->beginGFXTransaction();
285
288
                initCommonGFX(false);
380
383
                _pauseLevel--;
381
384
 
382
385
        if (_pauseLevel == 1 && pause) {
 
386
                _pauseStartTime = _system->getMillis();
383
387
                pauseEngineIntern(true);
384
388
        } else if (_pauseLevel == 0) {
385
389
                pauseEngineIntern(false);
 
390
                _engineStartTime += _system->getMillis() - _pauseStartTime;
 
391
                _pauseStartTime = 0;
386
392
        }
387
393
}
388
394
 
398
404
        syncSoundSettings();
399
405
}
400
406
 
 
407
uint32 Engine::getTotalPlayTime() const {
 
408
        if (!_pauseLevel)
 
409
                return _system->getMillis() - _engineStartTime;
 
410
        else
 
411
                return _pauseStartTime - _engineStartTime;
 
412
}
 
413
 
 
414
void Engine::setTotalPlayTime(uint32 time) {
 
415
        const uint32 currentTime = _system->getMillis();
 
416
 
 
417
        // We need to reset the pause start time here in case the engine is already
 
418
        // paused to avoid any incorrect play time counting.
 
419
        if (_pauseLevel > 0)
 
420
                _pauseStartTime = currentTime;
 
421
 
 
422
        _engineStartTime = currentTime - time;
 
423
}
 
424
 
401
425
int Engine::runDialog(GUI::Dialog &dialog) {
402
426
        pauseEngine(true);
403
427
        int result = dialog.runModal();
407
431
}
408
432
 
409
433
void Engine::syncSoundSettings() {
410
 
 
411
434
        // Sync the engine with the config manager
412
435
        int soundVolumeMusic = ConfMan.getInt("music_volume");
413
436
        int soundVolumeSFX = ConfMan.getInt("sfx_volume");
417
440
        if (ConfMan.hasKey("mute"))
418
441
                mute = ConfMan.getBool("mute");
419
442
 
420
 
        _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, (mute ? 0 : soundVolumeMusic));
421
 
        _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, (mute ? 0 : soundVolumeSFX));
422
 
        _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, (mute ? 0 : soundVolumeSpeech));
 
443
        _mixer->muteSoundType(Audio::Mixer::kPlainSoundType, mute);
 
444
        _mixer->muteSoundType(Audio::Mixer::kMusicSoundType, mute);
 
445
        _mixer->muteSoundType(Audio::Mixer::kSFXSoundType, mute);
 
446
        _mixer->muteSoundType(Audio::Mixer::kSpeechSoundType, mute);
 
447
        _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, Audio::Mixer::kMaxMixerVolume);
 
448
        _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic);
 
449
        _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolumeSFX);
 
450
        _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech);
423
451
}
424
452
 
425
453
void Engine::flipMute() {