[Scummvm-cvs-logs] SF.net SVN: scummvm:[33855] scummvm/branches/gsoc2008-rtl/gui
cpage88 at users.sourceforge.net
cpage88 at users.sourceforge.net
Thu Aug 14 05:50:48 CEST 2008
Revision: 33855
http://scummvm.svn.sourceforge.net/scummvm/?rev=33855&view=rev
Author: cpage88
Date: 2008-08-14 03:50:48 +0000 (Thu, 14 Aug 2008)
Log Message:
-----------
Added 'delete' button to the launcher's load dialog, implementation for deleting a savegame to come
Modified Paths:
--------------
scummvm/branches/gsoc2008-rtl/gui/launcher.cpp
scummvm/branches/gsoc2008-rtl/gui/theme-config.cpp
scummvm/branches/gsoc2008-rtl/gui/themes/classic080.ini
scummvm/branches/gsoc2008-rtl/gui/themes/modern.ini
Modified: scummvm/branches/gsoc2008-rtl/gui/launcher.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/gui/launcher.cpp 2008-08-14 01:48:19 UTC (rev 33854)
+++ scummvm/branches/gsoc2008-rtl/gui/launcher.cpp 2008-08-14 03:50:48 UTC (rev 33855)
@@ -64,6 +64,7 @@
kLoadGameCmd = 'LOAD',
kQuitCmd = 'QUIT',
kChooseCmd = 'CHOS',
+ kDelCmd = 'DEL',
kCmdGlobalGraphicsOverride = 'OGFX',
@@ -474,9 +475,10 @@
typedef Common::String String;
typedef Common::StringList StringList;
protected:
- bool _saveMode;
+ bool _delSave;
GUI::ListWidget *_list;
GUI::ButtonWidget *_chooseButton;
+ GUI::ButtonWidget *_deleteButton;
GUI::GraphicsWidget *_gfxWidget;
GUI::ContainerWidget *_container;
@@ -484,7 +486,7 @@
void updateInfos(bool redraw);
public:
- SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode);
+ SaveLoadChooser(const String &title, const String &buttonLabel);
~SaveLoadChooser();
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
@@ -493,10 +495,12 @@
int runModal();
virtual void reflowLayout();
+
+ bool delSave() { return _delSave; };
};
-SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode)
- : Dialog("scummsaveload"), _saveMode(saveMode), _list(0), _chooseButton(0), _gfxWidget(0) {
+SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel)
+ : Dialog("scummsaveload"), _delSave(0), _list(0), _chooseButton(0), _deleteButton(0), _gfxWidget(0) {
_drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR;
@@ -504,8 +508,7 @@
// Add choice list
_list = new GUI::ListWidget(this, "scummsaveload_list");
- _list->setEditable(saveMode);
- _list->setNumberingMode(saveMode ? GUI::kListNumberingOne : GUI::kListNumberingZero);
+ _list->setNumberingMode(GUI::kListNumberingZero);
_container = new GUI::ContainerWidget(this, 0, 0, 10, 10);
_container->setHints(GUI::THEME_HINT_USE_SHADOW);
@@ -516,6 +519,9 @@
new GUI::ButtonWidget(this, "scummsaveload_cancel", "Cancel", kCloseCmd, 0);
_chooseButton = new GUI::ButtonWidget(this, "scummsaveload_choose", buttonLabel, kChooseCmd, 0);
_chooseButton->setEnabled(false);
+
+ _deleteButton = new GUI::ButtonWidget(this, "scummsaveload_delete", "Delete", kDelCmd, 0);
+ _deleteButton->setEnabled(false);
}
SaveLoadChooser::~SaveLoadChooser() {
@@ -532,6 +538,7 @@
int SaveLoadChooser::runModal() {
if (_gfxWidget)
_gfxWidget->setGfx(0);
+ _delSave = false;
int ret = Dialog::runModal();
return ret;
}
@@ -542,7 +549,7 @@
case GUI::kListItemActivatedCmd:
case GUI::kListItemDoubleClickedCmd:
if (selItem >= 0) {
- if (_saveMode || !getResultString().empty()) {
+ if (!getResultString().empty()) {
_list->endEditMode();
setResult(selItem);
close();
@@ -559,15 +566,23 @@
updateInfos(true);
}
- if (_saveMode) {
- _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 && (_saveMode || !getResultString().empty()));
+ // Disable these buttons if nothing is selected, or if an empty
+ // list item is selected.
+ _chooseButton->setEnabled(selItem >= 0 && (!getResultString().empty()));
_chooseButton->draw();
+ _deleteButton->setEnabled(selItem >= 0 && (!getResultString().empty()));
+ _deleteButton->draw();
} break;
+ case kDelCmd:
+ setResult(selItem);
+ _delSave = true;
+
+ // Disable these buttons again after deleteing a selection
+ _chooseButton->setEnabled(false);
+ _deleteButton->setEnabled(false);
+
+ close();
+ break;
case kCloseCmd:
setResult(-1);
default:
@@ -587,6 +602,7 @@
_gfxWidget->draw();
}
+
#pragma mark -
LauncherDialog::LauncherDialog()
@@ -650,8 +666,8 @@
// Create file browser dialog
_browser = new BrowserDialog("Select directory with game data", true);
- // Create SaveLoad dialog
- _loadDialog = new SaveLoadChooser("Load game:", "Load", false);
+ // Create Load dialog
+ _loadDialog = new SaveLoadChooser("Load game:", "Load");
}
void LauncherDialog::selectGame(const String &name) {
@@ -926,15 +942,26 @@
const EnginePlugin *plugin = 0;
GameDescriptor game = EngineMan.findGame(gameId, &plugin);
-
+
+ int idx;
if (plugin) {
- _loadDialog->setList(generateSavegameList(item, plugin));
- int idx = _loadDialog->runModal();
- if (idx >= 0) {
- ConfMan.setInt("save_slot", idx);
- ConfMan.setActiveDomain(_domains[item]);
- close();
+ do {
+ _loadDialog->setList(generateSavegameList(item, plugin));
+ idx = _loadDialog->runModal();
+ if (idx >= 0) {
+ // Delete the savegame
+ if (_loadDialog->delSave()) {
+ printf("Deleting slot: %d\n", idx);
+ }
+ // Load the savegame
+ else {
+ ConfMan.setInt("save_slot", idx);
+ ConfMan.setActiveDomain(_domains[item]);
+ close();
+ }
+ }
}
+ while (_loadDialog->delSave());
} else {
MessageDialog dialog("ScummVM could not find any engine capable of running the selected game!", "OK");
dialog.runModal();
Modified: scummvm/branches/gsoc2008-rtl/gui/theme-config.cpp
===================================================================
--- scummvm/branches/gsoc2008-rtl/gui/theme-config.cpp 2008-08-14 01:48:19 UTC (rev 33854)
+++ scummvm/branches/gsoc2008-rtl/gui/theme-config.cpp 2008-08-14 03:50:48 UTC (rev 33855)
@@ -95,6 +95,7 @@
"scummsaveload_thumbnail=(parent.w - (kThumbnailWidth + 22)) 18\n"
"scummsaveload_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n"
"scummsaveload_choose=(prev.x2 + 10) prev.y prev.w prev.h\n"
+"scummsaveload_delete=prev.x2 prev.y prev.w prev.h\n"
"scummsaveload_extinfo.visible=false\n"
"\n"
"# MM NES resolution\n"
@@ -372,6 +373,7 @@
"scummsaveload_thumbnail.fillB=0\n"
"scummsaveload_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n"
"scummsaveload_choose=(prev.x2 + 10) prev.y prev.w prev.h\n"
+"scummsaveload_delete=prev.x (prev.y - 30) prev.w prev.h\n"
"scummsaveload_extinfo.visible=true\n"
"\n"
"############################################\n"
Modified: scummvm/branches/gsoc2008-rtl/gui/themes/classic080.ini
===================================================================
--- scummvm/branches/gsoc2008-rtl/gui/themes/classic080.ini 2008-08-14 01:48:19 UTC (rev 33854)
+++ scummvm/branches/gsoc2008-rtl/gui/themes/classic080.ini 2008-08-14 03:50:48 UTC (rev 33855)
@@ -290,6 +290,7 @@
scummsaveload_thumbnail.fillB=0
scummsaveload_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight
scummsaveload_choose=(prev.x2 + 10) prev.y prev.w prev.h
+scummsaveload_delete=prev.x (prev.y - 30) prev.w prev.h
scummsaveload_extinfo.visible=true
############################################
@@ -442,6 +443,7 @@
scummsaveload_thumbnail=(parent.w - (kThumbnailWidth + 22)) 18
scummsaveload_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight
scummsaveload_choose=(prev.x2 + 10) prev.y prev.w prev.h
+scummsaveload_delete=prev.x (prev.y - 30) prev.w prev.h
scummsaveload_extinfo.visible=false
# MM NES resolution
Modified: scummvm/branches/gsoc2008-rtl/gui/themes/modern.ini
===================================================================
--- scummvm/branches/gsoc2008-rtl/gui/themes/modern.ini 2008-08-14 01:48:19 UTC (rev 33854)
+++ scummvm/branches/gsoc2008-rtl/gui/themes/modern.ini 2008-08-14 03:50:48 UTC (rev 33855)
@@ -457,6 +457,7 @@
scummsaveload_thumbnail.fillB=0
scummsaveload_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight
scummsaveload_choose=(prev.x2 + 10) prev.y prev.w prev.h
+scummsaveload_delete=prev.x (prev.y - 30) prev.w prev.h
scummsaveload_extinfo.visible=true
############################################
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