[Scummvm-cvs-logs] SF.net SVN: scummvm:[34918] scummvm/trunk
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Thu Nov 6 21:26:19 CET 2008
Revision: 34918
http://scummvm.svn.sourceforge.net/scummvm/?rev=34918&view=rev
Author: thebluegr
Date: 2008-11-06 20:26:19 +0000 (Thu, 06 Nov 2008)
Log Message:
-----------
Added some WIP code for the GMM save dialog (still not working correctly)
Modified Paths:
--------------
scummvm/trunk/engines/dialogs.cpp
scummvm/trunk/engines/dialogs.h
scummvm/trunk/gui/launcher.cpp
scummvm/trunk/gui/launcher.h
Modified: scummvm/trunk/engines/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/dialogs.cpp 2008-11-06 19:03:11 UTC (rev 34917)
+++ scummvm/trunk/engines/dialogs.cpp 2008-11-06 20:26:19 UTC (rev 34918)
@@ -118,13 +118,15 @@
_aboutDialog = new GUI::AboutDialog();
_optionsDialog = new ConfigDialog();
_loadDialog = new GUI::SaveLoadChooser("Load game:", "Load");
+ _saveDialog = new GUI::SaveLoadChooser("Save game:", "Save");
+ _saveDialog->setSaveMode(true);
}
MainMenuDialog::~MainMenuDialog() {
delete _aboutDialog;
delete _optionsDialog;
delete _loadDialog;
- //delete _saveDialog;
+ delete _saveDialog;
}
void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
@@ -154,16 +156,26 @@
break;
case kSaveCmd:
/*
+ {
Common::String gameId = ConfMan.get("gameid");
const EnginePlugin *plugin = 0;
EngineMan.findGame(gameId, &plugin);
int slot = _saveDialog->runModal(plugin, ConfMan.getActiveDomainName());
- Common::String desc = ... get desired description from _saveDialog ...
if (slot >= 0) {
- _engine->saveGameState(slot, desc.c_str());
+ Common::String result(_saveDialog->getResultString());
+ char *desc;
+ if (result.empty()) {
+ // If the user was lazy and entered no save name, come up with a default name.
+ desc = new char[20];
+ sprintf(desc, "Save %d", slot + 1);
+ } else {
+ desc = (char*)result.c_str();
+ }
+
+ _engine->saveGameState(slot, desc);
close();
}
Modified: scummvm/trunk/engines/dialogs.h
===================================================================
--- scummvm/trunk/engines/dialogs.h 2008-11-06 19:03:11 UTC (rev 34917)
+++ scummvm/trunk/engines/dialogs.h 2008-11-06 20:26:19 UTC (rev 34918)
@@ -59,7 +59,7 @@
GUI::Dialog *_aboutDialog;
GUI::Dialog *_optionsDialog;
GUI::SaveLoadChooser *_loadDialog;
-
+ GUI::SaveLoadChooser *_saveDialog;
};
class ConfigDialog : public GUI::OptionsDialog {
Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp 2008-11-06 19:03:11 UTC (rev 34917)
+++ scummvm/trunk/gui/launcher.cpp 2008-11-06 20:26:19 UTC (rev 34918)
@@ -536,6 +536,15 @@
return ret;
}
+const Common::String &SaveLoadChooser::getResultString() const {
+ return _list->getSelectedString();
+}
+
+void SaveLoadChooser::setSaveMode(bool saveMode) {
+ _list->setEditable(saveMode);
+ _list->setNumberingMode(saveMode ? GUI::kListNumberingOne : GUI::kListNumberingZero);
+}
+
void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
int selItem = _list->getSelected();
@@ -543,7 +552,7 @@
case GUI::kListItemActivatedCmd:
case GUI::kListItemDoubleClickedCmd:
if (selItem >= 0) {
- if (!_list->getSelectedString().empty()) {
+ if (_list->isEditable() || !_list->getSelectedString().empty()) {
_list->endEditMode();
setResult(atoi(_saveList[selItem].save_slot().c_str()));
close();
@@ -556,6 +565,17 @@
break;
case GUI::kListSelectionChangedCmd: {
updateSelection(true);
+
+ /*
+ if (_list->isEditable()) {
+ _list->startEditMode();
+ }
+ // Disable button if nothing is selected, or (in load mode) if an empty
+ // list item is selected. We allow choosing an empty item in save mode
+ // because we then just assign a default name.
+ _chooseButton->setEnabled(selItem >= 0 && (_list->isEditable() || !getResultString().empty()));
+ _chooseButton->draw();
+ */
} break;
case kDelCmd:
if (selItem >= 0 && _delSupport) {
Modified: scummvm/trunk/gui/launcher.h
===================================================================
--- scummvm/trunk/gui/launcher.h 2008-11-06 19:03:11 UTC (rev 34917)
+++ scummvm/trunk/gui/launcher.h 2008-11-06 20:26:19 UTC (rev 34918)
@@ -114,6 +114,9 @@
void setList(const StringList& list);
int runModal(const EnginePlugin *plugin, const String &target);
+ const Common::String &SaveLoadChooser::getResultString() const;
+ void setSaveMode(bool saveMode);
+
virtual void reflowLayout();
virtual void close();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list