aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/saveload-dialog.cpp41
-rw-r--r--gui/saveload-dialog.h11
-rw-r--r--gui/saveload.cpp2
3 files changed, 51 insertions, 3 deletions
diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index 0a94fede51..3a778b2fa4 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -21,6 +21,7 @@
#include "gui/saveload-dialog.h"
#include "common/translation.h"
+#include "common/config-manager.h"
#include "gui/message.h"
#include "gui/gui-manager.h"
@@ -73,11 +74,17 @@ void SaveLoadChooserDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd
switch (cmd) {
case kListSwitchCmd:
setResult(kSwitchToList);
+ // We save the requested dialog type here to avoid the setting to be
+ // overwritten when our reflowLayout logic selects a different dialog
+ // type.
+ ConfMan.set("gui_saveload_chooser", "list", Common::ConfigManager::kApplicationDomain);
close();
break;
case kGridSwitchCmd:
setResult(kSwitchToGrid);
+ // See above.
+ ConfMan.set("gui_saveload_chooser", "grid", Common::ConfigManager::kApplicationDomain);
close();
break;
@@ -101,13 +108,45 @@ void SaveLoadChooserDialog::addChooserButtons() {
_listButton = createSwitchButton("SaveLoadChooser.ListSwitch", "L", _("List view"), ThemeEngine::kImageList, kListSwitchCmd);
_gridButton = createSwitchButton("SaveLoadChooser.GridSwitch", "G", _("Grid view"), ThemeEngine::kImageGrid, kGridSwitchCmd);
- if (!_metaInfoSupport || !_thumbnailSupport || _saveMode)
+ if (!_metaInfoSupport || !_thumbnailSupport || _saveMode || !(g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400))
_gridButton->setEnabled(false);
}
void SaveLoadChooserDialog::reflowLayout() {
addChooserButtons();
+ const SaveLoadChooserType currentType = getType();
+ SaveLoadChooserType requestedType;
+
+ const Common::String &userConfig = ConfMan.get("gui_saveload_chooser", Common::ConfigManager::kApplicationDomain);
+ if (!_saveMode && g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400
+ && _metaEngine->hasFeature(MetaEngine::kSavesSupportMetaInfo)
+ && _metaEngine->hasFeature(MetaEngine::kSavesSupportThumbnail)
+ && userConfig.equalsIgnoreCase("grid")) {
+ // In case we are 640x400 or higher, this dialog is not in save mode,
+ // the user requested the grid dialog and the engines supports it we
+ // try to set it up.
+ requestedType = kSaveLoadDialogGrid;
+ } else {
+ // In all other cases we want to use the list dialog.
+ requestedType = kSaveLoadDialogList;
+ }
+
+ // Change the dialog type if there is any need for it.
+ if (requestedType != currentType) {
+ switch (requestedType) {
+ case kSaveLoadDialogGrid:
+ setResult(kSwitchToGrid);
+ break;
+
+ case kSaveLoadDialogList:
+ setResult(kSwitchToList);
+ break;
+ }
+
+ close();
+ }
+
Dialog::reflowLayout();
}
diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h
index 7921f5798a..75b1dc41e0 100644
--- a/gui/saveload-dialog.h
+++ b/gui/saveload-dialog.h
@@ -32,6 +32,11 @@ namespace GUI {
#define kSwitchToList -2
#define kSwitchToGrid -3
+enum SaveLoadChooserType {
+ kSaveLoadDialogList = 0,
+ kSaveLoadDialogGrid = 1
+};
+
class SaveLoadChooserDialog : protected Dialog {
public:
SaveLoadChooserDialog(const Common::String &dialogName, const bool saveMode);
@@ -43,6 +48,8 @@ public:
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
+ virtual SaveLoadChooserType getType() const = 0;
+
int run(const Common::String &target, const MetaEngine *metaEngine);
virtual const Common::String &getResultString() const = 0;
@@ -77,6 +84,8 @@ public:
virtual void reflowLayout();
+ virtual SaveLoadChooserType getType() const { return kSaveLoadDialogList; }
+
virtual void close();
private:
virtual int runIntern();
@@ -109,6 +118,8 @@ public:
virtual void reflowLayout();
+ virtual SaveLoadChooserType getType() const { return kSaveLoadDialogGrid; }
+
virtual void close();
protected:
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
diff --git a/gui/saveload.cpp b/gui/saveload.cpp
index 9cc8935f03..7f3dd6d5d8 100644
--- a/gui/saveload.cpp
+++ b/gui/saveload.cpp
@@ -93,11 +93,9 @@ int SaveLoadChooser::runModalWithPluginAndTarget(const EnginePlugin *plugin, con
if (ret == kSwitchToList) {
delete _impl;
_impl = new SaveLoadChooserSimple(_title, _buttonLabel, _saveMode);
- ConfMan.set("gui_saveload_chooser", "list", Common::ConfigManager::kApplicationDomain);
} else if (ret == kSwitchToGrid) {
delete _impl;
_impl = new LoadChooserThumbnailed(_title);
- ConfMan.set("gui_saveload_chooser", "grid", Common::ConfigManager::kApplicationDomain);
}
} while (ret < -1);