aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-10-20 21:48:22 -0700
committerPaul Gilbert2018-12-08 19:05:59 -0800
commitbbd744ad4731784e13c8e92048a75531300e3fe4 (patch)
tree919c15aec19cac5f52eb14cb50e639b825223ec7
parentef15871fec18060420eddc92a9830f595b8cc970 (diff)
downloadscummvm-rg350-bbd744ad4731784e13c8e92048a75531300e3fe4.tar.gz
scummvm-rg350-bbd744ad4731784e13c8e92048a75531300e3fe4.tar.bz2
scummvm-rg350-bbd744ad4731784e13c8e92048a75531300e3fe4.zip
GLK: Further config loading
-rw-r--r--engines/gargoyle/conf.cpp107
-rw-r--r--engines/gargoyle/conf.h9
-rw-r--r--engines/gargoyle/windows.cpp33
3 files changed, 108 insertions, 41 deletions
diff --git a/engines/gargoyle/conf.cpp b/engines/gargoyle/conf.cpp
index c296254d74..0b8eda8bff 100644
--- a/engines/gargoyle/conf.cpp
+++ b/engines/gargoyle/conf.cpp
@@ -23,6 +23,7 @@
#include "gargoyle/conf.h"
#include "gargoyle/fonts.h"
#include "gargoyle/string.h"
+#include "gargoyle/windows.h"
#include "common/config-manager.h"
namespace Gargoyle {
@@ -32,6 +33,36 @@ const byte BLUE[3] = { 0x00, 0x00, 0x60 };
const byte SCROLL_BG[3] = { 0xb0, 0xb0, 0xb0 };
const byte SCROLL_FG[3] = { 0x80, 0x80, 0x80 };
+WindowStyle T_STYLES[style_NUMSTYLES] = {
+ { PROPR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Normal
+ { PROPI,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Emphasized
+ { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Preformatted
+ { PROPB,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Header
+ { PROPB,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Subheader
+ { PROPZ,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Alert
+ { PROPR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Note
+ { PROPR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< BlockQuote
+ { PROPB,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Input
+ { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< User1
+ { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< User2
+};
+
+WindowStyle G_STYLES[style_NUMSTYLES] = {
+ { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Normal
+ { MONOI,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Emphasized
+ { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Preformatted
+ { MONOB,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Header
+ { MONOB,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Subheader
+ { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Alert
+ { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Note
+ { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< BlockQuote
+ { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Input
+ { MONOR,{ 0x60,0x60,0x60 },{ 0xff,0xff,0xff }, 0 }, ///< User1
+ { MONOR,{ 0x60,0x60,0x60 },{ 0xff,0xff,0xff }, 0 }, ///< User2
+};
+
+Conf *g_conf;
+
Conf::Conf() {
g_conf = this;
@@ -111,6 +142,55 @@ Conf::Conf() {
get("speak_language", _speakLanguage);
get("stylehint", _styleHint, 1);
+ Common::copy(T_STYLES, T_STYLES + style_NUMSTYLES, _tStyles);
+ Common::copy(G_STYLES, G_STYLES + style_NUMSTYLES, _gStyles);
+
+ char buffer[255];
+ const char *const TG_COLOR[2] = { "tcolor", "gcolor" };
+ for (int idx = 0; idx < 2; ++idx) {
+ if (!ConfMan.hasKey(TG_COLOR[idx]))
+ continue;
+
+ strncpy(buffer, ConfMan.get(TG_COLOR[idx]).c_str(), 254);
+ buffer[255] = '\0';
+ char *style = strtok(buffer, "\r\n\t ");
+ char *fg = strtok(nullptr, "\r\n\t ");
+ char *bg = strtok(nullptr, "\r\n\t ");
+
+ int i = atoi(style);
+ if (i < 0 || i >= style_NUMSTYLES)
+ continue;
+
+ if (idx == 0) {
+ parseColor(fg, _tStyles[i].fg);
+ parseColor(bg, _tStyles[i].bg);
+ } else {
+ parseColor(fg, _gStyles[i].fg);
+ parseColor(bg, _gStyles[i].bg);
+ }
+ }
+
+ const char *const TG_FONT[2] = { "tfont", "gfont" };
+ for (int idx = 0; idx < 2; ++idx) {
+ if (!ConfMan.hasKey(TG_FONT[idx]))
+ continue;
+
+ strncpy(buffer, ConfMan.get(TG_FONT[idx]).c_str(), 254);
+ buffer[255] = '\0';
+ char *style = strtok(buffer, "\r\n\t ");
+ char *font = strtok(nullptr, "\r\n\t ");
+ int i = atoi(style);
+ if (i < 0 || i >= style_NUMSTYLES)
+ continue;
+
+ if (idx == 0)
+ _tStyles[i].font = Fonts::getId(font);
+ else
+ _gStyles[i].font = Fonts::getId(font);
+ }
+
+ Common::copy(_tStyles, _tStyles + style_NUMSTYLES, _tStylesDefault);
+ Common::copy(_gStyles, _gStyles + style_NUMSTYLES, _gStylesDefault);
}
void Conf::get(const Common::String &key, Common::String &field, const char *defaultVal) {
@@ -119,17 +199,8 @@ void Conf::get(const Common::String &key, Common::String &field, const char *def
}
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);
+ if (ConfMan.hasKey(key)) {
+ parseColor(ConfMan.get(key), color);
} else if (defaultColor) {
Common::copy(defaultColor, defaultColor + 3, color);
} else {
@@ -149,4 +220,18 @@ void Conf::get(const Common::String &key, double &field, double defaultVal) {
field = ConfMan.hasKey(key) ? atof(ConfMan.get(key).c_str()) : defaultVal;
}
+void Conf::parseColor(const Common::String &str, byte *color) {
+ char r[3], g[3], b[3];
+
+ if (str.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);
+ }
+}
+
} // End of namespace Gargoyle
diff --git a/engines/gargoyle/conf.h b/engines/gargoyle/conf.h
index 2dbb29f44c..c63cdc025a 100644
--- a/engines/gargoyle/conf.h
+++ b/engines/gargoyle/conf.h
@@ -25,6 +25,7 @@
#include "gargoyle/glk_types.h"
#include "gargoyle/fonts.h"
+#include "gargoyle/windows.h"
namespace Gargoyle {
@@ -55,6 +56,10 @@ private:
*/
void get(const Common::String &key, double &field, double defaultVal = 0.0);
+ /**
+ * Parse a color
+ */
+ void parseColor(const Common::String &str, byte *color);
public:
Common::String _morePrompt;
byte _moreColor[3], _moreSave[3];
@@ -104,6 +109,10 @@ public:
int _speakInput;
Common::String _speakLanguage;
int _styleHint;
+ WindowStyle _tStyles[style_NUMSTYLES];
+ WindowStyle _gStyles[style_NUMSTYLES];
+ WindowStyle _tStylesDefault[style_NUMSTYLES];
+ WindowStyle _gStylesDefault[style_NUMSTYLES];
public:
/**
* Constructor
diff --git a/engines/gargoyle/windows.cpp b/engines/gargoyle/windows.cpp
index 2c8680b45d..edea1abb5d 100644
--- a/engines/gargoyle/windows.cpp
+++ b/engines/gargoyle/windows.cpp
@@ -21,6 +21,7 @@
*/
#include "gargoyle/windows.h"
+#include "gargoyle/conf.h"
#include "gargoyle/gargoyle.h"
#include "gargoyle/streams.h"
#include "common/algorithm.h"
@@ -59,34 +60,6 @@ int Windows::_overrideFgVal;
int Windows::_overrideBgVal;
-WindowStyle T_STYLES[style_NUMSTYLES] = {
- { PROPR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Normal
- { PROPI,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Emphasized
- { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Preformatted
- { PROPB,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Header
- { PROPB,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Subheader
- { PROPZ,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Alert
- { PROPR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Note
- { PROPR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< BlockQuote
- { PROPB,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Input
- { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< User1
- { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< User2
-};
-
-WindowStyle G_STYLES[style_NUMSTYLES] = {
- { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Normal
- { MONOI,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Emphasized
- { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Preformatted
- { MONOB,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Header
- { MONOB,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Subheader
- { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Alert
- { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Note
- { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< BlockQuote
- { MONOR,{ 0xff,0xff,0xff },{ 0x00,0x00,0x00 }, 0 }, ///< Input
- { MONOR,{ 0x60,0x60,0x60 },{ 0xff,0xff,0xff }, 0 }, ///< User1
- { MONOR,{ 0x60,0x60,0x60 },{ 0xff,0xff,0xff }, 0 }, ///< User2
-};
-
/*--------------------------------------------------------------------------*/
Windows::Windows(GargoyleEngine *engine, Graphics::Screen *screen) :
@@ -330,7 +303,7 @@ TextGridWindow::TextGridWindow(Windows *windows, uint32 rock) : Window(windows,
inarrayrock.num = 0;
line_terminators = nullptr;
- Common::copy(&G_STYLES[0], &G_STYLES[style_NUMSTYLES], styles);
+ Common::copy(&g_conf->_gStyles[0], &g_conf->_gStyles[style_NUMSTYLES], styles);
}
void TextGridWindow::rearrange(const Common::Rect &box) {
@@ -381,7 +354,7 @@ TextBufferWindow::TextBufferWindow(Windows *windows, uint32 rock) : Window(windo
_type = wintype_TextBuffer;
Common::fill(&history[0], &history[HISTORYLEN], nullptr);
- Common::copy(&T_STYLES[0], &T_STYLES[style_NUMSTYLES], styles);
+ Common::copy(&g_conf->_tStyles[0], &g_conf->_tStyles[style_NUMSTYLES], styles);
}
void TextBufferWindow::rearrange(const Common::Rect &box) {