Ticket #8925: common-load_v4.patch
File common-load_v4.patch, 18.1 KB (added by , 16 years ago) |
---|
-
engines/dialogs.cpp
33 33 34 34 #include "gui/about.h" 35 35 #include "gui/newgui.h" 36 #include "gui/launcher.h" 36 37 #include "gui/ListWidget.h" 37 38 #include "gui/theme.h" 38 39 … … 96 97 97 98 new GUI::ButtonWidget(this, "GlobalMenu.Resume", "Resume", kPlayCmd, 'P'); 98 99 99 // new GUI::ButtonWidget(this, "globalmain_load", "Load", kLoadCmd, 'L'); 100 // new GUI::ButtonWidget(this, "globalmain_save", "Save", kSaveCmd, 'S'); 100 _loadButton = new GUI::ButtonWidget(this, "GlobalMenu.Load", "Load", kLoadCmd, 'L'); 101 // TODO: setEnabled -> setVisible 102 _loadButton->setEnabled(_engine->hasFeature(Engine::kSupportsListSaves) && 103 _engine->hasFeature(Engine::kSupportsLoadingDuringRuntime)); 104 105 _saveButton = new GUI::ButtonWidget(this, "GlobalMenu.Save", "Save", kSaveCmd, 'S'); 106 // TODO: setEnabled -> setVisible 107 _saveButton->setEnabled(_engine->hasFeature(Engine::kSupportsListSaves) && 108 _engine->hasFeature(Engine::kSupportsSavingDuringRuntime)); 101 109 102 110 new GUI::ButtonWidget(this, "GlobalMenu.Options", "Options", kOptionsCmd, 'O'); 103 111 … … 111 119 112 120 _aboutDialog = new GUI::AboutDialog(); 113 121 _optionsDialog = new ConfigDialog(); 122 _loadDialog = new GUI::SaveLoadChooser("Load game:", "Load"); 114 123 } 115 124 116 125 MainMenuDialog::~MainMenuDialog() { 117 126 delete _aboutDialog; 118 127 delete _optionsDialog; 128 delete _loadDialog; 129 //delete _saveDialog; 119 130 } 120 131 121 132 void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { … … 123 134 case kPlayCmd: 124 135 close(); 125 136 break; 137 case kLoadCmd: 138 { 139 String gameId = ConfMan.get("gameid"); 140 141 const EnginePlugin *plugin = 0; 142 EngineMan.findGame(gameId, &plugin); 143 144 int slot = _loadDialog->runModal(plugin, ConfMan.getActiveDomainName()); 145 146 if (slot >= 0) { 147 _engine->loadGameState(slot); 148 close(); 149 } 150 151 } 152 break; 153 case kSaveCmd: 154 /* 155 String gameId = ConfMan.get("gameid"); 156 157 const EnginePlugin *plugin = 0; 158 EngineMan.findGame(gameId, &plugin); 159 160 int slot = _saveDialog->runModal(plugin, ConfMan.getActiveDomainName()); 161 162 if (slot >= 0) { 163 _engine->saveGameState(slot); 164 close(); 165 } 166 167 } 168 */ 169 break; 126 170 case kOptionsCmd: 127 171 _optionsDialog->runModal(); 128 172 break; … … 149 193 } 150 194 151 195 void MainMenuDialog::reflowLayout() { 196 _loadButton->setEnabled(_engine->canLoadGameStateCurrently()); 197 _saveButton->setEnabled(_engine->canSaveGameStateCurrently()); 198 152 199 #ifndef DISABLE_FANCY_THEMES 153 200 if (g_gui.xmlEval()->getVar("Globals.ShowGlobalMenuLogo", 0) == 1 && g_gui.theme()->supportsImages()) { 154 201 if (!_logo) -
engines/dialogs.h
27 27 28 28 #include "common/str.h" 29 29 #include "gui/dialog.h" 30 #include "gui/launcher.h" 30 31 #include "gui/options.h" 31 32 #include "gui/widget.h" 32 33 … … 56 57 57 58 GUI::GraphicsWidget *_logo; 58 59 GUI::ButtonWidget *_rtlButton; 60 GUI::ButtonWidget *_loadButton; 61 GUI::ButtonWidget *_saveButton; 59 62 GUI::Dialog *_aboutDialog; 60 63 GUI::Dialog *_optionsDialog; 64 GUI::SaveLoadChooser *_loadDialog; 61 65 62 66 }; 63 67 -
engines/engine.cpp
244 244 _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech); 245 245 } 246 246 247 int Engine::loadGameState(int slot) { 248 // Do nothing by default 249 return 0; 250 } 251 252 bool Engine::canLoadGameStateCurrently() { 253 // Do not allow loading by default 254 return false; 255 } 256 257 int Engine::saveGameState(int slot) { 258 // Do nothing by default 259 return 0; 260 } 261 262 bool Engine::canSaveGameStateCurrently() { 263 // Do not allow saving by default 264 return false; 265 } 266 247 267 void Engine::quitGame() { 248 268 Common::Event event; 249 269 -
engines/engine.h
125 125 */ 126 126 virtual void syncSoundSettings(); 127 127 128 /** 129 * Load a game state 130 */ 131 virtual int loadGameState(int slot); 132 133 /** 134 * Indicates whether a game state can be loaded 135 */ 136 virtual bool canLoadGameStateCurrently(); 137 138 /** 139 * Save a game state 140 */ 141 virtual int saveGameState(int slot); 142 143 /** 144 * Indicates whether a game state can be saved 145 */ 146 virtual bool canSaveGameStateCurrently(); 147 128 148 protected: 129 149 130 150 /** … … 182 202 /** 183 203 * 'Return to launcher' feature is supported, i.e., EVENT_RTL is handled. 184 204 */ 185 kSupportsRTL 205 kSupportsRTL = 0, 206 207 /** 208 * Listing all Save States for a given target is supported, i.e., 209 * the listSaves() method is implemented. 210 * Used for --list-saves support, as well as the GMM load dialog. 211 */ 212 kSupportsListSaves = 1, 213 214 /** 215 * Loading from the in-game common ScummVM options dialog is supported 216 */ 217 kSupportsLoadingDuringRuntime = 8, 218 219 /** 220 * Saving from the in-game common ScummVM options dialog is supported 221 */ 222 kSupportsSavingDuringRuntime = 9 186 223 }; 187 224 188 225 /** -
engines/igor/igor.h
427 427 void dialogueReplyToQuestion(int x, int y, int r, int g, int b, int reply = 0); 428 428 429 429 void saveOrLoadGameState(TypeSerializer &typeSerializer); 430 voidloadGameState(int slot);431 voidsaveGameState(int slot);430 int loadGameState(int slot); 431 int saveGameState(int slot); 432 432 void generateGameStateFileName(int num, char *dst, int len) const; 433 433 434 434 MidiPlayer *_midiPlayer; -
engines/igor/saveload.cpp
156 156 } 157 157 } 158 158 159 voidIgorEngine::loadGameState(int slot) {159 int IgorEngine::loadGameState(int slot) { 160 160 char name[64]; 161 161 generateGameStateFileName(slot, name, 63); 162 162 Common::InSaveFile *isf = _saveFileMan->openForLoading(name); … … 175 175 } 176 176 debug(0, "Loaded state, current part %d", _currentPart); 177 177 } 178 179 return 0; // TODO: return success/failure 178 180 } 179 181 180 voidIgorEngine::saveGameState(int slot) {182 int IgorEngine::saveGameState(int slot) { 181 183 char name[64]; 182 184 generateGameStateFileName(slot, name, 63); 183 185 Common::OutSaveFile *osf = _saveFileMan->openForSaving(name); … … 187 189 saveOrLoadGameState(ts); 188 190 delete osf; 189 191 } 192 193 return 0; // TODO: return success/failure 190 194 } 191 195 192 196 void IgorEngine::generateGameStateFileName(int num, char *dst, int len) const { -
engines/metaengine.h
183 183 * the game till the save. 184 184 * This flag may only be set when 'kSavesSupportMetaInfo' is set. 185 185 */ 186 kSavesSupportPlayTime 186 kSavesSupportPlayTime, 187 188 /** 189 *Features loading from the Common ScummVM options dialog in-game 190 */ 191 kSupportsLoadingDuringRuntime, 192 193 /** 194 *Features saving from the Common ScummVM options dialog in-game 195 */ 196 kSupportsSavingDuringRuntime 187 197 }; 188 198 189 199 /** -
engines/queen/queen.cpp
351 351 } 352 352 } 353 353 354 voidQueenEngine::loadGameState(int slot) {354 int QueenEngine::loadGameState(int slot) { 355 355 debug(3, "Loading game from slot %d", slot); 356 356 GameStateHeader header; 357 357 Common::InSaveFile *file = readGameStateHeader(slot, &header); … … 374 374 delete[] saveData; 375 375 delete file; 376 376 } 377 378 return 0; // TODO: return success/failure 377 379 } 378 380 379 381 Common::InSaveFile *QueenEngine::readGameStateHeader(int slot, GameStateHeader *gsh) { -
engines/queen/queen.h
108 108 109 109 bool canLoadOrSave() const; 110 110 void saveGameState(int slot, const char *desc); 111 voidloadGameState(int slot);111 int loadGameState(int slot); 112 112 void makeGameStateName(int slot, char *buf) const; 113 113 int getGameStateSlot(const char *filename) const; 114 114 void findGameStateDescriptions(char descriptions[100][32]); -
engines/saga/detection.cpp
33 33 #include "common/advancedDetector.h" 34 34 #include "common/system.h" 35 35 36 #include "saga/animation.h" 36 37 #include "saga/displayinfo.h" 38 #include "saga/events.h" 37 39 #include "saga/rscfile.h" 38 40 #include "saga/interface.h" 39 41 #include "saga/scene.h" … … 157 159 (f == kSupportsRTL) || 158 160 (f == kSupportsListSaves) || 159 161 (f == kSupportsLoadingDuringStartup) || 160 (f == kSupportsDeleteSave); 162 (f == kSupportsDeleteSave) || 163 (f == kSupportsLoadingDuringRuntime) || 164 (f == kSupportsSavingDuringRuntime); 161 165 } 162 166 163 167 bool SagaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const { … … 237 241 return di.logicalHeight; 238 242 } 239 243 244 int SagaEngine::loadGameState(int slot) { 245 // Init the current chapter to 8 (character selection) for IHNM 246 if (getGameType() == GType_IHNM) 247 _scene->changeScene(-2, 0, kTransitionFade, 8); 248 249 // First scene sets up palette 250 _scene->changeScene(getStartSceneNumber(), 0, kTransitionNoFade); 251 _events->handleEvents(0); // Process immediate events 252 253 if (getGameType() != GType_IHNM) 254 _interface->setMode(kPanelMain); 255 else 256 _interface->setMode(kPanelChapterSelection); 257 258 load(calcSaveFileName((uint)slot)); 259 syncSoundSettings(); 260 261 return 0; // TODO: return success/failure 262 } 263 240 264 } // End of namespace Saga -
engines/saga/saga.cpp
535 535 _sound->setVolume(); 536 536 } 537 537 538 bool SagaEngine::canLoadGameStateCurrently() { 539 return !this->_scene->isInIntro(); 540 } 541 542 bool SagaEngine::canSaveGameStateCurrently() { 543 return !this->_scene->isInIntro(); 544 } 545 538 546 } // End of namespace Saga -
engines/saga/saga.h
650 650 const Common::Rect &getDisplayClip() const { return _displayClip;} 651 651 int getDisplayWidth() const; 652 652 int getDisplayHeight() const; 653 int loadGameState(int slot); 654 bool canLoadGameStateCurrently(); 655 bool canSaveGameStateCurrently(); 653 656 const GameDisplayInfo &getDisplayInfo(); 654 657 655 658 const char *getTextString(int textStringId); -
engines/touche/menu.cpp
331 331 break; 332 332 case kActionPerformSaveLoad: 333 333 if (menuData->mode == kMenuLoadStateMode) { 334 if (loadGameState(_saveLoadCurrentSlot) ) {334 if (loadGameState(_saveLoadCurrentSlot) == 0) { 335 335 menuData->quit = true; 336 336 } 337 337 } else if (menuData->mode == kMenuSaveStateMode) { -
engines/touche/saveload.cpp
340 340 return saveOk; 341 341 } 342 342 343 boolToucheEngine::loadGameState(int num) {343 int ToucheEngine::loadGameState(int num) { 344 344 bool loadOk = false; 345 345 char gameStateFileName[64]; 346 346 generateGameStateFileName(num, gameStateFileName, 63); … … 360 360 } 361 361 delete f; 362 362 } 363 return loadOk ;363 return loadOk ? 0 : 1; 364 364 } 365 365 366 366 void ToucheEngine::readGameStateDescription(int num, char *description, int len) { -
engines/touche/touche.h
496 496 void saveGameStateData(Common::WriteStream *stream); 497 497 void loadGameStateData(Common::ReadStream *stream); 498 498 bool saveGameState(int num, const char *description); 499 boolloadGameState(int num);499 int loadGameState(int num); 500 500 void readGameStateDescription(int num, char *description, int len); 501 501 void generateGameStateFileName(int num, char *dst, int len, bool prefixOnly = false) const; 502 502 int getGameStateFileSlot(const char *filename) const; -
gui/launcher.cpp
473 473 } 474 474 } 475 475 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 515 476 SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel) 516 477 : Dialog("ScummSaveLoad"), _delSupport(0), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0) { 517 478 _delSupport = _metaInfoSupport = _thumbnailSupport = _saveDateSupport = _playTimeSupport = false; -
gui/launcher.h
27 27 28 28 #include "gui/dialog.h" 29 29 #include "engines/game.h" 30 #include "engines/metaengine.h" 30 31 #include "common/str.h" 31 32 32 33 namespace GUI { … … 79 80 void selectGame(const String &name); 80 81 }; 81 82 83 class SaveLoadChooser : public GUI::Dialog { 84 typedef Common::String String; 85 typedef Common::StringList StringList; 86 protected: 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); 109 public: 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 82 122 } // End of namespace GUI 83 123 84 124 #endif -
gui/themes/scummclassic/classic_layout.stx
464 464 height = 'Globals.Button.Height' 465 465 /> 466 466 <space size = '10'/> 467 <widget name = 'Load' 468 width = '150' 469 height = 'Globals.Button.Height' 470 /> 471 <widget name = 'Save' 472 width = '150' 473 height = 'Globals.Button.Height' 474 /> 475 <space size = '10'/> 467 476 <widget name = 'Options' 468 477 width = '150' 469 478 height = 'Globals.Button.Height' -
gui/themes/scummclassic/classic_layout_320.stx
465 465 height = 'Globals.Button.Height' 466 466 /> 467 467 <space size = '4'/> 468 <widget name = 'Load' 469 width = '70' 470 height = 'Globals.Button.Height' 471 /> 472 <widget name = 'Save' 473 width = '70' 474 height = 'Globals.Button.Height' 475 /> 476 <space size = '4'/> 468 477 <widget name = 'Options' 469 478 width = '70' 470 479 height = 'Globals.Button.Height' -
gui/themes/scummmodern/scummmodern_layout.stx
476 476 height = 'Globals.Button.Height' 477 477 /> 478 478 <space size = '10'/> 479 <widget name = 'Load' 480 width = '150' 481 height = 'Globals.Button.Height' 482 /> 483 <widget name = 'Save' 484 width = '150' 485 height = 'Globals.Button.Height' 486 /> 487 <space size = '10'/> 479 488 <widget name = 'Options' 480 489 width = '150' 481 490 height = 'Globals.Button.Height' -
gui/themes/scummmodern/scummmodern_layout_320.stx
462 462 height = 'Globals.Button.Height' 463 463 /> 464 464 <space size = '4'/> 465 <widget name = 'Load' 466 width = '70' 467 height = 'Globals.Button.Height' 468 /> 469 <widget name = 'Save' 470 width = '70' 471 height = 'Globals.Button.Height' 472 /> 473 <space size = '4'/> 465 474 <widget name = 'Options' 466 475 width = '70' 467 476 height = 'Globals.Button.Height'