diff options
author | Vicent Marti | 2008-08-13 17:46:00 +0000 |
---|---|---|
committer | Vicent Marti | 2008-08-13 17:46:00 +0000 |
commit | 2b52383534ecb5c3770dfb267d7238516f0ca144 (patch) | |
tree | 0dc6b6d060b0a489f5f1b88fe7c46d24ee4ad458 /gui | |
parent | 1d9f98d121e51943b4967cf6188062aae9195af4 (diff) | |
download | scummvm-rg350-2b52383534ecb5c3770dfb267d7238516f0ca144.tar.gz scummvm-rg350-2b52383534ecb5c3770dfb267d7238516f0ca144.tar.bz2 scummvm-rg350-2b52383534ecb5c3770dfb267d7238516f0ca144.zip |
Finished legacy API cleanup. Removed all legacy code.
Possible regressions.
svn-id: r33833
Diffstat (limited to 'gui')
-rw-r--r-- | gui/EditTextWidget.cpp | 4 | ||||
-rw-r--r-- | gui/ListWidget.cpp | 7 | ||||
-rw-r--r-- | gui/PopUpWidget.cpp | 6 | ||||
-rw-r--r-- | gui/TabWidget.cpp | 5 | ||||
-rw-r--r-- | gui/ThemeClassic.cpp | 710 | ||||
-rw-r--r-- | gui/ThemeClassic.h | 127 | ||||
-rw-r--r-- | gui/ThemeModern.cpp | 1586 | ||||
-rw-r--r-- | gui/ThemeModern.h | 340 | ||||
-rw-r--r-- | gui/ThemeRenderer.cpp | 26 | ||||
-rw-r--r-- | gui/ThemeRenderer.h | 2 | ||||
-rw-r--r-- | gui/console.cpp | 8 | ||||
-rw-r--r-- | gui/dialog.cpp | 20 | ||||
-rw-r--r-- | gui/dialog.h | 11 | ||||
-rw-r--r-- | gui/eval.cpp | 333 | ||||
-rw-r--r-- | gui/eval.h | 130 | ||||
-rw-r--r-- | gui/launcher.cpp | 4 | ||||
-rw-r--r-- | gui/module.mk | 1 | ||||
-rw-r--r-- | gui/newgui.cpp | 3 | ||||
-rw-r--r-- | gui/options.cpp | 2 | ||||
-rw-r--r-- | gui/theme-config.cpp | 772 | ||||
-rw-r--r-- | gui/theme.cpp | 2 | ||||
-rw-r--r-- | gui/theme.h | 43 | ||||
-rw-r--r-- | gui/themebrowser.cpp | 2 | ||||
-rw-r--r-- | gui/themes/classic080.ini | 466 | ||||
-rw-r--r-- | gui/themes/modern.ini | 622 | ||||
-rw-r--r-- | gui/themes/modern.zip | bin | 42693 -> 0 bytes | |||
-rw-r--r-- | gui/themes/scummodern.zip | bin | 116164 -> 121066 bytes | |||
-rw-r--r-- | gui/widget.cpp | 26 | ||||
-rw-r--r-- | gui/widget.h | 5 |
29 files changed, 52 insertions, 5211 deletions
diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp index 244d296c80..889310d958 100644 --- a/gui/EditTextWidget.cpp +++ b/gui/EditTextWidget.cpp @@ -24,7 +24,6 @@ #include "gui/EditTextWidget.h" #include "gui/dialog.h" -#include "gui/eval.h" #include "gui/newgui.h" #include "gui/ThemeEval.h" @@ -43,7 +42,6 @@ EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const String : EditableWidget(boss, name) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE); _type = kEditTextWidget; - _hints |= THEME_HINT_USE_SHADOW; setEditString(text); } @@ -84,7 +82,7 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) { void EditTextWidget::drawWidget() { - g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _hints, Theme::kWidgetBackgroundEditText); + g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), 0, Theme::kWidgetBackgroundEditText); // Draw the text adjustOffset(); diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 13633941c8..c17963ea95 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -27,7 +27,6 @@ #include "gui/ListWidget.h" #include "gui/ScrollBarWidget.h" #include "gui/dialog.h" -#include "gui/eval.h" #include "gui/newgui.h" #include "gui/ThemeEval.h" @@ -47,7 +46,6 @@ ListWidget::ListWidget(GuiObject *boss, const String &name) _scrollBar->setTarget(this); setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE); - setHints(THEME_HINT_SAVE_BACKGROUND | THEME_HINT_USE_SHADOW); _type = kListWidget; _editMode = false; _numberingMode = kListNumberingOne; @@ -77,7 +75,6 @@ ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h) _scrollBar->setTarget(this); setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE); - setHints(THEME_HINT_SAVE_BACKGROUND | THEME_HINT_USE_SHADOW); _type = kListWidget; _editMode = false; _numberingMode = kListNumberingOne; @@ -363,7 +360,7 @@ void ListWidget::drawWidget() { Common::String buffer; // Draw a thin frame around the list. - g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _hints, Theme::kWidgetBackgroundBorder); + g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, Theme::kWidgetBackgroundBorder); const int scrollbarW = (_scrollBar && _scrollBar->isVisible()) ? _scrollBarWidth : 0; // Draw the list items @@ -378,7 +375,7 @@ void ListWidget::drawWidget() { inverted = true; else g_gui.theme()->drawWidgetBackground(Common::Rect(_x, y - 1, _x + _w - 1, y + fontHeight - 1), - _hints, Theme::kWidgetBackgroundBorderSmall); + 0, Theme::kWidgetBackgroundBorderSmall); } Common::Rect r(getEditRect()); diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp index 921647e038..6c89e7113c 100644 --- a/gui/PopUpWidget.cpp +++ b/gui/PopUpWidget.cpp @@ -25,7 +25,6 @@ #include "common/system.h" #include "common/events.h" #include "gui/dialog.h" -#include "gui/eval.h" #include "gui/newgui.h" #include "gui/PopUpWidget.h" #include "engines/engine.h" @@ -73,7 +72,7 @@ protected: }; PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY) - : Dialog(0, 0, 16, 16, false), + : Dialog(0, 0, 16, 16), _popUpBoss(boss) { // Copy the selection index @@ -153,7 +152,7 @@ PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY) void PopUpDialog::drawDialog() { // Draw the menu border - g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND | THEME_HINT_USE_SHADOW); + g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), 0); /*if (_twoColumns) g_gui.vLine(_x + _w / 2, _y, _y + _h - 2, g_gui._color);*/ @@ -360,7 +359,6 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) { PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const String &label, uint labelWidth) : Widget(boss, name), CommandSender(boss), _label(label), _labelWidth(labelWidth) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS); - setHints(THEME_HINT_SAVE_BACKGROUND); _type = kPopUpWidget; _selectedItem = -1; diff --git a/gui/TabWidget.cpp b/gui/TabWidget.cpp index 3933823943..402e9075c1 100644 --- a/gui/TabWidget.cpp +++ b/gui/TabWidget.cpp @@ -26,7 +26,6 @@ #include "gui/TabWidget.h" #include "gui/dialog.h" #include "gui/newgui.h" -#include "gui/eval.h" #include "gui/ThemeEval.h" @@ -69,9 +68,7 @@ void TabWidget::init() { int x = _w - _butRP - _butW * 2 - 2; int y = _butTP - _tabHeight; _navLeft = new ButtonWidget(this, x, y, _butW, _butH, "<", kCmdLeft, 0); - _navLeft->setHints(THEME_HINT_NO_BACKGROUND_RESTORE); _navRight = new ButtonWidget(this, x + _butW + 2, y, _butW, _butH, ">", kCmdRight, 0); - _navRight->setHints(THEME_HINT_NO_BACKGROUND_RESTORE); } TabWidget::~TabWidget() { @@ -256,7 +253,7 @@ void TabWidget::drawWidget() { for (int i = _firstVisibleTab; i < (int)_tabs.size(); ++i) { tabs.push_back(_tabs[i].title); } - g_gui.theme()->drawTab(Common::Rect(_x, _y, _x+_w, _y+_h), _tabHeight, _tabWidth, tabs, _activeTab - _firstVisibleTab, _hints, _titleVPad); + g_gui.theme()->drawTab(Common::Rect(_x, _y, _x+_w, _y+_h), _tabHeight, _tabWidth, tabs, _activeTab - _firstVisibleTab, 0, _titleVPad); } void TabWidget::draw() { diff --git a/gui/ThemeClassic.cpp b/gui/ThemeClassic.cpp deleted file mode 100644 index eaf86d1cbb..0000000000 --- a/gui/ThemeClassic.cpp +++ /dev/null @@ -1,710 +0,0 @@ -/* 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#include "gui/ThemeClassic.h" -#include "gui/eval.h" - -namespace GUI { -ThemeClassic::ThemeClassic(OSystem *system, const Common::String &config, const Common::ConfigFile *cfg) : Theme() { - _enableBlending = true; - _stylefile = config; - _system = system; - _initOk = false; - _enabled = false; - _font = 0; - _fontName.clear(); - memset(&_screen, 0, sizeof(_screen)); -#ifndef CT_NO_TRANSPARENCY - memset(&_dialog, 0, sizeof(_dialog)); -#endif - _font = 0; - - // 'classic' is always the built in one, we force it and - // ignore all 'classic' named config files - if (config.compareToIgnoreCase("classic (builtin)") != 0) { - if (cfg) - _configFile = *cfg; - else - loadConfigFile(_stylefile); - } - - if (_configFile.hasKey("name", "theme")) - _configFile.getKey("name", "theme", _stylename); - else - _stylename = _stylefile; -} - -ThemeClassic::~ThemeClassic() { - deinit(); -} - -bool ThemeClassic::init() { - deinit(); - _screen.create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(OverlayColor)); - if (_screen.pixels) { - _initOk = true; - clearAll(); - resetDrawArea(); - } - - if (isThemeLoadingRequired()) { - loadTheme(_defaultConfig); - loadTheme(_configFile, false, true); - - setupConfig(); - } - - _bgcolor = _system->RGBToColor(_colors[kBGColor][0], _colors[kBGColor][1], _colors[kBGColor][2]); - _color = _system->RGBToColor(_colors[kColor][0], _colors[kColor][1], _colors[kColor][2]); - _shadowcolor = _system->RGBToColor(_colors[kShadowColor][0], _colors[kShadowColor][1], _colors[kShadowColor][2]); - _textcolor = _system->RGBToColor(_colors[kTextColor][0], _colors[kTextColor][1], _colors[kTextColor][2]); - _textcolorhi = _system->RGBToColor(_colors[kTextColorHi][0], _colors[kTextColorHi][1], _colors[kTextColorHi][2]); - if (_fontName.empty()) { - if (_screen.w >= 400 && _screen.h >= 300) { - _font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - } else { - _font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); - } - } - - return true; -} - -void ThemeClassic::deinit() { - if (_initOk) { - _system->hideOverlay(); - _screen.free(); - _initOk = false; - } -} - -void ThemeClassic::refresh() { - init(); - if (_enabled) - _system->showOverlay(); -} - -void ThemeClassic::enable() { - init(); - resetDrawArea(); - _system->showOverlay(); - clearAll(); - _enabled = true; -} - -void ThemeClassic::disable() { - _system->hideOverlay(); - _enabled = false; -} - -void ThemeClassic::openDialog(bool topDialog, ShadingStyle shading) { -#ifndef CT_NO_TRANSPARENCY - if (!_dialog) { - _dialog = new DialogState; - assert(_dialog); - // first dialog - _dialog->screen.create(_screen.w, _screen.h, sizeof(OverlayColor)); - } - memcpy(_dialog->screen.pixels, _screen.pixels, _screen.pitch*_screen.h); - if (!_enableBlending) - _dialog->screen.fillRect(Common::Rect(0, 0, _screen.w, _screen.h), _bgcolor); - else - blendScreenToDialog(); -#endif -} - -void ThemeClassic::closeAllDialogs() { -#ifndef CT_NO_TRANSPARENCY - if (_dialog) { - _dialog->screen.free(); - delete _dialog; - _dialog = 0; - } - _forceRedraw = true; -#endif -} - -void ThemeClassic::clearAll() { - if (!_initOk) - return; - _system->clearOverlay(); - // FIXME: problem with the 'pitch' - _system->grabOverlay((OverlayColor*)_screen.pixels, _screen.w); -} - -void ThemeClassic::updateScreen() { - _forceRedraw = false; -} - -void ThemeClassic::resetDrawArea() { - if (_initOk) { - _drawArea = Common::Rect(0, 0, _screen.w, _screen.h); - } -} - -int ThemeClassic::getTabSpacing() const { - return 2; -} -int ThemeClassic::getTabPadding() const { - return 3; -} - -void ThemeClassic::drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state) { - if (!_initOk) - return; - - restoreBackground(r); - -#ifndef CT_NO_TRANSPARENCY - if ((hints & THEME_HINT_SAVE_BACKGROUND) && !(hints & THEME_HINT_FIRST_DRAW) && !_forceRedraw) { - addDirtyRect(r); - return; - } -#endif - - box(r.left, r.top, r.width(), r.height(), _color, _shadowcolor); - addDirtyRect(r, (hints & THEME_HINT_SAVE_BACKGROUND) != 0); -} - -void ThemeClassic::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) { - if (!_initOk) - return; - - if (!inverted) { - restoreBackground(r); - _font->drawString(&_screen, str, r.left, r.top, r.width(), getColor(state), convertAligment(align), deltax, useEllipsis); - } else { - _screen.fillRect(r, getColor(state)); - _font->drawString(&_screen, str, r.left, r.top, r.width(), _bgcolor, convertAligment(align), deltax, useEllipsis); - } - - addDirtyRect(r); -} - -void ThemeClassic::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state) { - if (!_initOk) - return; - restoreBackground(r); - font->drawChar(&_screen, ch, r.left, r.top, getColor(state)); - addDirtyRect(r); -} - -void ThemeClassic::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) { - if (!_initOk || background == kWidgetBackgroundNo) - return; - - restoreBackground(r); - -#ifndef CT_NO_TRANSPARENCY - if ((hints & THEME_HINT_SAVE_BACKGROUND) && !(hints & THEME_HINT_FIRST_DRAW) && !_forceRedraw) { - addDirtyRect(r); - return; - } -#endif - - switch (background) { - case kWidgetBackgroundBorder: - box(r.left, r.top, r.width(), r.height(), _color, _shadowcolor); - break; - - //case kWidgetBackgroundPlain: - //case kWidgetBackgroundBorderSmall: - default: - box(r.left, r.top, r.width(), r.height()); - break; - }; - - addDirtyRect(r, (hints & THEME_HINT_SAVE_BACKGROUND) != 0); -} - -void ThemeClassic::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) { - if (!_initOk) - return; - restoreBackground(r); - - drawWidgetBackground(r, 0, kWidgetBackgroundBorder, state); - - const int off = (r.height() - _font->getFontHeight()) / 2; - _font->drawString(&_screen, str, r.left, r.top+off, r.width(), getColor(state), Graphics::kTextAlignCenter, 0, false); - - addDirtyRect(r); -} - -void ThemeClassic::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) { - if (!_initOk) - return; - - Common::Rect rect(r.left, r.top, r.left + surface.w, r.top + surface.h); - rect.clip(_screen.w, _screen.h); - - if (!rect.isValidRect()) - return; - - assert(surface.bytesPerPixel == sizeof(OverlayColor)); - - OverlayColor *src = (OverlayColor *)surface.pixels; - OverlayColor *dst = (OverlayColor *)_screen.getBasePtr(rect.left, rect.top); - - int w = rect.width(); - int h = rect.height(); - - while (h--) { - memcpy(dst, src, surface.pitch); - src += w; - // FIXME: this should be pitch - dst += _screen.w; - } - addDirtyRect(r); -} - -void ThemeClassic::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) { - if (!_initOk) - return; - Common::Rect r2 = r; - - restoreBackground(r); - - box(r.left, r.top, r.width(), r.height(), _color, _shadowcolor); - r2.left = r.left + 2; - r2.top = r.top + 2; - r2.bottom = r.bottom - 2; - r2.right = r2.left + width; - if (r2.right > r.right - 2) { - r2.right = r.right - 2; - } - - _screen.fillRect(r2, getColor(state)); - - addDirtyRect(r); -} - -void ThemeClassic::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align) { - if (!_initOk) - return; - - restoreBackground(r); - - box(r.left, r.top, r.width(), r.height()); - - Common::Point p0, p1; - - p0 = Common::Point(r.right + 1 - r.height() / 2, r.top + 4); - p1 = Common::Point(r.right + 1 - r.height() / 2, r.bottom - 4); - - OverlayColor color = getColor(state); - - // Evil HACK to draw filled triangles - // FIXME: The "big" version is pretty ugly. - for (; p1.y - p0.y > 1; p0.y++, p0.x--, p1.y--, p1.x++) { - _screen.drawLine(p0.x, p0.y, p1.x, p0.y, color); - _screen.drawLine(p0.x, p1.y, p1.x, p1.y, color); - } - - if (!sel.empty()) { - Common::Rect text(r.left + 2, r.top + 3, r.right - 4, r.top + 3 + _font->getFontHeight()); - _font->drawString(&_screen, sel, text.left, text.top, text.width(), color, convertAligment(align), deltax, false); - } - - addDirtyRect(r); -} - -void ThemeClassic::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) { - if (!_initOk) - return; - - Common::Rect r2 = r; - int checkBoxSize = getFontHeight(); - if (checkBoxSize > r.height()) { - checkBoxSize = r.height(); - } - r2.bottom = r2.top + checkBoxSize; - - restoreBackground(r2); - - box(r.left, r.top, checkBoxSize, checkBoxSize, _color, _shadowcolor); - - if (checked) { - r2.top += 3; - r2.bottom = r.top + checkBoxSize - 4; - r2.left += 3; - r2.right = r.left + checkBoxSize - 4; - - OverlayColor c = getColor(state); - - // Draw a cross - _screen.drawLine(r2.left, r2.top, r2.right, r2.bottom, c); - _screen.drawLine(r2.left, r2.bottom, r2.right, r2.top, c); - - if (r2.height() > 5) { - // Thicken the lines - _screen.drawLine(r2.left, r2.top + 1, r2.right - 1, r2.bottom, c); - _screen.drawLine(r2.left + 1, r2.top, r2.right, r2.bottom - 1, c); - _screen.drawLine(r2.left, r2.bottom - 1, r2.right - 1, r2.top, c); - _screen.drawLine(r2.left + 1, r2.bottom, r2.right, r2.top + 1, c); - } - - r2 = r; - } - - r2.left += checkBoxSize + 10; - _font->drawString(&_screen, str, r2.left, r2.top, r2.width(), getColor(state), Graphics::kTextAlignLeft, 0, true); - - addDirtyRect(r); -} - -void ThemeClassic::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) { - if (!_initOk) - return; - restoreBackground(r); - - for (int i = 0; i < (int)tabs.size(); ++i) { - if (i == active) - continue; - box(r.left + i * tabWidth, r.top+2, tabWidth, tabHeight-2, _color, _shadowcolor); - _font->drawString(&_screen, tabs[i], r.left + i * tabWidth, r.top+4, tabWidth, getColor(state), Graphics::kTextAlignCenter, 0, true); - } - - if (active >= 0) { - box(r.left + active * tabWidth, r.top, tabWidth, tabHeight, _color, _shadowcolor, true); - _font->drawString(&_screen, tabs[active], r.left + active * tabWidth, r.top+titleVPad, tabWidth, getColor(kStateHighlight), Graphics::kTextAlignCenter, 0, true); - - _screen.hLine(r.left, r.top + tabHeight, r.left + active * tabWidth + 1, _color); - _screen.hLine(r.left + active * tabWidth + tabWidth - 2, r.top + tabHeight, r.right, _color); - _screen.hLine(r.left, r.bottom - 1, r.right - 1, _shadowcolor); - _screen.vLine(r.left, r.top + tabHeight, r.bottom - 1, _color); - _screen.vLine(r.right - 1, r.top + tabHeight, r.bottom - 1, _shadowcolor); - } - - addDirtyRect(r); -} - -void ThemeClassic::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scroll, WidgetStateInfo state) { - if (!_initOk) - return; - restoreBackground(r); - Common::Rect r2 = r; - box(r.left, r.top, r.width(), r.height(), _color, _shadowcolor); - - const int UP_DOWN_BOX_HEIGHT = r.width() + 1; - const int B = 3; - const int arrowSize = (r.width() / 2 - B + 1); - - OverlayColor color = 0; - if (scroll == kScrollbarStateSinglePage) { - color = _color; - } else if (scroll == kScrollbarStateUp && state == kStateHighlight) { - color = _textcolorhi; - } else { - color = _textcolor; - } - - // draws the 'up' button - box(r.left, r.top, r.width(), UP_DOWN_BOX_HEIGHT, _color, _shadowcolor); - Common::Point p0 = Common::Point(r.left + r.width() / 2, r.top + (UP_DOWN_BOX_HEIGHT - arrowSize - 1) / 2); - Common::Point p1 = Common::Point(p0.x - arrowSize, p0.y + arrowSize); - Common::Point p2 = Common::Point(p0.x + arrowSize, p0.y + arrowSize); - for (; p1.x <= p2.x; ++p1.x) - _screen.drawLine(p0.x, p0.y, p1.x, p1.y, color); - - if (scroll != kScrollbarStateSinglePage) { - r2.top += sliderY; - r2.left += 2; - r2.right -= 2; - r2.bottom = r2.top + sliderHeight; - _screen.fillRect(r2, (state == kStateHighlight && scroll == kScrollbarStateSlider) ? _textcolorhi : _textcolor); - box(r2.left, r2.top, r2.width(), r2.height()); - int y = r2.top + sliderHeight / 2; - color = (state == kStateHighlight && scroll == kScrollbarStateSlider) ? _color : _bgcolor; - _screen.hLine(r2.left + 1, y - 2, r2.right - 2, color); - _screen.hLine(r2.left + 1, y, r2.right - 2, color); - _screen.hLine(r2.left + 1, y + 2, r2.right - 2, color); - r2 = r; - } - - r2.top = r2.bottom - UP_DOWN_BOX_HEIGHT; - if (scroll == kScrollbarStateSinglePage) { - color = _color; - } else if (scroll == kScrollbarStateDown && state == kStateHighlight) { - color = _textcolorhi; - } else { - color = _textcolor; - } - - // draws the 'down' button - box(r2.left, r2.top, r2.width(), UP_DOWN_BOX_HEIGHT, _color, _shadowcolor); - p0 = Common::Point(r2.left + r2.width() / 2, r2.top + (UP_DOWN_BOX_HEIGHT + arrowSize + 1) / 2); - p1 = Common::Point(p0.x - arrowSize, p0.y - arrowSize); - p2 = Common::Point(p0.x + arrowSize, p0.y - arrowSize); - for (; p1.x <= p2.x; ++p1.x) - _screen.drawLine(p0.x, p0.y, p1.x, p1.y, color); - - addDirtyRect(r); -} - -void ThemeClassic::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state) { - if (!_initOk) - return; - - OverlayColor color = 0; - if (erase) { - color = _bgcolor; - } else { - color = getColor(state); - } - - _screen.vLine(r.left, r.top, r.bottom - 2, color); - addDirtyRect(r); -} - -void ThemeClassic::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) { - if (!_initOk) - return; - _screen.hLine(r.left - 1, r.top + r.height() / 2, r.right, _shadowcolor); - _screen.hLine(r.left, r.top + 1 + r.height() / 2, r.right, _color); - addDirtyRect(r); -} - -// intern drawing - -void ThemeClassic::restoreBackground(Common::Rect r, bool special) { - r.clip(_screen.w, _screen.h); - r.clip(_drawArea); -#ifdef CT_NO_TRANSPARENCY - _screen.fillRect(r, _bgcolor); -#else - if (_dialog) { - if (!_dialog->screen.pixels) { - _screen.fillRect(r, _bgcolor); - return; - } - const OverlayColor *src = (const OverlayColor*)_dialog->screen.getBasePtr(r.left, r.top); - OverlayColor *dst = (OverlayColor*)_screen.getBasePtr(r.left, r.top); - - int h = r.height(); - int w = r.width(); - while (h--) { - memcpy(dst, src, w*sizeof(OverlayColor)); - src += _dialog->screen.w; - dst += _screen.w; - } - } else { - _screen.fillRect(r, _bgcolor); - } -#endif -} - -bool ThemeClassic::addDirtyRect(Common::Rect r, bool save, bool special) { - // TODO: implement proper dirty rect handling - // FIXME: problem with the 'pitch' - r.clip(_screen.w, _screen.h); - r.clip(_drawArea); - _system->copyRectToOverlay((OverlayColor*)_screen.getBasePtr(r.left, r.top), _screen.w, r.left, r.top, r.width(), r.height()); -#ifndef CT_NO_TRANSPARENCY - if (_dialog && save) { - if (_dialog->screen.pixels) { - OverlayColor *dst = (OverlayColor*)_dialog->screen.getBasePtr(r.left, r.top); - const OverlayColor *src = (const OverlayColor*)_screen.getBasePtr(r.left, r.top); - int h = r.height(); - while (h--) { - memcpy(dst, src, r.width()*sizeof(OverlayColor)); - dst += _dialog->screen.w; - src += _screen.w; - } - } - } -#endif - return true; -} - -void ThemeClassic::box(int x, int y, int width, int height, OverlayColor colorA, OverlayColor colorB, bool skipLastRow) { - if (y >= 0) { - _screen.hLine(x + 1, y, x + width - 2, colorA); - _screen.hLine(x, y + 1, x + width - 1, colorA); - } - int drawY = y; - if (drawY < 0) { - height += drawY; - drawY = 0; - } - _screen.vLine(x, drawY + 1, drawY + height - 2, colorA); - _screen.vLine(x + 1, drawY, drawY + height - 1, colorA); - _screen.vLine(x + width - 1, drawY + 1, drawY + height - 2, colorB); - _screen.vLine(x + width - 2, drawY + 1, drawY + height - 1, colorB); - - if (y + height >= 0 && !skipLastRow) { - _screen.hLine(x + 1, drawY + height - 2, x + width - 1, colorB); - _screen.hLine(x + 1, drawY + height - 1, x + width - 2, colorB); - } -} - -void ThemeClassic::box(int x, int y, int w, int h) { - _screen.hLine(x, y, x + w - 1, _color); - _screen.hLine(x, y + h - 1, x +w - 1, _shadowcolor); - _screen.vLine(x, y, y + h - 1, _color); - _screen.vLine(x + w - 1, y, y + h - 1, _shadowcolor); -} - -OverlayColor ThemeClassic::getColor(State state) { - OverlayColor usedColor = _color; - switch (state) { - case kStateEnabled: - usedColor = _textcolor; - break; - - case kStateHighlight: - usedColor = _textcolorhi; - break; - - default: - break; - } - return usedColor; -} - -#ifndef CT_NO_TRANSPARENCY -void ThemeClassic::blendScreenToDialog() { - Common::Rect rect(0, 0, _screen.w, _screen.h); - - if (!rect.isValidRect()) - return; - - if (_system->hasFeature(OSystem::kFeatureOverlaySupportsAlpha)) { - int a, r, g, b; - uint8 aa, ar, ag, ab; - _system->colorToARGB(_bgcolor, aa, ar, ag, ab); - a = aa*3/(3+1); - if (a < 1) - return; - r = ar * a; - g = ag * a; - b = ab * a; - - OverlayColor *ptr = (OverlayColor*)_dialog->screen.getBasePtr(rect.left, rect.top); - - int h = rect.height(); - int w = rect.width(); - while (h--) { - for (int i = 0; i < w; i++) { - _system->colorToARGB(ptr[i], aa, ar, ag, ab); - int a2 = aa + a - (a*aa)/255; - ptr[i] = _system->ARGBToColor(a2, - ((255-a)*aa*ar/255+r)/a2, - ((255-a)*aa*ag/255+g)/a2, - ((255-a)*aa*ab/255+b)/a2); - } - ptr += _screen.w; - } - } else { - int r, g, b; - uint8 ar, ag, ab; - _system->colorToRGB(_bgcolor, ar, ag, ab); - r = ar * 3; - g = ag * 3; - b = ab * 3; - - OverlayColor *ptr = (OverlayColor*)_dialog->screen.getBasePtr(rect.left, rect.top); - - int h = rect.height(); - int w = rect.width(); - - while (h--) { - for (int i = 0; i < w; i++) { - _system->colorToRGB(ptr[i], ar, ag, ab); - ptr[i] = _system->RGBToColor((ar + r) / (3+1), - (ag + g) / (3+1), - (ab + b) / (3+1)); - } - ptr += _screen.w; - } - } -} -#endif - -void ThemeClassic::setupConfig() { - if (_configFile.hasSection("theme")) { - if (loadConfig()) - return; - } - - static const uint8 colors[][3] = { - { 104, 104, 104 }, - { 64, 64, 64 }, - { 0, 0, 0, }, - { 32, 160, 32 }, - { 0, 255, 0 } - }; - - memcpy(_colors, colors, sizeof(colors)); -} - -bool ThemeClassic::loadConfig() { - Common::String temp; - _configFile.getKey("version", "theme", temp); - if (atoi(temp.c_str()) != THEME_VERSION) { - // TODO: improve this detection and handle it nicer - warning("Theme config uses a different version (you have: '%s', needed is: '%d')", temp.c_str(), THEME_VERSION); - _configFile.clear(); - - // force a theme reload here - loadTheme(_defaultConfig); - return false; - } - - temp.clear(); - _configFile.getKey("type", "theme", temp); - if (0 != temp.compareToIgnoreCase("classic")) { - warning("Theme config is not for the classic style theme"); - _configFile.clear(); - - // force a theme reload here - loadTheme(_defaultConfig); - return false; - } - - getColorFromConfig("color", _colors[kColor][0], _colors[kColor][1], _colors[kColor][2]); - getColorFromConfig("shadowcolor", _colors[kShadowColor][0], _colors[kShadowColor][1], _colors[kShadowColor][2]); - getColorFromConfig("bgcolor", _colors[kBGColor][0], _colors[kBGColor][1], _colors[kBGColor][2]); - getColorFromConfig("textcolor", _colors[kTextColor][0], _colors[kTextColor][1], _colors[kTextColor][2]); - getColorFromConfig("textcolorhi", _colors[kTextColorHi][0], _colors[kTextColorHi][1], _colors[kTextColorHi][2]); - - temp.clear(); - temp = _evaluator->getStringVar("font"); - if (temp.empty() || 0 == temp.compareToIgnoreCase("builtin")) { - if (!_fontName.empty()) - delete _font; - _fontName.clear(); - } else if (temp != _fontName) { - if (!_fontName.empty()) - delete _font; - _font = loadFont(temp.c_str()); - _fontName = temp; - } - - _enableBlending = (_evaluator->getVar("blending") != 0); - - return true; -} - -} // end of namespace GUI - diff --git a/gui/ThemeClassic.h b/gui/ThemeClassic.h deleted file mode 100644 index 28c522b906..0000000000 --- a/gui/ThemeClassic.h +++ /dev/null @@ -1,127 +0,0 @@ -/* 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#ifndef GUI_THEMECLASSIC_H -#define GUI_THEMECLASSIC_H - -#include "gui/theme.h" - -namespace GUI { - -// enable this to disable transparency support for the classic theme -//#define CT_NO_TRANSPARENCY - -class ThemeClassic : public Theme { -public: - ThemeClassic(OSystem *system, const Common::String &config = "classic", const Common::ConfigFile *cfg = 0); - virtual ~ThemeClassic(); - - bool init(); - void deinit(); - - void refresh(); - - void enable(); - void disable(); - - void openDialog(bool topDialog, ShadingStyle = kShadingNone); - void closeAllDialogs(); - - void clearAll(); - void updateScreen(); - - void resetDrawArea(); - - const Graphics::Font *getFont(FontStyle font) const { return _font; } - int getFontHeight(FontStyle font = kFontStyleBold) const { if (_initOk) return _font->getFontHeight(); return 0; } - int getStringWidth(const Common::String &str, FontStyle font) const { if (_initOk) return _font->getStringWidth(str); return 0; } - int getCharWidth(byte c, FontStyle font) const { if (_initOk) return _font->getCharWidth(c); return 0; } - - void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state); - void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); - void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state); - - void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state); - void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints); - void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans); - void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state); - void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state); - void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state); - void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state); - void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align); - void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state); - void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state); - void restoreBackground(Common::Rect r, bool special = false); - bool addDirtyRect(Common::Rect r, bool save = false, bool special = false); - - int getTabSpacing() const; - int getTabPadding() const; - -private: - void box(int x, int y, int width, int height, OverlayColor colorA, OverlayColor colorB, bool skipLastRow = false); - void box(int x, int y, int width, int height); - - OverlayColor getColor(State state); - - OSystem *_system; - Graphics::Surface _screen; - -#ifndef CT_NO_TRANSPARENCY - struct DialogState { - Graphics::Surface screen; - } *_dialog; - - void blendScreenToDialog(); -#endif - bool _enableBlending; - - bool _forceRedraw; - bool _initOk; - bool _enabled; - - Common::String _fontName; - const Graphics::Font *_font; - OverlayColor _color, _shadowcolor; - OverlayColor _bgcolor; - OverlayColor _textcolor; - OverlayColor _textcolorhi; - - enum { - kColor = 0, - kShadowColor = 1, - kBGColor = 2, - kTextColor = 3, - kTextColorHi = 4, - kMaxColors = 5 - }; - uint8 _colors[kMaxColors][3]; - - void setupConfig(); - bool loadConfig(); -}; - -} // end of namespace GUI - -#endif - diff --git a/gui/ThemeModern.cpp b/gui/ThemeModern.cpp deleted file mode 100644 index 45a454e00e..0000000000 --- a/gui/ThemeModern.cpp +++ /dev/null @@ -1,1586 +0,0 @@ -/* 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#ifndef DISABLE_FANCY_THEMES - -#include "gui/ThemeModern.h" -#include "gui/eval.h" - -#include "graphics/imageman.h" -#include "graphics/imagedec.h" -#include "graphics/colormasks.h" -#include "graphics/cursorman.h" - -#include "common/config-manager.h" -#include "common/file.h" - -#define kShadowTr0 8 -#define kShadowTr1 16 -#define kShadowTr2 32 -#define kShadowTr3 64 -#define kShadowTr35 96 -#define kShadowTr4 128 -#define kShadowTr5 192 - -using Graphics::Surface; - -/** Specifies the currently active 16bit pixel format, 555 or 565. */ -extern int gBitFormat; - -namespace GUI { - -// TODO: This should be moved to ThemeModern -OverlayColor getColorAlpha(OverlayColor col1, OverlayColor col2, int alpha); -OverlayColor calcGradient(OverlayColor start, OverlayColor end, int pos, int max, uint factor); -void getStateColor(OverlayColor &s, OverlayColor &e, OverlayColor enabledS, OverlayColor enabledE, OverlayColor highlightS, OverlayColor highlightE, Theme::WidgetStateInfo state); - -#pragma mark - - -ThemeModern::ThemeModern(OSystem *system, const Common::String &stylefile, const Common::ConfigFile *cfg) : Theme(), _system(system), _screen(), _initOk(false), -_forceRedraw(false), _lastUsedBitMask(0), _fonts(), _cursor(0), _imageHandles(), _images(0), _colors(), _gradientFactors() { - _stylefile = stylefile; - _initOk = false; - _enabled = false; - _useCursor = false; - memset(&_screen, 0, sizeof(_screen)); - memset(&_dialog, 0, sizeof(_dialog)); - memset(&_colors, 0, sizeof(_colors)); - memset(&_gradientFactors, 0, sizeof(_gradientFactors)); - - _screen.create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(OverlayColor)); - if (_screen.pixels) { - _initOk = true; - clearAll(); - } - - if (cfg) { - _configFile = *cfg; - } else { - if (!loadConfigFile(stylefile)) { - warning("Can not find theme config file '%s'", (stylefile + ".ini").c_str()); - return; - } - } - - ImageMan.addArchive(stylefile + ".zip"); - - Common::String temp; - _configFile.getKey("version", "theme", temp); - if (atoi(temp.c_str()) != THEME_VERSION) { - // TODO: improve this detection and handle it nicer - warning("Theme config uses a different version (you have: '%s', needed is: '%d')", temp.c_str(), THEME_VERSION); - return; - } - - temp.clear(); - _configFile.getKey("type", "theme", temp); - if (0 != temp.compareToIgnoreCase("modern")) { - warning("Theme config is not for the modern style theme"); - return; - } - - if (_configFile.hasKey("name", "theme")) - _configFile.getKey("name", "theme", _stylename); - else - _stylename = _stylefile; - - _images = new const Graphics::Surface*[kImageHandlesMax]; - assert(_images); - - _lastUsedBitMask = gBitFormat; -} - -ThemeModern::~ThemeModern() { - deleteFonts(); - deinit(); - delete[] _images; - delete[] _cursor; - _images = 0; - for (int i = 0; i < kImageHandlesMax; ++i) { - ImageMan.unregisterSurface(_imageHandles[i]); - } - ImageMan.remArchive(_stylefile + ".zip"); -} - -bool ThemeModern::init() { - if (!_images) - return false; - - deinit(); - _screen.create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(OverlayColor)); - if (_screen.pixels) { - _initOk = true; - clearAll(); - resetDrawArea(); - } - - if (isThemeLoadingRequired()) { - loadTheme(_defaultConfig); - loadTheme(_configFile, false, true); // Don't reset - - processExtraValues(); - } - - for (int i = 0; i < kImageHandlesMax; ++i) { - if (!_images[i]) { - return false; - } - } - - return true; -} - -void ThemeModern::deinit() { - if (_initOk) { - _system->hideOverlay(); - _screen.free(); - _initOk = false; - } -} - -void ThemeModern::refresh() { - init(); - resetupGuiRenderer(); - if (_enabled) { - _system->showOverlay(); - CursorMan.replaceCursorPalette(_cursorPal, 0, MAX_CURS_COLORS); - CursorMan.replaceCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY, 255, _cursorTargetScale); - } -} - -void ThemeModern::enable() { - init(); - resetupGuiRenderer(); - resetDrawArea(); - if (_useCursor) - setUpCursor(); - _system->showOverlay(); - clearAll(); - _enabled = true; -} - -void ThemeModern::disable() { - _system->hideOverlay(); - if (_useCursor) { - CursorMan.popCursorPalette(); - CursorMan.popCursor(); - } - _enabled = false; -} - -void ThemeModern::openDialog(bool topDialog, ShadingStyle shading) { - if (!_dialog) { - _dialog = new DialogState; - assert(_dialog); - // first dialog - _dialog->screen.create(_screen.w, _screen.h, sizeof(OverlayColor)); - } - - if (_dialogShadingCallback && topDialog) { - OverlayColor *col = (OverlayColor*)_screen.pixels; - for (int y = 0; y < _screen.h; ++y) { - for (int x = 0; x < _screen.w; ++x) { - col[x] = (this->*(_dialogShadingCallback))(col[x]); - } - col += _screen.w; - } - } - - memcpy(_dialog->screen.pixels, _screen.pixels, _screen.pitch*_screen.h); - - if ((_dialogShadingCallback) && topDialog) - addDirtyRect(Common::Rect(0, 0, _screen.w, _screen.h), false, false); -} - -void ThemeModern::closeAllDialogs() { - if (_dialog) { - _dialog->screen.free(); - delete _dialog; - _dialog = 0; - } - _forceRedraw = true; -} - -void ThemeModern::clearAll() { - if (!_initOk) - return; - _system->clearOverlay(); - // FIXME: problem with the 'pitch' - _system->grabOverlay((OverlayColor*)_screen.pixels, _screen.w); -} - -void ThemeModern::updateScreen() { - // TODO: see ThemeModern::addDirtyRect - _forceRedraw = false; -} - -void ThemeModern::setDrawArea(const Common::Rect &r) { - if (_initOk) { - _drawArea = r; - _shadowDrawArea = Common::Rect(r.left-_shadowLeftWidth, r.top-_shadowTopHeight, r.right+_shadowRightWidth, r.bottom+_shadowBottomHeight); - _drawArea.clip(_screen.w, _screen.h); - _shadowDrawArea.clip(_screen.w, _screen.h); - } -} - -void ThemeModern::resetDrawArea() { - if (_initOk) { - _drawArea = Common::Rect(0, 0, _screen.w, _screen.h); - _shadowDrawArea = _drawArea; - } -} - -#define surface(x) (_images[x]) - -void ThemeModern::drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state) { - if (!_initOk) - return; - - Common::Rect r2 = shadowRect(r, kShadowFull); - - if ((hints & THEME_HINT_SAVE_BACKGROUND) && !(hints & THEME_HINT_FIRST_DRAW) && !_forceRedraw) { - restoreBackground(r2, true); - addDirtyRect(r2); - return; - } - - if (hints & THEME_HINT_MAIN_DIALOG) { - colorFade(r, _colors[kMainDialogStart], _colors[kMainDialogEnd], _gradientFactors[kMainDialogFactor]); - } else if (hints & THEME_HINT_SPECIAL_COLOR) { - drawShadow(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), kShadowFull); - - drawRectMasked(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), - 256, _colors[kMainDialogStart], _colors[kMainDialogEnd], _gradientFactors[kDialogSpecialFactor]); - } else if (hints & THEME_HINT_PLAIN_COLOR) { - drawShadow(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), kShadowFull); - - drawRectMasked(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), - 256, _colors[kDialogEnd], _colors[kDialogEnd], _gradientFactors[kDialogFactor]); - } else { - drawShadow(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), kShadowFull); - - drawRectMasked(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), - 256, _colors[kDialogStart], _colors[kDialogEnd], _gradientFactors[kDialogFactor]); - } - - addDirtyRect(r2, (hints & THEME_HINT_SAVE_BACKGROUND) != 0, true); -} - -void ThemeModern::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) { - if (!_initOk) - return; - - uint32 color; - - restoreBackground(r); - - if (inverted) { - _screen.fillRect(r, _colors[kTextInvertedBackground]); - color = _colors[kTextInvertedColor]; - } else { - color = getColor(state); - } - - getFont(font)->drawString(&_screen, str, r.left, r.top, r.width(), color, convertAligment(align), deltax, useEllipsis); - addDirtyRect(r); -} - -void ThemeModern::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state) { - if (!_initOk) - return; - restoreBackground(r); - font->drawChar(&_screen, ch, r.left, r.top, getColor(state)); - addDirtyRect(r); -} - -void ThemeModern::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) { - if (!_initOk) - return; - - Common::Rect r2; - - ImageHandles corner, top, left, bkgd; - ShadowStyles shadow; - ColorHandles start, end; - GradientFactors factor; - - switch (background) { - case kWidgetBackgroundBorderSmall: - corner = kWidgetSmallBkgdCorner; - top = kWidgetSmallBkgdTop; - left = kWidgetSmallBkgdLeft; - bkgd = kWidgetSmallBkgd; - shadow = kShadowSmall; - start = kWidgetBackgroundSmallStart; - end = kWidgetBackgroundSmallEnd; - factor = kWidgetSmallFactor; - break; - case kWidgetBackgroundEditText: - corner = kEditTextBkgdCorner; - top = kEditTextBkgdTop; - left = kEditTextBkgdLeft; - bkgd = kEditTextBkgd; - shadow = kShadowEmboss; - start = kEditTextBackgroundStart; - end = kEditTextBackgroundEnd; - factor = kEditTextFactor; - break; - case kWidgetBackgroundSlider: - corner = kSliderBkgdCorner; - top = kSliderBkgdTop; - left = kSliderBkgdLeft; - bkgd = kSliderBkgd; - shadow = kShadowEmboss; - start = kSliderBackgroundStart; - end = kSliderBackgroundEnd; - factor = kSliderBackground; - break; - default: - corner = kWidgetBkgdCorner; - top = kWidgetBkgdTop; - left = kWidgetBkgdLeft; - bkgd = kWidgetBkgd; - shadow = kShadowFull; - if (hints & THEME_HINT_PLAIN_COLOR) - start = kWidgetBackgroundEnd; - else - start = kWidgetBackgroundStart; - end = kWidgetBackgroundEnd; - factor = kWidgetFactor; - break; - } - - if ((hints & THEME_HINT_SAVE_BACKGROUND) && !(hints & THEME_HINT_FIRST_DRAW) && !_forceRedraw) { - restoreBackground((hints & THEME_HINT_USE_SHADOW) ? r2 : r); - addDirtyRect((hints & THEME_HINT_USE_SHADOW) ? r2 : r); - return; - } - - if ((hints & THEME_HINT_USE_SHADOW)) { - r2 = shadowRect(r, shadow); - restoreBackground(r2); - // shadow - drawShadow(r, surface(corner), surface(top), surface(left), surface(bkgd), shadow); - } - - drawRectMasked(r, surface(corner), surface(top), surface(left), surface(bkgd), - (state == kStateDisabled) ? -30 : 256, _colors[start], _colors[end], - _gradientFactors[factor]); - - addDirtyRect((hints & THEME_HINT_USE_SHADOW) ? r2 : r, (hints & THEME_HINT_SAVE_BACKGROUND) != 0); -} - -void ThemeModern::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) { - if (!_initOk) - return; - - Common::Rect r2 = shadowRect(r, kShadowButton); - - if (!(hints & THEME_HINT_NO_BACKGROUND_RESTORE) || state == kStateDisabled) - restoreBackground(r2); - - // shadow - drawShadow(r, surface(kButtonBkgdCorner), surface(kButtonBkgdTop), surface(kButtonBkgdLeft), surface(kButtonBkgd), kShadowButton); - - OverlayColor start, end; - int alpha = 256; - - getStateColor(start, end, _colors[kButtonBackgroundStart], _colors[kButtonBackgroundEnd], - _colors[kButtonBackgroundHighlightStart], _colors[kButtonBackgroundHighlightEnd], state); - - if (state != kStateHighlight) - alpha = (state == kStateDisabled) ? -30 : 256; - - drawRectMasked(r, surface(kButtonBkgdCorner), surface(kButtonBkgdTop), surface(kButtonBkgdLeft), surface(kButtonBkgd), - alpha, start, end, _gradientFactors[kButtonFactor]); - - const int off = (r.height() - getFontHeight()) / 2; - - OverlayColor col = 0; - switch (state) { - case kStateEnabled: - col = _colors[kButtonTextEnabled]; - break; - - case kStateHighlight: - col = _colors[kButtonTextHighlight]; - break; - - default: - col = _colors[kButtonTextDisabled]; - break; - }; - - getFont()->drawString(&_screen, str, r.left, r.top + off, r.width(), col, Graphics::kTextAlignCenter, 0, true); - - addDirtyRect(r2); -} - -void ThemeModern::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) { - if (!_initOk) - return; - - Common::Rect rect(r.left, r.top, r.left + surface.w, r.top + surface.h); - rect.clip(_screen.w, _screen.h); - - if (!rect.isValidRect()) - return; - - assert(surface.bytesPerPixel == sizeof(OverlayColor)); - - if (alpha != 256) - restoreBackground(rect); - - if (themeTrans) - drawSurface(rect, &surface, false, false, alpha); - else { - OverlayColor *dst = (OverlayColor*)_screen.getBasePtr(rect.left, rect.top); - const OverlayColor *src = (OverlayColor*)surface.pixels; - - int h = rect.height(); - if (alpha == 256) { - while (h--) { - memcpy(dst, src, surface.pitch); - dst += _screen.w; - src += surface.w; - } - } else { - int w = rect.width(); - while (h--) { - for (int i = 0; i < w; ++i) { - *dst = getColorAlpha(*src, *dst, alpha); - } - dst += _screen.w; - src += surface.w; - } - } - } - - addDirtyRect(rect); -} - -void ThemeModern::drawSlider(const Common::Rect &rr, int width, WidgetStateInfo state) { - if (!_initOk) - return; - - Common::Rect r = rr; - - r.left++; - r.right++; - - drawWidgetBackground(r, THEME_HINT_USE_SHADOW, kWidgetBackgroundSlider, kStateEnabled); - - Common::Rect r2 = r; - r2.left = r.left; - r2.top = r.top; - r2.bottom = r.bottom-1; - r2.right = r2.left + width-1; - if (r2.right > r.right) { - r2.right = r.right; - } - - drawShadow(r2, surface(kButtonBkgdCorner), surface(kButtonBkgdTop), surface(kButtonBkgdLeft), surface(kButtonBkgd), kShadowButton); - - OverlayColor start, end; - int alpha = 256; - - getStateColor(start, end, _colors[kSliderStart], _colors[kSliderEnd], _colors[kSliderHighStart], _colors[kSliderHighEnd], state); - - if (state != kStateHighlight) - alpha = (state == kStateDisabled) ? -30 : 256; - - drawRectMasked(r2, surface(kSliderCorner), surface(kSliderTop), surface(kSliderLeft), surface(kSliderBkgd), - alpha, start, end, _gradientFactors[kSliderFactor]); - - addDirtyRect(r); -} - -void ThemeModern::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align) { - if (!_initOk) - return; - - Common::Rect r2 = shadowRect(r, kShadowSmall); - restoreBackground(r2); - - OverlayColor start = _colors[kPopUpWidgetStart], end = _colors[kPopUpWidgetEnd]; - if (state == kStateHighlight) { - start = _colors[kPopUpWidgetHighlightStart]; - end = _colors[kPopUpWidgetHighlightEnd]; - } - - drawShadow(r, surface(kDialogBkgdCorner), surface(kDialogBkgdTop), surface(kDialogBkgdLeft), surface(kDialogBkgd), kShadowPopUp); - - drawRectMasked(r, surface(kPopUpWidgetBkgdCorner), surface(kPopUpWidgetBkgdTop), surface(kPopUpWidgetBkgdLeft), surface(kPopUpWidgetBkgd), - (state == kStateDisabled) ? -30 : 256, start, end, _gradientFactors[kPopUpWidgetFactor]); - - const Graphics::Surface *arrow = surface(kWidgetArrow); - - int yOff = r.height() / 2 - arrow->h; - if (yOff < 0) - yOff = 0; - - Common::Rect arrowRect(r.right - 4 - arrow->w, r.top + yOff, r.right - 4, r.top + yOff + arrow->h); - arrowRect.clip(r); - - drawSurface(arrowRect, arrow, false, false, (state == kStateDisabled) ? -30 : 256); - - arrowRect.top += arrow->h; - arrowRect.bottom += arrow->h; - arrowRect.clip(r); - drawSurface(arrowRect, arrow, true, false, (state == kStateDisabled) ? -30 : 256); - - if (!sel.empty()) { - Common::Rect text(r.left + 2, r.top + 3, r.right - 4, r.top + 3 + getFont()->getFontHeight()); - getFont()->drawString(&_screen, sel, text.left, text.top, text.width(), getColor(state), convertAligment(align), deltax, false); - } - - addDirtyRect(r2); -} - -void ThemeModern::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) { - if (!_initOk) - return; - Common::Rect r2 = r; - - const Graphics::Surface *checkBox = surface(checked ? kCheckboxChecked : kCheckboxEmpty); - int checkBoxSize = checkBox->w; - - restoreBackground(Common::Rect(r.left, r.top, r.left+checkBox->w, r.top+checkBox->h)); - - drawSurface(Common::Rect(r.left, r.top, r.left+checkBox->w, r.top+checkBox->h), checkBox, false, false, (state == kStateDisabled) ? 128 : 256); - - r2.left += checkBoxSize + 5; - getFont()->drawString(&_screen, str, r2.left, r2.top, r2.width(), getColor(state), Graphics::kTextAlignLeft, 0, false); - - addDirtyRect(r); -} - -void ThemeModern::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) { - if (!_initOk) - return; - - restoreBackground(r); - - // whole tab background - drawRectMasked(r, surface(kTabBkgdCorner), surface(kTabBkgdTop), surface(kTabBkgdLeft), surface(kTabBkgd), - /*(state == kStateDisabled) ? -30 : */256, _colors[kTabBackgroundStart], _colors[kTabBackgroundEnd], - _gradientFactors[kTabFactor]); - - OverlayColor tabEnd = calcGradient(_colors[kTabActiveStart], _colors[kTabActiveEnd], tabHeight, r.height()-1, _gradientFactors[kTabFactor]); - - const int tabOffset = 1; - - // tab shadows - for (int i = 0; i < (int)tabs.size(); ++i) { - Common::Rect tabRect(r.left + i * (tabWidth + tabOffset), r.top, r.left + i * (tabWidth + tabOffset) + tabWidth, r.top + tabHeight); - drawShadow(tabRect, surface(kTabBkgdCorner), surface(kTabBkgdTop), surface(kTabBkgdLeft), surface(kTabBkgd), - kShadowSmall, true); - } - - // inactive tabs - for (int i = 0; i < (int)tabs.size(); ++i) { - if (i == active) - continue; - - Common::Rect tabRect(r.left + i * (tabWidth + tabOffset), r.top, r.left + i * (tabWidth + tabOffset) + tabWidth, r.top + tabHeight + 5); - drawRectMasked(tabRect, surface(kTabBkgdCorner), surface(kTabBkgdTop), surface(kTabBkgdLeft), surface(kTabBkgd), - 256, _colors[kTabInactiveStart], _colors[kTabInactiveEnd], _gradientFactors[kTabFactor], true); - - getFont()->drawString(&_screen, tabs[i], tabRect.left, tabRect.top+titleVPad, tabRect.width(), getColor(kStateEnabled), Graphics::kTextAlignCenter, 0, true); - } - - // area shadow - Common::Rect widgetBackground = Common::Rect(r.left, r.top + tabHeight - 1, r.right, r.top - + tabHeight + 20); - drawShadow(widgetBackground, surface(kTabBkgdCorner), surface(kTabBkgdTop), surface(kTabBkgdLeft), surface(kTabBkgd), - kShadowSmall); - - // area itself - widgetBackground = Common::Rect(r.left, r.top + tabHeight, r.right, r.bottom); - drawRectMasked(widgetBackground, surface(kTabBkgdCorner), surface(kTabBkgdTop), surface(kTabBkgdLeft), surface(kTabBkgd), - /*(state == kStateDisabled) ? -30 : */256, tabEnd, _colors[kTabActiveEnd], - _gradientFactors[kTabFactor]); - addDirtyRect(widgetBackground, true); - - // active tab - if (active >= 0) { - Common::Rect tabRect(r.left + active * (tabWidth + tabOffset), r.top, r.left + active * (tabWidth + tabOffset) + tabWidth, r.top + tabHeight + 5); - - Common::Rect shadowRect2(tabRect.left, r.top, tabRect.right, tabRect.bottom - 6); - drawShadow(shadowRect2, surface(kTabBkgdCorner), surface(kTabBkgdTop), surface(kTabBkgdLeft), surface(kTabBkgd), kShadowSmall, false, true); - - drawRectMasked(tabRect, surface(kTabBkgdCorner), surface(kTabBkgdTop), surface(kTabBkgdLeft), surface(kTabBkgd), - 256, _colors[kTabActiveStart], tabEnd, _gradientFactors[kTabFactor], true); - - - getFont()->drawString(&_screen, tabs[active], tabRect.left, tabRect.top+titleVPad, tabRect.width(), getColor(kStateEnabled), Graphics::kTextAlignCenter, 0, true); - } - - addDirtyRect(Common::Rect(r.left, r.top-2, r.right, r.bottom)); -} - -void ThemeModern::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) { - if (!_initOk) - return; - const int UP_DOWN_BOX_HEIGHT = r.width() + 1; - Common::Rect r2 = r; - - // draws the scrollbar background - drawRectMasked(r2, surface(kScrollbarBkgdCorner), surface(kScrollbarBkgdTop), surface(kScrollbarBkgdLeft), surface(kScrollbarBkgd), 256, - _colors[kScrollbarBackgroundStart], _colors[kScrollbarBackgroundEnd], _gradientFactors[kScrollbarBkgdFactor]); - - // draws the 'up' button - OverlayColor buttonStart = _colors[kScrollbarButtonStart]; - OverlayColor buttonEnd = _colors[kScrollbarButtonEnd]; - - if (scrollState == kScrollbarStateUp) - getStateColor(buttonStart, buttonEnd, buttonStart, buttonEnd, _colors[kScrollbarButtonHighlightStart], _colors[kScrollbarButtonHighlightEnd], state); - - r2.bottom = r2.top + UP_DOWN_BOX_HEIGHT; - drawRectMasked(r2, surface(kScrollbarBkgdCorner), surface(kScrollbarBkgdTop), surface(kScrollbarBkgdLeft), surface(kScrollbarBkgd), 256, - buttonStart, buttonEnd, _gradientFactors[kScrollbarBkgdFactor]); - - const Graphics::Surface *arrow = surface(kWidgetArrow); - r2.left += 1 + (r2.width() - arrow->w) / 2; - r2.right = r2.left + arrow->w; - r2.top += (r2.height() - arrow->h) / 2; - r2.bottom = r2.top + arrow->h; - drawSurface(r2, arrow, false, false, 256); - - // draws the slider - OverlayColor sliderStart = _colors[kScrollbarSliderStart]; - OverlayColor sliderEnd = _colors[kScrollbarSliderEnd]; - - if (scrollState == kScrollbarStateSlider) - getStateColor(sliderStart, sliderEnd, sliderStart, sliderEnd, _colors[kScrollbarSliderHighlightStart], _colors[kScrollbarSliderHighlightEnd], state); - - r2 = r; - r2.left += 1; - r2.right -= 1; - r2.top += sliderY; - r2.bottom = r2.top + sliderHeight - 1; - - drawShadow(r2, surface(kSliderCorner), surface(kSliderTop), surface(kSliderLeft), surface(kSliderBkgd), kShadowSmall); - - r2.left += 1; - r2.right -= 1; - - r2.bottom = r2.top + sliderHeight / 2 + surface(kScrollbarCorner)->h + 4; - drawRectMasked(r2, surface(kScrollbarCorner), surface(kScrollbarTop), surface(kScrollbarLeft), surface(kScrollbarBkgd), 256, - sliderStart, sliderEnd, _gradientFactors[kScrollbarFactor]); - r2.top += sliderHeight / 2; - r2.bottom += sliderHeight / 2 - surface(kScrollbarCorner)->h - 4; - drawRectMasked(r2, surface(kScrollbarCorner), surface(kScrollbarTop), surface(kScrollbarLeft), surface(kScrollbarBkgd), 256, - sliderEnd, sliderStart, _gradientFactors[kScrollbarFactor]); - - // draws the 'down' button - buttonStart = _colors[kScrollbarButtonStart]; - buttonEnd = _colors[kScrollbarButtonEnd]; - - if (scrollState == kScrollbarStateDown) - getStateColor(buttonStart, buttonEnd, buttonStart, buttonEnd, _colors[kScrollbarButtonHighlightStart], _colors[kScrollbarButtonHighlightEnd], state); - - r2 = r; - r2.top = r2.bottom - UP_DOWN_BOX_HEIGHT; - drawRectMasked(r2, surface(kScrollbarBkgdCorner), surface(kScrollbarBkgdTop), surface(kScrollbarBkgdLeft), surface(kScrollbarBkgd), 256, - buttonStart, buttonEnd, _gradientFactors[kScrollbarBkgdFactor]); - - r2.left += 1 + (r2.width() - arrow->w) / 2; - r2.right = r2.left + arrow->w; - r2.top += (r2.height() - arrow->h) / 2; - r2.bottom = r2.top + arrow->h; - drawSurface(r2, arrow, true, false, 256); - - addDirtyRect(r); -} - -void ThemeModern::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state) { - if (!_initOk) - return; - - restoreBackground(r); - if (!erase) { - _screen.vLine(r.left, r.top, r.bottom-1, _colors[kCaretColor]); - } else if (r.top >= 0) { - // FIXME: hack to restore the caret background correctly - const OverlayColor search = _colors[kTextInvertedBackground]; - const OverlayColor *src = (const OverlayColor*)_screen.getBasePtr(r.left-1, r.top-1); - int height = r.height() + 2; - if (r.top + height > _screen.h) { - height = _screen.h - r.top; - } - bool drawInvBackground = false; - while (height--) { - if (src[0] == search || src[1] == search || src[2] == search) { - drawInvBackground = true; - } - src += _screen.w; - } - if (drawInvBackground) { - _screen.vLine(r.left, r.top, r.bottom-1, search); - } - } - addDirtyRect(r); -} - -void ThemeModern::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) { - if (!_initOk) - return; - _screen.hLine(r.left - 1, r.top + r.height() / 2, r.right, _system->RGBToColor(0, 0, 0)); - addDirtyRect(r); -} - -int ThemeModern::getTabSpacing() const { - return 0; -} -int ThemeModern::getTabPadding() const { - return 3; -} - -#pragma mark - intern drawing - -void ThemeModern::restoreBackground(Common::Rect r, bool special) { - r.clip(_screen.w, _screen.h); - if (special) { - r.clip(_shadowDrawArea); - } else { - r.clip(_drawArea); - } - if (_dialog) { - if (!_dialog->screen.pixels) { - return; - } - const OverlayColor *src = (const OverlayColor*)_dialog->screen.getBasePtr(r.left, r.top); - OverlayColor *dst = (OverlayColor*)_screen.getBasePtr(r.left, r.top); - - int h = r.height(); - int w = r.width(); - while (h--) { - memcpy(dst, src, w*sizeof(OverlayColor)); - src += _dialog->screen.w; - dst += _screen.w; - } - } -} - -bool ThemeModern::addDirtyRect(Common::Rect r, bool backup, bool special) { - // TODO: implement proper dirty rect handling - // FIXME: problem with the 'pitch' - r.clip(_screen.w, _screen.h); - if (special) { - r.clip(_shadowDrawArea); - } else { - r.clip(_drawArea); - } - _system->copyRectToOverlay((OverlayColor*)_screen.getBasePtr(r.left, r.top), _screen.w, r.left, r.top, r.width(), r.height()); - if (_dialog && backup) { - if (_dialog->screen.pixels) { - OverlayColor *dst = (OverlayColor*)_dialog->screen.getBasePtr(r.left, r.top); - const OverlayColor *src = (const OverlayColor*)_screen.getBasePtr(r.left, r.top); - int h = r.height(); - while (h--) { - memcpy(dst, src, r.width()*sizeof(OverlayColor)); - dst += _dialog->screen.w; - src += _screen.w; - } - } - } - return true; -} - -void ThemeModern::colorFade(const Common::Rect &r, OverlayColor start, OverlayColor end, uint factor) { - OverlayColor *ptr = (OverlayColor*)_screen.getBasePtr(r.left, r.top); - const int h = r.height(); - const int w = r.width(); - const int lastRow = r.height() - 1; - const int ptrAdd = _screen.w - r.width(); - for (int l = 0; l < h; ++l) { - OverlayColor col = calcGradient(start, end, l, lastRow, factor); - for (int i = 0; i < w; ++i) { - *ptr++ = col; - } - ptr += ptrAdd; - } -} - -void ThemeModern::drawRect(const Common::Rect &r, const Surface *corner, const Surface *top, const Surface *left, const Surface *fill, int alpha, bool skipLastRow) { - drawRectMasked(r, corner, top, left, fill, alpha, _system->RGBToColor(255, 255, 255), _system->RGBToColor(255, 255, 255), 1, skipLastRow); -} - -void ThemeModern::drawRectMasked(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top, - const Graphics::Surface *left, const Graphics::Surface *fill, int alpha, - OverlayColor start, OverlayColor end, uint factor, bool skipLastRow, bool skipTopRow) { - int drawWidth = MIN(corner->w, MIN(top->w, MIN(left->w, fill->w))); - int drawHeight = MIN(corner->h, MIN(top->h, MIN(left->h, fill->h))); - int partsH = r.height() / drawHeight; - int partsW = r.width() / drawWidth; - int yPos = r.top; - - int specialHeight = 0; - int specialWidth = 0; - - if (drawHeight*2 > r.height()) { - drawHeight = r.height() / 2; - partsH = 2; - } else { - specialHeight = r.height() % drawHeight; - if (specialHeight != 0) - ++partsH; - } - - if (drawWidth*2 > r.width()) { - drawWidth = r.width() / 2; - partsW = 2; - } else { - specialWidth = r.width() % drawWidth; - if (specialWidth != 0) - ++partsW; - } - - for (int y = 0; y < partsH; ++y) { - int xPos = r.left; - bool upDown = (y == partsH - 1); - - // calculate the correct drawing height - int usedHeight = drawHeight; - if (specialHeight && y == 1) { - usedHeight = specialHeight; - } - - OverlayColor startCol = calcGradient(start, end, yPos-r.top, r.height()-1, factor); - OverlayColor endCol = calcGradient(start, end, yPos-r.top+usedHeight, r.height()-1, factor); - - for (int i = 0; i < partsW; ++i) { - // calculate the correct drawing width - int usedWidth = drawWidth; - if (specialWidth && i == 1) { - usedWidth = specialWidth; - } - - // draw the right surface - if (!i || i == partsW - 1) { - if ((!y && !skipTopRow) || (y == partsH - 1 && !skipLastRow)) { - drawSurfaceMasked(Common::Rect(xPos, yPos, xPos+usedWidth, yPos+usedHeight), corner, upDown, (i == partsW - 1), alpha, startCol, endCol); - } else { - drawSurfaceMasked(Common::Rect(xPos, yPos, xPos+usedWidth, yPos+usedHeight), left, upDown, (i == partsW - 1), alpha, startCol, endCol); - } - } else if (!y || (y == partsH - 1 && !skipLastRow)) { - drawSurfaceMasked(Common::Rect(xPos, yPos, xPos+usedWidth, yPos+usedHeight), top, upDown, false, alpha, startCol, endCol); - } else { - drawSurfaceMasked(Common::Rect(xPos, yPos, xPos+usedWidth, yPos+usedHeight), fill, false, false, alpha, startCol, endCol); - } - xPos += usedWidth; - } - - yPos += usedHeight; - } -} - -Common::Rect ThemeModern::shadowRect(const Common::Rect &r, uint32 shadowStyle) { - switch (shadowStyle) { - case kShadowButton: - return Common::Rect(r.left - 1, r.top - 1, r.right + 1, r.bottom + 1); - - case kShadowEmboss: - return Common::Rect(r.left - 1, r.top - 1, r.right + 1, r.bottom + 1); - - case kShadowPopUp: - return Common::Rect(r.left - 1, r.top - 1, r.right + 3, r.bottom + 3); - - case kShadowFull: - return Common::Rect(r.left - 2, r.top - 2, r.right + 4, r.bottom + 4); - - default: - return Common::Rect(r.left - _shadowLeftWidth/2, r.top - _shadowTopHeight/2, r.right + _shadowRightWidth/2 + 1, r.bottom + _shadowBottomHeight/2 + 1); - } - - return Common::Rect(); -} - -void ThemeModern::drawShadow(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top, - const Graphics::Surface *left, const Graphics::Surface *fill, uint32 shadowStyle, bool skipLastRow, bool skipTopRow) { - switch (shadowStyle) { - case kShadowFull: { - Common::Rect r2(r.left-1, r.top-1, r.right + 4, r.bottom + 4); - Common::Rect r3(r.left, r.top+1, r.right + 3, r.bottom + 3); - Common::Rect r4(r.left, r.top+1, r.right + 2, r.bottom + 2); - Common::Rect r5(r.left, r.top, r.right + 1, r.bottom + 1); - - drawShadowRect(r2, r, corner, top, left, fill, kShadowTr0, skipLastRow, skipTopRow); - drawShadowRect(r3, r, corner, top, left, fill, kShadowTr1, skipLastRow, skipTopRow); - drawShadowRect(r4, r, corner, top, left, fill, kShadowTr2, skipLastRow, skipTopRow); - drawShadowRect(r5, r, corner, top, left, fill, kShadowTr3, skipLastRow, skipTopRow); - //drawShadowRect(r5, r, corner, top, left, fill, kShadowTr35, skipLastRow); - } break; - - case kShadowSmall: { - Common::Rect r3(r.left - _shadowLeftWidth/2, r.top - _shadowTopHeight/2, r.right + _shadowRightWidth/2, r.bottom + _shadowBottomHeight/2); - Common::Rect r4(r.left - _shadowLeftWidth/2 + 1, r.top - _shadowTopHeight/2 + 1, r.right + _shadowRightWidth/2-1, r.bottom + _shadowBottomHeight/2-1); - - drawShadowRect(r3, r, corner, top, left, fill, kShadowTr1, skipLastRow, skipTopRow); - drawShadowRect(r4, r, corner, top, left, fill, kShadowTr2, skipLastRow, skipTopRow); - } break; - - case kShadowButton: { - Common::Rect r2(r.left-1, r.top - 1, r.right, r.bottom); - Common::Rect r4(r.left, r.top, r.right + 1, r.bottom + 1); - - drawShadowRect(r2, r, corner, top, left, fill, -kShadowTr35-256, skipLastRow, skipTopRow); - drawShadowRect(r4, r, corner, top, left, fill, kShadowTr4, skipLastRow, skipTopRow); - } break; - - case kShadowEmboss: { - Common::Rect r2(r.left - 1, r.top - 1, r.right, r.bottom); - Common::Rect r4(r.left + 1, r.top + 1, r.right + 1, r.bottom + 1); - - drawShadowRect(r2, r, corner, top, left, fill, kShadowTr5, skipLastRow, skipTopRow); - drawShadowRect(r4, r, corner, top, left, fill, kShadowTr1, skipLastRow, skipTopRow); - } break; - - case kShadowPopUp: { - Common::Rect r2(r.left, r.top, r.right + 3, r.bottom + 3); - Common::Rect r25(r.left-1, r.top-1, r.right + 2, r.bottom + 2); - Common::Rect r3(r.left - 1, r.top-1, r.right, r.bottom); - Common::Rect r4(r.left, r.top, r.right + 1, r.bottom + 1); - - drawShadowRect(r2, r, corner, top, left, fill, kShadowTr1, skipLastRow, skipTopRow); - drawShadowRect(r25, r, corner, top, left, fill, kShadowTr2, skipLastRow, skipTopRow); - drawShadowRect(r4, r, corner, top, left, fill, kShadowTr3, skipLastRow, skipTopRow); - drawShadowRect(r3, r, corner, top, left, fill, -kShadowTr35-256, skipLastRow, skipTopRow); - } break; - - default: - break; - } -} - -void ThemeModern::drawShadowRect(const Common::Rect &r, const Common::Rect &area, const Graphics::Surface *corner, - const Graphics::Surface *top, const Graphics::Surface *left, const Graphics::Surface *fill, - int alpha, bool skipLastRow, bool skipTopRow) { - int drawWidth = MIN(corner->w, MIN(top->w, MIN(left->w, fill->w))); - int drawHeight = MIN(corner->h, MIN(top->h, MIN(left->h, fill->h))); - int partsH = r.height() / drawHeight; - int partsW = r.width() / drawWidth; - int yPos = r.top; - - int yDrawTilesTop = 1 + (ABS(area.top - r.top) % drawHeight); - int xDrawTilesLeft = 1 + (ABS(area.left - r.left) % drawWidth); - int yDrawTilesBottom = 1 + (ABS(area.bottom - r.bottom) % drawHeight); - int xDrawTilesRight = 1 + (ABS(area.right - r.right) % drawWidth); - - int specialHeight = 0; - int specialWidth = 0; - - if (drawHeight*2 > r.height()) { - drawHeight = r.height() / 2; - partsH = 2; - } else { - specialHeight = r.height() % drawHeight; - if (specialHeight != 0) - ++partsH; - } - - if (drawWidth*2 > r.width()) { - drawWidth = r.width() / 2; - partsW = 2; - } else { - specialWidth = r.width() % drawWidth; - if (specialWidth != 0) - ++partsW; - } - - OverlayColor startCol = g_system->RGBToColor(0, 0, 0); - OverlayColor endCol = g_system->RGBToColor(0, 0, 0); - - for (int y = 0; y < partsH; ++y) { - // calculate the correct drawing height - int usedHeight = drawHeight; - if (specialHeight && y == 1) { - usedHeight = specialHeight; - } - - int xPos = r.left; - bool upDown = (y == partsH - 1); - - for (int i = 0; i < partsW; ++i) { - // calculate the correct drawing width - int usedWidth = drawWidth; - if (specialWidth && i == 1) { - usedWidth = specialWidth; - } - - if (i >= xDrawTilesLeft && i <= partsW - xDrawTilesRight && y >= yDrawTilesTop && y <= partsH - yDrawTilesBottom) { - xPos += usedWidth; - continue; - } - - // draw the right surface - if (!i || i == partsW - 1) { - if ((!y && !skipTopRow) || (y == partsH - 1 && !skipLastRow)) { - drawSurfaceMasked(Common::Rect(xPos, yPos, xPos+usedWidth, yPos+usedHeight), corner, upDown, (i == partsW - 1), alpha, startCol, endCol); - } else { - drawSurfaceMasked(Common::Rect(xPos, yPos, xPos+usedWidth, yPos+usedHeight), left, upDown, (i == partsW - 1), alpha, startCol, endCol); - } - } else if (!y || (y == partsH - 1 && !skipLastRow)) { - drawSurfaceMasked(Common::Rect(xPos, yPos, xPos+usedWidth, yPos+usedHeight), top, upDown, false, alpha, startCol, endCol); - } else { - drawSurfaceMasked(Common::Rect(xPos, yPos, xPos+usedWidth, yPos+usedHeight), fill, upDown, false, alpha, startCol, endCol); - } - xPos += usedWidth; - } - yPos += usedHeight; - } -} - -void ThemeModern::drawSurface(const Common::Rect &r, const Surface *surf, bool upDown, bool leftRight, int alpha) { - drawSurfaceMasked(r, surf, upDown, leftRight, alpha, _system->RGBToColor(255, 255, 255), _system->RGBToColor(255, 255, 255)); -} - -void ThemeModern::drawSurfaceMasked(const Common::Rect &r, const Graphics::Surface *surf, bool upDown, bool leftRight, - int alpha, OverlayColor start, OverlayColor end, uint factor) { - OverlayColor *dst = (OverlayColor*)_screen.getBasePtr(r.left, r.top); - const OverlayColor *src = 0; - - const OverlayColor transparency = _colors[kColorTransparency]; - int drawWidth = (r.width() < surf->w) ? r.width() : surf->w; - if (r.left + drawWidth > _screen.w) - drawWidth = _screen.w - r.left; - - int srcAdd = 0; - if (upDown) { - src = (const OverlayColor*)surf->pixels + (surf->h - 1) * surf->w; - srcAdd = -surf->w; - } else { - src = (const OverlayColor*)surf->pixels; - srcAdd = surf->w; - } - - int h = r.height(); - if (r.top + h > _screen.h) - h = _screen.h - r.top; - - while (dst < _screen.pixels) { - dst += _screen.w; - src += srcAdd; - --h; - } - - if (h <= 0) - return; - -#define NO_EFFECT(x) ((x) & rowColor) -#define ALPHA_EFFECT(x) (getColorAlpha((x) & rowColor, *dst, alpha)) -#define DARKEN_EFFECT(x) (calcDimColor((x) & rowColor)) - -#define LEFT_RIGHT_OFFSET(x) (drawWidth-x-1) -#define NORMAL_OFFSET(x) (x) - -#define blitSurface(a, b) \ - const int dstAdd = _screen.w - drawWidth; \ - const int lastRow = r.height() - 1; \ - for (int i = 0; i < h; ++i) { \ - OverlayColor rowColor = calcGradient(start, end, i, lastRow, factor); \ - for (int x = 0; x < drawWidth; ++x, ++dst) { \ - OverlayColor col = src[a(x)]; \ - if (col != transparency) { \ - col = b(col); \ - *dst = col; \ - } \ - } \ - dst += dstAdd; \ - src += srcAdd; \ - } - if (alpha >= 256) { - if (leftRight) { - blitSurface(LEFT_RIGHT_OFFSET, NO_EFFECT); - } else { - blitSurface(NORMAL_OFFSET, NO_EFFECT); - } - } else if (alpha < 0 && alpha >= -256) { - int backUp = _dimPercentValue; - _dimPercentValue = 256 * (100 - (-alpha)) / 100; - - if (leftRight) { - blitSurface(LEFT_RIGHT_OFFSET, DARKEN_EFFECT); - } else { - blitSurface(NORMAL_OFFSET, DARKEN_EFFECT); - } - - _dimPercentValue = backUp; - } else { - if (leftRight) { - blitSurface(LEFT_RIGHT_OFFSET, ALPHA_EFFECT); - } else { - blitSurface(NORMAL_OFFSET, ALPHA_EFFECT); - } - } -#undef blitSurface - -#undef NORMAL_OFFSET -#undef LEFT_RIGHT_OFFSET - -#undef DARKEN_EFFECT -#undef ALPHA_EFFECT -#undef NO_EFFECT -} - -OverlayColor ThemeModern::getColor(State state) { - switch (state) { - case kStateDisabled: - return _colors[kColorStateDisabled]; - - case kStateHighlight: - return _colors[kColorStateHighlight]; - - default: - break; - }; - return _colors[kColorStateEnabled]; -} - -void ThemeModern::resetupGuiRenderer() { - if (_lastUsedBitMask == gBitFormat || !_initOk) { - // ok same format no need to reload - return; - } - - _lastUsedBitMask = gBitFormat; - - int i; - for (i = 0; i < kImageHandlesMax; ++i) { - ImageMan.unregisterSurface(_imageHandles[i]); - } - - for (i = 0; i < kImageHandlesMax; ++i) { - ImageMan.registerSurface(_imageHandles[i], 0); - _images[i] = ImageMan.getSurface(_imageHandles[i]); - } - - setupColors(); -} - -void ThemeModern::setupColors() { - // load the colors from the config file - getColorFromConfig("main_dialog_start", _colors[kMainDialogStart]); - getColorFromConfig("main_dialog_end", _colors[kMainDialogEnd]); - - getColorFromConfig("dialog_start", _colors[kDialogStart]); - getColorFromConfig("dialog_end", _colors[kDialogEnd]); - - getColorFromConfig("color_state_disabled", _colors[kColorStateDisabled]); - getColorFromConfig("color_state_highlight", _colors[kColorStateHighlight]); - getColorFromConfig("color_state_enabled", _colors[kColorStateEnabled]); - getColorFromConfig("color_transparency", _colors[kColorTransparency]); - - getColorFromConfig("text_inverted_background", _colors[kTextInvertedBackground]); - getColorFromConfig("text_inverted_color", _colors[kTextInvertedColor]); - - getColorFromConfig("widget_bkgd_start", _colors[kWidgetBackgroundStart]); - getColorFromConfig("widget_bkgd_end", _colors[kWidgetBackgroundEnd]); - getColorFromConfig("widget_bkgd_small_start", _colors[kWidgetBackgroundSmallStart]); - getColorFromConfig("widget_bkgd_small_end", _colors[kWidgetBackgroundSmallEnd]); - - getColorFromConfig("button_bkgd_start", _colors[kButtonBackgroundStart]); - getColorFromConfig("button_bkgd_end", _colors[kButtonBackgroundEnd]); - getColorFromConfig("button_bkgd_highlight_start", _colors[kButtonBackgroundHighlightStart]); - getColorFromConfig("button_bkgd_highlight_end", _colors[kButtonBackgroundHighlightEnd]); - getColorFromConfig("button_text_enabled", _colors[kButtonTextEnabled]); - getColorFromConfig("button_text_disabled", _colors[kButtonTextDisabled]); - getColorFromConfig("button_text_highlight", _colors[kButtonTextHighlight]); - - getColorFromConfig("slider_background_start", _colors[kSliderBackgroundStart]); - getColorFromConfig("slider_background_end", _colors[kSliderBackgroundEnd]); - getColorFromConfig("slider_start", _colors[kSliderStart]); - getColorFromConfig("slider_end", _colors[kSliderEnd]); - getColorFromConfig("slider_highlight_start", _colors[kSliderHighStart]); - getColorFromConfig("slider_highlight_end", _colors[kSliderHighEnd]); - - getColorFromConfig("tab_background_start", _colors[kTabBackgroundStart]); - getColorFromConfig("tab_background_end", _colors[kTabBackgroundEnd]); - - getColorFromConfig("tab_active_start", _colors[kTabActiveStart]); - getColorFromConfig("tab_active_end", _colors[kTabActiveEnd]); - getColorFromConfig("tab_inactive_start", _colors[kTabInactiveStart]); - getColorFromConfig("tab_inactive_end", _colors[kTabInactiveEnd]); - - getColorFromConfig("scrollbar_background_start", _colors[kScrollbarBackgroundStart]); - getColorFromConfig("scrollbar_background_end", _colors[kScrollbarBackgroundEnd]); - getColorFromConfig("scrollbar_button_start", _colors[kScrollbarButtonStart]); - getColorFromConfig("scrollbar_button_end", _colors[kScrollbarButtonEnd]); - getColorFromConfig("scrollbar_slider_start", _colors[kScrollbarSliderStart]); - getColorFromConfig("scrollbar_slider_end", _colors[kScrollbarSliderEnd]); - getColorFromConfig("scrollbar_button_highlight_start", _colors[kScrollbarButtonHighlightStart]); - getColorFromConfig("scrollbar_button_highlight_end", _colors[kScrollbarButtonHighlightEnd]); - getColorFromConfig("scrollbar_slider_highlight_start", _colors[kScrollbarSliderHighlightStart]); - getColorFromConfig("scrollbar_slider_highlight_end", _colors[kScrollbarSliderHighlightEnd]); - - getColorFromConfig("caret_color", _colors[kCaretColor]); - - getColorFromConfig("popupwidget_start", _colors[kPopUpWidgetStart]); - getColorFromConfig("popupwidget_end", _colors[kPopUpWidgetEnd]); - getColorFromConfig("popupwidget_highlight_start", _colors[kPopUpWidgetHighlightStart]); - getColorFromConfig("popupwidget_highlight_end", _colors[kPopUpWidgetHighlightEnd]); - - getColorFromConfig("edittext_background_start", _colors[kEditTextBackgroundStart]); - getColorFromConfig("edittext_background_end", _colors[kEditTextBackgroundEnd]); -} - -#define FONT_NAME_NORMAL "newgui_normal" -#define FONT_NAME_BOLD "newgui_bold" -#define FONT_NAME_ITALIC "newgui_italic" -#define FONT_NAME_FIXED_NORMAL "newgui_fixed_normal" -#define FONT_NAME_FIXED_BOLD "newgui_fixed_bold" -#define FONT_NAME_FIXED_ITALIC "newgui_fixed_italic" - -void ThemeModern::setupFonts() { - if (_screen.w >= 400 && _screen.h >= 270) { - setupFont("fontfile_bold", FONT_NAME_BOLD, kFontStyleBold); - setupFont("fontfile_normal", FONT_NAME_NORMAL, kFontStyleNormal); - setupFont("fontfile_italic", FONT_NAME_ITALIC, kFontStyleItalic); - - setupFont("fontfile_fixed_bold", FONT_NAME_FIXED_BOLD, kFontStyleFixedBold); - setupFont("fontfile_fixed_normal", FONT_NAME_FIXED_NORMAL, kFontStyleFixedNormal); - setupFont("fontfile_fixed_italic", FONT_NAME_FIXED_ITALIC, kFontStyleFixedItalic); - } else { - _fonts[kFontStyleBold] = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); - _fonts[kFontStyleNormal] = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); - _fonts[kFontStyleItalic] = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); - } -} - -void ThemeModern::deleteFonts() { - const Graphics::Font *normal = FontMan.getFontByName(FONT_NAME_NORMAL); - const Graphics::Font *bold = FontMan.getFontByName(FONT_NAME_BOLD); - const Graphics::Font *italic = FontMan.getFontByName(FONT_NAME_ITALIC); - - delete normal; - delete bold; - delete italic; - - FontMan.removeFontName(FONT_NAME_NORMAL); - FontMan.removeFontName(FONT_NAME_BOLD); - FontMan.removeFontName(FONT_NAME_ITALIC); -} - -void ThemeModern::setupFont(const Common::String &key, const Common::String &name, FontStyle style) { - if (_evaluator->getVar(key) == EVAL_STRING_VAR) { - _fonts[style] = FontMan.getFontByName(name); - - if (!_fonts[style]) { - Common::String temp(_evaluator->getStringVar(key)); - - _fonts[style] = loadFont(temp.c_str()); - if (!_fonts[style]) - error("Couldn't load %s font '%s'", key.c_str(), temp.c_str()); - - FontMan.assignFontToName(name, _fonts[style]); - } - } else { - _fonts[style] = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - } -} - -#pragma mark - - -void ThemeModern::processExtraValues() { - // TODO: think of unloading all old graphic files first, instead of just - // loading new ones if needed when this is processed? - - // load the pixmap filenames from the config file -#define loadRectData(type, str) \ - _imageHandles[k##type##Corner] = _evaluator->getStringVar("pix_"str"_corner"); \ - _imageHandles[k##type##Top] = _evaluator->getStringVar("pix_"str"_top"); \ - _imageHandles[k##type##Left] = _evaluator->getStringVar("pix_"str"_left"); \ - _imageHandles[k##type] = _evaluator->getStringVar("pix_"str"_bkgd") - - loadRectData(DialogBkgd, "dialog"); - loadRectData(WidgetBkgd, "widget"); - loadRectData(WidgetSmallBkgd, "widget_small"); - loadRectData(TabBkgd, "tab"); - loadRectData(SliderBkgd, "slider_bkgd"); - loadRectData(Slider, "slider"); - loadRectData(ScrollbarBkgd, "scrollbar_bkgd"); - loadRectData(Scrollbar, "scrollbar"); - loadRectData(ButtonBkgd, "button"); - loadRectData(PopUpWidgetBkgd, "popupwidget"); - loadRectData(EditTextBkgd, "edittext_bkgd"); - -#undef loadRectData - - _imageHandles[kCheckboxEmpty] = _evaluator->getStringVar("pix_checkbox_empty"); - _imageHandles[kCheckboxChecked] = _evaluator->getStringVar("pix_checkbox_checked"); - - _imageHandles[kWidgetArrow] = _evaluator->getStringVar("pix_widget_arrow"); - - _imageHandles[kThemeLogo] = _evaluator->getStringVar("pix_theme_logo"); - - _imageHandles[kGUICursor] = _evaluator->getStringVar("pix_cursor_image"); - - for (int i = 0; i < kImageHandlesMax; ++i) { - ImageMan.registerSurface(_imageHandles[i], 0); - _images[i] = ImageMan.getSurface(_imageHandles[i]); - } - - // load the gradient factors from the config file - _gradientFactors[kMainDialogFactor] = _evaluator->getVar("gradient_dialog_main", 1); - _gradientFactors[kDialogFactor] = _evaluator->getVar("gradient_dialog", 1); - _gradientFactors[kDialogSpecialFactor] = _evaluator->getVar("gradient_dialog_special", 1); - - _gradientFactors[kWidgetSmallFactor] = _evaluator->getVar("gradient_widget_small", 1); - _gradientFactors[kWidgetFactor] = _evaluator->getVar("gradient_widget", 1); - - _gradientFactors[kButtonFactor] = _evaluator->getVar("gradient_button", 1); - - _gradientFactors[kSliderFactor] = _evaluator->getVar("gradient_slider", 1); - _gradientFactors[kSliderBackground] = _evaluator->getVar("gradient_silder_bkgd", 1); - - _gradientFactors[kTabFactor] = _evaluator->getVar("gradient_tab", 1); - - _gradientFactors[kScrollbarFactor] = _evaluator->getVar("gradient_scrollbar", 1); - _gradientFactors[kScrollbarBkgdFactor] = _evaluator->getVar("gradient_scrollbar_background", 1); - - _gradientFactors[kPopUpWidgetFactor] = _evaluator->getVar("gradient_popupwidget", 1); - - _gradientFactors[kEditTextFactor] = _evaluator->getVar("gradient_edittext", 1); - - // load values with default values from the config file - _shadowLeftWidth = _evaluator->getVar("shadow_left_width", 2); - _shadowRightWidth = _evaluator->getVar("shadow_right_width", 4); - _shadowTopHeight = _evaluator->getVar("shadow_top_height", 2); - _shadowBottomHeight = _evaluator->getVar("shadow_bottom_height", 4); - - _cursorHotspotX = _evaluator->getVar("cursor_hotspot_x", 0); - _cursorHotspotY = _evaluator->getVar("cursor_hotspot_y", 0); - - _cursorTargetScale = _evaluator->getVar("cursor_targetScale", 1); - - // inactive dialog shading stuff - - ShadingStyle shading = (ShadingStyle)_evaluator->getVar("inactive_dialog_shading", kShadingNone); - - switch (shading) { - case kShadingNone: - _dialogShadingCallback = 0; - break; - - case kShadingLuminance: - _dialogShadingCallback = &ThemeModern::calcLuminance; - break; - - case kShadingDim: - _dimPercentValue = _evaluator->getVar("shading_dim_percent", -1); - - if (_dimPercentValue < 0) { - _dimPercentValue = 0; - } else if (_dimPercentValue > 100) { - _dimPercentValue = 100; - } - - if (_dimPercentValue != 0) { - _dimPercentValue = 256 * (100 - _dimPercentValue) / 100; - _dialogShadingCallback = &ThemeModern::calcDimColor; - } - break; - - default: - warning("no valid 'inactive_dialog_shading' specified"); - } - - setupFonts(); - - // load the colors from the config file - setupColors(); - - // creates cursor image - if (_system->hasFeature(OSystem::kFeatureCursorHasPalette)) { - createCursor(); - } -} - -#pragma mark - - -OverlayColor ThemeModern::calcLuminance(OverlayColor col) { - uint8 r, g, b; - _system->colorToRGB(col, r, g, b); - - // A better (but slower) formula to calculate the luminance would be: - //uint lum = (byte)((0.299 * r + 0.587 * g + 0.114 * b) + 0.5); - // Note that the approximation below will only produce values between - // (and including) 0 and 221. - uint lum = (r >> 2) + (g >> 1) + (b >> 3); - - return _system->RGBToColor(lum, lum, lum); -} - -OverlayColor ThemeModern::calcDimColor(OverlayColor col) { - uint8 r, g, b; - _system->colorToRGB(col, r, g, b); - - r = r * _dimPercentValue >> 8; - g = g * _dimPercentValue >> 8; - b = b * _dimPercentValue >> 8; - - return _system->RGBToColor(r, g, b); -} - -#pragma mark - - -void ThemeModern::setUpCursor() { - CursorMan.pushCursorPalette(_cursorPal, 0, MAX_CURS_COLORS); - CursorMan.pushCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY, 255, _cursorTargetScale); - CursorMan.showMouse(true); -} - -void ThemeModern::createCursor() { - const Surface *cursor = _images[kGUICursor]; - - _cursorWidth = cursor->w; - _cursorHeight = cursor->h; - - uint colorsFound = 0; - const OverlayColor *src = (const OverlayColor*)cursor->pixels; - - byte *table = new byte[65536]; - assert(table); - memset(table, 0, sizeof(byte)*65536); - - byte r, g, b; - - _system->colorToRGB(_colors[kColorTransparency], r, g, b); - uint16 transparency = RGBToColor<ColorMasks<565> >(r, g, b); - - delete[] _cursor; - - _cursor = new byte[_cursorWidth * _cursorHeight]; - assert(_cursor); - memset(_cursor, 255, sizeof(byte)*_cursorWidth*_cursorHeight); - - for (uint y = 0; y < _cursorHeight; ++y) { - for (uint x = 0; x < _cursorWidth; ++x) { - _system->colorToRGB(src[x], r, g, b); - uint16 col = RGBToColor<ColorMasks<565> >(r, g, b); - if (!table[col] && col != transparency) { - table[col] = colorsFound++; - - uint index = table[col]; - _cursorPal[index * 4 + 0] = r; - _cursorPal[index * 4 + 1] = g; - _cursorPal[index * 4 + 2] = b; - _cursorPal[index * 4 + 3] = 0xFF; - - if (colorsFound > MAX_CURS_COLORS) - error("Cursor contains too much colors (%d, but only %d are allowed)", colorsFound, MAX_CURS_COLORS); - } - - if (col != transparency) { - uint index = table[col]; - _cursor[y * _cursorWidth + x] = index; - } - } - src += _cursorWidth; - } - - _useCursor = true; - delete[] table; -} - -#pragma mark - - -template<class T> -inline OverlayColor getColorAlphaImpl(OverlayColor col1, OverlayColor col2, int alpha) { - OverlayColor output = 0; - output |= ((alpha * ((col1 & T::kRedMask) - (col2 & T::kRedMask)) >> 8) + (col2 & T::kRedMask)) & T::kRedMask; - output |= ((alpha * ((col1 & T::kGreenMask) - (col2 & T::kGreenMask)) >> 8) + (col2 & T::kGreenMask)) & T::kGreenMask; - output |= ((alpha * ((col1 & T::kBlueMask) - (col2 & T::kBlueMask)) >> 8) + (col2 & T::kBlueMask)) & T::kBlueMask; - output |= ~(T::kRedMask | T::kGreenMask | T::kBlueMask); - return output; -} - -// broken implementation! -template<class T> -inline OverlayColor getColorAlphaImp2(OverlayColor col1, OverlayColor col2, int alpha) { - OverlayColor output = 0; - output |= ((alpha * ((~col1 & T::kRedMask) - (col2 & T::kRedMask)) >> 8) + (col2 & T::kRedMask)) & T::kRedMask; - output |= ((alpha * ((~col1 & T::kGreenMask) - (col2 & T::kGreenMask)) >> 8) + (col2 & T::kGreenMask)) & T::kGreenMask; - output |= ((alpha * ((~col1 & T::kBlueMask) - (col2 & T::kBlueMask)) >> 8) + (col2 & T::kBlueMask)) & T::kBlueMask; - output |= ~(T::kRedMask | T::kGreenMask | T::kBlueMask); - return output; -} - -OverlayColor getColorAlpha(OverlayColor col1, OverlayColor col2, int alpha) { - if (alpha >= 0) { - if (gBitFormat == 565) { - return getColorAlphaImpl<ColorMasks<565> >(col1, col2, alpha); - } else { - return getColorAlphaImpl<ColorMasks<555> >(col1, col2, alpha); - } - } else { - if (gBitFormat == 565) { - return getColorAlphaImp2<ColorMasks<565> >(col1, col2, -alpha - 256); - } else { - return getColorAlphaImp2<ColorMasks<555> >(col1, col2, -alpha - 256); - } - } -} - -template<class T> -inline OverlayColor calcGradient(OverlayColor start, OverlayColor end, int pos) { - OverlayColor output = 0; - output |= (start + ((((end & T::kRedMask) - (start & T::kRedMask))) * pos >> 12)) & T::kRedMask; - output |= (start + ((((end & T::kGreenMask) - (start & T::kGreenMask))) * pos >> 12)) & T::kGreenMask; - output |= (start + ((((end & T::kBlueMask) - (start & T::kBlueMask))) * pos >> 12)) & T::kBlueMask; - output |= ~(T::kRedMask | T::kGreenMask | T::kBlueMask); - return output; -} - -OverlayColor calcGradient(OverlayColor start, OverlayColor end, int pos, int max, uint factor = 1) { - pos *= factor; - if (pos >= max) - return end; - - pos = (0x1000 * pos) / max; - - if (gBitFormat == 565) { - return calcGradient<ColorMasks<565> >(start, end, pos); - } else { - return calcGradient<ColorMasks<555> >(start, end, pos); - } -} - -void getStateColor(OverlayColor &s, OverlayColor &e, - OverlayColor enabledS, OverlayColor enabledE, - OverlayColor highlightS, OverlayColor highlightE, - Theme::WidgetStateInfo state) { - if (state == Theme::kStateHighlight) { - s = highlightS; - e = highlightE; - } else { - s = enabledS; - e = enabledE; - } -} - -} // end of namespace GUI - -#endif diff --git a/gui/ThemeModern.h b/gui/ThemeModern.h deleted file mode 100644 index 29843a73e0..0000000000 --- a/gui/ThemeModern.h +++ /dev/null @@ -1,340 +0,0 @@ -/* 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#ifndef GUI_THEMEMODERN_H -#define GUI_THEMEMODERN_H - -#ifndef DISABLE_FANCY_THEMES - -#include "gui/theme.h" - -namespace GUI { - -class ThemeModern : public Theme { -public: - ThemeModern(OSystem *system, const Common::String &stylefile, const Common::ConfigFile *cfg = 0); - virtual ~ThemeModern(); - - bool init(); - void deinit(); - - void refresh(); - - bool ownCursor() const { return _useCursor; } - - void enable(); - void disable(); - - void openDialog(bool topDialog, ShadingStyle = kShadingNone); - void closeAllDialogs(); - - void clearAll(); - void updateScreen(); - - void setDrawArea(const Common::Rect &r); - void resetDrawArea(); - - const Graphics::Font *getFont(FontStyle font = kFontStyleBold) const { return _fonts[font]; } - int getFontHeight(FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getFontHeight(); return 0; } - int getStringWidth(const Common::String &str, FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getStringWidth(str); return 0; } - int getCharWidth(byte c, FontStyle font = kFontStyleBold) const { if (_fonts[font]) return _fonts[font]->getCharWidth(c); return 0; } - - void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state); - void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); - void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state); - - void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state); - void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints); - void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans); - void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state); - void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state); - void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state); - void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState, WidgetStateInfo state); - void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align); - void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state); - void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state); - - void restoreBackground(Common::Rect r, bool special = false); - bool addDirtyRect(Common::Rect r, bool backup = false, bool special = false); - - int getTabSpacing() const; - int getTabPadding() const; - - bool supportsImages() const { return true; } - const Graphics::Surface *getImageSurface(const kThemeImages n) const { return n == kImageLogo ? _images[kThemeLogo] : 0; } -private: - void colorFade(const Common::Rect &r, OverlayColor start, OverlayColor end, uint factor = 1); - void drawRect(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top, - const Graphics::Surface *left, const Graphics::Surface *fill, int alpha, bool skipLastRow = false); - void drawRectMasked(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top, - const Graphics::Surface *left, const Graphics::Surface *fill, int alpha, - OverlayColor start, OverlayColor end, uint factor = 1, bool skipLastRow = false, bool skipTopRow = false); - void drawSurface(const Common::Rect &r, const Graphics::Surface *surf, bool upDown, bool leftRight, int alpha); - void drawSurfaceMasked(const Common::Rect &r, const Graphics::Surface *surf, bool upDown, bool leftRight, int alpha, - OverlayColor start, OverlayColor end, uint factor = 1); - - enum ShadowStyles { - kShadowFull = 0, - kShadowSmall = 1, - kShadowButton = 2, - kShadowEmboss = 3, - kShadowPopUp = 4 - }; - - Common::Rect shadowRect(const Common::Rect &r, uint32 shadowStyle); - void drawShadow(const Common::Rect &r, const Graphics::Surface *corner, const Graphics::Surface *top, - const Graphics::Surface *left, const Graphics::Surface *fill, uint32 shadowStyle, bool skipLastRow = false, - bool skipTopRow = false); - void drawShadowRect(const Common::Rect &r, const Common::Rect &area, const Graphics::Surface *corner, - const Graphics::Surface *top, const Graphics::Surface *left, const Graphics::Surface *fill, - int alpha, bool skipLastRow = false, bool skipTopRow = false); - - int _shadowLeftWidth, _shadowRightWidth; - int _shadowTopHeight, _shadowBottomHeight; - - OSystem *_system; - Graphics::Surface _screen; - Common::Rect _shadowDrawArea; - - bool _initOk; - bool _forceRedraw; - bool _enabled; - - int _lastUsedBitMask; - void resetupGuiRenderer(); - void setupColors(); - - OverlayColor getColor(State state); - - struct DialogState { - Graphics::Surface screen; - } *_dialog; - - void setupFonts(); - void deleteFonts(); - - void setupFont(const Common::String &key, const Common::String &name, FontStyle style); - - const Graphics::Font *_fonts[kFontStyleMax]; - -private: - void processExtraValues(); - - enum ImageHandles { - kDialogBkgdCorner = 0, - kDialogBkgdTop = 1, - kDialogBkgdLeft = 2, - kDialogBkgd = 3, - - kWidgetBkgdCorner = 4, - kWidgetBkgdTop = 5, - kWidgetBkgdLeft = 6, - kWidgetBkgd = 7, - - kCheckboxEmpty = 8, - kCheckboxChecked = 9, - - kWidgetArrow = 10, - - kTabBkgdCorner = 11, - kTabBkgdTop = 12, - kTabBkgdLeft = 13, - kTabBkgd = 14, - - kSliderBkgdCorner = 15, - kSliderBkgdTop = 16, - kSliderBkgdLeft = 17, - kSliderBkgd = 18, - - kSliderCorner = 19, - kSliderTop = 20, - kSliderLeft = 21, - kSlider = 22, - - kScrollbarBkgdCorner = 23, - kScrollbarBkgdTop = 24, - kScrollbarBkgdLeft = 25, - kScrollbarBkgd = 26, - - kScrollbarCorner = 27, - kScrollbarTop = 28, - kScrollbarLeft = 29, - kScrollbar = 30, - - kButtonBkgdCorner = 31, - kButtonBkgdTop = 32, - kButtonBkgdLeft = 33, - kButtonBkgd = 34, - - kWidgetSmallBkgdCorner = 35, - kWidgetSmallBkgdTop = 36, - kWidgetSmallBkgdLeft = 37, - kWidgetSmallBkgd = 38, - - kThemeLogo = 39, - - kPopUpWidgetBkgdCorner = 40, - kPopUpWidgetBkgdTop = 41, - kPopUpWidgetBkgdLeft = 42, - kPopUpWidgetBkgd = 43, - - kEditTextBkgdCorner = 44, - kEditTextBkgdTop = 45, - kEditTextBkgdLeft = 46, - kEditTextBkgd = 47, - - kGUICursor = 48, - - kImageHandlesMax - }; - -private: - int _dimPercentValue; - typedef OverlayColor (ThemeModern::*InactiveDialogCallback)(OverlayColor col); - InactiveDialogCallback _dialogShadingCallback; - - OverlayColor calcLuminance(OverlayColor col); - OverlayColor calcDimColor(OverlayColor col); - - bool _useCursor; - void setUpCursor(); - void createCursor(); - int _cursorHotspotX, _cursorHotspotY; - int _cursorTargetScale; -#define MAX_CURS_COLORS 255 - byte *_cursor; - bool _needPaletteUpdates; - uint _cursorWidth, _cursorHeight; - byte _cursorPal[4*MAX_CURS_COLORS]; - -private: - Common::String _imageHandles[kImageHandlesMax]; - const Graphics::Surface **_images; - - enum ColorHandles { - kMainDialogStart = 0, - kMainDialogEnd = 1, - - kDialogStart = 2, - kDialogEnd = 3, - - kColorStateDisabled = 4, - kColorStateHighlight = 5, - kColorStateEnabled = 6, - kColorTransparency = 7, - - kTextInvertedBackground = 8, - kTextInvertedColor = 9, - - kWidgetBackgroundStart = 10, - kWidgetBackgroundEnd = 11, - kWidgetBackgroundSmallStart = 12, - kWidgetBackgroundSmallEnd = 13, - - kButtonBackgroundStart = 14, - kButtonBackgroundEnd = 15, - kButtonTextEnabled = 16, - kButtonTextDisabled = 17, - kButtonTextHighlight = 18, - - kSliderBackgroundStart = 19, - kSliderBackgroundEnd = 20, - kSliderStart = 21, - kSliderEnd = 22, - - kTabBackgroundStart = 23, - kTabBackgroundEnd = 24, - - kScrollbarBackgroundStart = 25, - kScrollbarBackgroundEnd = 26, - kScrollbarButtonStart = 27, - kScrollbarButtonEnd = 28, - kScrollbarSliderStart = 29, - kScrollbarSliderEnd = 30, - - kCaretColor = 31, - - kSliderHighStart = 32, - kSliderHighEnd = 33, - - kButtonBackgroundHighlightStart = 34, - kButtonBackgroundHighlightEnd = 35, - - kScrollbarButtonHighlightStart = 36, - kScrollbarButtonHighlightEnd = 37, - kScrollbarSliderHighlightStart = 38, - kScrollbarSliderHighlightEnd = 39, - - kPopUpWidgetStart = 40, - kPopUpWidgetEnd = 41, - kPopUpWidgetHighlightStart = 42, - kPopUpWidgetHighlightEnd = 43, - - kEditTextBackgroundStart = 44, - kEditTextBackgroundEnd = 45, - - kTabActiveStart = 46, - kTabActiveEnd = 47, - kTabInactiveStart = 48, - kTabInactiveEnd = 49, - - kColorHandlesMax - }; - - OverlayColor _colors[kColorHandlesMax]; - - enum GradientFactors { - kMainDialogFactor = 0, - kDialogFactor = 1, - kDialogSpecialFactor = 2, - - kWidgetSmallFactor = 3, - kWidgetFactor = 4, - - kButtonFactor = 5, - - kSliderFactor = 6, - kSliderBackground = 7, - - kTabFactor = 7, - - kScrollbarFactor = 8, - kScrollbarBkgdFactor = 9, - - kPopUpWidgetFactor = 10, - - kEditTextFactor = 11, - - kMaxGradientFactors - }; - - uint _gradientFactors[kMaxGradientFactors]; -}; - -} // end of namespace GUI - -#endif - -#endif - diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp index 1632488b91..00a07909b0 100644 --- a/gui/ThemeRenderer.cpp +++ b/gui/ThemeRenderer.cpp @@ -683,18 +683,26 @@ void ThemeRenderer::drawScrollbar(const Common::Rect &r, int sliderY, int slider queueDD(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2); } -void ThemeRenderer::drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state) { +void ThemeRenderer::drawDialogBackground(const Common::Rect &r, DialogBackground bgtype, WidgetStateInfo state) { if (!ready()) return; - if (hints & THEME_HINT_MAIN_DIALOG) { - queueDD(kDDMainDialogBackground, r); - } else if (hints & THEME_HINT_SPECIAL_COLOR) { - queueDD(kDDSpecialColorBackground, r); - } else if (hints & THEME_HINT_PLAIN_COLOR) { - queueDD(kDDPlainColorBackground, r); - } else { - queueDD(kDDDefaultBackground, r); + switch (bgtype) { + case kDialogBackgroundMain: + queueDD(kDDMainDialogBackground, r); + break; + + case kDialogBackgroundSpecial: + queueDD(kDDSpecialColorBackground, r); + break; + + case kDialogBackgroundPlain: + queueDD(kDDPlainColorBackground, r); + break; + + case kDialogBackgroundDefault: + queueDD(kDDDefaultBackground, r); + break; } } diff --git a/gui/ThemeRenderer.h b/gui/ThemeRenderer.h index d26dc21f48..4fe968752c 100644 --- a/gui/ThemeRenderer.h +++ b/gui/ThemeRenderer.h @@ -328,7 +328,7 @@ public: void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled); - void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state); + void drawDialogBackground(const Common::Rect &r, DialogBackground type, WidgetStateInfo state); void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); diff --git a/gui/console.cpp b/gui/console.cpp index de4db14a4f..58c7404a19 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -24,7 +24,6 @@ #include "gui/console.h" #include "gui/ScrollBarWidget.h" -#include "gui/eval.h" #include "gui/ThemeEval.h" #include "engines/engine.h" @@ -120,8 +119,6 @@ void ConsoleDialog::init() { scrollBarWidth = kNormalScrollBarWidth; _scrollBar->resize(_w - scrollBarWidth - 1, 0, scrollBarWidth, _h); - _drawingHints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND; - _pageWidth = (_w - scrollBarWidth - 2 - _leftPadding - _topPadding - scrollBarWidth) / kConsoleCharWidth; _linesPerPage = (_h - 2 - _topPadding - _bottomPadding) / kConsoleLineHeight; _linesInBuffer = kBufferSize / kCharsPerLine; @@ -152,8 +149,6 @@ void ConsoleDialog::open() { if (_w != w || _h != h) init(); - _drawingHints |= THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND; - _y = -_h; _slideTime = g_system->getMillis(); _slideMode = kDownSlideMode; @@ -170,7 +165,7 @@ void ConsoleDialog::close() { } void ConsoleDialog::drawDialog() { - g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _drawingHints); + g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _backgroundType); // FIXME: for the old theme the frame around the console vanishes // when any action is processed if we enable this // _drawingHints &= ~THEME_HINT_FIRST_DRAW; @@ -229,7 +224,6 @@ void ConsoleDialog::handleTickle() { // Perform the "slide animation". if (_slideMode != kNoSlideMode) { - _drawingHints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND; const float tmp = (float)(g_system->getMillis() - _slideTime) / kConsoleSlideDownDuration; if (_slideMode == kUpSlideMode) { _y = (int)(_h * (0.0 - tmp)); diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 1e58c654eb..3b302ff36a 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -42,18 +42,15 @@ namespace GUI { * ... */ -Dialog::Dialog(int x, int y, int w, int h, bool dimsInactive_) +Dialog::Dialog(int x, int y, int w, int h) : GuiObject(x, y, w, h), - _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _visible(false), _drawingHints(0), - _dimsInactive(dimsInactive_) { - _drawingHints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND; -} + _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _visible(false), + _backgroundType(GUI::Theme::kDialogBackgroundDefault) {} -Dialog::Dialog(const Common::String &name, bool dimsInactive_) +Dialog::Dialog(const Common::String &name) : GuiObject(name), - _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _visible(false), _drawingHints(0), - _dimsInactive(dimsInactive_) { - _drawingHints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND; + _mouseWidget(0), _focusedWidget(0), _dragWidget(0), _visible(false), + _backgroundType(GUI::Theme::kDialogBackgroundDefault) { // It may happen that we have 3x scaler in launcher (960xY) and then 640x480 // game will be forced to 1x. At this stage GUI will not be aware of @@ -113,11 +110,9 @@ void Dialog::reflowLayout() { // changed, so any cached image may be invalid. The subsequent redraw // should be treated as the very first draw. - _drawingHints |= THEME_HINT_FIRST_DRAW; Widget *w = _firstWidget; while (w) { w->reflowLayout(); - w->setHints(THEME_HINT_FIRST_DRAW); w = w->_next; } @@ -144,8 +139,7 @@ void Dialog::drawDialog() { if (!isVisible()) return; - g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _drawingHints); - _drawingHints &= ~THEME_HINT_FIRST_DRAW; + g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _backgroundType); // Draw all children Widget *w = _firstWidget; diff --git a/gui/dialog.h b/gui/dialog.h index 553a63d1a9..bc5ce6b6e0 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -49,15 +49,15 @@ protected: Widget *_focusedWidget; Widget *_dragWidget; bool _visible; - uint16 _drawingHints; + + Theme::DialogBackground _backgroundType; private: int _result; - bool _dimsInactive; public: - Dialog(int x, int y, int w, int h, bool dimsInactive = true); - Dialog(const Common::String &name, bool dimsInactive = true); + Dialog(int x, int y, int w, int h); + Dialog(const Common::String &name); virtual int runModal(); @@ -91,9 +91,6 @@ protected: void setResult(int result) { _result = result; } int getResult() const { return _result; } - - // Whether dialog dims all underneath dialogs or not when active - bool dimsInactive() { return _dimsInactive; } }; } // End of namespace GUI diff --git a/gui/eval.cpp b/gui/eval.cpp deleted file mode 100644 index 716006c108..0000000000 --- a/gui/eval.cpp +++ /dev/null @@ -1,333 +0,0 @@ -/* 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "common/system.h" -#include "gui/eval.h" -#include "gui/widget.h" -#include "gui/newgui.h" - -#include "graphics/scaler.h" - -namespace GUI { - -static bool isdelim(char c) { - return strchr(" ;,+-<>/*%^=()", c) != 0 || c == 9 || c == '\n' || !c; -} - -Eval::Eval() { - loadConstants(); -} - -Eval::~Eval() { - _vars.clear(); - _aliases.clear(); -} - -int Eval::eval(const String &input, const String §ion, const String &name, int startpos) { - int result; - - debug(5, "%s=%s", name.c_str(), input.c_str()); - - strncpy(_input, input.c_str(), 256); - _section = section; - _name = name; - _startpos = startpos; - - _pos = 0; - - getToken(); - - if (_tokenType == tString) - return EVAL_STRING_VAR; - - if (!*_token) - exprError(eBadExpr); - - level2(&result); - - debug(5, "Result: %d", result); - - return result; -} - -void Eval::level2(int *result) { - char op; - int hold; - - level3(result); - - while ((op = *_token) == '+' || op == '-') { - getToken(); - level3(&hold); - arith(op, result, &hold); - } -} - -void Eval::level3(int *result) { - char op; - int hold; - - level4(result); - - while ((op = *_token) == '*' || op == '/' || op == '%') { - getToken(); - level4(&hold); - arith(op, result, &hold); - } -} - -void Eval::level4(int *result) { - char op; - - op = 0; - if ((_tokenType == tDelimiter) && (*_token == '+' || *_token == '-')) { - op = *_token; - getToken(); - } - - level5(result); - - if (op) - unary(op, result); -} - -void Eval::level5(int *result) { - if ((*_token == '(') && (_tokenType == tDelimiter)) { - getToken(); - - level2(result); - - if (*_token != ')') - exprError(eUnclosedBracket); - getToken(); - } else { - primitive(result); - } -} - -void Eval::primitive(int *result) { - if (*_token == ')') - exprError(eExtraBracket); - - switch (_tokenType) { - case tVariable: - *result = getVar_(_token); - if (*result == EVAL_UNDEF_VAR) - exprError(eUndefVar); - getToken(); - return; - case tNumber: - *result = atoi(_token); - getToken(); - return; - default: - exprError(eSyntaxError); - } -} - -void Eval::arith(char op, int *r, int *h) { - switch (op) { - case '-': - *r = *r - *h; - break; - case '+': - *r = *r + *h; - break; - case '*': - *r = *r * *h; - break; - case '/': - *r = (*r) / (*h); - break; - case '%': - *r = (*r) % (*h); - break; - } -} - -void Eval::unary(char op, int *r) { - if (op == '-') - *r = -(*r); -} - -void Eval::getToken() { - char *temp; - - _tokenType = tNone; - temp = _token; - - if (_input[_pos] == 0) { - *_token = 0; - _tokenType = tDelimiter; - return; - } - while (isspace(_input[_pos])) - _pos++; - - if (_input[_pos] == '"') { - _pos++; - while (_input[_pos] != '"' && _input[_pos] != '\n') - *temp++ = _input[_pos++]; - - if (_input[_pos] == '\n') - exprError(eMissingQuote); - - _pos++; - *temp = 0; - - _tokenType = tString; - return; - } - - if (isdigit(_input[_pos])) { - while (!isdelim(_input[_pos])) - *temp++ = _input[_pos++]; - *temp = 0; - - _tokenType = tNumber; - return; - } - - if (isalpha(_input[_pos])) { - while (!isdelim(_input[_pos])) - *temp++ = _input[_pos++]; - *temp = 0; - _tokenType = tVariable; - return; - } - - if (!_tokenType && isdelim(_input[_pos])) { - *temp++ = _input[_pos++]; - *temp = 0; - _tokenType = tDelimiter; - } -} - -void Eval::exprError(EvalErrors err) { - static const char *errors[] = { - "Syntax error", - "Extra ')'", - "Missing ')'", - "Bad expression", - "Undefined variable", - "Missing '\"'" - }; - - error("%s in section [%s] expression: \"%s\" start is at: %d near token '%s'", - errors[err], _section.c_str(), _name.c_str(), _pos + _startpos, _token); -} - -struct BuiltinConsts { - const char *name; - int value; -}; - -static const BuiltinConsts builtinConsts[] = { - {"kButtonWidth", GUI::kButtonWidth}, - {"kButtonHeight", GUI::kButtonHeight}, - {"kSliderWidth", GUI::kSliderWidth}, - {"kSliderHeight", GUI::kSliderHeight}, - - {"kBigButtonWidth", GUI::kBigButtonWidth}, - {"kBigButtonHeight", GUI::kBigButtonHeight}, - {"kBigSliderWidth", GUI::kBigSliderWidth}, - {"kBigSliderHeight", GUI::kBigSliderHeight}, - - {"kNormalWidgetSize", GUI::kNormalWidgetSize}, - {"kBigWidgetSize", GUI::kBigWidgetSize}, - - {"kThumbnailWidth", kThumbnailWidth}, - - {"kTextAlignLeft", kTextAlignLeft}, - {"kTextAlignRight", kTextAlignRight}, - {"kTextAlignCenter", kTextAlignCenter}, - - {"kFontStyleBold", Theme::kFontStyleBold}, - {"kFontStyleNormal", Theme::kFontStyleNormal}, - {"kFontStyleItalic", Theme::kFontStyleItalic}, - - {"kFontStyleFixedBold", Theme::kFontStyleFixedBold}, - {"kFontStyleFixedNormal", Theme::kFontStyleFixedNormal}, - {"kFontStyleFixedItalic", Theme::kFontStyleFixedItalic}, - - {"kShadingNone", Theme::kShadingNone}, - {"kShadingDim", Theme::kShadingDim}, - {"kShadingLuminance", Theme::kShadingLuminance}, - - {"false", 0}, - {"true", 1}, - {NULL, 0} -}; - -void Eval::loadConstants() { - int i; - - for (i = 0; builtinConsts[i].name; i++) - _vars[builtinConsts[i].name] = builtinConsts[i].value; -} - -int Eval::getBuiltinVar(const char *s) { - if (!strcmp(s, "w")) - return g_system->getOverlayWidth(); - - if (!strcmp(s, "h")) - return g_system->getOverlayHeight(); - - return EVAL_UNDEF_VAR; -} - -int Eval::getVar_(const Common::String &s, bool includeAliases) { - int val; - - val = getBuiltinVar(s.c_str()); - - if (val != EVAL_UNDEF_VAR) - return val; - - const Common::String *var = &s; - if (includeAliases) { - AliasesMap::const_iterator itera = _aliases.find(s); - if (itera != _aliases.end()) - var = &(itera->_value); - } - - VariablesMap::const_iterator iterv = _vars.find(*var); - if (iterv != _vars.end()) - return iterv->_value; - - return EVAL_UNDEF_VAR; -} - -void Eval::setVar(const String §ion, const String &name, const String &value) { - _vars[name.c_str() + 4] = eval(value, section, name, 0); -} - -void Eval::reset() { - _vars.clear(); - _aliases.clear(); - loadConstants(); -} - -} // end of namespace GUI diff --git a/gui/eval.h b/gui/eval.h deleted file mode 100644 index bd58a0e1c3..0000000000 --- a/gui/eval.h +++ /dev/null @@ -1,130 +0,0 @@ -/* 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef GUI_EVAL_H -#define GUI_EVAL_H - -#include "common/str.h" -#include "common/hashmap.h" -#include "common/hash-str.h" - -namespace GUI { - -using Common::String; -using Common::HashMap; - -enum { - EVAL_UNDEF_VAR = -13375, - EVAL_STRING_VAR = -13376 -}; - -class Eval { -public: - Eval(); - ~Eval(); - - int eval(const String &input, const String §ion, const String &name, int startpos); - void setVar(const String §ion, const String &name, const String &value); - - void setParent(const String &name); - - void setVar(const String &name, int val) { _vars[name] = val; } - void setStringVar(const String &name, const String &val) { _strings[name] = val; } - void setAlias(const Common::String &name, const String &val) { _aliases[name] = val; } - - int getVar(const Common::String &s) { - warning("Old evaluator access: '%s'", s.c_str()); - return getVar_(s); - } - - int getVar(const Common::String &s, int def) { - warning("Old evaluator access: '%s'", s.c_str()); - int val = getVar_(s); - return (val == EVAL_UNDEF_VAR) ? def : val; - } - - const String &getStringVar(const Common::String &name) { return _strings[name]; } - - uint getNumVars() { return _vars.size(); } - - void reset(); - - char *lastToken() { return _token; } - - typedef HashMap<String, int> VariablesMap; - typedef HashMap<String, String> AliasesMap; - typedef HashMap<String, String> StringsMap; - -private: - enum TokenTypes { - tNone, - tDelimiter, - tVariable, - tNumber, - tString - }; - - enum EvalErrors { - eSyntaxError, - eExtraBracket, - eUnclosedBracket, - eBadExpr, - eUndefVar, - eMissingQuote - }; - - - void getToken(); - void level2(int *); - void level3(int *); - void level4(int *); - void level5(int *); - void primitive(int *); - void arith(char op, int *r, int *h); - void unary(char op, int *r); - void exprError(EvalErrors error); - int getVar_(const Common::String &s, bool includeAliases = true); - int getBuiltinVar(const char *s); - void loadConstants(); - - char _input[256]; - String _section; - String _name; - - int _startpos; - - TokenTypes _tokenType; - int _pos; - - char _token[256]; - - AliasesMap _aliases; - VariablesMap _vars; - StringsMap _strings; -}; - -} // end of namespace GUI - -#endif diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 3d35420326..d1187a4ad5 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -34,7 +34,6 @@ #include "gui/about.h" #include "gui/browser.h" #include "gui/chooser.h" -#include "gui/eval.h" #include "gui/launcher.h" #include "gui/massadd.h" #include "gui/message.h" @@ -161,7 +160,6 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc) // GUI: Add tab widget TabWidget *tab = new TabWidget(this, "GameOptions.TabWidget"); - tab->setHints(THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND); // // 1) The game tab @@ -471,7 +469,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat LauncherDialog::LauncherDialog() : Dialog(0, 0, 320, 200) { - _drawingHints |= THEME_HINT_MAIN_DIALOG; + _backgroundType = GUI::Theme::kDialogBackgroundMain; const int screenW = g_system->getOverlayWidth(); const int screenH = g_system->getOverlayHeight(); diff --git a/gui/module.mk b/gui/module.mk index 1cb9ecb30f..f1ba840459 100644 --- a/gui/module.mk +++ b/gui/module.mk @@ -9,7 +9,6 @@ MODULE_OBJS := \ dialog.o \ editable.o \ EditTextWidget.o \ - eval.o \ ThemeRenderer.o \ launcher.o \ ListWidget.o \ diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 665d190e6f..f4d20920dd 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -28,9 +28,6 @@ #include "graphics/cursorman.h" #include "gui/newgui.h" #include "gui/dialog.h" -#include "gui/eval.h" -#include "gui/ThemeModern.h" -#include "gui/ThemeClassic.h" #include "gui/ThemeRenderer.h" #include "common/config-manager.h" diff --git a/gui/options.cpp b/gui/options.cpp index 1e6e551a57..590b0bd900 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -25,7 +25,6 @@ #include "gui/browser.h" #include "gui/themebrowser.h" #include "gui/chooser.h" -#include "gui/eval.h" #include "gui/message.h" #include "gui/newgui.h" #include "gui/ThemeEval.h" @@ -664,7 +663,6 @@ GlobalOptionsDialog::GlobalOptionsDialog() // The tab widget TabWidget *tab = new TabWidget(this, "GlobalOptions.TabWidget"); - tab->setHints(THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND); // // 1) The graphics tab diff --git a/gui/theme-config.cpp b/gui/theme-config.cpp deleted file mode 100644 index f70696e8d5..0000000000 --- a/gui/theme-config.cpp +++ /dev/null @@ -1,772 +0,0 @@ -/* 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - */ - -#include "gui/theme.h" -#include "gui/eval.h" - -namespace GUI { - -const char *Theme::_defaultConfigINI = -"# Define our classic greenish theme here\n" -"[320xY]\n" -"def_widgetSize=kNormalWidgetSize\n" -"def_buttonWidth=kButtonWidth\n" -"def_buttonHeight=kButtonHeight\n" -"def_sliderWidth=kSliderWidth\n" -"def_sliderHeight=kSliderHeight\n" -"def_kLineHeight=12\n" -"def_kFontHeight=10\n" -"def_insetX=10\n" -"def_insetY=10\n" -"def_insetW=(w - 2 * 10)\n" -"def_insetH=(h - 30)\n" -"def_gameOptionsLabelWidth=60\n" -"def_tabPopupsLabelW=100\n" -"def_aboutXOff=3\n" -"def_aboutYOff=2\n" -"def_aboutOuterBorder=10\n" -"def_scummmainHOffset=8\n" -"def_scummmainVSpace=5\n" -"def_scummmainVAddOff=2\n" -"def_scummmainButtonWidth=90\n" -"def_scummmainButtonHeight=16\n" -"def_scummhelpX=5\n" -"def_scummhelpW=(w - 2 * 5)\n" -"def_midiControlsSpacing=1\n" -"def_vcAudioTabIndent=0\n" -"def_vcAudioTabSpacing=2\n" -"use=XxY\n" -"\n" -"# Override audio tab\n" -"set_parent=gameoptions\n" -"vBorder=5\n" -"\n" -"# audio tab\n" -"opYoffset=vBorder\n" -"useWithPrefix=audioControls globaloptions_\n" -"useWithPrefix=subtitleControls globaloptions_\n" -"\n" -"# volume tab\n" -"opYoffset=vBorder\n" -"useWithPrefix=volumeControls globaloptions_\n" -"\n" -"# audio tab\n" -"opYoffset=vBorder\n" -"gameoptions_audioCheckbox=gox opYoffset (parent.w - gox - 5) buttonHeight\n" -"opYoffset=(opYoffset + buttonHeight + 6)\n" -"useWithPrefix=audioControls gameoptions_\n" -"useWithPrefix=subtitleControls gameoptions_\n" -"\n" -"# volume tab\n" -"opYoffset=vBorder\n" -"gameoptions_volumeCheckbox=gox opYoffset (parent.w - gox - 5) buttonHeight\n" -"opYoffset=(opYoffset + buttonHeight + 6)\n" -"useWithPrefix=volumeControls gameoptions_\n" -"\n" -"TabWidget.tabWidth=0\n" -"TabWidget.tabHeight=16\n" -"TabWidget.titleVPad=2\n" -"# Scumm Saveload dialog\n" -"scummsaveload=8 8 (w - 2 * 8) (h - 16)\n" -"set_parent=scummsaveload\n" -"scummsaveload_title=10 2 (parent.w - 2 * 10) kLineHeight\n" -"scummsaveload_list=10 18 prev.w (parent.h - 17 - buttonHeight - 8 - self.y)\n" -"scummsaveload_thumbnail=(parent.w - (kThumbnailWidth + 22)) 18\n" -"scummsaveload_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n" -"scummsaveload_choose=(prev.x2 + 10) prev.y prev.w prev.h\n" -"scummsaveload_extinfo.visible=false\n" -"\n" -"# MM NES resolution\n" -"[256x240]\n" -"useAsIs=320xY\n" -"\n" -"[XxY]\n" -"def_widgetSize=kBigWidgetSize\n" -"def_buttonWidth=kBigButtonWidth\n" -"def_buttonHeight=kBigButtonHeight\n" -"def_sliderWidth=kBigSliderWidth\n" -"def_sliderHeight=kBigSliderHeight\n" -"def_kLineHeight=16\n" -"def_kFontHeight=14\n" -"def_insetX=10\n" -"def_insetY=20\n" -"def_insetW=(w - 2 * 10)\n" -"def_insetH=(h - 2 * 40)\n" -"def_gameOptionsLabelWidth=90\n" -"def_tabPopupsLabelW=150\n" -"def_aboutXOff=8\n" -"def_aboutYOff=5\n" -"def_aboutOuterBorder=80\n" -"def_scummmainHOffset=12\n" -"def_scummmainVSpace=7\n" -"def_scummmainVAddOff=3\n" -"def_scummmainButtonWidth=160\n" -"def_scummmainButtonHeight=28\n" -"def_scummhelpW=370\n" -"def_scummhelpX=((w - scummhelpW) / 2)\n" -"def_midiControlsSpacing=2\n" -"def_vcAudioTabIndent=10\n" -"def_vcAudioTabSpacing=4\n" -"##### Widgets config\n" -"ListWidget.leftPadding=4\n" -"ListWidget.rightPadding=0\n" -"ListWidget.topPadding=2\n" -"ListWidget.bottomPadding=2\n" -"ListWidget.hlLeftPadding=2\n" -"ListWidget.hlRightPadding=1\n" -"PopUpWidget.leftPadding=4\n" -"PopUpWidget.rightPadding=0\n" -"TabWidget.tabWidth=70\n" -"TabWidget.tabHeight=22\n" -"TabWidget.titleVPad=2\n" -"\n" -"###### chooser\n" -"opHeight=(h * 7 / 10)\n" -"useWithPrefix=chooser defaultChooser_\n" -"\n" -"##### browser\n" -"brW=((w * 7) / 8)\n" -"brH=((h * 9) / 10)\n" -"browser=((w - brW) / 2) ((h - brH) / 2) brW brH\n" -"set_parent=browser\n" -"browser_headline=10 kLineHeight (parent.w - 2 * 10) kLineHeight\n" -"browser_headline.align=kTextAlignCenter\n" -"browser_path=10 prev.y2 prev.w prev.h\n" -"browser_list=10 prev.y2 prev.w (parent.h - 3 * kLineHeight - buttonHeight - 14)\n" -"browser_up=10 (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n" -"browser_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n" -"browser_choose=(prev.x2 + 10) prev.y prev.w prev.h\n" -"\n" -"##### launcher\n" -"hBorder=10\n" -"launcher_version=hBorder 8 (w - 2 * hBorder) kLineHeight\n" -"launcher_version.align=kTextAlignCenter\n" -"top=(h - 8 - buttonHeight)\n" -"numButtons=4\n" -"space=8\n" -"butWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons)\n" -"launcher_quit_button=hBorder top butWidth buttonHeight\n" -"launcher_about_button=(prev.x2 + space) prev.y prev.w prev.h\n" -"launcher_options_button=(prev.x2 + space) prev.y prev.w prev.h\n" -"launcher_start_button=(prev.x2 + space) prev.y prev.w prev.h\n" -"top=(top - buttonHeight * 2)\n" -"numButtons=3\n" -"space=10\n" -"butWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons)\n" -"launcher_addGame_button=hBorder top butWidth buttonHeight\n" -"launcher_editGame_button=(prev.x2 + space) prev.y prev.w prev.h\n" -"launcher_removeGame_button=(prev.x2 + space) prev.y prev.w prev.h\n" -"launcher_list=hBorder (kLineHeight + 16) (w - 2 * hBorder) (top - kLineHeight - 20)\n" -"\n" -"### global options\n" -"globaloptions=insetX insetY insetW insetH\n" -"set_parent=globaloptions\n" -"vBorder=5\n" -"globaloptions_tabwidget=0 0 parent.w (parent.h - buttonHeight - 8 - 2 * vBorder)\n" -"\n" -"# graphics tab\n" -"opYoffset=vBorder\n" -"opXoffset=0\n" -"useWithPrefix=graphicsControls globaloptions_\n" -"\n" -"# audio tab\n" -"opYoffset=vBorder\n" -"useWithPrefix=audioControls globaloptions_\n" -"useWithPrefix=subtitleControls globaloptions_\n" -"\n" -"# volume tab\n" -"opYoffset=vBorder\n" -"useWithPrefix=volumeControls globaloptions_\n" -"\n" -"# MIDI tab\n" -"opYoffset=vBorder\n" -"useWithPrefix=midiControls globaloptions_\n" -"\n" -"# paths tab\n" -"yoffset=vBorder\n" -"glOff=((buttonHeight - kLineHeight) / 2 + 2)\n" -"globaloptions_savebutton=10 yoffset (buttonWidth + 5) buttonHeight\n" -"globaloptions_savepath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight\n" -"yoffset=(yoffset + buttonHeight + 4)\n" -"globaloptions_extrabutton=10 yoffset (buttonWidth + 5) buttonHeight\n" -"globaloptions_extrapath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight\n" -"yoffset=(yoffset + buttonHeight + 4)\n" -"globaloptions_themebutton=10 yoffset (buttonWidth + 5) buttonHeight\n" -"globaloptions_themepath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight\n" -"yoffset=(yoffset + buttonHeight + 4)\n" -"globaloptions_pluginsbutton=10 yoffset (buttonWidth + 5) buttonHeight\n" -"globaloptions_pluginspath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight\n" -"yoffset=(yoffset + buttonHeight + 4)\n" -"globaloptions_keysbutton=10 yoffset (buttonWidth + 5) buttonHeight\n" -"\n" -"# Misc options\n" -"yoffset=vBorder\n" -"glOff=((buttonHeight - kLineHeight) / 2 + 2)\n" -"globaloptions_themebutton2=10 yoffset buttonWidth buttonHeight\n" -"globaloptions_curtheme=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 10) kLineHeight\n" -"yoffset=(yoffset + buttonHeight + 4)\n" -"globaloptions_autosaveperiod=10 yoffset (parent.w - 10 - 25) (kLineHeight + 2)\n" -"\n" -"globaloptions_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n" -"globaloptions_ok=(prev.x2 + 10) prev.y prev.w prev.h\n" -"\n" -"### game options\n" -"gameoptions=insetX insetY insetW insetH\n" -"set_parent=gameoptions\n" -"vBorder=5\n" -"gox=5\n" -"gow=(parent.w - 15)\n" -"\n" -"gameoptions_tabwidget=0 vBorder parent.w (parent.h - buttonHeight - 8 - 2 * vBorder)\n" -"\n" -"# game tab\n" -"opYoffset=vBorder\n" -"gameoptions_id=gox (opYoffset + 2) gameOptionsLabelWidth kLineHeight\n" -"gameoptions_id.align=kTextAlignRight\n" -"gameoptions_domain=prev.x2 (prev.y - 1) (parent.w - gameOptionsLabelWidth - 10 - gox) (prev.h + 2)\n" -"opYoffset=(opYoffset + prev.h + 5)\n" -"gameoptions_name=gox (opYoffset + 2) gameOptionsLabelWidth kLineHeight\n" -"gameoptions_name.align=kTextAlignRight\n" -"gameoptions_desc=prev.x2 (prev.y - 1) (parent.w - gameOptionsLabelWidth - 10 - gox) (prev.h + 2)\n" -"opYoffset=(opYoffset + prev.h + 7)\n" -"gameoptions_lang=gox (opYoffset - 1) gow (kLineHeight + 2)\n" -"opYoffset=(opYoffset + prev.h + 5)\n" -"gameoptions_platform=prev.x opYoffset prev.w prev.h\n" -"opYoffset=(opYoffset + prev.h + 5)\n" -"\n" -"# paths tab\n" -"opYoffset=vBorder\n" -"goOff=((buttonHeight - kLineHeight) / 2 + 2)\n" -"gameoptions_savepath=gox opYoffset (buttonWidth + 5) buttonHeight\n" -"gameoptions_savepathText=(prev.x2 + 20) (opYoffset + goOff) (parent.w - self.x - 10) kLineHeight\n" -"opYoffset=(opYoffset + buttonHeight + 4)\n" -"gameoptions_extrapath=gox opYoffset (buttonWidth + 5) buttonHeight\n" -"gameoptions_extrapathText=(prev.x2 + 20) (opYoffset + goOff) (parent.w - self.x - 10) kLineHeight\n" -"opYoffset=(opYoffset + buttonHeight + 4)\n" -"gameoptions_gamepath=gox opYoffset (buttonWidth + 5) buttonHeight\n" -"gameoptions_gamepathText=(prev.x2 + 20) (opYoffset + goOff) (parent.w - self.x - 10) kLineHeight\n" -"opYoffset=(opYoffset + buttonHeight + 4)\n" -"\n" -"# graphics tab\n" -"opYoffset=vBorder\n" -"opXoffset=gox\n" -"gameoptions_graphicsCheckbox=gox opYoffset (parent.w - gox - 5) buttonHeight\n" -"opYoffset=(opYoffset + buttonHeight)\n" -"useWithPrefix=graphicsControls gameoptions_\n" -"\n" -"# audio tab\n" -"opYoffset=vBorder\n" -"gameoptions_audioCheckbox=gox opYoffset (parent.w - gox - 5) buttonHeight\n" -"opYoffset=(opYoffset + buttonHeight)\n" -"useWithPrefix=audioControls gameoptions_\n" -"useWithPrefix=subtitleControls gameoptions_\n" -"\n" -"# volume tab\n" -"opYoffset=vBorder\n" -"gameoptions_volumeCheckbox=gox opYoffset (parent.w - gox - 5) buttonHeight\n" -"opYoffset=(opYoffset + buttonHeight)\n" -"useWithPrefix=volumeControls gameoptions_\n" -"\n" -"# midi tab\n" -"opYoffset=vBorder\n" -"gameoptions_midiCheckbox=gox opYoffset (parent.w - gox - 5) buttonHeight\n" -"opYoffset=(opYoffset + buttonHeight)\n" -"useWithPrefix=midiControls gameoptions_\n" -"\n" -"gameoptions_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n" -"gameoptions_ok=(prev.x2 + 10) prev.y prev.w prev.h\n" -"\n" -"### keys dialog\n" -"keysdialog=(w / 20) (h / 10) (w - w / 10) (h - h / 4)\n" -"set_parent=keysdialog\n" -"keysdialog_map=(parent.w - buttonWidth - 10) (10 + 2 * kLineHeight) buttonWidth buttonHeight\n" -"keysdialog_ok=prev.x (prev.y2 + 4) prev.w prev.h\n" -"keysdialog_cancel=prev.x (prev.y2 + 4) prev.w prev.h\n" -"keysdialog_action=10 10 (parent.w - 20) kLineHeight\n" -"keysdialog_action.align=kTextAlignCenter\n" -"keysdialog_list=prev.x (prev.y + 2 * kLineHeight) (parent.w - buttonWidth - 30) (parent.h - kLineHeight * 6)\n" -"keysdialog_mapping=prev.x (prev.y + prev.h + kLineHeight) (parent.w - buttonWidth - 20) kLineHeight\n" -"\n" -"### mass add dialog\n" -"massadddialog=10 20 300 174\n" -"set_parent=massadddialog\n" -"massadddialog_caption=10 (10 + 1 * kLineHeight) (parent.w - 2*10) kLineHeight\n" -"massadddialog_caption.align=kTextAlignCenter\n" -"massadddialog_dirprogress=10 (10 + 3 * kLineHeight) (parent.w - 2*10) kLineHeight\n" -"massadddialog_dirprogress.align=kTextAlignCenter\n" -"massadddialog_gameprogress=10 (10 + 4 * kLineHeight) (parent.w - 2*10) kLineHeight\n" -"massadddialog_gameprogress.align=kTextAlignCenter\n" -"massadddialog_ok=((parent.w - (buttonWidth * 2)) / 2) (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n" -"massadddialog_cancel=(prev.x2 + 10) prev.y prev.w prev.h\n" -"\n" -"\n" -"##### SCUMM dialogs\n" -"scummDummyDialog=0 80 0 16\n" -"\n" -"use=scummmain\n" -"## Engine config\n" -"# note that scummconfig size depends on overall height\n" -"# hence it is on the end of the list\n" -"opYoffset=8\n" -"useWithPrefix=volumeControls scummconfig_\n" -"useWithPrefix=subtitleControls scummconfig_\n" -"opYoffset=(opYoffset + buttonHeight)\n" -"opYoffset=(opYoffset + buttonHeight + 4)\n" -"soWidth=(39 + 3 * buttonWidth)\n" -"scummconfig_keys=(soWidth - 3 * (buttonWidth + 4) + 6) opYoffset (buttonWidth - 10) buttonHeight\n" -"scummconfig_cancel=(prev.x2 + 4) prev.y (prev.w + 10) prev.h\n" -"scummconfig_ok=(prev.x2 + 4) prev.y prev.w prev.h\n" -"opYoffset=(opYoffset + buttonHeight)\n" -"scummconfig=((w - soWidth) / 2) ((h - opYoffset) / 2) soWidth (opYoffset + 8)\n" -"\n" -"## Help\n" -"scummHelpNumLines=15\n" -"shH=(5 + (2 + scummHelpNumLines) * kFontHeight + buttonHeight + 7)\n" -"scummhelp=scummhelpX ((h - shH) / 2) scummhelpW shH\n" -"scummhelp_title=10 5 scummhelpW kFontHeight\n" -"scummhelp_key.x=10\n" -"scummhelp_key.yoffset=5\n" -"scummhelp_key.w=80\n" -"scummhelp_key.h=kFontHeight\n" -"scummhelp_dsc.x=90\n" -"scummhelp_dsc.yoffset=5\n" -"scummhelp_dsc.w=(scummhelpW - 10 - 90)\n" -"scummhelp_dsc.h=kFontHeight\n" -"scummhelp_prev=10 (5 + kFontHeight * (scummHelpNumLines + 2) + 2) buttonWidth buttonHeight\n" -"scummhelp_next=(prev.x2 + 8) prev.y prev.w prev.h\n" -"scummhelp_close=(scummhelpW - 8 - buttonWidth) prev.y prev.w prev.h\n" -"\n" -"# Saveload dialog\n" -"scummsaveload=8 8 (w - 2 * 8) (h - 16)\n" -"set_parent=scummsaveload\n" -"scummsaveload_title=10 2 (parent.w - 2 * 10 - 180) kLineHeight\n" -"scummsaveload_title.align=kTextAlignCenter\n" -"scummsaveload_list=10 18 prev.w (parent.h - 17 - buttonHeight - 8 - self.y)\n" -"scummsaveload_thumbnail=(parent.w - (kThumbnailWidth + 18)) 22\n" -"scummsaveload_thumbnail.hPad=4\n" -"scummsaveload_thumbnail.vPad=4\n" -"scummsaveload_thumbnail.fillR=0\n" -"scummsaveload_thumbnail.fillG=0\n" -"scummsaveload_thumbnail.fillB=0\n" -"scummsaveload_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight\n" -"scummsaveload_choose=(prev.x2 + 10) prev.y prev.w prev.h\n" -"scummsaveload_extinfo.visible=true\n" -"\n" -"############################################\n" -"[chooser]\n" -"chooserW=(w - 2 * 8)\n" -"chooser=((w - chooserW) / 2) ((h - opHeight) / 2) chooserW opHeight\n" -"chooser_headline=10 6 (chooserW - 2 * 10) (kLineHeight)\n" -"chooser_headline.align=kTextAlignCenter\n" -"chooser_list=10 (6 + kLineHeight + 2) prev.w (opHeight - self.y - buttonHeight - 12)\n" -"chooser_cancel=(chooserW - 2 * (buttonWidth + 10)) (opHeight - buttonHeight - 8) buttonWidth buttonHeight\n" -"chooser_ok=(prev.x2 + 10) prev.y prev.w prev.h\n" -"\n" -"[graphicsControls]\n" -"gcx=10\n" -"gcw=(parent.w - 2 * 10)\n" -"grModePopup=(gcx - 5) (opYoffset - 1) (gcw + 5) (kLineHeight + 2)\n" -"opYoffset=(opYoffset + kLineHeight + 4)\n" -"grRenderPopup=prev.x (opYoffset - 1) prev.w prev.h\n" -"opYoffset=(opYoffset + kLineHeight + 4)\n" -"grFullscreenCheckbox=gcx opYoffset (parent.w - gcx - 5) buttonHeight\n" -"opYoffset=(opYoffset + buttonHeight)\n" -"grAspectCheckbox=prev.x opYoffset prev.w prev.h\n" -"opYoffset=(opYoffset + buttonHeight)\n" -"\n" -"[audioControls]\n" -"aux=10\n" -"auw=(parent.w - 2 * 10)\n" -"auMidiPopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2)\n" -"opYoffset=(opYoffset + buttonHeight + 4)\n" -"auSampleRatePopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2)\n" -"opYoffset=(opYoffset + buttonHeight + 4)\n" -"\n" -"[volumeControls]\n" -"vctextw=(95 + vcAudioTabIndent)\n" -"vcxoff=(opXoffset + vctextw + 15)\n" -"vcx=(opXoffset + 10)\n" -"vcMusicText=vcx (opYoffset + 2) vctextw kLineHeight\n" -"vcMusicText.align=kTextAlignRight\n" -"vcMusicSlider=vcxoff opYoffset sliderWidth sliderHeight\n" -"vcMusicLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n" -"opYoffset=(opYoffset + sliderHeight + vcAudioTabSpacing)\n" -"vcSfxText=vcx (opYoffset + 2) vctextw kLineHeight\n" -"vcSfxText.align=kTextAlignRight\n" -"vcSfxSlider=vcxoff opYoffset sliderWidth sliderHeight\n" -"vcSfxLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n" -"opYoffset=(opYoffset + sliderHeight + vcAudioTabSpacing)\n" -"vcSpeechText=vcx (opYoffset + 2) vctextw kLineHeight\n" -"vcSpeechText.align=kTextAlignRight\n" -"vcSpeechSlider=vcxoff opYoffset sliderWidth sliderHeight\n" -"vcSpeechLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight\n" -"opYoffset=(opYoffset + sliderHeight + vcAudioTabSpacing)\n" -"\n" -"[midiControls]\n" -"mcx=10\n" -"mcFontButton=mcx opYoffset buttonWidth buttonHeight\n" -"mcFontPath=(prev.x2 + 20) (opYoffset + 3) (parent.w - (buttonWidth + 20) - 15 - kLineHeight - 10) kLineHeight\n" -"mcFontClearButton=(prev.x2 + 10) (opYoffset + 2) kLineHeight kLineHeight\n" -"opYoffset=(opYoffset + buttonHeight + 2 * midiControlsSpacing)\n" -"mcMixedCheckbox=mcx opYoffset (parent.w - mcx - 5) buttonHeight\n" -"opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)\n" -"mcMt32Checkbox=mcx opYoffset prev.w buttonHeight\n" -"opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)\n" -"mcGSCheckbox=mcx opYoffset prev.w buttonHeight\n" -"opYoffset=(opYoffset + buttonHeight + midiControlsSpacing)\n" -"mcMidiGainText=mcx (opYoffset + 2) 95 kLineHeight\n" -"mcMidiGainText.align=kTextAlignRight\n" -"mcMidiGainSlider=(prev.x2 + 10) opYoffset sliderWidth sliderHeight\n" -"mcMidiGainLabel=(prev.x2 + 10) (opYoffset + 2) 40 kLineHeight\n" -"opYoffset=(opYoffset + sliderHeight + midiControlsSpacing)\n" -"\n" -"[subtitleControls]\n" -"sbx=(opXoffset + 10)\n" -"sbYoff=(buttonHeight / 8)\n" -"sbOff=((sliderHeight - kLineHeight) / 2 + 2)\n" -"sbtextw=(100 + vcAudioTabIndent)\n" -"opYoffset=(opYoffset + sbYoff)\n" -"subToggleDesc=sbx (opYoffset + sbYoff) sbtextw buttonHeight\n" -"subToggleDesc.align=kTextAlignRight\n" -"subToggleButton=prev.x2 (opYoffset - sbYoff) (buttonWidth + 54) buttonHeight\n" -"opYoffset=(opYoffset + buttonHeight + 6)\n" -"subSubtitleSpeedDesc=sbx (opYoffset + sbOff) sbtextw kLineHeight\n" -"subSubtitleSpeedDesc.align=kTextAlignRight\n" -"subSubtitleSpeedSlider=prev.x2 opYoffset sliderWidth sliderHeight\n" -"subSubtitleSpeedLabel=(prev.x2 + 10) (opYoffset + sbOff) 24 kLineHeight\n" -"opYoffset=(opYoffset + sliderHeight + 8)\n" -"\n" -"[scummmain]\n" -"## Main dialog\n" -"# note that scummmain size depends on overall height\n" -"smY=(scummmainVSpace + scummmainVAddOff)\n" -"scummmain_resume=scummmainHOffset smY scummmainButtonWidth scummmainButtonHeight\n" -"smY=(smY + scummmainButtonHeight + scummmainVAddOff)\n" -"smY=(smY + scummmainVSpace)\n" -"scummmain_load=prev.x smY prev.w prev.h\n" -"smY=(smY + scummmainButtonHeight + scummmainVAddOff)\n" -"scummmain_save=prev.x smY prev.w prev.h\n" -"smY=(smY + scummmainButtonHeight + scummmainVAddOff)\n" -"smY=(smY + scummmainVSpace)\n" -"scummmain_options=prev.x smY prev.w prev.h\n" -"smY=(smY + scummmainButtonHeight + scummmainVAddOff)\n" -"scummmain_about=prev.x smY prev.w prev.h\n" -"smY=(smY + scummmainButtonHeight + scummmainVAddOff)\n" -"scummmain_help=prev.x smY prev.w prev.h\n" -"smY=(smY + scummmainButtonHeight + scummmainVAddOff)\n" -"smY=(smY + scummmainVSpace)\n" -"scummmain_quit=prev.x smY prev.w prev.h\n" -"smY=(smY + scummmainButtonHeight + scummmainVAddOff)\n" -"smW=(scummmainButtonWidth + 2 * scummmainHOffset)\n" -"smH=(smY + scummmainVSpace)\n" -"scummmain=((w - smW) / 2) ((h - smH) / 2) smW smH\n" -"\n" -"# PSP GUI\n" -"[480x272]\n" -"def_buttonWidth=100\n" -"def_buttonHeight=23\n" -"def_insetX=20\n" -"def_insetY=10\n" -"def_insetW=(w - 2 * insetX)\n" -"def_insetH=(h - 13 - insetY)\n" -"def_launcherVersionX=50\n" -"def_launcherVersionY=5\n" -"def_midiControlsSpacing=2\n" -"def_gameOptionsOverrideVPad=10\n" -"def_aboutXOff=3\n" -"def_aboutYOff=2\n" -"def_aboutOuterBorder=10\n" -"\n" -"use=XxY\n" -""; - -using Common::String; - -void Theme::processSingleLine(const String §ion, const String &prefix, const String &name, const String &str) { - int level = 0; - int start = 0; - uint i; - int value; - const char *selfpostfixes[] = {"self.x", "self.y", "self.w", "self.h"}; - const char *postfixesXYWH[] = {".x", ".y", ".w", ".h"}; - const char *postfixesRGB[] = {".r", ".g", ".b"}; - int npostfix = 0; - const String prefixedname(prefix + name); - - // Make self.BLAH work, but not self.ANYTHING.BLAH - if (!strchr(prefixedname.c_str(), '.')) { - for (i = 0; i < ARRAYSIZE(postfixesXYWH); i++) { - String to(prefixedname); - - to += postfixesXYWH[i]; - - _evaluator->setAlias(selfpostfixes[i], to); - _evaluator->setVar(to, EVAL_UNDEF_VAR); - } - } - - // Count the number of parameters, so that we know if they're meant to - // be XY[WH] or RGB. - - int ntmppostfix = 0; - - for (i = 0; i < str.size(); i++) { - if (isspace(str[i]) && level == 0) { - ntmppostfix++; - } - - if (str[i] == '(') - level++; - else if (str[i] == ')') { - if (level == 0) { - error("Extra ')' in section: [%s] expression: \"%s\" start is at: %d", - section.c_str(), name.c_str(), start); - } - level--; - } - } - - if (level > 0) - error("Missing ')' in section: [%s] expression: \"%s\" start is at: %d", - section.c_str(), name.c_str(), start); - - const char **postfixes = (ntmppostfix == 2) ? postfixesRGB : postfixesXYWH; - - // Now do it for real, only this time we already know the parentheses - // are balanced. - - for (i = 0; i < str.size(); i++) { - if (isspace(str[i]) && level == 0) { - value = _evaluator->eval(String(&(str.c_str()[start]), i - start), section, name + postfixes[npostfix], start); - _evaluator->setVar(prefixedname + postfixes[npostfix++], value); - start = i + 1; - } - if (str[i] == '(') - level++; - else if (str[i] == ')') - level--; - } - - value = _evaluator->eval(String(&(str.c_str()[start]), i - start), section, name + postfixes[npostfix], start); - - if (value == EVAL_STRING_VAR) - _evaluator->setStringVar(prefixedname, _evaluator->lastToken()); - - // process VAR=VALUE construct - if (npostfix == 0) { - _evaluator->setVar(name, value); - - // Fix bug #1742561: "GUI: Missaligned text" - // "blah.align=foo" should be prefixed too - _evaluator->setVar(prefixedname, value); - } else { - _evaluator->setVar(prefixedname + postfixes[npostfix], value); - } - - // If we have all 4 parameters, set .x2 and .y2 - if (npostfix == 3) { - _evaluator->setVar(prefixedname + ".x2", - _evaluator->getVar(prefixedname + ".x") + _evaluator->getVar(prefixedname + ".w")); - _evaluator->setVar(prefixedname + ".y2", - _evaluator->getVar(prefixedname + ".y") + _evaluator->getVar(prefixedname + ".h")); - } - - if (npostfix != 0) - setSpecialAlias("prev", prefixedname); -} - - -void Theme::processResSection(Common::ConfigFile &config, const String &name, bool skipDefs, const String &prefix) { - debug(3, "Reading section: [%s]", name.c_str()); - - const Common::ConfigFile::SectionKeyList &keys = config.getKeys(name); - - Common::ConfigFile::SectionKeyList::const_iterator iterk; - for (iterk = keys.begin(); iterk != keys.end(); ++iterk) { - if (iterk->key == "set_parent") { - setSpecialAlias("parent", prefix + iterk->value); - continue; - } - if (iterk->key.hasPrefix("set_")) { - _evaluator->setAlias(iterk->key.c_str() + 4, prefix + iterk->value); - continue; - } - if (iterk->key.hasPrefix("def_")) { - if (!skipDefs) - _evaluator->setVar(name, prefix + iterk->key, iterk->value); - continue; - } - if (iterk->key == "use") { - if (iterk->value == name) - error("Theme section [%s]: cannot use itself", name.c_str()); - if (!config.hasSection(iterk->value)) - error("Undefined use of section [%s]", iterk->value.c_str()); - processResSection(config, iterk->value, true); - continue; - } - if (iterk->key == "useAsIs") { - if (iterk->value == name) - error("Theme section [%s]: cannot use itself", name.c_str()); - if (!config.hasSection(iterk->value)) - error("Undefined use of section [%s]", iterk->value.c_str()); - processResSection(config, iterk->value); - continue; - } - if (iterk->key == "useWithPrefix") { - const char *temp = iterk->value.c_str(); - const char *pos = strrchr(temp, ' '); - - if (pos == NULL) - error("2 arguments required for useWithPrefix keyword"); - - String n(temp, strchr(temp, ' ') - temp); - String pref(pos + 1); - - if (n == name) - error("Theme section [%s]: cannot use itself", n.c_str()); - if (!config.hasSection(n)) - error("Undefined use of section [%s]", n.c_str()); - processResSection(config, n, true, pref); - continue; - } - processSingleLine(name, prefix, iterk->key, iterk->value); - } -} - -void Theme::setSpecialAlias(const String &alias, const String &name) { - const char *postfixes[] = {".x", ".y", ".w", ".h", ".x2", ".y2"}; - int i; - - for (i = 0; i < ARRAYSIZE(postfixes); i++) { - String from(alias + postfixes[i]); - String to(name + postfixes[i]); - - _evaluator->setAlias(from.c_str(), to); - } -} - -bool Theme::sectionIsSkipped(Common::ConfigFile &config, const char *name, int w, int h) { - if (!config.hasKey("skipFor", name)) - return false; - - String res; - - config.getKey("skipFor", name, res); - - int x, y; - int phase = 0; - const char *ptr = res.c_str(); - - x = y = 0; - - while (phase != 3) { - switch (phase) { - case 0: - if (*ptr >= '0' && *ptr <= '9') { - x = x * 10 + *ptr - '0'; - } else if (*ptr == 'X') { - phase = 1; - } else if (*ptr == 'x') { - phase = 1; - } else { - error("Syntax error. Wrong resolution in skipFor in section %s", name); - } - break; - case 1: - if (*ptr >= '0' && *ptr <= '9') { - y = y * 10 + *ptr - '0'; - } else if (*ptr == 'Y' || !*ptr || *ptr == ',') { - phase = 2; - - if ((x == w || x == 0) && (y == h || y == 0)) - return true; - if (!*ptr) - return false; - if (*ptr == ',') { - phase = x = y = 0; - } - } else { - error("Syntax error. Wrong resolution in skipFor in section %s", name); - } - break; - case 2: - if (*ptr == ',') { - phase = x = y = 0; - } else if (!*ptr) { - if ((x == w || x == 0) && (y == h || y == 0)) - return true; - return false; - } else { - error ("Syntax error. Wrong resolution in skipFor in section %s", name); - } - break; - default: - break; - } - - ptr++; - } - - return false; -} - -void Theme::loadTheme(Common::ConfigFile &config, bool reset) { - char name[80]; - int x = g_system->getOverlayWidth(), y = g_system->getOverlayHeight(); - - if (reset) - _evaluator->reset(); - - strcpy(name, "XxY"); - if (config.hasSection(name) && !sectionIsSkipped(config, "XxY", x, y)) - processResSection(config, name); - - sprintf(name, "%dxY", x); - if (config.hasSection(name) && !sectionIsSkipped(config, name, x, y)) - processResSection(config, name); - - sprintf(name, "Xx%d", y); - if (config.hasSection(name) && !sectionIsSkipped(config, name, x, y)) - processResSection(config, name); - - sprintf(name, "%dx%d", x, y); - if (config.hasSection(name) && !sectionIsSkipped(config, name, x, y)) - processResSection(config, name); - - debug(3, "Number of variables: %d", _evaluator->getNumVars()); -} - -void Theme::loadTheme(Common::ConfigFile &config, bool reset, bool doBackendSpecificPostProcessing) { - loadTheme(config, reset); - - if (doBackendSpecificPostProcessing && !g_system->getExtraThemeConfig().empty()) { - Common::ConfigFile myConfig; - Common::String myConfigINI = g_system->getExtraThemeConfig(); - Common::MemoryReadStream s((const byte *)myConfigINI.c_str(), myConfigINI.size()); - myConfig.loadFromStream(s); - loadTheme(myConfig, false); - } -} - -} // End of namespace GUI diff --git a/gui/theme.cpp b/gui/theme.cpp index 6e05ce086c..e61fc1993d 100644 --- a/gui/theme.cpp +++ b/gui/theme.cpp @@ -23,8 +23,6 @@ */ #include "gui/theme.h" -#include "gui/eval.h" - #include "common/unzip.h" namespace GUI { diff --git a/gui/theme.h b/gui/theme.h index 067603d562..72495b3a22 100644 --- a/gui/theme.h +++ b/gui/theme.h @@ -40,39 +40,6 @@ namespace GUI { class ThemeEval; -//! Hint to the theme engine that the widget is used in a non-standard way. -enum ThemeHint { - //! Indicates that this is the first time the widget is drawn. - THEME_HINT_FIRST_DRAW = 1 << 0, - - /** - * Indicates that the widget will be redrawn often, e.g. list widgets. - * It may therefore be a good idea to save the background so that it - * can be redrawn quickly. - */ - THEME_HINT_SAVE_BACKGROUND = 1 << 1, - - //! Indicates that this is the launcher dialog (maybe delete this in the future) - THEME_HINT_MAIN_DIALOG = 1 << 2, - - //! Indicates special colorfade - THEME_HINT_SPECIAL_COLOR = 1 << 3, - - //! Indicates no colorfade - THEME_HINT_PLAIN_COLOR = 1 << 4, - - //! Indictaes that a shadows should be drawn around the background - THEME_HINT_USE_SHADOW = 1 << 5, - - /** - * Indicates that no background should be restored when drawing the widget - * (note that this can be silently ignored if for example the theme does - * alpha blending and would blend over an already drawn widget) - * TODO: currently only ThemeModern::drawButton supports this - */ - THEME_HINT_NO_BACKGROUND_RESTORE = 1 << 6 -}; - /** * Our theme renderer class. * @@ -109,6 +76,14 @@ public: kWidgetBackgroundEditText, //! Background used for edit text fields kWidgetBackgroundSlider //! Background used for sliders }; + + //! Dialog background type + enum DialogBackground { + kDialogBackgroundMain, + kDialogBackgroundSpecial, + kDialogBackgroundPlain, + kDialogBackgroundDefault + }; //! State of the widget to be drawn enum State { @@ -271,7 +246,7 @@ public: virtual int getStringWidth(const Common::String &str, FontStyle font = kFontStyleBold) const = 0; virtual int getCharWidth(byte c, FontStyle font = kFontStyleBold) const = 0; - virtual void drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state = kStateEnabled) = 0; + virtual void drawDialogBackground(const Common::Rect &r, DialogBackground type, WidgetStateInfo state = kStateEnabled) = 0; virtual void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignCenter, bool inverted = false, int deltax = 0, bool useEllipsis = true, FontStyle font = kFontStyleBold) = 0; // this should ONLY be used by the debugger until we get a nicer solution virtual void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state = kStateEnabled) = 0; diff --git a/gui/themebrowser.cpp b/gui/themebrowser.cpp index 97184fda91..f4039c6cff 100644 --- a/gui/themebrowser.cpp +++ b/gui/themebrowser.cpp @@ -53,7 +53,7 @@ ThemeBrowser::ThemeBrowser() : Dialog("Browser") { _fileList->setNumberingMode(kListNumberingOff); _fileList->setEditable(false); - _fileList->setHints(THEME_HINT_PLAIN_COLOR); + _backgroundType = GUI::Theme::kDialogBackgroundPlain; // Buttons new ButtonWidget(this, "Browser.Cancel", "Cancel", kCloseCmd, 0); diff --git a/gui/themes/classic080.ini b/gui/themes/classic080.ini deleted file mode 100644 index b5c911bada..0000000000 --- a/gui/themes/classic080.ini +++ /dev/null @@ -1,466 +0,0 @@ -# $URL$ -# $Id$ -[theme] -version=23 -type=classic -name=Classic (ScummVM 0.8.0) - -[colors] -color=104 104 104 -shadowcolor=64 64 64 -bgcolor=0 0 0 -textcolor=32 160 32 -textcolorhi=0 255 0 - -[extra] -font="builtin" -blending=true - -[XxY] -def_widgetSize=kBigWidgetSize -def_buttonWidth=kBigButtonWidth -def_buttonHeight=kBigButtonHeight -def_sliderWidth=kBigSliderWidth -def_sliderHeight=kBigSliderHeight -def_kLineHeight=16 -def_kFontHeight=14 -def_insetX=10 -def_insetY=20 -def_insetW=(w - 2 * 10) -def_insetH=(h - 2 * 40) -def_gameOptionsLabelWidth=90 -def_tabPopupsLabelW=150 -def_aboutXOff=8 -def_aboutYOff=5 -def_aboutOuterBorder=80 -def_scummmainHOffset=12 -def_scummmainVSpace=7 -def_scummmainVAddOff=3 -def_scummmainButtonWidth=160 -def_scummmainButtonHeight=28 -def_scummhelpW=370 -def_scummhelpX=((w - scummhelpW) / 2) -def_midiControlsSpacing=2 -def_vcAudioTabIndent=10 -def_vcAudioTabSpacing=4 - -use=colors -use=extra - -##### Widgets config -ListWidget.leftPadding=4 -ListWidget.rightPadding=0 -ListWidget.topPadding=2 -ListWidget.bottomPadding=2 -ListWidget.hlLeftPadding=2 -ListWidget.hlRightPadding=1 -PopUpWidget.leftPadding=4 -PopUpWidget.rightPadding=0 -TabWidget.tabWidth=70 -TabWidget.tabHeight=21 -TabWidget.titleVPad=2 - -###### chooser -opHeight=(h * 7 / 10) -useWithPrefix=chooser defaultChooser_ - -##### browser -brW=((w * 7) / 8) -brH=((h * 9) / 10) -browser=((w - brW) / 2) ((h - brH) / 2) brW brH -set_parent=browser -browser_headline=10 kLineHeight (parent.w - 2 * 10) kLineHeight -browser_headline.align=kTextAlignCenter -browser_path=10 prev.y2 prev.w prev.h -browser_list=10 prev.y2 prev.w (parent.h - 3 * kLineHeight - buttonHeight - 14) -browser_up=10 (parent.h - buttonHeight - 8) buttonWidth buttonHeight -browser_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight -browser_choose=(prev.x2 + 10) prev.y prev.w prev.h - -##### launcher -hBorder=10 -launcher_version=hBorder 8 (w - 2 * hBorder) kLineHeight -launcher_version.align=kTextAlignCenter -top=(h - 8 - buttonHeight) -numButtons=4 -space=8 -butWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons) -launcher_quit_button=hBorder top butWidth buttonHeight -launcher_about_button=(prev.x2 + space) prev.y prev.w prev.h -launcher_options_button=(prev.x2 + space) prev.y prev.w prev.h -launcher_start_button=(prev.x2 + space) prev.y prev.w prev.h -top=(top - buttonHeight * 2) -numButtons=3 -space=10 -butWidth=((w - 2 * hBorder - space * (numButtons - 1)) / numButtons) -launcher_addGame_button=hBorder top butWidth buttonHeight -launcher_editGame_button=(prev.x2 + space) prev.y prev.w prev.h -launcher_removeGame_button=(prev.x2 + space) prev.y prev.w prev.h -launcher_list=hBorder (kLineHeight + 16) (w - 2 * hBorder) (top - kLineHeight - 20) - -### global options -globaloptions=insetX insetY insetW insetH -set_parent=globaloptions -vBorder=5 -globaloptions_tabwidget=0 vBorder parent.w (parent.h - buttonHeight - 8 - 2 * vBorder) - -# graphics tab -opYoffset=vBorder -opXoffset=0 -useWithPrefix=graphicsControls globaloptions_ - -# audio tab -opYoffset=vBorder -useWithPrefix=audioControls globaloptions_ -useWithPrefix=subtitleControls globaloptions_ - -# volume tab -opYoffset=vBorder -useWithPrefix=volumeControls globaloptions_ - -# MIDI tab -opYoffset=vBorder -useWithPrefix=midiControls globaloptions_ - -# paths tab -yoffset=vBorder -glOff=((buttonHeight - kLineHeight) / 2 + 2) -globaloptions_savebutton=10 yoffset (buttonWidth + 5) buttonHeight -globaloptions_savepath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight -yoffset=(yoffset + buttonHeight + 4) -globaloptions_extrabutton=10 yoffset (buttonWidth + 5) buttonHeight -globaloptions_extrapath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight -yoffset=(yoffset + buttonHeight + 4) -globaloptions_themebutton=10 yoffset (buttonWidth + 5) buttonHeight -globaloptions_themepath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight -yoffset=(yoffset + buttonHeight + 4) -globaloptions_pluginsbutton=10 yoffset (buttonWidth + 5) buttonHeight -globaloptions_pluginspath=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 15) kLineHeight -yoffset=(yoffset + buttonHeight + 4) -globaloptions_keysbutton=10 yoffset (buttonWidth + 5) buttonHeight - -# Misc options -yoffset=vBorder -glOff=((buttonHeight - kLineHeight) / 2 + 2) -globaloptions_themebutton2=10 yoffset buttonWidth buttonHeight -globaloptions_curtheme=(prev.x2 + 20) (yoffset + glOff) (parent.w - (prev.w + 20) - 10) kLineHeight -yoffset=(yoffset + buttonHeight + 12) -globaloptions_autosaveperiod=10 yoffset (parent.w - 10 - 25) (kLineHeight + 2) - -globaloptions_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight -globaloptions_ok=(prev.x2 + 10) prev.y prev.w prev.h - -### game options -gameoptions=insetX insetY insetW insetH -set_parent=gameoptions -vBorder=5 -gox=5 -gow=(parent.w - 15) - -gameoptions_tabwidget=0 vBorder parent.w (parent.h - buttonHeight - 8 - 2 * vBorder) - -# game tab -opYoffset=vBorder -gameoptions_id=gox (opYoffset + 2) gameOptionsLabelWidth kLineHeight -gameoptions_id.align=kTextAlignRight -gameoptions_domain=prev.x2 (prev.y - 1) (parent.w - gameOptionsLabelWidth - 10 - gox) (prev.h + 2) -opYoffset=(opYoffset + prev.h + 5) -gameoptions_name=gox (opYoffset + 2) gameOptionsLabelWidth kLineHeight -gameoptions_name.align=kTextAlignRight -gameoptions_desc=prev.x2 (prev.y - 1) (parent.w - gameOptionsLabelWidth - 10 - gox) (prev.h + 2) -opYoffset=(opYoffset + prev.h + 7) -gameoptions_lang=gox (opYoffset - 1) gow (kLineHeight + 2) -opYoffset=(opYoffset + prev.h + 5) -gameoptions_platform=prev.x opYoffset prev.w prev.h -opYoffset=(opYoffset + prev.h + 5) - -# paths tab -opYoffset=vBorder -goOff=((buttonHeight - kLineHeight) / 2 + 2) -gameoptions_savepath=gox opYoffset (buttonWidth + 5) buttonHeight -gameoptions_savepathText=(prev.x2 + 20) (opYoffset + goOff) (parent.w - self.x - 10) kLineHeight -opYoffset=(opYoffset + buttonHeight + 4) -gameoptions_extrapath=gox opYoffset (buttonWidth + 5) buttonHeight -gameoptions_extrapathText=(prev.x2 + 20) (opYoffset + goOff) (parent.w - self.x - 10) kLineHeight -opYoffset=(opYoffset + buttonHeight + 4) -gameoptions_gamepath=gox opYoffset (buttonWidth + 5) buttonHeight -gameoptions_gamepathText=(prev.x2 + 20) (opYoffset + goOff) (parent.w - self.x - 10) kLineHeight -opYoffset=(opYoffset + buttonHeight + 4) - -# graphics tab -opYoffset=vBorder -opXoffset=gox -gameoptions_graphicsCheckbox=gox opYoffset (parent.w - gox - 5) buttonHeight -opYoffset=(opYoffset + buttonHeight) -useWithPrefix=graphicsControls gameoptions_ - -# audio tab -opYoffset=vBorder -gameoptions_audioCheckbox=gox opYoffset (parent.w - gox - 5) buttonHeight -opYoffset=(opYoffset + buttonHeight) -useWithPrefix=audioControls gameoptions_ -useWithPrefix=subtitleControls gameoptions_ - -# volume tab -opYoffset=vBorder -gameoptions_volumeCheckbox=gox opYoffset (parent.w - gox - 5) buttonHeight -opYoffset=(opYoffset + buttonHeight) -useWithPrefix=volumeControls gameoptions_ - -# midi tab -opYoffset=vBorder -gameoptions_midiCheckbox=gox opYoffset (parent.w - gox - 5) buttonHeight -opYoffset=(opYoffset + buttonHeight) -useWithPrefix=midiControls gameoptions_ - -gameoptions_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight -gameoptions_ok=(prev.x2 + 10) prev.y prev.w prev.h - -### keys dialog -keysdialog=(w / 20) (h / 10) (w - w / 10) (h - h / 5) -set_parent=keysdialog -keysdialog_map=(parent.w - buttonWidth - 10) 20 buttonWidth buttonHeight -keysdialog_ok=prev.x (prev.y2 + 4) prev.w prev.h -keysdialog_cancel=prev.x (prev.y2 + 4) prev.w prev.h -keysdialog_list=10 10 (prev.x - 20) (parent.h - kLineHeight * 4 - self.y) -keysdialog_action=prev.x (parent.h - kLineHeight * 3) (parent.w - self.x * 2) kLineHeight -keysdialog_mapping=prev.x (prev.y + kLineHeight) prev.w prev.h - -### mass add dialog -massadddialog=10 20 300 174 -set_parent=massadddialog -massadddialog_caption=10 (10 + 1 * kLineHeight) (parent.w - 2*10) kLineHeight -massadddialog_caption.align=kTextAlignCenter -massadddialog_dirprogress=10 (10 + 3 * kLineHeight) prev.w prev.h -massadddialog_dirprogress.align=kTextAlignCenter -massadddialog_gameprogress=10 (10 + 4 * kLineHeight) prev.w prev.h -massadddialog_gameprogress.align=kTextAlignCenter -massadddialog_ok=((parent.w - (buttonWidth * 2)) / 2) (parent.h - buttonHeight - 8) buttonWidth buttonHeight -massadddialog_cancel=(prev.x2 + 10) prev.y prev.w prev.h - - -##### SCUMM dialogs -scummDummyDialog=0 80 0 16 - -use=scummmain -## Engine config -# note that scummconfig size depends on overall height -# hence it is on the end of the list -opYoffset=8 -useWithPrefix=volumeControls scummconfig_ -useWithPrefix=subtitleControls scummconfig_ -opYoffset=(opYoffset + buttonHeight) -opYoffset=(opYoffset + buttonHeight + 4) -soWidth=(39 + 3 * buttonWidth) -scummconfig_keys=(soWidth - 3 * (buttonWidth + 4) + 6) opYoffset (buttonWidth - 10) buttonHeight -scummconfig_cancel=(prev.x2 + 4) prev.y (prev.w + 10) prev.h -scummconfig_ok=(prev.x2 + 4) prev.y prev.w prev.h -opYoffset=(opYoffset + buttonHeight) -scummconfig=((w - soWidth) / 2) ((h - opYoffset) / 2) soWidth (opYoffset + 8) - -## Help -scummHelpNumLines=15 -shH=(5 + (2 + scummHelpNumLines) * kFontHeight + buttonHeight + 7) -scummhelp=scummhelpX ((h - shH) / 2) scummhelpW shH -scummhelp_title=10 5 scummhelpW kFontHeight -scummhelp_key.x=10 -scummhelp_key.yoffset=5 -scummhelp_key.w=80 -scummhelp_key.h=kFontHeight -scummhelp_dsc.x=90 -scummhelp_dsc.yoffset=5 -scummhelp_dsc.w=(scummhelpW - 10 - 90) -scummhelp_dsc.h=kFontHeight -scummhelp_prev=10 (5 + kFontHeight * (scummHelpNumLines + 2) + 2) buttonWidth buttonHeight -scummhelp_next=(prev.x2 + 8) prev.y prev.w prev.h -scummhelp_close=(scummhelpW - 8 - buttonWidth) prev.y prev.w prev.h - -# Saveload dialog -scummsaveload=8 8 (w - 2 * 8) (h - 16) -set_parent=scummsaveload -scummsaveload_title=10 2 (parent.w - 2 * 10 - 180) kLineHeight -scummsaveload_title.align=kTextAlignCenter -scummsaveload_list=10 18 prev.w (parent.h - 17 - buttonHeight - 8 - self.y) -scummsaveload_thumbnail=(parent.w - (kThumbnailWidth + 18)) 22 -scummsaveload_thumbnail.hPad=4 -scummsaveload_thumbnail.vPad=4 -scummsaveload_thumbnail.fillR=0 -scummsaveload_thumbnail.fillG=0 -scummsaveload_thumbnail.fillB=0 -scummsaveload_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight -scummsaveload_choose=(prev.x2 + 10) prev.y prev.w prev.h -scummsaveload_extinfo.visible=true - -############################################ -[chooser] -chooserW=(w - 2 * 8) -chooser=((w - chooserW) / 2) ((h - opHeight) / 2) chooserW opHeight -chooser_headline=10 6 (chooserW - 2 * 10) (kLineHeight) -chooser_headline.align=kTextAlignCenter -chooser_list=10 (6 + kLineHeight + 2) prev.w (opHeight - self.y - buttonHeight - 12) -chooser_cancel=(chooserW - 2 * (buttonWidth + 10)) (opHeight - buttonHeight - 8) buttonWidth buttonHeight -chooser_ok=(prev.x2 + 10) prev.y prev.w prev.h - -[graphicsControls] -gcx=10 -gcw=(parent.w - 2 * 10) -grModePopup=(gcx - 5) (opYoffset - 1) (gcw + 5) (kLineHeight + 2) -opYoffset=(opYoffset + kLineHeight + 4) -grRenderPopup=prev.x (opYoffset - 1) prev.w prev.h -opYoffset=(opYoffset + kLineHeight + 4) -grFullscreenCheckbox=gcx opYoffset (parent.w - gcx - 5) buttonHeight -opYoffset=(opYoffset + buttonHeight) -grAspectCheckbox=prev.x opYoffset prev.w prev.h -opYoffset=(opYoffset + buttonHeight) - -[audioControls] -aux=10 -auw=(parent.w - 2 * 10) -auMidiPopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2) -opYoffset=(opYoffset + buttonHeight + 4) -auSampleRatePopup=(aux - 5) (opYoffset - 1) (auw + 5) (kLineHeight + 2) -opYoffset=(opYoffset + buttonHeight + 4) - -[volumeControls] -vctextw=(95 + vcAudioTabIndent) -vcxoff=(opXoffset + vctextw + 15) -vcx=(opXoffset + 10) -vcMusicText=vcx (opYoffset + 2) vctextw kLineHeight -vcMusicText.align=kTextAlignRight -vcMusicSlider=vcxoff opYoffset sliderWidth sliderHeight -vcMusicLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight -opYoffset=(opYoffset + sliderHeight + vcAudioTabSpacing) -vcSfxText=vcx (opYoffset + 2) vctextw kLineHeight -vcSfxText.align=kTextAlignRight -vcSfxSlider=vcxoff opYoffset sliderWidth sliderHeight -vcSfxLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight -opYoffset=(opYoffset + sliderHeight + vcAudioTabSpacing) -vcSpeechText=vcx (opYoffset + 2) vctextw kLineHeight -vcSpeechText.align=kTextAlignRight -vcSpeechSlider=vcxoff opYoffset sliderWidth sliderHeight -vcSpeechLabel=(vcxoff + prev.w + 10) (opYoffset + 2) 24 kLineHeight -opYoffset=(opYoffset + sliderHeight + vcAudioTabSpacing) - -[midiControls] -mcx=10 -mcFontButton=mcx opYoffset buttonWidth buttonHeight -mcFontPath=(prev.x2 + 20) (opYoffset + 3) (parent.w - (buttonWidth + 20) - mcx - kLineHeight - 20) kLineHeight -mcFontClearButton=(prev.x2 + 10) (opYoffset + 3) kLineHeight kLineHeight -opYoffset=(opYoffset + buttonHeight + 2 * midiControlsSpacing) -mcMixedCheckbox=mcx opYoffset (parent.w - mcx - 5) buttonHeight -opYoffset=(opYoffset + buttonHeight + midiControlsSpacing) -mcMt32Checkbox=mcx opYoffset prev.w buttonHeight -opYoffset=(opYoffset + buttonHeight + midiControlsSpacing) -mcGSCheckbox=mcx opYoffset prev.w buttonHeight -opYoffset=(opYoffset + buttonHeight + midiControlsSpacing) -mcMidiGainText=mcx (opYoffset + 2) 95 kLineHeight -mcMidiGainText.align=kTextAlignRight -mcMidiGainSlider=(prev.x2 + 10) opYoffset sliderWidth sliderHeight -mcMidiGainLabel=(prev.x2 + 10) (opYoffset + 2) 40 kLineHeight -opYoffset=(opYoffset + sliderHeight + midiControlsSpacing) - -[subtitleControls] -sbx=(opXoffset + 10) -sbYoff=(buttonHeight / 8) -sbOff=((sliderHeight - kLineHeight) / 2 + 2) -sbtextw=(100 + vcAudioTabIndent) -opYoffset=(opYoffset + sbYoff) -subToggleDesc=sbx (opYoffset + sbYoff) sbtextw buttonHeight -subToggleDesc.align=kTextAlignRight -subToggleButton=prev.x2 (opYoffset - sbYoff) (buttonWidth + 54) buttonHeight -opYoffset=(opYoffset + buttonHeight + 6) -subSubtitleSpeedDesc=sbx (opYoffset + sbOff) sbtextw kLineHeight -subSubtitleSpeedDesc.align=kTextAlignRight -subSubtitleSpeedSlider=prev.x2 opYoffset sliderWidth sliderHeight -subSubtitleSpeedLabel=(prev.x2 + 10) (opYoffset + sbOff) 24 kLineHeight -opYoffset=(opYoffset + sliderHeight + 8) - -[scummmain] -## Main dialog -# note that scummmain size depends on overall height -smY=(scummmainVSpace + scummmainVAddOff) -scummmain_resume=scummmainHOffset smY scummmainButtonWidth scummmainButtonHeight -smY=(smY + scummmainButtonHeight + scummmainVAddOff) -smY=(smY + scummmainVSpace) -scummmain_load=prev.x smY prev.w prev.h -smY=(smY + scummmainButtonHeight + scummmainVAddOff) -scummmain_save=prev.x smY prev.w prev.h -smY=(smY + scummmainButtonHeight + scummmainVAddOff) -smY=(smY + scummmainVSpace) -scummmain_options=prev.x smY prev.w prev.h -smY=(smY + scummmainButtonHeight + scummmainVAddOff) -scummmain_about=prev.x smY prev.w prev.h -smY=(smY + scummmainButtonHeight + scummmainVAddOff) -scummmain_help=prev.x smY prev.w prev.h -smY=(smY + scummmainButtonHeight + scummmainVAddOff) -smY=(smY + scummmainVSpace) -scummmain_quit=prev.x smY prev.w prev.h -smY=(smY + scummmainButtonHeight + scummmainVAddOff) -smW=(scummmainButtonWidth + 2 * scummmainHOffset) -smH=(smY + scummmainVSpace) -scummmain=((w - smW) / 2) ((h - smH) / 2) smW smH - -# Define our classic greenish theme here -[320xY] -def_widgetSize=kNormalWidgetSize -def_buttonWidth=kButtonWidth -def_buttonHeight=kButtonHeight -def_sliderWidth=kSliderWidth -def_sliderHeight=kSliderHeight -def_kLineHeight=12 -def_kFontHeight=10 -def_insetX=10 -def_insetY=10 -def_insetW=(w - 2 * 10) -def_insetH=(h - 30) -def_gameOptionsLabelWidth=60 -def_tabPopupsLabelW=100 -def_aboutXOff=3 -def_aboutYOff=2 -def_aboutOuterBorder=10 -def_scummmainHOffset=8 -def_scummmainVSpace=5 -def_scummmainVAddOff=2 -def_scummmainButtonWidth=90 -def_scummmainButtonHeight=16 -def_scummhelpX=5 -def_scummhelpW=(w - 2 * 5) -def_midiControlsSpacing=1 -def_vcAudioTabIndent=0 -def_vcAudioTabSpacing=2 -use=XxY - -TabWidget.tabWidth=0 -TabWidget.tabHeight=16 -TabWidget.titleVPad=2 -# Scumm Saveload dialog -scummsaveload=8 8 (w - 2 * 8) (h - 16) -set_parent=scummsaveload -scummsaveload_title=10 2 (parent.w - 2 * 10) kLineHeight -scummsaveload_list=10 18 prev.w (parent.h - 17 - buttonHeight - 8 - self.y) -scummsaveload_thumbnail=(parent.w - (kThumbnailWidth + 22)) 18 -scummsaveload_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight -scummsaveload_choose=(prev.x2 + 10) prev.y prev.w prev.h -scummsaveload_extinfo.visible=false - -# MM NES resolution -[256x240] -useAsIs=320xY - -# PSP GUI -[480x272] -def_buttonWidth=100 -def_buttonHeight=23 -def_insetX=20 -def_insetY=10 -def_insetW=(w - 2 * insetX) -def_insetH=(h - 13 - insetY) -def_launcherVersionX=50 -def_launcherVersionY=5 -def_midiControlsSpacing=2 -def_gameOptionsOverrideVPad=10 -def_aboutXOff=3 -def_aboutYOff=2 -def_aboutOuterBorder=10 - -use=XxY diff --git a/gui/themes/modern.ini b/gui/themes/modern.ini deleted file mode 100644 index 87ef0bcbb9..0000000000 --- a/gui/themes/modern.ini +++ /dev/null @@ -1,622 +0,0 @@ -# $URL$ -# $Id$ -[theme] -version=23 -type=modern -name=Modern Style - -[pixmaps] -pix_dialog_corner="dialog_bkgd_corner.bmp" -pix_dialog_top="dialog_bkgd_top.bmp" -pix_dialog_left="dialog_bkgd_left.bmp" -pix_dialog_bkgd="dialog_bkgd.bmp" - -pix_widget_corner="widget_bkgd_corner.bmp" -pix_widget_top="widget_bkgd_top.bmp" -pix_widget_left="widget_bkgd_left.bmp" -pix_widget_bkgd="widget_bkgd.bmp" - -pix_widget_small_corner="widget_small_bkgd_corner.bmp" -pix_widget_small_top="widget_small_bkgd_top.bmp" -pix_widget_small_left="widget_small_bkgd_left.bmp" -pix_widget_small_bkgd="widget_small_bkgd.bmp" - -pix_checkbox_empty="checkbox_empty.bmp" -pix_checkbox_checked="checkbox_checked.bmp" - -pix_widget_arrow="widget_arrow.bmp" - -pix_tab_corner="button_bkgd_corner.bmp" -pix_tab_top="widget_bkgd_top.bmp" -pix_tab_left="widget_bkgd_left.bmp" -pix_tab_bkgd="widget_bkgd.bmp" - -pix_slider_bkgd_corner="button_bkgd_corner.bmp" -pix_slider_bkgd_top="button_bkgd_top.bmp" -pix_slider_bkgd_left="button_bkgd_left.bmp" -pix_slider_bkgd_bkgd="button_bkgd.bmp" - -pix_slider_corner="button_bkgd_corner.bmp" -pix_slider_top="button_bkgd_top.bmp" -pix_slider_left="button_bkgd_left.bmp" -pix_slider_bkgd="button_bkgd.bmp" - -pix_scrollbar_bkgd_corner="widget_small_bkgd_corner.bmp" -pix_scrollbar_bkgd_top="widget_small_bkgd_top.bmp" -pix_scrollbar_bkgd_left="widget_small_bkgd_left.bmp" -pix_scrollbar_bkgd_bkgd="widget_small_bkgd.bmp" - -pix_scrollbar_corner="widget_bkgd_corner.bmp" -pix_scrollbar_top="widget_bkgd_top.bmp" -pix_scrollbar_left="widget_bkgd_left.bmp" -pix_scrollbar_bkgd="widget_bkgd.bmp" - -pix_button_corner="button_bkgd_corner.bmp" -pix_button_top="button_bkgd_top.bmp" -pix_button_left="button_bkgd_left.bmp" -pix_button_bkgd="button_bkgd.bmp" - -pix_popupwidget_corner="button_bkgd_corner.bmp" -pix_popupwidget_top="button_bkgd_top.bmp" -pix_popupwidget_left="button_bkgd_left.bmp" -pix_popupwidget_bkgd="button_bkgd.bmp" - -pix_edittext_bkgd_corner="button_bkgd_corner.bmp" -pix_edittext_bkgd_top="button_bkgd_top.bmp" -pix_edittext_bkgd_left="button_bkgd_left.bmp" -pix_edittext_bkgd_bkgd="button_bkgd.bmp" - -pix_theme_logo="logo.bmp" - -pix_cursor_image="cursor.bmp" - -[colors] -main_dialog_start=210 114 10 -main_dialog_end=239 196 24 - -dialog_start=246 224 139 -dialog_end=251 241 206 - -color_state_disabled=192 192 192 -color_state_highlight=100 162 8 -color_state_enabled=0 0 0 - -color_transparency=255 0 255 - -text_inverted_background=100 162 8 -text_inverted_color=0 0 0 - -widget_bkgd_start=246 224 139 -widget_bkgd_end=251 241 206 -widget_bkgd_small_start=246 224 139 -widget_bkgd_small_end=251 241 206 - -button_bkgd_start=203 126 107 -button_bkgd_end=169 42 12 -button_bkgd_highlight_start=255 210 200 -button_bkgd_highlight_end=200 70 50 -button_text_enabled=255 255 255 -button_text_disabled=192 192 192 -button_text_highlight=255 214 84 - -slider_background_start=247 228 166 -slider_background_end=247 228 166 -slider_start=203 126 107 -slider_end=169 42 12 -slider_highlight_start=255 210 200 -slider_highlight_end=200 70 50 - -tab_background_start=232 180 80 -tab_background_end=232 180 80 - -tab_active_start=246 224 139 -tab_active_end=251 241 206 -tab_inactive_start=239 202 109 -tab_inactive_end=239 202 109 - -scrollbar_background_start=247 228 166 -scrollbar_background_end=247 228 166 -scrollbar_button_start=247 228 166 -scrollbar_button_end=247 228 166 -scrollbar_slider_start=203 126 107 -scrollbar_slider_end=169 42 12 -scrollbar_button_highlight_start=255 210 200 -scrollbar_button_highlight_end=200 70 50 -scrollbar_slider_highlight_start=255 210 200 -scrollbar_slider_highlight_end=200 70 50 - -popupwidget_start=251 241 206 -popupwidget_end=251 241 206 -popupwidget_highlight_start=246 224 139 -popupwidget_highlight_end=251 241 206 - -edittext_background_start=247 228 166 -edittext_background_end=247 228 166 - -caret_color=0 0 0 - -[gradients] -gradient_dialog_main=1 -gradient_dialog=4 -gradient_dialog_special=4 - -gradient_widget_small=9 -gradient_widget=9 - -gradient_button=1 - -gradient_slider=1 -gradient_slider_bkgd=1 - -gradient_tab=4 - -gradient_scrollbar=1 -gradient_scrollbar_background=1 - -gradient_popupwidget=1 - -gradient_edittext=1 - -[extra] -shadow_left_width=2 -shadow_right_width=4 -shadow_top_height=2 -shadow_bottom_height=4 -inactive_dialog_shading=kShadingDim -shading_dim_percent=50 -fontfile_normal="helvr12-l1.bdf" -fontfile_fixed_normal="courr12-l1.bdf" -cursor_hotspot_x=0 -cursor_hotspot_y=0 -cursor_targetScale=3 - -[XxY] -skipFor=320xY,256x240 -def_widgetSize=kBigWidgetSize -def_buttonWidth=120 -def_buttonHeight=25 -def_sliderWidth=kBigSliderWidth -def_sliderHeight=kBigSliderHeight -def_kLineHeight=16 -def_kFontHeight=14 -def_kPopUpHeight=(kLineHeight + 3) -def_insetX=23 -def_insetY=94 -def_insetW=(w - buttonWidth - 17 * 2 - insetX) -def_insetH=(h - 23 - insetY) -def_optionsVPad=20 -def_optionsLabelWidth=110 -def_gameOptionsOverrideVPad=20 -def_tabPopupsLabelW=optionsLabelWidth -def_aboutXOff=8 -def_aboutYOff=5 -def_aboutOuterBorder=80 -def_scummmainHOffset=12 -def_scummmainVSpace=15 -def_scummmainVAddOff=5 -def_scummhelpW=370 -def_scummhelpX=((w - scummhelpW) / 2) -def_launcherVersionX=(w / 2 - 283 / 2 - 90) -def_launcherVersionY=21 - -def_xSeparation=10 -def_ySeparation=10 -def_xBorder=15 - -use=pixmaps -use=colors -use=gradients -use=extra - -##### Widgets config -ListWidget.leftPadding=7 -ListWidget.rightPadding=5 -ListWidget.topPadding=5 -ListWidget.bottomPadding=5 -ListWidget.hlLeftPadding=0 -ListWidget.hlRightPadding=0 -PopUpWidget.leftPadding=7 -PopUpWidget.rightPadding=5 -PopUpWidget.labelSpacing=xSeparation -EditTextWidget.font=kFontStyleNormal -EditTextWidget.leftPadding=7 -EditTextWidget.rightPadding=5 -Console.font=kFontStyleFixedNormal -Console.leftPadding=7 -Console.rightPadding=5 -Console.topPadding=5 -Console.bottomPadding=5 -TabWidget.tabWidth=75 -TabWidget.tabHeight=27 -TabWidget.titleVPad=8 -TabWidget.navButtonRightPad=3 -TabWidget.navButtonTopPad=4 -TabWidget.navButtonW=15 -TabWidget.navButtonH=18 - -###### chooser -opHeight=insetH -useWithPrefix=chooser defaultChooser_ - -##### browser -use=browser - -##### launcher -launcher_version=launcherVersionX launcherVersionY 247 kLineHeight -launcher_version.align=kTextAlignRight -launcher_logo=(w / 2 - 283 / 2) 5 283 80 -launcher_logo.visible=true -space1=20 -space2=5 -launcher_list=insetX insetY insetW insetH -launcher_start_button=(prev.x2 + 17) prev.y buttonWidth buttonHeight -launcher_addGame_button=prev.x (prev.y2 + space1) prev.w prev.h -launcher_editGame_button=prev.x (prev.y2 + space2) prev.w prev.h -launcher_removeGame_button=prev.x (prev.y2 + space2) prev.w prev.h -launcher_options_button=prev.x (prev.y2 + space1) prev.w prev.h -launcher_about_button=prev.x (prev.y2 + space2) prev.w prev.h -launcher_quit_button=prev.x (prev.y2 + space1) prev.w prev.h - -use=scummmain - -### global options -globaloptions=insetX insetY insetW insetH -set_parent=globaloptions -vBorder=optionsVPad -globaloptions_tabwidget=0 0 parent.w (parent.h - buttonHeight - 8 - ySeparation) - -# graphics tab -opYoffset=vBorder -opXoffset=0 -useWithPrefix=graphicsControls globaloptions_ - -# audio tab -opYoffset=vBorder -useWithPrefix=audioControls globaloptions_ -useWithPrefix=subtitleControls globaloptions_ - -# volume tab -opYoffset=vBorder -useWithPrefix=volumeControls globaloptions_ - -# MIDI tab -opYoffset=vBorder -useWithPrefix=midiControls globaloptions_ - -# paths tab -yoffset=vBorder -glOff=((buttonHeight - kLineHeight) / 2 + 2) -globaloptions_savebutton=xBorder yoffset buttonWidth buttonHeight -globaloptions_savepath=(prev.x2 + xSeparation) (yoffset + glOff) (parent.w - self.x - xBorder) kLineHeight -yoffset=(yoffset + buttonHeight + ySeparation) -globaloptions_extrabutton=xBorder yoffset buttonWidth buttonHeight -globaloptions_extrapath=(prev.x2 + xSeparation) (yoffset + glOff) (parent.w - self.x - xBorder) kLineHeight -yoffset=(yoffset + buttonHeight + ySeparation) -globaloptions_themebutton=xBorder yoffset buttonWidth buttonHeight -globaloptions_themepath=(prev.x2 + xSeparation) (yoffset + glOff) (parent.w - self.x - xBorder) kLineHeight -yoffset=(yoffset + buttonHeight + ySeparation) -globaloptions_pluginsbutton=xBorder yoffset buttonWidth buttonHeight -globaloptions_pluginspath=(prev.x2 + xSeparation) (yoffset + glOff) (parent.w - self.x - xBorder) kLineHeight -yoffset=(yoffset + buttonHeight + ySeparation) -globaloptions_keysbutton=xBorder yoffset buttonWidth buttonHeight - -# Misc options -yoffset=vBorder -glOff=((buttonHeight - kLineHeight) / 2 + 2) -globaloptions_themebutton2=xBorder yoffset buttonWidth buttonHeight -globaloptions_curtheme=(prev.x2 + xSeparation) (yoffset + glOff) (parent.w - self.x - xBorder) kLineHeight -yoffset=(yoffset + buttonHeight + ySeparation) -globaloptions_autosaveperiod=xBorder yoffset (parent.w - self.x - xBorder) kPopUpHeight - -globaloptions_cancel=(parent.w - 2 * buttonWidth - xSeparation - xBorder) (parent.h - buttonHeight - 8) buttonWidth buttonHeight -globaloptions_ok=(prev.x2 + xSeparation) prev.y prev.w prev.h - -### game options -gameoptions=insetX insetY insetW insetH -set_parent=gameoptions -vBorder=gameOptionsOverrideVPad -gox=xBorder -gow=(parent.w - gox - xBorder) - -gameoptions_tabwidget=0 0 parent.w (parent.h - buttonHeight - 8 - ySeparation) - -# game tab -opYoffset=optionsVPad -glOff=((kPopUpHeight - kLineHeight) / 2 + 2) -gameoptions_id=gox (opYoffset + glOff) optionsLabelWidth kLineHeight -gameoptions_id.align=kTextAlignRight -gameoptions_domain=(prev.x2 + xSeparation) opYoffset (parent.w - self.x - xBorder) kPopUpHeight -opYoffset=(opYoffset + prev.h + ySeparation) -gameoptions_name=gox (opYoffset + glOff) optionsLabelWidth kLineHeight -gameoptions_name.align=kTextAlignRight -gameoptions_desc=(prev.x2 + xSeparation) opYoffset (parent.w - self.x - xBorder) kPopUpHeight -opYoffset=(opYoffset + prev.h + ySeparation) -gameoptions_lang=gox opYoffset (parent.w - self.x - xBorder) kPopUpHeight -opYoffset=(opYoffset + prev.h + ySeparation) -gameoptions_platform=prev.x opYoffset prev.w prev.h -opYoffset=(opYoffset + prev.h + ySeparation) - -# paths tab -opYoffset=optionsVPad -goOff=((buttonHeight - kLineHeight) / 2 + 2) -gameoptions_savepath=gox opYoffset buttonWidth buttonHeight -gameoptions_savepathText=(prev.x2 + xSeparation) (opYoffset + goOff) (parent.w - self.x - xBorder) kLineHeight -opYoffset=(opYoffset + buttonHeight + ySeparation) -gameoptions_extrapath=gox opYoffset buttonWidth buttonHeight -gameoptions_extrapathText=(prev.x2 + xSeparation) (opYoffset + goOff) (parent.w - self.x - xBorder) kLineHeight -opYoffset=(opYoffset + buttonHeight + ySeparation) -gameoptions_gamepath=gox opYoffset buttonWidth buttonHeight -gameoptions_gamepathText=(prev.x2 + xSeparation) (opYoffset + goOff) (parent.w - self.x - xBorder) kLineHeight -opYoffset=(opYoffset + buttonHeight + ySeparation) - -# graphics tab -opYoffset=vBorder -opXoffset=gox -gameoptions_graphicsCheckbox=gox opYoffset (parent.w - gox - xBorder) buttonHeight -opYoffset=(prev.y2 + ySeparation) -useWithPrefix=graphicsControls gameoptions_ - -# audio tab -opYoffset=vBorder -gameoptions_audioCheckbox=gox opYoffset (parent.w - gox - xBorder) buttonHeight -opYoffset=(prev.y2 + ySeparation) -useWithPrefix=audioControls gameoptions_ -useWithPrefix=subtitleControls gameoptions_ - -# volume tab -opYoffset=vBorder -gameoptions_volumeCheckbox=gox opYoffset (parent.w - gox - xBorder) buttonHeight -opYoffset=(prev.y2 + ySeparation) -useWithPrefix=volumeControls gameoptions_ - -# midi tab -opYoffset=vBorder -gameoptions_midiCheckbox=gox opYoffset (parent.w - gox - xBorder) buttonHeight -opYoffset=(prev.y2 + ySeparation) -useWithPrefix=midiControls gameoptions_ - -gameoptions_cancel=(parent.w - 2 * buttonWidth - xSeparation - xBorder) (parent.h - buttonHeight - 8) buttonWidth buttonHeight -gameoptions_ok=(prev.x2 + xSeparation) prev.y prev.w prev.h - -### keys dialog -keysdialog=(w / 20) (h / 10) (w - w / 10) (h - h / 5) -set_parent=keysdialog -keysdialog_map=(parent.w - buttonWidth - 10) 20 buttonWidth buttonHeight -keysdialog_ok=prev.x (prev.y2 + 4) prev.w prev.h -keysdialog_cancel=prev.x (prev.y2 + 4) prev.w prev.h -keysdialog_list=10 10 (prev.x - 20) (parent.h - kLineHeight * 4 - self.y) -keysdialog_action=prev.x (parent.h - kLineHeight * 3) (parent.w - self.x * 2) kLineHeight -keysdialog_action.align=kTextAlignCenter -keysdialog_mapping=prev.x (prev.y + kLineHeight) prev.w prev.h -keysdialog_mapping.align=kTextAlignCenter - -### mass add dialog -massadddialog=10 20 300 174 -set_parent=massadddialog -massadddialog_caption=xBorder (10 + 1 * kLineHeight) (parent.w - 2 * xBorder) kLineHeight -massadddialog_caption.align=kTextAlignCenter -massadddialog_dirprogress=xBorder (10 + 3 * kLineHeight) prev.w prev.h -massadddialog_dirprogress.align=kTextAlignCenter -massadddialog_gameprogress=xBorder (10 + 4 * kLineHeight) prev.w prev.h -massadddialog_gameprogress.align=kTextAlignCenter -massadddialog_ok=((parent.w - (buttonWidth * 2) - xSeparation) / 2) (parent.h - buttonHeight - ySeparation) buttonWidth buttonHeight -massadddialog_cancel=(prev.x2 + xSeparation) prev.y prev.w prev.h - - -##### SCUMM dialogs -scummDummyDialog=0 80 0 16 - -use=scummmain -## Engine config -# note that scummconfig size depends on overall height -# hence it is on the end of the list -opYoffset=8 -useWithPrefix=volumeControls scummconfig_ -opYoffset=(opYoffset + 2) -useWithPrefix=subtitleControls scummconfig_ -opYoffset=(opYoffset + buttonHeight) -opYoffset=(opYoffset + buttonHeight + 4) -soWidth=(8 + 3 * buttonWidth + 4) -scummconfig_keys=(soWidth - 3 * (buttonWidth + 4) + 6) opYoffset (buttonWidth - 10) buttonHeight -scummconfig_cancel=(prev.x2 + 4) prev.y (prev.w + 10) prev.h -scummconfig_ok=(prev.x2 + 4) prev.y prev.w prev.h -opYoffset=(opYoffset + buttonHeight) -scummconfig=((w - soWidth) / 2) ((h - opYoffset) / 2) soWidth (opYoffset + 8) - -## Help -scummHelpNumLines=15 -shH=(5 + (2 + scummHelpNumLines) * kFontHeight + buttonHeight + 7) -shButtonWidth=(buttonWidth - 20) -scummhelp=scummhelpX ((h - shH) / 2) scummhelpW shH -scummhelp_title=10 5 scummhelpW kFontHeight -scummhelp_title.align=kTextAlignCenter -scummhelp_key.x=10 -scummhelp_key.yoffset=5 -scummhelp_key.w=80 -scummhelp_key.h=kFontHeight -scummhelp_dsc.x=90 -scummhelp_dsc.yoffset=5 -scummhelp_dsc.w=(scummhelpW - 10 - 90) -scummhelp_dsc.h=kFontHeight -scummhelp_prev=10 (5 + kFontHeight * (scummHelpNumLines + 2) + 2) shButtonWidth buttonHeight -scummhelp_next=(prev.x2 + 8) prev.y prev.w prev.h -scummhelp_close=(scummhelpW - 8 - shButtonWidth) prev.y prev.w prev.h - -# Saveload dialog -scummsaveload=8 8 (w - 2 * 8) (h - 16) -set_parent=scummsaveload -scummsaveload_title=10 2 (parent.w - 2 * 10 - 180-20) kLineHeight -scummsaveload_title.align=kTextAlignCenter -scummsaveload_list=10 18 prev.w (parent.h - 17 - buttonHeight - 8 - self.y) -scummsaveload_thumbnail=(parent.w - (kThumbnailWidth + 22)) 18 -scummsaveload_thumbnail.hPad=10 -scummsaveload_thumbnail.vPad=10 -scummsaveload_thumbnail.fillR=0 -scummsaveload_thumbnail.fillG=0 -scummsaveload_thumbnail.fillB=0 -scummsaveload_cancel=(parent.w - 2 * (buttonWidth + 10)) (parent.h - buttonHeight - 8) buttonWidth buttonHeight -scummsaveload_choose=(prev.x2 + 10) prev.y prev.w prev.h -scummsaveload_extinfo.visible=true - -############################################ -[chooser] -chooserW=insetW -chooser=insetX insetY chooserW opHeight -chooser_headline=xBorder 6 (chooserW - 2 * xBorder) kLineHeight -chooser_list=prev.x (prev.y2 + 2) prev.w (opHeight - self.y - buttonHeight - 12) -#JVPRAT: next Y doesn't seem right -chooser_cancel=(chooserW - 2 * buttonWidth - xSeparation - xBorder) (opHeight - buttonHeight - 8) buttonWidth buttonHeight -chooser_ok=(prev.x2 + xSeparation) prev.y prev.w prev.h - -[browser] -browser=insetX insetY insetW insetH -set_parent=browser -browser_headline=xBorder 5 (parent.w - 2 * xBorder) kLineHeight -browser_headline.align=kTextAlignCenter -browser_path=prev.x (prev.y2 + 5) prev.w prev.h -browser_list=prev.x prev.y2 prev.w (parent.h - 3 * kLineHeight - buttonHeight - 14) -browser_up=prev.x (parent.h - buttonHeight - 8) buttonWidth buttonHeight -#JVPRAT: doesn't it lack insetx?: -browser_cancel=(parent.w - 2 * buttonWidth - xSeparation - xBorder) (parent.h - buttonHeight - 8) buttonWidth buttonHeight -browser_choose=(prev.x2 + xSeparation) prev.y prev.w prev.h - -[graphicsControls] -gcx=(opXoffset + xBorder) -grModePopup=gcx opYoffset (parent.w - self.x - xBorder) kPopUpHeight -opYoffset=(prev.y2 + ySeparation) -grRenderPopup=prev.x (opYoffset - 1) prev.w prev.h -opYoffset=(prev.y2 + ySeparation) -grFullscreenCheckbox=gcx opYoffset (parent.w - gcx - xBorder) kLineHeight -opYoffset=(prev.y2 + ySeparation) -grAspectCheckbox=prev.x opYoffset prev.w prev.h -opYoffset=(prev.y2 + ySeparation) - -[audioControls] -aux=(opXoffset + xBorder) -auMidiPopup=aux opYoffset (parent.w - self.x - xBorder) kPopUpHeight -opYoffset=(opYoffset + prev.h + ySeparation) -auSampleRatePopup=aux (opYoffset - 1) prev.w kPopUpHeight -opYoffset=(opYoffset + prev.h + ySeparation) - -[volumeControls] -vcx=(opXoffset + xBorder) -vcOff=((sliderHeight - kLineHeight) / 2 + 2) -vcMusicText=vcx (opYoffset + vcOff) optionsLabelWidth kLineHeight -vcMusicText.align=kTextAlignRight -vcMusicSlider=(prev.x2 + xSeparation) opYoffset sliderWidth sliderHeight -vcMusicLabel=(prev.x2 + xSeparation) (opYoffset + vcOff) 24 kLineHeight -opYoffset=(opYoffset + sliderHeight + ySeparation) -vcSfxText=vcx (opYoffset + vcOff) optionsLabelWidth kLineHeight -vcSfxText.align=kTextAlignRight -vcSfxSlider=(prev.x2 + xSeparation) opYoffset sliderWidth sliderHeight -vcSfxLabel=(prev.x2 + xSeparation) (opYoffset + vcOff) 24 kLineHeight -opYoffset=(opYoffset + sliderHeight + ySeparation) -vcSpeechText=vcx (opYoffset + vcOff) optionsLabelWidth kLineHeight -vcSpeechText.align=kTextAlignRight -vcSpeechSlider=(prev.x2 + xSeparation) opYoffset sliderWidth sliderHeight -vcSpeechLabel=(prev.x2 + xSeparation) (opYoffset + vcOff) 24 kLineHeight -opYoffset=(opYoffset + sliderHeight + ySeparation) - -[midiControls] -mcx=(opXoffset + xBorder) -mcOff=((buttonHeight - kLineHeight) / 2 + 2) -mcFontButton=mcx opYoffset buttonWidth buttonHeight -mcFontPath=(prev.x2 + xSeparation) (opYoffset + mcOff) (parent.w - self.x - xSeparation - kLineHeight - xBorder) kLineHeight -mcFontClearButton=(prev.x2 + xSeparation) prev.y kLineHeight kLineHeight -opYoffset=(opYoffset + buttonHeight + ySeparation) -mcMixedCheckbox=mcx opYoffset (parent.w - self.x - xBorder) kLineHeight -opYoffset=(opYoffset + prev.h + ySeparation) -mcMt32Checkbox=mcx opYoffset prev.w kLineHeight -opYoffset=(opYoffset + prev.h + ySeparation) -mcGSCheckbox=mcx opYoffset prev.w kLineHeight -opYoffset=(opYoffset + prev.h + ySeparation) -mcOff=((sliderHeight - kLineHeight) / 2 + 2) -mcMidiGainText=mcx (opYoffset + mcOff) optionsLabelWidth kLineHeight -mcMidiGainText.align=kTextAlignRight -mcMidiGainSlider=(prev.x2 + xSeparation) opYoffset sliderWidth sliderHeight -mcMidiGainLabel=(prev.x2 + xSeparation) (opYoffset + mcOff) 40 kLineHeight -opYoffset=(opYoffset + sliderHeight + ySeparation) - -[subtitleControls] -sbx=(opXoffset + xBorder) -sbOff=((sliderHeight - kLineHeight) / 2 + 2) -subToggleDesc=sbx (opYoffset + sbOff) optionsLabelWidth kLineHeight -subToggleDesc.align=kTextAlignRight -subToggleButton=(prev.x2 + xSeparation) opYoffset (buttonWidth + 34) sliderHeight -opYoffset=(prev.y2 + ySeparation) -subSubtitleSpeedDesc=sbx (opYoffset + sbOff) optionsLabelWidth kLineHeight -subSubtitleSpeedDesc.align=kTextAlignRight -subSubtitleSpeedSlider=(prev.x2 + xSeparation) opYoffset sliderWidth sliderHeight -subSubtitleSpeedLabel=(prev.x2 + xSeparation) (opYoffset + sbOff) 24 kLineHeight -opYoffset=(opYoffset + sliderHeight + ySeparation) - -[scummmain] -## Main dialog -# note that scummmain size depends on overall height -smY=scummmainHOffset -scummmain_resume=scummmainHOffset smY buttonWidth buttonHeight -smY=(smY + buttonHeight + scummmainVAddOff) -smY=(smY + scummmainVSpace) -scummmain_load=prev.x smY prev.w prev.h -smY=(smY + buttonHeight + scummmainVAddOff) -scummmain_save=prev.x smY prev.w prev.h -smY=(smY + buttonHeight + scummmainVAddOff) -smY=(smY + scummmainVSpace) -scummmain_options=prev.x smY prev.w prev.h -smY=(smY + buttonHeight + scummmainVAddOff) -scummmain_about=prev.x smY prev.w prev.h -smY=(smY + buttonHeight + scummmainVAddOff) -scummmain_help=prev.x smY prev.w prev.h -smY=(smY + buttonHeight + scummmainVAddOff) -smY=(smY + scummmainVSpace) -scummmain_quit=prev.x smY prev.w prev.h -smH=(smY + buttonHeight + scummmainHOffset) -smW=(buttonWidth + 2 * scummmainHOffset) -scummmain=((w - smW) / 2) ((h - smH) / 2) smW smH - -[320xY] -use=pixmaps -use=colors -use=gradients -use=extra -shadow_right_width=1 -pix_checkbox_empty="checkbox_empty320.bmp" -pix_checkbox_checked="checkbox_checked320.bmp" -pix_cursor_image="cursor320.bmp" - -# NES resoltuion -[256x240] -use=320xY - -# PSP GUI -[480x272] -def_buttonWidth=100 -def_buttonHeight=23 -def_insetX=20 -def_insetY=10 -def_insetW=(w - buttonWidth - 17 * 2 - insetX) -def_insetH=(h - 13 - insetY) -def_launcherVersionX=50 -def_launcherVersionY=5 -def_gameOptionsOverrideVPad=10 -def_aboutXOff=3 -def_aboutYOff=2 -def_aboutOuterBorder=10 - -use=XxY - -TabWidget.tabWidth=75 - -# Override launcher -launcher_list=insetX 103 (w - buttonWidth - 17 * 2 - self.x) (h - 15 - self.y) -launcher_version=50 80 247 kLineHeight -launcher_version.align=kTextAlignCenter -launcher_logo=40 2 283 80 -launcher_logo.visible=true - -# Override extras -inactive_dialog_shading=kShadingNone - -# Override browser -def_buttonWidth=90 -use=browser diff --git a/gui/themes/modern.zip b/gui/themes/modern.zip Binary files differdeleted file mode 100644 index 739c6d23ac..0000000000 --- a/gui/themes/modern.zip +++ /dev/null diff --git a/gui/themes/scummodern.zip b/gui/themes/scummodern.zip Binary files differindex c240b0080c..4f83ad5cd8 100644 --- a/gui/themes/scummodern.zip +++ b/gui/themes/scummodern.zip diff --git a/gui/widget.cpp b/gui/widget.cpp index 0320aa1f04..685b6dfc65 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -26,7 +26,6 @@ #include "graphics/fontman.h" #include "gui/widget.h" #include "gui/dialog.h" -#include "gui/eval.h" #include "gui/newgui.h" #include "gui/ThemeEval.h" @@ -35,15 +34,13 @@ namespace GUI { Widget::Widget(GuiObject *boss, int x, int y, int w, int h) : GuiObject(x, y, w, h), _type(0), _boss(boss), - _id(0), _flags(0), _hints(THEME_HINT_FIRST_DRAW), - _hasFocus(false), _state(Theme::kStateEnabled) { + _id(0), _flags(0), _hasFocus(false), _state(Theme::kStateEnabled) { init(); } Widget::Widget(GuiObject *boss, const Common::String &name) : GuiObject(name), _type(0), _boss(boss), - _id(0), _flags(0), _hints(THEME_HINT_FIRST_DRAW), - _hasFocus(false), _state(Theme::kStateDisabled) { + _id(0), _flags(0), _hasFocus(false), _state(Theme::kStateDisabled) { init(); } @@ -51,8 +48,6 @@ void Widget::init() { // Insert into the widget list of the boss _next = _boss->_firstWidget; _boss->_firstWidget = this; - // HACK: we enable background saving for all widgets by default for now - _hints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND; } Widget::~Widget() { @@ -101,7 +96,7 @@ void Widget::draw() { // Draw border if (_flags & WIDGET_BORDER) { - gui->theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _hints, Theme::kWidgetBackgroundBorder); + gui->theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), 0, Theme::kWidgetBackgroundBorder); _x += 4; _y += 4; _w -= 8; @@ -128,8 +123,6 @@ void Widget::draw() { w->draw(); w = w->_next; } - - clearHints(THEME_HINT_FIRST_DRAW); } Widget *Widget::findWidgetInChain(Widget *w, int x, int y) { @@ -225,7 +218,6 @@ ButtonWidget::ButtonWidget(GuiObject *boss, const Common::String &name, const Co : StaticTextWidget(boss, name, label), CommandSender(boss), _cmd(cmd), _hotkey(hotkey) { setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG); - _hints = THEME_HINT_USE_SHADOW; _type = kButtonWidget; } @@ -235,7 +227,7 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) { } void ButtonWidget::drawWidget() { - g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, _hints); + g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, 0); } #pragma mark - @@ -335,20 +327,12 @@ GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h) : Widget(boss, x, y, w, h), _gfx(), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG); _type = kGraphicsWidget; - // HACK: Don't save the background. We want to be sure that redrawing - // the widget updates the screen, even when there isn't any image - // to draw. - _hints &= ~THEME_HINT_SAVE_BACKGROUND; } GraphicsWidget::GraphicsWidget(GuiObject *boss, const Common::String &name) : Widget(boss, name), _gfx(), _alpha(256), _transparency(false) { setFlags(WIDGET_ENABLED | WIDGET_CLEARBG); _type = kGraphicsWidget; - // HACK: Don't save the background. We want to be sure that redrawing - // the widget updates the screen, even when there isn't any image - // to draw. - _hints &= ~THEME_HINT_SAVE_BACKGROUND; } GraphicsWidget::~GraphicsWidget() { @@ -403,7 +387,7 @@ ContainerWidget::ContainerWidget(GuiObject *boss, const Common::String &name) : } void ContainerWidget::drawWidget() { - g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _hints, Theme::kWidgetBackgroundBorder); + g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, Theme::kWidgetBackgroundBorder); } } // End of namespace GUI diff --git a/gui/widget.h b/gui/widget.h index 00bf800857..3e111f28d4 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -93,7 +93,6 @@ protected: GuiObject *_boss; Widget *_next; uint16 _id; - uint16 _hints; bool _hasFocus; Theme::WidgetStateInfo _state; @@ -142,10 +141,6 @@ public: void clearFlags(int flags); int getFlags() const { return _flags; } - void setHints(int hints) { _hints |= hints; } - void clearHints(int hints) { _hints &= ~hints; } - int getHints() const { return _hints; } - void setEnabled(bool e) { if (e) setFlags(WIDGET_ENABLED); else clearFlags(WIDGET_ENABLED); } bool isEnabled() const; bool isVisible() const; |