diff options
author | Alexander Tkachev | 2016-06-06 12:22:22 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | f1a56eaf3666a6535ff0d1654e4e014249933452 (patch) | |
tree | e48d1598f023d0915fb3d559fb6648b0f6d3e1a0 /gui | |
parent | 6c5a8f34eaf5fe6af0d885cb162b5ebf193030f8 (diff) | |
download | scummvm-rg350-f1a56eaf3666a6535ff0d1654e4e014249933452.tar.gz scummvm-rg350-f1a56eaf3666a6535ff0d1654e4e014249933452.tar.bz2 scummvm-rg350-f1a56eaf3666a6535ff0d1654e4e014249933452.zip |
GUI: Show "locked" saves during sync
Diffstat (limited to 'gui')
-rw-r--r-- | gui/saveload-dialog.cpp | 56 | ||||
-rw-r--r-- | gui/saveload-dialog.h | 19 |
2 files changed, 58 insertions, 17 deletions
diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 2646194b4b..5360bfe1ac 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -251,6 +251,32 @@ void SaveLoadChooserDialog::reflowLayout() { void SaveLoadChooserDialog::updateSaveList() { Common::Array<Common::String> files = CloudMan.getSyncingFiles(); //returns empty array if not syncing g_system->getSavefileManager()->updateSavefilesList(files); + listSaves(); +} + +void SaveLoadChooserDialog::listSaves() { + _saveList = _metaEngine->listSaves(_target.c_str()); + + Common::String pattern = _metaEngine->getSavefilesPattern(_target); + Common::Array<Common::String> files = CloudMan.getSyncingFiles(); //returns empty array if not syncing + for (uint32 i = 0; i < files.size(); ++i) { + if (!files[i].matchString(pattern, true)) continue; + + //make up some slot number + int slotNum = 0; + for (int j = files[i].size() - 3; j < files[i].size(); ++j) { //3 last chars + if (j < 0) continue; + char c = files[i][j]; + if (c < '0' || c > '9') continue; + slotNum = slotNum * 10 + (c - '0'); + } + + SaveStateDescriptor slot(slotNum, files[i]); + slot.setLocked(true); + _saveList.push_back(slot); + } + + Common::sort(_saveList.begin(), _saveList.end(), SaveStateDescriptorSlotComparator()); } #ifndef DISABLE_SAVELOADCHOOSER_GRID @@ -454,6 +480,7 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) { bool isDeletable = _delSupport; bool isWriteProtected = false; bool startEditMode = _list->isEditable(); + bool isLocked = false; // We used to support letting the themes specify the fill color with our // initial theme based GUI. But this support was dropped. @@ -463,10 +490,11 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) { _playtime->setLabel(_("No playtime saved")); if (selItem >= 0 && _metaInfoSupport) { - SaveStateDescriptor desc = _metaEngine->querySaveMetaInfos(_target.c_str(), _saveList[selItem].getSaveSlot()); + SaveStateDescriptor desc = (_saveList[selItem].getLocked() ? _saveList[selItem] : _metaEngine->querySaveMetaInfos(_target.c_str(), _saveList[selItem].getSaveSlot())); isDeletable = desc.getDeletableFlag() && _delSupport; isWriteProtected = desc.getWriteProtectedFlag(); + isLocked = desc.getLocked(); // Don't allow the user to change the description of write protected games if (isWriteProtected) @@ -499,9 +527,9 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) { if (_list->isEditable()) { - // Disable the save button if nothing is selected, or if the selected - // game is write protected - _chooseButton->setEnabled(selItem >= 0 && !isWriteProtected); + // Disable the save button if slot is locked, nothing is selected, + // or if the selected game is write protected + _chooseButton->setEnabled(!isLocked && selItem >= 0 && !isWriteProtected); if (startEditMode) { _list->startEditMode(); @@ -513,13 +541,13 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) { } } } else { - // Disable the load button if nothing is selected, or if an empty - // list item is selected. - _chooseButton->setEnabled(selItem >= 0 && !_list->getSelectedString().empty()); + // Disable the load button if slot is locked, nothing is selected, + // or if an empty list item is selected. + _chooseButton->setEnabled(!isLocked && selItem >= 0 && !_list->getSelectedString().empty()); } // Delete will always be disabled if the engine doesn't support it. - _deleteButton->setEnabled(isDeletable && (selItem >= 0) && (!_list->getSelectedString().empty())); + _deleteButton->setEnabled(isDeletable && !isLocked && (selItem >= 0) && (!_list->getSelectedString().empty())); if (redraw) { _gfxWidget->draw(); @@ -565,7 +593,6 @@ void SaveLoadChooserSimple::close() { void SaveLoadChooserSimple::updateSaveList() { SaveLoadChooserDialog::updateSaveList(); - _saveList = _metaEngine->listSaves(_target.c_str()); int curSlot = 0; int saveSlot = 0; @@ -598,7 +625,7 @@ void SaveLoadChooserSimple::updateSaveList() { description = _("Untitled savestate"); colors.push_back(ThemeEngine::kFontColorAlternate); } else { - colors.push_back(ThemeEngine::kFontColorNormal); + colors.push_back((x->getLocked() ? ThemeEngine::kFontColorAlternate : ThemeEngine::kFontColorNormal)); } saveNames.push_back(description); @@ -724,7 +751,6 @@ void SaveLoadChooserGrid::handleMouseWheel(int x, int y, int direction) { void SaveLoadChooserGrid::updateSaveList() { SaveLoadChooserDialog::updateSaveList(); - _saveList = _metaEngine->listSaves(_target.c_str()); updateSaves(); draw(); } @@ -732,7 +758,7 @@ void SaveLoadChooserGrid::updateSaveList() { void SaveLoadChooserGrid::open() { SaveLoadChooserDialog::open(); - _saveList = _metaEngine->listSaves(_target.c_str()); + listSaves(); _resultString.clear(); // Load information to restore the last page the user had open. @@ -973,7 +999,7 @@ void SaveLoadChooserGrid::updateSaves() { for (uint i = _curPage * _entriesPerPage, curNum = 0; i < _saveList.size() && curNum < _entriesPerPage; ++i, ++curNum) { const uint saveSlot = _saveList[i].getSaveSlot(); - SaveStateDescriptor desc = _metaEngine->querySaveMetaInfos(_target.c_str(), saveSlot); + SaveStateDescriptor desc = (_saveList[i].getLocked() ? _saveList[i] : _metaEngine->querySaveMetaInfos(_target.c_str(), saveSlot)); SlotButton &curButton = _buttons[curNum]; curButton.setVisible(true); const Graphics::Surface *thumbnail = desc.getThumbnail(); @@ -984,6 +1010,10 @@ void SaveLoadChooserGrid::updateSaves() { } curButton.description->setLabel(Common::String::format("%d. %s", saveSlot, desc.getDescription().c_str())); + //that would make it look "disabled" if slot is locked + curButton.button->setEnabled(!desc.getLocked()); + curButton.description->setEnabled(!desc.getLocked()); + Common::String tooltip(_("Name: ")); tooltip += desc.getDescription(); diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index 435bfc7a5d..a81e03c881 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -89,8 +89,20 @@ public: protected: virtual int runIntern() = 0; + + /** Common function to refresh the list on the screen. */ virtual void updateSaveList(); + /** + * Common function to get saves list from MetaEngine. + * + * It also checks whether there are some locked saves + * because of saves sync and adds such saves as locked + * slots. User sees these slots, but is unable to save + * or load from these. + */ + virtual void listSaves(); + const bool _saveMode; const MetaEngine *_metaEngine; bool _delSupport; @@ -100,6 +112,7 @@ protected: bool _playTimeSupport; Common::String _target; bool _dialogWasShown; + SaveStateList _saveList; #ifndef DISABLE_SAVELOADCHOOSER_GRID ButtonWidget *_listButton; @@ -128,8 +141,8 @@ public: virtual void open(); virtual void close(); -protected: - virtual void updateSaveList(); +protected: + virtual void updateSaveList(); private: virtual int runIntern(); @@ -142,7 +155,6 @@ private: StaticTextWidget *_time; StaticTextWidget *_playtime; - SaveStateList _saveList; String _resultString; void updateSelection(bool redraw); @@ -194,7 +206,6 @@ private: uint _columns, _lines; uint _entriesPerPage; uint _curPage; - SaveStateList _saveList; ButtonWidget *_nextButton; ButtonWidget *_prevButton; |