Ticket #8921: saveStateRem_v1.patch

File saveStateRem_v1.patch, 11.7 KB (added by lordhoto, 16 years ago)

Patch against r34490.

  • gui/launcher.cpp

     
    940940}
    941941
    942942void LauncherDialog::loadGame(int item) {
    943         Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
    944943        String gameId = ConfMan.get("gameid", _domains[item]);
    945944        if (gameId.empty())
    946945                gameId = _domains[item];
     
    956955                bool delSupport = (*plugin)->hasFeature(MetaEngine::kSupportsDeleteSave);
    957956
    958957                if ((*plugin)->hasFeature(MetaEngine::kSupportsListSaves) &&
    959                         (*plugin)->hasFeature(MetaEngine::kSupportsDirectLoad))
    960                 {
     958                        (*plugin)->hasFeature(MetaEngine::kSupportsDirectLoad)) {
    961959                        do {
    962960                                Common::StringList saveNames = generateSavegameList(item, plugin);
    963961                                _loadDialog->setList(saveNames);
     
    971969                                                MessageDialog alert("Do you really want to delete this savegame?",
    972970                                                                        "Delete", "Cancel");
    973971                                                if (alert.runModal() == GUI::kMessageOK) {
    974                                                         saveFileMan->removeSavefile(filename.c_str());
    975                                                         if ((saveList.size() - 1) == 0) {
    976                                                                 //ConfMan.setInt("save_slot", -1);
    977                                                         }
     972                                                        (*plugin)->removeSaveState(description.c_str(), atoi(saveList[idx].save_slot().c_str()));
     973                                                        /*if ((saveList.size() - 1) == 0) {
     974                                                                ConfMan.setInt("save_slot", -1);
     975                                                        }*/
    978976                                                }
    979                                         }
    980                                         // Load the savegame
    981                                         else {
     977                                        } else { // Load the savegame
    982978                                                int slot = atoi(saveList[idx].save_slot().c_str());
    983979                                                //const char *file = saveList[idx].filename().c_str();
    984980                                                //printf("Loading slot: %d\n", slot);
     
    988984                                                close();
    989985                                        }
    990986                                }
    991                         }
    992                         while (_loadDialog->delSave());
     987                        } while (_loadDialog->delSave());
    993988                } else {
    994989                        MessageDialog dialog
    995990                                ("Sorry, this game does not yet support loading games from the launcher.", "OK");
  • engines/sword2/sword2.cpp

     
    8585        virtual GameDescriptor findGame(const char *gameid) const;
    8686        virtual GameList detectGames(const Common::FSList &fslist) const;
    8787        virtual SaveStateList listSaves(const char *target) const;
     88        virtual void removeSaveState(const char *target, int slot) const;
    8889
    8990        virtual PluginError createInstance(OSystem *syst, Engine **engine) const;
    9091};
     
    196197        return saveList;
    197198}
    198199
     200void Sword2MetaEngine::removeSaveState(const char *target, int slot) const {
     201        char extension[6];
     202        snprintf(extension, sizeof(extension), ".%03d", slot);
     203
     204        Common::String filename = target;
     205        filename += extension;
     206
     207        g_system->getSavefileManager()->removeSavefile(filename.c_str());
     208}
     209
    199210PluginError Sword2MetaEngine::createInstance(OSystem *syst, Engine **engine) const {
    200211        assert(syst);
    201212        assert(engine);
  • engines/scumm/detection.cpp

     
    682682        virtual PluginError createInstance(OSystem *syst, Engine **engine) const;
    683683
    684684        virtual SaveStateList listSaves(const char *target) const;
     685        virtual void removeSaveState(const char *target, int slot) const;
    685686};
    686687
    687688bool ScummMetaEngine::hasFeature(MetaEngineFeature f) const {
     
    975976        return saveList;
    976977}
    977978
     979void ScummMetaEngine::removeSaveState(const char *target, int slot) const {
     980        char extension[6];
     981        snprintf(extension, sizeof(extension), ".s%02d", slot);
     982
     983        Common::String filename = target;
     984        filename += extension;
     985
     986        g_system->getSavefileManager()->removeSavefile(filename.c_str());
     987}
     988
    978989#if PLUGIN_ENABLED_DYNAMIC(SCUMM)
    979990        REGISTER_PLUGIN_DYNAMIC(SCUMM, PLUGIN_TYPE_ENGINE, ScummMetaEngine);
    980991#else
  • engines/touche/detection.cpp

     
    139139        virtual bool hasFeature(MetaEngineFeature f) const;
    140140        virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
    141141        virtual SaveStateList listSaves(const char *target) const;
     142        virtual void removeSaveState(const char *target, int slot) const;
    142143};
    143144
    144145bool ToucheMetaEngine::hasFeature(MetaEngineFeature f) const {
     
    208209        return saveList;
    209210}
    210211
     212void ToucheMetaEngine::removeSaveState(const char *target, int slot) const {
     213        char extension[5];
     214        snprintf(extension, sizeof(extension), ".%d", slot);
     215
     216        Common::String filename = target;
     217        filename += extension;
     218
     219        g_system->getSavefileManager()->removeSavefile(filename.c_str());
     220}
     221
    211222#if PLUGIN_ENABLED_DYNAMIC(TOUCHE)
    212223        REGISTER_PLUGIN_DYNAMIC(TOUCHE, PLUGIN_TYPE_ENGINE, ToucheMetaEngine);
    213224#else
  • engines/agi/detection.cpp

     
    21252125        virtual bool hasFeature(MetaEngineFeature f) const;
    21262126        virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
    21272127        virtual SaveStateList listSaves(const char *target) const;
     2128        virtual void removeSaveState(const char *target, int slot) const;
    21282129       
    21292130        const Common::ADGameDescription *fallbackDetect(const Common::FSList *fslist) const;
    21302131};
     
    21892190        return saveList;
    21902191}
    21912192
     2193void AgiMetaEngine::removeSaveState(const char *target, int slot) const {
     2194        char extension[6];
     2195        snprintf(extension, sizeof(extension), ".%03d", slot);
     2196
     2197        Common::String filename = target;
     2198        filename += extension;
     2199
     2200        g_system->getSavefileManager()->removeSavefile(filename.c_str());
     2201}
     2202
    21922203const Common::ADGameDescription *AgiMetaEngine::fallbackDetect(const Common::FSList *fslist) const {
    21932204        typedef Common::HashMap<Common::String, int32> IntMap;
    21942205        IntMap allFiles;
  • engines/metaengine.h

     
    101101         * For most engines this just amounts to calling _saveFileMan->removeSaveFile(). 
    102102         * Engines which keep an index file will also update it accordingly.
    103103         *
     104         * @param target        name of a config manager target
    104105         * @param slot          slot number of the save state to be removed
    105          *
    106          * @todo  This method is currently never called. Rather, LauncherDialog::loadGame
    107          *        directly calls _saveFileMan->removeSaveFile() if kSupportsDeleteSave is set.
    108106         */
    109         virtual void removeSaveState(int slot) const {};
     107        virtual void removeSaveState(const char *target, int slot) const {};
    110108
    111109       
    112110        /** @name MetaEngineFeature flags */
  • engines/kyra/detection.cpp

     
    10671067        bool hasFeature(MetaEngineFeature f) const;
    10681068        bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
    10691069        SaveStateList listSaves(const char *target) const;
     1070        void removeSaveState(const char *target, int slot) const;
    10701071};
    10711072
    10721073bool KyraMetaEngine::hasFeature(MetaEngineFeature f) const {
     
    11471148        return saveList;
    11481149}
    11491150
     1151void KyraMetaEngine::removeSaveState(const char *target, int slot) const {
     1152        char extension[6];
     1153        snprintf(extension, sizeof(extension), ".%03d", slot);
     1154
     1155        Common::String filename = target;
     1156        filename += extension;
     1157
     1158        g_system->getSavefileManager()->removeSavefile(filename.c_str());
     1159}
     1160
    11501161#if PLUGIN_ENABLED_DYNAMIC(KYRA)
    11511162        REGISTER_PLUGIN_DYNAMIC(KYRA, PLUGIN_TYPE_ENGINE, KyraMetaEngine);
    11521163#else
  • engines/lure/detection.cpp

     
    188188        virtual bool hasFeature(MetaEngineFeature f) const;
    189189        virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
    190190        virtual SaveStateList listSaves(const char *target) const;
     191        virtual void removeSaveState(const char *target, int slot) const;
    191192};
    192193
    193194bool LureMetaEngine::hasFeature(MetaEngineFeature f) const {
     
    234235        return saveList;
    235236}
    236237
     238void LureMetaEngine::removeSaveState(const char *target, int slot) const {
     239        char extension[6];
     240        snprintf(extension, sizeof(extension), ".%03d", slot);
     241
     242        Common::String filename = target;
     243        filename += extension;
     244
     245        g_system->getSavefileManager()->removeSavefile(filename.c_str());
     246}
     247
    237248#if PLUGIN_ENABLED_DYNAMIC(LURE)
    238249        REGISTER_PLUGIN_DYNAMIC(LURE, PLUGIN_TYPE_ENGINE, LureMetaEngine);
    239250#else
  • engines/parallaction/detection.cpp

     
    246246        virtual bool hasFeature(MetaEngineFeature f) const;
    247247        virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
    248248        virtual SaveStateList listSaves(const char *target) const;
     249        virtual void removeSaveState(const char *target, int slot) const;
    249250};
    250251
    251252bool ParallactionMetaEngine::hasFeature(MetaEngineFeature f) const {
     
    302303        return saveList;
    303304}
    304305
     306void ParallactionMetaEngine::removeSaveState(const char *target, int slot) const {
     307        char extension[6];
     308        snprintf(extension, sizeof(extension), ".0%02d", slot);
     309
     310        Common::String filename = target;
     311        filename += extension;
     312
     313        g_system->getSavefileManager()->removeSavefile(filename.c_str());
     314}
     315
    305316#if PLUGIN_ENABLED_DYNAMIC(PARALLACTION)
    306317        REGISTER_PLUGIN_DYNAMIC(PARALLACTION, PLUGIN_TYPE_ENGINE, ParallactionMetaEngine);
    307318#else
  • engines/saga/detection.cpp

     
    150150        virtual bool hasFeature(MetaEngineFeature f) const;
    151151        virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
    152152        virtual SaveStateList listSaves(const char *target) const;
     153        virtual void removeSaveState(const char *target, int slot) const;
    153154};
    154155
    155156bool SagaMetaEngine::hasFeature(MetaEngineFeature f) const {
     
    198199        return saveList;
    199200}
    200201
     202void SagaMetaEngine::removeSaveState(const char *target, int slot) const {
     203        char extension[6];
     204        snprintf(extension, sizeof(extension), ".s%02d", slot);
     205
     206        Common::String filename = target;
     207        filename += extension;
     208
     209        g_system->getSavefileManager()->removeSavefile(filename.c_str());
     210}
     211
    201212#if PLUGIN_ENABLED_DYNAMIC(SAGA)
    202213        REGISTER_PLUGIN_DYNAMIC(SAGA, PLUGIN_TYPE_ENGINE, SagaMetaEngine);
    203214#else
  • engines/queen/queen.cpp

     
    6565        virtual GameDescriptor findGame(const char *gameid) const;
    6666        virtual GameList detectGames(const Common::FSList &fslist) const;
    6767        virtual SaveStateList listSaves(const char *target) const;
     68        virtual void removeSaveState(const char *target, int slot) const;
    6869
    6970        virtual PluginError createInstance(OSystem *syst, Engine **engine) const;
    7071};
     
    161162        return saveList;
    162163}
    163164
     165void QueenMetaEngine::removeSaveState(const char *target, int slot) const {
     166        char extension[6];
     167        snprintf(extension, sizeof(extension), ".s%02d", slot);
     168
     169        Common::String filename = target;
     170        filename += extension;
     171
     172        g_system->getSavefileManager()->removeSavefile(filename.c_str());
     173}
     174
    164175PluginError QueenMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
    165176        assert(engine);
    166177        *engine = new Queen::QueenEngine(syst);