[Scummvm-git-logs] scummvm master -> b27b32d5973baa966e8db1b250c8c69bfe1c4d25
sev-
noreply at scummvm.org
Fri Apr 3 16:12:46 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
b27b32d597 GLK: Expose GUI options
Commit: b27b32d5973baa966e8db1b250c8c69bfe1c4d25
https://github.com/scummvm/scummvm/commit/b27b32d5973baa966e8db1b250c8c69bfe1c4d25
Author: Priyanshu (10b.priyanshu at gmail.com)
Date: 2026-04-03T18:12:40+02:00
Commit Message:
GLK: Expose GUI options
Changed paths:
A engines/glk/dialogs.cpp
A engines/glk/dialogs.h
engines/glk/POTFILES
engines/glk/conf.cpp
engines/glk/conf.h
engines/glk/glk.cpp
engines/glk/metaengine.cpp
engines/glk/module.mk
engines/glk/screen.cpp
engines/glk/streams.cpp
engines/glk/window_text_buffer.cpp
engines/glk/window_text_buffer.h
engines/glk/window_text_grid.cpp
engines/glk/window_text_grid.h
engines/glk/windows.cpp
engines/glk/windows.h
gui/themes/common/highres_layout.stx
gui/themes/common/lowres_layout.stx
diff --git a/engines/glk/POTFILES b/engines/glk/POTFILES
index 1c78f7f773c..1dc9ce96c2c 100644
--- a/engines/glk/POTFILES
+++ b/engines/glk/POTFILES
@@ -7,6 +7,7 @@ engines/glk/advsys/advsys.cpp
engines/glk/advsys/vm.cpp
engines/glk/alan2/alan2.cpp
engines/glk/comprehend/game.cpp
+engines/glk/dialogs.cpp
engines/glk/glulx/glulx.cpp
engines/glk/magnetic/magnetic.cpp
engines/glk/quest/quest.cpp
diff --git a/engines/glk/conf.cpp b/engines/glk/conf.cpp
index 74482ca5a33..5d258de1c75 100644
--- a/engines/glk/conf.cpp
+++ b/engines/glk/conf.cpp
@@ -77,6 +77,7 @@ Conf::Conf(InterpreterType interpType) : _interpType(interpType), _graphics(true
_wBorderX(0), _wBorderY(0), _tMarginX(7), _tMarginY(7), _gamma(1.0),
_borderColor(0), _borderSave(0),
_windowColor(parseColor(WHITE)), _windowSave(parseColor(WHITE)),
+ _windowColorOverride(false),
_sound(true), _speak(false), _speakInput(false), _styleHint(1),
_scrollBg(parseColor(SCROLL_BG)), _scrollFg(parseColor(SCROLL_FG)),
_scrollWidth(0), _safeClicks(false) {
@@ -192,9 +193,25 @@ void Conf::synchronize() {
syncAsColor("bordercolor", _borderColor);
syncAsColor("bordercolor", _borderSave);
+ syncAsBool("bordercolor_override", _borderColorOverride);
+
+ if (_isLoading && !_borderColorOverride && _borderColor != parseColor(WHITE))
+ _borderColorOverride = true;
+
+ if (_borderColorOverride)
+ Windows::_overrideBgSet = true;
+
+ syncAsBool("windowcolor_override", _windowColorOverride);
syncAsColor("windowcolor", _windowColor);
syncAsColor("windowcolor", _windowSave);
+ // if we read a colour but no explicit override flag was present, pretend the user meant to force that colour.
+ if (_isLoading && !_windowColorOverride && _windowColor != parseColor(WHITE))
+ _windowColorOverride = true;
+
+ if (_windowColorOverride)
+ Windows::_overrideBgSet = true;
+
syncAsColor("caretcolor", _propInfo._caretColor);
syncAsInt("caretshape", _propInfo._caretShape);
syncAsInt("linkstyle", _propInfo._linkStyle);
diff --git a/engines/glk/conf.h b/engines/glk/conf.h
index 85aca3ab2f0..3e0d3f85627 100644
--- a/engines/glk/conf.h
+++ b/engines/glk/conf.h
@@ -90,6 +90,8 @@ public:
double _gamma;
uint _borderColor, _borderSave;
uint _windowColor, _windowSave;
+ bool _windowColorOverride;
+ bool _borderColorOverride;
int _scrollWidth;
uint _scrollBg, _scrollFg;
bool _graphics;
diff --git a/engines/glk/dialogs.cpp b/engines/glk/dialogs.cpp
new file mode 100644
index 00000000000..c7d022eb7fd
--- /dev/null
+++ b/engines/glk/dialogs.cpp
@@ -0,0 +1,1329 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "glk/glk.h"
+#include "glk/dialogs.h"
+
+#include "gui/ThemeEval.h"
+#include "gui/gui-manager.h"
+#include "gui/message.h"
+#include "gui/saveload.h"
+#include "gui/ThemeEngine.h"
+#include "gui/widget.h"
+#include "gui/widgets/list.h"
+#include "gui/widgets/popup.h"
+
+#include "glk/conf.h"
+#include "glk/fonts.h"
+#include "glk/screen.h"
+#include "glk/streams.h"
+#include "glk/windows.h"
+#include "glk/window_text_buffer.h"
+#include "glk/window_text_grid.h"
+
+#include "common/system.h"
+#include "common/translation.h"
+
+#define NEW_LABEL(name, text, tooltip) \
+ do { \
+ auto label = new GUI::StaticTextWidget(widgetsBoss(), name, _(text), _(tooltip)); \
+ label->setAlign(Graphics::kTextAlignRight); \
+ } while (0)
+
+#define NEW_EDIT(widget, name) \
+ widget = new GUI::EditTextWidget(widgetsBoss(), name, Common::U32String())
+
+#define NEW_CHECKBOX(widget, name) \
+ widget = new GUI::CheckboxWidget(widgetsBoss(), name, Common::U32String())
+
+#define NEW_POPUP(widget, name) \
+ widget = new GUI::PopUpWidget(widgetsBoss(), name)
+
+#define NEW_EDIT_CMD(widget, name, cmd) \
+ widget = new GUI::EditTextWidget(widgetsBoss(), name, Common::U32String(), Common::U32String(), cmd, cmd)
+
+#define NEW_POPUP_CMD(widget, name, cmd) \
+ widget = new GUI::PopUpWidget(widgetsBoss(), name, Common::U32String(), cmd)
+
+#define INIT_NUM(widget, configMember) \
+ if (g_conf && widget) \
+ widget->setEditString(Common::U32String(Common::String::format("%d", g_conf->configMember)))
+
+#define INIT_INT(widget, configMember) \
+ if (g_conf && widget) \
+ widget->setEditString(Common::U32String(Common::String::format("%d", configMember)))
+
+#define INIT_STRING(widget, configExpression) \
+ if (g_conf && widget) \
+ widget->setEditString(Common::U32String(configExpression))
+
+#define INIT_BOOL(widget, configMember) \
+ if (g_conf && widget) \
+ widget->setState(configMember)
+
+#define INIT_POPUP(widget, configValue) \
+ if (g_conf && widget) \
+ widget->setSelectedTag(configValue)
+
+#define INIT_FLOAT(widget, configMember) \
+ if (g_conf && widget) \
+ widget->setEditString(Common::U32String(Common::String::format("%g", configMember)))
+
+namespace Glk {
+
+struct GlkColor {
+ const char *name;
+ unsigned int rgb;
+};
+
+static const GlkColor GLK_COLORS[] = {
+ { "white", 0xFFFFFF },
+ { "green", 0x00FF00 },
+ { "red", 0xFF0000 },
+ { "blue", 0x0000FF },
+ { "black", 0x000000 },
+ { "grey", 0x808080 }
+};
+
+struct BoolOption {
+ GUI::CheckboxWidget *widget;
+ int *targetInt;
+ bool *targetBool;
+ const char *confKey;
+};
+
+struct IntOption {
+ GUI::EditTextWidget *widget;
+ int *target;
+ const char *confKey;
+ int minValue;
+};
+
+struct FloatOption {
+ GUI::EditTextWidget *widget;
+ double *target;
+ const char *confKey;
+ double minValue;
+};
+
+struct ColorOption {
+ GUI::PopUpWidget *popup;
+ GUI::EditTextWidget *hexInput;
+ WindowStyle *styles; // for t/g/w/b
+ PropFontInfo *propInfo; // for caret/link/more
+ const char *confKey;
+ bool isProp; // true for caret/link/more
+};
+
+struct FontOption {
+ GUI::PopUpWidget *popup;
+ WindowStyle *styles;
+ const char *confKeyPrefix;
+};
+
+static GUI::StaticTextWidget *createHeading(GUI::GuiObject *boss, const char *id, const char *text) {
+ auto h = new GUI::StaticTextWidget(boss, id, _(text));
+ h->setAlign(Graphics::kTextAlignCenter);
+ return h;
+}
+
+GlkOptionsWidget::GlkOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain)
+ : GUI::OptionsContainerWidget(boss, name, "GlkOptionsDialog", domain) {
+
+ static const char *fontLabels[] = { "Monospace Regular", "Monospace Bold", "Monospace Italic", "Monospace Bold Italic", "Proportional Regular", "Proportional Bold", "Proportional Italic", "Proportional Bold Italic" };
+
+ for (int f = MONOR; f <= PROPZ; ++f) {
+ _tfontPopUps[f] = nullptr;
+ _gfontPopUps[f] = nullptr;
+ }
+
+ _fontHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.FontHeading", "Font");
+
+ NEW_POPUP(_tfontPopUps[0], "GlkOptionsDialog.TFont0");
+ NEW_LABEL("GlkOptionsDialog.TFont", "Text:", "");
+ for (int f = MONOR; f <= PROPZ; ++f)
+ _tfontPopUps[0]->appendEntry(fontLabels[f], f);
+
+ NEW_POPUP(_gfontPopUps[0], "GlkOptionsDialog.GFont0");
+ NEW_LABEL("GlkOptionsDialog.GFont", "Grid:", "Font for drawn graphics like maps, diagrams, puzzles, etc");
+ for (int f = MONOR; f <= PROPZ; ++f)
+ _gfontPopUps[0]->appendEntry(fontLabels[f], f);
+
+ _colorHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.ColorHeading", "Color");
+
+ NEW_LABEL("GlkOptionsDialog.THexPrefix", "0x", "");
+ NEW_EDIT_CMD(_manualTColorHexInput, "GlkOptionsDialog.THex", kTHexChangedCmd);
+ NEW_POPUP_CMD(_tcolorPopUps[0], "GlkOptionsDialog.TColor0", kTColorChangedCmd);
+ NEW_LABEL("GlkOptionsDialog.TColor", "Text:", "Color of the interactive text");
+ for (int c = 0; c <= 5; ++c)
+ _tcolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _tcolorPopUps[0]->appendEntry("Custom", 6);
+
+ NEW_LABEL("GlkOptionsDialog.GHexPrefix", "0x", "");
+ NEW_EDIT_CMD(_manualGColorHexInput, "GlkOptionsDialog.GHex", kGHexChangedCmd);
+ NEW_POPUP_CMD(_gcolorPopUps[0], "GlkOptionsDialog.GColor0", kGColorChangedCmd);
+ NEW_LABEL("GlkOptionsDialog.GColor", "Grid:", "Color for drawn graphics such as maps, diagrams, puzzles, etc");
+ for (int c = 0; c <= 5; ++c)
+ _gcolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _gcolorPopUps[0]->appendEntry("Custom", 6);
+
+ NEW_LABEL("GlkOptionsDialog.WHexPrefix", "0x", "");
+ NEW_EDIT_CMD(_manualWColorHexInput, "GlkOptionsDialog.WHex", kWHexChangedCmd);
+ NEW_POPUP_CMD(_wcolorPopUps[0], "GlkOptionsDialog.WColor0", kWColorChangedCmd);
+ NEW_LABEL("GlkOptionsDialog.WColor", "Window:", "Color of the window(background)");
+ _wcolorPopUps[0]->appendEntry("Game default", 7);
+ for (int c = 0; c <= 5; ++c)
+ _wcolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _wcolorPopUps[0]->appendEntry("Custom", 6);
+
+ NEW_LABEL("GlkOptionsDialog.BHexPrefix", "0x", "");
+ NEW_EDIT_CMD(_manualBColorHexInput, "GlkOptionsDialog.BHex", kBHexChangedCmd);
+ NEW_POPUP_CMD(_bcolorPopUps[0], "GlkOptionsDialog.BColor0", kBColorChangedCmd);
+ NEW_LABEL("GlkOptionsDialog.BColor", "Border:", "Color of the window border");
+ _bcolorPopUps[0]->appendEntry("Game default", 7);
+ for (int c = 0; c <= 5; ++c)
+ _bcolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _bcolorPopUps[0]->appendEntry("Custom", 6);
+
+ _borderHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.wborderlbl", "Border");
+
+ NEW_LABEL("GlkOptionsDialog.wborderx", "Horizontal:", "");
+ NEW_EDIT(_wborderx, "GlkOptionsDialog.wborderhorizontal");
+ NEW_LABEL("GlkOptionsDialog.wbordery", "Vertical:", "");
+ NEW_EDIT(_wbordery, "GlkOptionsDialog.wbordervertical");
+
+ NEW_LABEL("GlkOptionsDialog.CHexPrefix", "0x", "");
+ NEW_EDIT_CMD(_manualCColorHexInput, "GlkOptionsDialog.CHex", kCHexChangedCmd);
+ NEW_POPUP_CMD(_ccolorPopUps[0], "GlkOptionsDialog.CColor0", kCColorChangedCmd);
+ NEW_LABEL("GlkOptionsDialog.CColor", "Caret:", "Color of the cursor.");
+ _ccolorPopUps[0]->appendEntry("Game default", 7);
+ for (int c = 0; c <= 5; ++c)
+ _ccolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _ccolorPopUps[0]->appendEntry("Custom", 6);
+
+ NEW_LABEL("GlkOptionsDialog.LHexPrefix", "0x", "");
+ NEW_EDIT_CMD(_manualLColorHexInput, "GlkOptionsDialog.LHex", kLHexChangedCmd);
+ NEW_POPUP_CMD(_lcolorPopUps[0], "GlkOptionsDialog.LColor0", kLColorChangedCmd);
+ NEW_LABEL("GlkOptionsDialog.LColor", "Link:", "Color for URLs if they appear in-game");
+ _lcolorPopUps[0]->appendEntry("Game default", 7);
+ for (int c = 0; c <= 5; ++c)
+ _lcolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _lcolorPopUps[0]->appendEntry("Custom", 6);
+
+ NEW_LABEL("GlkOptionsDialog.MHexPrefix", "0x", "");
+ NEW_EDIT_CMD(_manualMColorHexInput, "GlkOptionsDialog.MHex", kMHexChangedCmd);
+ NEW_POPUP_CMD(_mcolorPopUps[0], "GlkOptionsDialog.MColor0", kMColorChangedCmd);
+ NEW_LABEL("GlkOptionsDialog.MColor", "More:", "Color for the \"More...\" markers in the text");
+ _mcolorPopUps[0]->appendEntry("Game default", 7);
+ for (int c = 0; c <= 5; ++c)
+ _mcolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _mcolorPopUps[0]->appendEntry("Custom", 6);
+
+ _typographyHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.topographyheadinglbl", "Typography");
+
+ NEW_LABEL("GlkOptionsDialog.linkstyle", "Link style:", "Style for URLs if they appear in-game");
+ NEW_EDIT(_linkStyle, "GlkOptionsDialog.linkStyle");
+ NEW_LABEL("GlkOptionsDialog.caretshape", "Caret shape:", "Shape of the cursor");
+ NEW_EDIT(_caretShape, "GlkOptionsDialog.caretShape");
+ NEW_LABEL("GlkOptionsDialog.moreprompt", "More prompt:", "Custom marker in place of the \"More...\" marker");
+ NEW_EDIT(_morePrompt, "GlkOptionsDialog.morePrompt");
+
+ NEW_LABEL("GlkOptionsDialog.stylehintlabel", "Style hints:", "Let the game suggest text styling options");
+ NEW_CHECKBOX(_styleHint, "GlkOptionsDialog.stylehint");
+ NEW_LABEL("GlkOptionsDialog.safeclickslabel", "Safe clicks:", "Safely apply clicks while input is pending.");
+ NEW_CHECKBOX(_safeClicks, "GlkOptionsDialog.safeclicks");
+
+ NEW_LABEL("GlkOptionsDialog.colslbl", "Column count:", "Number of columns.");
+ NEW_EDIT(_cols, "GlkOptionsDialog.cols");
+ NEW_LABEL("GlkOptionsDialog.rowslbl", "Rows count:", "Number of rows.");
+ NEW_EDIT(_rows, "GlkOptionsDialog.rows");
+
+ NEW_LABEL("GlkOptionsDialog.lockcolslbl", "Lock columns:", "Set it to 1 to manually change the column count.");
+ NEW_CHECKBOX(_lockcols, "GlkOptionsDialog.lockcols");
+ NEW_LABEL("GlkOptionsDialog.lockrowslbl", "Lock rows:", "Set it to 1 to manually change the row count.");
+ NEW_CHECKBOX(_lockrows, "GlkOptionsDialog.lockrows");
+
+ NEW_LABEL("GlkOptionsDialog.justifylbl", "Justify:", "Enable text justification.");
+ NEW_CHECKBOX(_justify, "GlkOptionsDialog.justify");
+
+ NEW_LABEL("GlkOptionsDialog.quoteslbl", "Typographic quotes:", "Choose typographic quotes.");
+ NEW_POPUP(_quotes, "GlkOptionsDialog.quotes");
+ _quotes->appendEntry(_("Off"), 0);
+ _quotes->appendEntry(_("Normal"), 1);
+ _quotes->appendEntry(_("Rabid"), 2);
+
+ NEW_LABEL("GlkOptionsDialog.capslbl", "Caps:", "Force uppercase input.");
+ NEW_CHECKBOX(_caps, "GlkOptionsDialog.caps");
+
+ NEW_LABEL("GlkOptionsDialog.dasheslbl", "Dashes:", "Types of dashes");
+ NEW_POPUP(_dashes, "GlkOptionsDialog.dashes");
+ _dashes->appendEntry(_("Off"), 0);
+ _dashes->appendEntry(_("Em dashes"), 1);
+ _dashes->appendEntry(_("En+Em dashes"), 2);
+
+ _userExperiencelbl = createHeading(widgetsBoss(), "GlkOptionsDialog.userexplbl", "User experience");
+
+ NEW_LABEL("GlkOptionsDialog.spaceslbl", "Spaces:", "Types of spaces");
+ NEW_POPUP(_spaces, "GlkOptionsDialog.spaces");
+ _spaces->appendEntry(_("Off"), 0);
+ _spaces->appendEntry(_("Compress double spaces"), 1);
+ _spaces->appendEntry(_("Expand single spaces"), 2);
+
+ NEW_LABEL("GlkOptionsDialog.graphicslbl", "Graphics:", "Turn graphics on/off.");
+ NEW_CHECKBOX(_graphics, "GlkOptionsDialog.graphics");
+
+ _wmarginHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.WindowMarginHeading", "Window margin");
+ NEW_LABEL("GlkOptionsDialog.wmarginxlbl", "Horizontal:", "Horizontal margin");
+ NEW_EDIT(_wmarginx, "GlkOptionsDialog.wmarginx");
+ NEW_LABEL("GlkOptionsDialog.wmarginylbl", "Vertical:", "Vertical margin");
+ NEW_EDIT(_wmarginy, "GlkOptionsDialog.wmarginy");
+
+ _wpaddingHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.wpaddinglbl", "Window padding");
+ NEW_LABEL("GlkOptionsDialog.wpaddingxlbl", "Horizontal:", "Horizontal padding");
+ NEW_EDIT(_wpaddingx, "GlkOptionsDialog.wpaddingx");
+ NEW_LABEL("GlkOptionsDialog.wpaddingylbl", "Vertical:", "Vertical padding");
+ NEW_EDIT(_wpaddingy, "GlkOptionsDialog.wpaddingy");
+
+ _tmarginHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.tmarginlbl", "Text margin");
+ NEW_LABEL("GlkOptionsDialog.tmarginxlbl", "Horizontal:", "Horizontal margin for text");
+ NEW_EDIT(_tmarginx, "GlkOptionsDialog.tmarginx");
+ NEW_LABEL("GlkOptionsDialog.tmarginylbl", "Vertical:", "Vertical margin for text");
+ NEW_EDIT(_tmarginy, "GlkOptionsDialog.tmarginy");
+
+ NEW_LABEL("GlkOptionsDialog.leadinglbl", "Leading:", "Vertical distance between text rows");
+ NEW_EDIT(_leading, "GlkOptionsDialog.leading");
+ NEW_LABEL("GlkOptionsDialog.baselinelbl", "Baseline:", "Invisible horizontal line on which text sits");
+ NEW_EDIT(_baseline, "GlkOptionsDialog.baseline");
+
+ NEW_LABEL("GlkOptionsDialog.monosizelbl", "Monosize:", "Font size scaling for the monospace text font");
+ NEW_EDIT(_monosize, "GlkOptionsDialog.monosize");
+ NEW_LABEL("GlkOptionsDialog.propsizelbl", "Propsize:", "Font size scaling for the proportional text font");
+ NEW_EDIT(_propsize, "GlkOptionsDialog.propsize");
+
+ _moreHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.morelbl", "More");
+ NEW_LABEL("GlkOptionsDialog.morealignlbl", "Align:", "Alignment of the \"More...\" marker on the window");
+ NEW_POPUP(_morealign, "GlkOptionsDialog.morealign");
+ _morealign->appendEntry(_("Left"), 0);
+ _morealign->appendEntry(_("Centre"), 1);
+ _morealign->appendEntry(_("Right"), 2);
+
+ NEW_POPUP(_morefont, "GlkOptionsDialog.morefont");
+ NEW_LABEL("GlkOptionsDialog.morefontlbl", "Font:", "Font for the \"More...\" marker");
+ for (int f = MONOR; f <= PROPZ; ++f)
+ _morefont->appendEntry(fontLabels[f], f);
+
+}
+
+GlkOptionsWidget::~GlkOptionsWidget() = default;
+
+void GlkOptionsWidget::reflowLayout() {
+ GUI::OptionsContainerWidget::reflowLayout();
+ layoutHeadings();
+}
+
+void GlkOptionsWidget::layoutHeadings() {
+
+ int16 containerX = 0, containerY = 0, containerW = 0, containerH = 0;
+ bool useRTL = false;
+ if (!g_gui.xmlEval()->getWidgetData("GlkOptionsDialog", containerX, containerY, containerW, containerH, useRTL))
+ return;
+
+ if (containerW <= 0)
+ return;
+
+ struct HeadingX {
+ GUI::StaticTextWidget *widget;
+ int16 *xOut;
+ int16 *wOut;
+ };
+
+ int16 fontX, colorX, borderX, wmarginX, tmarginX, wpaddingX, moreX, typographyX, userexpX;
+ int16 fontW, colorW, borderW, wmarginW, tmarginW, wpaddingW, moreW, typographyW, userexpW;
+
+ HeadingX headingXPos[] = {
+ { _fontHeadinglbl, &fontX, &fontW },
+ { _colorHeadinglbl, &colorX, &colorW },
+ { _borderHeadinglbl, &borderX, &borderW },
+ { _wmarginHeadinglbl, &wmarginX, &wmarginW },
+ { _tmarginHeadinglbl, &tmarginX, &tmarginW },
+ { _wpaddingHeadinglbl, &wpaddingX, &wpaddingW },
+ { _moreHeadinglbl, &moreX, &moreW },
+ { _typographyHeadinglbl, &typographyX, &typographyW },
+ { _userExperiencelbl, &userexpX, &userexpW }
+ };
+
+ for (auto &h : headingXPos) {
+ int w = MIN<int>(h.widget->getWidth(), containerW);
+ int x = containerX + (containerW - w) / 2;
+ *(h.wOut) = w;
+ *(h.xOut) = x;
+ }
+
+ struct HeadingY {
+ const char *rowWidgetName;
+ GUI::StaticTextWidget *heading;
+ int16 *yOut;
+ int16 *rowYOut;
+ int16 extraOffset;
+ };
+
+ int16 fontY, colorY, borderY, wmarginY, tmarginY, wpaddingY, moreY, typographyY, userexpY;
+ int16 fontRowY, colorRowY, borderRowY, wmarginRowY, tmarginRowY, wpaddingRowY, moreRowY, typographyRowY, userexpRowY;
+
+ int16 headingOffset = g_gui.xmlEval()->getVar("GlkOptionsDialog.HeadingVerticalOffset", 50);
+ int16 headingMinGap = g_gui.xmlEval()->getVar("GlkOptionsDialog.HeadingMinGap", 2);
+
+ HeadingY headingYpos[] = {
+ { "GlkOptionsDialog.TFont0", _fontHeadinglbl, &fontY, &fontRowY, headingOffset },
+ { "GlkOptionsDialog.TColor0", _colorHeadinglbl, &colorY, &colorRowY, 0 },
+ { "GlkOptionsDialog.linkStyle", _typographyHeadinglbl, &typographyY, &typographyRowY, 0 },
+ { "GlkOptionsDialog.wborderx", _borderHeadinglbl, &borderY, &borderRowY, 0 },
+ { "GlkOptionsDialog.wmarginy", _wmarginHeadinglbl, &wmarginY, &wmarginRowY, 0 },
+ { "GlkOptionsDialog.tmarginx", _tmarginHeadinglbl, &tmarginY, &tmarginRowY, 0 },
+ { "GlkOptionsDialog.wpaddingx", _wpaddingHeadinglbl, &wpaddingY, &wpaddingRowY, 0 },
+ { "GlkOptionsDialog.morealign", _moreHeadinglbl, &moreY, &moreRowY, 0 },
+ { "GlkOptionsDialog.stylehintlabel", _userExperiencelbl, &userexpY, &userexpRowY, 0 }
+ };
+
+ int spacing = g_gui.xmlEval()->getVar("Globals.Line.Height", 16) / 2;
+
+ for (auto &h : headingYpos) {
+ int16 tmpX = 0, tmpW = 0, tmpH = 0;
+ if (g_gui.xmlEval()->getWidgetData(h.rowWidgetName, tmpX, *h.rowYOut, tmpW, tmpH, useRTL))
+ *h.yOut = *h.rowYOut - h.heading->getHeight() - spacing + h.extraOffset;
+ }
+
+ if (fontY + _fontHeadinglbl->getHeight() + headingMinGap >= colorY)
+ fontY = colorY - _fontHeadinglbl->getHeight() - headingMinGap;
+
+ struct HeadingResize {
+ GUI::StaticTextWidget *widget;
+ int16 *x;
+ int16 *y;
+ int16 *w;
+ };
+
+ HeadingResize headingResize[] = {
+ { _fontHeadinglbl, &fontX, &fontY, &fontW },
+ { _colorHeadinglbl, &colorX, &colorY, &colorW },
+ { _typographyHeadinglbl, &typographyX, &typographyY, &typographyW },
+ { _borderHeadinglbl, &borderX, &borderY, &borderW },
+ { _wmarginHeadinglbl, &wmarginX, &wmarginY, &wmarginW },
+ { _tmarginHeadinglbl, &tmarginX, &tmarginY, &tmarginW },
+ { _moreHeadinglbl, &moreX, &moreY, &moreW },
+ { _wpaddingHeadinglbl, &wpaddingX, &wpaddingY, &wpaddingW },
+ { _userExperiencelbl, &userexpX, &userexpY, &userexpW },
+ };
+
+ for (auto &h : headingResize)
+ h.widget->resize(*h.x, *h.y, *h.w, h.widget->getHeight(), false);
+}
+
+static void setFontPopUp(GUI::PopUpWidget *popup, bool hasConf, FACES font, const char *settingName, const Common::String &domain) {
+
+ if (hasConf)
+ popup->setSelectedTag(font);
+ else
+ popup->setSelectedTag(Screen::getFontId(ConfMan.get(settingName, domain)));
+}
+
+static void setSimpleColorPopUp(GUI::PopUpWidget *popup, GUI::EditTextWidget *hexInput, bool hasConf, const char *confKey, const char *themeKey, const Common::String &domain, bool overrideEnabled, int defaultValue = 7) {
+
+ if (hasConf) {
+ if (!overrideEnabled) {
+ popup->setSelectedTag(defaultValue);
+ hexInput->setEditString(Common::U32String());
+ return;
+ }
+ Common::String colorStr = ConfMan.get(confKey, domain);
+ Common::String hexPart = colorStr.substr(0, 6);
+ hexInput->setEditString(Common::U32String(hexPart));
+
+ unsigned int rgb;
+ sscanf(hexPart.c_str(), "%x", &rgb);
+ bool found = false;
+
+ for (int i = 0; i <= 5; ++i) {
+ if (GLK_COLORS[i].rgb == rgb) {
+ popup->setSelectedTag(i);
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ popup->setSelectedTag(6);
+ } else {
+ popup->setSelectedTag((uint32)GUI::ListWidget::getThemeColor(ConfMan.get(themeKey, domain)));
+ }
+}
+
+void GlkOptionsWidget::load() {
+
+ BoolOption boolOptions[] = {
+ { _safeClicks, nullptr, &g_conf->_safeClicks, "safeclicks" },
+ { _styleHint, &g_conf->_styleHint, nullptr, "stylehint" },
+ { _lockcols, &g_conf->_lockCols, nullptr, "lockcols" },
+ { _lockrows, &g_conf->_lockRows, nullptr, "lockrows" },
+ { _justify, &g_conf->_propInfo._justify, nullptr, "justify" },
+ { _caps, &g_conf->_propInfo._caps, nullptr, "caps" },
+ { _graphics, nullptr, &g_conf->_graphics, "graphics" }
+ };
+
+ IntOption intOptions[] = {
+ { _wmarginx, &g_conf->_wMarginX, "wmarginx", 0 },
+ { _wmarginy, &g_conf->_wMarginY, "wmarginy", 0 },
+ { _wpaddingx, &g_conf->_wPaddingX, "wpaddingx", 0 },
+ { _wpaddingy, &g_conf->_wPaddingY, "wpaddingy", 0 },
+ { _tmarginx, &g_conf->_tMarginX, "tmarginx", 0 },
+ { _tmarginy, &g_conf->_tMarginY, "tmarginy", 0 },
+ { _leading, &g_conf->_monoInfo._leading, "leading", 0 },
+ { _baseline, &g_conf->_propInfo._baseLine, "baseline", 0 }
+ };
+
+ FloatOption floatOptions[] = {
+ { _monosize, &g_conf->_monoInfo._size, "monosize", 0.0 },
+ { _propsize, &g_conf->_propInfo._size, "propsize", 0.0 }
+ };
+
+ ColorOption colorOptions[] = {
+ { _tcolorPopUps[0], _manualTColorHexInput, g_conf->_tStyles, nullptr, "tcolor_0", false },
+ { _gcolorPopUps[0], _manualGColorHexInput, g_conf->_gStyles, nullptr, "gcolor_0", false },
+ { _wcolorPopUps[0], _manualWColorHexInput, nullptr, nullptr, "windowcolor", false },
+ { _bcolorPopUps[0], _manualBColorHexInput, nullptr, nullptr, "bordercolor", false },
+ { _ccolorPopUps[0], _manualCColorHexInput, nullptr, &g_conf->_propInfo, "caretcolor", true },
+ { _lcolorPopUps[0], _manualLColorHexInput, nullptr, &g_conf->_propInfo, "linkcolor", true },
+ { _mcolorPopUps[0], _manualMColorHexInput, nullptr, &g_conf->_propInfo, "morecolor", true }
+ };
+
+ FontOption fontOptions[] = {
+ { _tfontPopUps[0], g_conf->_tStyles, "tfont" },
+ { _gfontPopUps[0], g_conf->_gStyles, "gfont" }
+ };
+
+ for (auto &opt : fontOptions) {
+ if (g_conf)
+ setFontPopUp(opt.popup, true, opt.styles[style_Normal].font, nullptr, _domain);
+ else
+ setFontPopUp(opt.popup, false, (FACES)0, opt.confKeyPrefix, _domain);
+ }
+
+ for (auto &opt : colorOptions) {
+ if (g_conf) {
+ bool overrideEnabled = true;
+ if (!opt.isProp && strcmp(opt.confKey, "windowcolor") == 0)
+ overrideEnabled = g_conf->_windowColorOverride;
+ if (!opt.isProp && strcmp(opt.confKey, "bordercolor") == 0)
+ overrideEnabled = g_conf->_borderColorOverride;
+ setSimpleColorPopUp(opt.popup, opt.hexInput, true, opt.confKey, opt.confKey, _domain, overrideEnabled);
+ } else {
+ setSimpleColorPopUp(opt.popup, opt.hexInput, false, opt.confKey, opt.confKey, _domain, true);
+ }
+ }
+
+ // number fields
+ for (auto &opt : intOptions) {
+ if (opt.widget && g_conf)
+ opt.widget->setEditString(Common::U32String(Common::String::format("%d", *opt.target)));
+ }
+
+ for (auto &opt : floatOptions) {
+ if (opt.widget && g_conf)
+ opt.widget->setEditString(Common::U32String(Common::String::format("%g", *opt.target)));
+ }
+
+ for (auto &opt : boolOptions) {
+ if (opt.widget && g_conf) {
+ if (opt.targetBool)
+ opt.widget->setState(*opt.targetBool);
+ else
+ opt.widget->setState(*opt.targetInt != 0);
+ }
+ }
+
+ INIT_NUM(_wborderx ,_wBorderX);
+ INIT_NUM(_wbordery ,_wBorderY);
+ INIT_INT(_linkStyle, g_conf->_propInfo._linkStyle);
+ INIT_INT(_caretShape, g_conf->_propInfo._caretShape);
+ INIT_STRING(_morePrompt, g_conf->_propInfo._morePrompt);
+ INIT_BOOL(_styleHint, g_conf->_styleHint);
+ INIT_BOOL(_safeClicks, g_conf->_safeClicks);
+ INIT_NUM(_cols, _cols);
+ INIT_NUM(_rows, _rows);
+ INIT_BOOL(_lockcols, g_conf->_lockCols);
+ INIT_BOOL(_lockrows, g_conf->_lockRows);
+ INIT_BOOL(_justify, g_conf->_propInfo._justify);
+ INIT_BOOL(_caps, g_conf->_propInfo._caps);
+ INIT_POPUP(_quotes, g_conf->_propInfo._quotes);
+ INIT_POPUP(_dashes, g_conf->_propInfo._dashes);
+ INIT_POPUP(_spaces, g_conf->_propInfo._spaces);
+ INIT_BOOL(_graphics, g_conf->_graphics);
+ INIT_NUM(_wmarginx, _wMarginX);
+ INIT_NUM(_wmarginy, _wMarginY);
+ INIT_NUM(_wpaddingx, _wPaddingX);
+ INIT_NUM(_wpaddingy, _wPaddingY);
+ INIT_NUM(_tmarginx, _tMarginX);
+ INIT_NUM(_tmarginy, _tMarginY);
+ INIT_INT(_leading, g_conf->_propInfo._leading);
+ INIT_INT(_baseline, g_conf->_propInfo._baseLine);
+ INIT_FLOAT(_monosize, g_conf->_monoInfo._size);
+ INIT_FLOAT(_propsize, g_conf->_propInfo._size);
+ INIT_POPUP(_morealign, g_conf->_propInfo._moreAlign);
+ INIT_POPUP(_morefont, g_conf->_propInfo._moreFont);
+}
+
+void GlkOptionsWidget::defineLayout(GUI::ThemeEval &layouts,
+ const Common::String &layoutName,
+ const Common::String &overlayedLayout) const {
+ layouts.addDialog(layoutName, overlayedLayout)
+ .addLayout(GUI::ThemeLayout::kLayoutVertical)
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal, 0, GUI::ThemeLayout::kItemAlignStretch)
+ .addWidget("FontHeading", "OptionsLabel")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("TFont", "OptionsLabel")
+ .addWidget("TFont0", "PopUp", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("GFont", "OptionsLabel")
+ .addWidget("GFont0", "PopUp", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(8, 8, 8, 8)
+ .addWidget("ColorHeading", "OptionsLabel")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("TColor", "OptionsLabel")
+ .addWidget("TColor0", "PopUp", 80)
+ .addWidget("THexPrefix", "OptionsLabel")
+ .addWidget("THex", "EditTextWidget")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("GColor", "OptionsLabel")
+ .addWidget("GColor0", "PopUp", 80)
+ .addWidget("GHexPrefix", "OptionsLabel")
+ .addWidget("GHex", "EditTextWidget")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("WColor", "OptionsLabel")
+ .addWidget("WColor0", "PopUp", 80)
+ .addWidget("WHexPrefix", "OptionsLabel")
+ .addWidget("WHex", "EditTextWidget")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("BColor", "OptionsLabel")
+ .addWidget("BColor0", "PopUp", 80)
+ .addWidget("BHexPrefix", "OptionsLabel")
+ .addWidget("BHex", "EditTextWidget")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("CColor", "OptionsLabel")
+ .addWidget("CColor0", "PopUp", 80)
+ .addWidget("CHexPrefix", "OptionsLabel")
+ .addWidget("CHex", "EditTextWidget")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("LColor", "OptionsLabel")
+ .addWidget("LColor0", "PopUp", 80)
+ .addWidget("LHexPrefix", "OptionsLabel")
+ .addWidget("LHex", "EditTextWidget")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("MColor", "OptionsLabel")
+ .addWidget("MColor0", "PopUp", 80)
+ .addWidget("MHexPrefix", "OptionsLabel")
+ .addWidget("MHex", "EditTextWidget")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(8, 8, 8, 8)
+ .addWidget("wborderlbl", "OptionsLabel")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("wborderx", "OptionsLabel")
+ .addWidget("wborderhorizontal", "EditTextWidget", 80)
+ .addWidget("wbordery", "OptionsLabel")
+ .addWidget("wbordervertical", "EditTextWidget", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(8, 8, 8, 8)
+ .addWidget("WindowMarginHeading", "OptionsLabel")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("wmarginxlbl", "OptionsLabel")
+ .addWidget("wmarginx", "EditTextWidget", 80)
+ .addWidget("wmarginylbl", "OptionsLabel")
+ .addWidget("wmarginy", "EditTextWidget", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(8, 8, 8, 8)
+ .addWidget("tmarginlbl", "OptionsLabel")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("tmarginxlbl", "OptionsLabel")
+ .addWidget("tmarginx", "EditTextWidget", 80)
+ .addWidget("tmarginylbl", "OptionsLabel")
+ .addWidget("tmarginy", "EditTextWidget", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(8, 8, 8, 8)
+ .addWidget("wpaddinglbl", "OptionsLabel")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("wpaddingxlbl", "OptionsLabel")
+ .addWidget("wpaddingx", "EditTextWidget", 80)
+ .addWidget("wpaddingylbl", "OptionsLabel")
+ .addWidget("wpaddingy", "EditTextWidget", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(8, 8, 8, 8)
+ .addWidget("morelbl", "OptionsLabel")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("morealignlbl", "OptionsLabel")
+ .addWidget("morealign", "PopUp", 80)
+ .addWidget("morefontlbl", "OptionsLabel")
+ .addWidget("morefont", "PopUp", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(8, 8, 8, 8)
+ .addWidget("topographyheadinglbl", "OptionsLabel")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("linkstyle", "OptionsLabel")
+ .addWidget("linkStyle", "EditTextWidget", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("caretshape", "OptionsLabel")
+ .addWidget("caretShape", "EditTextWidget", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("moreprompt", "OptionsLabel")
+ .addWidget("morePrompt", "EditTextWidget", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("leadinglbl", "OptionsLabel")
+ .addWidget("leading", "EditTextWidget", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("baselinelbl", "OptionsLabel")
+ .addWidget("baseline", "EditTextWidget", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("monosizelbl", "OptionsLabel")
+ .addWidget("monosize", "EditTextWidget", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0 ,0)
+ .addWidget("propsizelbl", "OptionsLabel")
+ .addWidget("propsize", "EditTextWidget", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("capslbl", "OptionsLabel")
+ .addWidget("caps", "Checkbox", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("quoteslbl", "OptionsLabel")
+ .addWidget("quotes", "PopUp", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("dasheslbl", "OptionsLabel")
+ .addWidget("dashes", "PopUp", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("spaceslbl", "OptionsLabel")
+ .addWidget("spaces", "PopUp", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(8, 8, 8, 8)
+ .addWidget("userexplbl", "OptionsLabel")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("stylehintlabel", "OptionsLabel")
+ .addWidget("stylehint", "Checkbox", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("safeclickslabel", "OptionsLabel")
+ .addWidget("safeclicks", "Checkbox", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("colslbl", "OptionsLabel")
+ .addWidget("cols", "EditTextWidget", 80)
+ .addWidget("lockcolslbl", "OptionsLabel")
+ .addWidget("lockcols", "Checkbox")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("rowslbl", "OptionsLabel")
+ .addWidget("rows", "EditTextWidget", 80)
+ .addWidget("lockrowslbl", "OptionsLabel")
+ .addWidget("lockrows", "Checkbox")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("justifylbl", "OptionsLabel")
+ .addWidget("justify", "Checkbox", 80)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0 ,0)
+ .addWidget("graphicslbl", "OptionsLabel")
+ .addWidget("graphics", "Checkbox", 80)
+ .closeLayout()
+ .closeLayout()
+ .closeDialog();
+}
+
+static void saveFontPopUp(GUI::PopUpWidget *popup, WindowStyle *styles, const char *confKeyPrefix, const Common::String &domain) {
+
+ FACES selectedFont = (FACES)popup->getSelectedTag();
+ for (int i = 0; i < style_NUMSTYLES; ++i) {
+ styles[i].font = selectedFont;
+ Common::String key = Common::String::format("%s%d", confKeyPrefix, i);
+ ConfMan.set(key, Screen::getFontName(selectedFont), domain);
+ }
+}
+
+static void saveColorPopUp(GUI::PopUpWidget *popup, GUI::EditTextWidget *hexInput, WindowStyle *styles, const char *prefix, const Common::String &domain) {
+
+ int idx = popup->getSelectedTag();
+ unsigned int rgb = 0;
+ bool valid = false;
+
+ if (idx >= 0 && idx <= 5) {
+ rgb = GLK_COLORS[idx].rgb;
+ valid = true;
+ } else if (idx == 6) { // custom
+ Common::String hexStr = hexInput ? hexInput->getEditString().encode() : Common::String();
+ if (hexStr.size() == 6) {
+ unsigned int parsed;
+ if (sscanf(hexStr.c_str(), "%x", &parsed) == 1) {
+ rgb = parsed;
+ valid = true;
+ }
+ }
+ }
+
+ if (!valid)
+ return;
+
+ byte r = (rgb >> 16) & 0xFF;
+ byte g = (rgb >> 8) & 0xFF;
+ byte b = rgb & 0xFF;
+ Common::String rgbStr = Common::String::format("%02x%02x%02x", r, g, b);
+
+ ConfMan.set(prefix, rgbStr, domain);
+
+ Common::String stylePrefix(prefix);
+ if (!stylePrefix.empty() && stylePrefix[stylePrefix.size()-1] == '0')
+ stylePrefix = stylePrefix.substr(0, stylePrefix.size()-1);
+
+ unsigned int engineColor = g_conf->parseColor(rgb);
+
+ if (styles) {
+ for (int i = 0; i < style_NUMSTYLES; ++i)
+ styles[i].fg = engineColor;
+ }
+
+ for (int i = 0; i < style_NUMSTYLES; ++i) {
+ Common::String key = Common::String::format("%s%d", stylePrefix.c_str(), i);
+ Common::String line = Common::String::format("%s,%s", rgbStr.c_str(), rgbStr.c_str());
+ ConfMan.set(key, line, domain);
+ }
+}
+
+static void savePropColorPopUp(GUI::PopUpWidget *popup, GUI::EditTextWidget *hexInput, PropFontInfo &propInfo, const char *confKey, const Common::String &domain) {
+ int idx = popup->getSelectedTag();
+ unsigned int rgb = 0;
+ bool valid = false;
+
+ if (idx >= 0 && idx <= 5) {
+ rgb = GLK_COLORS[idx].rgb;
+ valid = true;
+ } else if (idx == 6) {
+ Common::String hex = hexInput ? hexInput->getEditString().encode() : Common::String();
+ hex.toLowercase();
+ if (hex.size() == 6) {
+ bool allHex = true;
+ for (char c : hex) {
+ if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'))) {
+ allHex = false;
+ break;
+ }
+ }
+ if (allHex) {
+ sscanf(hex.c_str(), "%x", &rgb);
+ valid = true;
+ }
+ }
+ } else if (idx == 7) {
+ ConfMan.set(confKey, Common::String(), domain);
+ return;
+ }
+
+ if (!valid)
+ return;
+
+ unsigned int engineColor = g_conf->parseColor(rgb);
+ if (strcmp(confKey, "caretcolor") == 0)
+ propInfo._caretColor = engineColor;
+ else if (strcmp(confKey, "linkcolor") == 0)
+ propInfo._linkColor = engineColor;
+ else if (strcmp(confKey, "morecolor") == 0)
+ propInfo._moreColor = engineColor;
+
+ byte r = (rgb >> 16) & 0xFF;
+ byte g = (rgb >> 8) & 0xFF;
+ byte b = rgb & 0xFF;
+ Common::String rgbStr = Common::String::format("%02x%02x%02x", r, g, b);
+ Common::String value = Common::String::format("%s,%s", rgbStr.c_str(), rgbStr.c_str());
+ ConfMan.set(confKey, value, domain);
+}
+
+static void saveIntField(GUI::EditTextWidget *widget, int &outValue, const char *confKey, int minValue, const Common::String &domain) {
+ Common::String txt = widget->getEditString().encode();
+ int value = txt.empty() ? 0 : atoi(txt.c_str());
+ if (value < minValue) value = minValue;
+ outValue = value;
+ ConfMan.setInt(confKey, value, domain);
+}
+
+static void saveFloatField(GUI::EditTextWidget *widget, double &outValue, const char *confKey, double minValue, const Common::String &domain) {
+
+ Common::String text = widget->getEditString().encode();
+ double value = text.empty() ? minValue : atof(text.c_str());
+
+ if (value < minValue)
+ value = minValue;
+
+ outValue = value;
+ ConfMan.setFloat(confKey, value, domain);
+}
+
+static void saveBoolField(GUI::CheckboxWidget *widget, bool &outValue, const char *confKey, const Common::String &domain) {
+ bool value = widget->getState();
+ outValue = value;
+ ConfMan.setBool(confKey, value, domain);
+}
+
+static void saveBoolField(GUI::CheckboxWidget *widget, int &outValue, const char *confKey, const Common::String &domain) {
+ bool value = widget->getState();
+ outValue = value ? 1 : 0;
+ ConfMan.setInt(confKey, outValue, domain);
+}
+
+static void savePopupField(GUI::PopUpWidget *popup, int &outValue, const char *confKey, const Common::String &domain) {
+ int value = popup->getSelectedTag();
+ outValue = value;
+ ConfMan.setInt(confKey, value, domain);
+}
+
+bool GlkOptionsWidget::save() {
+
+ if (!g_conf)
+ return true;
+
+ BoolOption boolOptions[] = {
+ { _safeClicks, nullptr, &g_conf->_safeClicks, "safeclicks" },
+ { _styleHint, &g_conf->_styleHint, nullptr, "stylehint" },
+ { _lockcols, &g_conf->_lockCols, nullptr, "lockcols" },
+ { _lockrows, &g_conf->_lockRows, nullptr, "lockrows" },
+ { _justify, &g_conf->_propInfo._justify, nullptr, "justify" },
+ { _caps, &g_conf->_propInfo._caps, nullptr, "caps" },
+ { _graphics, nullptr, &g_conf->_graphics, "graphics" }
+ };
+
+ IntOption intOptions[] = {
+ { _wmarginx, &g_conf->_wMarginX, "wmarginx", 0 },
+ { _wmarginy, &g_conf->_wMarginY, "wmarginy", 0 },
+ { _wpaddingx, &g_conf->_wPaddingX, "wpaddingx", 0 },
+ { _wpaddingy, &g_conf->_wPaddingY, "wpaddingy", 0 },
+ { _tmarginx, &g_conf->_tMarginX, "tmarginx", 0 },
+ { _tmarginy, &g_conf->_tMarginY, "tmarginy", 0 },
+ { _leading, &g_conf->_monoInfo._leading, "leading", 0 },
+ { _baseline, &g_conf->_propInfo._baseLine, "baseline", 0 }
+ };
+
+ FloatOption floatOptions[] = {
+ { _monosize, &g_conf->_monoInfo._size, "monosize", 0.0 },
+ { _propsize, &g_conf->_propInfo._size, "propsize", 0.0 }
+ };
+
+ ColorOption colorOptions[] = {
+ { _tcolorPopUps[0], _manualTColorHexInput, g_conf->_tStyles, nullptr, "tcolor_0", false },
+ { _gcolorPopUps[0], _manualGColorHexInput, g_conf->_gStyles, nullptr, "gcolor_0", false },
+ { _wcolorPopUps[0], _manualWColorHexInput, nullptr, nullptr, "windowcolor", false },
+ { _bcolorPopUps[0], _manualBColorHexInput, nullptr, nullptr, "bordercolor", false },
+ { _ccolorPopUps[0], _manualCColorHexInput, nullptr, &g_conf->_propInfo, "caretcolor", true },
+ { _lcolorPopUps[0], _manualLColorHexInput, nullptr, &g_conf->_propInfo, "linkcolor", true },
+ { _mcolorPopUps[0], _manualMColorHexInput, nullptr, &g_conf->_propInfo, "morecolor", true }
+ };
+
+ FontOption fontOptions[] = {
+ { _tfontPopUps[0], g_conf->_tStyles, "tfont" },
+ { _gfontPopUps[0], g_conf->_gStyles, "gfont" }
+ };
+
+
+ for (auto &opt : fontOptions)
+ saveFontPopUp(opt.popup, opt.styles, opt.confKeyPrefix, _domain);
+
+ for (auto &opt : colorOptions) {
+ if (opt.isProp)
+ savePropColorPopUp(opt.popup, opt.hexInput, *opt.propInfo, opt.confKey, _domain);
+ else
+ saveColorPopUp(opt.popup, opt.hexInput, opt.styles, opt.confKey, _domain);
+ }
+
+ for (auto &opt : intOptions)
+ if (opt.widget) saveIntField(opt.widget, *opt.target, opt.confKey, opt.minValue, _domain);
+
+ for (auto &opt : floatOptions)
+ if (opt.widget) saveFloatField(opt.widget, *opt.target, opt.confKey, opt.minValue, _domain);
+
+ for (auto &opt : boolOptions) {
+ if (opt.widget) {
+ if (opt.targetBool)
+ saveBoolField(opt.widget, *opt.targetBool, opt.confKey, _domain);
+ else if (opt.targetInt)
+ saveBoolField(opt.widget, *opt.targetInt, opt.confKey, _domain);
+ }
+ }
+
+ g_conf->_propInfo._leading = g_conf->_monoInfo._leading;
+ g_conf->_monoInfo._baseLine = g_conf->_propInfo._baseLine;
+
+ Common::String WHexStr = _manualWColorHexInput->getEditString().encode();
+ Common::String BHexStr = _manualBColorHexInput->getEditString().encode();
+ Common::String bordStrx = _wborderx->getEditString().encode();
+ Common::String bordStry = _wbordery->getEditString().encode();
+ Common::String linkStr = _linkStyle->getEditString().encode();
+ Common::String caretStr = _caretShape->getEditString().encode();
+ Common::String morepromptStr = _morePrompt->getEditString().encode();
+ Common::String colsStr = _cols->getEditString().encode();
+ Common::String rowsStr = _rows->getEditString().encode();
+
+
+ int wIdx = _wcolorPopUps[0]->getSelectedTag();
+
+ if (wIdx == 7) {
+ // user chose to return control to the game
+ g_conf->_windowColorOverride = false;
+ ConfMan.setBool("windowcolor_override", false, _domain);
+ // revert the stored colour to the original saved value. the game may immediately overwrite it
+ // when it sends its next colour command.
+ g_conf->_windowColor = g_conf->_windowSave;
+ g_conf->_borderColor = g_conf->_borderSave;
+ // clear global override so that next colour command from the game (or the existing _windowColor)
+ // determines what is shown
+ Windows::_overrideBgSet = false;
+ } else {
+ // any other selection does a manual override
+ g_conf->_windowColorOverride = true;
+ ConfMan.setBool("windowcolor_override", true, _domain);
+ Windows::_overrideBgSet = true;
+
+ if (wIdx == 6) {
+ if (WHexStr.size() == 6) {
+ unsigned int rgb;
+ sscanf(WHexStr.c_str(), "%x", &rgb);
+ unsigned int engineColor = g_conf->parseColor(rgb);
+ byte r = (rgb >> 16) & 0xFF;
+ byte g = (rgb >> 8) & 0xFF;
+ byte b = rgb & 0xFF;
+ Common::String rgbStr = Common::String::format("%02x%02x%02x", r, g, b);
+
+ for (int i = 0; i < style_NUMSTYLES; i++) {
+ g_conf->_windowColor = engineColor;
+ Common::String key = Common::String::format("windowcolor");
+ Common::String line = Common::String::format("%s,%s", rgbStr.c_str(), rgbStr.c_str());
+ ConfMan.set(key, line, _domain);
+ }
+ }
+ } else if (_wcolorPopUps[0]) {
+ int idx = _wcolorPopUps[0]->getSelectedTag();
+ if (idx >= 0 && idx <= 5) {
+ unsigned int engineColor = g_conf->parseColor(GLK_COLORS[idx].rgb);
+ g_conf->_windowColor = engineColor;
+ byte r = (GLK_COLORS[idx].rgb >> 16) & 0xFF;
+ byte g = (GLK_COLORS[idx].rgb >> 8) & 0xFF;
+ byte b = GLK_COLORS[idx].rgb & 0xFF;
+ Common::String rgbStr = Common::String::format("%02x%02x%02x", r, g, b);
+ ConfMan.set("windowcolor", rgbStr, _domain);
+ }
+ }
+ }
+
+ int bIdx = _bcolorPopUps[0]->getSelectedTag();
+
+ if (bIdx == 7) {
+ g_conf->_borderColorOverride = false;
+ ConfMan.setBool("bordercolor_override", false, _domain);
+
+ g_conf->_windowColor = g_conf->_windowSave;
+ g_conf->_borderColor = g_conf->_borderSave;
+
+ Windows::_overrideBgSet = false;
+ } else {
+ g_conf->_borderColorOverride = true;
+ ConfMan.setBool("bordercolor_override", true, _domain);
+ Windows::_overrideBgSet = true;
+
+ if (bIdx == 6) {
+ if (BHexStr.size() == 6) {
+ unsigned int rgb;
+ sscanf(BHexStr.c_str(), "%x", &rgb);
+ unsigned int engineColor = g_conf->parseColor(rgb);
+ byte r = (rgb >> 16) & 0xFF;
+ byte g = (rgb >> 8) & 0xFF;
+ byte b = rgb & 0xFF;
+ Common::String rgbStr = Common::String::format("%02x%02x%02x", r, g, b);
+
+ for (int i = 0; i < style_NUMSTYLES; i++) {
+ g_conf->_borderColor = engineColor;
+ Common::String key = Common::String::format("bordercolor");
+ Common::String line = Common::String::format("%s,%s", rgbStr.c_str(), rgbStr.c_str());
+ ConfMan.set(key, line, _domain);
+ }
+ }
+ } else if (_bcolorPopUps[0]) {
+ int idx = _bcolorPopUps[0]->getSelectedTag();
+ if (idx >= 0 && idx <= 5) {
+ unsigned int engineColor = g_conf->parseColor(GLK_COLORS[idx].rgb);
+ g_conf->_borderColor = engineColor;
+ byte r = (GLK_COLORS[idx].rgb >> 16) & 0xFF;
+ byte g = (GLK_COLORS[idx].rgb >> 8) & 0xFF;
+ byte b = GLK_COLORS[idx].rgb & 0xFF;
+ Common::String rgbStr = Common::String::format("%02x%02x%02x", r, g, b);
+ ConfMan.set("bordercolor", rgbStr, _domain);
+ }
+ }
+ }
+
+ int bordx = bordStrx.empty() ? 0 : atoi(bordStrx.c_str());
+ if (bordx < 0)
+ bordx = 0;
+
+ g_conf->_wBorderX = bordx;
+ ConfMan.setInt("wborderx", bordx, _domain);
+
+ int bordy = bordStry.empty() ? 0 : atoi(bordStry.c_str());
+ if (bordy < 0)
+ bordy = 0;
+ g_conf->_wBorderY = bordy;
+ ConfMan.setInt("wbordery", bordy, _domain);
+
+
+ int linkstyle = linkStr.empty() ? 0 : atoi(linkStr.c_str());
+ if (linkstyle < 0)
+ linkstyle = 0;
+
+ g_conf->_propInfo._linkStyle = linkstyle;
+ g_conf->_monoInfo._linkStyle = linkstyle;
+ ConfMan.setInt("linkstyle", linkstyle, _domain);
+
+ int caretshape = caretStr.empty() ? 0 : atoi(caretStr.c_str());
+ if (caretshape < 0 || caretshape >4)
+ caretshape = 0;
+
+ g_conf->_propInfo._caretShape = caretshape;
+ FontInfo::_caretShape = caretshape;
+ ConfMan.setInt("caretshape", caretshape, _domain);
+
+ g_conf->_propInfo._morePrompt = morepromptStr;
+ ConfMan.set("moreprompt", morepromptStr, _domain);
+
+ if (_cols) {
+ int cols = colsStr.empty() ? 0 : atoi(colsStr.c_str());
+ g_conf->_cols = cols;
+ ConfMan.setInt("cols", cols, _domain);
+ }
+
+ if (_rows) {
+ int rows = rowsStr.empty() ? 0 : atoi(rowsStr.c_str());
+ g_conf->_rows = rows;
+ ConfMan.setInt("rows", rows, _domain);
+ }
+
+ if (_quotes)
+ savePopupField(_quotes, g_conf->_propInfo._quotes, "quotes", _domain);
+
+ if (_dashes)
+ savePopupField(_dashes, g_conf->_propInfo._dashes, "dashes", _domain);
+
+ if (_spaces)
+ savePopupField(_spaces, g_conf->_propInfo._spaces, "spaces", _domain);
+
+
+ if (_morealign) {
+ int x = _morealign->getSelectedTag();
+ g_conf->_propInfo._moreAlign = x;
+ ConfMan.setInt("morealign", x, _domain);
+ }
+
+ if (_morefont) {
+ FACES tf = (FACES)_morefont->getSelectedTag();
+ g_conf->_propInfo._moreFont = tf;
+ ConfMan.set("morefont", Screen::getFontName(tf), _domain);
+ }
+
+
+ g_vm->_screen->initialize();
+ g_vm->_windows->rearrange();
+
+ if (g_vm && g_vm->_windows) {
+ for (Glk::Windows::iterator it = g_vm->_windows->begin(); it != g_vm->_windows->end(); ++it) {
+ Glk::Window *w = *it;
+ if (auto tb = dynamic_cast<Glk::TextBufferWindow *>(w))
+ tb->refreshStyles();
+ else if (auto tg = dynamic_cast<Glk::TextGridWindow *>(w))
+ tg->refreshStyles();
+
+ }
+ g_vm->_windows->_forceRedraw = true;
+ g_vm->_events->redraw();
+ }
+
+ return true;
+}
+
+static void setManualColorHex(GUI::PopUpWidget *popup, GUI::EditTextWidget *hexInput) {
+ int idx = popup->getSelectedTag();
+
+ byte r = (GLK_COLORS[idx].rgb >> 16) & 0xFF;
+ byte g = (GLK_COLORS[idx].rgb >> 8) & 0xFF;
+ byte b = GLK_COLORS[idx].rgb & 0xFF;
+ hexInput->setEditString(Common::U32String(Common::String::format("%02X%02X%02X", r, g, b)));
+}
+
+static void setColorPopupFromHex(GUI::PopUpWidget *popup, GUI::EditTextWidget *hexInput) {
+ Common::String hex = hexInput->getEditString().encode();
+ if (hex.size() != 6)
+ return;
+
+ unsigned int rgb;
+ if (sscanf(hex.c_str(), "%x", &rgb) != 1)
+ return;
+
+ bool found = false;
+ for (int i = 0; i <= 5; ++i) {
+ if (GLK_COLORS[i].rgb == rgb) {
+ popup->setSelectedTag(i);
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ popup->setSelectedTag(6);
+
+ popup->markAsDirty();
+}
+
+void GlkOptionsWidget::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
+ // Update the hex field to match the color chosen from the color popup
+ if (cmd == kTColorChangedCmd) {
+ setManualColorHex(_tcolorPopUps[0], _manualTColorHexInput);
+ save();
+ return;
+ } else if (cmd == kGColorChangedCmd) {
+ setManualColorHex(_gcolorPopUps[0], _manualGColorHexInput);
+ save();
+ return;
+ } else if (cmd == kWColorChangedCmd) {
+ setManualColorHex(_wcolorPopUps[0], _manualWColorHexInput);
+ save();
+ return;
+ } else if (cmd == kBColorChangedCmd) {
+ setManualColorHex(_bcolorPopUps[0], _manualBColorHexInput);
+ save();
+ return;
+ } else if (cmd == kCColorChangedCmd) {
+ setManualColorHex(_ccolorPopUps[0], _manualCColorHexInput);
+ save();
+ return;
+ } else if (cmd == kLColorChangedCmd) {
+ setManualColorHex(_lcolorPopUps[0], _manualLColorHexInput);
+ save();
+ return;
+ } else if (cmd == kMColorChangedCmd) {
+ setManualColorHex(_mcolorPopUps[0], _manualMColorHexInput);
+ save();
+ return;
+ } else if (cmd == kTHexChangedCmd) { // hex input â popup sync
+ setColorPopupFromHex(_tcolorPopUps[0], _manualTColorHexInput);
+ save();
+ return;
+ } else if (cmd == kGHexChangedCmd) {
+ setColorPopupFromHex(_gcolorPopUps[0], _manualGColorHexInput);
+ save();
+ return;
+ } else if (cmd == kWHexChangedCmd) {
+ setColorPopupFromHex(_wcolorPopUps[0], _manualWColorHexInput);
+ save();
+ return;
+ } else if (cmd == kBHexChangedCmd) {
+ setColorPopupFromHex(_bcolorPopUps[0], _manualBColorHexInput);
+ save();
+ return;
+ } else if (cmd == kCHexChangedCmd) {
+ setColorPopupFromHex(_ccolorPopUps[0], _manualCColorHexInput);
+ save();
+ return;
+ } else if (cmd == kLHexChangedCmd) {
+ setColorPopupFromHex(_lcolorPopUps[0], _manualLColorHexInput);
+ save();
+ return;
+ } else if (cmd == kMHexChangedCmd) {
+ setColorPopupFromHex(_mcolorPopUps[0], _manualMColorHexInput);
+ save();
+ return;
+ }
+
+ OptionsContainerWidget::handleCommand(sender, cmd, data);
+}
+
+} // End of namespace Glk
diff --git a/engines/glk/dialogs.h b/engines/glk/dialogs.h
new file mode 100644
index 00000000000..5a78024291e
--- /dev/null
+++ b/engines/glk/dialogs.h
@@ -0,0 +1,135 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GLK_DIALOGS_H
+#define GLK_DIALOGS_H
+
+#include "glk/glk.h"
+
+#include "common/str.h"
+#include "gui/dialog.h"
+#include "gui/widget.h"
+#include "gui/widgets/edittext.h"
+
+namespace GUI {
+class PopUpWidget;
+class StaticTextWidget;
+class EditTextWidget;
+class CheckboxWidget;
+} // namespace GUI
+
+namespace Glk {
+
+class GlkEngine;
+
+class GlkOptionsWidget : public GUI::OptionsContainerWidget {
+
+ enum {
+ kTColorChangedCmd = 'TCLR',
+ kGColorChangedCmd = 'GCLR',
+ kWColorChangedCmd = 'WCLR',
+ kBColorChangedCmd = 'BCLR',
+ kCColorChangedCmd = 'CCLR',
+ kLColorChangedCmd = 'LCLR',
+ kMColorChangedCmd = 'MCLR',
+ kTHexChangedCmd = 'THEX',
+ kGHexChangedCmd = 'GHEX',
+ kWHexChangedCmd = 'WHEX',
+ kBHexChangedCmd = 'BHEX',
+ kCHexChangedCmd = 'CHEX',
+ kLHexChangedCmd = 'LHEX',
+ kMHexChangedCmd = 'MHEX'
+ };
+
+public:
+ GlkOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain);
+ ~GlkOptionsWidget() override;
+
+ // OptionsContainerWidget API
+ void load() override;
+ bool save() override;
+
+ void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
+ void reflowLayout() override;
+
+private:
+ // OptionsContainerWidget API
+ void defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const override;
+ GUI::PopUpWidget *_tfontPopUps[style_NUMSTYLES];
+ GUI::PopUpWidget *_gfontPopUps[style_NUMSTYLES];
+ GUI::PopUpWidget *_tcolorPopUps[style_NUMSTYLES];
+ GUI::PopUpWidget *_gcolorPopUps[style_NUMSTYLES];
+ GUI::PopUpWidget *_wcolorPopUps[style_NUMSTYLES];
+ GUI::PopUpWidget *_bcolorPopUps[style_NUMSTYLES];
+ GUI::PopUpWidget *_ccolorPopUps[style_NUMSTYLES];
+ GUI::PopUpWidget *_lcolorPopUps[style_NUMSTYLES];
+ GUI::PopUpWidget *_mcolorPopUps[style_NUMSTYLES];
+ GUI::EditTextWidget *_manualTColorHexInput;
+ GUI::EditTextWidget *_manualGColorHexInput;
+ GUI::EditTextWidget *_manualWColorHexInput;
+ GUI::EditTextWidget *_manualBColorHexInput;
+ GUI::EditTextWidget *_wborderx;
+ GUI::EditTextWidget *_wbordery;
+ GUI::EditTextWidget *_manualCColorHexInput;
+ GUI::EditTextWidget *_manualLColorHexInput;
+ GUI::EditTextWidget *_manualMColorHexInput;
+ GUI::EditTextWidget *_linkStyle;
+ GUI::EditTextWidget *_caretShape;
+ GUI::EditTextWidget *_morePrompt;
+ GUI::CheckboxWidget *_styleHint;
+ GUI::CheckboxWidget *_safeClicks;
+ GUI::EditTextWidget *_cols;
+ GUI::EditTextWidget *_rows;
+ GUI::CheckboxWidget *_lockcols;
+ GUI::CheckboxWidget *_lockrows;
+ GUI::CheckboxWidget *_justify;
+ GUI::CheckboxWidget *_caps;
+ GUI::PopUpWidget *_quotes;
+ GUI::PopUpWidget *_dashes;
+ GUI::PopUpWidget *_spaces;
+ GUI::CheckboxWidget *_graphics;
+ GUI::EditTextWidget *_wmarginx;
+ GUI::EditTextWidget *_wmarginy;
+ GUI::EditTextWidget *_wpaddingx;
+ GUI::EditTextWidget *_wpaddingy;
+ GUI::EditTextWidget *_tmarginx;
+ GUI::EditTextWidget *_tmarginy;
+ GUI::EditTextWidget *_leading;
+ GUI::EditTextWidget *_baseline;
+ GUI::EditTextWidget *_monosize;
+ GUI::EditTextWidget *_propsize;
+ GUI::PopUpWidget *_morealign;
+ GUI::PopUpWidget *_morefont;
+ GUI::StaticTextWidget *_fontHeadinglbl;
+ GUI::StaticTextWidget *_colorHeadinglbl;
+ GUI::StaticTextWidget *_borderHeadinglbl;
+ GUI::StaticTextWidget *_wmarginHeadinglbl;
+ GUI::StaticTextWidget *_tmarginHeadinglbl;
+ GUI::StaticTextWidget *_wpaddingHeadinglbl;
+ GUI::StaticTextWidget *_moreHeadinglbl;
+ GUI::StaticTextWidget *_typographyHeadinglbl;
+ GUI::StaticTextWidget *_userExperiencelbl;
+
+ void layoutHeadings();
+};
+} // namespace Glk
+
+#endif
diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp
index 56284a7c81d..77a522384e0 100644
--- a/engines/glk/glk.cpp
+++ b/engines/glk/glk.cpp
@@ -89,6 +89,9 @@ void GlkEngine::initialize() {
_streams = new Streams();
_windows = new Windows(_screen);
+ if (_conf->_windowColorOverride || _conf->_windowColor != _conf->parseColor("ffffff"))
+ Windows::_overrideBgSet = true;
+
// Setup mixer
syncSoundSettings();
}
diff --git a/engines/glk/metaengine.cpp b/engines/glk/metaengine.cpp
index 3027c223830..596d3d4dd11 100644
--- a/engines/glk/metaengine.cpp
+++ b/engines/glk/metaengine.cpp
@@ -20,6 +20,7 @@
*/
#include "glk/glk.h"
+#include "glk/dialogs.h"
#include "glk/detection.h"
#include "glk/quetzal.h"
#include "glk/adrift/detection.h"
@@ -79,6 +80,7 @@ public:
}
bool hasFeature(MetaEngineFeature f) const override;
+ GUI::OptionsContainerWidget *buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
Common::Error createInstance(OSystem *syst, Engine **engine,
const DetectedGame &gameDescriptor, const void *metaEngineDescriptor) override;
@@ -105,7 +107,8 @@ bool Glk::GlkEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsReturnToLauncher) ||
(f == kSupportsLoadingDuringRuntime) ||
- (f == kSupportsSavingDuringRuntime);
+ (f == kSupportsSavingDuringRuntime) ||
+ (f == kSupportsChangingOptionsDuringRuntime);
}
bool isGameAllowed(GameSupportLevel supportLevel) {
@@ -186,6 +189,15 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine,
return *engine ? Common::kNoError : Common::kUserCanceled;
}
+GUI::OptionsContainerWidget *GlkMetaEngine::buildEngineOptionsWidget(GUI::GuiObject *boss,
+ const Common::String &name,
+ const Common::String &target) const {
+ if (target.empty())
+ return nullptr;
+
+ return new Glk::GlkOptionsWidget(boss, name, target);
+}
+
const ExtraGuiOptions GlkMetaEngine::getExtraGuiOptions(const Common::String &) const {
ExtraGuiOptions options;
#if defined(USE_TTS)
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index 3fd465faea4..11511e31716 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -4,6 +4,7 @@ MODULE_OBJS := \
blorb.o \
conf.o \
debugger.o \
+ dialogs.o \
events.o \
fonts.o \
glk.o \
diff --git a/engines/glk/screen.cpp b/engines/glk/screen.cpp
index 3fa0551126f..a35d5764f1f 100644
--- a/engines/glk/screen.cpp
+++ b/engines/glk/screen.cpp
@@ -170,10 +170,18 @@ int Screen::drawStringUni(const Point &pos, int fontIdx, uint color, const Commo
int baseLine = (fontIdx >= PROPR) ? g_conf->_propInfo._baseLine : g_conf->_monoInfo._baseLine;
Point pt(pos.x / GLI_SUBPIX, pos.y - baseLine);
const Graphics::Font *font = _fonts[fontIdx];
- font->drawString(this, text, pt.x, pt.y, w - pt.x, color);
-
- pt.x += font->getStringWidth(text);
- return MIN((int)pt.x, (int)w) * GLI_SUBPIX;
+
+ int xSub = pos.x;
+ for (auto c : text) {
+ int xPix = xSub / GLI_SUBPIX;
+ font->drawString(this, Common::U32String(1, c), xPix, pt.y, w - xPix, color);
+ int charWidthPx = font->getStringWidth(Common::U32String(1, c));
+ xSub += charWidthPx * GLI_SUBPIX;
+ if (spw > 0 && c == ' ')
+ xSub += spw;
+ }
+ int xFinalPix = MIN(xSub / GLI_SUBPIX, (int)w);
+ return xFinalPix * GLI_SUBPIX;
}
size_t Screen::stringWidth(int fontIdx, const Common::String &text, int spw) {
@@ -183,7 +191,17 @@ size_t Screen::stringWidth(int fontIdx, const Common::String &text, int spw) {
size_t Screen::stringWidthUni(int fontIdx, const Common::U32String &text, int spw) {
const Graphics::Font *font = _fonts[fontIdx];
- return font->getStringWidth(text) * GLI_SUBPIX;
+ size_t width = font->getStringWidth(text)*GLI_SUBPIX;
+
+ if (spw > 0) {
+ int spaces = 0;
+ for (auto c : text)
+ if (c == ' ')
+ spaces++;
+
+ width += (size_t)spaces * (size_t)spw;
+ }
+ return width;
}
} // End of namespace Glk
diff --git a/engines/glk/streams.cpp b/engines/glk/streams.cpp
index 805bb9feaa6..b82f5ae8aa4 100644
--- a/engines/glk/streams.cpp
+++ b/engines/glk/streams.cpp
@@ -236,6 +236,9 @@ void WindowStream::setHyperlink(uint linkVal) {
}
void WindowStream::setZColors(uint fg, uint bg) {
+ // record that the game has spoken a colour command
+ Windows::_gotBgColor = true;
+
if (!_writable || !g_conf->_styleHint)
return;
@@ -267,21 +270,27 @@ void WindowStream::setZColors(uint fg, uint bg) {
if (/*bg != zcolor_Transparent &&*/ bg != zcolor_Cursor) {
if (bg == zcolor_Default) {
- _window->_attr.bgset = false;
- _window->_attr.bgcolor = 0;
- Windows::_overrideBgSet = false;
- Windows::_overrideBgVal = 0;
-
- g_conf->_windowColor = g_conf->_windowSave;
- g_conf->_borderColor = g_conf->_borderSave;
+ // only process default if neither game nor user override is active
+ if (!Windows::_overrideBgSet && !g_conf->_windowColorOverride) {
+ _window->_attr.bgset = false;
+ _window->_attr.bgcolor = 0;
+ Windows::_overrideBgSet = false;
+ Windows::_overrideBgVal = 0;
+ if (g_conf->_windowColor == g_conf->parseColor("ffffff")) {
+ g_conf->_windowColor = g_conf->_windowSave;
+ g_conf->_borderColor = g_conf->_borderSave;
+ }
+ }
} else if (bg != zcolor_Current) {
_window->_attr.bgset = true;
_window->_attr.bgcolor = bg;
- Windows::_overrideBgSet = true;
- Windows::_overrideBgVal = bg;
+ if (!g_conf->_windowColorOverride) {
+ Windows::_overrideBgSet = true;
+ Windows::_overrideBgVal = bg;
- g_conf->_windowColor = back;
- g_conf->_borderColor = back;
+ g_conf->_windowColor = back;
+ g_conf->_borderColor = back;
+ }
}
}
diff --git a/engines/glk/window_text_buffer.cpp b/engines/glk/window_text_buffer.cpp
index a82922ddeed..ad1e81261f9 100644
--- a/engines/glk/window_text_buffer.cpp
+++ b/engines/glk/window_text_buffer.cpp
@@ -119,6 +119,13 @@ void TextBufferWindow::rearrange(const Rect &box) {
}
}
+void TextBufferWindow::refreshStyles() {
+ // copy updated engine styles/font info into the window's private copy
+ Common::copy(&g_conf->_tStyles[0], &g_conf->_tStyles[style_NUMSTYLES], _styles);
+ _font = g_conf->_propInfo;
+ rearrange(_bbox);
+}
+
void TextBufferWindow::reflow() {
int inputbyte = -1;
Attributes curattr, oldattr;
diff --git a/engines/glk/window_text_buffer.h b/engines/glk/window_text_buffer.h
index e5b0763f0ce..27537aa1538 100644
--- a/engines/glk/window_text_buffer.h
+++ b/engines/glk/window_text_buffer.h
@@ -161,6 +161,11 @@ public:
*/
void rearrange(const Rect &box) override;
+ /**
+ * Use graphics styles and mono font for grid windows
+ */
+ void refreshStyles();
+
/**
* Get window split size within parent pair window
*/
diff --git a/engines/glk/window_text_grid.cpp b/engines/glk/window_text_grid.cpp
index 590dacc7fc6..6d9237128b6 100644
--- a/engines/glk/window_text_grid.cpp
+++ b/engines/glk/window_text_grid.cpp
@@ -79,6 +79,12 @@ void TextGridWindow::rearrange(const Rect &box) {
_height = newhgt;
}
+void TextGridWindow::refreshStyles() {
+ Common::copy(&g_conf->_gStyles[0], &g_conf->_gStyles[style_NUMSTYLES], _styles);
+ _font = g_conf->_monoInfo;
+ rearrange(_bbox);
+}
+
void TextGridWindow::touch(int line) {
int y = _bbox.top + line * _font._leading;
_lines[line].dirty = true;
diff --git a/engines/glk/window_text_grid.h b/engines/glk/window_text_grid.h
index a8ecf4d2fb3..81c932e29a9 100644
--- a/engines/glk/window_text_grid.h
+++ b/engines/glk/window_text_grid.h
@@ -118,6 +118,8 @@ public:
*/
void rearrange(const Rect &box) override;
+ void refreshStyles();
+
/**
* Get window split size within parent pair window
*/
diff --git a/engines/glk/windows.cpp b/engines/glk/windows.cpp
index f9639229b14..1b4e41aa8cc 100644
--- a/engines/glk/windows.cpp
+++ b/engines/glk/windows.cpp
@@ -39,6 +39,7 @@ bool Windows::_overrideBgSet;
bool Windows::_forceRedraw;
bool Windows::_claimSelect;
bool Windows::_moreFocus;
+bool Windows::_gotBgColor;
uint Windows::_overrideFgVal;
uint Windows::_overrideBgVal;
uint Windows::_zcolor_fg;
@@ -58,6 +59,7 @@ Windows::Windows(Graphics::Screen *screen) : _screen(screen), _windowList(nullpt
_forceRedraw = true;
_claimSelect = false;
_moreFocus = false;
+ _gotBgColor = false;
_overrideFgVal = 0;
_overrideBgVal = 0;
_zcolor_fg = _zcolor_bg = 0;
@@ -418,8 +420,14 @@ void Windows::redraw() {
_claimSelect = false;
if (_forceRedraw) {
- repaint(Rect(0, 0, g_conf->_imageW, g_conf->_imageH));
- g_vm->_screen->fill(g_conf->_windowColor);
+ // When no colour has yet been provided by the game and the user hasn't overridden anything,
+ // skip the initial fill to prevent the screen from showing white when _windowColor is
+ // still the default white value. The first setZColors() call will set _gotBgColor and trigger
+ // a redraw with the correct colour.
+ if (Windows::_overrideBgSet || g_conf->_windowColorOverride || Windows::_gotBgColor) {
+ repaint(Rect(0, 0, g_conf->_imageW, g_conf->_imageH));
+ g_vm->_screen->fill(g_conf->_windowColor);
+ }
}
if (_rootWin)
diff --git a/engines/glk/windows.h b/engines/glk/windows.h
index 83eaa69a097..75886680b86 100644
--- a/engines/glk/windows.h
+++ b/engines/glk/windows.h
@@ -141,6 +141,7 @@ public:
static bool _forceRedraw;
static bool _claimSelect;
static bool _moreFocus;
+ static bool _gotBgColor;
static uint _overrideFgVal;
static uint _overrideBgVal;
static uint _zcolor_fg, _zcolor_bg;
diff --git a/gui/themes/common/highres_layout.stx b/gui/themes/common/highres_layout.stx
index 791f74344b7..834845d9f77 100644
--- a/gui/themes/common/highres_layout.stx
+++ b/gui/themes/common/highres_layout.stx
@@ -41,6 +41,9 @@
<def var = 'ListWidget.hlRightPadding' value = '0'/>
<def var = 'ListWidget.itemSpacing' value = '2'/>
+ <def var = 'GlkOptionsDialog.HeadingVerticalOffset' value = '50'/>
+ <def var = 'GlkOptionsDialog.HeadingMinGap' value = '2'/>
+
<def var = 'ShowLauncherLogo' value = '1'/>
<def var = 'ShowGlobalMenuLogo' value = '1'/>
<def var = 'ShowSearchPic' value = '1'/>
diff --git a/gui/themes/common/lowres_layout.stx b/gui/themes/common/lowres_layout.stx
index 6472c4da695..60797168d3a 100644
--- a/gui/themes/common/lowres_layout.stx
+++ b/gui/themes/common/lowres_layout.stx
@@ -42,6 +42,9 @@
<def var = 'Launcher.HelpButton.Width' value = '16' scalable = 'yes'/> <!-- Button.Width -->
<def var = 'Launcher.ShowMainHelp' value = '0'/>
+ <def var = 'GlkOptionsDialog.HeadingVerticalOffset' value = '50'/>
+ <def var = 'GlkOptionsDialog.HeadingMinGap' value = '2'/>
+
<def var = 'SaveLoadChooser.ExtInfo.Visible' value = '0'/>
<def var = 'RecorderDialog.ExtInfo.Visible' value = '0'/>
<def var = 'ImageAlbum.ImageInset' value = '16' scalable = 'yes' />
More information about the Scummvm-git-logs
mailing list