diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | gui/launcher.cpp | 48 | ||||
| -rw-r--r-- | gui/options.cpp | 179 | ||||
| -rw-r--r-- | gui/options.h | 17 | ||||
| -rw-r--r-- | scumm/dialogs.cpp | 53 | ||||
| -rw-r--r-- | scumm/dialogs.h | 7 | 
6 files changed, 117 insertions, 189 deletions
| @@ -30,7 +30,7 @@ MODULE_DIRS :=  include config.mak  # Uncomment this for stricter compile time code verification -CXXFLAGS+= -Werror +# CXXFLAGS+= -Werror  CXXFLAGS:= -Wall $(CXXFLAGS)  CXXFLAGS+= -O -Wuninitialized diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 53772c67d4..0ab29f97c9 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -86,6 +86,8 @@ class EditGameDialog : public OptionsDialog {  public:  	EditGameDialog(const String &domain, GameSettings target); +	void open(); +	void close();  	virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);  protected: @@ -98,10 +100,6 @@ protected:  	CheckboxWidget *_globalGraphicsOverride;  	CheckboxWidget *_globalAudioOverride;  	CheckboxWidget *_globalVolumeOverride; - -	virtual void applySettings(); -	virtual void loadSettings(); -	virtual void saveSettings();  };  EditGameDialog::EditGameDialog(const String &domain, GameSettings target) @@ -205,17 +203,11 @@ EditGameDialog::EditGameDialog(const String &domain, GameSettings target)  	// Add OK & Cancel buttons  	addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0); -	addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kSaveCmd, 0); -} - -void EditGameDialog::applySettings() { -	// Do *never* apply settings from the EditGameDialog! -	// After all, we are editing a game target in the launcher; that target -	// can definitely not be the active target, since we are in the launcher. +	addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);  } -void EditGameDialog::loadSettings() { -	OptionsDialog::loadSettings(); +void EditGameDialog::open() { +	OptionsDialog::open();  	int sel, i;  	bool e; @@ -259,22 +251,24 @@ void EditGameDialog::loadSettings() {  	_platformPopUp->setSelected(sel);  } -void EditGameDialog::saveSettings() { -	ConfMan.set("description", _descriptionWidget->getLabel(), _domain); -	Common::Language lang = (Common::Language)_langPopUp->getSelectedTag(); -	if (lang < 0) -		ConfMan.removeKey("language", _domain); -	else -		ConfMan.set("language", Common::getLanguageCode(lang), _domain); +void EditGameDialog::close() { +	if (getResult()) { +		ConfMan.set("description", _descriptionWidget->getLabel(), _domain); -	Common::Platform platform = (Common::Platform)_platformPopUp->getSelectedTag(); -	if (platform < 0) -		ConfMan.removeKey("platform", _domain); -	else -		ConfMan.set("platform", Common::getPlatformCode(platform), _domain); +		Common::Language lang = (Common::Language)_langPopUp->getSelectedTag(); +		if (lang < 0) +			ConfMan.removeKey("language", _domain); +		else +			ConfMan.set("language", Common::getLanguageCode(lang), _domain); -	OptionsDialog::saveSettings(); +		Common::Platform platform = (Common::Platform)_platformPopUp->getSelectedTag(); +		if (platform < 0) +			ConfMan.removeKey("platform", _domain); +		else +			ConfMan.set("platform", Common::getPlatformCode(platform), _domain); +	} +	OptionsDialog::close();  }  void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { @@ -291,7 +285,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat  		setVolumeSettingsState(data != 0);  		draw();  		break; -	case kSaveCmd: { +	case kOKCmd: {  		// Write back changes made to config object  		String newDomain(_domainWidget->getLabel());  		if (newDomain != _domain) { diff --git a/gui/options.cpp b/gui/options.cpp index f4ffaf98e5..cb42735246 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -55,8 +55,6 @@ enum {  OptionsDialog::OptionsDialog(const String &domain, int x, int y, int w, int h)  	: Dialog(x, y, w, h),  	_domain(domain), -	_isActiveDomain(domain.isEmpty() || domain == ConfMan.getActiveDomain() || -				(ConfMan.getActiveDomain().isEmpty() && domain == Common::ConfigManager::kApplicationDomain)),  	_enableGraphicSettings(false),  	_gfxPopUp(0), _fullscreenCheckbox(0), _aspectCheckbox(0),  	_enableAudioSettings(false), @@ -66,7 +64,6 @@ OptionsDialog::OptionsDialog(const String &domain, int x, int y, int w, int h)  	_musicVolumeSlider(0), _musicVolumeLabel(0),  	_sfxVolumeSlider(0), _sfxVolumeLabel(0) { -printf("_isActiveDomain = %d, _domain = %s, active domain = %s\n", _isActiveDomain, _domain.c_str(), ConfMan.getActiveDomain().c_str());  }  void OptionsDialog::open() { @@ -74,49 +71,15 @@ void OptionsDialog::open() {  	// Reset result value  	setResult(0); - -	loadSettings(); -} - -void OptionsDialog::handleScreenChanged() { -	loadSettings(); -} - -void OptionsDialog::close() { -	if (getResult() == kSaveCmd) { -		saveSettings(); -	} - -	if (_isActiveDomain && (getResult() == kSaveCmd || getResult() == kApplyCmd)) { -		applySettings(); -	} - -	Dialog::close(); -} - -void OptionsDialog::applySettings() { -	// Activate changes now -	if (_enableGraphicSettings) { -		g_system->setFeatureState(OSystem::kFeatureFullscreenMode, _fullscreenCheckbox->getState()); -		g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, _aspectCheckbox->getState()); -		if ((int32)_gfxPopUp->getSelectedTag() >= 0) -			g_system->setGraphicsMode(_gfxPopUp->getSelectedTag()); -	} -} - -void OptionsDialog::loadSettings() { -	bool state;  	if (_fullscreenCheckbox) {  		_gfxPopUp->setSelected(0); +		_gfxPopUp->setEnabled(false); -		if (_isActiveDomain) { -			int gfxMode = g_system->getGraphicsMode(); -			_gfxPopUp->setSelectedTag(gfxMode); -		} else if (ConfMan.hasKey("gfx_mode", _domain)) { +		if (ConfMan.hasKey("gfx_mode", _domain)) {  			const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes(); -			int gfxCount = 1;  			String gfxMode = ConfMan.get("gfx_mode", _domain); +			int gfxCount = 1;  			while (gm->name) {  				gfxCount++; @@ -129,16 +92,10 @@ void OptionsDialog::loadSettings() {  #ifndef _WIN32_WCE  		// Fullscreen setting -		state = _isActiveDomain ? -					g_system->getFeatureState(OSystem::kFeatureFullscreenMode) : -					ConfMan.getBool("fullscreen", _domain); -		_fullscreenCheckbox->setState(state); +		_fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain));  		// Aspect ratio setting -		state = _isActiveDomain ? -					g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection) : -					ConfMan.getBool("aspect_ratio", _domain); -		_aspectCheckbox->setState(state); +		_aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain));  #endif  	} @@ -183,55 +140,59 @@ void OptionsDialog::loadSettings() {  	}  } -void OptionsDialog::saveSettings() { -	if (_fullscreenCheckbox) { -		if (_enableGraphicSettings) { -			ConfMan.set("fullscreen", _fullscreenCheckbox->getState(), _domain); -			ConfMan.set("aspect_ratio", _aspectCheckbox->getState(), _domain); - -			if ((int32)_gfxPopUp->getSelectedTag() >= 0) -				ConfMan.set("gfx_mode", _gfxPopUp->getSelectedString(), _domain); -		} else { -			ConfMan.removeKey("fullscreen", _domain); -			ConfMan.removeKey("aspect_ratio", _domain); -			ConfMan.removeKey("gfx_mode", _domain); +void OptionsDialog::close() { +	if (getResult()) { +		if (_fullscreenCheckbox) { +			if (_enableGraphicSettings) { +				ConfMan.set("fullscreen", _fullscreenCheckbox->getState(), _domain); +				ConfMan.set("aspect_ratio", _aspectCheckbox->getState(), _domain); + +				if ((int32)_gfxPopUp->getSelectedTag() >= 0) +					ConfMan.set("gfx_mode", _gfxPopUp->getSelectedString(), _domain); +			} else { +				ConfMan.removeKey("fullscreen", _domain); +				ConfMan.removeKey("aspect_ratio", _domain); +				ConfMan.removeKey("gfx_mode", _domain); +			}  		} -	} -	if (_masterVolumeSlider) { -		if (_enableVolumeSettings) { -			ConfMan.set("master_volume", _masterVolumeSlider->getValue(), _domain); -			ConfMan.set("music_volume", _musicVolumeSlider->getValue(), _domain); -			ConfMan.set("sfx_volume", _sfxVolumeSlider->getValue(), _domain); -		} else { -			ConfMan.removeKey("master_volume", _domain); -			ConfMan.removeKey("music_volume", _domain); -			ConfMan.removeKey("sfx_volume", _domain); +		if (_masterVolumeSlider) { +			if (_enableVolumeSettings) { +				ConfMan.set("master_volume", _masterVolumeSlider->getValue(), _domain); +				ConfMan.set("music_volume", _musicVolumeSlider->getValue(), _domain); +				ConfMan.set("sfx_volume", _sfxVolumeSlider->getValue(), _domain); +			} else { +				ConfMan.removeKey("master_volume", _domain); +				ConfMan.removeKey("music_volume", _domain); +				ConfMan.removeKey("sfx_volume", _domain); +			}  		} -	} -	if (_multiMidiCheckbox) { -		if (_enableAudioSettings) { -			ConfMan.set("multi_midi", _multiMidiCheckbox->getState(), _domain); -			ConfMan.set("native_mt32", _mt32Checkbox->getState(), _domain); -			ConfMan.set("subtitles", _subCheckbox->getState(), _domain);  -			const MidiDriverDescription *md = getAvailableMidiDrivers(); -			while (md->name && md->id != (int)_midiPopUp->getSelectedTag()) -				md++; -			if (md->name) -				ConfMan.set("music_driver", md->name, _domain); -			else +		if (_multiMidiCheckbox) { +			if (_enableAudioSettings) { +				ConfMan.set("multi_midi", _multiMidiCheckbox->getState(), _domain); +				ConfMan.set("native_mt32", _mt32Checkbox->getState(), _domain); +				ConfMan.set("subtitles", _subCheckbox->getState(), _domain);  +				const MidiDriverDescription *md = getAvailableMidiDrivers(); +				while (md->name && md->id != (int)_midiPopUp->getSelectedTag()) +					md++; +				if (md->name) +					ConfMan.set("music_driver", md->name, _domain); +				else +					ConfMan.removeKey("music_driver", _domain); +			} else { +				ConfMan.removeKey("multi_midi", _domain); +				ConfMan.removeKey("native_mt32", _domain);  				ConfMan.removeKey("music_driver", _domain); -		} else { -			ConfMan.removeKey("multi_midi", _domain); -			ConfMan.removeKey("native_mt32", _domain); -			ConfMan.removeKey("music_driver", _domain); -			ConfMan.removeKey("subtitles", _domain);  +				ConfMan.removeKey("subtitles", _domain);  +			}  		} + +		// Save config file +		ConfMan.flushToDisk();  	} -	// Save config file -	ConfMan.flushToDisk(); +	Dialog::close();  }  void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { @@ -248,14 +209,10 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data  		_sfxVolumeLabel->setValue(_sfxVolumeSlider->getValue());  		_sfxVolumeLabel->draw();  		break; -	case kApplyCmd: -	case kSaveCmd: -		setResult(cmd); +	case kOKCmd: +		setResult(1);  		close();  		break; -	case kRevertCmd: -		// TODO: Implement this! -		break;  	default:  		Dialog::handleCommand(sender, cmd, data);  	} @@ -387,7 +344,7 @@ int OptionsDialog::addVolumeControls(GuiObject *boss, int yoffset) {  GlobalOptionsDialog::GlobalOptionsDialog(GameDetector &detector) -	: OptionsDialog(Common::ConfigManager::kApplicationDomain, 10, 10, 320 - 2 * 10, 200 - 2 * 10) { +	: OptionsDialog(Common::ConfigManager::kApplicationDomain, 10, 20, 320 - 2 * 10, 200 - 2 * 20) {  	const int vBorder = 5;  	int yoffset; @@ -431,30 +388,19 @@ GlobalOptionsDialog::GlobalOptionsDialog(GameDetector &detector)  	tab->setActiveTab(0);  	// Add OK & Cancel buttons -	addButton(10, _h - 24, "Revert", kRevertCmd, 0); -	addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Save", kSaveCmd, 0); -	addButton(_w - (kButtonWidth + 10), _h - 24, "Apply", kApplyCmd, 0); +	addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0); +	addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);  	// Create file browser dialog  	_browser = new BrowserDialog("Select directory for savegames"); - -	setGraphicSettingsState(true); -	setAudioSettingsState(true); -	setVolumeSettingsState(true);  }  GlobalOptionsDialog::~GlobalOptionsDialog() {  	delete _browser;  } -void GlobalOptionsDialog::applySettings() { -	OptionsDialog::applySettings(); - -	// TODO ? -} - -void GlobalOptionsDialog::loadSettings() { -	OptionsDialog::loadSettings(); +void GlobalOptionsDialog::open() { +	OptionsDialog::open();  #if !( defined(__DC__) || defined(__GP32__) )  	// Set _savePath to the current save path @@ -470,11 +416,12 @@ void GlobalOptionsDialog::loadSettings() {  #endif  } -void GlobalOptionsDialog::saveSettings() { -	// Savepath -	ConfMan.set("savepath", _savePath->getLabel(), _domain); - -	OptionsDialog::saveSettings(); +void GlobalOptionsDialog::close() { +	if (getResult()) { +		// Savepath +		ConfMan.set("savepath", _savePath->getLabel(), _domain); +	} +	OptionsDialog::close();  }  void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { diff --git a/gui/options.h b/gui/options.h index 0196bad21d..9f6c6bf852 100644 --- a/gui/options.h +++ b/gui/options.h @@ -42,20 +42,15 @@ public:  	void open();  	void close();  	void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); -	void handleScreenChanged();  	enum { -		kApplyCmd	= 'aply', -		kSaveCmd	= 'save', -		kRevertCmd	= 'rvrt' +		kOKCmd					= 'ok  '  	};  protected:  	/** Config domain this dialog is used to edit. */  	String _domain; -	const bool _isActiveDomain; -	  	int addGraphicControls(GuiObject *boss, int yoffset);  	int addMIDIControls(GuiObject *boss, int yoffset);  	int addVolumeControls(GuiObject *boss, int yoffset); @@ -63,10 +58,6 @@ protected:  	void setGraphicSettingsState(bool enabled);  	void setAudioSettingsState(bool enabled);  	void setVolumeSettingsState(bool enabled); -	 -	virtual void applySettings(); -	virtual void loadSettings(); -	virtual void saveSettings();  private:  	// @@ -108,15 +99,13 @@ public:  	GlobalOptionsDialog(GameDetector &detector);  	~GlobalOptionsDialog(); +	void open(); +	void close();  	void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);  protected:  	BrowserDialog *_browser;  	StaticTextWidget *_savePath; - -	virtual void applySettings(); -	virtual void loadSettings(); -	virtual void saveSettings();  };  } // End of namespace GUI diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index a0992ee8c0..ce7884eb48 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -395,6 +395,10 @@ void MainMenuDialog::load() {  #pragma mark -  enum { +	kOKCmd					= 'ok  ' +}; + +enum {  	kKeysCmd = 'KEYS'  }; @@ -409,14 +413,12 @@ ConfigDialog::ConfigDialog(ScummEngine *scumm)  	// Add the buttons  	//  #ifdef _WIN32_WCE -	addButton(_w - kButtonWidth - 8, _h - 24 - 4, "Save", GUI::OptionsDialog::kSaveCmd, 'S'); -	addButton(_w - 2 * kButtonWidth - 12, _h - 24 - 4, "Apply", GUI::OptionsDialog::kApplyCmd, 'A'); -	addButton(_w - 3 * kButtonWidth - 16, _h - 24 - 4, "Revert", GUI::OptionsDialog::kRevertCmd, 'R'); -	addButton(_w - 4 * kButtonWidth - 16, _h - 24 - 4, "Keys", kKeysCmd, 'K'); +	addButton(_w - kButtonWidth - 8, _h - 24 - 4, "OK", GUI::OptionsDialog::kOKCmd, 'O'); +	addButton(_w - 2 * kButtonWidth - 12, _h - 24 - 4, "Cancel", kCloseCmd, 'C'); +	addButton(_w - 3 * kButtonWidth - 16, _h - 24 - 4, "Keys", kKeysCmd, 'K');  #else -	addButton(_w - kButtonWidth - 8, _h - 24, "Save", GUI::OptionsDialog::kSaveCmd, 'S'); -	addButton(_w - 2 * kButtonWidth - 12, _h - 24, "Apply", GUI::OptionsDialog::kApplyCmd, 'A'); -	addButton(_w - 3 * kButtonWidth - 16, _h - 24, "Revert", GUI::OptionsDialog::kRevertCmd, 'R'); +	addButton(_w - kButtonWidth-8, _h - 24, "OK", GUI::OptionsDialog::kOKCmd, 'O'); +	addButton(_w - 2 * kButtonWidth-12, _h - 24, "Cancel", kCloseCmd, 'C');  #endif  	// @@ -444,8 +446,24 @@ ConfigDialog::~ConfigDialog() {  #endif  } -void ConfigDialog::applySettings() { -	ConfigDialog::applySettings(); +void ConfigDialog::open() { +	GUI_OptionsDialog::open(); + +	// update checkboxes, too +	subtitlesCheckbox->setState(ConfMan.getBool("subtitles")); +} + +void ConfigDialog::close() { +	 +	if (getResult()) { +		// Subtitles +		ConfMan.set("subtitles", subtitlesCheckbox->getState(), _domain); +		// Sync with current setting +		if (_vm->_version >= 7) +			_vm->VAR(_vm->VAR_VOICE_MODE) = subtitlesCheckbox->getState(); +	} + +	GUI_OptionsDialog::close();  	// Sync the engine with the config manager  	int soundVolumeMaster = ConfMan.getInt("master_volume"); @@ -461,25 +479,8 @@ void ConfigDialog::applySettings() {  	_vm->_mixer->setVolume(soundVolumeSfx * soundVolumeMaster / 255);  	_vm->_mixer->setMusicVolume(soundVolumeMusic); - -	// Sync with current setting -	if (_vm->_version >= 7) -		_vm->VAR(_vm->VAR_VOICE_MODE) = ConfMan.getBool("subtitles");  } -void ConfigDialog::loadSettings() { -	GUI_OptionsDialog::loadSettings(); - -	// Update subtitles checkbox -	subtitlesCheckbox->setState(ConfMan.getBool("subtitles")); -} - -void ConfigDialog::saveSettings() { -	// Subtitles -	ConfMan.set("subtitles", subtitlesCheckbox->getState(), _domain); - -	GUI_OptionsDialog::saveSettings(); -}  void ConfigDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {  	switch (cmd) { diff --git a/scumm/dialogs.h b/scumm/dialogs.h index 2531f17c7a..54a260b621 100644 --- a/scumm/dialogs.h +++ b/scumm/dialogs.h @@ -112,15 +112,12 @@ public:  	ConfigDialog(ScummEngine *scumm);  	~ConfigDialog(); +	virtual void open(); +	virtual void close();  	virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);  protected:  	GUI::CheckboxWidget *subtitlesCheckbox; - - -	virtual void applySettings(); -	virtual void loadSettings(); -	virtual void saveSettings();  };  class InfoDialog : public ScummDialog { | 
