diff options
author | Johannes Schickel | 2011-07-02 20:25:32 +0200 |
---|---|---|
committer | Johannes Schickel | 2011-07-02 21:07:55 +0200 |
commit | 09501be85bee9f686a7815fc0f47a1e16008f38d (patch) | |
tree | 5aecb20411d3300a185214f3a6590888f4559b35 /gui/saveload.cpp | |
parent | a5b0792295f46ebcf5d30df975bd2056bc4a695f (diff) | |
download | scummvm-rg350-09501be85bee9f686a7815fc0f47a1e16008f38d.tar.gz scummvm-rg350-09501be85bee9f686a7815fc0f47a1e16008f38d.tar.bz2 scummvm-rg350-09501be85bee9f686a7815fc0f47a1e16008f38d.zip |
ENGINES: Clean up SaveStateDescriptor.
Now SaveStateDescriptor no longer subclasses HashMap. Instead all possible
saved meta data is included directly into SaveStateDescriptor.
This is slightly less flexible, but we never needed that flexibility so far.
On the other hand it should reduce the memory usage. At least on my system
(Linux/amd64) the old SaveStateDescriptor had a size of 928 and the new
SaveStateDescriptor has a size of 200.
Diffstat (limited to 'gui/saveload.cpp')
-rw-r--r-- | gui/saveload.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/gui/saveload.cpp b/gui/saveload.cpp index 460246e5fc..02ddf814dc 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -131,7 +131,7 @@ void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 da if (_list->isEditable() || !_list->getSelectedString().empty()) { _list->endEditMode(); if (!_saveList.empty()) { - setResult(atoi(_saveList[selItem].save_slot().c_str())); + setResult(_saveList[selItem].getSaveSlot()); _resultString = _list->getSelectedString(); } close(); @@ -141,7 +141,7 @@ void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 da case kChooseCmd: _list->endEditMode(); if (!_saveList.empty()) { - setResult(atoi(_saveList[selItem].save_slot().c_str())); + setResult(_saveList[selItem].getSaveSlot()); _resultString = _list->getSelectedString(); } close(); @@ -154,7 +154,7 @@ void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 da MessageDialog alert(_("Do you really want to delete this savegame?"), _("Delete"), _("Cancel")); if (alert.runModal() == GUI::kMessageOK) { - (*_plugin)->removeSaveState(_target.c_str(), atoi(_saveList[selItem].save_slot().c_str())); + (*_plugin)->removeSaveState(_target.c_str(), _saveList[selItem].getSaveSlot()); setResult(-1); _list->setSelected(-1); @@ -241,10 +241,10 @@ void SaveLoadChooser::updateSelection(bool redraw) { _playtime->setLabel(_("No playtime saved")); if (selItem >= 0 && !_list->getSelectedString().empty() && _metaInfoSupport) { - SaveStateDescriptor desc = (*_plugin)->querySaveMetaInfos(_target.c_str(), atoi(_saveList[selItem].save_slot().c_str())); + SaveStateDescriptor desc = (*_plugin)->querySaveMetaInfos(_target.c_str(), _saveList[selItem].getSaveSlot()); - isDeletable = desc.getBool("is_deletable") && _delSupport; - isWriteProtected = desc.getBool("is_write_protected"); + isDeletable = desc.getDeletableFlag() && _delSupport; + isWriteProtected = desc.getWriteProtectedFlag(); // Don't allow the user to change the description of write protected games if (isWriteProtected) @@ -259,16 +259,19 @@ void SaveLoadChooser::updateSelection(bool redraw) { } if (_saveDateSupport) { - if (desc.contains("save_date")) - _date->setLabel(_("Date: ") + desc.getVal("save_date")); + const Common::String &saveDate = desc.getSaveDate(); + if (!saveDate.empty()) + _date->setLabel(_("Date: ") + saveDate); - if (desc.contains("save_time")) - _time->setLabel(_("Time: ") + desc.getVal("save_time")); + const Common::String &saveTime = desc.getSaveTime(); + if (!saveTime.empty()) + _time->setLabel(_("Time: ") + saveTime); } if (_playTimeSupport) { - if (desc.contains("play_time")) - _playtime->setLabel(_("Playtime: ") + desc.getVal("play_time")); + const Common::String &playTime = desc.getPlayTime(); + if (!playTime.empty()) + _playtime->setLabel(_("Playtime: ") + playTime); } } @@ -326,25 +329,25 @@ void SaveLoadChooser::updateSaveList() { ListWidget::ColorList colors; for (SaveStateList::const_iterator x = _saveList.begin(); x != _saveList.end(); ++x) { // Handle gaps in the list of save games - saveSlot = atoi(x->save_slot().c_str()); + saveSlot = x->getSaveSlot(); if (curSlot < saveSlot) { while (curSlot < saveSlot) { SaveStateDescriptor dummySave(curSlot, ""); _saveList.insert_at(curSlot, dummySave); - saveNames.push_back(dummySave.description()); + saveNames.push_back(dummySave.getDescription()); colors.push_back(ThemeEngine::kFontColorNormal); curSlot++; } // Sync the save list iterator for (x = _saveList.begin(); x != _saveList.end(); ++x) { - if (atoi(x->save_slot().c_str()) == saveSlot) + if (x->getSaveSlot() == saveSlot) break; } } // Show "Untitled savestate" for empty/whitespace savegame descriptions - Common::String description = x->description(); + Common::String description = x->getDescription(); Common::String trimmedDescription = description; trimmedDescription.trim(); if (trimmedDescription.empty()) { |