aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-10-20 21:04:41 -0700
committerPaul Gilbert2018-12-08 19:05:59 -0800
commitef15871fec18060420eddc92a9830f595b8cc970 (patch)
treee302a20b25f9f27056ee470ee9da87516d259f64
parentcf5259d3bc279fd73b4ae8bad2d7b04b8ff7265e (diff)
downloadscummvm-rg350-ef15871fec18060420eddc92a9830f595b8cc970.tar.gz
scummvm-rg350-ef15871fec18060420eddc92a9830f595b8cc970.tar.bz2
scummvm-rg350-ef15871fec18060420eddc92a9830f595b8cc970.zip
GLK: Setting up of configuration loading
-rw-r--r--engines/gargoyle/conf.cpp152
-rw-r--r--engines/gargoyle/conf.h118
-rw-r--r--engines/gargoyle/fonts.cpp40
-rw-r--r--engines/gargoyle/fonts.h45
-rw-r--r--engines/gargoyle/gargoyle.cpp4
-rw-r--r--engines/gargoyle/gargoyle.h2
-rw-r--r--engines/gargoyle/glk.cpp1
-rw-r--r--engines/gargoyle/glk_types.h4
-rw-r--r--engines/gargoyle/module.mk3
-rw-r--r--engines/gargoyle/streams.cpp9
-rw-r--r--engines/gargoyle/streams.h7
-rw-r--r--engines/gargoyle/string.cpp51
-rw-r--r--engines/gargoyle/string.h43
-rw-r--r--engines/gargoyle/windows.h3
14 files changed, 460 insertions, 22 deletions
diff --git a/engines/gargoyle/conf.cpp b/engines/gargoyle/conf.cpp
new file mode 100644
index 0000000000..c296254d74
--- /dev/null
+++ b/engines/gargoyle/conf.cpp
@@ -0,0 +1,152 @@
+/* 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.
+ *
+ */
+
+#include "gargoyle/conf.h"
+#include "gargoyle/fonts.h"
+#include "gargoyle/string.h"
+#include "common/config-manager.h"
+
+namespace Gargoyle {
+
+const byte WHITE[3] = { 0xff, 0xff, 0xff };
+const byte BLUE[3] = { 0x00, 0x00, 0x60 };
+const byte SCROLL_BG[3] = { 0xb0, 0xb0, 0xb0 };
+const byte SCROLL_FG[3] = { 0x80, 0x80, 0x80 };
+
+Conf::Conf() {
+ g_conf = this;
+
+ get("moreprompt", _morePrompt, "\207 more \207");
+ get("morecolor", _moreColor);
+ get("morecolor", _moreSave);
+ get("morefont", _moreFont, PROPB);
+ get("morealign", _moreAlign);
+ get("monoaspect", _monoAspect, 1.0);
+ get("propaspect", _propAspect, 1.0);
+ get("monosize", _monoSize, 12.5);
+ get("monor", _monoR);
+ get("monob", _monoR);
+ get("monoi", _monoI);
+ get("monoz", _monoZ);
+ get("monofont", _monoFont, "Liberation Mono");
+ get("propsize", _propSize, 15.5);
+ get("propr", _propR);
+ get("propb", _propR);
+ get("propi", _propI);
+ get("propz", _propZ);
+ get("propfont", _propFont, "Linux Libertine O");
+ get("leading", _leading);
+ get("baseline", _baseLine);
+ get("rows", _rows, 25);
+ get("cols", _cols, 60);
+
+ if (ConfMan.hasKey("minrows"))
+ _rows = MAX(_rows, strToInt(ConfMan.get("minrows").c_str()));
+ if (ConfMan.hasKey("maxrows"))
+ _rows = MIN(_rows, strToInt(ConfMan.get("maxrows").c_str()));
+ if (ConfMan.hasKey("mincols"))
+ _cols = MAX(_cols, strToInt(ConfMan.get("mincols").c_str()));
+ if (ConfMan.hasKey("maxcols"))
+ _cols = MIN(_cols, strToInt(ConfMan.get("maxcols").c_str()));
+
+ get("lockrows", _lockRows);
+ get("lockcols", _lockCols);
+ get("wmarginx", _wMarginX, 15);
+ get("wmarginy", _wMarginY, 15);
+ _wMarginSaveX = _wMarginX;
+ _wMarginSaveY = _wMarginY;
+
+ get("wpaddingx", _wPaddingX);
+ get("wpaddingy", _wPaddingY);
+ get("wborderx", _wBorderX, 1);
+ get("wbordery", _wBorderY, 1);
+ get("tmarginx", _tMarginX, 7);
+ get("tmarginy", _tMarginY, 7);
+ get("gamma", _gamma, 1.0);
+
+ get("caretcolor", _caretColor);
+ get("caretcolor", _caretSave);
+ get("linkcolor", _linkColor, BLUE);
+ get("linkcolor", _linkSave, BLUE);
+ get("bordercolor", _borderColor);
+ get("bordercolor", _borderSave);
+ get("windowcolor", _windowColor, WHITE);
+ get("windowcolor", _windowSave, WHITE);
+ get("lcd", _lcd, 1);
+ get("caretshape", _caretShape, 2);
+
+ _linkStyle = ConfMan.hasKey("linkstyle") && !strToInt(ConfMan.get("linkstyle").c_str()) ? 0 : 1;
+
+ get("scrollwidth", _scrollWidth);
+ get("scrollbg", _scrollBg, SCROLL_BG);
+ get("scrollfg", _scrollFg, SCROLL_FG);
+ get("justify", _justify);
+ get("quotes", _quotes, 1);
+ get("dashes", _dashes, 1);
+ get("spaces", _spaces);
+ get("caps", _caps);
+ get("graphics", _graphics, 1);
+ get("sound", _sound, 1);
+ get("speak", _speak);
+ get("speak_input", _speakInput);
+ get("speak_language", _speakLanguage);
+ get("stylehint", _styleHint, 1);
+
+}
+
+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, byte *color, const byte *defaultColor) {
+ char r[3], g[3], b[3];
+ Common::String str;
+
+ if (ConfMan.hasKey(key) && (str = ConfMan.get(key)).size() == 6) {
+ r[0] = str[0]; r[1] = str[1]; r[2] = 0;
+ g[0] = str[2]; g[1] = str[3]; g[2] = 0;
+ b[0] = str[4]; b[1] = str[5]; b[2] = 0;
+
+ color[0] = strtol(r, NULL, 16);
+ color[1] = strtol(g, NULL, 16);
+ color[2] = strtol(b, NULL, 16);
+ } else if (defaultColor) {
+ Common::copy(defaultColor, defaultColor + 3, color);
+ } else {
+ Common::fill(color, color + 3, 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, FACES &field, FACES defaultFont) {
+ field = ConfMan.hasKey(key) ? Fonts::getId(ConfMan.get(key)) : defaultFont;
+}
+
+void Conf::get(const Common::String &key, double &field, double defaultVal) {
+ field = ConfMan.hasKey(key) ? atof(ConfMan.get(key).c_str()) : defaultVal;
+}
+
+} // End of namespace Gargoyle
diff --git a/engines/gargoyle/conf.h b/engines/gargoyle/conf.h
new file mode 100644
index 0000000000..2dbb29f44c
--- /dev/null
+++ b/engines/gargoyle/conf.h
@@ -0,0 +1,118 @@
+/* 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 GARGOYLE_CONF_H
+#define GARGOYLE_CONF_H
+
+#include "gargoyle/glk_types.h"
+#include "gargoyle/fonts.h"
+
+namespace Gargoyle {
+
+class Conf {
+private:
+ /**
+ * Get a string
+ */
+ void get(const Common::String &key, Common::String &field, const char *defaultVal = nullptr);
+
+ /**
+ * Get a color
+ */
+ void get(const Common::String &key, byte *color, const byte *defaultColor = nullptr);
+
+ /**
+ * Get a font name into a font Id
+ */
+ void get(const Common::String &key, FACES &field, FACES defaultFont);
+
+ /**
+ * Get a numeric value
+ */
+ void get(const Common::String &key, int &field, int defaultVal = 0);
+
+ /**
+ * Get a double
+ */
+ void get(const Common::String &key, double &field, double defaultVal = 0.0);
+
+public:
+ Common::String _morePrompt;
+ byte _moreColor[3], _moreSave[3];
+ FACES _moreFont;
+ int _moreAlign;
+ double _monoAspect;
+ double _propAspect;
+ double _monoSize;
+ Common::String _monoR;
+ Common::String _monoB;
+ Common::String _monoI;
+ Common::String _monoZ;
+ Common::String _monoFont;
+ double _propSize;
+ Common::String _propR;
+ Common::String _propB;
+ Common::String _propI;
+ Common::String _propZ;
+ Common::String _propFont;
+ int _leading;
+ int _baseLine;
+ int _cols, _rows;
+ int _lockCols, _lockRows;
+ int _wMarginX, _wMarginY;
+ int _wMarginSaveX, _wMarginSaveY;
+ int _wPaddingX, _wPaddingY;
+ int _wBorderX, _wBorderY;
+ int _tMarginX, _tMarginY;
+ double _gamma;
+ byte _caretColor[3], _caretSave[3];
+ byte _linkColor[3], _linkSave[3];
+ byte _borderColor[3], _borderSave[3];
+ byte _windowColor[3], _windowSave[3];
+ int _lcd;
+ int _caretShape;
+ int _linkStyle;
+ int _scrollWidth;
+ byte _scrollBg[3], _scrollFg[3];
+ int _justify;
+ int _quotes;
+ int _dashes;
+ int _spaces;
+ int _caps;
+ int _graphics;
+ int _sound;
+ int _speak;
+ int _speakInput;
+ Common::String _speakLanguage;
+ int _styleHint;
+public:
+ /**
+ * Constructor
+ */
+ Conf();
+};
+
+extern Conf *g_conf;
+
+} // End of namespace Gargoyle
+
+#endif
diff --git a/engines/gargoyle/fonts.cpp b/engines/gargoyle/fonts.cpp
new file mode 100644
index 0000000000..9c84a123db
--- /dev/null
+++ b/engines/gargoyle/fonts.cpp
@@ -0,0 +1,40 @@
+/* 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.
+ *
+ */
+
+#include "gargoyle/fonts.h"
+#include "gargoyle/glk_types.h"
+
+namespace Gargoyle {
+
+FACES Fonts::getId(const Common::String &name) {
+ if (name == "monor") return MONOR;
+ if (name == "monob") return MONOB;
+ if (name == "monoi") return MONOI;
+ if (name == "monoz") return MONOZ;
+ if (name == "propr") return PROPR;
+ if (name == "propb") return PROPB;
+ if (name == "propi") return PROPI;
+ if (name == "propz") return PROPZ;
+ return MONOR;
+}
+
+} // End of namespace Gargoyle
diff --git a/engines/gargoyle/fonts.h b/engines/gargoyle/fonts.h
new file mode 100644
index 0000000000..f2f701a602
--- /dev/null
+++ b/engines/gargoyle/fonts.h
@@ -0,0 +1,45 @@
+/* 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 GARGOYLE_FONTS_H
+#define GARGOYLE_FONTS_H
+
+#include "gargoyle/glk_types.h"
+#include "common/str.h"
+
+namespace Gargoyle {
+
+enum FACES { MONOR, MONOB, MONOI, MONOZ, PROPR, PROPB, PROPI, PROPZ };
+enum TYPES { MONOF, PROPF };
+enum STYLES { FONTR, FONTB, FONTI, FONTZ };
+
+class Fonts {
+public:
+ /**
+ * Get the index/id of a font by name
+ */
+ static FACES getId(const Common::String &name);
+};
+
+} // End of namespace Gargoyle
+
+#endif
diff --git a/engines/gargoyle/gargoyle.cpp b/engines/gargoyle/gargoyle.cpp
index a481ae9624..d3dd35bca0 100644
--- a/engines/gargoyle/gargoyle.cpp
+++ b/engines/gargoyle/gargoyle.cpp
@@ -29,6 +29,7 @@
#include "graphics/scaler.h"
#include "graphics/thumbnail.h"
#include "gargoyle/gargoyle.h"
+#include "gargoyle/conf.h"
#include "gargoyle/events.h"
#include "gargoyle/streams.h"
#include "gargoyle/windows.h"
@@ -36,11 +37,12 @@
namespace Gargoyle {
GargoyleEngine::GargoyleEngine(OSystem *syst, const GargoyleGameDescription *gameDesc) :
- _gameDescription(gameDesc), Engine(syst), _random("Gargoyle"),
+ _gameDescription(gameDesc), Engine(syst), _random("Gargoyle"), _conf(nullptr),
_events(nullptr), _screen(nullptr), _windows(nullptr) {
}
GargoyleEngine::~GargoyleEngine() {
+ delete _conf;
delete _events;
delete _screen;
delete _streams;
diff --git a/engines/gargoyle/gargoyle.h b/engines/gargoyle/gargoyle.h
index e7d5df2ae4..39799d7b60 100644
--- a/engines/gargoyle/gargoyle.h
+++ b/engines/gargoyle/gargoyle.h
@@ -33,6 +33,7 @@
namespace Gargoyle {
+class Conf;
class Events;
class Windows;
class Streams;
@@ -90,6 +91,7 @@ protected:
*/
virtual void runGame(Common::SeekableReadStream *gameFile) = 0;
public:
+ Conf *_conf;
Events *_events;
Streams *_streams;
Windows *_windows;
diff --git a/engines/gargoyle/glk.cpp b/engines/gargoyle/glk.cpp
index b49fb63e66..e81e806ac5 100644
--- a/engines/gargoyle/glk.cpp
+++ b/engines/gargoyle/glk.cpp
@@ -23,6 +23,7 @@
#include "gargoyle/glk.h"
#include "gargoyle/events.h"
#include "gargoyle/streams.h"
+#include "gargoyle/string.h"
#include "gargoyle/windows.h"
namespace Gargoyle {
diff --git a/engines/gargoyle/glk_types.h b/engines/gargoyle/glk_types.h
index c7b505e1d9..b6f0d290f1 100644
--- a/engines/gargoyle/glk_types.h
+++ b/engines/gargoyle/glk_types.h
@@ -219,10 +219,6 @@ enum StyleHint {
stylehint_just_RightFlush = 3,
};
-enum FACES { MONOR, MONOB, MONOI, MONOZ, PROPR, PROPB, PROPI, PROPZ };
-enum TYPES { MONOF, PROPF };
-enum STYLES { FONTR, FONTB, FONTI, FONTZ };
-
#ifdef GLK_MODULE_IMAGE
enum ImageAlign {
diff --git a/engines/gargoyle/module.mk b/engines/gargoyle/module.mk
index 05b7f5ff3a..925c66d359 100644
--- a/engines/gargoyle/module.mk
+++ b/engines/gargoyle/module.mk
@@ -1,12 +1,15 @@
MODULE := engines/gargoyle
MODULE_OBJS := \
+ conf.o \
detection.o \
events.o \
+ fonts.o \
gargoyle.o \
glk.o \
picture.o \
streams.o \
+ string.o \
windows.o \
scott/detection.o \
scott/scott.o
diff --git a/engines/gargoyle/streams.cpp b/engines/gargoyle/streams.cpp
index 62e43e3908..382ce287cf 100644
--- a/engines/gargoyle/streams.cpp
+++ b/engines/gargoyle/streams.cpp
@@ -144,13 +144,4 @@ Stream *Streams::getFirst(uint32 *rock) {
return _streamList;
}
-/*--------------------------------------------------------------------------*/
-
-size_t strlen_uni(const uint32 *s) {
- size_t len = 0;
- while (*s++)
- ++len;
- return len;
-}
-
} // End of namespace Gargoyle
diff --git a/engines/gargoyle/streams.h b/engines/gargoyle/streams.h
index db21d58867..3a80366c0f 100644
--- a/engines/gargoyle/streams.h
+++ b/engines/gargoyle/streams.h
@@ -215,13 +215,6 @@ public:
Stream *getCurrent() const { return _currentStream; }
};
-
-
-/*
- * Get the length of a unicode string
- */
-size_t strlen_uni(const uint32 *s);
-
} // End of namespace Gargoyle
#endif
diff --git a/engines/gargoyle/string.cpp b/engines/gargoyle/string.cpp
new file mode 100644
index 0000000000..4b6897818a
--- /dev/null
+++ b/engines/gargoyle/string.cpp
@@ -0,0 +1,51 @@
+/* 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.
+ *
+ */
+
+#include "gargoyle/conf.h"
+#include "common/textconsole.h"
+
+namespace Gargoyle {
+
+size_t strlen_uni(const uint32 *s) {
+ size_t len = 0;
+ while (*s++)
+ ++len;
+ return len;
+}
+
+int strToInt(const char *s) {
+ if (!*s)
+ // No string at all
+ return 0;
+ else if (toupper(s[strlen(s) - 1]) != 'H')
+ // Standard decimal string
+ return atoi(s);
+
+ // Hexadecimal string
+ uint tmp = 0;
+ int read = sscanf(s, "%xh", &tmp);
+ if (read < 1)
+ error("strToInt failed on string \"%s\"", s);
+ return (int)tmp;
+}
+
+} // End of namespace Gargoyle
diff --git a/engines/gargoyle/string.h b/engines/gargoyle/string.h
new file mode 100644
index 0000000000..2ab2925323
--- /dev/null
+++ b/engines/gargoyle/string.h
@@ -0,0 +1,43 @@
+/* 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 GARGOYLE_STRING_H
+#define GARGOYLE_STRING_H
+
+#include "gargoyle/string.h"
+#include "gargoyle/glk_types.h"
+
+namespace Gargoyle {
+
+/*
+ * Get the length of a unicode string
+ */
+size_t strlen_uni(const uint32 *s);
+
+/**
+ * Converts a decimal or hexadecimal string into a number
+ */
+int strToInt(const char *s);
+
+} // End of namespace Gargoyle
+
+#endif
diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h
index 95f1ed48e1..0eb508894a 100644
--- a/engines/gargoyle/windows.h
+++ b/engines/gargoyle/windows.h
@@ -28,6 +28,7 @@
#include "common/rect.h"
#include "graphics/screen.h"
#include "gargoyle/glk_types.h"
+#include "gargoyle/fonts.h"
#include "gargoyle/picture.h"
#include "gargoyle/streams.h"
@@ -125,7 +126,7 @@ public:
* Window styles
*/
struct WindowStyle {
- int font;
+ FACES font;
byte bg[3];
byte fg[3];
int reverse;