[Scummvm-git-logs] scummvm master -> 3226e5fce5b076a42437ac32d0fe46812d623c62
sev-
noreply at scummvm.org
Mon Apr 6 16:00:02 UTC 2026
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
f08ac3cb8d GUI: Add offset variable for glk
3226e5fce5 GLK: Expose GUI options
Commit: f08ac3cb8d2d9606c40ea1957195217ff7ea4d8f
https://github.com/scummvm/scummvm/commit/f08ac3cb8d2d9606c40ea1957195217ff7ea4d8f
Author: Priyanshu (10b.priyanshu at gmail.com)
Date: 2026-04-06T17:59:56+02:00
Commit Message:
GUI: Add offset variable for glk
Changed paths:
gui/themes/common/highres_layout.stx
gui/themes/common/lowres_layout.stx
gui/themes/scummclassic/classic_layout.stx
gui/themes/scummclassic/classic_layout_lowres.stx
diff --git a/gui/themes/common/highres_layout.stx b/gui/themes/common/highres_layout.stx
index 791f74344b7..fd5d3359a5d 100644
--- a/gui/themes/common/highres_layout.stx
+++ b/gui/themes/common/highres_layout.stx
@@ -41,6 +41,8 @@
<def var = 'ListWidget.hlRightPadding' value = '0'/>
<def var = 'ListWidget.itemSpacing' value = '2'/>
+ <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..aa47897d488 100644
--- a/gui/themes/common/lowres_layout.stx
+++ b/gui/themes/common/lowres_layout.stx
@@ -42,6 +42,8 @@
<def var = 'Launcher.HelpButton.Width' value = '16' scalable = 'yes'/> <!-- Button.Width -->
<def var = 'Launcher.ShowMainHelp' value = '0'/>
+ <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' />
diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx
index ae29a1ba3f4..abc6f9fd891 100644
--- a/gui/themes/scummclassic/classic_layout.stx
+++ b/gui/themes/scummclassic/classic_layout.stx
@@ -32,6 +32,8 @@
<def var = 'Layout.Spacing' value = '8' scalable = 'yes'/>
+ <def var = 'GlkOptionsDialog.HeadingMinGap' value = '2'/>
+
<def var = 'ShowLauncherLogo' value = '0'/>
<def var = 'ShowGlobalMenuLogo' value = '0'/>
<def var = 'ShowSearchPic' value = '0'/>
diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx
index af871444fbb..8c93d4daf83 100644
--- a/gui/themes/scummclassic/classic_layout_lowres.stx
+++ b/gui/themes/scummclassic/classic_layout_lowres.stx
@@ -32,6 +32,8 @@
<def var = 'Layout.Spacing' value = '8' scalable = 'yes'/>
+ <def var = 'GlkOptionsDialog.HeadingMinGap' value = '2'/>
+
<def var = 'ShowLauncherLogo' value = '0'/>
<def var = 'ShowGlobalMenuLogo' value = '0'/>
<def var = 'ShowSearchPic' value = '0'/>
Commit: 3226e5fce5b076a42437ac32d0fe46812d623c62
https://github.com/scummvm/scummvm/commit/3226e5fce5b076a42437ac32d0fe46812d623c62
Author: Priyanshu (10b.priyanshu at gmail.com)
Date: 2026-04-06T17:59:56+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/glk_api.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
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..ab4e567b230 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);
@@ -373,4 +390,9 @@ void Conf::syncAsFont(const Common::String &name, FACES &val) {
ConfMan.set(name, Screen::getFontName(val));
}
+Conf::~Conf() {
+ if (g_conf == this)
+ g_conf = nullptr;
+}
+
} // End of namespace Glk
diff --git a/engines/glk/conf.h b/engines/glk/conf.h
index 85aca3ab2f0..4602838b688 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;
@@ -122,6 +124,11 @@ public:
* modify scummvm.ini later on to see what options are available
*/
void flush();
+
+ /**
+ * Destructor
+ */
+ ~Conf();
};
extern Conf *g_conf;
diff --git a/engines/glk/dialogs.cpp b/engines/glk/dialogs.cpp
new file mode 100644
index 00000000000..23efdaade39
--- /dev/null
+++ b/engines/glk/dialogs.cpp
@@ -0,0 +1,1350 @@
+/* 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, tooltip) \
+ widget = new GUI::EditTextWidget(widgetsBoss(), name, Common::U32String(), _(tooltip))
+
+#define NEW_CHECKBOX(widget, name, tooltip) \
+ widget = new GUI::CheckboxWidget(widgetsBoss(), name, Common::U32String(), _(tooltip))
+
+#define NEW_POPUP(widget, name, tooltip) \
+ widget = new GUI::PopUpWidget(widgetsBoss(), name, _(tooltip))
+
+#define NEW_SLIDER(widget, name, tooltip) \
+ widget = new GUI::SliderWidget(widgetsBoss(), name, _(tooltip))
+
+#define NEW_EDIT_CMD(widget, name, tooltip, cmd) \
+ widget = new GUI::EditTextWidget(widgetsBoss(), name, Common::U32String(), _(tooltip), cmd, cmd)
+
+#define NEW_POPUP_CMD(widget, name, tooltip, cmd) \
+ widget = new GUI::PopUpWidget(widgetsBoss(), name, _(tooltip), cmd)
+
+#define NEW_SLIDER_CMD(widget, name, tooltip, cmd) \
+ widget = new GUI::SliderWidget(widgetsBoss(), name, _(tooltip), 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_SLIDER_FLOAT(widget, configMember, minV, maxV) \
+ if (g_conf && widget) { \
+ widget->setMinValue(minV); \
+ widget->setMaxValue(maxV); \
+ widget->setValue((int)(configMember)); \
+ }
+
+#define NEW_LABEL_EDIT(lbl_name, text, edit_widget, edit_name, tooltip) \
+ do { \
+ NEW_LABEL(lbl_name, text, tooltip); \
+ NEW_EDIT(edit_widget, edit_name, tooltip); \
+ } while (0)
+
+#define NEW_LABEL_CHECKBOX(lbl_name, text, chk_widget, chk_name, tooltip) \
+ do { \
+ NEW_LABEL(lbl_name, text, tooltip); \
+ NEW_CHECKBOX(chk_widget, chk_name, tooltip); \
+ } while (0)
+
+#define NEW_LABEL_POPUP(lbl_name, text, pop_widget, pop_name, tooltip) \
+ do { \
+ NEW_LABEL(lbl_name, text, tooltip); \
+ NEW_POPUP(pop_widget, pop_name, tooltip); \
+ } while (0)
+
+#define NEW_LABEL_SLIDER_CMD(lbl_name, text, sld_widget, sld_name, val_widget, val_name, tooltip, cmd) \
+ do { \
+ NEW_LABEL(lbl_name, text, tooltip); \
+ NEW_SLIDER_CMD(sld_widget, sld_name, tooltip, cmd); \
+ val_widget = new GUI::StaticTextWidget(widgetsBoss(), val_name, Common::U32String("10"), _(tooltip)); \
+ val_widget->setFlags(GUI::WIDGET_CLEARBG); \
+ } while (0)
+
+#define COLOR_EDIT(prefix, varhex, var, labelText, tooltip, hexcmd, colorcmd) \
+ do { \
+ NEW_LABEL(prefix "HexPrefix", "0x", tooltip); \
+ NEW_EDIT_CMD(varhex, prefix "Hex", tooltip, hexcmd); \
+ NEW_POPUP_CMD(var, prefix "Color0", tooltip, colorcmd); \
+ NEW_LABEL(prefix "Color", labelText, tooltip); \
+ } while (0)
+
+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_LABEL_POPUP("GlkOptionsDialog.TFont", _s("Text:"), _tfontPopUps[0], "GlkOptionsDialog.TFont0", _s("Font for the text"));
+ for (int f = MONOR; f <= PROPZ; ++f)
+ _tfontPopUps[0]->appendEntry(fontLabels[f], f);
+
+ NEW_LABEL_POPUP("GlkOptionsDialog.GFont", _s("Grid:"), _gfontPopUps[0], "GlkOptionsDialog.GFont0", _s("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");
+
+ COLOR_EDIT("GlkOptionsDialog.T", _manualTColorHexInput, _tcolorPopUps[0], _s("Text:"), _s("Color of the interactive text"), kTHexChangedCmd, kTColorChangedCmd);
+ for (int c = 0; c <= 5; ++c)
+ _tcolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _tcolorPopUps[0]->appendEntry("custom", 6);
+
+ COLOR_EDIT("GlkOptionsDialog.G", _manualGColorHexInput, _gcolorPopUps[0], _s("Grid:"), _s("Color for drawn graphics such as maps, diagrams, puzzles, etc"), kGHexChangedCmd, kGColorChangedCmd);
+ for (int c = 0; c <= 5; ++c)
+ _gcolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _gcolorPopUps[0]->appendEntry("custom", 6);
+
+ COLOR_EDIT("GlkOptionsDialog.W", _manualWColorHexInput, _wcolorPopUps[0], _s("Window:"), _s("Color of the window(background)"), kWHexChangedCmd, kWColorChangedCmd);
+ _wcolorPopUps[0]->appendEntry("<default>", 7);
+ for (int c = 0; c <= 5; ++c)
+ _wcolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _wcolorPopUps[0]->appendEntry("custom", 6);
+
+ COLOR_EDIT("GlkOptionsDialog.B", _manualBColorHexInput, _bcolorPopUps[0], _s("Border:"), _s("Color of the window border"), kBHexChangedCmd, kBColorChangedCmd);
+ _bcolorPopUps[0]->appendEntry("<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_EDIT("GlkOptionsDialog.wborderx", _s("Horizontal:"), _wborderx, "GlkOptionsDialog.wborderhorizontal", _s("Horizontal border size"));
+ NEW_LABEL_EDIT("GlkOptionsDialog.wbordery", _s("Vertical:"), _wbordery, "GlkOptionsDialog.wbordervertical", _s("Vertical border size"));
+
+ COLOR_EDIT("GlkOptionsDialog.C", _manualCColorHexInput, _ccolorPopUps[0], _s("Caret:"), _s("Color of the cursor"), kCHexChangedCmd, kCColorChangedCmd);
+ _ccolorPopUps[0]->appendEntry("<default>", 7);
+ for (int c = 0; c <= 5; ++c)
+ _ccolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _ccolorPopUps[0]->appendEntry("custom", 6);
+
+ COLOR_EDIT("GlkOptionsDialog.L", _manualLColorHexInput, _lcolorPopUps[0], _s("Link:"), _s("Color for URLs if they appear in-game"), kLHexChangedCmd, kLColorChangedCmd);
+ _lcolorPopUps[0]->appendEntry("<default>", 7);
+ for (int c = 0; c <= 5; ++c)
+ _lcolorPopUps[0]->appendEntry(_(GLK_COLORS[c].name), c);
+ _lcolorPopUps[0]->appendEntry("custom", 6);
+
+ COLOR_EDIT("GlkOptionsDialog.M", _manualMColorHexInput, _mcolorPopUps[0], _s("More:"), _s("Color for the \"More...\" markers in the text"), kMHexChangedCmd, kMColorChangedCmd);
+ _mcolorPopUps[0]->appendEntry("<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_POPUP("GlkOptionsDialog.linkstyle", _s("Link style:"), _linkStyle, "GlkOptionsDialog.linkStyle", _s("Style for URLs if they appear in-game"));
+ _linkStyle->appendEntry(_("1"), 0);
+ _linkStyle->appendEntry(_("2"), 1);
+ _linkStyle->appendEntry(_("3"), 2);
+
+ NEW_LABEL_POPUP("GlkOptionsDialog.caretshape", _s("Caret shape:"), _caretShape, "GlkOptionsDialog.caretShape", _s("Shape of the cursor"));
+ _caretShape->appendEntry(_("0"), 0);
+ _caretShape->appendEntry(_("1"), 1);
+ _caretShape->appendEntry(_("2"), 2);
+ _caretShape->appendEntry(_("3"), 3);
+ _caretShape->appendEntry(_("4"), 4);
+
+ NEW_LABEL_EDIT("GlkOptionsDialog.moreprompt", _s("More prompt:"), _morePrompt, "GlkOptionsDialog.morePrompt", _s("Custom marker in place of the \"More...\" marker for eg. \"continue\". Leave it blank to use the game's default"));
+
+ NEW_LABEL_CHECKBOX("GlkOptionsDialog.stylehintlabel", _s("Style hints:"), _styleHint, "GlkOptionsDialog.stylehint", _s("Let the game suggest text styling options"));
+ NEW_LABEL_CHECKBOX("GlkOptionsDialog.safeclickslabel", _s("Safe clicks:"), _safeClicks, "GlkOptionsDialog.safeclicks", _s("Safely apply clicks while input is pending"));
+
+ NEW_LABEL_EDIT("GlkOptionsDialog.colslbl", _s("Column count:"), _cols, "GlkOptionsDialog.cols", _s("Number of columns"));
+ NEW_LABEL_EDIT("GlkOptionsDialog.rowslbl", _s("Rows count:"), _rows, "GlkOptionsDialog.rows", _s("Number of rows"));
+
+ NEW_LABEL_CHECKBOX("GlkOptionsDialog.lockcolslbl", _s("Lock columns:"), _lockcols, "GlkOptionsDialog.lockcols", _s("Check it to manually change the column count"));
+ NEW_LABEL_CHECKBOX("GlkOptionsDialog.lockrowslbl", _s("Lock rows:"), _lockrows, "GlkOptionsDialog.lockrows", _s("Check it to manually change the row count"));
+
+ NEW_LABEL_CHECKBOX("GlkOptionsDialog.justifylbl", _s("Justify:"), _justify, "GlkOptionsDialog.justify", _s("Enable text justification"));
+
+ NEW_LABEL_POPUP("GlkOptionsDialog.quoteslbl", _s("Typographic quotes:"), _quotes, "GlkOptionsDialog.quotes", _s("Choose typographic quotes"));
+ _quotes->appendEntry(_("Off"), 0);
+ _quotes->appendEntry(_("Normal"), 1);
+ _quotes->appendEntry(_("Rabid"), 2);
+
+ NEW_LABEL_CHECKBOX("GlkOptionsDialog.capslbl", _s("Caps:"), _caps, "GlkOptionsDialog.caps", _s("Force uppercase input"));
+
+ NEW_LABEL_POPUP("GlkOptionsDialog.dasheslbl", _s("Dashes:"), _dashes, "GlkOptionsDialog.dashes", _s("Types of 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_POPUP("GlkOptionsDialog.spaceslbl", _s("Spaces:"), _spaces, "GlkOptionsDialog.spaces", _s("Types of spaces"));
+ _spaces->appendEntry(_("Off"), 0);
+ _spaces->appendEntry(_("Compress double spaces"), 1);
+ _spaces->appendEntry(_("Expand single spaces"), 2);
+
+ NEW_LABEL_CHECKBOX("GlkOptionsDialog.graphicslbl", _s("Graphics:"), _graphics, "GlkOptionsDialog.graphics", _s("Turn graphics on/off"));
+
+ _wmarginHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.WindowMarginHeading", "Window margin");
+ NEW_LABEL_EDIT("GlkOptionsDialog.wmarginxlbl", _s("Horizontal:"), _wmarginx, "GlkOptionsDialog.wmarginx", _s("Horizontal margin for window"));
+ NEW_LABEL_EDIT("GlkOptionsDialog.wmarginylbl", _s("Vertical:"), _wmarginy, "GlkOptionsDialog.wmarginy", _s("Vertical margin for window"));
+
+ _wpaddingHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.wpaddinglbl", "Window padding");
+ NEW_LABEL_EDIT("GlkOptionsDialog.wpaddingxlbl", _s("Horizontal:"), _wpaddingx, "GlkOptionsDialog.wpaddingx", _s("Horizontal padding for window"));
+ NEW_LABEL_EDIT("GlkOptionsDialog.wpaddingylbl", _s("Vertical:"), _wpaddingy, "GlkOptionsDialog.wpaddingy", _s("Vertical padding for window"));
+
+ _tmarginHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.tmarginlbl", "Text margin");
+ NEW_LABEL_EDIT("GlkOptionsDialog.tmarginxlbl", _s("Horizontal:"), _tmarginx, "GlkOptionsDialog.tmarginx", _s("Horizontal margin for text"));
+ NEW_LABEL_EDIT("GlkOptionsDialog.tmarginylbl", _s("Vertical:"), _tmarginy, "GlkOptionsDialog.tmarginy", _s("Vertical margin for text"));
+
+ NEW_LABEL_EDIT("GlkOptionsDialog.leadinglbl", _s("Leading:"), _leading, "GlkOptionsDialog.leading", _s("Vertical distance between text rows. Valid inputs - 12, 16, 22 etc."));
+ NEW_LABEL_EDIT("GlkOptionsDialog.baselinelbl", _s("Baseline:"), _baseline, "GlkOptionsDialog.baseline", _s("Invisible horizontal line on which text sits. Valid inputs - 8, 16 etc. as per your font size"));
+
+ NEW_LABEL_SLIDER_CMD("GlkOptionsDialog.monosizelbl", _s("Monosize:"), _monosize, "GlkOptionsDialog.monosize", _monosizeVal, "GlkOptionsDialog.monosizeval", _s("Font size scaling for the monospace text font"), kMonoSizeCmd);
+ NEW_LABEL_SLIDER_CMD("GlkOptionsDialog.propsizelbl", _s("Propsize:"), _propsize, "GlkOptionsDialog.propsize", _propsizeVal, "GlkOptionsDialog.propsizeval", _s("Font size scaling for the proportional text font"), kPropSizeCmd);
+
+ _moreHeadinglbl = createHeading(widgetsBoss(), "GlkOptionsDialog.morelbl", "More");
+ NEW_LABEL_POPUP("GlkOptionsDialog.morealignlbl", _s("Align:"), _morealign, "GlkOptionsDialog.morealign", _s("Alignment of the \"More...\" marker on the window"));
+ _morealign->appendEntry(_("Left"), 0);
+ _morealign->appendEntry(_("Centre"), 1);
+ _morealign->appendEntry(_("Right"), 2);
+
+ NEW_LABEL_POPUP("GlkOptionsDialog.morefontlbl", _s("Font:"), _morefont, "GlkOptionsDialog.morefont", _s("Font for the \"More...\" marker"));
+ for (int f = MONOR; f <= PROPZ; ++f)
+ _morefont->appendEntry(fontLabels[f], f);
+
+}
+
+GlkOptionsWidget::~GlkOptionsWidget() {}
+
+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 headingMinGap = g_gui.xmlEval()->getVar("GlkOptionsDialog.HeadingMinGap", 2);
+
+ HeadingY headingYpos[] = {
+ { "GlkOptionsDialog.TFont0", _fontHeadinglbl, &fontY, &fontRowY, 0 },
+ { "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) {
+
+ Common::String targetKey = hasConf ? confKey : themeKey;
+
+ if (hasConf && !overrideEnabled) {
+ popup->setSelectedTag(defaultValue);
+ hexInput->setEditString(Common::U32String());
+ return;
+ }
+
+ // Grab the color from ConfMan (returns "RRGGBB" or "RRGGBB,RRGGBB")
+ Common::String colorStr = ConfMan.get(targetKey, domain);
+ Common::String hexPart = colorStr.substr(0, 6);
+
+ if (hexInput) {
+ hexInput->setEditString(Common::U32String(hexPart));
+ }
+
+ unsigned int rgb = 0;
+ sscanf(hexPart.c_str(), "%x", &rgb);
+ bool found = false;
+
+ // See if it matches one of our predefined 6 colors
+ for (int i = 0; i <= 5; ++i) {
+ if (GLK_COLORS[i].rgb == rgb) {
+ popup->setSelectedTag(i);
+ found = true;
+ break;
+ }
+ }
+
+ // If it doesn't match standard colors, set to Custom (6)
+ if (!found) {
+ popup->setSelectedTag(6);
+ }
+}
+
+void GlkOptionsWidget::load() {
+ bool tempConfCreated = false;
+ if (!g_conf) {
+ tempConfCreated = true;
+ // instantiate a global g_conf so the dialog can read values from it
+ new Conf(INTERPRETER_GLULX);
+ g_conf->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 }
+ };
+
+ 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 : 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_POPUP(_linkStyle, g_conf->_propInfo._linkStyle);
+ INIT_POPUP(_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_SLIDER_FLOAT(_monosize, g_conf->_monoInfo._size, 10, 25);
+ INIT_SLIDER_FLOAT(_propsize, g_conf->_propInfo._size, 10, 25);
+ _monosizeVal->setValue(_monosize->getValue());
+ _propsizeVal->setValue(_propsize->getValue());
+ INIT_POPUP(_morealign, g_conf->_propInfo._moreAlign);
+ INIT_POPUP(_morefont, g_conf->_propInfo._moreFont);
+
+ if (tempConfCreated)
+ delete g_conf;
+}
+
+void GlkOptionsWidget::defineLayout(GUI::ThemeEval &layouts,
+ const Common::String &layoutName,
+ const Common::String &overlayedLayout) const {
+ int16 baseScale = g_gui.xmlEval()->getVar("Globals.Line.Height", 16);
+ int16 labelWidth = baseScale * 4;
+ int16 popUpWidth = baseScale * 4.5;
+ int16 prefixWidth = baseScale * 1.5;
+ int16 hexWidth = baseScale * 3.5;
+
+ layouts.addDialog(layoutName, overlayedLayout)
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addSpace()
+ .addLayout(GUI::ThemeLayout::kLayoutVertical)
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(8, 8, 8, 8)
+ .addWidget("FontHeading", "OptionsLabel")
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, prefixWidth + hexWidth, 0, 0)
+ .addWidget("TFont", "OptionsLabel", labelWidth, baseScale)
+ .addWidget("TFont0", "PopUp", baseScale * 10)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, prefixWidth + hexWidth, 0, 0)
+ .addWidget("GFont", "OptionsLabel", labelWidth, baseScale)
+ .addWidget("GFont0", "PopUp", baseScale * 10)
+ .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", labelWidth)
+ .addWidget("TColor0", "PopUp", popUpWidth)
+ .addWidget("THexPrefix", "", prefixWidth)
+ .addWidget("THex", "EditTextWidget", hexWidth)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("GColor", "OptionsLabel")
+ .addWidget("GColor0", "PopUp", popUpWidth)
+ .addWidget("GHexPrefix", "", prefixWidth)
+ .addWidget("GHex", "EditTextWidget", hexWidth)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("WColor", "OptionsLabel")
+ .addWidget("WColor0", "PopUp", popUpWidth)
+ .addWidget("WHexPrefix", "", prefixWidth)
+ .addWidget("WHex", "EditTextWidget", hexWidth)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("BColor", "OptionsLabel")
+ .addWidget("BColor0", "PopUp", popUpWidth)
+ .addWidget("BHexPrefix", "", prefixWidth)
+ .addWidget("BHex", "EditTextWidget", hexWidth)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("CColor", "OptionsLabel")
+ .addWidget("CColor0", "PopUp", popUpWidth)
+ .addWidget("CHexPrefix", "", prefixWidth)
+ .addWidget("CHex", "EditTextWidget", hexWidth)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("LColor", "OptionsLabel")
+ .addWidget("LColor0", "PopUp", popUpWidth)
+ .addWidget("LHexPrefix", "", prefixWidth)
+ .addWidget("LHex", "EditTextWidget", hexWidth)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("MColor", "OptionsLabel")
+ .addWidget("MColor0", "PopUp", popUpWidth)
+ .addWidget("MHexPrefix", "", prefixWidth)
+ .addWidget("MHex", "EditTextWidget", hexWidth)
+ .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", baseScale * 2)
+ .addWidget("wbordery", "", baseScale * 3.75)
+ .addWidget("wbordervertical", "EditTextWidget", baseScale * 2)
+ .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", baseScale * 2)
+ .addWidget("wmarginylbl", "", baseScale * 3.75)
+ .addWidget("wmarginy", "EditTextWidget", baseScale * 2)
+ .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", baseScale * 2)
+ .addWidget("tmarginylbl", "", baseScale * 3.75)
+ .addWidget("tmarginy", "EditTextWidget", baseScale * 2)
+ .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", baseScale * 1.875)
+ .addWidget("wpaddingylbl", "", baseScale * 3.75)
+ .addWidget("wpaddingy", "EditTextWidget", baseScale * 1.875)
+ .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", baseScale * 10)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("morefontlbl", "OptionsLabel")
+ .addWidget("morefont", "PopUp", baseScale * 10)
+ .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", baseScale * 10)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("caretshape", "OptionsLabel")
+ .addWidget("caretShape", "EditTextWidget", baseScale * 10)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("moreprompt", "OptionsLabel")
+ .addWidget("morePrompt", "EditTextWidget", baseScale * 10)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("leadinglbl", "OptionsLabel")
+ .addWidget("leading", "EditTextWidget", baseScale * 10)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("baselinelbl", "OptionsLabel")
+ .addWidget("baseline", "EditTextWidget", baseScale * 10)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("monosizelbl", "OptionsLabel")
+ .addWidget("monosize", "SliderWidget", baseScale * 10)
+ .addWidget("monosizeval", "StaticTextWidget", baseScale * 2)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0 ,0)
+ .addWidget("propsizelbl", "OptionsLabel")
+ .addWidget("propsize", "SliderWidget", baseScale * 10)
+ .addWidget("propsizeval", "StaticTextWidget", baseScale * 2)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("capslbl", "OptionsLabel")
+ .addWidget("caps", "Checkbox", baseScale * 10)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("quoteslbl", "OptionsLabel")
+ .addWidget("quotes", "PopUp", baseScale * 10)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("dasheslbl", "OptionsLabel")
+ .addWidget("dashes", "PopUp", baseScale * 10)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("spaceslbl", "OptionsLabel")
+ .addWidget("spaces", "PopUp", baseScale * 10)
+ .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", baseScale * 5)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("safeclickslabel", "OptionsLabel")
+ .addWidget("safeclicks", "Checkbox", baseScale * 5)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("colslbl", "OptionsLabel")
+ .addWidget("cols", "EditTextWidget", baseScale * 1.875)
+ .addWidget("lockcolslbl", "OptionsLabel")
+ .addWidget("lockcols", "Checkbox", baseScale * 2)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("rowslbl", "OptionsLabel")
+ .addWidget("rows", "EditTextWidget", baseScale * 1.875)
+ .addWidget("lockrowslbl", "OptionsLabel")
+ .addWidget("lockrows", "Checkbox", baseScale * 2)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0, 0)
+ .addWidget("justifylbl", "OptionsLabel")
+ .addWidget("justify", "Checkbox", baseScale * 5)
+ .closeLayout()
+ .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+ .addPadding(0, 0, 0 ,0)
+ .addWidget("graphicslbl", "OptionsLabel")
+ .addWidget("graphics", "Checkbox", baseScale * 5)
+ .closeLayout()
+ .closeLayout()
+ .addSpace()
+ .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 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);
+}
+
+static void saveSliderFloatField(GUI::SliderWidget *widget, double &outValue, const char *confKey, const Common::String &domain) {
+ if (!widget) return;
+
+ double value = widget->getValue();
+ outValue = value;
+ ConfMan.setFloat(confKey, value, domain);
+}
+
+bool GlkOptionsWidget::save() {
+
+ bool tempConfCreated = false;
+ if (!g_conf) {
+ tempConfCreated = true;
+ // instantiate a global g_conf so the dialog can save values into it
+ new Conf(INTERPRETER_GLULX);
+ g_conf->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 }
+ };
+
+ 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);
+
+ saveSliderFloatField(_monosize, g_conf->_monoInfo._size, "monosize", _domain);
+ saveSliderFloatField(_propsize, g_conf->_propInfo._size, "propsize", _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 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);
+
+ g_conf->_windowColor = engineColor;
+ ConfMan.set("windowcolor", rgbStr, _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);
+
+ g_conf->_borderColor = engineColor;
+ ConfMan.set("bordercolor", rgbStr, _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);
+
+
+ if (_linkStyle) {
+ savePopupField(_linkStyle, g_conf->_propInfo._linkStyle, "linkstyle", _domain);
+ g_conf->_monoInfo._linkStyle = g_conf->_propInfo._linkStyle;
+ }
+
+ if (_caretShape) {
+ savePopupField(_caretShape, g_conf->_propInfo._caretShape, "caretShape", _domain);
+ g_conf->_monoInfo._caretShape = g_conf->_propInfo._caretShape;
+ }
+
+ 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);
+ }
+
+
+ if (g_vm) {
+ if (g_vm->_screen)
+ g_vm->_screen->initialize();
+
+ if (g_vm->_windows) {
+ g_vm->_windows->rearrange();
+
+ 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;
+ }
+
+ if (g_vm->_events)
+ g_vm->_events->redraw();
+ }
+
+ if (tempConfCreated)
+ delete g_conf;
+
+ 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;
+ } else if (cmd == kMonoSizeCmd) {
+ _monosizeVal->setValue(_monosize->getValue());
+ _monosizeVal->markAsDirty();
+ return;
+ } else if (cmd == kPropSizeCmd) {
+ _propsizeVal->setValue(_propsize->getValue());
+ _propsizeVal->markAsDirty();
+ 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..271763982e2
--- /dev/null
+++ b/engines/glk/dialogs.h
@@ -0,0 +1,140 @@
+/* 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;
+class SliderWidget;
+} // 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',
+ kMonoSizeCmd = 'MSZC',
+ kPropSizeCmd = 'PSZC'
+ };
+
+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::PopUpWidget *_linkStyle;
+ GUI::PopUpWidget *_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::SliderWidget *_monosize;
+ GUI::SliderWidget *_propsize;
+ GUI::StaticTextWidget *_monosizeVal;
+ GUI::StaticTextWidget *_propsizeVal;
+ 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..2d23ad68ae7 100644
--- a/engines/glk/glk.cpp
+++ b/engines/glk/glk.cpp
@@ -68,6 +68,7 @@ GlkEngine::~GlkEngine() {
delete _streams;
delete _windows;
delete _conf;
+ g_vm = nullptr;
}
void GlkEngine::initialize() {
@@ -89,6 +90,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/glk_api.cpp b/engines/glk/glk_api.cpp
index 5270c7922e6..61878cfb877 100644
--- a/engines/glk/glk_api.cpp
+++ b/engines/glk/glk_api.cpp
@@ -507,7 +507,8 @@ void GlkAPI::glk_stylehint_set(uint wintype, uint style, uint hint, int val) {
}
if (wintype == wintype_TextBuffer && style == style_Normal && hint == stylehint_BackColor) {
- g_conf->_windowColor = styles[style].bg;
+ if (!g_conf->_windowColorOverride)
+ g_conf->_windowColor = styles[style].bg;
}
if (wintype == wintype_TextBuffer && style == style_Normal && hint == stylehint_TextColor) {
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;
More information about the Scummvm-git-logs
mailing list