From 1e8eea426899fee80bae496ca74b4230294c6e67 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 21 Mar 2012 14:55:12 -0400 Subject: CREDITS: Add pegasus --- gui/credits.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index ecfe280d20..928799efd7 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -157,6 +157,9 @@ static const char *credits[] = { "C1""Parallaction", "C0""peres", "", +"C1""Pegasus", +"C0""Matthew Hoops", +"", "C1""Queen", "C0""David Eriksson", "C2""(retired)", @@ -710,5 +713,7 @@ static const char *credits[] = { "C0""", "C0""Broken Sword 2.5 team for providing sources of their engine and their great support.", "C0""", +"C0""Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for providing the source code of The Journeyman Project: Pegasus Prime.", +"C0""", "", }; -- cgit v1.2.3 From 27b8b7e9b6644767ad9de1e40c188a7abd631c4e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 10 Jun 2012 04:06:25 +0200 Subject: GUI: Hide save/load chooser implementation. --- gui/saveload.cpp | 125 +++++++++++++++++++++++++++++++++++++++++++------------ gui/saveload.h | 43 ++----------------- 2 files changed, 103 insertions(+), 65 deletions(-) (limited to 'gui') diff --git a/gui/saveload.cpp b/gui/saveload.cpp index 67d871e133..717523b107 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -41,8 +41,52 @@ enum { }; -SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode) - : Dialog("SaveLoadChooser"), _delSupport(0), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0) { +class SaveLoadChooserImpl : GUI::Dialog { + typedef Common::String String; + typedef Common::Array StringArray; +public: + SaveLoadChooserImpl(const String &title, const String &buttonLabel, bool saveMode); + + int runModalWithCurrentTarget(); + int runModalWithPluginAndTarget(const EnginePlugin *plugin, const String &target); + + virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); + + const Common::String &getResultString() const; + + virtual void open(); + + virtual void reflowLayout(); + + virtual void close(); +private: + GUI::ListWidget *_list; + GUI::ButtonWidget *_chooseButton; + GUI::ButtonWidget *_deleteButton; + GUI::GraphicsWidget *_gfxWidget; + GUI::ContainerWidget *_container; + GUI::StaticTextWidget *_date; + GUI::StaticTextWidget *_time; + GUI::StaticTextWidget *_playtime; + + const EnginePlugin *_plugin; + bool _delSupport; + bool _metaInfoSupport; + bool _thumbnailSupport; + bool _saveDateSupport; + bool _playTimeSupport; + String _target; + SaveStateList _saveList; + String _resultString; + + uint8 _fillR, _fillG, _fillB; + + void updateSaveList(); + void updateSelection(bool redraw); +}; + +SaveLoadChooserImpl::SaveLoadChooserImpl(const String &title, const String &buttonLabel, bool saveMode) + : Dialog("SaveLoadChooser"), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0) { _delSupport = _metaInfoSupport = _thumbnailSupport = _saveDateSupport = _playTimeSupport = false; _backgroundType = ThemeEngine::kDialogBackgroundSpecial; @@ -74,10 +118,7 @@ SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, // _container->setHints(GUI::THEME_HINT_USE_SHADOW); } -SaveLoadChooser::~SaveLoadChooser() { -} - -int SaveLoadChooser::runModalWithCurrentTarget() { +int SaveLoadChooserImpl::runModalWithCurrentTarget() { const Common::String gameId = ConfMan.get("gameid"); const EnginePlugin *plugin = 0; @@ -86,7 +127,7 @@ int SaveLoadChooser::runModalWithCurrentTarget() { return runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); } -int SaveLoadChooser::runModalWithPluginAndTarget(const EnginePlugin *plugin, const String &target) { +int SaveLoadChooserImpl::runModalWithPluginAndTarget(const EnginePlugin *plugin, const String &target) { if (_gfxWidget) _gfxWidget->setGfx(0); @@ -114,7 +155,7 @@ int SaveLoadChooser::runModalWithPluginAndTarget(const EnginePlugin *plugin, con return ret; } -void SaveLoadChooser::open() { +void SaveLoadChooserImpl::open() { Dialog::open(); // So that quitting ScummVM will not cause the dialog result to say a @@ -122,24 +163,12 @@ void SaveLoadChooser::open() { setResult(-1); } -const Common::String &SaveLoadChooser::getResultString() const { +const Common::String &SaveLoadChooserImpl::getResultString() const { int selItem = _list->getSelected(); return (selItem >= 0) ? _list->getSelectedString() : _resultString; } -Common::String SaveLoadChooser::createDefaultSaveDescription(const int slot) const { -#if defined(USE_SAVEGAME_TIMESTAMP) - TimeDate curTime; - g_system->getTimeAndDate(curTime); - curTime.tm_year += 1900; // fixup year - curTime.tm_mon++; // fixup month - return Common::String::format("%04d.%02d.%02d / %02d:%02d:%02d", curTime.tm_year, curTime.tm_mon, curTime.tm_mday, curTime.tm_hour, curTime.tm_min, curTime.tm_sec); -#else - return Common::String::format("Save %d", slot + 1); -#endif -} - -void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { +void SaveLoadChooserImpl::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { int selItem = _list->getSelected(); switch (cmd) { @@ -189,7 +218,7 @@ void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 da } } -void SaveLoadChooser::reflowLayout() { +void SaveLoadChooserImpl::reflowLayout() { if (g_gui.xmlEval()->getVar("Globals.SaveLoadChooser.ExtInfo.Visible") == 1 && _thumbnailSupport) { int16 x, y; uint16 w, h; @@ -246,7 +275,7 @@ void SaveLoadChooser::reflowLayout() { Dialog::reflowLayout(); } -void SaveLoadChooser::updateSelection(bool redraw) { +void SaveLoadChooserImpl::updateSelection(bool redraw) { int selItem = _list->getSelected(); bool isDeletable = _delSupport; @@ -329,7 +358,7 @@ void SaveLoadChooser::updateSelection(bool redraw) { } } -void SaveLoadChooser::close() { +void SaveLoadChooserImpl::close() { _plugin = 0; _target.clear(); _saveList.clear(); @@ -338,7 +367,7 @@ void SaveLoadChooser::close() { Dialog::close(); } -void SaveLoadChooser::updateSaveList() { +void SaveLoadChooserImpl::updateSaveList() { _saveList = (*_plugin)->listSaves(_target.c_str()); int curSlot = 0; @@ -402,4 +431,48 @@ void SaveLoadChooser::updateSaveList() { _list->setList(saveNames, &colors); } +// --- SaveLoadChooser implementation --- + +SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode) { + _impl = new SaveLoadChooserImpl(title, buttonLabel, saveMode); +} + +SaveLoadChooser::~SaveLoadChooser() { + delete _impl; + _impl = 0; +} + +Common::String SaveLoadChooser::createDefaultSaveDescription(const int slot) const { +#if defined(USE_SAVEGAME_TIMESTAMP) + TimeDate curTime; + g_system->getTimeAndDate(curTime); + curTime.tm_year += 1900; // fixup year + curTime.tm_mon++; // fixup month + return Common::String::format("%04d.%02d.%02d / %02d:%02d:%02d", curTime.tm_year, curTime.tm_mon, curTime.tm_mday, curTime.tm_hour, curTime.tm_min, curTime.tm_sec); +#else + return Common::String::format("Save %d", slot + 1); +#endif +} + +int SaveLoadChooser::runModalWithCurrentTarget() { + if (_impl) + return _impl->runModalWithCurrentTarget(); + else + return -1; +} + +int SaveLoadChooser::runModalWithPluginAndTarget(const EnginePlugin *plugin, const String &target) { + if (_impl) + return _impl->runModalWithPluginAndTarget(plugin, target); + else + return -1; +} + +Common::String SaveLoadChooser::getResultString() const { + if (_impl) + return _impl->getResultString(); + else + return Common::String(); +} + } // End of namespace GUI diff --git a/gui/saveload.h b/gui/saveload.h index a19f5ab083..9cd3c4605f 100644 --- a/gui/saveload.h +++ b/gui/saveload.h @@ -27,46 +27,16 @@ namespace GUI { -class ListWidget; -class GraphicsWidget; -class ButtonWidget; -class CommandSender; -class ContainerWidget; -class StaticTextWidget; +class SaveLoadChooserImpl; -class SaveLoadChooser : GUI::Dialog { +class SaveLoadChooser { typedef Common::String String; - typedef Common::Array StringArray; protected: - GUI::ListWidget *_list; - GUI::ButtonWidget *_chooseButton; - GUI::ButtonWidget *_deleteButton; - GUI::GraphicsWidget *_gfxWidget; - GUI::ContainerWidget *_container; - GUI::StaticTextWidget *_date; - GUI::StaticTextWidget *_time; - GUI::StaticTextWidget *_playtime; - - const EnginePlugin *_plugin; - bool _delSupport; - bool _metaInfoSupport; - bool _thumbnailSupport; - bool _saveDateSupport; - bool _playTimeSupport; - String _target; - SaveStateList _saveList; - String _resultString; - - uint8 _fillR, _fillG, _fillB; - - void updateSaveList(); - void updateSelection(bool redraw); + SaveLoadChooserImpl *_impl; public: SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode); ~SaveLoadChooser(); - virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); - /** * Runs the save/load chooser with the currently active config manager * domain as target. @@ -75,9 +45,8 @@ public: */ int runModalWithCurrentTarget(); int runModalWithPluginAndTarget(const EnginePlugin *plugin, const String &target); - void open(); - const Common::String &getResultString() const; + Common::String getResultString() const; /** * Creates a default save description for the specified slot. Depending @@ -93,10 +62,6 @@ public: * @return The slot description. */ Common::String createDefaultSaveDescription(const int slot) const; - - virtual void reflowLayout(); - - virtual void close(); }; } // End of namespace GUI -- cgit v1.2.3 From e866dfd4069dfb4418ebdc0d4522b56aebed7522 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 14 Jun 2012 03:13:49 +0200 Subject: GUI: Refactor engine plugin access out of SaveLoadChooserImpl into SaveLoadChooser. --- gui/saveload.cpp | 77 ++++++++++++++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 41 deletions(-) (limited to 'gui') diff --git a/gui/saveload.cpp b/gui/saveload.cpp index 717523b107..e2f9461ddb 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -47,8 +47,7 @@ class SaveLoadChooserImpl : GUI::Dialog { public: SaveLoadChooserImpl(const String &title, const String &buttonLabel, bool saveMode); - int runModalWithCurrentTarget(); - int runModalWithPluginAndTarget(const EnginePlugin *plugin, const String &target); + int run(const String &target, const MetaEngine *metaEngine); virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); @@ -69,7 +68,7 @@ private: GUI::StaticTextWidget *_time; GUI::StaticTextWidget *_playtime; - const EnginePlugin *_plugin; + const MetaEngine *_metaEngine; bool _delSupport; bool _metaInfoSupport; bool _thumbnailSupport; @@ -118,41 +117,22 @@ SaveLoadChooserImpl::SaveLoadChooserImpl(const String &title, const String &butt // _container->setHints(GUI::THEME_HINT_USE_SHADOW); } -int SaveLoadChooserImpl::runModalWithCurrentTarget() { - const Common::String gameId = ConfMan.get("gameid"); - - const EnginePlugin *plugin = 0; - EngineMan.findGame(gameId, &plugin); - - return runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); -} - -int SaveLoadChooserImpl::runModalWithPluginAndTarget(const EnginePlugin *plugin, const String &target) { +int SaveLoadChooserImpl::run(const String &target, const MetaEngine *metaEngine) { if (_gfxWidget) _gfxWidget->setGfx(0); - // Set up the game domain as newly active domain, so - // target specific savepath will be checked - String oldDomain = ConfMan.getActiveDomainName(); - ConfMan.setActiveDomain(target); - - _plugin = plugin; + _metaEngine = metaEngine; _target = target; - _delSupport = (*_plugin)->hasFeature(MetaEngine::kSupportsDeleteSave); - _metaInfoSupport = (*_plugin)->hasFeature(MetaEngine::kSavesSupportMetaInfo); - _thumbnailSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSavesSupportThumbnail); - _saveDateSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSavesSupportCreationDate); - _playTimeSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSavesSupportPlayTime); + _delSupport = _metaEngine->hasFeature(MetaEngine::kSupportsDeleteSave); + _metaInfoSupport = _metaEngine->hasFeature(MetaEngine::kSavesSupportMetaInfo); + _thumbnailSupport = _metaInfoSupport && _metaEngine->hasFeature(MetaEngine::kSavesSupportThumbnail); + _saveDateSupport = _metaInfoSupport && _metaEngine->hasFeature(MetaEngine::kSavesSupportCreationDate); + _playTimeSupport = _metaInfoSupport && _metaEngine->hasFeature(MetaEngine::kSavesSupportPlayTime); _resultString.clear(); reflowLayout(); updateSaveList(); - int ret = Dialog::runModal(); - - // Revert to the old active domain - ConfMan.setActiveDomain(oldDomain); - - return ret; + return Dialog::runModal(); } void SaveLoadChooserImpl::open() { @@ -201,7 +181,7 @@ void SaveLoadChooserImpl::handleCommand(CommandSender *sender, uint32 cmd, uint3 MessageDialog alert(_("Do you really want to delete this savegame?"), _("Delete"), _("Cancel")); if (alert.runModal() == GUI::kMessageOK) { - (*_plugin)->removeSaveState(_target.c_str(), _saveList[selItem].getSaveSlot()); + _metaEngine->removeSaveState(_target.c_str(), _saveList[selItem].getSaveSlot()); setResult(-1); _list->setSelected(-1); @@ -288,7 +268,7 @@ void SaveLoadChooserImpl::updateSelection(bool redraw) { _playtime->setLabel(_("No playtime saved")); if (selItem >= 0 && _metaInfoSupport) { - SaveStateDescriptor desc = (*_plugin)->querySaveMetaInfos(_target.c_str(), _saveList[selItem].getSaveSlot()); + SaveStateDescriptor desc = _metaEngine->querySaveMetaInfos(_target.c_str(), _saveList[selItem].getSaveSlot()); isDeletable = desc.getDeletableFlag() && _delSupport; isWriteProtected = desc.getWriteProtectedFlag(); @@ -359,7 +339,7 @@ void SaveLoadChooserImpl::updateSelection(bool redraw) { } void SaveLoadChooserImpl::close() { - _plugin = 0; + _metaEngine = 0; _target.clear(); _saveList.clear(); _list->setList(StringArray()); @@ -368,7 +348,7 @@ void SaveLoadChooserImpl::close() { } void SaveLoadChooserImpl::updateSaveList() { - _saveList = (*_plugin)->listSaves(_target.c_str()); + _saveList = _metaEngine->listSaves(_target.c_str()); int curSlot = 0; int saveSlot = 0; @@ -410,7 +390,7 @@ void SaveLoadChooserImpl::updateSaveList() { // Fill the rest of the save slots with empty saves - int maximumSaveSlots = (*_plugin)->getMaximumSaveSlot(); + int maximumSaveSlots = _metaEngine->getMaximumSaveSlot(); #ifdef __DS__ // Low memory on the DS means too many save slots are impractical, so limit @@ -455,17 +435,32 @@ Common::String SaveLoadChooser::createDefaultSaveDescription(const int slot) con } int SaveLoadChooser::runModalWithCurrentTarget() { - if (_impl) - return _impl->runModalWithCurrentTarget(); - else + if (!_impl) return -1; + + const Common::String gameId = ConfMan.get("gameid"); + + const EnginePlugin *plugin = 0; + EngineMan.findGame(gameId, &plugin); + + return runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); } int SaveLoadChooser::runModalWithPluginAndTarget(const EnginePlugin *plugin, const String &target) { - if (_impl) - return _impl->runModalWithPluginAndTarget(plugin, target); - else + if (!_impl) return -1; + + // Set up the game domain as newly active domain, so + // target specific savepath will be checked + String oldDomain = ConfMan.getActiveDomainName(); + ConfMan.setActiveDomain(target); + + int ret = _impl->run(target, &(**plugin)); + + // Revert to the old active domain + ConfMan.setActiveDomain(oldDomain); + + return ret; } Common::String SaveLoadChooser::getResultString() const { -- cgit v1.2.3 From 62c66cdb9c11c029e48706932c2513eaea1dd82b Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 14 Jun 2012 03:17:33 +0200 Subject: GUI: Fix include guard of saveload.h. --- gui/saveload.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/saveload.h b/gui/saveload.h index 9cd3c4605f..a3834ff777 100644 --- a/gui/saveload.h +++ b/gui/saveload.h @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef GUI_SAVELOAD_DIALOG_H -#define GUI_SAVELOAD_DIALOG_H +#ifndef GUI_SAVELOAD_H +#define GUI_SAVELOAD_H #include "gui/dialog.h" #include "engines/metaengine.h" -- cgit v1.2.3 From 1aa5200bb824119651e19a1809d9c07292da57fe Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 14 Jun 2012 03:33:50 +0200 Subject: GUI: Create an interface for save/load dialogs. --- gui/module.mk | 1 + gui/saveload-dialog.cpp | 380 +++++++++++++++++++++++++++++++++++++++++++++++ gui/saveload-dialog.h | 90 +++++++++++ gui/saveload.cpp | 388 +----------------------------------------------- gui/saveload.h | 4 +- 5 files changed, 475 insertions(+), 388 deletions(-) create mode 100644 gui/saveload-dialog.cpp create mode 100644 gui/saveload-dialog.h (limited to 'gui') diff --git a/gui/module.mk b/gui/module.mk index d272bb0313..a435d8cca7 100644 --- a/gui/module.mk +++ b/gui/module.mk @@ -15,6 +15,7 @@ MODULE_OBJS := \ options.o \ predictivedialog.o \ saveload.o \ + saveload-dialog.o \ themebrowser.o \ ThemeEngine.o \ ThemeEval.o \ diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp new file mode 100644 index 0000000000..b8e64c4d99 --- /dev/null +++ b/gui/saveload-dialog.cpp @@ -0,0 +1,380 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "gui/saveload-dialog.h" +#include "common/translation.h" + +#include "gui/message.h" +#include "gui/gui-manager.h" +#include "gui/ThemeEval.h" + +#include "graphics/scaler.h" + +namespace GUI { + +SaveLoadChooserDialog::SaveLoadChooserDialog(const Common::String &dialogName) + : Dialog(dialogName), _metaEngine(0), _delSupport(false), _metaInfoSupport(false), + _thumbnailSupport(false), _saveDateSupport(false), _playTimeSupport(false) { +} + +SaveLoadChooserDialog::SaveLoadChooserDialog(int x, int y, int w, int h) + : Dialog(x, y, w, h), _metaEngine(0), _delSupport(false), _metaInfoSupport(false), + _thumbnailSupport(false), _saveDateSupport(false), _playTimeSupport(false) { +} + +void SaveLoadChooserDialog::open() { + Dialog::open(); + + // So that quitting ScummVM will not cause the dialog result to say a + // savegame was selected. + setResult(-1); +} + +int SaveLoadChooserDialog::run(const Common::String &target, const MetaEngine *metaEngine) { + _metaEngine = metaEngine; + _target = target; + _delSupport = _metaEngine->hasFeature(MetaEngine::kSupportsDeleteSave); + _metaInfoSupport = _metaEngine->hasFeature(MetaEngine::kSavesSupportMetaInfo); + _thumbnailSupport = _metaInfoSupport && _metaEngine->hasFeature(MetaEngine::kSavesSupportThumbnail); + _saveDateSupport = _metaInfoSupport && _metaEngine->hasFeature(MetaEngine::kSavesSupportCreationDate); + _playTimeSupport = _metaInfoSupport && _metaEngine->hasFeature(MetaEngine::kSavesSupportPlayTime); + + return runIntern(); +} + +// SaveLoadChooserSimple implementation + +enum { + kChooseCmd = 'CHOS', + kDelCmd = 'DEL ' +}; + +SaveLoadChooserSimple::SaveLoadChooserSimple(const String &title, const String &buttonLabel, bool saveMode) + : SaveLoadChooserDialog("SaveLoadChooser"), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0) { + _backgroundType = ThemeEngine::kDialogBackgroundSpecial; + + new StaticTextWidget(this, "SaveLoadChooser.Title", title); + + // Add choice list + _list = new GUI::ListWidget(this, "SaveLoadChooser.List"); + _list->setNumberingMode(GUI::kListNumberingZero); + _list->setEditable(saveMode); + + _gfxWidget = new GUI::GraphicsWidget(this, 0, 0, 10, 10); + + _date = new StaticTextWidget(this, 0, 0, 10, 10, _("No date saved"), Graphics::kTextAlignCenter); + _time = new StaticTextWidget(this, 0, 0, 10, 10, _("No time saved"), Graphics::kTextAlignCenter); + _playtime = new StaticTextWidget(this, 0, 0, 10, 10, _("No playtime saved"), Graphics::kTextAlignCenter); + + // Buttons + new GUI::ButtonWidget(this, "SaveLoadChooser.Cancel", _("Cancel"), 0, kCloseCmd); + _chooseButton = new GUI::ButtonWidget(this, "SaveLoadChooser.Choose", buttonLabel, 0, kChooseCmd); + _chooseButton->setEnabled(false); + + _deleteButton = new GUI::ButtonWidget(this, "SaveLoadChooser.Delete", _("Delete"), 0, kDelCmd); + _deleteButton->setEnabled(false); + + _delSupport = _metaInfoSupport = _thumbnailSupport = false; + + _container = new GUI::ContainerWidget(this, 0, 0, 10, 10); +// _container->setHints(GUI::THEME_HINT_USE_SHADOW); +} + +int SaveLoadChooserSimple::runIntern() { + if (_gfxWidget) + _gfxWidget->setGfx(0); + + _resultString.clear(); + reflowLayout(); + updateSaveList(); + + return Dialog::runModal(); +} + +const Common::String &SaveLoadChooserSimple::getResultString() const { + int selItem = _list->getSelected(); + return (selItem >= 0) ? _list->getSelectedString() : _resultString; +} + +void SaveLoadChooserSimple::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { + int selItem = _list->getSelected(); + + switch (cmd) { + case GUI::kListItemActivatedCmd: + case GUI::kListItemDoubleClickedCmd: + if (selItem >= 0 && _chooseButton->isEnabled()) { + if (_list->isEditable() || !_list->getSelectedString().empty()) { + _list->endEditMode(); + if (!_saveList.empty()) { + setResult(_saveList[selItem].getSaveSlot()); + _resultString = _list->getSelectedString(); + } + close(); + } + } + break; + case kChooseCmd: + _list->endEditMode(); + if (!_saveList.empty()) { + setResult(_saveList[selItem].getSaveSlot()); + _resultString = _list->getSelectedString(); + } + close(); + break; + case GUI::kListSelectionChangedCmd: + updateSelection(true); + break; + case kDelCmd: + if (selItem >= 0 && _delSupport) { + MessageDialog alert(_("Do you really want to delete this savegame?"), + _("Delete"), _("Cancel")); + if (alert.runModal() == GUI::kMessageOK) { + _metaEngine->removeSaveState(_target.c_str(), _saveList[selItem].getSaveSlot()); + + setResult(-1); + _list->setSelected(-1); + + updateSaveList(); + updateSelection(true); + } + } + break; + case kCloseCmd: + setResult(-1); + default: + SaveLoadChooserDialog::handleCommand(sender, cmd, data); + } +} + +void SaveLoadChooserSimple::reflowLayout() { + if (g_gui.xmlEval()->getVar("Globals.SaveLoadChooser.ExtInfo.Visible") == 1 && _thumbnailSupport) { + int16 x, y; + uint16 w, h; + + if (!g_gui.xmlEval()->getWidgetData("SaveLoadChooser.Thumbnail", x, y, w, h)) + error("Error when loading position data for Save/Load Thumbnails"); + + int thumbW = kThumbnailWidth; + int thumbH = kThumbnailHeight2; + int thumbX = x + (w >> 1) - (thumbW >> 1); + int thumbY = y + kLineHeight; + + int textLines = 0; + if (!_saveDateSupport) + textLines++; + if (!_playTimeSupport) + textLines++; + + _container->resize(x, y, w, h - (kLineHeight * textLines)); + _gfxWidget->resize(thumbX, thumbY, thumbW, thumbH); + + int height = thumbY + thumbH + kLineHeight; + + if (_saveDateSupport) { + _date->resize(thumbX, height, kThumbnailWidth, kLineHeight); + height += kLineHeight; + _time->resize(thumbX, height, kThumbnailWidth, kLineHeight); + height += kLineHeight; + } + + if (_playTimeSupport) + _playtime->resize(thumbX, height, kThumbnailWidth, kLineHeight); + + _container->setVisible(true); + _gfxWidget->setVisible(true); + + _date->setVisible(_saveDateSupport); + _time->setVisible(_saveDateSupport); + + _playtime->setVisible(_playTimeSupport); + + _fillR = 0; + _fillG = 0; + _fillB = 0; + updateSelection(false); + } else { + _container->setVisible(false); + _gfxWidget->setVisible(false); + _date->setVisible(false); + _time->setVisible(false); + _playtime->setVisible(false); + } + + SaveLoadChooserDialog::reflowLayout(); +} + +void SaveLoadChooserSimple::updateSelection(bool redraw) { + int selItem = _list->getSelected(); + + bool isDeletable = _delSupport; + bool isWriteProtected = false; + bool startEditMode = _list->isEditable(); + + _gfxWidget->setGfx(-1, -1, _fillR, _fillG, _fillB); + _date->setLabel(_("No date saved")); + _time->setLabel(_("No time saved")); + _playtime->setLabel(_("No playtime saved")); + + if (selItem >= 0 && _metaInfoSupport) { + SaveStateDescriptor desc = _metaEngine->querySaveMetaInfos(_target.c_str(), _saveList[selItem].getSaveSlot()); + + isDeletable = desc.getDeletableFlag() && _delSupport; + isWriteProtected = desc.getWriteProtectedFlag(); + + // Don't allow the user to change the description of write protected games + if (isWriteProtected) + startEditMode = false; + + if (_thumbnailSupport) { + const Graphics::Surface *thumb = desc.getThumbnail(); + if (thumb) { + _gfxWidget->setGfx(thumb); + _gfxWidget->useAlpha(256); + } + } + + if (_saveDateSupport) { + const Common::String &saveDate = desc.getSaveDate(); + if (!saveDate.empty()) + _date->setLabel(_("Date: ") + saveDate); + + const Common::String &saveTime = desc.getSaveTime(); + if (!saveTime.empty()) + _time->setLabel(_("Time: ") + saveTime); + } + + if (_playTimeSupport) { + const Common::String &playTime = desc.getPlayTime(); + if (!playTime.empty()) + _playtime->setLabel(_("Playtime: ") + playTime); + } + } + + + if (_list->isEditable()) { + // Disable the save button if nothing is selected, or if the selected + // game is write protected + _chooseButton->setEnabled(selItem >= 0 && !isWriteProtected); + + if (startEditMode) { + _list->startEditMode(); + + if (_chooseButton->isEnabled() && _list->getSelectedString() == _("Untitled savestate") && + _list->getSelectionColor() == ThemeEngine::kFontColorAlternate) { + _list->setEditString(""); + _list->setEditColor(ThemeEngine::kFontColorNormal); + } + } + } else { + // Disable the load button 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(); + _date->draw(); + _time->draw(); + _playtime->draw(); + _chooseButton->draw(); + _deleteButton->draw(); + + draw(); + } +} + +void SaveLoadChooserSimple::close() { + _metaEngine = 0; + _target.clear(); + _saveList.clear(); + _list->setList(StringArray()); + + SaveLoadChooserDialog::close(); +} + +void SaveLoadChooserSimple::updateSaveList() { + _saveList = _metaEngine->listSaves(_target.c_str()); + + int curSlot = 0; + int saveSlot = 0; + StringArray saveNames; + ListWidget::ColorList colors; + for (SaveStateList::const_iterator x = _saveList.begin(); x != _saveList.end(); ++x) { + // Handle gaps in the list of save games + saveSlot = x->getSaveSlot(); + if (curSlot < saveSlot) { + while (curSlot < saveSlot) { + SaveStateDescriptor dummySave(curSlot, ""); + _saveList.insert_at(curSlot, dummySave); + 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 (x->getSaveSlot() == saveSlot) + break; + } + } + + // Show "Untitled savestate" for empty/whitespace savegame descriptions + Common::String description = x->getDescription(); + Common::String trimmedDescription = description; + trimmedDescription.trim(); + if (trimmedDescription.empty()) { + description = _("Untitled savestate"); + colors.push_back(ThemeEngine::kFontColorAlternate); + } else { + colors.push_back(ThemeEngine::kFontColorNormal); + } + + saveNames.push_back(description); + curSlot++; + } + + // Fill the rest of the save slots with empty saves + + int maximumSaveSlots = _metaEngine->getMaximumSaveSlot(); + +#ifdef __DS__ + // Low memory on the DS means too many save slots are impractical, so limit + // the maximum here. + if (maximumSaveSlots > 99) { + maximumSaveSlots = 99; + } +#endif + + Common::String emptyDesc; + for (int i = curSlot; i <= maximumSaveSlots; i++) { + saveNames.push_back(emptyDesc); + SaveStateDescriptor dummySave(i, ""); + _saveList.push_back(dummySave); + colors.push_back(ThemeEngine::kFontColorNormal); + } + + _list->setList(saveNames, &colors); +} + +} // End of namespace GUI diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h new file mode 100644 index 0000000000..7a78e17bae --- /dev/null +++ b/gui/saveload-dialog.h @@ -0,0 +1,90 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef GUI_SAVELOAD_DIALOG_H +#define GUI_SAVELOAD_DIALOG_H + +#include "gui/dialog.h" +#include "gui/widgets/list.h" + +#include "engines/metaengine.h" + +namespace GUI { + +class SaveLoadChooserDialog : protected Dialog { +public: + SaveLoadChooserDialog(const Common::String &dialogName); + SaveLoadChooserDialog(int x, int y, int w, int h); + + virtual void open(); + + int run(const Common::String &target, const MetaEngine *metaEngine); + virtual const Common::String &getResultString() const = 0; + +protected: + virtual int runIntern() = 0; + + const MetaEngine *_metaEngine; + bool _delSupport; + bool _metaInfoSupport; + bool _thumbnailSupport; + bool _saveDateSupport; + bool _playTimeSupport; + Common::String _target; +}; + +class SaveLoadChooserSimple : public SaveLoadChooserDialog { + typedef Common::String String; + typedef Common::Array StringArray; +public: + SaveLoadChooserSimple(const String &title, const String &buttonLabel, bool saveMode); + + virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); + + virtual const Common::String &getResultString() const; + + virtual void reflowLayout(); + + virtual void close(); +private: + virtual int runIntern(); + + GUI::ListWidget *_list; + GUI::ButtonWidget *_chooseButton; + GUI::ButtonWidget *_deleteButton; + GUI::GraphicsWidget *_gfxWidget; + GUI::ContainerWidget *_container; + GUI::StaticTextWidget *_date; + GUI::StaticTextWidget *_time; + GUI::StaticTextWidget *_playtime; + + SaveStateList _saveList; + String _resultString; + + uint8 _fillR, _fillG, _fillB; + + void updateSaveList(); + void updateSelection(bool redraw); +}; + +} // End of namespace GUI + +#endif diff --git a/gui/saveload.cpp b/gui/saveload.cpp index e2f9461ddb..e0e6d6187e 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -20,401 +20,17 @@ */ #include "common/config-manager.h" -#include "common/translation.h" #include "common/system.h" -#include "gui/widgets/list.h" -#include "gui/message.h" #include "gui/saveload.h" -#include "gui/ThemeEval.h" -#include "gui/gui-manager.h" - -#include "graphics/scaler.h" +#include "gui/saveload-dialog.h" #include "engines/metaengine.h" namespace GUI { -enum { - kChooseCmd = 'CHOS', - kDelCmd = 'DEL ' - -}; - -class SaveLoadChooserImpl : GUI::Dialog { - typedef Common::String String; - typedef Common::Array StringArray; -public: - SaveLoadChooserImpl(const String &title, const String &buttonLabel, bool saveMode); - - int run(const String &target, const MetaEngine *metaEngine); - - virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); - - const Common::String &getResultString() const; - - virtual void open(); - - virtual void reflowLayout(); - - virtual void close(); -private: - GUI::ListWidget *_list; - GUI::ButtonWidget *_chooseButton; - GUI::ButtonWidget *_deleteButton; - GUI::GraphicsWidget *_gfxWidget; - GUI::ContainerWidget *_container; - GUI::StaticTextWidget *_date; - GUI::StaticTextWidget *_time; - GUI::StaticTextWidget *_playtime; - - const MetaEngine *_metaEngine; - bool _delSupport; - bool _metaInfoSupport; - bool _thumbnailSupport; - bool _saveDateSupport; - bool _playTimeSupport; - String _target; - SaveStateList _saveList; - String _resultString; - - uint8 _fillR, _fillG, _fillB; - - void updateSaveList(); - void updateSelection(bool redraw); -}; - -SaveLoadChooserImpl::SaveLoadChooserImpl(const String &title, const String &buttonLabel, bool saveMode) - : Dialog("SaveLoadChooser"), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0) { - _delSupport = _metaInfoSupport = _thumbnailSupport = _saveDateSupport = _playTimeSupport = false; - - _backgroundType = ThemeEngine::kDialogBackgroundSpecial; - - new StaticTextWidget(this, "SaveLoadChooser.Title", title); - - // Add choice list - _list = new GUI::ListWidget(this, "SaveLoadChooser.List"); - _list->setNumberingMode(GUI::kListNumberingZero); - _list->setEditable(saveMode); - - _gfxWidget = new GUI::GraphicsWidget(this, 0, 0, 10, 10); - - _date = new StaticTextWidget(this, 0, 0, 10, 10, _("No date saved"), Graphics::kTextAlignCenter); - _time = new StaticTextWidget(this, 0, 0, 10, 10, _("No time saved"), Graphics::kTextAlignCenter); - _playtime = new StaticTextWidget(this, 0, 0, 10, 10, _("No playtime saved"), Graphics::kTextAlignCenter); - - // Buttons - new GUI::ButtonWidget(this, "SaveLoadChooser.Cancel", _("Cancel"), 0, kCloseCmd); - _chooseButton = new GUI::ButtonWidget(this, "SaveLoadChooser.Choose", buttonLabel, 0, kChooseCmd); - _chooseButton->setEnabled(false); - - _deleteButton = new GUI::ButtonWidget(this, "SaveLoadChooser.Delete", _("Delete"), 0, kDelCmd); - _deleteButton->setEnabled(false); - - _delSupport = _metaInfoSupport = _thumbnailSupport = false; - - _container = new GUI::ContainerWidget(this, 0, 0, 10, 10); -// _container->setHints(GUI::THEME_HINT_USE_SHADOW); -} - -int SaveLoadChooserImpl::run(const String &target, const MetaEngine *metaEngine) { - if (_gfxWidget) - _gfxWidget->setGfx(0); - - _metaEngine = metaEngine; - _target = target; - _delSupport = _metaEngine->hasFeature(MetaEngine::kSupportsDeleteSave); - _metaInfoSupport = _metaEngine->hasFeature(MetaEngine::kSavesSupportMetaInfo); - _thumbnailSupport = _metaInfoSupport && _metaEngine->hasFeature(MetaEngine::kSavesSupportThumbnail); - _saveDateSupport = _metaInfoSupport && _metaEngine->hasFeature(MetaEngine::kSavesSupportCreationDate); - _playTimeSupport = _metaInfoSupport && _metaEngine->hasFeature(MetaEngine::kSavesSupportPlayTime); - _resultString.clear(); - reflowLayout(); - updateSaveList(); - - return Dialog::runModal(); -} - -void SaveLoadChooserImpl::open() { - Dialog::open(); - - // So that quitting ScummVM will not cause the dialog result to say a - // savegame was selected. - setResult(-1); -} - -const Common::String &SaveLoadChooserImpl::getResultString() const { - int selItem = _list->getSelected(); - return (selItem >= 0) ? _list->getSelectedString() : _resultString; -} - -void SaveLoadChooserImpl::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { - int selItem = _list->getSelected(); - - switch (cmd) { - case GUI::kListItemActivatedCmd: - case GUI::kListItemDoubleClickedCmd: - if (selItem >= 0 && _chooseButton->isEnabled()) { - if (_list->isEditable() || !_list->getSelectedString().empty()) { - _list->endEditMode(); - if (!_saveList.empty()) { - setResult(_saveList[selItem].getSaveSlot()); - _resultString = _list->getSelectedString(); - } - close(); - } - } - break; - case kChooseCmd: - _list->endEditMode(); - if (!_saveList.empty()) { - setResult(_saveList[selItem].getSaveSlot()); - _resultString = _list->getSelectedString(); - } - close(); - break; - case GUI::kListSelectionChangedCmd: - updateSelection(true); - break; - case kDelCmd: - if (selItem >= 0 && _delSupport) { - MessageDialog alert(_("Do you really want to delete this savegame?"), - _("Delete"), _("Cancel")); - if (alert.runModal() == GUI::kMessageOK) { - _metaEngine->removeSaveState(_target.c_str(), _saveList[selItem].getSaveSlot()); - - setResult(-1); - _list->setSelected(-1); - - updateSaveList(); - updateSelection(true); - } - } - break; - case kCloseCmd: - setResult(-1); - default: - Dialog::handleCommand(sender, cmd, data); - } -} - -void SaveLoadChooserImpl::reflowLayout() { - if (g_gui.xmlEval()->getVar("Globals.SaveLoadChooser.ExtInfo.Visible") == 1 && _thumbnailSupport) { - int16 x, y; - uint16 w, h; - - if (!g_gui.xmlEval()->getWidgetData("SaveLoadChooser.Thumbnail", x, y, w, h)) - error("Error when loading position data for Save/Load Thumbnails"); - - int thumbW = kThumbnailWidth; - int thumbH = kThumbnailHeight2; - int thumbX = x + (w >> 1) - (thumbW >> 1); - int thumbY = y + kLineHeight; - - int textLines = 0; - if (!_saveDateSupport) - textLines++; - if (!_playTimeSupport) - textLines++; - - _container->resize(x, y, w, h - (kLineHeight * textLines)); - _gfxWidget->resize(thumbX, thumbY, thumbW, thumbH); - - int height = thumbY + thumbH + kLineHeight; - - if (_saveDateSupport) { - _date->resize(thumbX, height, kThumbnailWidth, kLineHeight); - height += kLineHeight; - _time->resize(thumbX, height, kThumbnailWidth, kLineHeight); - height += kLineHeight; - } - - if (_playTimeSupport) - _playtime->resize(thumbX, height, kThumbnailWidth, kLineHeight); - - _container->setVisible(true); - _gfxWidget->setVisible(true); - - _date->setVisible(_saveDateSupport); - _time->setVisible(_saveDateSupport); - - _playtime->setVisible(_playTimeSupport); - - _fillR = 0; - _fillG = 0; - _fillB = 0; - updateSelection(false); - } else { - _container->setVisible(false); - _gfxWidget->setVisible(false); - _date->setVisible(false); - _time->setVisible(false); - _playtime->setVisible(false); - } - - Dialog::reflowLayout(); -} - -void SaveLoadChooserImpl::updateSelection(bool redraw) { - int selItem = _list->getSelected(); - - bool isDeletable = _delSupport; - bool isWriteProtected = false; - bool startEditMode = _list->isEditable(); - - _gfxWidget->setGfx(-1, -1, _fillR, _fillG, _fillB); - _date->setLabel(_("No date saved")); - _time->setLabel(_("No time saved")); - _playtime->setLabel(_("No playtime saved")); - - if (selItem >= 0 && _metaInfoSupport) { - SaveStateDescriptor desc = _metaEngine->querySaveMetaInfos(_target.c_str(), _saveList[selItem].getSaveSlot()); - - isDeletable = desc.getDeletableFlag() && _delSupport; - isWriteProtected = desc.getWriteProtectedFlag(); - - // Don't allow the user to change the description of write protected games - if (isWriteProtected) - startEditMode = false; - - if (_thumbnailSupport) { - const Graphics::Surface *thumb = desc.getThumbnail(); - if (thumb) { - _gfxWidget->setGfx(thumb); - _gfxWidget->useAlpha(256); - } - } - - if (_saveDateSupport) { - const Common::String &saveDate = desc.getSaveDate(); - if (!saveDate.empty()) - _date->setLabel(_("Date: ") + saveDate); - - const Common::String &saveTime = desc.getSaveTime(); - if (!saveTime.empty()) - _time->setLabel(_("Time: ") + saveTime); - } - - if (_playTimeSupport) { - const Common::String &playTime = desc.getPlayTime(); - if (!playTime.empty()) - _playtime->setLabel(_("Playtime: ") + playTime); - } - } - - - if (_list->isEditable()) { - // Disable the save button if nothing is selected, or if the selected - // game is write protected - _chooseButton->setEnabled(selItem >= 0 && !isWriteProtected); - - if (startEditMode) { - _list->startEditMode(); - - if (_chooseButton->isEnabled() && _list->getSelectedString() == _("Untitled savestate") && - _list->getSelectionColor() == ThemeEngine::kFontColorAlternate) { - _list->setEditString(""); - _list->setEditColor(ThemeEngine::kFontColorNormal); - } - } - } else { - // Disable the load button 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(); - _date->draw(); - _time->draw(); - _playtime->draw(); - _chooseButton->draw(); - _deleteButton->draw(); - - draw(); - } -} - -void SaveLoadChooserImpl::close() { - _metaEngine = 0; - _target.clear(); - _saveList.clear(); - _list->setList(StringArray()); - - Dialog::close(); -} - -void SaveLoadChooserImpl::updateSaveList() { - _saveList = _metaEngine->listSaves(_target.c_str()); - - int curSlot = 0; - int saveSlot = 0; - StringArray saveNames; - ListWidget::ColorList colors; - for (SaveStateList::const_iterator x = _saveList.begin(); x != _saveList.end(); ++x) { - // Handle gaps in the list of save games - saveSlot = x->getSaveSlot(); - if (curSlot < saveSlot) { - while (curSlot < saveSlot) { - SaveStateDescriptor dummySave(curSlot, ""); - _saveList.insert_at(curSlot, dummySave); - 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 (x->getSaveSlot() == saveSlot) - break; - } - } - - // Show "Untitled savestate" for empty/whitespace savegame descriptions - Common::String description = x->getDescription(); - Common::String trimmedDescription = description; - trimmedDescription.trim(); - if (trimmedDescription.empty()) { - description = _("Untitled savestate"); - colors.push_back(ThemeEngine::kFontColorAlternate); - } else { - colors.push_back(ThemeEngine::kFontColorNormal); - } - - saveNames.push_back(description); - curSlot++; - } - - // Fill the rest of the save slots with empty saves - - int maximumSaveSlots = _metaEngine->getMaximumSaveSlot(); - -#ifdef __DS__ - // Low memory on the DS means too many save slots are impractical, so limit - // the maximum here. - if (maximumSaveSlots > 99) { - maximumSaveSlots = 99; - } -#endif - - Common::String emptyDesc; - for (int i = curSlot; i <= maximumSaveSlots; i++) { - saveNames.push_back(emptyDesc); - SaveStateDescriptor dummySave(i, ""); - _saveList.push_back(dummySave); - colors.push_back(ThemeEngine::kFontColorNormal); - } - - _list->setList(saveNames, &colors); -} - -// --- SaveLoadChooser implementation --- - SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode) { - _impl = new SaveLoadChooserImpl(title, buttonLabel, saveMode); + _impl = new SaveLoadChooserSimple(title, buttonLabel, saveMode); } SaveLoadChooser::~SaveLoadChooser() { diff --git a/gui/saveload.h b/gui/saveload.h index a3834ff777..ac61291b62 100644 --- a/gui/saveload.h +++ b/gui/saveload.h @@ -27,12 +27,12 @@ namespace GUI { -class SaveLoadChooserImpl; +class SaveLoadChooserDialog; class SaveLoadChooser { typedef Common::String String; protected: - SaveLoadChooserImpl *_impl; + SaveLoadChooserDialog *_impl; public: SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode); ~SaveLoadChooser(); -- cgit v1.2.3 From b4882ce6bdb8f3a0df0085fa43ed3bbaf5cb47e1 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 15 Jun 2012 22:39:57 +0200 Subject: GUI: Implement a new load chooser, which displays a list of thumbnails. --- gui/saveload-dialog.cpp | 192 ++++++++++++++++++++++++++++++++++++++++++++++++ gui/saveload-dialog.h | 46 ++++++++++++ 2 files changed, 238 insertions(+) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index b8e64c4d99..6740fcad13 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -377,4 +377,196 @@ void SaveLoadChooserSimple::updateSaveList() { _list->setList(saveNames, &colors); } +// LoadChooserThumbnailed implementation + +enum { + kNextCmd = 'NEXT', + kPrevCmd = 'PREV' +}; + +LoadChooserThumbnailed::LoadChooserThumbnailed(const Common::String &title) + : SaveLoadChooserDialog("SaveLoadChooser"), _lines(0), _columns(0), _entriesPerPage(0), + _curPage(0), _buttons() { + _backgroundType = ThemeEngine::kDialogBackgroundSpecial; + + new StaticTextWidget(this, "SaveLoadChooser.Title", title); + + // Buttons + new GUI::ButtonWidget(this, "SaveLoadChooser.Delete", _("Cancel"), 0, kCloseCmd); + _nextButton = new GUI::ButtonWidget(this, "SaveLoadChooser.Choose", _("Next"), 0, kNextCmd); + _nextButton->setEnabled(false); + + _prevButton = new GUI::ButtonWidget(this, "SaveLoadChooser.Cancel", _("Prev"), 0, kPrevCmd); + _prevButton->setEnabled(false); +} + +const Common::String &LoadChooserThumbnailed::getResultString() const { + // FIXME: This chooser is only for loading, thus the result is never used + // anyway. But this is still an ugly hack. + return _target; +} + +void LoadChooserThumbnailed::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { + if (cmd <= _entriesPerPage) { + setResult(_saveList[cmd - 1 + _curPage * _entriesPerPage].getSaveSlot()); + close(); + } + + switch (cmd) { + case kNextCmd: + ++_curPage; + updateSaves(); + draw(); + break; + + case kPrevCmd: + --_curPage; + updateSaves(); + draw(); + break; + + case kCloseCmd: + setResult(-1); + default: + SaveLoadChooserDialog::handleCommand(sender, cmd, data); + } +} + +void LoadChooserThumbnailed::handleMouseWheel(int x, int y, int direction) { + if (direction > 0) { + if (_nextButton->isEnabled()) { + ++_curPage; + updateSaves(); + draw(); + } + } else { + if (_prevButton->isEnabled()) { + --_curPage; + updateSaves(); + draw(); + } + } +} + +void LoadChooserThumbnailed::open() { + SaveLoadChooserDialog::open(); + + _curPage = 0; + updateSaves(); +} + +void LoadChooserThumbnailed::reflowLayout() { + SaveLoadChooserDialog::reflowLayout(); + destroyButtons(); + + const uint16 availableWidth = getWidth() - 20; + uint16 availableHeight; + + int16 x, y; + uint16 w; + g_gui.xmlEval()->getWidgetData("SaveLoadChooser.List", x, y, w, availableHeight); + + const int16 buttonWidth = kThumbnailWidth + 6; + const int16 buttonHeight = kThumbnailHeight2 + 6; + + const int16 containerFrameWidthAdd = 10; + const int16 containerFrameHeightAdd = 0; + const int16 containerWidth = buttonWidth + containerFrameWidthAdd; + const int16 containerHeight = buttonHeight + kLineHeight + containerFrameHeightAdd; + + const int16 defaultSpacingHorizontal = 4; + const int16 defaultSpacingVertical = 4; + const int16 slotAreaWidth = containerWidth + defaultSpacingHorizontal; + const int16 slotAreaHeight = containerHeight + defaultSpacingHorizontal; + + const uint oldEntriesPerPage = _entriesPerPage; + _columns = MAX(1, availableWidth / slotAreaWidth); + _lines = MAX(1, availableHeight / slotAreaHeight); + _entriesPerPage = _columns * _lines; + // Recalculate the page number + if (!_saveList.empty() && oldEntriesPerPage != 0) { + _curPage = (_curPage * oldEntriesPerPage) / _entriesPerPage; + } + + const uint addX = _columns > 1 ? (availableWidth % slotAreaWidth) / (_columns - 1) : 0; + const uint addY = _lines > 1 ? (availableHeight % slotAreaHeight) / (_lines - 1) : 0; + + _buttons.reserve(_lines * _columns); + y += defaultSpacingVertical / 2; + for (uint curLine = 0; curLine < _lines; ++curLine, y += slotAreaHeight + addY) { + for (uint curColumn = 0, curX = x + defaultSpacingHorizontal / 2; curColumn < _columns; ++curColumn, curX += slotAreaWidth + addX) { + ContainerWidget *container = new ContainerWidget(this, curX, y, containerWidth, containerHeight); + container->setVisible(false); + + int dstY = y + containerFrameHeightAdd / 2; + int dstX = curX + containerFrameWidthAdd / 2; + + PicButtonWidget *button = new PicButtonWidget(this, dstX, dstY, buttonWidth, buttonHeight, 0, curLine * _columns + curColumn + 1); + button->setVisible(false); + dstY += buttonHeight; + + StaticTextWidget *description = new StaticTextWidget(this, dstX, dstY, buttonWidth, kLineHeight, Common::String(), Graphics::kTextAlignLeft); + description->setVisible(false); + + _buttons.push_back(SlotButton(container, button, description)); + } + } + + if (!_target.empty()) + updateSaves(); +} + +void LoadChooserThumbnailed::close() { + SaveLoadChooserDialog::close(); + hideButtons(); +} + +int LoadChooserThumbnailed::runIntern() { + return SaveLoadChooserDialog::runModal(); +} + +void LoadChooserThumbnailed::destroyButtons() { + for (ButtonArray::iterator i = _buttons.begin(), end = _buttons.end(); i != end; ++i) { + removeWidget(i->container); + removeWidget(i->button); + removeWidget(i->description); + } + + _buttons.clear(); +} + +void LoadChooserThumbnailed::hideButtons() { + for (ButtonArray::iterator i = _buttons.begin(), end = _buttons.end(); i != end; ++i) { + i->button->setGfx(0); + i->setVisible(false); + } + +} + +void LoadChooserThumbnailed::updateSaves() { + hideButtons(); + + _saveList = _metaEngine->listSaves(_target.c_str()); + + 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); + SlotButton &curButton = _buttons[curNum]; + curButton.setVisible(true); + curButton.button->setGfx(desc.getThumbnail()); + curButton.description->setLabel(Common::String::format("%d. %s", saveSlot, desc.getDescription().c_str())); + } + + if (_curPage > 0) + _prevButton->setEnabled(true); + else + _prevButton->setEnabled(false); + + if ((_curPage + 1) * _entriesPerPage < _saveList.size()) + _nextButton->setEnabled(true); + else + _nextButton->setEnabled(false); +} + } // End of namespace GUI diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index 7a78e17bae..b80741d36a 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -85,6 +85,52 @@ private: void updateSelection(bool redraw); }; +class LoadChooserThumbnailed : public SaveLoadChooserDialog { +public: + LoadChooserThumbnailed(const Common::String &title); + + virtual const Common::String &getResultString() const; + + virtual void open(); + + virtual void reflowLayout(); + + virtual void close(); +protected: + virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); + virtual void handleMouseWheel(int x, int y, int direction); +private: + virtual int runIntern(); + + uint _columns, _lines; + uint _entriesPerPage; + uint _curPage; + SaveStateList _saveList; + + GUI::ButtonWidget *_nextButton; + GUI::ButtonWidget *_prevButton; + + struct SlotButton { + SlotButton() : container(0), button(0), description(0) {} + SlotButton(ContainerWidget *c, PicButtonWidget *b, StaticTextWidget *d) : container(c), button(b), description(d) {} + + ContainerWidget *container; + PicButtonWidget *button; + StaticTextWidget *description; + + void setVisible(bool state) { + container->setVisible(state); + button->setVisible(state); + description->setVisible(state); + } + }; + typedef Common::Array ButtonArray; + ButtonArray _buttons; + void destroyButtons(); + void hideButtons(); + void updateSaves(); +}; + } // End of namespace GUI #endif -- cgit v1.2.3 From 72ea449431d9db61c45160f7c42d546599e84afe Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 15 Jun 2012 22:47:57 +0200 Subject: GUI: Hook up the new load chooser for > 320x200 and engines which support thumbnails. --- gui/saveload.cpp | 22 +++++++++++++++++----- gui/saveload.h | 6 ++++++ 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'gui') diff --git a/gui/saveload.cpp b/gui/saveload.cpp index e0e6d6187e..becc3f6b4f 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -24,13 +24,14 @@ #include "gui/saveload.h" #include "gui/saveload-dialog.h" +#include "gui/gui-manager.h" #include "engines/metaengine.h" namespace GUI { -SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode) { - _impl = new SaveLoadChooserSimple(title, buttonLabel, saveMode); +SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode) + : _impl(0), _title(title), _buttonLabel(buttonLabel), _saveMode(saveMode) { } SaveLoadChooser::~SaveLoadChooser() { @@ -38,6 +39,19 @@ SaveLoadChooser::~SaveLoadChooser() { _impl = 0; } +void SaveLoadChooser::selectChooser(const MetaEngine &engine) { + delete _impl; + _impl = 0; + + if (!_saveMode && g_gui.getWidth() > 320 && g_gui.getHeight() > 200 + && engine.hasFeature(MetaEngine::kSavesSupportMetaInfo) + && engine.hasFeature(MetaEngine::kSavesSupportThumbnail)) { + _impl = new LoadChooserThumbnailed(_title); + } else { + _impl = new SaveLoadChooserSimple(_title, _buttonLabel, _saveMode); + } +} + Common::String SaveLoadChooser::createDefaultSaveDescription(const int slot) const { #if defined(USE_SAVEGAME_TIMESTAMP) TimeDate curTime; @@ -51,9 +65,6 @@ Common::String SaveLoadChooser::createDefaultSaveDescription(const int slot) con } int SaveLoadChooser::runModalWithCurrentTarget() { - if (!_impl) - return -1; - const Common::String gameId = ConfMan.get("gameid"); const EnginePlugin *plugin = 0; @@ -63,6 +74,7 @@ int SaveLoadChooser::runModalWithCurrentTarget() { } int SaveLoadChooser::runModalWithPluginAndTarget(const EnginePlugin *plugin, const String &target) { + selectChooser(**plugin); if (!_impl) return -1; diff --git a/gui/saveload.h b/gui/saveload.h index ac61291b62..26a8cd1bad 100644 --- a/gui/saveload.h +++ b/gui/saveload.h @@ -33,6 +33,12 @@ class SaveLoadChooser { typedef Common::String String; protected: SaveLoadChooserDialog *_impl; + + const String _title; + const String _buttonLabel; + const bool _saveMode; + + void selectChooser(const MetaEngine &engine); public: SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode); ~SaveLoadChooser(); -- cgit v1.2.3 From 80ae9d7d34234e6cf9a7464723691d7b2b72cb26 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 20 Jun 2012 03:31:50 +0200 Subject: GUI: Allow tooltips to be changed after widget creation. --- gui/Tooltip.cpp | 2 +- gui/gui-manager.cpp | 2 +- gui/widget.h | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'gui') diff --git a/gui/Tooltip.cpp b/gui/Tooltip.cpp index 85e5856cff..88124e782b 100644 --- a/gui/Tooltip.cpp +++ b/gui/Tooltip.cpp @@ -37,7 +37,7 @@ Tooltip::Tooltip() : } void Tooltip::setup(Dialog *parent, Widget *widget, int x, int y) { - assert(widget->getTooltip()); + assert(widget->hasTooltip()); _maxWidth = g_gui.xmlEval()->getVar("Globals.Tooltip.MaxWidth", 100); _xdelta = g_gui.xmlEval()->getVar("Globals.Tooltip.XDelta", 0); diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index abd781e1a3..a0ef4216aa 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -381,7 +381,7 @@ void GuiManager::runLoop() { if (tooltipCheck && _lastMousePosition.time + kTooltipDelay < _system->getMillis()) { Widget *wdg = activeDialog->findWidget(_lastMousePosition.x, _lastMousePosition.y); - if (wdg && wdg->getTooltip() && !(wdg->getFlags() & WIDGET_PRESSED)) { + if (wdg && wdg->hasTooltip() && !(wdg->getFlags() & WIDGET_PRESSED)) { Tooltip *tooltip = new Tooltip(); tooltip->setup(activeDialog, wdg, _lastMousePosition.x, _lastMousePosition.y); tooltip->runModal(); diff --git a/gui/widget.h b/gui/widget.h index 6de56862c3..d80b2ad7e2 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -88,7 +88,7 @@ protected: uint16 _id; bool _hasFocus; ThemeEngine::WidgetStateInfo _state; - const char *_tooltip; + Common::String _tooltip; private: uint16 _flags; @@ -142,7 +142,9 @@ public: uint8 parseHotkey(const Common::String &label); Common::String cleanupHotkey(const Common::String &label); - const char *getTooltip() const { return _tooltip; } + bool hasTooltip() const { return !_tooltip.empty(); } + const Common::String &getTooltip() const { return _tooltip; } + void setTooltip(const Common::String &tooltip) { _tooltip = tooltip; } protected: void updateState(int oldFlags, int newFlags); -- cgit v1.2.3 From d7db655c5b832691fbaa0d0d175de38f43217dc2 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 20 Jun 2012 03:42:32 +0200 Subject: GUI: Show additional meta data in the thumbnail load chooser via tooltip. --- gui/saveload-dialog.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 6740fcad13..5d9d489fec 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -556,6 +556,33 @@ void LoadChooserThumbnailed::updateSaves() { curButton.setVisible(true); curButton.button->setGfx(desc.getThumbnail()); curButton.description->setLabel(Common::String::format("%d. %s", saveSlot, desc.getDescription().c_str())); + + Common::String tooltip(_("Name: ")); + tooltip += desc.getDescription(); + + if (_saveDateSupport) { + const Common::String &saveDate = desc.getSaveDate(); + if (!saveDate.empty()) { + tooltip += "\n"; + tooltip += _("Date: ") + saveDate; + } + + const Common::String &saveTime = desc.getSaveTime(); + if (!saveTime.empty()) { + tooltip += "\n"; + tooltip += _("Time: ") + saveTime; + } + } + + if (_playTimeSupport) { + const Common::String &playTime = desc.getPlayTime(); + if (!playTime.empty()) { + tooltip += "\n"; + tooltip += _("Playtime: ") + playTime; + } + } + + curButton.button->setTooltip(tooltip); } if (_curPage > 0) -- cgit v1.2.3 From 0b5b58829cbb76a2da1c4de19dd51e30fc2c5a3d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 29 Jun 2012 14:57:54 +0200 Subject: GUI: Don't distribute vertical space between buttons in the thumbnail load chooser. --- gui/saveload-dialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 5d9d489fec..8537937c0f 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -489,11 +489,11 @@ void LoadChooserThumbnailed::reflowLayout() { } const uint addX = _columns > 1 ? (availableWidth % slotAreaWidth) / (_columns - 1) : 0; - const uint addY = _lines > 1 ? (availableHeight % slotAreaHeight) / (_lines - 1) : 0; + //const uint addY = _lines > 1 ? (availableHeight % slotAreaHeight) / (_lines - 1) : 0; _buttons.reserve(_lines * _columns); y += defaultSpacingVertical / 2; - for (uint curLine = 0; curLine < _lines; ++curLine, y += slotAreaHeight + addY) { + for (uint curLine = 0; curLine < _lines; ++curLine, y += slotAreaHeight/* + addY*/) { for (uint curColumn = 0, curX = x + defaultSpacingHorizontal / 2; curColumn < _columns; ++curColumn, curX += slotAreaWidth + addX) { ContainerWidget *container = new ContainerWidget(this, curX, y, containerWidth, containerHeight); container->setVisible(false); -- cgit v1.2.3 From 0db0b650e215847005676755363565879c2a7b94 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 29 Jun 2012 14:58:33 +0200 Subject: GUI: Fix copy&paste error affecting vertical spacing in thumbnail load chooser. --- gui/saveload-dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 8537937c0f..1d8a9872aa 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -477,7 +477,7 @@ void LoadChooserThumbnailed::reflowLayout() { const int16 defaultSpacingHorizontal = 4; const int16 defaultSpacingVertical = 4; const int16 slotAreaWidth = containerWidth + defaultSpacingHorizontal; - const int16 slotAreaHeight = containerHeight + defaultSpacingHorizontal; + const int16 slotAreaHeight = containerHeight + defaultSpacingVertical; const uint oldEntriesPerPage = _entriesPerPage; _columns = MAX(1, availableWidth / slotAreaWidth); -- cgit v1.2.3 From 7860c5bfc93055f1ebcbf037876cd2abd42818c5 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 29 Jun 2012 15:00:56 +0200 Subject: GUI: Only update save list when the dialog opens in thumbnail load chooser. --- gui/saveload-dialog.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 1d8a9872aa..25c722eec1 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -452,6 +452,7 @@ void LoadChooserThumbnailed::open() { SaveLoadChooserDialog::open(); _curPage = 0; + _saveList = _metaEngine->listSaves(_target.c_str()); updateSaves(); } @@ -546,8 +547,6 @@ void LoadChooserThumbnailed::hideButtons() { void LoadChooserThumbnailed::updateSaves() { hideButtons(); - _saveList = _metaEngine->listSaves(_target.c_str()); - for (uint i = _curPage * _entriesPerPage, curNum = 0; i < _saveList.size() && curNum < _entriesPerPage; ++i, ++curNum) { const uint saveSlot = _saveList[i].getSaveSlot(); -- cgit v1.2.3 From d3e5763276826d3f469fd93077c2f1ef6ef61314 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 29 Jun 2012 15:52:56 +0200 Subject: GUI: Allow the user to switch between list and thumbnail based load chooser. --- gui/ThemeEngine.cpp | 2 + gui/ThemeEngine.h | 4 +- gui/saveload-dialog.cpp | 78 +++++++++++++++++++-- gui/saveload-dialog.h | 18 ++++- gui/saveload.cpp | 13 +++- gui/themes/default.inc | 18 +++++ gui/themes/scummclassic.zip | Bin 93390 -> 93928 bytes gui/themes/scummclassic/THEMERC | 2 +- gui/themes/scummclassic/classic_layout.stx | 9 +++ gui/themes/scummclassic/classic_layout_lowres.stx | 9 +++ gui/themes/scummmodern.zip | Bin 1449870 -> 1452236 bytes gui/themes/scummmodern/THEMERC | 2 +- gui/themes/scummmodern/grid.bmp | Bin 0 -> 822 bytes gui/themes/scummmodern/list.bmp | Bin 0 -> 822 bytes gui/themes/scummmodern/scummmodern_gfx.stx | 2 + gui/themes/scummmodern/scummmodern_layout.stx | 9 +++ .../scummmodern/scummmodern_layout_lowres.stx | 9 +++ 17 files changed, 163 insertions(+), 12 deletions(-) create mode 100644 gui/themes/scummmodern/grid.bmp create mode 100644 gui/themes/scummmodern/list.bmp (limited to 'gui') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 1bf7ad3c85..6f34e8dc70 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -48,6 +48,8 @@ const char * const ThemeEngine::kImageLogoSmall = "logo_small.bmp"; const char * const ThemeEngine::kImageSearch = "search.bmp"; const char * const ThemeEngine::kImageEraser = "eraser.bmp"; const char * const ThemeEngine::kImageDelbtn = "delbtn.bmp"; +const char * const ThemeEngine::kImageList = "list.bmp"; +const char * const ThemeEngine::kImageGrid = "grid.bmp"; struct TextDrawData { const Graphics::Font *_fontPtr; diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 21711e2955..cd388b7f65 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -35,7 +35,7 @@ #include "graphics/pixelformat.h" -#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.13" +#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.14" class OSystem; @@ -232,6 +232,8 @@ public: static const char *const kImageSearch; ///< Search tool image used in the launcher static const char *const kImageEraser; ///< Clear input image used in the launcher static const char *const kImageDelbtn; ///< Delete characters in the predictive dialog + static const char *const kImageList; ///< List image used in save/load chooser selection + static const char *const kImageGrid; ///< Grid image used in save/load chooser selection /** * Graphics mode enumeration. diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 25c722eec1..45bf1c49fc 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -30,14 +30,23 @@ namespace GUI { -SaveLoadChooserDialog::SaveLoadChooserDialog(const Common::String &dialogName) +enum { + kListSwitchCmd = 'LIST', + kGridSwitchCmd = 'GRID' +}; + +SaveLoadChooserDialog::SaveLoadChooserDialog(const Common::String &dialogName, const bool saveMode) : Dialog(dialogName), _metaEngine(0), _delSupport(false), _metaInfoSupport(false), - _thumbnailSupport(false), _saveDateSupport(false), _playTimeSupport(false) { + _thumbnailSupport(false), _saveDateSupport(false), _playTimeSupport(false), _saveMode(saveMode), + _listButton(0), _gridButton(0) { + addChooserButtons(); } -SaveLoadChooserDialog::SaveLoadChooserDialog(int x, int y, int w, int h) +SaveLoadChooserDialog::SaveLoadChooserDialog(int x, int y, int w, int h, const bool saveMode) : Dialog(x, y, w, h), _metaEngine(0), _delSupport(false), _metaInfoSupport(false), - _thumbnailSupport(false), _saveDateSupport(false), _playTimeSupport(false) { + _thumbnailSupport(false), _saveDateSupport(false), _playTimeSupport(false), _saveMode(saveMode), + _listButton(0), _gridButton(0) { + addChooserButtons(); } void SaveLoadChooserDialog::open() { @@ -60,6 +69,63 @@ int SaveLoadChooserDialog::run(const Common::String &target, const MetaEngine *m return runIntern(); } +void SaveLoadChooserDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { + switch (cmd) { + case kListSwitchCmd: + setResult(kSwitchToList); + close(); + break; + + case kGridSwitchCmd: + setResult(kSwitchToGrid); + close(); + break; + + default: + break; + } + + return Dialog::handleCommand(sender, cmd, data); +} + +void SaveLoadChooserDialog::addChooserButtons() { + if (_listButton) { + removeWidget(_listButton); + delete _listButton; + } + + if (_gridButton) { + removeWidget(_gridButton); + delete _gridButton; + } + + _listButton = createSwitchButton("SaveLoadChooser.ListSwitch", "L", _("List view"), ThemeEngine::kImageList, kListSwitchCmd); + _gridButton = createSwitchButton("SaveLoadChooser.GridSwitch", "G", _("Grid view"), ThemeEngine::kImageGrid, kGridSwitchCmd); + if (!_metaInfoSupport || !_thumbnailSupport || _saveMode) + _gridButton->setEnabled(false); +} + +void SaveLoadChooserDialog::reflowLayout() { + addChooserButtons(); + + Dialog::reflowLayout(); +} + +GUI::ButtonWidget *SaveLoadChooserDialog::createSwitchButton(const Common::String &name, const char *desc, const char *tooltip, const char *image, uint32 cmd) { + ButtonWidget *button; + +#ifndef DISABLE_FANCY_THEMES + if (g_gui.xmlEval()->getVar("Globals.ShowChooserPics") == 1 && g_gui.theme()->supportsImages()) { + button = new PicButtonWidget(this, name, tooltip, cmd); + ((PicButtonWidget *)button)->useThemeTransparency(true); + ((PicButtonWidget *)button)->setGfx(g_gui.theme()->getImageSurface(image)); + } else +#endif + button = new ButtonWidget(this, name, desc, tooltip, cmd); + + return button; +} + // SaveLoadChooserSimple implementation enum { @@ -68,7 +134,7 @@ enum { }; SaveLoadChooserSimple::SaveLoadChooserSimple(const String &title, const String &buttonLabel, bool saveMode) - : SaveLoadChooserDialog("SaveLoadChooser"), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0) { + : SaveLoadChooserDialog("SaveLoadChooser", saveMode), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0) { _backgroundType = ThemeEngine::kDialogBackgroundSpecial; new StaticTextWidget(this, "SaveLoadChooser.Title", title); @@ -385,7 +451,7 @@ enum { }; LoadChooserThumbnailed::LoadChooserThumbnailed(const Common::String &title) - : SaveLoadChooserDialog("SaveLoadChooser"), _lines(0), _columns(0), _entriesPerPage(0), + : SaveLoadChooserDialog("SaveLoadChooser", false), _lines(0), _columns(0), _entriesPerPage(0), _curPage(0), _buttons() { _backgroundType = ThemeEngine::kDialogBackgroundSpecial; diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index b80741d36a..7921f5798a 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -29,19 +29,27 @@ namespace GUI { +#define kSwitchToList -2 +#define kSwitchToGrid -3 + class SaveLoadChooserDialog : protected Dialog { public: - SaveLoadChooserDialog(const Common::String &dialogName); - SaveLoadChooserDialog(int x, int y, int w, int h); + SaveLoadChooserDialog(const Common::String &dialogName, const bool saveMode); + SaveLoadChooserDialog(int x, int y, int w, int h, const bool saveMode); virtual void open(); + virtual void reflowLayout(); + + virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); + int run(const Common::String &target, const MetaEngine *metaEngine); virtual const Common::String &getResultString() const = 0; protected: virtual int runIntern() = 0; + const bool _saveMode; const MetaEngine *_metaEngine; bool _delSupport; bool _metaInfoSupport; @@ -49,6 +57,12 @@ protected: bool _saveDateSupport; bool _playTimeSupport; Common::String _target; + + GUI::ButtonWidget *_listButton; + GUI::ButtonWidget *_gridButton; + + void addChooserButtons(); + GUI::ButtonWidget *createSwitchButton(const Common::String &name, const char *desc, const char *tooltip, const char *image, uint32 cmd = 0); }; class SaveLoadChooserSimple : public SaveLoadChooserDialog { diff --git a/gui/saveload.cpp b/gui/saveload.cpp index becc3f6b4f..f544f0e6a0 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -83,7 +83,18 @@ int SaveLoadChooser::runModalWithPluginAndTarget(const EnginePlugin *plugin, con String oldDomain = ConfMan.getActiveDomainName(); ConfMan.setActiveDomain(target); - int ret = _impl->run(target, &(**plugin)); + int ret; + do { + ret = _impl->run(target, &(**plugin)); + + if (ret == kSwitchToList) { + delete _impl; + _impl = new SaveLoadChooserSimple(_title, _buttonLabel, _saveMode); + } else if (ret == kSwitchToGrid) { + delete _impl; + _impl = new LoadChooserThumbnailed(_title); + } + } while (ret < -1); // Revert to the old active domain ConfMan.setActiveDomain(oldDomain); diff --git a/gui/themes/default.inc b/gui/themes/default.inc index 86d0061e1b..331289ddf7 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -619,6 +619,7 @@ " " " " " " +" " " " " " " " @@ -1362,6 +1363,14 @@ " " " " " " +" " +" " " " " " " " " " +" " " " " " " " @@ -2305,6 +2315,14 @@ "/> " " " " " +" " +" " " " " + @@ -804,6 +805,14 @@ /> + + + @@ -807,6 +808,14 @@ + + + + diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 087a844a1b..30f8f3c323 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -38,6 +38,7 @@ + @@ -818,6 +819,14 @@ /> + + + @@ -806,6 +807,14 @@ + + container); + delete i->container; removeWidget(i->button); + delete i->button; removeWidget(i->description); + delete i->description; } _buttons.clear(); -- cgit v1.2.3 From e2056bdfd93ba247c819ec3fd2f0b487dde05709 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 29 Jun 2012 16:09:28 +0200 Subject: GUI: Remember last save/load chooser selection. --- gui/saveload.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/saveload.cpp b/gui/saveload.cpp index f544f0e6a0..9ae27f31be 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -43,9 +43,12 @@ void SaveLoadChooser::selectChooser(const MetaEngine &engine) { delete _impl; _impl = 0; + Common::String userConfig = ConfMan.get("gui_saveload_chooser", Common::ConfigManager::kApplicationDomain); + if (!_saveMode && g_gui.getWidth() > 320 && g_gui.getHeight() > 200 && engine.hasFeature(MetaEngine::kSavesSupportMetaInfo) - && engine.hasFeature(MetaEngine::kSavesSupportThumbnail)) { + && engine.hasFeature(MetaEngine::kSavesSupportThumbnail) + && userConfig.equalsIgnoreCase("grid")) { _impl = new LoadChooserThumbnailed(_title); } else { _impl = new SaveLoadChooserSimple(_title, _buttonLabel, _saveMode); @@ -90,9 +93,11 @@ 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); -- cgit v1.2.3 From c1426f783d91976d221c059c37b606411445d438 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 29 Jun 2012 16:15:46 +0200 Subject: GUI: Use a black rect when no thumbnail is available in the thumbnail load chooser. --- gui/saveload-dialog.cpp | 7 ++++++- gui/widget.cpp | 13 +++++++++++++ gui/widget.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 1a6083bf9e..12b34e49fb 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -622,7 +622,12 @@ void LoadChooserThumbnailed::updateSaves() { SaveStateDescriptor desc = _metaEngine->querySaveMetaInfos(_target.c_str(), saveSlot); SlotButton &curButton = _buttons[curNum]; curButton.setVisible(true); - curButton.button->setGfx(desc.getThumbnail()); + const Graphics::Surface *thumbnail = desc.getThumbnail(); + if (thumbnail) { + curButton.button->setGfx(desc.getThumbnail()); + } else { + curButton.button->setGfx(kThumbnailWidth, kThumbnailHeight2, 0, 0, 0); + } curButton.description->setLabel(Common::String::format("%d. %s", saveSlot, desc.getDescription().c_str())); Common::String tooltip(_("Name: ")); diff --git a/gui/widget.cpp b/gui/widget.cpp index 1b68e36ea8..3c26f1135b 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -414,6 +414,19 @@ void PicButtonWidget::setGfx(const Graphics::Surface *gfx) { _gfx->copyFrom(*gfx); } +void PicButtonWidget::setGfx(int w, int h, int r, int g, int b) { + if (w == -1) + w = _w; + if (h == -1) + h = _h; + + const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); + + _gfx->free(); + _gfx->create(w, h, requiredFormat); + _gfx->fillRect(Common::Rect(0, 0, w, h), _gfx->format.RGBToColor(r, g, b)); +} + void PicButtonWidget::drawWidget() { g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), "", _state, getFlags()); diff --git a/gui/widget.h b/gui/widget.h index d80b2ad7e2..bcc9a3f6d3 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -222,6 +222,7 @@ public: ~PicButtonWidget(); void setGfx(const Graphics::Surface *gfx); + void setGfx(int w, int h, int r, int g, int b); void useAlpha(int alpha) { _alpha = alpha; } void useThemeTransparency(bool enable) { _transparency = enable; } -- cgit v1.2.3 From 10bfb82d3b7ba31b7b8f57560ff55b010dd7de3e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 29 Jun 2012 16:16:36 +0200 Subject: GUI: Use a slightly bigger vertical spacing in the thumbnail load chooser. --- gui/saveload-dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 12b34e49fb..0a94fede51 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -542,7 +542,7 @@ void LoadChooserThumbnailed::reflowLayout() { const int16 containerHeight = buttonHeight + kLineHeight + containerFrameHeightAdd; const int16 defaultSpacingHorizontal = 4; - const int16 defaultSpacingVertical = 4; + const int16 defaultSpacingVertical = 8; const int16 slotAreaWidth = containerWidth + defaultSpacingHorizontal; const int16 slotAreaHeight = containerHeight + defaultSpacingVertical; -- cgit v1.2.3 From 1c389e55105d40468ff9415a3d2b3ca31ef602b8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 1 Jul 2012 15:43:20 +0200 Subject: GUI: Only use grid load dialog for 640x400 or bigger. Formerly it was enabled for everything above 320x200, but resolutions below 640x400 feature not enough space. --- gui/saveload.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/saveload.cpp b/gui/saveload.cpp index 9ae27f31be..9cc8935f03 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -45,7 +45,7 @@ void SaveLoadChooser::selectChooser(const MetaEngine &engine) { Common::String userConfig = ConfMan.get("gui_saveload_chooser", Common::ConfigManager::kApplicationDomain); - if (!_saveMode && g_gui.getWidth() > 320 && g_gui.getHeight() > 200 + if (!_saveMode && g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400 && engine.hasFeature(MetaEngine::kSavesSupportMetaInfo) && engine.hasFeature(MetaEngine::kSavesSupportThumbnail) && userConfig.equalsIgnoreCase("grid")) { -- cgit v1.2.3 From 236db5ed87acf603898243734e2c5273c23568cb Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 1 Jul 2012 15:58:42 +0200 Subject: GUI: Automatically switch to list based save/load chooser when changing resolution below 640x400. --- gui/saveload-dialog.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- gui/saveload-dialog.h | 11 +++++++++++ gui/saveload.cpp | 2 -- 3 files changed, 51 insertions(+), 3 deletions(-) (limited to 'gui') 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); -- cgit v1.2.3 From bd3d5fb8ffed3938c68a723d5c5bfbb6b56fb0ec Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 1 Jul 2012 16:07:48 +0200 Subject: GUI: Clean up save load chooser selection code. --- gui/saveload-dialog.cpp | 47 ++++++++++++++++++++--------------------------- gui/saveload-dialog.h | 5 +++-- gui/saveload.cpp | 30 ++++++++++++++---------------- 3 files changed, 37 insertions(+), 45 deletions(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 3a778b2fa4..dce09aaec8 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -31,6 +31,22 @@ namespace GUI { +SaveLoadChooserType getRequestedSaveLoadDialog(const bool saveMode, const MetaEngine &metaEngine) { + 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. + return kSaveLoadDialogGrid; + } else { + // In all other cases we want to use the list dialog. + return kSaveLoadDialogList; + } +} + enum { kListSwitchCmd = 'LIST', kGridSwitchCmd = 'GRID' @@ -73,7 +89,7 @@ int SaveLoadChooserDialog::run(const Common::String &target, const MetaEngine *m void SaveLoadChooserDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { case kListSwitchCmd: - setResult(kSwitchToList); + setResult(kSwitchSaveLoadDialog); // We save the requested dialog type here to avoid the setting to be // overwritten when our reflowLayout logic selects a different dialog // type. @@ -82,7 +98,7 @@ void SaveLoadChooserDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd break; case kGridSwitchCmd: - setResult(kSwitchToGrid); + setResult(kSwitchSaveLoadDialog); // See above. ConfMan.set("gui_saveload_chooser", "grid", Common::ConfigManager::kApplicationDomain); close(); @@ -116,34 +132,11 @@ 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; - } + const SaveLoadChooserType requestedType = getRequestedSaveLoadDialog(_saveMode, *_metaEngine); // 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; - } - + setResult(kSwitchSaveLoadDialog); close(); } diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index 75b1dc41e0..68512ad9a5 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -29,14 +29,15 @@ namespace GUI { -#define kSwitchToList -2 -#define kSwitchToGrid -3 +#define kSwitchSaveLoadDialog -2 enum SaveLoadChooserType { kSaveLoadDialogList = 0, kSaveLoadDialogGrid = 1 }; +SaveLoadChooserType getRequestedSaveLoadDialog(const bool saveMode, const MetaEngine &metaEngine); + class SaveLoadChooserDialog : protected Dialog { public: SaveLoadChooserDialog(const Common::String &dialogName, const bool saveMode); diff --git a/gui/saveload.cpp b/gui/saveload.cpp index 7f3dd6d5d8..12e62122fe 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -40,18 +40,20 @@ SaveLoadChooser::~SaveLoadChooser() { } void SaveLoadChooser::selectChooser(const MetaEngine &engine) { - delete _impl; - _impl = 0; + const SaveLoadChooserType requestedType = getRequestedSaveLoadDialog(_saveMode, engine); + if (!_impl || _impl->getType() != requestedType) { + delete _impl; + _impl = 0; - Common::String userConfig = ConfMan.get("gui_saveload_chooser", Common::ConfigManager::kApplicationDomain); + switch (requestedType) { + case kSaveLoadDialogGrid: + _impl = new LoadChooserThumbnailed(_title); + break; - if (!_saveMode && g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400 - && engine.hasFeature(MetaEngine::kSavesSupportMetaInfo) - && engine.hasFeature(MetaEngine::kSavesSupportThumbnail) - && userConfig.equalsIgnoreCase("grid")) { - _impl = new LoadChooserThumbnailed(_title); - } else { - _impl = new SaveLoadChooserSimple(_title, _buttonLabel, _saveMode); + case kSaveLoadDialogList: + _impl = new SaveLoadChooserSimple(_title, _buttonLabel, _saveMode); + break; + } } } @@ -90,12 +92,8 @@ int SaveLoadChooser::runModalWithPluginAndTarget(const EnginePlugin *plugin, con do { ret = _impl->run(target, &(**plugin)); - if (ret == kSwitchToList) { - delete _impl; - _impl = new SaveLoadChooserSimple(_title, _buttonLabel, _saveMode); - } else if (ret == kSwitchToGrid) { - delete _impl; - _impl = new LoadChooserThumbnailed(_title); + if (ret == kSwitchSaveLoadDialog) { + selectChooser(**plugin); } } while (ret < -1); -- cgit v1.2.3 From 3256081b2b1c604b1367ba3b5fc3fea8bd76d842 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 1 Jul 2012 16:47:40 +0200 Subject: GUI: Add page display to grid based load chooser. --- gui/ThemeEngine.h | 2 +- gui/saveload-dialog.cpp | 12 ++++++++++++ gui/saveload-dialog.h | 2 ++ gui/themes/default.inc | 9 +++++++++ gui/themes/scummclassic.zip | Bin 93928 -> 94215 bytes gui/themes/scummclassic/THEMERC | 2 +- gui/themes/scummclassic/classic_layout.stx | 15 ++++++++++++--- gui/themes/scummclassic/classic_layout_lowres.stx | 2 ++ gui/themes/scummmodern.zip | Bin 1452236 -> 1452523 bytes gui/themes/scummmodern/THEMERC | 2 +- gui/themes/scummmodern/scummmodern_layout.stx | 15 ++++++++++++--- .../scummmodern/scummmodern_layout_lowres.stx | 2 ++ 12 files changed, 54 insertions(+), 9 deletions(-) (limited to 'gui') diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index cd388b7f65..de4a92be16 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -35,7 +35,7 @@ #include "graphics/pixelformat.h" -#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.14" +#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.15" class OSystem; diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index dce09aaec8..3d542b1dc8 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -496,6 +496,10 @@ LoadChooserThumbnailed::LoadChooserThumbnailed(const Common::String &title) _prevButton = new GUI::ButtonWidget(this, "SaveLoadChooser.Cancel", _("Prev"), 0, kPrevCmd); _prevButton->setEnabled(false); + + // Page display + _pageDisplay = new GUI::StaticTextWidget(this, "SaveLoadChooser.PageDisplay", Common::String()); + _pageDisplay->setAlign(Graphics::kTextAlignRight); } const Common::String &LoadChooserThumbnailed::getResultString() const { @@ -555,6 +559,11 @@ void LoadChooserThumbnailed::open() { } void LoadChooserThumbnailed::reflowLayout() { + removeWidget(_pageDisplay); + if (g_gui.xmlEval()->getVar("Globals.ShowChooserPageDisplay") == 1) { + _pageDisplay->init(); + } + SaveLoadChooserDialog::reflowLayout(); destroyButtons(); @@ -690,6 +699,9 @@ void LoadChooserThumbnailed::updateSaves() { curButton.button->setTooltip(tooltip); } + const uint numPages = _saveList.size() / _entriesPerPage + 1; + _pageDisplay->setLabel(Common::String::format("%u/%u", _curPage + 1, numPages)); + if (_curPage > 0) _prevButton->setEnabled(true); else diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index 68512ad9a5..63dbf4182e 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -136,6 +136,8 @@ private: GUI::ButtonWidget *_nextButton; GUI::ButtonWidget *_prevButton; + GUI::StaticTextWidget *_pageDisplay; + struct SlotButton { SlotButton() : container(0), button(0), description(0) {} SlotButton(ContainerWidget *c, PicButtonWidget *b, StaticTextWidget *d) : container(c), button(b), description(d) {} diff --git a/gui/themes/default.inc b/gui/themes/default.inc index 331289ddf7..dc8d5c1a0e 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -620,6 +620,7 @@ " " " " " " +" " " " " " " " @@ -1574,6 +1575,7 @@ " " " " " " +" " " " " " " " @@ -2304,9 +2306,16 @@ " " " " " " +" " " " +" " +" " +" " " " " " " + + @@ -794,9 +796,16 @@ - + + + + + + + diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip index 977a6960e6..a861e8e0df 100644 Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ diff --git a/gui/themes/scummmodern/THEMERC b/gui/themes/scummmodern/THEMERC index e9a2d542c4..c4381c2061 100644 --- a/gui/themes/scummmodern/THEMERC +++ b/gui/themes/scummmodern/THEMERC @@ -1 +1 @@ -[SCUMMVM_STX0.8.14:ScummVM Modern Theme:No Author] +[SCUMMVM_STX0.8.15:ScummVM Modern Theme:No Author] diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 30f8f3c323..e27de3fe9b 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -38,7 +38,9 @@ + + @@ -808,9 +810,16 @@ - + + + + + + + -- cgit v1.2.3 From 049e61b4459fd6fdbcf29c5d0e29d35755de82e3 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 1 Jul 2012 17:17:04 +0200 Subject: GUI: Fix small memory leak in grid based load chooser. --- gui/saveload-dialog.cpp | 5 +++++ gui/saveload-dialog.h | 1 + 2 files changed, 6 insertions(+) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 3d542b1dc8..d7fa9c686a 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -502,6 +502,11 @@ LoadChooserThumbnailed::LoadChooserThumbnailed(const Common::String &title) _pageDisplay->setAlign(Graphics::kTextAlignRight); } +LoadChooserThumbnailed::~LoadChooserThumbnailed() { + removeWidget(_pageDisplay); + delete _pageDisplay; +} + const Common::String &LoadChooserThumbnailed::getResultString() const { // FIXME: This chooser is only for loading, thus the result is never used // anyway. But this is still an ugly hack. diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index 63dbf4182e..e169dbf613 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -112,6 +112,7 @@ private: class LoadChooserThumbnailed : public SaveLoadChooserDialog { public: LoadChooserThumbnailed(const Common::String &title); + ~LoadChooserThumbnailed(); virtual const Common::String &getResultString() const; -- cgit v1.2.3 From 0cf00ddfe2d985bdd00f5fb06ee5bfb2f8683831 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 9 Jul 2012 01:49:58 +0200 Subject: GUI: Make container widget a bit more container like. Now it is possible to add sub widgets to a ContainerWidget and allow for these to get events too. --- gui/widget.cpp | 20 ++++++++++++++++++++ gui/widget.h | 3 +++ 2 files changed, 23 insertions(+) (limited to 'gui') diff --git a/gui/widget.cpp b/gui/widget.cpp index 3c26f1135b..4babce66fb 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -711,6 +711,26 @@ ContainerWidget::ContainerWidget(GuiObject *boss, const Common::String &name) : _type = kContainerWidget; } +ContainerWidget::~ContainerWidget() { + // We also remove the widget from the boss to avoid segfaults, when the + // deleted widget is an active widget in the boss. + for (Widget *w = _firstWidget; w; w = w->next()) { + _boss->removeWidget(w); + } +} + +Widget *ContainerWidget::findWidget(int x, int y) { + return findWidgetInChain(_firstWidget, x, y); +} + +void ContainerWidget::removeWidget(Widget *widget) { + // We also remove the widget from the boss to avoid a reference to a + // widget not in the widget chain anymore. + _boss->removeWidget(widget); + + Widget::removeWidget(widget); +} + void ContainerWidget::drawWidget() { g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, ThemeEngine::kWidgetBackgroundBorder); } diff --git a/gui/widget.h b/gui/widget.h index bcc9a3f6d3..6f710f302f 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -368,7 +368,10 @@ class ContainerWidget : public Widget { public: ContainerWidget(GuiObject *boss, int x, int y, int w, int h); ContainerWidget(GuiObject *boss, const Common::String &name); + ~ContainerWidget(); + virtual Widget *findWidget(int x, int y); + virtual void removeWidget(Widget *widget); protected: void drawWidget(); }; -- cgit v1.2.3 From e37c0be0d91029284cee1e3ff895de15e59248f8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 9 Jul 2012 02:17:57 +0200 Subject: GUI: Fix missing button background in grid based chooser. Now the thumbnail button and the descriptions are sub widgets of the container widget. --- gui/saveload-dialog.cpp | 14 ++++---------- gui/saveload-dialog.h | 2 -- 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index d7fa9c686a..cf97737a1b 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -611,15 +611,13 @@ void LoadChooserThumbnailed::reflowLayout() { ContainerWidget *container = new ContainerWidget(this, curX, y, containerWidth, containerHeight); container->setVisible(false); - int dstY = y + containerFrameHeightAdd / 2; - int dstX = curX + containerFrameWidthAdd / 2; + int dstY = containerFrameHeightAdd / 2; + int dstX = containerFrameWidthAdd / 2; - PicButtonWidget *button = new PicButtonWidget(this, dstX, dstY, buttonWidth, buttonHeight, 0, curLine * _columns + curColumn + 1); - button->setVisible(false); + PicButtonWidget *button = new PicButtonWidget(container, dstX, dstY, buttonWidth, buttonHeight, 0, curLine * _columns + curColumn + 1); dstY += buttonHeight; - StaticTextWidget *description = new StaticTextWidget(this, dstX, dstY, buttonWidth, kLineHeight, Common::String(), Graphics::kTextAlignLeft); - description->setVisible(false); + StaticTextWidget *description = new StaticTextWidget(container, dstX, dstY, buttonWidth, kLineHeight, Common::String(), Graphics::kTextAlignLeft); _buttons.push_back(SlotButton(container, button, description)); } @@ -642,10 +640,6 @@ void LoadChooserThumbnailed::destroyButtons() { for (ButtonArray::iterator i = _buttons.begin(), end = _buttons.end(); i != end; ++i) { removeWidget(i->container); delete i->container; - removeWidget(i->button); - delete i->button; - removeWidget(i->description); - delete i->description; } _buttons.clear(); diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index e169dbf613..a604773142 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -149,8 +149,6 @@ private: void setVisible(bool state) { container->setVisible(state); - button->setVisible(state); - description->setVisible(state); } }; typedef Common::Array ButtonArray; -- cgit v1.2.3 From 6d18bddbb5d2b6f61edbf6a1b7014ca1fbca81a9 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 20 Jul 2012 14:50:00 -0400 Subject: CREDITS: Credits for original sources --- gui/credits.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index 7226864543..1b3ba82017 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -710,5 +710,9 @@ static const char *credits[] = { "C0""", "C0""Broken Sword 2.5 team for providing sources of their engine and their great support.", "C0""", +"C0""Neil Dodwell and David Dew from Creative Reality for providing the source of Dreamweb and for their tremendous support.", +"C0""", +"C0""Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon for providing full source code for Soltys and letting us to redistribute the game.", +"C0""", "", }; -- cgit v1.2.3 From b5feb0dcc70ccaab77e2005d32a33cfc614a57e3 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 20 Jul 2012 21:03:34 +0200 Subject: CREDITS: Update dreamweb team --- gui/credits.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index 1b3ba82017..34c6f21026 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -106,8 +106,10 @@ static const char *credits[] = { "C1""DreamWeb", "C0""Torbj\366rn Andersson", "C0""Bertrand Augereau", +"C0""Filippos Karapetis", "C0""Vladimir Menshakov", "C2""(retired)", +"C0""Willem Jan Palenstijn", "", "C1""Gob", "C0""Torbj\366rn Andersson", -- cgit v1.2.3 From 90eb773c5d862d38f3dc834d51c5a57319c61c3f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 13 Jul 2012 17:17:58 +0200 Subject: GUI: Implement saving in the grid based save/load chooser. --- gui/ThemeEngine.h | 2 +- gui/saveload-dialog.cpp | 179 ++++++++++++++++++--- gui/saveload-dialog.h | 32 +++- gui/saveload.cpp | 4 +- gui/themes/default.inc | 40 +++++ gui/themes/scummclassic.zip | Bin 94215 -> 95181 bytes gui/themes/scummclassic/THEMERC | 2 +- gui/themes/scummclassic/classic_layout.stx | 21 +++ gui/themes/scummclassic/classic_layout_lowres.stx | 20 +++ gui/themes/scummmodern.zip | Bin 1452523 -> 1453476 bytes gui/themes/scummmodern/THEMERC | 2 +- gui/themes/scummmodern/scummmodern_layout.stx | 21 +++ .../scummmodern/scummmodern_layout_lowres.stx | 20 +++ gui/widget.cpp | 2 +- 14 files changed, 318 insertions(+), 27 deletions(-) (limited to 'gui') diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index de4a92be16..6fb93d3b46 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -35,7 +35,7 @@ #include "graphics/pixelformat.h" -#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.15" +#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.16" class OSystem; diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index cf97737a1b..8f61d038e5 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -26,14 +26,15 @@ #include "gui/message.h" #include "gui/gui-manager.h" #include "gui/ThemeEval.h" +#include "gui/widgets/edittext.h" #include "graphics/scaler.h" namespace GUI { -SaveLoadChooserType getRequestedSaveLoadDialog(const bool saveMode, const MetaEngine &metaEngine) { +SaveLoadChooserType getRequestedSaveLoadDialog(const MetaEngine &metaEngine) { const Common::String &userConfig = ConfMan.get("gui_saveload_chooser", Common::ConfigManager::kApplicationDomain); - if (!saveMode && g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400 + if (g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400 && metaEngine.hasFeature(MetaEngine::kSavesSupportMetaInfo) && metaEngine.hasFeature(MetaEngine::kSavesSupportThumbnail) && userConfig.equalsIgnoreCase("grid")) { @@ -124,7 +125,7 @@ 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 || !(g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400)) + if (!_metaInfoSupport || !_thumbnailSupport || !(g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400)) _gridButton->setEnabled(false); } @@ -132,7 +133,7 @@ void SaveLoadChooserDialog::reflowLayout() { addChooserButtons(); const SaveLoadChooserType currentType = getType(); - const SaveLoadChooserType requestedType = getRequestedSaveLoadDialog(_saveMode, *_metaEngine); + const SaveLoadChooserType requestedType = getRequestedSaveLoadDialog(*_metaEngine); // Change the dialog type if there is any need for it. if (requestedType != currentType) { @@ -479,12 +480,13 @@ void SaveLoadChooserSimple::updateSaveList() { enum { kNextCmd = 'NEXT', - kPrevCmd = 'PREV' + kPrevCmd = 'PREV', + kNewSaveCmd = 'SAVE' }; -LoadChooserThumbnailed::LoadChooserThumbnailed(const Common::String &title) - : SaveLoadChooserDialog("SaveLoadChooser", false), _lines(0), _columns(0), _entriesPerPage(0), - _curPage(0), _buttons() { +LoadChooserThumbnailed::LoadChooserThumbnailed(const Common::String &title, bool saveMode) + : SaveLoadChooserDialog("SaveLoadChooser", saveMode), _lines(0), _columns(0), _entriesPerPage(0), + _curPage(0), _newSaveContainer(0), _nextFreeSaveSlot(0), _buttons() { _backgroundType = ThemeEngine::kDialogBackgroundSpecial; new StaticTextWidget(this, "SaveLoadChooser.Title", title); @@ -508,14 +510,18 @@ LoadChooserThumbnailed::~LoadChooserThumbnailed() { } const Common::String &LoadChooserThumbnailed::getResultString() const { - // FIXME: This chooser is only for loading, thus the result is never used - // anyway. But this is still an ugly hack. - return _target; + return _resultString; } void LoadChooserThumbnailed::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { if (cmd <= _entriesPerPage) { - setResult(_saveList[cmd - 1 + _curPage * _entriesPerPage].getSaveSlot()); + const SaveStateDescriptor &desc = _saveList[cmd - 1 + _curPage * _entriesPerPage]; + + if (_saveMode) { + _resultString = desc.getDescription(); + } + + setResult(desc.getSaveSlot()); close(); } @@ -532,6 +538,11 @@ void LoadChooserThumbnailed::handleCommand(GUI::CommandSender *sender, uint32 cm draw(); break; + case kNewSaveCmd: + setResult(_nextFreeSaveSlot); + close(); + break; + case kCloseCmd: setResult(-1); default: @@ -560,6 +571,30 @@ void LoadChooserThumbnailed::open() { _curPage = 0; _saveList = _metaEngine->listSaves(_target.c_str()); + _resultString.clear(); + + // Determine the next free save slot for save mode + if (_saveMode) { + int lastSlot = -1; + _nextFreeSaveSlot = -1; + for (SaveStateList::const_iterator x = _saveList.begin(); x != _saveList.end(); ++x) { + const int curSlot = x->getSaveSlot(); + + // In case there was a gap found use the slot. + if (lastSlot + 1 < curSlot) { + _nextFreeSaveSlot = lastSlot + 1; + break; + } + + lastSlot = curSlot; + } + + // Use the next available slot otherwise. + if (_nextFreeSaveSlot == -1 && lastSlot + 1 < _metaEngine->getMaximumSaveSlot()) { + _nextFreeSaveSlot = lastSlot + 1; + } + } + updateSaves(); } @@ -596,9 +631,20 @@ void LoadChooserThumbnailed::reflowLayout() { _columns = MAX(1, availableWidth / slotAreaWidth); _lines = MAX(1, availableHeight / slotAreaHeight); _entriesPerPage = _columns * _lines; + + // In save mode the first button is always "New Save", thus we need to + // adjust the entries per page here. + if (_saveMode) { + --_entriesPerPage; + } + // Recalculate the page number if (!_saveList.empty() && oldEntriesPerPage != 0) { - _curPage = (_curPage * oldEntriesPerPage) / _entriesPerPage; + if (_entriesPerPage != 0) { + _curPage = (_curPage * oldEntriesPerPage) / _entriesPerPage; + } else { + _curPage = 0; + } } const uint addX = _columns > 1 ? (availableWidth % slotAreaWidth) / (_columns - 1) : 0; @@ -608,13 +654,32 @@ void LoadChooserThumbnailed::reflowLayout() { y += defaultSpacingVertical / 2; for (uint curLine = 0; curLine < _lines; ++curLine, y += slotAreaHeight/* + addY*/) { for (uint curColumn = 0, curX = x + defaultSpacingHorizontal / 2; curColumn < _columns; ++curColumn, curX += slotAreaWidth + addX) { - ContainerWidget *container = new ContainerWidget(this, curX, y, containerWidth, containerHeight); - container->setVisible(false); - int dstY = containerFrameHeightAdd / 2; int dstX = containerFrameWidthAdd / 2; - PicButtonWidget *button = new PicButtonWidget(container, dstX, dstY, buttonWidth, buttonHeight, 0, curLine * _columns + curColumn + 1); + // In the save mode we will always create a new save button as the first button. + if (_saveMode && curLine == 0 && curColumn == 0) { + _newSaveContainer = new ContainerWidget(this, curX, y, containerWidth, containerHeight); + ButtonWidget *newSave = new ButtonWidget(_newSaveContainer, dstX, dstY, buttonWidth, buttonHeight, _("New Save"), _("Create a new save game"), kNewSaveCmd); + // In case no more slots are free, we will disable the new save button + if (_nextFreeSaveSlot == -1) { + newSave->setEnabled(false); + } + continue; + } + + ContainerWidget *container = new ContainerWidget(this, curX, y, containerWidth, containerHeight); + container->setVisible(false); + + // Command 0 cannot be used, since it won't be send. Thus we will adjust + // command number here, if required. This is only the case for load mode + // since for save mode, the first button used is index 1 anyway. + uint buttonCmd = curLine * _columns + curColumn; + if (!_saveMode) { + buttonCmd += 1; + } + + PicButtonWidget *button = new PicButtonWidget(container, dstX, dstY, buttonWidth, buttonHeight, 0, buttonCmd); dstY += buttonHeight; StaticTextWidget *description = new StaticTextWidget(container, dstX, dstY, buttonWidth, kLineHeight, Common::String(), Graphics::kTextAlignLeft); @@ -633,10 +698,41 @@ void LoadChooserThumbnailed::close() { } int LoadChooserThumbnailed::runIntern() { - return SaveLoadChooserDialog::runModal(); + int slot; + do { + const SaveLoadChooserType currentType = getType(); + const SaveLoadChooserType requestedType = getRequestedSaveLoadDialog(*_metaEngine); + + // Catch resolution changes when the save name dialog was open. + if (currentType != requestedType) { + setResult(kSwitchSaveLoadDialog); + return kSwitchSaveLoadDialog; + } + + slot = runModal(); + } while (_saveMode && slot >= 0 && !selectDescription()); + + return slot; +} + +bool LoadChooserThumbnailed::selectDescription() { + _savenameDialog.setDescription(_resultString); + _savenameDialog.setTargetSlot(getResult()); + if (_savenameDialog.runModal() == 0) { + _resultString = _savenameDialog.getDescription(); + return true; + } else { + return false; + } } void LoadChooserThumbnailed::destroyButtons() { + if (_newSaveContainer) { + removeWidget(_newSaveContainer); + delete _newSaveContainer; + _newSaveContainer = 0; + } + for (ButtonArray::iterator i = _buttons.begin(), end = _buttons.end(); i != end; ++i) { removeWidget(i->container); delete i->container; @@ -696,9 +792,17 @@ void LoadChooserThumbnailed::updateSaves() { } curButton.button->setTooltip(tooltip); + + // In save mode we disable the button, when it's write protected. + // TODO: Maybe we should not display it at all then? + if (_saveMode && desc.getWriteProtectedFlag()) { + curButton.button->setEnabled(false); + } else { + curButton.button->setEnabled(true); + } } - const uint numPages = _saveList.size() / _entriesPerPage + 1; + const uint numPages = (_entriesPerPage != 0) ? (_saveList.size() / _entriesPerPage + 1) : 1; _pageDisplay->setLabel(Common::String::format("%u/%u", _curPage + 1, numPages)); if (_curPage > 0) @@ -712,4 +816,41 @@ void LoadChooserThumbnailed::updateSaves() { _nextButton->setEnabled(false); } +SavenameDialog::SavenameDialog() + : Dialog("SavenameDialog") { + _title = new StaticTextWidget(this, "SavenameDialog.DescriptionText", Common::String()); + + new ButtonWidget(this, "SavenameDialog.Cancel", _("Cancel"), 0, kCloseCmd); + new ButtonWidget(this, "SavenameDialog.Ok", _("Ok"), 0, kOKCmd); + + _description = new EditTextWidget(this, "SavenameDialog.Description", Common::String(), 0, 0, kOKCmd); +} + +void SavenameDialog::setDescription(const Common::String &desc) { + _description->setEditString(desc); +} + +const Common::String &SavenameDialog::getDescription() { + return _description->getEditString(); +} + +void SavenameDialog::open() { + Dialog::open(); + setResult(-1); + + _title->setLabel(Common::String::format(_("Enter a description for slot %d:"), _targetSlot)); +} + +void SavenameDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { + switch (cmd) { + case kOKCmd: + setResult(0); + close(); + break; + + default: + Dialog::handleCommand(sender, cmd, data); + } +} + } // End of namespace GUI diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index a604773142..46799ad853 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -36,7 +36,7 @@ enum SaveLoadChooserType { kSaveLoadDialogGrid = 1 }; -SaveLoadChooserType getRequestedSaveLoadDialog(const bool saveMode, const MetaEngine &metaEngine); +SaveLoadChooserType getRequestedSaveLoadDialog(const MetaEngine &metaEngine); class SaveLoadChooserDialog : protected Dialog { public: @@ -109,9 +109,30 @@ private: void updateSelection(bool redraw); }; + +class EditTextWidget; + +class SavenameDialog : public Dialog { +public: + SavenameDialog(); + + void setDescription(const Common::String &desc); + const Common::String &getDescription(); + + void setTargetSlot(int slot) { _targetSlot = slot; } + + virtual void open(); +protected: + virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); +private: + int _targetSlot; + StaticTextWidget *_title; + EditTextWidget *_description; +}; + class LoadChooserThumbnailed : public SaveLoadChooserDialog { public: - LoadChooserThumbnailed(const Common::String &title); + LoadChooserThumbnailed(const Common::String &title, bool saveMode); ~LoadChooserThumbnailed(); virtual const Common::String &getResultString() const; @@ -139,6 +160,13 @@ private: GUI::StaticTextWidget *_pageDisplay; + ContainerWidget *_newSaveContainer; + int _nextFreeSaveSlot; + Common::String _resultString; + + SavenameDialog _savenameDialog; + bool selectDescription(); + struct SlotButton { SlotButton() : container(0), button(0), description(0) {} SlotButton(ContainerWidget *c, PicButtonWidget *b, StaticTextWidget *d) : container(c), button(b), description(d) {} diff --git a/gui/saveload.cpp b/gui/saveload.cpp index 12e62122fe..1eceff79cd 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -40,14 +40,14 @@ SaveLoadChooser::~SaveLoadChooser() { } void SaveLoadChooser::selectChooser(const MetaEngine &engine) { - const SaveLoadChooserType requestedType = getRequestedSaveLoadDialog(_saveMode, engine); + const SaveLoadChooserType requestedType = getRequestedSaveLoadDialog(engine); if (!_impl || _impl->getType() != requestedType) { delete _impl; _impl = 0; switch (requestedType) { case kSaveLoadDialogGrid: - _impl = new LoadChooserThumbnailed(_title); + _impl = new LoadChooserThumbnailed(_title, _saveMode); break; case kSaveLoadDialogList: diff --git a/gui/themes/default.inc b/gui/themes/default.inc index dc8d5c1a0e..bfd78db3ae 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -1386,6 +1386,26 @@ " " " " " " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " " " " " " " " " " " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " " " " " " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + = 0 && x < _w && y >= 0 && y < _h) { - sendCommand(_cmd, 0); startAnimatePressedState(); + sendCommand(_cmd, 0); } } -- cgit v1.2.3 From 89b638128ff0482a01cfd3d058d87aa95faf58c3 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 24 Jul 2012 23:24:17 +0200 Subject: GUI: Rename LoadChooserThumbnailed to SaveLoadChooserGrid. --- gui/saveload-dialog.cpp | 28 ++++++++++++++-------------- gui/saveload-dialog.h | 6 +++--- gui/saveload.cpp | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 8f61d038e5..2ceace2c8a 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -476,7 +476,7 @@ void SaveLoadChooserSimple::updateSaveList() { _list->setList(saveNames, &colors); } -// LoadChooserThumbnailed implementation +// SaveLoadChooserGrid implementation enum { kNextCmd = 'NEXT', @@ -484,7 +484,7 @@ enum { kNewSaveCmd = 'SAVE' }; -LoadChooserThumbnailed::LoadChooserThumbnailed(const Common::String &title, bool saveMode) +SaveLoadChooserGrid::SaveLoadChooserGrid(const Common::String &title, bool saveMode) : SaveLoadChooserDialog("SaveLoadChooser", saveMode), _lines(0), _columns(0), _entriesPerPage(0), _curPage(0), _newSaveContainer(0), _nextFreeSaveSlot(0), _buttons() { _backgroundType = ThemeEngine::kDialogBackgroundSpecial; @@ -504,16 +504,16 @@ LoadChooserThumbnailed::LoadChooserThumbnailed(const Common::String &title, bool _pageDisplay->setAlign(Graphics::kTextAlignRight); } -LoadChooserThumbnailed::~LoadChooserThumbnailed() { +SaveLoadChooserGrid::~SaveLoadChooserGrid() { removeWidget(_pageDisplay); delete _pageDisplay; } -const Common::String &LoadChooserThumbnailed::getResultString() const { +const Common::String &SaveLoadChooserGrid::getResultString() const { return _resultString; } -void LoadChooserThumbnailed::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { +void SaveLoadChooserGrid::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { if (cmd <= _entriesPerPage) { const SaveStateDescriptor &desc = _saveList[cmd - 1 + _curPage * _entriesPerPage]; @@ -550,7 +550,7 @@ void LoadChooserThumbnailed::handleCommand(GUI::CommandSender *sender, uint32 cm } } -void LoadChooserThumbnailed::handleMouseWheel(int x, int y, int direction) { +void SaveLoadChooserGrid::handleMouseWheel(int x, int y, int direction) { if (direction > 0) { if (_nextButton->isEnabled()) { ++_curPage; @@ -566,7 +566,7 @@ void LoadChooserThumbnailed::handleMouseWheel(int x, int y, int direction) { } } -void LoadChooserThumbnailed::open() { +void SaveLoadChooserGrid::open() { SaveLoadChooserDialog::open(); _curPage = 0; @@ -598,7 +598,7 @@ void LoadChooserThumbnailed::open() { updateSaves(); } -void LoadChooserThumbnailed::reflowLayout() { +void SaveLoadChooserGrid::reflowLayout() { removeWidget(_pageDisplay); if (g_gui.xmlEval()->getVar("Globals.ShowChooserPageDisplay") == 1) { _pageDisplay->init(); @@ -692,12 +692,12 @@ void LoadChooserThumbnailed::reflowLayout() { updateSaves(); } -void LoadChooserThumbnailed::close() { +void SaveLoadChooserGrid::close() { SaveLoadChooserDialog::close(); hideButtons(); } -int LoadChooserThumbnailed::runIntern() { +int SaveLoadChooserGrid::runIntern() { int slot; do { const SaveLoadChooserType currentType = getType(); @@ -715,7 +715,7 @@ int LoadChooserThumbnailed::runIntern() { return slot; } -bool LoadChooserThumbnailed::selectDescription() { +bool SaveLoadChooserGrid::selectDescription() { _savenameDialog.setDescription(_resultString); _savenameDialog.setTargetSlot(getResult()); if (_savenameDialog.runModal() == 0) { @@ -726,7 +726,7 @@ bool LoadChooserThumbnailed::selectDescription() { } } -void LoadChooserThumbnailed::destroyButtons() { +void SaveLoadChooserGrid::destroyButtons() { if (_newSaveContainer) { removeWidget(_newSaveContainer); delete _newSaveContainer; @@ -741,7 +741,7 @@ void LoadChooserThumbnailed::destroyButtons() { _buttons.clear(); } -void LoadChooserThumbnailed::hideButtons() { +void SaveLoadChooserGrid::hideButtons() { for (ButtonArray::iterator i = _buttons.begin(), end = _buttons.end(); i != end; ++i) { i->button->setGfx(0); i->setVisible(false); @@ -749,7 +749,7 @@ void LoadChooserThumbnailed::hideButtons() { } -void LoadChooserThumbnailed::updateSaves() { +void SaveLoadChooserGrid::updateSaves() { hideButtons(); for (uint i = _curPage * _entriesPerPage, curNum = 0; i < _saveList.size() && curNum < _entriesPerPage; ++i, ++curNum) { diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index 46799ad853..351d0f682f 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -130,10 +130,10 @@ private: EditTextWidget *_description; }; -class LoadChooserThumbnailed : public SaveLoadChooserDialog { +class SaveLoadChooserGrid : public SaveLoadChooserDialog { public: - LoadChooserThumbnailed(const Common::String &title, bool saveMode); - ~LoadChooserThumbnailed(); + SaveLoadChooserGrid(const Common::String &title, bool saveMode); + ~SaveLoadChooserGrid(); virtual const Common::String &getResultString() const; diff --git a/gui/saveload.cpp b/gui/saveload.cpp index 1eceff79cd..0650be388c 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -47,7 +47,7 @@ void SaveLoadChooser::selectChooser(const MetaEngine &engine) { switch (requestedType) { case kSaveLoadDialogGrid: - _impl = new LoadChooserThumbnailed(_title, _saveMode); + _impl = new SaveLoadChooserGrid(_title, _saveMode); break; case kSaveLoadDialogList: -- cgit v1.2.3 From 91196e53750f328b30703ffd09cbf3f5e877dc8e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 24 Jul 2012 23:25:10 +0200 Subject: GUI: Also disable the switch-to-list button in the choosers, when the grid one isn't available. --- gui/saveload-dialog.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 2ceace2c8a..159e9617ad 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -125,8 +125,10 @@ 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 || !(g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400)) + if (!_metaInfoSupport || !_thumbnailSupport || !(g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400)) { _gridButton->setEnabled(false); + _listButton->setEnabled(false); + } } void SaveLoadChooserDialog::reflowLayout() { -- cgit v1.2.3 From 8e791896b80009dc779770d8761abc89755fee93 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 24 Jul 2012 23:26:47 +0200 Subject: GUI: Remove an unnecessary empty line. --- gui/saveload-dialog.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 159e9617ad..f81fdc210c 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -748,7 +748,6 @@ void SaveLoadChooserGrid::hideButtons() { i->button->setGfx(0); i->setVisible(false); } - } void SaveLoadChooserGrid::updateSaves() { -- cgit v1.2.3 From bab992ab98dba252e6106161502ec2b945540ea1 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 24 Jul 2012 23:27:59 +0200 Subject: GUI: Remove unecessary explicit GUI namespace uses. --- gui/saveload-dialog.cpp | 40 ++++++++++++++++++++-------------------- gui/saveload-dialog.h | 36 ++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 38 deletions(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index f81fdc210c..9f7664b809 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -87,7 +87,7 @@ int SaveLoadChooserDialog::run(const Common::String &target, const MetaEngine *m return runIntern(); } -void SaveLoadChooserDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { +void SaveLoadChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { case kListSwitchCmd: setResult(kSwitchSaveLoadDialog); @@ -146,7 +146,7 @@ void SaveLoadChooserDialog::reflowLayout() { Dialog::reflowLayout(); } -GUI::ButtonWidget *SaveLoadChooserDialog::createSwitchButton(const Common::String &name, const char *desc, const char *tooltip, const char *image, uint32 cmd) { +ButtonWidget *SaveLoadChooserDialog::createSwitchButton(const Common::String &name, const char *desc, const char *tooltip, const char *image, uint32 cmd) { ButtonWidget *button; #ifndef DISABLE_FANCY_THEMES @@ -175,28 +175,28 @@ SaveLoadChooserSimple::SaveLoadChooserSimple(const String &title, const String & new StaticTextWidget(this, "SaveLoadChooser.Title", title); // Add choice list - _list = new GUI::ListWidget(this, "SaveLoadChooser.List"); - _list->setNumberingMode(GUI::kListNumberingZero); + _list = new ListWidget(this, "SaveLoadChooser.List"); + _list->setNumberingMode(kListNumberingZero); _list->setEditable(saveMode); - _gfxWidget = new GUI::GraphicsWidget(this, 0, 0, 10, 10); + _gfxWidget = new GraphicsWidget(this, 0, 0, 10, 10); _date = new StaticTextWidget(this, 0, 0, 10, 10, _("No date saved"), Graphics::kTextAlignCenter); _time = new StaticTextWidget(this, 0, 0, 10, 10, _("No time saved"), Graphics::kTextAlignCenter); _playtime = new StaticTextWidget(this, 0, 0, 10, 10, _("No playtime saved"), Graphics::kTextAlignCenter); // Buttons - new GUI::ButtonWidget(this, "SaveLoadChooser.Cancel", _("Cancel"), 0, kCloseCmd); - _chooseButton = new GUI::ButtonWidget(this, "SaveLoadChooser.Choose", buttonLabel, 0, kChooseCmd); + new ButtonWidget(this, "SaveLoadChooser.Cancel", _("Cancel"), 0, kCloseCmd); + _chooseButton = new ButtonWidget(this, "SaveLoadChooser.Choose", buttonLabel, 0, kChooseCmd); _chooseButton->setEnabled(false); - _deleteButton = new GUI::ButtonWidget(this, "SaveLoadChooser.Delete", _("Delete"), 0, kDelCmd); + _deleteButton = new ButtonWidget(this, "SaveLoadChooser.Delete", _("Delete"), 0, kDelCmd); _deleteButton->setEnabled(false); _delSupport = _metaInfoSupport = _thumbnailSupport = false; - _container = new GUI::ContainerWidget(this, 0, 0, 10, 10); -// _container->setHints(GUI::THEME_HINT_USE_SHADOW); + _container = new ContainerWidget(this, 0, 0, 10, 10); +// _container->setHints(THEME_HINT_USE_SHADOW); } int SaveLoadChooserSimple::runIntern() { @@ -219,8 +219,8 @@ void SaveLoadChooserSimple::handleCommand(CommandSender *sender, uint32 cmd, uin int selItem = _list->getSelected(); switch (cmd) { - case GUI::kListItemActivatedCmd: - case GUI::kListItemDoubleClickedCmd: + case kListItemActivatedCmd: + case kListItemDoubleClickedCmd: if (selItem >= 0 && _chooseButton->isEnabled()) { if (_list->isEditable() || !_list->getSelectedString().empty()) { _list->endEditMode(); @@ -240,14 +240,14 @@ void SaveLoadChooserSimple::handleCommand(CommandSender *sender, uint32 cmd, uin } close(); break; - case GUI::kListSelectionChangedCmd: + case kListSelectionChangedCmd: updateSelection(true); break; case kDelCmd: if (selItem >= 0 && _delSupport) { MessageDialog alert(_("Do you really want to delete this savegame?"), _("Delete"), _("Cancel")); - if (alert.runModal() == GUI::kMessageOK) { + if (alert.runModal() == kMessageOK) { _metaEngine->removeSaveState(_target.c_str(), _saveList[selItem].getSaveSlot()); setResult(-1); @@ -494,15 +494,15 @@ SaveLoadChooserGrid::SaveLoadChooserGrid(const Common::String &title, bool saveM new StaticTextWidget(this, "SaveLoadChooser.Title", title); // Buttons - new GUI::ButtonWidget(this, "SaveLoadChooser.Delete", _("Cancel"), 0, kCloseCmd); - _nextButton = new GUI::ButtonWidget(this, "SaveLoadChooser.Choose", _("Next"), 0, kNextCmd); + new ButtonWidget(this, "SaveLoadChooser.Delete", _("Cancel"), 0, kCloseCmd); + _nextButton = new ButtonWidget(this, "SaveLoadChooser.Choose", _("Next"), 0, kNextCmd); _nextButton->setEnabled(false); - _prevButton = new GUI::ButtonWidget(this, "SaveLoadChooser.Cancel", _("Prev"), 0, kPrevCmd); + _prevButton = new ButtonWidget(this, "SaveLoadChooser.Cancel", _("Prev"), 0, kPrevCmd); _prevButton->setEnabled(false); // Page display - _pageDisplay = new GUI::StaticTextWidget(this, "SaveLoadChooser.PageDisplay", Common::String()); + _pageDisplay = new StaticTextWidget(this, "SaveLoadChooser.PageDisplay", Common::String()); _pageDisplay->setAlign(Graphics::kTextAlignRight); } @@ -515,7 +515,7 @@ const Common::String &SaveLoadChooserGrid::getResultString() const { return _resultString; } -void SaveLoadChooserGrid::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { +void SaveLoadChooserGrid::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { if (cmd <= _entriesPerPage) { const SaveStateDescriptor &desc = _saveList[cmd - 1 + _curPage * _entriesPerPage]; @@ -842,7 +842,7 @@ void SavenameDialog::open() { _title->setLabel(Common::String::format(_("Enter a description for slot %d:"), _targetSlot)); } -void SavenameDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { +void SavenameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { case kOKCmd: setResult(0); diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index 351d0f682f..05c0715fe0 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -47,7 +47,7 @@ public: virtual void reflowLayout(); - virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual SaveLoadChooserType getType() const = 0; @@ -66,11 +66,11 @@ protected: bool _playTimeSupport; Common::String _target; - GUI::ButtonWidget *_listButton; - GUI::ButtonWidget *_gridButton; + ButtonWidget *_listButton; + ButtonWidget *_gridButton; void addChooserButtons(); - GUI::ButtonWidget *createSwitchButton(const Common::String &name, const char *desc, const char *tooltip, const char *image, uint32 cmd = 0); + ButtonWidget *createSwitchButton(const Common::String &name, const char *desc, const char *tooltip, const char *image, uint32 cmd = 0); }; class SaveLoadChooserSimple : public SaveLoadChooserDialog { @@ -79,7 +79,7 @@ class SaveLoadChooserSimple : public SaveLoadChooserDialog { public: SaveLoadChooserSimple(const String &title, const String &buttonLabel, bool saveMode); - virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual const Common::String &getResultString() const; @@ -91,14 +91,14 @@ public: private: virtual int runIntern(); - GUI::ListWidget *_list; - GUI::ButtonWidget *_chooseButton; - GUI::ButtonWidget *_deleteButton; - GUI::GraphicsWidget *_gfxWidget; - GUI::ContainerWidget *_container; - GUI::StaticTextWidget *_date; - GUI::StaticTextWidget *_time; - GUI::StaticTextWidget *_playtime; + ListWidget *_list; + ButtonWidget *_chooseButton; + ButtonWidget *_deleteButton; + GraphicsWidget *_gfxWidget; + ContainerWidget *_container; + StaticTextWidget *_date; + StaticTextWidget *_time; + StaticTextWidget *_playtime; SaveStateList _saveList; String _resultString; @@ -123,7 +123,7 @@ public: virtual void open(); protected: - virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); private: int _targetSlot; StaticTextWidget *_title; @@ -145,7 +145,7 @@ public: virtual void close(); protected: - virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual void handleMouseWheel(int x, int y, int direction); private: virtual int runIntern(); @@ -155,10 +155,10 @@ private: uint _curPage; SaveStateList _saveList; - GUI::ButtonWidget *_nextButton; - GUI::ButtonWidget *_prevButton; + ButtonWidget *_nextButton; + ButtonWidget *_prevButton; - GUI::StaticTextWidget *_pageDisplay; + StaticTextWidget *_pageDisplay; ContainerWidget *_newSaveContainer; int _nextFreeSaveSlot; -- cgit v1.2.3 From f006eddac56fdf4305a3d63914245b8707210725 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 24 Jul 2012 23:32:17 +0200 Subject: GUI: Let SaveLoadChooser::getResultString return a const reference. --- gui/saveload.cpp | 8 +++----- gui/saveload.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'gui') diff --git a/gui/saveload.cpp b/gui/saveload.cpp index 0650be388c..d6a8688ce3 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -103,11 +103,9 @@ int SaveLoadChooser::runModalWithPluginAndTarget(const EnginePlugin *plugin, con return ret; } -Common::String SaveLoadChooser::getResultString() const { - if (_impl) - return _impl->getResultString(); - else - return Common::String(); +const Common::String &SaveLoadChooser::getResultString() const { + assert(_impl); + return _impl->getResultString(); } } // End of namespace GUI diff --git a/gui/saveload.h b/gui/saveload.h index 26a8cd1bad..17fd99a31d 100644 --- a/gui/saveload.h +++ b/gui/saveload.h @@ -52,7 +52,7 @@ public: int runModalWithCurrentTarget(); int runModalWithPluginAndTarget(const EnginePlugin *plugin, const String &target); - Common::String getResultString() const; + const Common::String &getResultString() const; /** * Creates a default save description for the specified slot. Depending -- cgit v1.2.3 From ca225cc7e0affd4bca287def475e34dabe251d8a Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 24 Jul 2012 23:34:35 +0200 Subject: GUI: Strip a trailing whitespace. --- gui/saveload-dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 9f7664b809..f59d67e490 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -604,7 +604,7 @@ void SaveLoadChooserGrid::reflowLayout() { removeWidget(_pageDisplay); if (g_gui.xmlEval()->getVar("Globals.ShowChooserPageDisplay") == 1) { _pageDisplay->init(); - } + } SaveLoadChooserDialog::reflowLayout(); destroyButtons(); -- cgit v1.2.3 From 7d519074053ab0482c1d163a626a9554b52a8783 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 24 Jul 2012 23:46:54 +0200 Subject: GUI: Add possibility to disable the grid based chooser via DISABLE_SAVELOADCHOOSER_GRID. --- gui/saveload-dialog.cpp | 60 +++++++++++++++++++++++++++++++++---------------- gui/saveload-dialog.h | 19 ++++++++++++++++ gui/saveload.cpp | 7 +++++- 3 files changed, 66 insertions(+), 20 deletions(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index f59d67e490..3c793c9e25 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -32,6 +32,7 @@ namespace GUI { +#ifndef DISABLE_SAVELOADCHOOSER_GRID SaveLoadChooserType getRequestedSaveLoadDialog(const MetaEngine &metaEngine) { const Common::String &userConfig = ConfMan.get("gui_saveload_chooser", Common::ConfigManager::kApplicationDomain); if (g_gui.getWidth() >= 640 && g_gui.getHeight() >= 400 @@ -52,19 +53,30 @@ enum { kListSwitchCmd = 'LIST', kGridSwitchCmd = 'GRID' }; +#endif // !DISABLE_SAVELOADCHOOSER_GRID SaveLoadChooserDialog::SaveLoadChooserDialog(const Common::String &dialogName, const bool saveMode) : Dialog(dialogName), _metaEngine(0), _delSupport(false), _metaInfoSupport(false), - _thumbnailSupport(false), _saveDateSupport(false), _playTimeSupport(false), _saveMode(saveMode), - _listButton(0), _gridButton(0) { + _thumbnailSupport(false), _saveDateSupport(false), _playTimeSupport(false), _saveMode(saveMode) +#ifndef DISABLE_SAVELOADCHOOSER_GRID + , _listButton(0), _gridButton(0) +#endif // !DISABLE_SAVELOADCHOOSER_GRID + { +#ifndef DISABLE_SAVELOADCHOOSER_GRID addChooserButtons(); +#endif // !DISABLE_SAVELOADCHOOSER_GRID } SaveLoadChooserDialog::SaveLoadChooserDialog(int x, int y, int w, int h, const bool saveMode) : Dialog(x, y, w, h), _metaEngine(0), _delSupport(false), _metaInfoSupport(false), - _thumbnailSupport(false), _saveDateSupport(false), _playTimeSupport(false), _saveMode(saveMode), - _listButton(0), _gridButton(0) { + _thumbnailSupport(false), _saveDateSupport(false), _playTimeSupport(false), _saveMode(saveMode) +#ifndef DISABLE_SAVELOADCHOOSER_GRID + , _listButton(0), _gridButton(0) +#endif // !DISABLE_SAVELOADCHOOSER_GRID + { +#ifndef DISABLE_SAVELOADCHOOSER_GRID addChooserButtons(); +#endif // !DISABLE_SAVELOADCHOOSER_GRID } void SaveLoadChooserDialog::open() { @@ -88,6 +100,7 @@ int SaveLoadChooserDialog::run(const Common::String &target, const MetaEngine *m } void SaveLoadChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { +#ifndef DISABLE_SAVELOADCHOOSER_GRID switch (cmd) { case kListSwitchCmd: setResult(kSwitchSaveLoadDialog); @@ -108,10 +121,29 @@ void SaveLoadChooserDialog::handleCommand(CommandSender *sender, uint32 cmd, uin default: break; } +#endif // !DISABLE_SAVELOADCHOOSER_GRID return Dialog::handleCommand(sender, cmd, data); } +void SaveLoadChooserDialog::reflowLayout() { +#ifndef DISABLE_SAVELOADCHOOSER_GRID + addChooserButtons(); + + const SaveLoadChooserType currentType = getType(); + const SaveLoadChooserType requestedType = getRequestedSaveLoadDialog(*_metaEngine); + + // Change the dialog type if there is any need for it. + if (requestedType != currentType) { + setResult(kSwitchSaveLoadDialog); + close(); + } +#endif // !DISABLE_SAVELOADCHOOSER_GRID + + Dialog::reflowLayout(); +} + +#ifndef DISABLE_SAVELOADCHOOSER_GRID void SaveLoadChooserDialog::addChooserButtons() { if (_listButton) { removeWidget(_listButton); @@ -131,21 +163,6 @@ void SaveLoadChooserDialog::addChooserButtons() { } } -void SaveLoadChooserDialog::reflowLayout() { - addChooserButtons(); - - const SaveLoadChooserType currentType = getType(); - const SaveLoadChooserType requestedType = getRequestedSaveLoadDialog(*_metaEngine); - - // Change the dialog type if there is any need for it. - if (requestedType != currentType) { - setResult(kSwitchSaveLoadDialog); - close(); - } - - Dialog::reflowLayout(); -} - ButtonWidget *SaveLoadChooserDialog::createSwitchButton(const Common::String &name, const char *desc, const char *tooltip, const char *image, uint32 cmd) { ButtonWidget *button; @@ -160,6 +177,7 @@ ButtonWidget *SaveLoadChooserDialog::createSwitchButton(const Common::String &na return button; } +#endif // !DISABLE_SAVELOADCHOOSER_GRID // SaveLoadChooserSimple implementation @@ -480,6 +498,8 @@ void SaveLoadChooserSimple::updateSaveList() { // SaveLoadChooserGrid implementation +#ifndef DISABLE_SAVELOADCHOOSER_GRID + enum { kNextCmd = 'NEXT', kPrevCmd = 'PREV', @@ -854,4 +874,6 @@ void SavenameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat } } +#endif // !DISABLE_SAVELOADCHOOSER_GRID + } // End of namespace GUI diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index 05c0715fe0..50b7d419b7 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -31,12 +31,22 @@ namespace GUI { #define kSwitchSaveLoadDialog -2 +// TODO: We might want to disable the grid based save/load chooser for more +// platforms, than those which define DISABLE_FANCY_THEMES. But those are +// probably not able to handle the grid chooser anyway, so disabling it +// for them is a good start. +#ifdef DISABLE_FANCY_THEMES +#define DISABLE_SAVELOADCHOOSER_GRID +#endif // DISABLE_FANCY_THEMES + +#ifndef DISABLE_SAVELOADCHOOSER_GRID enum SaveLoadChooserType { kSaveLoadDialogList = 0, kSaveLoadDialogGrid = 1 }; SaveLoadChooserType getRequestedSaveLoadDialog(const MetaEngine &metaEngine); +#endif // !DISABLE_SAVELOADCHOOSER_GRID class SaveLoadChooserDialog : protected Dialog { public: @@ -49,7 +59,9 @@ public: virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); +#ifndef DISABLE_SAVELOADCHOOSER_GRID virtual SaveLoadChooserType getType() const = 0; +#endif // !DISABLE_SAVELOADCHOOSER_GRID int run(const Common::String &target, const MetaEngine *metaEngine); virtual const Common::String &getResultString() const = 0; @@ -66,11 +78,13 @@ protected: bool _playTimeSupport; Common::String _target; +#ifndef DISABLE_SAVELOADCHOOSER_GRID ButtonWidget *_listButton; ButtonWidget *_gridButton; void addChooserButtons(); ButtonWidget *createSwitchButton(const Common::String &name, const char *desc, const char *tooltip, const char *image, uint32 cmd = 0); +#endif // !DISABLE_SAVELOADCHOOSER_GRID }; class SaveLoadChooserSimple : public SaveLoadChooserDialog { @@ -85,7 +99,9 @@ public: virtual void reflowLayout(); +#ifndef DISABLE_SAVELOADCHOOSER_GRID virtual SaveLoadChooserType getType() const { return kSaveLoadDialogList; } +#endif // !DISABLE_SAVELOADCHOOSER_GRID virtual void close(); private: @@ -109,6 +125,7 @@ private: void updateSelection(bool redraw); }; +#ifndef DISABLE_SAVELOADCHOOSER_GRID class EditTextWidget; @@ -186,6 +203,8 @@ private: void updateSaves(); }; +#endif // !DISABLE_SAVELOADCHOOSER_GRID + } // End of namespace GUI #endif diff --git a/gui/saveload.cpp b/gui/saveload.cpp index d6a8688ce3..c2bbcd9bec 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -40,6 +40,7 @@ SaveLoadChooser::~SaveLoadChooser() { } void SaveLoadChooser::selectChooser(const MetaEngine &engine) { +#ifndef DISABLE_SAVELOADCHOOSER_GRID const SaveLoadChooserType requestedType = getRequestedSaveLoadDialog(engine); if (!_impl || _impl->getType() != requestedType) { delete _impl; @@ -51,10 +52,13 @@ void SaveLoadChooser::selectChooser(const MetaEngine &engine) { break; case kSaveLoadDialogList: +#endif // !DISABLE_SAVELOADCHOOSER_GRID _impl = new SaveLoadChooserSimple(_title, _buttonLabel, _saveMode); +#ifndef DISABLE_SAVELOADCHOOSER_GRID break; } } +#endif // !DISABLE_SAVELOADCHOOSER_GRID } Common::String SaveLoadChooser::createDefaultSaveDescription(const int slot) const { @@ -91,10 +95,11 @@ int SaveLoadChooser::runModalWithPluginAndTarget(const EnginePlugin *plugin, con int ret; do { ret = _impl->run(target, &(**plugin)); - +#ifndef DISABLE_SAVELOADCHOOSER_GRID if (ret == kSwitchSaveLoadDialog) { selectChooser(**plugin); } +#endif // !DISABLE_SAVELOADCHOOSER_GRID } while (ret < -1); // Revert to the old active domain -- cgit v1.2.3 From 71daae7bbc03c1d9327f5353b1450f9d0d9774da Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 25 Jul 2012 17:21:36 +0200 Subject: GUI: Use "OK" instead of "Ok" in SavenameDialog. --- gui/saveload-dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 3c793c9e25..c714147488 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -842,7 +842,7 @@ SavenameDialog::SavenameDialog() _title = new StaticTextWidget(this, "SavenameDialog.DescriptionText", Common::String()); new ButtonWidget(this, "SavenameDialog.Cancel", _("Cancel"), 0, kCloseCmd); - new ButtonWidget(this, "SavenameDialog.Ok", _("Ok"), 0, kOKCmd); + new ButtonWidget(this, "SavenameDialog.Ok", _("OK"), 0, kOKCmd); _description = new EditTextWidget(this, "SavenameDialog.Description", Common::String(), 0, 0, kOKCmd); } -- cgit v1.2.3 From b4196e48b16c458ef6564a051495525ff5a282f0 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 30 Jul 2012 21:31:14 +0200 Subject: GRAPHICS: Add a DPI parameter to loadTTFFont. Will be used by WME. --- gui/ThemeEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index e37022f5f1..2fff92c263 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1422,7 +1422,7 @@ const Graphics::Font *ThemeEngine::loadScalableFont(const Common::String &filena for (Common::ArchiveMemberList::const_iterator i = members.begin(), end = members.end(); i != end; ++i) { Common::SeekableReadStream *stream = (*i)->createReadStream(); if (stream) { - font = Graphics::loadTTFFont(*stream, pointsize, false, + font = Graphics::loadTTFFont(*stream, pointsize, 0, false, #ifdef USE_TRANSLATION TransMan.getCharsetMapping() #else -- cgit v1.2.3 From ab3b052c6f16843bda7bd1ded8a210d1192a389f Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sun, 12 Aug 2012 00:19:44 +0100 Subject: GUI: Fix possible un-initialised variable usage in SaveLoadChooser. This was reported by valgrind, while looking at a different issue. --- gui/saveload.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'gui') diff --git a/gui/saveload.cpp b/gui/saveload.cpp index 67d871e133..ac315cb6f6 100644 --- a/gui/saveload.cpp +++ b/gui/saveload.cpp @@ -44,6 +44,7 @@ enum { SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode) : Dialog("SaveLoadChooser"), _delSupport(0), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0) { _delSupport = _metaInfoSupport = _thumbnailSupport = _saveDateSupport = _playTimeSupport = false; + _fillR = _fillG = _fillB = 0; _backgroundType = ThemeEngine::kDialogBackgroundSpecial; -- cgit v1.2.3 From e7cd238809520c9f3ee7ee820b3a106b7f72c2e2 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 12 Aug 2012 14:56:20 +0200 Subject: GUI: Remove left-over code from theme based fill color in thumbnail display. --- gui/saveload-dialog.cpp | 9 +++------ gui/saveload-dialog.h | 2 -- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 0b36ff5d59..8e214bce90 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -188,8 +188,6 @@ enum { SaveLoadChooserSimple::SaveLoadChooserSimple(const String &title, const String &buttonLabel, bool saveMode) : SaveLoadChooserDialog("SaveLoadChooser", saveMode), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0) { - _fillR = _fillG = _fillB = 0; - _backgroundType = ThemeEngine::kDialogBackgroundSpecial; new StaticTextWidget(this, "SaveLoadChooser.Title", title); @@ -327,9 +325,6 @@ void SaveLoadChooserSimple::reflowLayout() { _playtime->setVisible(_playTimeSupport); - _fillR = 0; - _fillG = 0; - _fillB = 0; updateSelection(false); } else { _container->setVisible(false); @@ -349,7 +344,9 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) { bool isWriteProtected = false; bool startEditMode = _list->isEditable(); - _gfxWidget->setGfx(-1, -1, _fillR, _fillG, _fillB); + // We used to support letting the themes specify the fill color with our + // initial theme based GUI. But this support was dropped. + _gfxWidget->setGfx(-1, -1, 0, 0, 0); _date->setLabel(_("No date saved")); _time->setLabel(_("No time saved")); _playtime->setLabel(_("No playtime saved")); diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index 50b7d419b7..9d0350d69d 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -119,8 +119,6 @@ private: SaveStateList _saveList; String _resultString; - uint8 _fillR, _fillG, _fillB; - void updateSaveList(); void updateSelection(bool redraw); }; -- cgit v1.2.3 From 7ea7a8ae7eeca2b7d6ddcc413012158d798a836e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 12 Aug 2012 14:58:16 +0200 Subject: I18N: Update POTFILES and rebuild the translations. --- gui/themes/translations.dat | Bin 342397 -> 342397 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'gui') diff --git a/gui/themes/translations.dat b/gui/themes/translations.dat index 4b35fdb9a8..cabad0c0c4 100644 Binary files a/gui/themes/translations.dat and b/gui/themes/translations.dat differ -- cgit v1.2.3 From 9ba145419faa46b85baf5982f0c62ab76268b0af Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 12 Aug 2012 15:16:27 +0200 Subject: GUI: Mark parts of the grid based chooser layout code as HACK. --- gui/saveload-dialog.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 8e214bce90..d1a66dc28a 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -620,6 +620,8 @@ void SaveLoadChooserGrid::open() { } void SaveLoadChooserGrid::reflowLayout() { + // HACK: The page display is not available in low resolution layout. We + // remove and readd the widget here to avoid our GUI from erroring out. removeWidget(_pageDisplay); if (g_gui.xmlEval()->getVar("Globals.ShowChooserPageDisplay") == 1) { _pageDisplay->init(); @@ -628,6 +630,8 @@ void SaveLoadChooserGrid::reflowLayout() { SaveLoadChooserDialog::reflowLayout(); destroyButtons(); + // HACK: The whole code below really works around the fact, that we have + // no easy way to dynamically layout widgets. const uint16 availableWidth = getWidth() - 20; uint16 availableHeight; -- cgit v1.2.3 From da790e112ca1a1de5730713cad1871917d52c781 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 12 Aug 2012 15:18:09 +0200 Subject: GUI: Create the builtin theme from scummclassic again. The old builtin one actually was based on a unpublished version, which failed with the current code. Oops. --- gui/themes/default.inc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/themes/default.inc b/gui/themes/default.inc index bfd78db3ae..7f565eb05d 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -1399,7 +1399,6 @@ " " -" " " " @@ -2379,7 +2378,7 @@ " " -" " +" " " " -- cgit v1.2.3 From fee19db7eedb16d7e7d62429f6c0eb4770bc07c3 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 12 Aug 2012 19:38:57 +0200 Subject: GUI: Make normal disabled color of the modern theme darker. This should fix bug #3395057 "GUI: Font-Background Color Contrast Problem in Modern Theme". At the very least it will improve the contrast. --- gui/themes/scummclassic.zip | Bin 95181 -> 95180 bytes gui/themes/scummmodern.zip | Bin 1453476 -> 1453485 bytes gui/themes/scummmodern/scummmodern_gfx.stx | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip index 468f4b1594..62eae0cd43 100644 Binary files a/gui/themes/scummclassic.zip and b/gui/themes/scummclassic.zip differ diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip index 34a1db9c06..38352bcc2f 100644 Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ diff --git a/gui/themes/scummmodern/scummmodern_gfx.stx b/gui/themes/scummmodern/scummmodern_gfx.stx index 4703683bc3..4d449f50ec 100644 --- a/gui/themes/scummmodern/scummmodern_gfx.stx +++ b/gui/themes/scummmodern/scummmodern_gfx.stx @@ -155,7 +155,7 @@ /> 345659 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'gui') diff --git a/gui/themes/translations.dat b/gui/themes/translations.dat index cabad0c0c4..d81c1a0475 100644 Binary files a/gui/themes/translations.dat and b/gui/themes/translations.dat differ -- cgit v1.2.3 From 333a05c5b1643c3021929b83eca0686a559f1ceb Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Mon, 27 Aug 2012 11:42:29 +0100 Subject: CREDITS: Add credits for Galician translation --- gui/credits.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index 34c6f21026..fdde2da821 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -476,6 +476,9 @@ static const char *credits[] = { "C1""French", "C0""Thierry Crozat", "", +"C1""Galician", +"C0""Santiago G. Sanz", +"", "C1""German", "C0""Simon Sawatzki", "C0""Lothar Serra Mari", -- cgit v1.2.3 From b8e10e478572f535a845de37fc005a54375e6bcd Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Mon, 27 Aug 2012 11:42:50 +0100 Subject: I18N: Update translation data file --- gui/themes/translations.dat | Bin 345659 -> 367742 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'gui') diff --git a/gui/themes/translations.dat b/gui/themes/translations.dat index d81c1a0475..613afc0e4a 100644 Binary files a/gui/themes/translations.dat and b/gui/themes/translations.dat differ -- cgit v1.2.3 From e96249a105b36f79656e4b75cd17fd88a9b69ba9 Mon Sep 17 00:00:00 2001 From: Jordi Vilalta Prat Date: Mon, 27 Aug 2012 15:57:29 +0200 Subject: I18N: Update translation data file. --- gui/themes/translations.dat | Bin 367742 -> 370908 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'gui') diff --git a/gui/themes/translations.dat b/gui/themes/translations.dat index 613afc0e4a..1c3abf84a8 100644 Binary files a/gui/themes/translations.dat and b/gui/themes/translations.dat differ -- cgit v1.2.3 From a1e56adad8eb8ed4c8de5850fb2c81af9adb9585 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 28 Aug 2012 02:25:14 +0200 Subject: GUI: Use in-place Surface conversion in widget code. --- gui/widget.cpp | 64 +++++++++++++++++++++++++--------------------------------- gui/widget.h | 4 ++-- 2 files changed, 30 insertions(+), 38 deletions(-) (limited to 'gui') diff --git a/gui/widget.cpp b/gui/widget.cpp index 9046bcc9c1..c5ca628576 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -376,7 +376,7 @@ void ButtonWidget::wantTickle(bool tickled) { PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd, uint8 hotkey) : ButtonWidget(boss, x, y, w, h, "", tooltip, cmd, hotkey), - _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { + _gfx(), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; @@ -384,18 +384,17 @@ PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, co PicButtonWidget::PicButtonWidget(GuiObject *boss, const Common::String &name, const char *tooltip, uint32 cmd, uint8 hotkey) : ButtonWidget(boss, name, "", tooltip, cmd, hotkey), - _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { + _gfx(), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); _type = kButtonWidget; } PicButtonWidget::~PicButtonWidget() { - _gfx->free(); - delete _gfx; + _gfx.free(); } void PicButtonWidget::setGfx(const Graphics::Surface *gfx) { - _gfx->free(); + _gfx.free(); if (!gfx || !gfx->pixels) return; @@ -411,7 +410,7 @@ void PicButtonWidget::setGfx(const Graphics::Surface *gfx) { return; } - _gfx->copyFrom(*gfx); + _gfx.copyFrom(*gfx); } void PicButtonWidget::setGfx(int w, int h, int r, int g, int b) { @@ -422,29 +421,26 @@ void PicButtonWidget::setGfx(int w, int h, int r, int g, int b) { const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); - _gfx->free(); - _gfx->create(w, h, requiredFormat); - _gfx->fillRect(Common::Rect(0, 0, w, h), _gfx->format.RGBToColor(r, g, b)); + _gfx.free(); + _gfx.create(w, h, requiredFormat); + _gfx.fillRect(Common::Rect(0, 0, w, h), _gfx.format.RGBToColor(r, g, b)); } void PicButtonWidget::drawWidget() { g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), "", _state, getFlags()); - if (_gfx->pixels) { + if (_gfx.pixels) { // Check whether the set up surface needs to be converted to the GUI // color format. const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); - if (_gfx->format != requiredFormat) { - Graphics::Surface *converted = _gfx->convertTo(requiredFormat); - _gfx->free(); - delete _gfx; - _gfx = converted; + if (_gfx.format != requiredFormat) { + _gfx.convertToInPlace(requiredFormat); } - const int x = _x + (_w - _gfx->w) / 2; - const int y = _y + (_h - _gfx->h) / 2; + const int x = _x + (_w - _gfx.w) / 2; + const int y = _y + (_h - _gfx.h) / 2; - g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx->w, y + _gfx->h), *_gfx, _state, _alpha, _transparency); + g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), _gfx, _state, _alpha, _transparency); } } @@ -632,24 +628,23 @@ int SliderWidget::posToValue(int pos) { #pragma mark - GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip) - : Widget(boss, x, y, w, h, tooltip), _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { + : Widget(boss, x, y, w, h, tooltip), _gfx(), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG); _type = kGraphicsWidget; } GraphicsWidget::GraphicsWidget(GuiObject *boss, const Common::String &name, const char *tooltip) - : Widget(boss, name, tooltip), _gfx(new Graphics::Surface()), _alpha(256), _transparency(false) { + : Widget(boss, name, tooltip), _gfx(), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG); _type = kGraphicsWidget; } GraphicsWidget::~GraphicsWidget() { - _gfx->free(); - delete _gfx; + _gfx.free(); } void GraphicsWidget::setGfx(const Graphics::Surface *gfx) { - _gfx->free(); + _gfx.free(); if (!gfx || !gfx->pixels) return; @@ -664,7 +659,7 @@ void GraphicsWidget::setGfx(const Graphics::Surface *gfx) { return; } - _gfx->copyFrom(*gfx); + _gfx.copyFrom(*gfx); } void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { @@ -675,27 +670,24 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) { const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); - _gfx->free(); - _gfx->create(w, h, requiredFormat); - _gfx->fillRect(Common::Rect(0, 0, w, h), _gfx->format.RGBToColor(r, g, b)); + _gfx.free(); + _gfx.create(w, h, requiredFormat); + _gfx.fillRect(Common::Rect(0, 0, w, h), _gfx.format.RGBToColor(r, g, b)); } void GraphicsWidget::drawWidget() { - if (_gfx->pixels) { + if (_gfx.pixels) { // Check whether the set up surface needs to be converted to the GUI // color format. const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat(); - if (_gfx->format != requiredFormat) { - Graphics::Surface *converted = _gfx->convertTo(requiredFormat); - _gfx->free(); - delete _gfx; - _gfx = converted; + if (_gfx.format != requiredFormat) { + _gfx.convertToInPlace(requiredFormat); } - const int x = _x + (_w - _gfx->w) / 2; - const int y = _y + (_h - _gfx->h) / 2; + const int x = _x + (_w - _gfx.w) / 2; + const int y = _y + (_h - _gfx.h) / 2; - g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx->w, y + _gfx->h), *_gfx, _state, _alpha, _transparency); + g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), _gfx, _state, _alpha, _transparency); } } diff --git a/gui/widget.h b/gui/widget.h index 6f710f302f..e3f712564f 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -230,7 +230,7 @@ public: protected: void drawWidget(); - Graphics::Surface *_gfx; + Graphics::Surface _gfx; int _alpha; bool _transparency; }; @@ -358,7 +358,7 @@ public: protected: void drawWidget(); - Graphics::Surface *_gfx; + Graphics::Surface _gfx; int _alpha; bool _transparency; }; -- cgit v1.2.3 From f607112da03d56329cfd0a62e47db6f4b9e145e1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 6 Sep 2012 16:47:33 +0200 Subject: CREDITS: Add myself to credits for the Wintermute-engine --- gui/credits.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index fdde2da821..f971d06f36 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -249,6 +249,9 @@ static const char *credits[] = { "C0""Gregory Montoir", "C2""(retired)", "", +"C1""Wintermute", +"C0""Einar Johan T. S\370m\345en", +"", "", "C1""Backend Teams", "C1""Android", -- cgit v1.2.3 From 3513f3870de3d99fafd7625120e5bf68436dd15d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 6 Sep 2012 16:53:01 +0200 Subject: CREDITS: Thank Jan Nedoma (Mnemonic) for sources/assistance with WME. --- gui/credits.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index f971d06f36..e61cc1053f 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -722,5 +722,7 @@ static const char *credits[] = { "C0""", "C0""Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon for providing full source code for Soltys and letting us to redistribute the game.", "C0""", +"C0""Jan Nedoma for providing the sources to the Wintermute-engine, and for providing support while porting the engine to ScummVM", +"C0""", "", }; -- cgit v1.2.3 From 1ea69b53cec1ed1dffab05a20d8df6bae074c2bb Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 6 Sep 2012 17:19:22 +0200 Subject: CREDITS: Minor tweaks --- gui/credits.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index e61cc1053f..124cf42062 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -720,9 +720,9 @@ static const char *credits[] = { "C0""", "C0""Neil Dodwell and David Dew from Creative Reality for providing the source of Dreamweb and for their tremendous support.", "C0""", -"C0""Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon for providing full source code for Soltys and letting us to redistribute the game.", +"C0""Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon for providing full source code for Soltys and letting us redistribute the game.", "C0""", -"C0""Jan Nedoma for providing the sources to the Wintermute-engine, and for providing support while porting the engine to ScummVM", +"C0""Jan Nedoma for providing the sources to the Wintermute-engine, and for his support while porting the engine to ScummVM.", "C0""", "", }; -- cgit v1.2.3 From 952a41abe2911500fe9c3d2663b5cac9b4f9b3dd Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 6 Sep 2012 17:45:44 +0200 Subject: CREDITS: Reshuffle special thanks --- gui/credits.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index 124cf42062..35b5dcf1c2 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -682,6 +682,8 @@ static const char *credits[] = { "C2""For generously providing hosting for our buildbot, SVN repository, planet and doxygen sites as well as tons of HD space", "C0""DOSBox Team", "C2""For their awesome OPL2 and OPL3 emulator", +"C0""Yusuke Kamiyamane", +"C2""For contributing some GUI icons ", "C0""Till Kresslein", "C2""For design of modern ScummVM GUI", "C0""Jezar", @@ -698,8 +700,6 @@ static const char *credits[] = { "C2""For additional work on the original MT-32 emulator", "C0""James Woodcock", "C2""Soundtrack enhancements", -"C0""Some icons by Yusuke Kamiyamane", -"C0""", "C0""Tony Warriner and everyone at Revolution Software Ltd. for sharing with us the source of some of their brilliant games, allowing us to release Beneath a Steel Sky as freeware... and generally being supportive above and beyond the call of duty.", "C0""", "C0""John Passfield and Steve Stamatiadis for sharing the source of their classic title, Flight of the Amazon Queen and also being incredibly supportive.", -- cgit v1.2.3 From be9c9e59b75a5a341eec0bdb6812ae3e3c4c338b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 25 Sep 2012 23:07:43 +0200 Subject: TONY: Add credits for Tony --- gui/credits.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index 43b9292ac5..7164e3e2dc 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -237,6 +237,11 @@ static const char *credits[] = { "C0""Filippos Karapetis", "C0""Joost Peters", "", +"C1""Tony", +"C0""Arnaud Boutonn\351", +"C0""Paul Gilbert", +"C0""Alyssa Milburn", +"", "C1""Toon", "C0""Sylvain Dupont", "", -- cgit v1.2.3 From 66fb399227acd92db3dc8d9ee193a41609cf3d39 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 26 Sep 2012 02:11:39 +0200 Subject: GUI: Save/restore the last used page in the grid save/load dialog. This allows opening the dialog on (nearly) the same page again as when it was closed. Sadly due to the different number of entries in the save and load version this is not always exactly the same page as before. Same goes for resolution changes. Thanks to wjp for suggesting this. --- gui/saveload-dialog.cpp | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 850dfcc78f..63d8d25fe0 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -590,10 +590,21 @@ void SaveLoadChooserGrid::handleMouseWheel(int x, int y, int direction) { void SaveLoadChooserGrid::open() { SaveLoadChooserDialog::open(); - _curPage = 0; _saveList = _metaEngine->listSaves(_target.c_str()); _resultString.clear(); + // Load information to restore the last page the user had open. + assert(_entriesPerPage != 0); + const uint lastPos = ConfMan.getInt("gui_saveload_last_pos"); + const uint listSize = _saveList.size(); + if (lastPos < listSize) { + _curPage = lastPos / _entriesPerPage; + } else if (listSize) { + _curPage = (_saveList.size() - 1) / _entriesPerPage; + } else { + _curPage = 0; + } + // Determine the next free save slot for save mode if (_saveMode) { int lastSlot = -1; @@ -718,6 +729,24 @@ void SaveLoadChooserGrid::reflowLayout() { } void SaveLoadChooserGrid::close() { + // Save the current page. + const int result = getResult(); + if (result >= 0 && result != _nextFreeSaveSlot) { + // If the user selected a slot we use that one. We ignore new slots + // here, since otherwise the dialog would reset to page 0 when the + // user cancels the savename dialog. + ConfMan.setInt("gui_saveload_last_pos", result); + } else { + // Otherwise save the first entry on the current page. + // This is less precise than the solution above, since the number of + // entries shown differs between save and load version of the dialog, + // thus it might wrap to a different page than expected. + // Similar things happen on resolution changes. + // TODO: Should we ignore this here? Is the user likely to be + // interested in having this page restored when he canceled? + ConfMan.setInt("gui_saveload_last_pos", _curPage * _entriesPerPage); + } + SaveLoadChooserDialog::close(); hideButtons(); } @@ -737,6 +766,12 @@ int SaveLoadChooserGrid::runIntern() { slot = runModal(); } while (_saveMode && slot >= 0 && !selectDescription()); + // Special case for new save games. We need to handle this here, since + // we cannot handle it in close() without problems. + if (slot == _nextFreeSaveSlot) { + ConfMan.setInt("gui_saveload_last_pos", slot); + } + return slot; } -- cgit v1.2.3 From bc1743b225597715164e3d2701b2c4b5731415a4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 26 Sep 2012 02:45:34 +0200 Subject: GUI: Save/restore last scroll position in the list save/load dialog. This should give a better user experience, since the user will not have to scroll back to where he was when he used the dialog last. Thanks to wjp for suggesting this. --- gui/saveload-dialog.cpp | 21 +++++++++++++++++++++ gui/saveload-dialog.h | 1 + gui/widgets/list.h | 1 + 3 files changed, 23 insertions(+) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 63d8d25fe0..c8f7556e66 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -422,7 +422,28 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) { } } +void SaveLoadChooserSimple::open() { + SaveLoadChooserDialog::open(); + + // Scroll the list to the last used entry. + _list->scrollTo(ConfMan.getInt("gui_saveload_last_pos")); +} + void SaveLoadChooserSimple::close() { + // Save the current scroll position/used entry. + const int result = getResult(); + if (result >= 0) { + ConfMan.setInt("gui_saveload_last_pos", result); + } else { + // Use the current scroll position here. + // TODO: This means we canceled the dialog (or switch to the grid). Do + // we want to save this position here? Does the user want that? + // TODO: Do we want to save the current scroll position or the + // currently selected item here? The scroll position is what the user + // currently sees and seems to make more sense. + ConfMan.setInt("gui_saveload_last_pos", _list->getCurrentScrollPos()); + } + _metaEngine = 0; _target.clear(); _saveList.clear(); diff --git a/gui/saveload-dialog.h b/gui/saveload-dialog.h index 9d0350d69d..6f7d95f73f 100644 --- a/gui/saveload-dialog.h +++ b/gui/saveload-dialog.h @@ -103,6 +103,7 @@ public: virtual SaveLoadChooserType getType() const { return kSaveLoadDialogList; } #endif // !DISABLE_SAVELOADCHOOSER_GRID + virtual void open(); virtual void close(); private: virtual int runIntern(); diff --git a/gui/widgets/list.h b/gui/widgets/list.h index 41fae37a71..47613b79f3 100644 --- a/gui/widgets/list.h +++ b/gui/widgets/list.h @@ -105,6 +105,7 @@ public: void scrollTo(int item); void scrollToEnd(); + int getCurrentScrollPos() const { return _currentPos; } void enableQuickSelect(bool enable) { _quickSelect = enable; } String getQuickSelectString() const { return _quickSelectStr; } -- cgit v1.2.3 From 40fb004509620323a466ee1f49addc773094e21f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 26 Sep 2012 02:49:24 +0200 Subject: GUI: Fix maximum page number calculation in grid chooser. This avoids a off by one error in some cases. --- gui/saveload-dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index c8f7556e66..cd0f96d60c 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -882,7 +882,7 @@ void SaveLoadChooserGrid::updateSaves() { } } - const uint numPages = (_entriesPerPage != 0) ? (_saveList.size() / _entriesPerPage + 1) : 1; + const uint numPages = (_entriesPerPage != 0 && !_saveList.empty()) ? ((_saveList.size() + _entriesPerPage - 1) / _entriesPerPage) : 1; _pageDisplay->setLabel(Common::String::format("%u/%u", _curPage + 1, numPages)); if (_curPage > 0) -- cgit v1.2.3 From 89abab97e3124fa25eb4c7d3e8b38501747a8d17 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 26 Sep 2012 04:17:31 +0200 Subject: JANITORIAL: Remove trailing whitespaces. Powered by: git ls-files "*.cpp" "*.h" "*.m" "*.mm" | xargs sed -i -e 's/[ \t]*$//' --- gui/ThemeParser.cpp | 4 ++-- gui/ThemeParser.h | 2 +- gui/launcher.cpp | 2 +- gui/options.cpp | 2 +- gui/predictivedialog.cpp | 18 +++++++++--------- gui/saveload-dialog.cpp | 4 ++-- gui/widget.cpp | 2 +- gui/widgets/editable.h | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) (limited to 'gui') diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp index 9a85399ed1..8285aff7ca 100644 --- a/gui/ThemeParser.cpp +++ b/gui/ThemeParser.cpp @@ -548,11 +548,11 @@ bool ThemeParser::parseDrawStep(ParserNode *stepNode, Graphics::DrawStep *drawst else return parserError("'" + stepNode->values["fill"] + "' is not a valid fill mode for a shape."); } - + if (stepNode->values.contains("padding")) { val = stepNode->values["padding"]; int pr, pt, pl, pb; - if (parseIntegerKey(val, 4, &pl, &pt, &pr, &pb)) + if (parseIntegerKey(val, 4, &pl, &pt, &pr, &pb)) drawstep->padding.left = pl, drawstep->padding.top = pt, drawstep->padding.right = pr, diff --git a/gui/ThemeParser.h b/gui/ThemeParser.h index 82f774b803..360e3da009 100644 --- a/gui/ThemeParser.h +++ b/gui/ThemeParser.h @@ -139,7 +139,7 @@ protected: XML_PROP(height, false) XML_PROP(xpos, false) XML_PROP(ypos, false) - XML_PROP(padding, false) + XML_PROP(padding, false) XML_PROP(orientation, false) XML_PROP(file, false) KEY_END() diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 26fafa5279..0f4867ced5 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -166,7 +166,7 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc) } else { warning("Plugin for target \"%s\" not found! Game specific settings might be missing", domain.c_str()); } - + // GAME: Path to game data (r/o), extra data (r/o), and save data (r/w) String gamePath(ConfMan.get("path", _domain)); String extraPath(ConfMan.get("extrapath", _domain)); diff --git a/gui/options.cpp b/gui/options.cpp index 4fc37c93da..4868f1876d 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -992,7 +992,7 @@ void OptionsDialog::addEngineControls(GuiObject *boss, const Common::String &pre ExtraGuiOptions::const_iterator iter; for (iter = engineOptions.begin(); iter != engineOptions.end(); ++iter, ++i) { Common::String id = Common::String::format("%d", i); - _engineCheckboxes.push_back(new CheckboxWidget(boss, + _engineCheckboxes.push_back(new CheckboxWidget(boss, prefix + "customOption" + id + "Checkbox", _(iter->label), _(iter->tooltip))); } } diff --git a/gui/predictivedialog.cpp b/gui/predictivedialog.cpp index b827d49416..ed18847a40 100644 --- a/gui/predictivedialog.cpp +++ b/gui/predictivedialog.cpp @@ -71,7 +71,7 @@ PredictiveDialog::PredictiveDialog() : Dialog("Predictive") { _btns = (ButtonWidget **)calloc(1, sizeof(ButtonWidget *) * 16); - _btns[kCancelAct] = new ButtonWidget(this, "Predictive.Cancel", _("Cancel") , 0, kCancelCmd); + _btns[kCancelAct] = new ButtonWidget(this, "Predictive.Cancel", _("Cancel") , 0, kCancelCmd); _btns[kOkAct] = new ButtonWidget(this, "Predictive.OK", _("Ok") , 0, kOkCmd); _btns[kBtn1Act] = new ButtonWidget(this, "Predictive.Button1", "1 `-.&" , 0, kBut1Cmd); _btns[kBtn2Act] = new ButtonWidget(this, "Predictive.Button2", "2 abc" , 0, kBut2Cmd); @@ -84,10 +84,10 @@ PredictiveDialog::PredictiveDialog() : Dialog("Predictive") { _btns[kBtn9Act] = new ButtonWidget(this, "Predictive.Button9", "9 wxyz" , 0, kBut9Cmd); _btns[kBtn0Act] = new ButtonWidget(this, "Predictive.Button0", "0" , 0, kBut0Cmd); // I18N: You must leave "#" as is, only word 'next' is translatable - _btns[kNextAct] = new ButtonWidget(this, "Predictive.Next", _("# next") , 0, kNextCmd); + _btns[kNextAct] = new ButtonWidget(this, "Predictive.Next", _("# next") , 0, kNextCmd); _btns[kAddAct] = new ButtonWidget(this, "Predictive.Add", _("add") , 0, kAddCmd); _btns[kAddAct]->setEnabled(false); - + #ifndef DISABLE_FANCY_THEMES _btns[kDelAct] = new PicButtonWidget(this, "Predictive.Delete", _("Delete char"), kDelCmd); ((PicButtonWidget *)_btns[kDelAct])->useThemeTransparency(true); @@ -214,7 +214,7 @@ void PredictiveDialog::handleKeyDown(Common::KeyState state) { _navigationwithkeys = true; if (_lastbutton == kBtn1Act || _lastbutton == kBtn4Act || _lastbutton == kBtn7Act) _currBtn = ButtonId(_lastbutton + 2); - else if (_lastbutton == kDelAct) + else if (_lastbutton == kDelAct) _currBtn = kBtn1Act; else if (_lastbutton == kModeAct) _currBtn = kNextAct; @@ -227,7 +227,7 @@ void PredictiveDialog::handleKeyDown(Common::KeyState state) { else _currBtn = ButtonId(_lastbutton - 1); - + if (_mode != kModeAbc && _lastbutton == kCancelAct) _currBtn = kOkAct; @@ -237,7 +237,7 @@ void PredictiveDialog::handleKeyDown(Common::KeyState state) { _navigationwithkeys = true; if (_lastbutton == kBtn3Act || _lastbutton == kBtn6Act || _lastbutton == kBtn9Act || _lastbutton == kOkAct) _currBtn = ButtonId(_lastbutton - 2); - else if (_lastbutton == kDelAct) + else if (_lastbutton == kDelAct) _currBtn = kBtn3Act; else if (_lastbutton == kBtn0Act) _currBtn = kNextAct; @@ -249,7 +249,7 @@ void PredictiveDialog::handleKeyDown(Common::KeyState state) { _currBtn = kAddAct; else _currBtn = ButtonId(_lastbutton + 1); - + if (_mode != kModeAbc && _lastbutton == kOkAct) _currBtn = kCancelAct; _needRefresh = true; @@ -260,7 +260,7 @@ void PredictiveDialog::handleKeyDown(Common::KeyState state) { _currBtn = kDelAct; else if (_lastbutton == kDelAct) _currBtn = kOkAct; - else if (_lastbutton == kModeAct) + else if (_lastbutton == kModeAct) _currBtn = kBtn7Act; else if (_lastbutton == kBtn0Act) _currBtn = kBtn8Act; @@ -286,7 +286,7 @@ void PredictiveDialog::handleKeyDown(Common::KeyState state) { _currBtn = kBtn0Act; else if (_lastbutton == kBtn9Act) _currBtn = kNextAct; - else if (_lastbutton == kModeAct) + else if (_lastbutton == kModeAct) _currBtn = kAddAct; else if (_lastbutton == kBtn0Act) _currBtn = kCancelAct; diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index cd0f96d60c..be6cefda26 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -735,7 +735,7 @@ void SaveLoadChooserGrid::reflowLayout() { if (!_saveMode) { buttonCmd += 1; } - + PicButtonWidget *button = new PicButtonWidget(container, dstX, dstY, buttonWidth, buttonHeight, 0, buttonCmd); dstY += buttonHeight; @@ -788,7 +788,7 @@ int SaveLoadChooserGrid::runIntern() { } while (_saveMode && slot >= 0 && !selectDescription()); // Special case for new save games. We need to handle this here, since - // we cannot handle it in close() without problems. + // we cannot handle it in close() without problems. if (slot == _nextFreeSaveSlot) { ConfMan.setInt("gui_saveload_last_pos", slot); } diff --git a/gui/widget.cpp b/gui/widget.cpp index 9046bcc9c1..270cdc56de 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -366,7 +366,7 @@ void ButtonWidget::startAnimatePressedState() { } void ButtonWidget::wantTickle(bool tickled) { - if (tickled) + if (tickled) ((GUI::Dialog *)_boss)->setTickleWidget(this); else ((GUI::Dialog *)_boss)->unSetTickleWidget(); diff --git a/gui/widgets/editable.h b/gui/widgets/editable.h index 7e453c1204..4a18d5e689 100644 --- a/gui/widgets/editable.h +++ b/gui/widgets/editable.h @@ -77,10 +77,10 @@ public: protected: virtual void startEditMode() = 0; virtual void endEditMode() = 0; - virtual void abortEditMode() = 0; + virtual void abortEditMode() = 0; virtual Common::Rect getEditRect() const = 0; virtual int getCaretOffset() const; - void drawCaret(bool erase); + void drawCaret(bool erase); bool adjustOffset(); void makeCaretVisible(); -- cgit v1.2.3 From 9942b5ab600f6b71b5d10921d11bf761f5eef298 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 26 Sep 2012 16:10:35 +0200 Subject: GUI: Support for page restoring for non-continuous save lists in the grid chooser. --- gui/saveload-dialog.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index be6cefda26..df8dda7470 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -618,14 +618,22 @@ void SaveLoadChooserGrid::open() { assert(_entriesPerPage != 0); const uint lastPos = ConfMan.getInt("gui_saveload_last_pos"); const uint listSize = _saveList.size(); - if (lastPos < listSize) { - _curPage = lastPos / _entriesPerPage; - } else if (listSize) { - _curPage = (_saveList.size() - 1) / _entriesPerPage; - } else { - _curPage = 0; + uint bestMatch = 0; + uint diff = 0xFFFFFFFF; + + // We look for the nearest available slot, since a slot might be missing + // due to the user deleting it via the list based chooser, by deleting + // it by hand, etc. + for (uint i = 0; i < listSize; ++i) { + uint curDiff = ABS(_saveList[i].getSaveSlot() - (int)lastPos); + if (curDiff < diff) { + diff = curDiff; + bestMatch = i; + } } + _curPage = bestMatch / _entriesPerPage; + // Determine the next free save slot for save mode if (_saveMode) { int lastSlot = -1; @@ -765,7 +773,7 @@ void SaveLoadChooserGrid::close() { // Similar things happen on resolution changes. // TODO: Should we ignore this here? Is the user likely to be // interested in having this page restored when he canceled? - ConfMan.setInt("gui_saveload_last_pos", _curPage * _entriesPerPage); + ConfMan.setInt("gui_saveload_last_pos", !_saveList.empty() ? _saveList[_curPage * _entriesPerPage].getSaveSlot() : 0); } SaveLoadChooserDialog::close(); -- cgit v1.2.3 From 53a53294af1eb5cb0bc70e5c4eb7964637827709 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Mon, 8 Oct 2012 20:30:24 +0100 Subject: CREDITS: Mark Lothar Serra Mari as retired --- gui/credits.h | 1 + 1 file changed, 1 insertion(+) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index 7164e3e2dc..37c5a7bd95 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -493,6 +493,7 @@ static const char *credits[] = { "C1""German", "C0""Simon Sawatzki", "C0""Lothar Serra Mari", +"C2""(retired)", "", "C1""Hungarian", "C0""Alex Bevilacqua", -- cgit v1.2.3