[Scummvm-git-logs] scummvm master -> f82a3468363bb640d291b45ceb39d18101586423

dreammaster paulfgilbert at gmail.com
Fri Apr 24 03:00:05 UTC 2020


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c8fa755049 ULTIMA4: Created a ConfSerializer class to simply settings read/write
f82a346836 ULTIMA4: Removing configuration items that will be kept static


Commit: c8fa755049ff3a97bce475b1f136c5c892a28d21
    https://github.com/scummvm/scummvm/commit/c8fa755049ff3a97bce475b1f136c5c892a28d21
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-23T18:06:25-07:00

Commit Message:
ULTIMA4: Created a ConfSerializer class to simply settings read/write

Changed paths:
  A engines/ultima/shared/conf/conf_serializer.h
    engines/ultima/ultima4/core/settings.cpp
    engines/ultima/ultima4/core/settings.h


diff --git a/engines/ultima/shared/conf/conf_serializer.h b/engines/ultima/shared/conf/conf_serializer.h
new file mode 100644
index 0000000000..12f62b7b50
--- /dev/null
+++ b/engines/ultima/shared/conf/conf_serializer.h
@@ -0,0 +1,102 @@
+/* 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 SHARED_CONF_CONF_SERIALIZER_H
+#define SHARED_CONF_CONF_SERIALIZER_H
+
+#include "common/config-manager.h"
+
+namespace Ultima {
+namespace Shared {
+
+/**
+ * A simplified serializer class for reading/writing stuff from ConfMan
+ */
+class ConfSerializer {
+private:
+	bool _isSaving;
+public:
+	/**
+	 * Constructor
+	 */
+	ConfSerializer(bool isSaving) : _isSaving(isSaving) {}
+
+	/**
+	 * Destructor
+	 */
+	~ConfSerializer() {
+		if (_isSaving)
+			ConfMan.flushToDisk();
+	}
+
+	/**
+	 * Returns true if saving
+	 */
+	bool isSaving() const {
+		return _isSaving;
+	}
+
+	/**
+	 * Returns true if loading
+	 */
+	bool isLoading() const {
+		return !_isSaving;
+	}
+
+	/**
+	 * Syncs a string
+	 */
+	void syncAsString(const Common::String &key, Common::String &value,
+			const char *defaultValue = nullptr) {
+		if (_isSaving)
+			ConfMan.set(key, value);
+		else
+			value = ConfMan.hasKey(key) ? ConfMan.get(key) : Common::String(defaultValue);
+	}
+
+	/**
+	 * Syncs a boolean
+	 */
+	void syncAsBool(const Common::String &key, bool &value,
+			bool defaultValue = false) {
+		if (_isSaving)
+			ConfMan.setBool(key, value);
+		else
+			value = ConfMan.hasKey(key) ? ConfMan.getBool(key) : defaultValue;
+	}
+
+	/**
+	 * Syncs an integer
+	 */
+	template<typename T>
+	void syncAsInt(const Common::String &key, T &value, T defaultValue = 0) {
+		if (_isSaving)
+			ConfMan.setInt(key, value);
+		else
+			value = ConfMan.hasKey(key) ? ConfMan.getInt(key) : defaultValue;
+	}
+};
+
+} // End of namespace Shared
+} // End of namespace Ultima
+
+#endif
diff --git a/engines/ultima/ultima4/core/settings.cpp b/engines/ultima/ultima4/core/settings.cpp
index 9d3f90810d..c3ffc6b625 100644
--- a/engines/ultima/ultima4/core/settings.cpp
+++ b/engines/ultima/ultima4/core/settings.cpp
@@ -24,7 +24,6 @@
 #include "ultima/ultima4/events/event_handler.h"
 #include "ultima/ultima4/filesys/filesystem.h"
 #include "ultima/ultima4/core/utils.h"
-#include "common/config-manager.h"
 #include "common/file.h"
 
 namespace Ultima {
@@ -87,7 +86,21 @@ bool SettingsData::operator!=(const SettingsData &s) const {
 /*-------------------------------------------------------------------*/
 
 Settings::Settings() {
-	read();
+	_innAlwaysCombat = 0;
+	_campingAlwaysCombat = 0;
+	_screenAnimationFramesPerSecond = DEFAULT_ANIMATION_FRAMES_PER_SECOND;
+
+	_game = "Ultima IV";
+	_debug = gDebugLevel > 0;
+  
+	_battleDiffs.push_back("Normal");
+	_battleDiffs.push_back("Hard");
+	_battleDiffs.push_back("Expert");
+
+	Shared::ConfSerializer s(false);
+	synchronize(s);
+
+	_eventTimerGranularity = (1000 / _gameCyclesPerSecond);
 }
 
 Settings &Settings::getInstance() {
@@ -101,215 +114,73 @@ void Settings::setData(const SettingsData &data) {
 	*(SettingsData *)this = data;
 }
 
-bool Settings::read() {
-	// default settings
-	_scale                 = DEFAULT_SCALE;
-	_fullscreen            = DEFAULT_FULLSCREEN;
-	_filter                = DEFAULT_FILTER;
-	_videoType             = DEFAULT_VIDEO_TYPE;
-	_gemLayout             = DEFAULT_GEM_LAYOUT;
-	_lineOfSight           = DEFAULT_LINEOFSIGHT;
-	_screenShakes          = DEFAULT_SCREEN_SHAKES;
-	_gamma                 = DEFAULT_GAMMA;
-	_musicVol              = DEFAULT_MUSIC_VOLUME;
-	_soundVol              = DEFAULT_SOUND_VOLUME;
-	_volumeFades           = DEFAULT_VOLUME_FADES;
-	_shortcutCommands      = DEFAULT_SHORTCUT_COMMANDS;
-	_keydelay              = DEFAULT_KEY_DELAY;
-	_keyinterval           = DEFAULT_KEY_INTERVAL;
-	_filterMoveMessages    = DEFAULT_FILTER_MOVE_MESSAGES;
-	_battleSpeed           = DEFAULT_BATTLE_SPEED;
-	_enhancements          = DEFAULT_ENHANCEMENTS;
-	_gameCyclesPerSecond   = DEFAULT_CYCLES_PER_SECOND;
-	_screenAnimationFramesPerSecond = DEFAULT_ANIMATION_FRAMES_PER_SECOND;
-	_debug                 = gDebugLevel > 0;
-	_battleDiff            = DEFAULT_BATTLE_DIFFICULTY;
-	_validateXml           = DEFAULT_VALIDATE_XML;
-	_spellEffectSpeed      = DEFAULT_SPELL_EFFECT_SPEED;
-	_campTime              = DEFAULT_CAMP_TIME;
-	_innTime               = DEFAULT_INN_TIME;
-	_shrineTime            = DEFAULT_SHRINE_TIME;
-	_shakeInterval         = DEFAULT_SHAKE_INTERVAL;
-	_titleSpeedRandom      = DEFAULT_TITLE_SPEED_RANDOM;
-	_titleSpeedOther       = DEFAULT_TITLE_SPEED_OTHER;
-
-	// all specific minor enhancements default to "on", any major enhancements default to "off"
-	_enhancementsOptions._activePlayer     = true;
-	_enhancementsOptions._u5spellMixing    = true;
-	_enhancementsOptions._u5shrines        = true;
-	_enhancementsOptions._slimeDivides     = true;
-	_enhancementsOptions._gazerSpawnsInsects = true;
-	_enhancementsOptions._textColorization = false;
-	_enhancementsOptions._c64chestTraps    = true;
-	_enhancementsOptions._smartEnterKey    = true;
-	_enhancementsOptions._peerShowsObjects = false;
-	_enhancementsOptions._u5combat         = false;
-	_enhancementsOptions._u4TileTransparencyHack = true;
-	_enhancementsOptions._u4TileTransparencyHackPixelShadowOpacity = DEFAULT_SHADOW_PIXEL_OPACITY;
-	_enhancementsOptions._u4TrileTransparencyHackShadowBreadth = DEFAULT_SHADOW_PIXEL_SIZE;
-
-	_innAlwaysCombat = 0;
-	_campingAlwaysCombat = 0;
-
-	// mouse defaults to on
-	_mouseOptions._enabled = 1;
-
-	_logging = DEFAULT_LOGGING;
-	_game = "Ultima IV";
-
-	_battleDiffs.push_back("Normal");
-	_battleDiffs.push_back("Hard");
-	_battleDiffs.push_back("Expert");
+bool Settings::write() {
+	Shared::ConfSerializer s(true);
+	synchronize(s);
 
-	if (ConfMan.hasKey("video"))
-		_videoType = ConfMan.get("video");
-	if (ConfMan.hasKey("gemLayout"))
-		_gemLayout = ConfMan.get("gemLayout");
-	if (ConfMan.hasKey("lineOfSight"))
-		_lineOfSight = ConfMan.get("lineOfSight");
-	if (ConfMan.hasKey("screenShakes"))
-		_screenShakes = ConfMan.getBool("screenShakes");
-	if (ConfMan.hasKey("gamma"))
-		_gamma = ConfMan.getInt("gamma");
+	setChanged();
+	notifyObservers(nullptr);
 
-	if (ConfMan.hasKey("volumeFades"))
-		_volumeFades = ConfMan.getBool("volumeFades");
-	if (ConfMan.hasKey("shortcutCommands"))
-		_shortcutCommands = ConfMan.getBool("shortcutCommands");
-	if (ConfMan.hasKey("keydelay"))
-		_keydelay = ConfMan.getInt("keydelay");
-	if (ConfMan.hasKey("filterMoveMessages"))
-		_filterMoveMessages = ConfMan.getBool("filterMoveMessages");
-	if (ConfMan.hasKey("battlespeed"))
-		_battleSpeed = ConfMan.getInt("battlespeed");
-	if (ConfMan.hasKey("enhancements"))
-		_enhancements = ConfMan.getBool("enhancements");
-	if (ConfMan.hasKey("gameCyclesPerSecond"))
-		_gameCyclesPerSecond = ConfMan.getInt("gameCyclesPerSecond");
-	if (ConfMan.hasKey("battleDiff"))
-		_battleDiff = ConfMan.get("battleDiff");
-	if (ConfMan.hasKey("validateXml"))
-		_validateXml = ConfMan.getBool("validateXml");
+	return true;
+}
 
-	if (ConfMan.hasKey("spellEffectSpeed"))
-		_spellEffectSpeed = ConfMan.getInt("spellEffectSpeed");
-	if (ConfMan.hasKey("campTime"))
-		_campTime = ConfMan.getInt("campTime");
-	if (ConfMan.hasKey("innTime"))
-		_innTime = ConfMan.getInt("innTime");
-	if (ConfMan.hasKey("shrineTime"))
-		_shrineTime = ConfMan.getInt("shrineTime");
-	if (ConfMan.hasKey("shakeInterval"))
-		_shakeInterval = ConfMan.getInt("shakeInterval");
-	if (ConfMan.hasKey("titleSpeedRandom"))
-		_titleSpeedRandom = ConfMan.getInt("titleSpeedRandom");
-	if (ConfMan.hasKey("titleSpeedOther"))
-		_titleSpeedOther = ConfMan.getInt("titleSpeedOther");
+void Settings::synchronize(Shared::ConfSerializer &s) {
+	// TODO: Deprecate these
+	_scale			= DEFAULT_SCALE;
+	_fullscreen		= DEFAULT_FULLSCREEN;
+	_filter			= DEFAULT_FILTER;
+	_musicVol		= DEFAULT_MUSIC_VOLUME;
+	_soundVol		= DEFAULT_SOUND_VOLUME;
+
+	// General settings
+	s.syncAsString("video", _videoType, DEFAULT_VIDEO_TYPE);
+	s.syncAsString("gemLayout", _gemLayout, DEFAULT_GEM_LAYOUT);
+	s.syncAsString("lineOfSight", _lineOfSight, DEFAULT_LINEOFSIGHT);
+	s.syncAsBool("screenShakes", _screenShakes, DEFAULT_SCREEN_SHAKES);
+	s.syncAsInt("gamma", _gamma, DEFAULT_GAMMA);
+	s.syncAsBool("volumeFades", _volumeFades, DEFAULT_VOLUME_FADES);
+	s.syncAsBool("shortcutCommands", _shortcutCommands, DEFAULT_SHORTCUT_COMMANDS);
+	s.syncAsInt("keydelay", _keydelay, DEFAULT_KEY_DELAY);
+	s.syncAsInt("keyinterval", _keyinterval, DEFAULT_KEY_INTERVAL);
+	s.syncAsBool("filterMoveMessages", _filterMoveMessages, DEFAULT_FILTER_MOVE_MESSAGES);
+	s.syncAsInt("battlespeed", _battleSpeed, DEFAULT_BATTLE_SPEED);
+	s.syncAsBool("enhancements", _enhancements, DEFAULT_ENHANCEMENTS);
+	s.syncAsInt("gameCyclesPerSecond", _gameCyclesPerSecond, DEFAULT_CYCLES_PER_SECOND);
+	s.syncAsString("battleDiff", _battleDiff, DEFAULT_BATTLE_DIFFICULTY);
+	s.syncAsBool("validateXml", _validateXml, DEFAULT_VALIDATE_XML);
+	s.syncAsInt("spellEffectSpeed", _spellEffectSpeed, DEFAULT_SPELL_EFFECT_SPEED);
+	s.syncAsInt("campTime", _campTime, DEFAULT_CAMP_TIME);
+	s.syncAsInt("innTime", _innTime, DEFAULT_INN_TIME);
+	s.syncAsInt("shrineTime", _shrineTime, DEFAULT_SHRINE_TIME);
+	s.syncAsInt("shakeInterval", _shakeInterval, DEFAULT_SHAKE_INTERVAL);
+	s.syncAsInt("titleSpeedRandom", _titleSpeedRandom, DEFAULT_TITLE_SPEED_RANDOM);
+	s.syncAsInt("titleSpeedOther", _titleSpeedOther, DEFAULT_TITLE_SPEED_OTHER);
+	s.syncAsBool("innAlwaysCombat", _innAlwaysCombat, false);
+	s.syncAsBool("campingAlwaysCombat", _campingAlwaysCombat, false);
 
+	// all specific minor enhancements default to "on", any major enhancements default to "off"
 	// minor enhancement options
-	if (ConfMan.hasKey("activePlayer"))
-		_enhancementsOptions._activePlayer = ConfMan.getBool("activePlayer");
-	if (ConfMan.hasKey("u5spellMixing"))
-		_enhancementsOptions._u5spellMixing = ConfMan.getBool("u5spellMixing");
-	if (ConfMan.hasKey("u5shrines"))
-		_enhancementsOptions._u5shrines = ConfMan.getBool("u5shrines");
-	if (ConfMan.hasKey("slimeDivides"))
-		_enhancementsOptions._slimeDivides = ConfMan.getBool("slimeDivides");
-	if (ConfMan.hasKey("gazerSpawnsInsects"))
-		_enhancementsOptions._gazerSpawnsInsects = ConfMan.getBool("gazerSpawnsInsects");
-	if (ConfMan.hasKey("textColorization"))
-		_enhancementsOptions._textColorization = ConfMan.getBool("textColorization");
-	if (ConfMan.hasKey("c64chestTraps"))
-		_enhancementsOptions._c64chestTraps = ConfMan.getBool("c64chestTraps");
-	if (ConfMan.hasKey("smartEnterKey"))
-		_enhancementsOptions._smartEnterKey = ConfMan.getBool("smartEnterKey");
+	s.syncAsBool("activePlayer", _enhancementsOptions._activePlayer, true);
+	s.syncAsBool("u5spellMixing", _enhancementsOptions._u5spellMixing, true);
+	s.syncAsBool("u5shrines", _enhancementsOptions._u5shrines, true);
+	s.syncAsBool("slimeDivides", _enhancementsOptions._slimeDivides, true);
+	s.syncAsBool("gazerSpawnsInsects", _enhancementsOptions._gazerSpawnsInsects, true);
+	s.syncAsBool("textColorization", _enhancementsOptions._textColorization, false);
+	s.syncAsBool("c64chestTraps", _enhancementsOptions._c64chestTraps, true);
+	s.syncAsBool("smartEnterKey", _enhancementsOptions._smartEnterKey, true);
 
 	// major enhancement options
-	if (ConfMan.hasKey("peerShowsObjects"))
-		_enhancementsOptions._peerShowsObjects = ConfMan.getBool("peerShowsObjects");
-	if (ConfMan.hasKey("u5combat"))
-		_enhancementsOptions._u5combat = ConfMan.getBool("u5combat");
-	if (ConfMan.hasKey("innAlwaysCombat"))
-		_innAlwaysCombat = ConfMan.getBool("innAlwaysCombat");
-	if (ConfMan.hasKey("campingAlwaysCombat"))
-		_campingAlwaysCombat = ConfMan.getBool("campingAlwaysCombat");
-
-	// mouse options
-	if (ConfMan.hasKey("mouseEnabled"))
-		_mouseOptions._enabled = ConfMan.getBool("mouseEnabled");
-	if (ConfMan.hasKey("logging"))
-		_logging = ConfMan.get("logging");
+	s.syncAsBool("peerShowsObjects", _enhancementsOptions._peerShowsObjects, false);
+	s.syncAsBool("u5combat", _enhancementsOptions._u5combat, false);
 
 	// graphics enhancements options
-	if (ConfMan.hasKey("renderTileTransparency"))
-		_enhancementsOptions._u4TileTransparencyHack = ConfMan.getBool("renderTileTransparency");
-	if (ConfMan.hasKey("transparentTilePixelShadowOpacity"))
-		_enhancementsOptions._u4TileTransparencyHackPixelShadowOpacity =
-			ConfMan.getInt("transparentTilePixelShadowOpacity");
-	if (ConfMan.hasKey("transparentTileShadowSize"))
-		_enhancementsOptions._u4TrileTransparencyHackShadowBreadth =
-		ConfMan.getInt("transparentTileShadowSize");
-
-
-	_eventTimerGranularity = (1000 / _gameCyclesPerSecond);
-	return true;
-}
-
-bool Settings::write() {
-	ConfMan.set("video", _videoType);
-	ConfMan.set("gemLayout", _gemLayout);
-	ConfMan.set("lineOfSight", _lineOfSight);
-	ConfMan.setBool("screenShakes", _screenShakes);
-	ConfMan.setInt("gamma", _gamma);
+	s.syncAsBool("renderTileTransparency", _enhancementsOptions._u4TileTransparencyHack, true);
+	s.syncAsInt("transparentTilePixelShadowOpacity", _enhancementsOptions._u4TileTransparencyHackPixelShadowOpacity, DEFAULT_SHADOW_PIXEL_OPACITY);
+	s.syncAsInt("transparentTileShadowSize", _enhancementsOptions._u4TrileTransparencyHackShadowBreadth, DEFAULT_SHADOW_PIXEL_SIZE);
 
-	ConfMan.setBool("volumeFades", _volumeFades);
-	ConfMan.setBool("shortcutCommands", _shortcutCommands);
-	ConfMan.setInt("keydelay", _keydelay);
-	ConfMan.setBool("filterMoveMessages", _filterMoveMessages);
-	ConfMan.setInt("battlespeed", _battleSpeed);
-	ConfMan.setBool("enhancements", _enhancements);
-	ConfMan.setInt("gameCyclesPerSecond", _gameCyclesPerSecond);
-	ConfMan.set("battleDiff", _battleDiff);
-	ConfMan.setBool("validateXml", _validateXml);
-
-	ConfMan.setInt("spellEffectSpeed", _spellEffectSpeed);
-	ConfMan.setInt("campTime", _campTime);
-	ConfMan.setInt("innTime", _innTime);
-	ConfMan.setInt("shrineTime", _shrineTime);
-	ConfMan.setInt("shakeInterval", _shakeInterval);
-	ConfMan.setInt("titleSpeedRandom", _titleSpeedRandom);
-	ConfMan.setInt("titleSpeedOther", _titleSpeedOther);
-
-	ConfMan.setBool("activePlayer", _enhancementsOptions._activePlayer);
-	ConfMan.setBool("u5spellMixing", _enhancementsOptions._u5spellMixing);
-	ConfMan.setBool("u5shrines", _enhancementsOptions._u5shrines);
-	ConfMan.setBool("slimeDivides", _enhancementsOptions._slimeDivides);
-	ConfMan.setBool("gazerSpawnsInsects", _enhancementsOptions._gazerSpawnsInsects);
-	ConfMan.setBool("textColorization", _enhancementsOptions._textColorization);
-	ConfMan.setBool("c64chestTraps", _enhancementsOptions._c64chestTraps);
-	ConfMan.setBool("smartEnterKey", _enhancementsOptions._smartEnterKey);
-
-	ConfMan.setBool("peerShowsObjects", _enhancementsOptions._peerShowsObjects);
-	ConfMan.setBool("u5combat", _enhancementsOptions._u5combat);
-	ConfMan.setBool("innAlwaysCombat", _innAlwaysCombat);
-	ConfMan.setBool("campingAlwaysCombat", _campingAlwaysCombat);
-
-	ConfMan.setBool("mouseEnabled", _mouseOptions._enabled);
-	ConfMan.set("logging", _logging);
-
-	ConfMan.setBool("renderTileTransparency",
-		_enhancementsOptions._u4TileTransparencyHack);
-	ConfMan.setInt("transparentTilePixelShadowOpacity",
-		_enhancementsOptions._u4TileTransparencyHackPixelShadowOpacity);
-	ConfMan.setInt("transparentTileShadowSize",
-		_enhancementsOptions._u4TrileTransparencyHackShadowBreadth);
-
-	ConfMan.flushToDisk();
-
-	setChanged();
-	notifyObservers(nullptr);
-
-	return true;
+	// mouse options
+	s.syncAsBool("mouseEnabled", _mouseOptions._enabled, true);
+	s.syncAsString("logging", _logging, DEFAULT_LOGGING);
 }
 
 const Std::vector<Common::String> &Settings::getBattleDiffs() {
diff --git a/engines/ultima/ultima4/core/settings.h b/engines/ultima/ultima4/core/settings.h
index 6cb95dd26f..438a758762 100644
--- a/engines/ultima/ultima4/core/settings.h
+++ b/engines/ultima/ultima4/core/settings.h
@@ -25,6 +25,7 @@
 
 #include "ultima/ultima4/core/observable.h"
 #include "ultima/ultima4/core/types.h"
+#include "ultima/shared/conf/conf_serializer.h"
 #include "common/hash-str.h"
 
 namespace Ultima {
@@ -157,7 +158,19 @@ public:
  */
 class Settings : public SettingsData, public Observable<Settings *> {
 	typedef Common::HashMap<Common::String, Common::String> SettingsMap;
+private:
+	static Settings *_instance;
+	Std::vector<Common::String> _battleDiffs;
+private:
+	/**
+	 * Default contructor.  Settings is a singleton so this is private.
+	 */
+	Settings();
 
+	/**
+	 * Synchronize settings with ConfMan
+	 */
+	void synchronize(Shared::ConfSerializer &s);
 public:
 	/* Methods */
 
@@ -167,11 +180,6 @@ public:
 	static Settings &getInstance();
 	void setData(const SettingsData &data);
 
-	/**
-	 * Read settings
-	 */
-	bool read();
-
 	/**
 	 * Write the settings out into a human readable file.  This also
 	 * notifies observers that changes have been commited.
@@ -179,15 +187,6 @@ public:
 	bool write();
 
 	const Std::vector<Common::String> &getBattleDiffs();
-
-private:
-	/**
-	 * Default contructor.  Settings is a singleton so this is private.
-	 */
-	Settings();
-
-	static Settings *_instance;
-	Std::vector<Common::String> _battleDiffs;
 };
 
 /* the global settings */


Commit: f82a3468363bb640d291b45ceb39d18101586423
    https://github.com/scummvm/scummvm/commit/f82a3468363bb640d291b45ceb39d18101586423
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-23T19:58:58-07:00

Commit Message:
ULTIMA4: Removing configuration items that will be kept static

Changed paths:
    engines/ultima/ultima4/controllers/intro_controller.cpp
    engines/ultima/ultima4/controllers/intro_controller.h
    engines/ultima/ultima4/core/settings.cpp
    engines/ultima/ultima4/core/settings.h


diff --git a/engines/ultima/ultima4/controllers/intro_controller.cpp b/engines/ultima/ultima4/controllers/intro_controller.cpp
index b109352ea0..5c8df629d7 100644
--- a/engines/ultima/ultima4/controllers/intro_controller.cpp
+++ b/engines/ultima/ultima4/controllers/intro_controller.cpp
@@ -222,10 +222,7 @@ IntroController::IntroController() : Controller(1),
 
 	_videoMenu.setTitle("Video Options:", 0, 0);
 	_videoMenu.add(MI_VIDEO_CONF_GFX,                        "\010 Game Graphics Options",  2,  2,/*'g'*/  2);
-	_videoMenu.add(MI_VIDEO_04,         new IntMenuItem("Scale                x%d", 2,  4,/*'s'*/  0, reinterpret_cast<int *>(&settingsChanged._scale), 1, 5, 1));
-	_videoMenu.add(MI_VIDEO_05, (new BoolMenuItem("Mode                 %s",  2,  5,/*'m'*/  0, &settingsChanged._fullscreen))->setValueStrings("Fullscreen", "Window"));
-	_videoMenu.add(MI_VIDEO_06,             new StringMenuItem("Filter               %s",  2,  6,/*'f'*/  0, &settingsChanged._filter, screenGetFilterNames()));
-	_videoMenu.add(MI_VIDEO_08,         new IntMenuItem("Gamma                %s",  2,  7,/*'a'*/  1, &settingsChanged._gamma, 50, 150, 10, MENU_OUTPUT_GAMMA));
+	_videoMenu.add(MI_VIDEO_08,         new IntMenuItem("Gamma                %s",  2,  4,/*'a'*/  1, &settingsChanged._gamma, 50, 150, 10, MENU_OUTPUT_GAMMA));
 	_videoMenu.add(USE_SETTINGS,                   "\010 Use These Settings",  2, 11,/*'u'*/  2);
 	_videoMenu.add(CANCEL,                         "\010 Cancel",              2, 12,/*'c'*/  2);
 	_videoMenu.addShortcutKey(CANCEL, ' ');
diff --git a/engines/ultima/ultima4/controllers/intro_controller.h b/engines/ultima/ultima4/controllers/intro_controller.h
index a265091ebb..bc914bc2d8 100644
--- a/engines/ultima/ultima4/controllers/intro_controller.h
+++ b/engines/ultima/ultima4/controllers/intro_controller.h
@@ -289,9 +289,6 @@ private:
 		MI_VIDEO_CONF_GFX,
 		MI_VIDEO_02,
 		MI_VIDEO_03,
-		MI_VIDEO_04,
-		MI_VIDEO_05,
-		MI_VIDEO_06,
 		MI_VIDEO_07,
 		MI_VIDEO_08,
 		MI_GFX_SCHEME,
diff --git a/engines/ultima/ultima4/core/settings.cpp b/engines/ultima/ultima4/core/settings.cpp
index c3ffc6b625..4ebf9a5324 100644
--- a/engines/ultima/ultima4/core/settings.cpp
+++ b/engines/ultima/ultima4/core/settings.cpp
@@ -86,20 +86,26 @@ bool SettingsData::operator!=(const SettingsData &s) const {
 /*-------------------------------------------------------------------*/
 
 Settings::Settings() {
+	// Synchronize settings
+	Shared::ConfSerializer s(false);
+	synchronize(s);
+
+	// Set up various other constants that aren't configurable
+	_game = "Ultima IV";
+	_debug = gDebugLevel > 0;
+
 	_innAlwaysCombat = 0;
 	_campingAlwaysCombat = 0;
 	_screenAnimationFramesPerSecond = DEFAULT_ANIMATION_FRAMES_PER_SECOND;
 
-	_game = "Ultima IV";
-	_debug = gDebugLevel > 0;
+	bool isEnhanced = _videoType != "EGA";
+	_scale = isEnhanced ? 2 : 1;
+	_filter = isEnhanced ? "Scale2x" : "point";
   
 	_battleDiffs.push_back("Normal");
 	_battleDiffs.push_back("Hard");
 	_battleDiffs.push_back("Expert");
 
-	Shared::ConfSerializer s(false);
-	synchronize(s);
-
 	_eventTimerGranularity = (1000 / _gameCyclesPerSecond);
 }
 
@@ -126,14 +132,12 @@ bool Settings::write() {
 
 void Settings::synchronize(Shared::ConfSerializer &s) {
 	// TODO: Deprecate these
-	_scale			= DEFAULT_SCALE;
-	_fullscreen		= DEFAULT_FULLSCREEN;
-	_filter			= DEFAULT_FILTER;
-	_musicVol		= DEFAULT_MUSIC_VOLUME;
-	_soundVol		= DEFAULT_SOUND_VOLUME;
+	_musicVol = DEFAULT_MUSIC_VOLUME;
+	_soundVol = DEFAULT_SOUND_VOLUME;
 
 	// General settings
-	s.syncAsString("video", _videoType, DEFAULT_VIDEO_TYPE);
+	bool isEnhanced = g_ultima->isEnhanced();
+	s.syncAsString("video", _videoType, isEnhanced ? "new" : "EGA");
 	s.syncAsString("gemLayout", _gemLayout, DEFAULT_GEM_LAYOUT);
 	s.syncAsString("lineOfSight", _lineOfSight, DEFAULT_LINEOFSIGHT);
 	s.syncAsBool("screenShakes", _screenShakes, DEFAULT_SCREEN_SHAKES);
diff --git a/engines/ultima/ultima4/core/settings.h b/engines/ultima/ultima4/core/settings.h
index 438a758762..5e68dced89 100644
--- a/engines/ultima/ultima4/core/settings.h
+++ b/engines/ultima/ultima4/core/settings.h
@@ -44,10 +44,6 @@ namespace Ultima4 {
 #define MAX_SHAKE_INTERVAL              200
 #define MAX_VOLUME                      10
 
-#define DEFAULT_SCALE                   2
-#define DEFAULT_FULLSCREEN              0
-#define DEFAULT_FILTER                  "Scale2x"
-#define DEFAULT_VIDEO_TYPE              (g_ultima->isEnhanced() ? "new" : "EGA")
 #define DEFAULT_GEM_LAYOUT              "Standard"
 #define DEFAULT_LINEOFSIGHT             "DOS"
 #define DEFAULT_SCREEN_SHAKES           1
@@ -120,7 +116,6 @@ public:
 	bool _enhancements;
 	SettingsEnhancementOptions _enhancementsOptions;
 	bool _filterMoveMessages;
-	bool _fullscreen;
 	int _gameCyclesPerSecond;
 	int _screenAnimationFramesPerSecond;
 	bool _innAlwaysCombat;




More information about the Scummvm-git-logs mailing list