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

dreammaster paulfgilbert at gmail.com
Wed Jul 8 05:09:27 UTC 2020


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

Summary:
478647d23e GLK: Splitting up Conf loading from constructor
c4ca9aff2b GLK: Fix signed vs unsigned warnings
dc35d40397 GLK: COMPREHEND: Switch to using nw conf loading


Commit: 478647d23e26b1f7068e589aa799b20880cbb4e5
    https://github.com/scummvm/scummvm/commit/478647d23e26b1f7068e589aa799b20880cbb4e5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-07-07T22:06:18-07:00

Commit Message:
GLK: Splitting up Conf loading from constructor

This is the basis for fixing a problem where sub-engines with
a differing color scheme were overriding configuration after
it had already loaded, meaning that even if users set new
colors or other properties in scummvm.ini, the sub-engine was
ignoring them

Changed paths:
    engines/glk/conf.cpp
    engines/glk/conf.h
    engines/glk/glk.cpp
    engines/glk/glk.h


diff --git a/engines/glk/conf.cpp b/engines/glk/conf.cpp
index fbe9019c91..a57965d5e7 100644
--- a/engines/glk/conf.cpp
+++ b/engines/glk/conf.cpp
@@ -63,22 +63,70 @@ WindowStyleStatic G_STYLES[style_NUMSTYLES] = {
 
 Conf *g_conf;
 
-Conf::Conf(InterpreterType interpType) {
+Conf::Conf(InterpreterType interpType) : _interpType(interpType), _graphics(true),
+		_rows(25), _cols(60), _lockRows(0), _lockCols(0), _wPaddingX(0),
+		_wPaddingY(0), _wBorderX(0), _wBorderY(0), _tMarginX(7), _tMarginY(7),
+		_gamma(1.0), _borderColor(0), _borderSave(0),
+		_windowColor(parseColor(WHITE)), _windowSave(parseColor(WHITE)),
+		_sound(true), _speak(false), _speakInput(false), _styleHint(1),
+		_scrollBg(parseColor(SCROLL_BG)), _scrollFg(parseColor(SCROLL_FG)),
+		_lcd(1), _scrollWidth(0), _safeClicks(false)
+{
 	g_conf = this;
 	_imageW = g_system->getWidth();
 	_imageH = g_system->getHeight();
 
-	get("moreprompt", _propInfo._morePrompt, "\207 more \207");
-	get("morecolor", _propInfo._moreColor, nullptr);
-	get("morecolor", _propInfo._moreSave, nullptr);
-	get("morefont", _propInfo._moreFont, PROPB);
+	_propInfo._morePrompt = "\207 more \207";
+	_propInfo._moreColor = 0;
+	_propInfo._moreSave = 0;
+	_propInfo._moreFont = PROPB;
+	_propInfo._moreAlign = 0;
+	_monoInfo._aspect = 1.0;
+	_propInfo._aspect = 1.0;
+	_monoInfo._size = 11;
+	_propInfo._size = 12;
+	_propInfo._linkColor = parseColor(BLUE);
+	_monoInfo._linkColor = _propInfo._linkColor;
+	_propInfo._linkSave = _propInfo._linkColor;
+	_propInfo._caretColor = 0;
+	_propInfo._caretSave = 0;
+	_propInfo._caretShape = 2;
+	_propInfo._linkStyle = 1;
+	_monoInfo._linkStyle = 1;
+	_propInfo._justify = 0;
+	_propInfo._quotes = 1;
+	_propInfo._dashes = 1;
+	_propInfo._spaces = 0;
+	_propInfo._caps = 0;
+
+	const int DEFAULT_MARGIN_X = (_interpType == INTERPRETER_ZCODE) ? 0 : 15;
+	const int DEFAULT_MARGIN_Y = (_interpType == INTERPRETER_ZCODE) ? 0 : 15;
+	_wMarginX = _wMarginSaveX = DEFAULT_MARGIN_X;
+	_wMarginY = _wMarginSaveY = DEFAULT_MARGIN_Y;
+
+	// For simplicity's sake, only allow graphics when in non-paletted graphics modes
+	if (g_system->getScreenFormat().bytesPerPixel == 1)
+		_graphics = false;
+
+	Common::copy(T_STYLES, T_STYLES + style_NUMSTYLES, _tStyles);
+	Common::copy(G_STYLES, G_STYLES + style_NUMSTYLES, _gStyles);
+
+	Common::copy(_tStyles, _tStyles + style_NUMSTYLES, _tStylesDefault);
+	Common::copy(_gStyles, _gStyles + style_NUMSTYLES, _gStylesDefault);
+}
+
+void Conf::load() {
+	get("moreprompt", _propInfo._morePrompt);
+	get("morecolor", _propInfo._moreColor);
+	get("morecolor", _propInfo._moreSave);
+	get("morefont", _propInfo._moreFont);
 	get("morealign", _propInfo._moreAlign);
-	get("monoaspect", _monoInfo._aspect, 1.0);
-	get("propaspect", _propInfo._aspect, 1.0);
-	get("monosize", _monoInfo._size, 11);
-	get("propsize", _propInfo._size, 12);
-	get("rows", _rows, 25);
-	get("cols", _cols, 60);
+	get("monoaspect", _monoInfo._aspect);
+	get("propaspect", _propInfo._aspect);
+	get("monosize", _monoInfo._size);
+	get("propsize", _propInfo._size);
+	get("rows", _rows);
+	get("cols", _cols);
 
 	if (ConfMan.hasKey("leading"))
 		_monoInfo._leading = _propInfo._leading = static_cast<int>(atof(ConfMan.get("leading").c_str()) + 0.5);
@@ -94,13 +142,10 @@ Conf::Conf(InterpreterType interpType) {
 	if (ConfMan.hasKey("maxcols"))
 		_cols = MIN(_cols, strToInt(ConfMan.get("maxcols").c_str()));
 
-	const int DEFAULT_MARGIN_X = (interpType == INTERPRETER_ZCODE) ? 0 : 15;
-	const int DEFAULT_MARGIN_Y = (interpType == INTERPRETER_ZCODE) ? 0 : 15;
-
 	get("lockrows", _lockRows);
 	get("lockcols", _lockCols);
-	get("wmarginx", _wMarginX, DEFAULT_MARGIN_X);
-	get("wmarginy", _wMarginY, DEFAULT_MARGIN_Y);
+	get("wmarginx", _wMarginX);
+	get("wmarginy", _wMarginY);
 	_wMarginSaveX = _wMarginX;
 	_wMarginSaveY = _wMarginY;
 
@@ -108,49 +153,43 @@ Conf::Conf(InterpreterType interpType) {
 	get("wpaddingy", _wPaddingY);
 	get("wborderx", _wBorderX);
 	get("wbordery", _wBorderY);
-	get("tmarginx", _tMarginX, 7);
-	get("tmarginy", _tMarginY, 7);
-	get("gamma", _gamma, 1.0);
+	get("tmarginx", _tMarginX);
+	get("tmarginy", _tMarginY);
+	get("gamma", _gamma);
 
-	get("linkcolor", _propInfo._linkColor, BLUE);
+	get("linkcolor", _propInfo._linkColor);
 	_monoInfo._linkColor = _propInfo._linkColor;
 	_propInfo._linkSave = _propInfo._linkColor;
 
-	get("bordercolor", _borderColor, nullptr);
-	get("bordercolor", _borderSave, nullptr);
-	get("windowcolor", _windowColor, WHITE);
-	get("windowcolor", _windowSave, WHITE);
-	get("lcd", _lcd, 1);
-	get("caretcolor", _propInfo._caretColor, nullptr);
-	get("caretcolor", _propInfo._caretSave, nullptr);
-	get("caretshape", _propInfo._caretShape, 2);
+	get("bordercolor", _borderColor);
+	get("bordercolor", _borderSave);
+	get("windowcolor", _windowColor);
+	get("windowcolor", _windowSave);
+	get("lcd", _lcd);
+	get("caretcolor", _propInfo._caretColor);
+	get("caretcolor", _propInfo._caretSave);
+	get("caretshape", _propInfo._caretShape);
 
-	_propInfo._linkStyle = _monoInfo._linkStyle = ConfMan.hasKey("linkstyle")
-		&& !strToInt(ConfMan.get("linkstyle").c_str()) ? 0 : 1;
+	if (ConfMan.hasKey("linkstyle"))
+		_propInfo._linkStyle = _monoInfo._linkStyle = 
+			!strToInt(ConfMan.get("linkstyle").c_str()) ? 0 : 1;
 
 	get("scrollwidth", _scrollWidth);
-	get("scrollbg", _scrollBg, SCROLL_BG);
-	get("scrollfg", _scrollFg, SCROLL_FG);
+	get("scrollbg", _scrollBg);
+	get("scrollfg", _scrollFg);
 	get("justify", _propInfo._justify);
-	get("quotes", _propInfo._quotes, 1);
-	get("dashes", _propInfo._dashes, 1);
+	get("quotes", _propInfo._quotes);
+	get("dashes", _propInfo._dashes);
 	get("spaces", _propInfo._spaces);
 	get("caps", _propInfo._caps);
-	get("graphics", _graphics, true);
-	get("sound", _sound, true);
+	get("graphics", _graphics);
+	get("sound", _sound);
 	get("speak", _speak);
 	get("speak_input", _speakInput);
 	get("speak_language", _speakLanguage);
-	get("stylehint", _styleHint, 1);
+	get("stylehint", _styleHint);
 	get("safeclicks", _safeClicks);
 
-	// For simplicity's sake, only allow graphics when in non-paletted graphics modes
-	if (g_system->getScreenFormat().bytesPerPixel == 1)
-		_graphics = false;
-
-	Common::copy(T_STYLES, T_STYLES + style_NUMSTYLES, _tStyles);
-	Common::copy(G_STYLES, G_STYLES + style_NUMSTYLES, _gStyles);
-
 	char buffer[256];
 	const char *const TG_COLOR[2] = { "tcolor_%d", "gcolor_%d" };
 	for (int tg = 0; tg < 2; ++tg) {
@@ -196,36 +235,36 @@ Conf::Conf(InterpreterType interpType) {
 	Common::copy(_gStyles, _gStyles + style_NUMSTYLES, _gStylesDefault);
 }
 
-void Conf::get(const Common::String &key, Common::String &field, const char *defaultVal) {
-	field = ConfMan.hasKey(key) ? ConfMan.get(key) : defaultVal;
-	field.trim();
+void Conf::get(const Common::String &key, Common::String &field) {
+	if (ConfMan.hasKey(key)) {
+		field = ConfMan.get(key);
+		field.trim();
+	}
 }
 
-void Conf::get(const Common::String &key, uint &color, const byte *defaultColor) {
-	if (ConfMan.hasKey(key)) {
+void Conf::get(const Common::String &key, uint &color) {
+	if (ConfMan.hasKey(key))
 		color = parseColor(ConfMan.get(key));
-	} else if (defaultColor) {
-		color = g_system->getScreenFormat().RGBToColor(defaultColor[0], defaultColor[1], defaultColor[2]);
-	} else {
-		color = 0;
-	}
 }
 
-void Conf::get(const Common::String &key, int &field, int defaultVal) {
-	field = ConfMan.hasKey(key) ? strToInt(ConfMan.get(key).c_str()) : defaultVal;
+void Conf::get(const Common::String &key, int &field) {
+	if (ConfMan.hasKey(key))
+		field = strToInt(ConfMan.get(key).c_str());
 }
 
-void Conf::get(const Common::String &key, bool &field, bool defaultVal) {
-	if (!ConfMan.hasKey(key) || !Common::parseBool(ConfMan.get(key), field))
-		field = defaultVal;
+void Conf::get(const Common::String &key, bool &field) {
+	if (ConfMan.hasKey(key))
+		Common::parseBool(ConfMan.get(key), field);
 }
 
-void Conf::get(const Common::String &key, FACES &field, FACES defaultFont) {
-	field = ConfMan.hasKey(key) ? Screen::getFontId(ConfMan.get(key)) : defaultFont;
+void Conf::get(const Common::String &key, FACES &field) {
+	if (ConfMan.hasKey(key))
+		field = Screen::getFontId(ConfMan.get(key));
 }
 
-void Conf::get(const Common::String &key, double &field, double defaultVal) {
-	field = ConfMan.hasKey(key) ?  atof(ConfMan.get(key).c_str()) : defaultVal;
+void Conf::get(const Common::String &key, double &field) {
+	if (ConfMan.hasKey(key))
+		field = atof(ConfMan.get(key).c_str());
 }
 
 uint Conf::parseColor(const Common::String &str) {
@@ -252,4 +291,8 @@ uint Conf::parseColor(const Common::String &str) {
 	return 0;
 }
 
+uint Conf::parseColor(const byte *rgb) {
+	return g_system->getScreenFormat().RGBToColor(rgb[0], rgb[1], rgb[2]);
+}
+
 } // End of namespace Glk
diff --git a/engines/glk/conf.h b/engines/glk/conf.h
index b12b46ab38..1d95a471b5 100644
--- a/engines/glk/conf.h
+++ b/engines/glk/conf.h
@@ -34,40 +34,47 @@ namespace Glk {
  */
 class Conf {
 private:
+	InterpreterType _interpType;
+
 	/**
 	 * Get a string
 	 */
-	void get(const Common::String &key, Common::String &field, const char *defaultVal = nullptr);
+	void get(const Common::String &key, Common::String &field);
 
 	/**
 	 * Get a color
 	 */
-	void get(const Common::String &key, uint &color, const byte *defaultColor);
+	void get(const Common::String &key, uint &color);
 
 	/**
 	 * Get a font name into a font Id
 	 */
-	void get(const Common::String &key, FACES &field, FACES defaultFont);
+	void get(const Common::String &key, FACES &field);
 
 	/**
 	 * Get a numeric value
 	 */
-	void get(const Common::String &key, int &field, int defaultVal = 0);
+	void get(const Common::String &key, int &field);
 
 	/**
 	 * Get a numeric value
 	 */
-	void get(const Common::String &key, bool &field, bool defaultVal = false);
+	void get(const Common::String &key, bool &field);
 
 	/**
 	 * Get a double
 	 */
-	void get(const Common::String &key, double &field, double defaultVal = 0.0);
+	void get(const Common::String &key, double &field);
 
 	/**
 	 * Parse a color
 	 */
 	uint parseColor(const Common::String &str);
+
+	/**
+	 * Convert an RGB tuplet to a color
+	 */
+	uint parseColor(const byte *rgb);
 public:
 	MonoFontInfo _monoInfo;
 	PropFontInfo _propInfo;
@@ -102,6 +109,11 @@ public:
 	 * Constructor
 	 */
 	Conf(InterpreterType interpType);
+
+	/**
+	 * Loads the configuration from the ScummVM configuration
+	 */
+	void load();
 };
 
 extern Conf *g_conf;
diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp
index 7acf4d3a6a..dc501b0537 100644
--- a/engines/glk/glk.cpp
+++ b/engines/glk/glk.cpp
@@ -84,7 +84,9 @@ void GlkEngine::initialize() {
 	initGraphicsMode();
 	createDebugger();
 
-	_conf = new Conf(getInterpreterType());
+	createConfiguration();
+	_conf->load();
+
 	_screen = createScreen();
 	_screen->initialize();
 	_clipboard = new Clipboard();
@@ -124,6 +126,10 @@ void GlkEngine::createDebugger() {
 	setDebugger(new Debugger());
 }
 
+void GlkEngine::createConfiguration() {
+	_conf = new Conf(getInterpreterType());
+}
+
 Common::Error GlkEngine::run() {
 	// Open up the game file
 	Common::String filename = getFilename();
diff --git a/engines/glk/glk.h b/engines/glk/glk.h
index 39363a80d8..528b7b4332 100644
--- a/engines/glk/glk.h
+++ b/engines/glk/glk.h
@@ -106,6 +106,11 @@ protected:
 	 */
 	virtual Screen *createScreen();
 
+	/**
+	 * Loads the configuration
+	 */
+	virtual void createConfiguration();
+
 	/**
 	 * Main game loop for the individual interpreters
 	 */


Commit: c4ca9aff2bac40a1129a39cb8f14ee7823e573af
    https://github.com/scummvm/scummvm/commit/c4ca9aff2bac40a1129a39cb8f14ee7823e573af
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-07-07T22:06:19-07:00

Commit Message:
GLK: Fix signed vs unsigned warnings

Changed paths:
    engines/glk/speech.cpp


diff --git a/engines/glk/speech.cpp b/engines/glk/speech.cpp
index 3476b1abf7..70648a399c 100644
--- a/engines/glk/speech.cpp
+++ b/engines/glk/speech.cpp
@@ -175,7 +175,7 @@ void Speech::gli_tts_purge(void) {
 void Speech::gli_tts_speak(const uint32 *buf, size_t len) {
 	debugC(1, kDebugSpeech, "gli_tts_speak(const uint32 *, size_t)");
 	if (_speechManager) {
-		for (int i = 0 ; i < len ; ++i, ++buf) {
+		for (uint i = 0 ; i < len ; ++i, ++buf) {
 			// Should we automatically flush on new lines without waiting for the call to gli_tts_flush?
 			// Should we also flush on '.', '?', and '!'?
 			//if (*buf == '\n') {
@@ -192,7 +192,7 @@ void Speech::gli_tts_speak(const uint32 *buf, size_t len) {
 void Speech::gli_tts_speak(const char *buf, size_t len) {
 	debugC(1, kDebugSpeech, "gli_tts_speak(const char *, size_t)");
 	if (_speechManager) {
-		for (int i = 0 ; i < len ; ++i, ++buf) {
+		for (uint i = 0 ; i < len ; ++i, ++buf) {
 			// Should we automatically flush on new lines without waiting for the call to gli_tts_flush?
 			// Should we also flush on '.', '?', and '!'?
 			//if (*buf == '\n') {


Commit: dc35d40397b9beea12a34691b901526bb57fdbb6
    https://github.com/scummvm/scummvm/commit/dc35d40397b9beea12a34691b901526bb57fdbb6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-07-07T22:06:19-07:00

Commit Message:
GLK: COMPREHEND: Switch to using nw conf loading

Changed paths:
    engines/glk/comprehend/comprehend.cpp
    engines/glk/comprehend/comprehend.h
    engines/glk/conf.h
    engines/glk/glk.cpp
    engines/glk/glk.h


diff --git a/engines/glk/comprehend/comprehend.cpp b/engines/glk/comprehend/comprehend.cpp
index 7116e75a10..07e7225f50 100644
--- a/engines/glk/comprehend/comprehend.cpp
+++ b/engines/glk/comprehend/comprehend.cpp
@@ -63,6 +63,11 @@ void Comprehend::initGraphicsMode() {
 	initGraphics(640, 400, &pixelFormat);
 }
 
+void Comprehend::createConfiguration() {
+	GlkAPI::createConfiguration();
+	switchToWhiteOnBlack();
+}
+
 void Comprehend::runGame() {
 	initialize();
 
@@ -76,23 +81,18 @@ void Comprehend::runGame() {
 }
 
 void Comprehend::initialize() {
-	// Set up the GLK windows
-	g_conf->_wMarginX = 0;
-	g_conf->_wMarginY = 0;
-	g_conf->_tMarginY = 4;
-
 	_bottomWindow = (TextBufferWindow *)glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
 	glk_set_window(_bottomWindow);
 
 	showGraphics();
 	_topWindow->fillRect(0, Rect(0, 0, _topWindow->_w, _topWindow->_h));
-
+/*
 	const Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
 	_bottomWindow->_stream->setZColors(
 		pixelFormat.RGBToColor(0xff, 0xff, 0xff),
 		pixelFormat.RGBToColor(0, 0, 0)
 	);
-
+*/
 	// Initialize drawing surface, and the archive that abstracts
 	// the room and item graphics as as individual files
 	_drawSurface = new DrawSurface();
diff --git a/engines/glk/comprehend/comprehend.h b/engines/glk/comprehend/comprehend.h
index 8f7ed8a350..a910d8e7dc 100644
--- a/engines/glk/comprehend/comprehend.h
+++ b/engines/glk/comprehend/comprehend.h
@@ -80,6 +80,11 @@ private:
 	 */
 	void createGame();
 
+protected:
+	/**
+	 * Loads the configuration
+	 */
+	void createConfiguration() override;
 public:
 	/**
 	 * Constructor
diff --git a/engines/glk/conf.h b/engines/glk/conf.h
index 1d95a471b5..5c0fef74df 100644
--- a/engines/glk/conf.h
+++ b/engines/glk/conf.h
@@ -66,15 +66,17 @@ private:
 	 */
 	void get(const Common::String &key, double &field);
 
+public:
 	/**
 	 * Parse a color
 	 */
-	uint parseColor(const Common::String &str);
+	static uint parseColor(const Common::String &str);
 
 	/**
 	 * Convert an RGB tuplet to a color
 	 */
-	uint parseColor(const byte *rgb);
+	static uint parseColor(const byte *rgb);
+
 public:
 	MonoFontInfo _monoInfo;
 	PropFontInfo _propInfo;
diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp
index dc501b0537..ab1ac80fa3 100644
--- a/engines/glk/glk.cpp
+++ b/engines/glk/glk.cpp
@@ -286,4 +286,23 @@ void GlkEngine::beep() {
 	_pcSpeaker->speakerOn(50, 50);
 }
 
+void GlkEngine::switchToWhiteOnBlack() {
+	const uint WHITE = Conf::parseColor("ffffff");
+	const uint BLACK = Conf::parseColor("000000");
+
+	_conf->_wMarginX = 0;
+	_conf->_wMarginY = 0;
+	_conf->_tMarginY = 4;
+	_conf->_propInfo._caretColor = WHITE;
+
+	_conf->_windowColor = _conf->_windowSave = 0;
+	WindowStyle &ws1 = _conf->_tStyles[style_Normal];
+	ws1.bg = BLACK;
+	ws1.fg = WHITE;
+
+	WindowStyle &ws2 = _conf->_tStyles[style_Input];
+	ws2.bg = BLACK;
+	ws2.fg = WHITE;
+}
+
 } // End of namespace Glk
diff --git a/engines/glk/glk.h b/engines/glk/glk.h
index 528b7b4332..df85953bb3 100644
--- a/engines/glk/glk.h
+++ b/engines/glk/glk.h
@@ -115,6 +115,12 @@ protected:
 	 * Main game loop for the individual interpreters
 	 */
 	virtual void runGame() = 0;
+
+	/**
+	 * Switches Glk from the default black on white color scheme
+	 * to white on black
+	 */
+	void switchToWhiteOnBlack();
 public:
 	Blorb *_blorb;
 	Clipboard *_clipboard;




More information about the Scummvm-git-logs mailing list