Ticket #9121: dott_mm.patch

File dott_mm.patch, 8.6 KB (added by SF/tobigun, 14 years ago)
  • backends/events/default/default-events.h

     
    9090        virtual int shouldQuit() const { return _shouldQuit; }
    9191        virtual int shouldRTL() const { return _shouldRTL; }
    9292        virtual void resetRTL() { _shouldRTL = false; }
    93 #ifdef FORCE_RTL
    9493        virtual void resetQuit() { _shouldQuit = false; }
    95 #endif
    9694
    9795#ifdef ENABLE_KEYMAPPER
    9896        virtual Common::Keymapper *getKeymapper() { return _keymapper; }
  • base/main.cpp

     
    393393                                // TODO: Show an informative error dialog if starting the selected game failed.
    394394                        }
    395395
     396                        bool forceRTL = false;
     397                        #ifdef FORCE_RTL
     398                        forceRTL = true;
     399                        #endif
     400                        if (ConfMan.hasNextDomain())
     401                                forceRTL = true;
     402
    396403                        // Quit unless an error occurred, or Return to launcher was requested
    397                         #ifndef FORCE_RTL
    398                         if (result == 0 && !g_system->getEventManager()->shouldRTL())
     404                        if (result == 0 && !forceRTL && !g_system->getEventManager()->shouldRTL())
    399405                                break;
    400                         #endif
     406
    401407                        // Reset RTL flag in case we want to load another engine
    402408                        g_system->getEventManager()->resetRTL();
    403                         #ifdef FORCE_RTL
    404                         g_system->getEventManager()->resetQuit();
    405                         #endif
     409                        if (forceRTL)
     410                                g_system->getEventManager()->resetQuit();
    406411
     412                        Common::ConfigManager::Domain *transientDomain = ConfMan.getDomain(Common::ConfigManager::kTransientDomain);
     413
    407414                        // Discard any command line options. It's unlikely that the user
    408415                        // wanted to apply them to *all* games ever launched.
    409                         ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
     416                        transientDomain->clear();
    410417
    411                         // Clear the active config domain
    412                         ConfMan.setActiveDomain("");
     418                        // setup the domain
     419                        if (ConfMan.hasNextDomain()) {
     420                                // set active domain to next pending domain
     421                                Common::ConfigManager::DomainQueueEntry nextDomain = ConfMan.dequeueNextDomain();
     422                                ConfMan.setActiveDomain(nextDomain.getName());
    413423
     424                                // set transient options
     425                                const Common::StringMap &transientOptions = nextDomain.getTransientOptions();
     426                                Common::StringMap::const_iterator iter;
     427                                for (iter = transientOptions.begin(); iter != transientOptions.end(); ++iter) {
     428                                        transientDomain->setVal(iter->_key, iter->_value);
     429                                }
     430                        } else {
     431                                // Clear the active config domain
     432                                ConfMan.setActiveDomain("");
     433                        }
     434
    414435                        // PluginManager::instance().unloadPlugins();
    415436                        PluginManager::instance().loadPlugins();
    416437                } else {
     
    430451
    431452                // reset the graphics to default
    432453                setupGraphics(system);
    433                 launcherDialog();
     454                if (0 == ConfMan.getActiveDomain()) {
     455                        launcherDialog();
     456                }
    434457        }
    435458        PluginManager::instance().unloadPlugins();
    436459        PluginManager::destroy();
  • common/config-manager.cpp

     
    632632        return isValidDomainName(domName) && _gameDomains.contains(domName);
    633633}
    634634
     635void ConfigManager::enqueueNextDomain(const String &domName, const StringMap &transientOptions) {
     636        DomainQueueEntry entry(domName, transientOptions);
     637        _domainQueue.push_back(entry);
     638}
    635639
     640ConfigManager::DomainQueueEntry ConfigManager::dequeueNextDomain() {
     641        if (_domainQueue.empty())
     642                return DomainQueueEntry();
     643        else
     644                return _domainQueue.remove_at(0);
     645}
     646
     647
    636648#pragma mark -
    637649
    638650
  • common/config-manager.h

     
    6868
    6969        typedef HashMap<String, Domain, IgnoreCase_Hash, IgnoreCase_EqualTo> DomainMap;
    7070
     71        class DomainQueueEntry {
     72        private:
     73                String _domainName;
     74                StringMap _transientOptions;
     75        public:
     76                DomainQueueEntry()
     77                        : _domainName("") {}
     78                DomainQueueEntry(const String &domName, const StringMap &transientOptions)
     79                        : _domainName(domName), _transientOptions(transientOptions) {}
     80                const String &getName() { return _domainName; }
     81                const StringMap &getTransientOptions() { return _transientOptions; }
     82        };
     83
    7184#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
    7285        /** The name of the application domain (normally 'scummvm'). */
    7386        static const String kApplicationDomain;
     
    150163        const Domain *          getActiveDomain() const { return _activeDomain; }
    151164        const String &          getActiveDomainName() const { return _activeDomainName; }
    152165
     166        bool                            hasNextDomain() { return !_domainQueue.empty(); }
     167        void                            enqueueNextDomain(const String &domName, const StringMap &transientOptions = StringMap());
     168        DomainQueueEntry        dequeueNextDomain();
     169
    153170        void                            addGameDomain(const String &domName);
    154171        void                            removeGameDomain(const String &domName);
    155172        void                            renameGameDomain(const String &oldName, const String &newName);
     
    178195        String                  _activeDomainName;
    179196        Domain *                _activeDomain;
    180197
     198        Array<DomainQueueEntry> _domainQueue;
     199
    181200        String                  _filename;
    182201};
    183202
  • common/events.h

     
    377377         * Used when we have returned to the launcher.
    378378         */
    379379        virtual void resetRTL() = 0;
    380 #ifdef FORCE_RTL
    381380        virtual void resetQuit() = 0;
    382 #endif
     381
    383382        // Optional: check whether a given key is currently pressed ????
    384383        //virtual bool isKeyPressed(int keycode) = 0;
    385384
  • engines/scumm/script.cpp

     
    10381038        }
    10391039}
    10401040
     1041void ScummEngine::killAllScripts() {
     1042        for (int i = 0; i < NUM_SCRIPT_SLOT; i++) {
     1043                vm.slot[i].status = ssDead;
     1044                vm.slot[i].cutsceneOverride = 0;
     1045        }
     1046}
     1047
    10411048void ScummEngine::doSentence(int verb, int objectA, int objectB) {
    10421049        SentenceTab *st;
    10431050
  • engines/scumm/scumm.cpp

     
    3030#include "common/system.h"
    3131
    3232#include "gui/message.h"
     33#include "gui/launcher.h"
    3334#include "gui/GuiManager.h"
    3435
    3536#include "graphics/cursorman.h"
     
    23652366#endif
    23662367
    23672368void ScummEngine::startManiac() {
    2368         debug(0, "stub startManiac()");
    2369         displayMessage(0, "Usually, Maniac Mansion would start now. But ScummVM doesn't do that yet. To play it, go to 'Add Game' in the ScummVM start menu and select the 'Maniac' directory inside the Tentacle game directory.");
     2369        // prevent to start MM again after a restart of DOTT
     2370        if (ConfMan.hasKey("dott_restart_after_mm")) {
     2371                ConfMan.removeKey("dott_restart_after_mm", Common::ConfigManager::kTransientDomain);
     2372                return;
     2373        }
     2374
     2375        // find maniac mansion launcher entry
     2376        Common::String mmDomain;
     2377        Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
     2378        Common::ConfigManager::DomainMap::iterator iter = domains.begin();
     2379        for (iter = domains.begin(); iter != domains.end(); ++iter) {
     2380                Common::ConfigManager::Domain &dom = iter->_value;
     2381                Common::String gameid(dom.get("gameid"));
     2382                if (gameid.equals("maniac"))
     2383                        mmDomain = iter->_key;
     2384        }
     2385
     2386        if (mmDomain.empty()) {
     2387                displayMessage(0, "To play Maniac Mansion you have to add it to the ScummVM launcher first. Go to 'Add Game' in the ScummVM start menu and select the 'Maniac' directory inside the Tentacle game directory.");
     2388                return;
     2389        }
     2390
     2391        // save current state for restart
     2392        strcpy(_saveLoadName, "Autosave 0");
     2393        if (!saveState(0, false)) {
     2394                displayMessage(0, "Could not save state. Maniac Mansion will not be executed!");
     2395                return;
     2396        }
     2397
     2398        // add MM to launcher queue
     2399        ConfMan.enqueueNextDomain(mmDomain);
     2400
     2401        // add DOTT (with current savestate and transient options) to launcher queue
     2402        Common::StringMap dottOptions = *ConfMan.getDomain(Common::ConfigManager::kTransientDomain);
     2403        dottOptions.setVal("save_slot", "0");
     2404        dottOptions.setVal("dott_restart_after_mm", "true");
     2405        ConfMan.enqueueNextDomain(ConfMan.getActiveDomainName(), dottOptions);
     2406
     2407        // return to launcher
     2408        killAllScripts();
     2409        quitGame();
    23702410}
    23712411
    23722412#pragma mark -
  • engines/scumm/scumm.h

     
    729729        bool isScriptRunning(int script) const;
    730730
    731731        void killAllScriptsExceptCurrent();
     732        void killAllScripts();
    732733        void killScriptsAndResources();
    733734        void decreaseScriptDelay(int amount);
    734735