diff options
-rw-r--r-- | graphics/font.h | 1 | ||||
-rw-r--r-- | gui/ThemeEngine.h | 2 | ||||
-rw-r--r-- | gui/ThemeEval.cpp | 3 | ||||
-rw-r--r-- | gui/ThemeEval.h | 3 | ||||
-rw-r--r-- | gui/ThemeParser.cpp | 47 | ||||
-rw-r--r-- | gui/ThemeParser.h | 2 | ||||
-rw-r--r-- | gui/themes/default.inc | 18 | ||||
-rw-r--r-- | gui/themes/scummclassic.zip | bin | 46407 -> 46878 bytes | |||
-rw-r--r-- | gui/themes/scummclassic/classic_layout.stx | 9 | ||||
-rw-r--r-- | gui/themes/scummclassic/classic_layout_lowres.stx | 9 | ||||
-rw-r--r-- | gui/themes/scummmodern.zip | bin | 150484 -> 150954 bytes | |||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout.stx | 11 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout_lowres.stx | 9 | ||||
-rw-r--r-- | gui/widget.cpp | 2 |
14 files changed, 97 insertions, 19 deletions
diff --git a/graphics/font.h b/graphics/font.h index f68a6dd7a6..33962875e7 100644 --- a/graphics/font.h +++ b/graphics/font.h @@ -36,6 +36,7 @@ namespace Graphics { /** Text alignment modes */ enum TextAlign { + kTextAlignInvalid, kTextAlignLeft, //!< Text should be aligned to the left kTextAlignCenter, //!< Text should be centered kTextAlignRight //!< Text should be aligned to the right diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index a7bec4d9a3..3d056486e0 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -31,6 +31,7 @@ #include "common/fs.h" #include "graphics/surface.h" #include "graphics/fontman.h" +#include "graphics/font.h" #define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.4" @@ -123,6 +124,7 @@ protected: public: //! Vertical alignment of the text. enum TextAlignVertical { + kTextAlignVInvalid, kTextAlignVBottom, kTextAlignVCenter, kTextAlignVTop diff --git a/gui/ThemeEval.cpp b/gui/ThemeEval.cpp index 3729c1b499..d50564462c 100644 --- a/gui/ThemeEval.cpp +++ b/gui/ThemeEval.cpp @@ -67,7 +67,7 @@ bool ThemeEval::getWidgetData(const Common::String &widget, int16 &x, int16 &y, } -void ThemeEval::addWidget(const Common::String &name, int w, int h, const Common::String &type, bool enabled) { +void ThemeEval::addWidget(const Common::String &name, int w, int h, const Common::String &type, bool enabled, Graphics::TextAlign align) { int typeW = -1; int typeH = -1; @@ -82,6 +82,7 @@ void ThemeEval::addWidget(const Common::String &name, int w, int h, const Common _curLayout.top()->addChild(widget); setVar(_curDialog + "." + name + ".Enabled", enabled ? 1 : 0); + setVar(_curDialog + "." + name + ".Align", align); } void ThemeEval::addDialog(const Common::String &name, const Common::String &overlays, bool enabled, int inset) { diff --git a/gui/ThemeEval.h b/gui/ThemeEval.h index 07242e890e..2e15f604ed 100644 --- a/gui/ThemeEval.h +++ b/gui/ThemeEval.h @@ -30,6 +30,7 @@ #include "common/hashmap.h" #include "common/hash-str.h" #include "common/stack.h" +#include "graphics/font.h" #include "gui/ThemeLayout.h" @@ -76,7 +77,7 @@ public: void addDialog(const Common::String &name, const Common::String &overlays, bool enabled = true, int inset = 0); void addLayout(ThemeLayout::LayoutType type, int spacing, bool center = false); - void addWidget(const Common::String &name, int w, int h, const Common::String &type, bool enabled = true); + void addWidget(const Common::String &name, int w, int h, const Common::String &type, bool enabled = true, Graphics::TextAlign align = Graphics::kTextAlignLeft); bool addImportedLayout(const Common::String &name); void addSpace(int size); diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp index d0e5528480..31d1deb656 100644 --- a/gui/ThemeParser.cpp +++ b/gui/ThemeParser.cpp @@ -62,6 +62,28 @@ static TextData parseTextDataId(const Common::String &name) { return kTextDataNone; } +static Graphics::TextAlign parseTextHAlign(const Common::String &val) { + if (val == "left") + return Graphics::kTextAlignLeft; + else if (val == "right") + return Graphics::kTextAlignRight; + else if (val == "center") + return Graphics::kTextAlignCenter; + else + return Graphics::kTextAlignInvalid; +} + +static GUI::ThemeEngine::TextAlignVertical parseTextVAlign(const Common::String &val) { + if (val == "top") + return GUI::ThemeEngine::kTextAlignVTop; + else if (val == "center") + return GUI::ThemeEngine::kTextAlignVCenter; + else if (val == "bottom") + return GUI::ThemeEngine::kTextAlignVBottom; + else + return GUI::ThemeEngine::kTextAlignVInvalid; +} + ThemeParser::ThemeParser(ThemeEngine *parent) : XMLParser() { @@ -206,22 +228,10 @@ bool ThemeParser::parserCallback_text(ParserNode *node) { Graphics::TextAlign alignH; GUI::ThemeEngine::TextAlignVertical alignV; - if (node->values["horizontal_align"] == "left") - alignH = Graphics::kTextAlignLeft; - else if (node->values["horizontal_align"] == "right") - alignH = Graphics::kTextAlignRight; - else if (node->values["horizontal_align"] == "center") - alignH = Graphics::kTextAlignCenter; - else + if ((alignH = parseTextHAlign(node->values["horizontal_align"])) == Graphics::kTextAlignInvalid) return parserError("Invalid value for text alignment."); - if (node->values["vertical_align"] == "top") - alignV = GUI::ThemeEngine::kTextAlignVTop; - else if (node->values["vertical_align"] == "center") - alignV = GUI::ThemeEngine::kTextAlignVCenter; - else if (node->values["vertical_align"] == "bottom") - alignV = GUI::ThemeEngine::kTextAlignVBottom; - else + if ((alignV = parseTextVAlign(node->values["vertical_align"])) == GUI::ThemeEngine::kTextAlignVInvalid) return parserError("Invalid value for text alignment."); Common::String id = getParentNode(node)->values["id"]; @@ -566,7 +576,14 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) { return parserError("Corrupted height value in key for %s", var.c_str()); } - _theme->getEvaluator()->addWidget(var, width, height, node->values["type"], enabled); + Graphics::TextAlign alignH = Graphics::kTextAlignLeft; + + if (node->values.contains("textalign")) { + if((alignH = parseTextHAlign(node->values["textalign"])) == Graphics::kTextAlignInvalid) + return parserError("Invalid value for text alignment."); + } + + _theme->getEvaluator()->addWidget(var, width, height, node->values["type"], enabled, alignH); } return true; diff --git a/gui/ThemeParser.h b/gui/ThemeParser.h index 520b319a06..7c9d39030b 100644 --- a/gui/ThemeParser.h +++ b/gui/ThemeParser.h @@ -169,6 +169,7 @@ protected: XML_PROP(pos, false) XML_PROP(padding, false) XML_PROP(resolution, false) + XML_PROP(textalign, false) KEY_END() KEY_END() @@ -195,6 +196,7 @@ protected: XML_PROP(height, false) XML_PROP(type, false) XML_PROP(enabled, false) + XML_PROP(textalign, false) KEY_END() XML_KEY(space) diff --git a/gui/themes/default.inc b/gui/themes/default.inc index 564b3b6ba3..99ac80adc5 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -484,6 +484,7 @@ "<layout type='horizontal' padding='0,0,0,0'> " "<widget name='subToggleDesc' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='subToggleButton' " "width='150' " @@ -493,6 +494,7 @@ "<layout type='horizontal' padding='0,0,0,0'> " "<widget name='subSubtitleSpeedDesc' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='subSubtitleSpeedSlider' " "type='Slider' " @@ -509,6 +511,7 @@ "<layout type='horizontal' padding='0,0,0,0'> " "<widget name='vcMusicText' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='vcMusicSlider' " "type='Slider' " @@ -520,6 +523,7 @@ "<layout type='horizontal' padding='0,0,0,0'> " "<widget name='vcSfxText' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='vcSfxSlider' " "type='Slider' " @@ -531,6 +535,7 @@ "<layout type='horizontal' padding='0,0,0,0'> " "<widget name='vcSpeechText' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='vcSpeechSlider' " "type='Slider' " @@ -716,6 +721,7 @@ "<layout type='horizontal' padding='0,0,0,0' spacing='16'> " "<widget name='Id' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='Domain' " "type='PopUp' " @@ -724,6 +730,7 @@ "<layout type='horizontal' padding='0,0,0,0' spacing='16'> " "<widget name='Name' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='Desc' " "type='PopUp' " @@ -884,6 +891,7 @@ "<layout type='horizontal' padding='0,0,0,0' spacing='8'> " "<widget name='subToggleDesc' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='subToggleButton' " "width='158' " @@ -893,6 +901,7 @@ "<layout type='horizontal' padding='0,0,0,0' spacing='8'> " "<widget name='subSubtitleSpeedDesc' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='subSubtitleSpeedSlider' " "type='Slider' " @@ -1147,6 +1156,7 @@ "<layout type='horizontal' padding='0,0,0,0'> " "<widget name='subToggleDesc' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='subToggleButton' " "width='128' " @@ -1156,6 +1166,7 @@ "<layout type='horizontal' padding='0,0,0,0'> " "<widget name='subSubtitleSpeedDesc' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='subSubtitleSpeedSlider' " "type='Slider' " @@ -1171,6 +1182,7 @@ "<layout type='horizontal' padding='0,0,0,0'> " "<widget name='vcMusicText' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='vcMusicSlider' " "type='Slider' " @@ -1182,6 +1194,7 @@ "<layout type='horizontal' padding='0,0,0,0'> " "<widget name='vcSfxText' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='vcSfxSlider' " "type='Slider' " @@ -1193,6 +1206,7 @@ "<layout type='horizontal' padding='0,0,0,0'> " "<widget name='vcSpeechText' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='vcSpeechSlider' " "type='Slider' " @@ -1379,6 +1393,7 @@ "<widget name='Id' " "width='35' " "height='Globals.Line.Height' " +"textalign='right' " "/> " "<widget name='Domain' " "type='PopUp' " @@ -1388,6 +1403,7 @@ "<widget name='Name' " "width='35' " "height='Globals.Line.Height' " +"textalign='right' " "/> " "<widget name='Desc' " "type='PopUp' " @@ -1553,6 +1569,7 @@ "<layout type='horizontal' padding='0,0,0,0' spacing='8'> " "<widget name='subToggleDesc' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='subToggleButton' " "width='128' " @@ -1562,6 +1579,7 @@ "<layout type='horizontal' padding='0,0,0,0' spacing='8'> " "<widget name='subSubtitleSpeedDesc' " "type='OptionsLabel' " +"textalign='right' " "/> " "<widget name='subSubtitleSpeedSlider' " "type='Slider' " diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip Binary files differindex 7b87f0e46e..15fed944f3 100644 --- a/gui/themes/scummclassic.zip +++ b/gui/themes/scummclassic.zip diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index f8e804916a..a50e17ad25 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -195,6 +195,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'subToggleDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subToggleButton' width = '150' @@ -204,6 +205,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'subSubtitleSpeedDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subSubtitleSpeedSlider' type = 'Slider' @@ -221,6 +223,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcMusicText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcMusicSlider' type = 'Slider' @@ -232,6 +235,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcSfxText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcSfxSlider' type = 'Slider' @@ -243,6 +247,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcSpeechText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcSpeechSlider' type = 'Slider' @@ -438,6 +443,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '16'> <widget name = 'Id' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'Domain' type = 'PopUp' @@ -446,6 +452,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '16'> <widget name = 'Name' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'Desc' type = 'PopUp' @@ -611,6 +618,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '8'> <widget name = 'subToggleDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subToggleButton' width = '158' @@ -620,6 +628,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '8'> <widget name = 'subSubtitleSpeedDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subSubtitleSpeedSlider' type = 'Slider' diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index 007450e07b..89b894de84 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -192,6 +192,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'subToggleDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subToggleButton' width = '128' @@ -201,6 +202,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'subSubtitleSpeedDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subSubtitleSpeedSlider' type = 'Slider' @@ -217,6 +219,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcMusicText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcMusicSlider' type = 'Slider' @@ -228,6 +231,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcSfxText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcSfxSlider' type = 'Slider' @@ -239,6 +243,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcSpeechText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcSpeechSlider' type = 'Slider' @@ -435,6 +440,7 @@ <widget name = 'Id' width = '35' height = 'Globals.Line.Height' + textalign = 'right' /> <widget name = 'Domain' type = 'PopUp' @@ -444,6 +450,7 @@ <widget name = 'Name' width = '35' height = 'Globals.Line.Height' + textalign = 'right' /> <widget name = 'Desc' type = 'PopUp' @@ -613,6 +620,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '8'> <widget name = 'subToggleDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subToggleButton' width = '128' @@ -622,6 +630,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '8'> <widget name = 'subSubtitleSpeedDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subSubtitleSpeedSlider' type = 'Slider' diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip Binary files differindex 8d3d4a979e..e70b79f02e 100644 --- a/gui/themes/scummmodern.zip +++ b/gui/themes/scummmodern.zip diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 91db687575..527acccba2 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -210,7 +210,8 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'subToggleDesc' type = 'OptionsLabel' - /> + textalign = 'right' + /> <widget name = 'subToggleButton' width = '150' height = 'Globals.Slider.Height' @@ -219,6 +220,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'subSubtitleSpeedDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subSubtitleSpeedSlider' type = 'Slider' @@ -236,6 +238,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcMusicText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcMusicSlider' type = 'Slider' @@ -247,6 +250,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcSfxText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcSfxSlider' type = 'Slider' @@ -258,6 +262,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcSpeechText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcSpeechSlider' type = 'Slider' @@ -453,6 +458,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '16'> <widget name = 'Id' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'Domain' type = 'PopUp' @@ -461,6 +467,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '16'> <widget name = 'Name' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'Desc' type = 'PopUp' @@ -626,6 +633,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '8'> <widget name = 'subToggleDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subToggleButton' width = '158' @@ -635,6 +643,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '8'> <widget name = 'subSubtitleSpeedDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subSubtitleSpeedSlider' type = 'Slider' diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index 2bebe18e53..52b23ea532 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -190,6 +190,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'subToggleDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subToggleButton' width = '128' @@ -199,6 +200,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'subSubtitleSpeedDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subSubtitleSpeedSlider' type = 'Slider' @@ -215,6 +217,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcMusicText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcMusicSlider' type = 'Slider' @@ -226,6 +229,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcSfxText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcSfxSlider' type = 'Slider' @@ -237,6 +241,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0'> <widget name = 'vcSpeechText' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'vcSpeechSlider' type = 'Slider' @@ -433,6 +438,7 @@ <widget name = 'Id' width = '35' height = 'Globals.Line.Height' + textalign = 'right' /> <widget name = 'Domain' type = 'PopUp' @@ -442,6 +448,7 @@ <widget name = 'Name' width = '35' height = 'Globals.Line.Height' + textalign = 'right' /> <widget name = 'Desc' type = 'PopUp' @@ -604,6 +611,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '8'> <widget name = 'subToggleDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subToggleButton' width = '128' @@ -613,6 +621,7 @@ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '8'> <widget name = 'subSubtitleSpeedDesc' type = 'OptionsLabel' + textalign = 'right' /> <widget name = 'subSubtitleSpeedSlider' type = 'Slider' diff --git a/gui/widget.cpp b/gui/widget.cpp index 12da012c7b..8c3b4bc210 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -192,7 +192,7 @@ StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name, _type = kStaticTextWidget; _label = text; - _align = (Graphics::TextAlign)g_gui.xmlEval()->getVar(name + ".Align", Graphics::kTextAlignLeft); + _align = (Graphics::TextAlign)g_gui.xmlEval()->getVar("Dialog." + name + ".Align", Graphics::kTextAlignLeft); } void StaticTextWidget::setValue(int value) { |