Ticket #8925: common-load.patch

File common-load.patch, 10.4 KB (added by bluegr, 16 years ago)

Common load game dialog

  • engines/dialogs.cpp

     
    3434#include "gui/about.h"
    3535#include "gui/eval.h"
    3636#include "gui/newgui.h"
     37#include "gui/launcher.h"
    3738#include "gui/ListWidget.h"
    3839#include "gui/theme.h"
    3940
     
    9596               
    9697        new GUI::ButtonWidget(this, "globalmain_resume", "Resume", kPlayCmd, 'P');
    9798
    98 //      new GUI::ButtonWidget(this, "globalmain_load", "Load", kLoadCmd, 'L');
     99        _loadButton = new GUI::ButtonWidget(this, "globalmain_load", "Load", kLoadCmd, 'L');
     100        // '1' - kSupportsListSaves, '2' - kSupportsDirectLoad
     101        _loadButton->setEnabled(_engine->hasFeature(1 & 2));
    99102//      new GUI::ButtonWidget(this, "globalmain_save", "Save", kSaveCmd, 'S');
    100103
    101104        new GUI::ButtonWidget(this, "globalmain_options", "Options", kOptionsCmd, 'O');
     
    111114
    112115        _aboutDialog = new GUI::AboutDialog();
    113116        _optionsDialog = new ConfigDialog();
     117        _loadDialog = new GUI::SaveLoadChooser("Load game:", "Load");
    114118}
    115119
    116120MainMenuDialog::~MainMenuDialog() {
    117121        delete _aboutDialog;
    118122        delete _optionsDialog;
     123        delete _loadDialog;
    119124}
    120125
    121126void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
     
    123128        case kPlayCmd:
    124129                close();
    125130                break;
     131        case kLoadCmd:
     132                {
     133                String gameId = ConfMan.get("gameid");
     134
     135                const EnginePlugin *plugin = 0;
     136                EngineMan.findGame(gameId, &plugin);
     137
     138                int slot = _loadDialog->runModal(plugin, ConfMan.getActiveDomainName());
     139
     140                if (slot >= 0) {
     141                        _engine->loadGameState(slot);
     142                        close();
     143                }
     144
     145                }
     146                break;
    126147        case kOptionsCmd:
    127148                _optionsDialog->runModal();
    128149                break;
  • engines/dialogs.h

     
    2727
    2828#include "common/str.h"
    2929#include "gui/dialog.h"
     30#include "gui/launcher.h"
    3031#include "gui/options.h"
    3132#include "gui/widget.h"
    3233
     
    5657
    5758        GUI::GraphicsWidget *_logo;
    5859        GUI::ButtonWidget       *_rtlButton;
     60        GUI::ButtonWidget       *_loadButton;
    5961        GUI::Dialog             *_aboutDialog;
    6062        GUI::Dialog             *_optionsDialog;
     63        GUI::SaveLoadChooser    *_loadDialog;
    6164
    6265};
    6366
  • engines/engine.cpp

     
    216216        _mixer->pauseAll(pause);
    217217}
    218218
     219bool Engine::loadGameState(int slot) {
     220        // Do nothing by default
     221        return false;
     222}
     223
    219224void Engine::mainMenuDialog() {
    220225        if (!_mainMenuDialog)
    221226                _mainMenuDialog = new MainMenuDialog(this);
  • engines/engine.h

     
    164164         * for details.
    165165         */
    166166        virtual void pauseEngineIntern(bool pause);
     167
     168        /** Load a game state */
     169        virtual bool loadGameState(int slot);
    167170};
    168171
    169172extern Engine *g_engine;
  • engines/igor/igor.h

     
    427427        void dialogueReplyToQuestion(int x, int y, int r, int g, int b, int reply = 0);
    428428
    429429        void saveOrLoadGameState(TypeSerializer &typeSerializer);
    430         void loadGameState(int slot);
     430        bool loadGameState(int slot);
    431431        void saveGameState(int slot);
    432432        void generateGameStateFileName(int num, char *dst, int len) const;
    433433
  • engines/igor/saveload.cpp

     
    156156        }
    157157}
    158158
    159 void IgorEngine::loadGameState(int slot) {
     159bool IgorEngine::loadGameState(int slot) {
    160160        char name[64];
    161161        generateGameStateFileName(slot, name, 63);
    162162        Common::InSaveFile *isf = _saveFileMan->openForLoading(name);
     
    175175                }
    176176                debug(0, "Loaded state, current part %d", _currentPart);
    177177        }
     178
     179        return true;    // TODO: return success/failure
    178180}
    179181
    180182void IgorEngine::saveGameState(int slot) {
  • engines/queen/queen.cpp

     
    351351        }
    352352}
    353353
    354 void QueenEngine::loadGameState(int slot) {
     354bool QueenEngine::loadGameState(int slot) {
    355355        debug(3, "Loading game from slot %d", slot);
    356356        GameStateHeader header;
    357357        Common::InSaveFile *file = readGameStateHeader(slot, &header);
     
    374374                delete[] saveData;
    375375                delete file;
    376376        }
     377
     378        return true;    // TODO: return success/failure
    377379}
    378380
    379381Common::InSaveFile *QueenEngine::readGameStateHeader(int slot, GameStateHeader *gsh) {
  • engines/queen/queen.h

     
    108108
    109109        bool canLoadOrSave() const;
    110110        void saveGameState(int slot, const char *desc);
    111         void loadGameState(int slot);
     111        bool loadGameState(int slot);
    112112        void makeGameStateName(int slot, char *buf) const;
    113113        int getGameStateSlot(const char *filename) const;
    114114        void findGameStateDescriptions(char descriptions[100][32]);
  • engines/saga/detection.cpp

     
    3232#include "common/config-manager.h"
    3333#include "common/advancedDetector.h"
    3434
     35#include "saga/animation.h"
    3536#include "saga/displayinfo.h"
     37#include "saga/events.h"
    3638#include "saga/rscfile.h"
    3739#include "saga/interface.h"
    3840#include "saga/scene.h"
     
    238240        return di.logicalHeight;
    239241}
    240242
     243bool SagaEngine::loadGameState(int slot) {
     244                // FIXME: This doesn't work when called during the intro
     245
     246                // Init the current chapter to 8 (character selection) for IHNM
     247                if (getGameType() == GType_IHNM)
     248                        _scene->changeScene(-2, 0, kTransitionFade, 8);
     249
     250                // First scene sets up palette
     251                _scene->changeScene(getStartSceneNumber(), 0, kTransitionNoFade);
     252                _events->handleEvents(0); // Process immediate events
     253
     254                if (getGameType() != GType_IHNM)
     255                        _interface->setMode(kPanelMain);
     256                else
     257                        _interface->setMode(kPanelChapterSelection);
     258
     259                load(calcSaveFileName((uint)slot));
     260                syncSoundSettings();
     261
     262        return true;    // TODO: return success/failure
     263}
     264
    241265} // End of namespace Saga
  • engines/saga/saga.h

     
    651651        const Common::Rect &getDisplayClip() const { return _displayClip;}
    652652        int getDisplayWidth() const;
    653653        int getDisplayHeight() const;
     654        bool loadGameState(int slot);
    654655        const GameDisplayInfo &getDisplayInfo();
    655656
    656657        const char *getTextString(int textStringId);
  • gui/launcher.cpp

     
    473473        }
    474474}
    475475
    476 class SaveLoadChooser : public GUI::Dialog {
    477         typedef Common::String String;
    478         typedef Common::StringList StringList;
    479 protected:
    480         GUI::ListWidget         *_list;
    481         GUI::ButtonWidget       *_chooseButton;
    482         GUI::ButtonWidget       *_deleteButton;
    483         GUI::GraphicsWidget     *_gfxWidget;
    484         GUI::ContainerWidget    *_container;
    485         GUI::StaticTextWidget   *_date;
    486         GUI::StaticTextWidget   *_time;
    487         GUI::StaticTextWidget   *_playtime;
    488 
    489         const EnginePlugin              *_plugin;
    490         bool                                    _delSupport;
    491         bool                                    _metaInfoSupport;
    492         bool                                    _thumbnailSupport;
    493         bool                                    _saveDateSupport;
    494         bool                                    _playTimeSupport;
    495         String                                  _target;
    496         SaveStateList                   _saveList;
    497 
    498         uint8 _fillR, _fillG, _fillB;
    499 
    500         void updateSaveList();
    501         void updateSelection(bool redraw);
    502 public:
    503         SaveLoadChooser(const String &title, const String &buttonLabel);
    504         ~SaveLoadChooser();
    505 
    506         virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
    507         void setList(const StringList& list);
    508         int runModal(const EnginePlugin *plugin, const String &target);
    509 
    510         virtual void reflowLayout();
    511 
    512         virtual void close();
    513 };
    514 
    515476SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel)
    516477        : Dialog("scummsaveload"), _delSupport(0), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0)  {
    517478        _delSupport = _metaInfoSupport = _thumbnailSupport = _saveDateSupport = _playTimeSupport = false;
  • gui/launcher.h

     
    2727
    2828#include "gui/dialog.h"
    2929#include "engines/game.h"
     30#include "engines/metaengine.h"
    3031#include "common/str.h"
    3132
    3233namespace GUI {
     
    7980        void selectGame(const String &name);
    8081};
    8182
     83class SaveLoadChooser : public GUI::Dialog {
     84        typedef Common::String String;
     85        typedef Common::StringList StringList;
     86protected:
     87        GUI::ListWidget         *_list;
     88        GUI::ButtonWidget       *_chooseButton;
     89        GUI::ButtonWidget       *_deleteButton;
     90        GUI::GraphicsWidget     *_gfxWidget;
     91        GUI::ContainerWidget    *_container;
     92        GUI::StaticTextWidget   *_date;
     93        GUI::StaticTextWidget   *_time;
     94        GUI::StaticTextWidget   *_playtime;
     95
     96        const EnginePlugin              *_plugin;
     97        bool                                    _delSupport;
     98        bool                                    _metaInfoSupport;
     99        bool                                    _thumbnailSupport;
     100        bool                                    _saveDateSupport;
     101        bool                                    _playTimeSupport;
     102        String                                  _target;
     103        SaveStateList                   _saveList;
     104
     105        uint8 _fillR, _fillG, _fillB;
     106
     107        void updateSaveList();
     108        void updateSelection(bool redraw);
     109public:
     110        SaveLoadChooser(const String &title, const String &buttonLabel);
     111        ~SaveLoadChooser();
     112
     113        virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
     114        void setList(const StringList& list);
     115        int runModal(const EnginePlugin *plugin, const String &target);
     116
     117        virtual void reflowLayout();
     118
     119        virtual void close();
     120};
     121
    82122} // End of namespace GUI
    83123
    84124#endif
  • gui/themes/modern.ini

     
    273273globalmain_resume=globalmainHOffset gmY scummmainButtonWidth scummmainButtonHeight
    274274gmY=(gmY + scummmainButtonHeight + scummmainVAddOff)
    275275gmY=(gmY + scummmainVSpace)
     276globalmain_load=prev.x gmY prev.w prev.h
     277gmY=(gmY + scummmainButtonHeight + scummmainVAddOff)
    276278globalmain_options=prev.x gmY prev.w prev.h
    277279gmY=(gmY + scummmainButtonHeight + scummmainVAddOff)
    278280globalmain_about=prev.x gmY prev.w prev.h