aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-11-09 20:04:08 -0800
committerPaul Gilbert2018-12-08 19:05:59 -0800
commit671321c45fb52163022b51e4e128a02ec66dc28d (patch)
treec57032db662356d650c590e2eaa792697d554186
parentf73d56f6bab4ca2642790cb8429b9fee3d5d2006 (diff)
downloadscummvm-rg350-671321c45fb52163022b51e4e128a02ec66dc28d.tar.gz
scummvm-rg350-671321c45fb52163022b51e4e128a02ec66dc28d.tar.bz2
scummvm-rg350-671321c45fb52163022b51e4e128a02ec66dc28d.zip
GLK: Fix loading of font colors and styles from configuration
-rw-r--r--engines/gargoyle/conf.cpp73
1 files changed, 35 insertions, 38 deletions
diff --git a/engines/gargoyle/conf.cpp b/engines/gargoyle/conf.cpp
index 98af236323..7add133cba 100644
--- a/engines/gargoyle/conf.cpp
+++ b/engines/gargoyle/conf.cpp
@@ -156,47 +156,44 @@ Conf::Conf() {
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_COLOR[2] = { "tcolor_%d", "gcolor_%d" };
+ for (int tg = 0; tg < 2; ++tg) {
+ for (int style = 0; style <= 10; ++style) {
+ Common::String key = Common::String::format(TG_COLOR[tg], style);
+ if (!ConfMan.hasKey(key))
+ continue;
+
+ strncpy(buffer, ConfMan.get(key).c_str(), 254);
+ buffer[255] = '\0';
+ char *fg = strtok(buffer, "\r\n\t ");
+ char *bg = strtok(nullptr, "\r\n\t ");
+
+ if (tg == 0) {
+ parseColor(fg, _tStyles[style].fg);
+ parseColor(bg, _tStyles[style].bg);
+ } else {
+ parseColor(fg, _gStyles[style].fg);
+ parseColor(bg, _gStyles[style].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);
+ const char *const TG_FONT[2] = { "tfont_%d", "gfont_%d" };
+ for (int tg = 0; tg < 2; ++tg) {
+ for (int style = 0; style <= 10; ++style) {
+ Common::String key = Common::String::format(TG_FONT[tg], style);
+ if (!ConfMan.hasKey(key))
+ continue;
+
+ strncpy(buffer, ConfMan.get(key).c_str(), 254);
+ buffer[255] = '\0';
+ char *font = strtok(buffer, "\r\n\t ");
+
+ if (tg == 0)
+ _tStyles[style].font = Fonts::getId(font);
+ else
+ _gStyles[style].font = Fonts::getId(font);
+ }
}
Common::copy(_tStyles, _tStyles + style_NUMSTYLES, _tStylesDefault);