GUI: Factor out save/load activation to a function
This commit is contained in:
parent
4796729a58
commit
44e5d3f9bd
2 changed files with 19 additions and 22 deletions
|
@ -330,6 +330,17 @@ void SaveLoadChooserDialog::listSaves() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SaveLoadChooserDialog::activate(int slot, const Common::U32String &description) {
|
||||||
|
if (!_saveList.empty() && slot < int(_saveList.size())) {
|
||||||
|
const SaveStateDescriptor &desc = _saveList[slot];
|
||||||
|
if (_saveMode) {
|
||||||
|
_resultString = description.empty() ? desc.getDescription() : description;
|
||||||
|
}
|
||||||
|
setResult(desc.getSaveSlot());
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_SAVELOADCHOOSER_GRID
|
#ifndef DISABLE_SAVELOADCHOOSER_GRID
|
||||||
void SaveLoadChooserDialog::addChooserButtons() {
|
void SaveLoadChooserDialog::addChooserButtons() {
|
||||||
if (_listButton) {
|
if (_listButton) {
|
||||||
|
@ -441,22 +452,14 @@ void SaveLoadChooserSimple::handleCommand(CommandSender *sender, uint32 cmd, uin
|
||||||
if (selItem >= 0 && _chooseButton->isEnabled()) {
|
if (selItem >= 0 && _chooseButton->isEnabled()) {
|
||||||
if (_list->isEditable() || !_list->getSelectedString().empty()) {
|
if (_list->isEditable() || !_list->getSelectedString().empty()) {
|
||||||
_list->endEditMode();
|
_list->endEditMode();
|
||||||
if (!_saveList.empty()) {
|
activate(selItem, _list->getSelectedString());
|
||||||
setResult(_saveList[selItem].getSaveSlot());
|
|
||||||
_resultString = _list->getSelectedString();
|
|
||||||
}
|
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kChooseCmd:
|
case kChooseCmd:
|
||||||
_list->endEditMode();
|
_list->endEditMode();
|
||||||
if (selItem >= 0) {
|
if (selItem >= 0) {
|
||||||
if (!_saveList.empty()) {
|
activate(selItem, _list->getSelectedString());
|
||||||
setResult(_saveList[selItem].getSaveSlot());
|
|
||||||
_resultString = _list->getSelectedString();
|
|
||||||
}
|
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kListSelectionChangedCmd:
|
case kListSelectionChangedCmd:
|
||||||
|
@ -793,15 +796,9 @@ const Common::U32String &SaveLoadChooserGrid::getResultString() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveLoadChooserGrid::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
void SaveLoadChooserGrid::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||||
if (cmd <= _entriesPerPage && cmd + _curPage * _entriesPerPage <= _saveList.size()) {
|
const int slot = cmd + _curPage * _entriesPerPage - 1;
|
||||||
const SaveStateDescriptor &desc = _saveList[cmd - 1 + _curPage * _entriesPerPage];
|
if (cmd <= _entriesPerPage) {
|
||||||
|
activate(slot, Common::U32String());
|
||||||
if (_saveMode) {
|
|
||||||
_resultString = desc.getDescription();
|
|
||||||
}
|
|
||||||
|
|
||||||
setResult(desc.getSaveSlot());
|
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
|
|
@ -110,6 +110,8 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void listSaves();
|
virtual void listSaves();
|
||||||
|
|
||||||
|
void activate(int slot, const Common::U32String &description);
|
||||||
|
|
||||||
const bool _saveMode;
|
const bool _saveMode;
|
||||||
const MetaEngine *_metaEngine;
|
const MetaEngine *_metaEngine;
|
||||||
bool _delSupport;
|
bool _delSupport;
|
||||||
|
@ -120,6 +122,7 @@ protected:
|
||||||
Common::String _target;
|
Common::String _target;
|
||||||
bool _dialogWasShown;
|
bool _dialogWasShown;
|
||||||
SaveStateList _saveList;
|
SaveStateList _saveList;
|
||||||
|
Common::U32String _resultString;
|
||||||
|
|
||||||
#ifndef DISABLE_SAVELOADCHOOSER_GRID
|
#ifndef DISABLE_SAVELOADCHOOSER_GRID
|
||||||
ButtonWidget *_listButton;
|
ButtonWidget *_listButton;
|
||||||
|
@ -166,8 +169,6 @@ private:
|
||||||
StaticTextWidget *_playtime;
|
StaticTextWidget *_playtime;
|
||||||
StaticTextWidget *_pageTitle;
|
StaticTextWidget *_pageTitle;
|
||||||
|
|
||||||
U32String _resultString;
|
|
||||||
|
|
||||||
void addThumbnailContainer();
|
void addThumbnailContainer();
|
||||||
void updateSelection(bool redraw);
|
void updateSelection(bool redraw);
|
||||||
};
|
};
|
||||||
|
@ -227,7 +228,6 @@ private:
|
||||||
|
|
||||||
ContainerWidget *_newSaveContainer;
|
ContainerWidget *_newSaveContainer;
|
||||||
int _nextFreeSaveSlot;
|
int _nextFreeSaveSlot;
|
||||||
Common::U32String _resultString;
|
|
||||||
|
|
||||||
SavenameDialog _savenameDialog;
|
SavenameDialog _savenameDialog;
|
||||||
bool selectDescription();
|
bool selectDescription();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue