diff options
| -rw-r--r-- | engines/dialogs.cpp | 18 | ||||
| -rw-r--r-- | engines/dialogs.h | 2 | ||||
| -rw-r--r-- | gui/launcher.cpp | 22 | ||||
| -rw-r--r-- | gui/launcher.h | 3 | 
4 files changed, 40 insertions, 5 deletions
diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp index 95be09184f..40cec8e10b 100644 --- a/engines/dialogs.cpp +++ b/engines/dialogs.cpp @@ -118,13 +118,15 @@ MainMenuDialog::MainMenuDialog(Engine *engine)  	_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 @@ void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat  		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();  		} diff --git a/engines/dialogs.h b/engines/dialogs.h index e93b069636..0e715e6fb6 100644 --- a/engines/dialogs.h +++ b/engines/dialogs.h @@ -59,7 +59,7 @@ protected:  	GUI::Dialog		*_aboutDialog;  	GUI::Dialog		*_optionsDialog;  	GUI::SaveLoadChooser	*_loadDialog; - +	GUI::SaveLoadChooser	*_saveDialog;  };  class ConfigDialog : public GUI::OptionsDialog { diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 9a201fd936..090e3e2406 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -536,6 +536,15 @@ int SaveLoadChooser::runModal(const EnginePlugin *plugin, const String &target)  	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 @@ void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 da  	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 @@ void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 da  		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) { diff --git a/gui/launcher.h b/gui/launcher.h index 7e04e865f9..4b873d6186 100644 --- a/gui/launcher.h +++ b/gui/launcher.h @@ -114,6 +114,9 @@ public:  	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();  | 
