aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJohannes Schickel2008-09-16 14:10:55 +0000
committerJohannes Schickel2008-09-16 14:10:55 +0000
commit259d87a8a68d443d2bbb2bcc1887b4f11b7d342e (patch)
tree15389a0901e3439eda5b83975f0d98556fbd2b41 /gui
parent9d96d9d3806c43107ffcf4173bd99c3d10eeb565 (diff)
downloadscummvm-rg350-259d87a8a68d443d2bbb2bcc1887b4f11b7d342e.tar.gz
scummvm-rg350-259d87a8a68d443d2bbb2bcc1887b4f11b7d342e.tar.bz2
scummvm-rg350-259d87a8a68d443d2bbb2bcc1887b4f11b7d342e.zip
Added "querySaveMetaInfos" to MetaEngine.
-> Allows easy addition of save state specific infos like playtime, save date atc. -> Removed MetaEngine::loadThumbnailFromSlot, superseded by meta infos -> Changed SCUMM / KYRA to implement the newly added functionallity -> Removed hack in KYRAs listSavefiles, which is now handled via meta infos svn-id: r34581
Diffstat (limited to 'gui')
-rw-r--r--gui/launcher.cpp72
-rw-r--r--gui/widget.cpp3
2 files changed, 42 insertions, 33 deletions
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 3674da5a97..1d50f21998 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -477,7 +477,6 @@ class SaveLoadChooser : public GUI::Dialog {
typedef Common::String String;
typedef Common::StringList StringList;
protected:
- bool _delSupport;
GUI::ListWidget *_list;
GUI::ButtonWidget *_chooseButton;
GUI::ButtonWidget *_deleteButton;
@@ -485,13 +484,16 @@ protected:
GUI::ContainerWidget *_container;
const EnginePlugin *_plugin;
+ bool _delSupport;
+ bool _metaInfoSupport;
+ bool _thumbnailSupport;
String _target;
SaveStateList _saveList;
uint8 _fillR, _fillG, _fillB;
void updateSaveList();
- void updateInfos(bool redraw);
+ void updateSelection(bool redraw);
public:
SaveLoadChooser(const String &title, const String &buttonLabel);
~SaveLoadChooser();
@@ -528,6 +530,8 @@ SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel)
_deleteButton = new GUI::ButtonWidget(this, "scummsaveload_delete", "Delete", kDelCmd, 0);
_deleteButton->setEnabled(false);
+
+ _delSupport = _metaInfoSupport = _thumbnailSupport = false;
}
SaveLoadChooser::~SaveLoadChooser() {
@@ -540,6 +544,8 @@ int SaveLoadChooser::runModal(const EnginePlugin *plugin, const String &target)
_plugin = plugin;
_target = target;
_delSupport = (*_plugin)->hasFeature(MetaEngine::kSupportsDeleteSave);
+ _metaInfoSupport = (*_plugin)->hasFeature(MetaEngine::kSupportsMetaInfos);
+ _thumbnailSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSupportsThumbnails);
reflowLayout();
updateSaveList();
@@ -566,16 +572,7 @@ void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 da
close();
break;
case GUI::kListSelectionChangedCmd: {
- if (_gfxWidget)
- updateInfos(true);
-
- // Disable these buttons if nothing is selected, or if an empty
- // list item is selected.
- _chooseButton->setEnabled(selItem >= 0 && (!_list->getSelectedString().empty()));
- _chooseButton->draw();
- // Delete will always be disabled if the engine doesn't support it.
- _deleteButton->setEnabled(_delSupport && (selItem >= 0) && (!_list->getSelectedString().empty()));
- _deleteButton->draw();
+ updateSelection(true);
} break;
case kDelCmd:
if (selItem >= 0 && _delSupport) {
@@ -588,10 +585,7 @@ void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 da
_list->setSelected(-1);
updateSaveList();
-
- // Disable these buttons again after deleteing a selection
- _chooseButton->setEnabled(false);
- _deleteButton->setEnabled(false);
+ updateSelection(true);
}
}
break;
@@ -603,7 +597,7 @@ void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 da
}
void SaveLoadChooser::reflowLayout() {
- if (g_gui.evaluator()->getVar("scummsaveload_extinfo.visible") == 1 && (_plugin && (*_plugin)->hasFeature(MetaEngine::kSupportsThumbnails))) {
+ if (g_gui.evaluator()->getVar("scummsaveload_extinfo.visible") == 1 && _thumbnailSupport) {
int thumbX = g_gui.evaluator()->getVar("scummsaveload_thumbnail.x");
int thumbY = g_gui.evaluator()->getVar("scummsaveload_thumbnail.y");
int hPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.hPad");
@@ -621,7 +615,7 @@ void SaveLoadChooser::reflowLayout() {
_fillR = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillR");
_fillG = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillG");
_fillB = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillB");
- updateInfos(false);
+ updateSelection(false);
} else {
_container->setFlags(GUI::WIDGET_INVISIBLE);
_gfxWidget->setFlags(GUI::WIDGET_INVISIBLE);
@@ -630,23 +624,39 @@ void SaveLoadChooser::reflowLayout() {
Dialog::reflowLayout();
}
-void SaveLoadChooser::updateInfos(bool redraw) {
+void SaveLoadChooser::updateSelection(bool redraw) {
int selItem = _list->getSelected();
- Graphics::Surface *thumb = 0;
- if (selItem >= 0 && !_list->getSelectedString().empty())
- thumb = (*_plugin)->loadThumbnailFromSlot(_target.c_str(), atoi(_saveList[selItem].save_slot().c_str()));
-
- if (thumb) {
- _gfxWidget->setGfx(thumb);
- _gfxWidget->useAlpha(256);
- thumb->free();
- delete thumb;
- } else {
- _gfxWidget->setGfx(-1, -1, _fillR, _fillG, _fillB);
+
+ bool isDeletable = _delSupport;
+
+ if (selItem >= 0 && !_list->getSelectedString().empty() && _metaInfoSupport) {
+ SaveStateDescriptor desc = (*_plugin)->querySaveMetaInfos(_target.c_str(), atoi(_saveList[selItem].save_slot().c_str()));
+
+ isDeletable = desc.getBool("is_deletable") && _delSupport;
+
+ if (_thumbnailSupport) {
+ const Graphics::Surface *thumb = desc.getThumbnail();
+ if (thumb) {
+ _gfxWidget->setGfx(thumb);
+ _gfxWidget->useAlpha(256);
+ } else {
+ _gfxWidget->setGfx(-1, -1, _fillR, _fillG, _fillB);
+ }
+ }
}
- if (redraw)
+
+ // Disable these buttons if nothing is selected, or if an empty
+ // list item is selected.
+ _chooseButton->setEnabled(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()));
+
+ if (redraw) {
_gfxWidget->draw();
+ _chooseButton->draw();
+ _deleteButton->draw();
+ }
}
void SaveLoadChooser::close() {
diff --git a/gui/widget.cpp b/gui/widget.cpp
index e9afc30301..31f76eac6f 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -363,8 +363,7 @@ void GraphicsWidget::setGfx(const Graphics::Surface *gfx) {
return;
// TODO: add conversion to OverlayColor
- _gfx.create(gfx->w, gfx->h, gfx->bytesPerPixel);
- memcpy(_gfx.pixels, gfx->pixels, gfx->h * gfx->pitch);
+ _gfx.copyFrom(*gfx);
}
void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) {