Ticket #9065: gmm-load_del_empty.patch
File gmm-load_del_empty.patch, 3.5 KB (added by , 15 years ago) |
---|
-
gui/saveload.cpp
235 235 bool isWriteProtected = false; 236 236 bool startEditMode = _list->isEditable(); 237 237 238 if (selItem >= 0 && !_list->getSelectedString().empty() && _metaInfoSupport) { 238 // Only try to fetch meta information about a savegame if 239 // 1) there's a savegame selected, 240 // 2) it is not a dummy one (i.e. a filler for a gap in the savegame list) 241 // 3) and the engine supports savegame meta information. 242 if (selItem >= 0 && !_saveList[selItem].getBool("is_dummy") && _metaInfoSupport) { 239 243 SaveStateDescriptor desc = (*_plugin)->querySaveMetaInfos(_target.c_str(), atoi(_saveList[selItem].save_slot().c_str())); 240 244 241 245 isDeletable = desc.getBool("is_deletable") && _delSupport; … … 292 296 if (startEditMode) 293 297 _list->startEditMode(); 294 298 } else { 295 // Disable the load button if nothing is selected, or if a n empty299 // Disable the load button if nothing is selected, or if a dummy 296 300 // list item is selected. 297 _chooseButton->setEnabled(selItem >= 0 && !_ list->getSelectedString().empty());301 _chooseButton->setEnabled(selItem >= 0 && !_saveList[selItem].getBool("is_dummy")); 298 302 } 299 303 300 304 // Delete will always be disabled if the engine doesn't support it. 301 _deleteButton->setEnabled(isDeletable && (selItem >= 0) && (!_list->getSelectedString().empty())); 305 // Also don't allow trying to delete dummy list items. 306 _deleteButton->setEnabled(isDeletable && (selItem >= 0) && (!_saveList[selItem].getBool("is_dummy"))); 302 307 303 308 if (redraw) { 304 309 _gfxWidget->draw(); … … 328 333 int saveSlot = 0; 329 334 StringList saveNames; 330 335 for (SaveStateList::const_iterator x = _saveList.begin(); x != _saveList.end(); ++x) { 331 // Handle gaps in the list of save games 336 // Handle gaps in the list of save games by filling them with dummy SaveStateDescriptors 332 337 saveSlot = atoi(x->save_slot().c_str()); 333 338 if (curSlot < saveSlot) { 334 339 while (curSlot < saveSlot) { 335 340 SaveStateDescriptor dummySave(curSlot, ""); 341 dummySave.setDummyFlag(true); 336 342 _saveList.insert_at(curSlot, dummySave); 337 343 saveNames.push_back(dummySave.description()); 338 344 curSlot++; … … 349 355 curSlot++; 350 356 } 351 357 352 // Fill the rest of the save slots with empty saves358 // Fill the rest of the save slots with dummy saves 353 359 Common::String emptyDesc; 354 360 for (int i = curSlot; i <= (*_plugin)->getMaximumSaveSlot(); i++) { 355 361 saveNames.push_back(emptyDesc); 356 362 SaveStateDescriptor dummySave(i, ""); 363 dummySave.setDummyFlag(true); 357 364 _saveList.push_back(dummySave); 358 365 } 359 366 -
engines/game.cpp
128 128 return false; 129 129 } 130 130 131 void SaveStateDescriptor::setDummyFlag(bool state) { 132 setVal("is_dummy", state ? "true" : "false"); 133 } 134 131 135 void SaveStateDescriptor::setDeletableFlag(bool state) { 132 136 setVal("is_deletable", state ? "true" : "false"); 133 137 } -
engines/game.h
166 166 bool getBool(const Common::String &key) const; 167 167 168 168 /** 169 * Sets the 'is_dummy' key, which indicates if the 170 * given savestate is a dummy one 171 * (i.e. a filler for a gap in the savegame list). 172 */ 173 void setDummyFlag(bool state); 174 175 /** 169 176 * Sets the 'is_deletable' key, which indicates if the 170 177 * given savestate is safe for deletion. 171 178 */