2008-05-25 11:20:28 +00:00
|
|
|
/* 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/util.h"
|
|
|
|
#include "graphics/surface.h"
|
|
|
|
#include "graphics/colormasks.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/events.h"
|
2008-06-25 22:30:28 +00:00
|
|
|
#include "common/config-manager.h"
|
2008-08-09 18:34:16 +00:00
|
|
|
#include "graphics/imageman.h"
|
2008-05-25 11:20:28 +00:00
|
|
|
|
2008-07-01 15:57:30 +00:00
|
|
|
#include "gui/launcher.h"
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
#include "gui/ThemeRenderer.h"
|
2008-07-31 17:23:38 +00:00
|
|
|
#include "gui/ThemeEval.h"
|
2008-05-25 11:20:28 +00:00
|
|
|
#include "graphics/VectorRenderer.h"
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
2008-05-28 15:03:30 +00:00
|
|
|
using namespace Graphics;
|
|
|
|
|
2008-07-21 19:15:59 +00:00
|
|
|
const ThemeRenderer::DrawDataInfo ThemeRenderer::kDrawDataDefaults[] = {
|
2008-07-20 21:47:28 +00:00
|
|
|
{kDDMainDialogBackground, "mainmenu_bg", true, kDDNone},
|
|
|
|
{kDDSpecialColorBackground, "special_bg", true, kDDNone},
|
|
|
|
{kDDPlainColorBackground, "plain_bg", true, kDDNone},
|
|
|
|
{kDDDefaultBackground, "default_bg", true, kDDNone},
|
2008-07-23 16:38:39 +00:00
|
|
|
{kDDTextSelectionBackground, "text_selection", false, kDDNone},
|
2008-06-24 19:48:01 +00:00
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
{kDDWidgetBackgroundDefault, "widget_default", true, kDDNone},
|
|
|
|
{kDDWidgetBackgroundSmall, "widget_small", true, kDDNone},
|
|
|
|
{kDDWidgetBackgroundEditText, "widget_textedit", true, kDDNone},
|
|
|
|
{kDDWidgetBackgroundSlider, "widget_slider", true, kDDNone},
|
2008-06-24 19:48:01 +00:00
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
{kDDButtonIdle, "button_idle", true, kDDNone},
|
|
|
|
{kDDButtonHover, "button_hover", false, kDDButtonIdle},
|
|
|
|
{kDDButtonDisabled, "button_disabled", true, kDDNone},
|
2008-06-24 19:48:01 +00:00
|
|
|
|
2008-07-21 16:14:06 +00:00
|
|
|
{kDDSliderFull, "slider_full", false, kDDNone},
|
2008-08-02 15:15:32 +00:00
|
|
|
{kDDSliderHover, "slider_hover", false, kDDNone},
|
|
|
|
{kDDSliderDisabled, "slider_disabled", true, kDDNone},
|
2008-06-24 19:48:01 +00:00
|
|
|
|
2008-08-01 20:19:37 +00:00
|
|
|
{kDDCheckboxDefault, "checkbox_default", true, kDDNone},
|
2008-07-20 21:47:28 +00:00
|
|
|
{kDDCheckboxDisabled, "checkbox_disabled", true, kDDNone},
|
2008-08-01 20:19:37 +00:00
|
|
|
{kDDCheckboxSelected, "checkbox_selected", false, kDDCheckboxDefault},
|
2008-06-24 19:48:01 +00:00
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
{kDDTabActive, "tab_active", false, kDDTabInactive},
|
|
|
|
{kDDTabInactive, "tab_inactive", true, kDDNone},
|
2008-08-01 20:19:37 +00:00
|
|
|
{kDDTabBackground, "tab_background", true, kDDNone},
|
2008-06-24 19:48:01 +00:00
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
{kDDScrollbarBase, "scrollbar_base", true, kDDNone},
|
2008-07-24 18:40:36 +00:00
|
|
|
|
|
|
|
{kDDScrollbarButtonIdle, "scrollbar_button_idle", true, kDDNone},
|
|
|
|
{kDDScrollbarButtonHover, "scrollbar_button_hover", false, kDDScrollbarButtonIdle},
|
|
|
|
|
|
|
|
{kDDScrollbarHandleIdle, "scrollbar_handle_idle", false, kDDNone},
|
|
|
|
{kDDScrollbarHandleHover, "scrollbar_handle_hover", false, kDDScrollbarBase},
|
2008-07-19 15:49:08 +00:00
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
{kDDPopUpIdle, "popup_idle", true, kDDNone},
|
|
|
|
{kDDPopUpHover, "popup_hover", false, kDDPopUpIdle},
|
2008-07-19 15:49:08 +00:00
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
{kDDCaret, "caret", false, kDDNone},
|
|
|
|
{kDDSeparator, "separator", true, kDDNone},
|
2008-06-24 19:48:01 +00:00
|
|
|
};
|
|
|
|
|
2008-07-23 16:38:39 +00:00
|
|
|
const ThemeRenderer::TextDataInfo ThemeRenderer::kTextDataDefaults[] = {
|
|
|
|
{kTextDataDefault, "text_default"},
|
|
|
|
{kTextDataHover, "text_hover"},
|
|
|
|
{kTextDataDisabled, "text_disabled"},
|
2008-08-01 20:19:37 +00:00
|
|
|
{kTextDataInverted, "text_inverted"},
|
|
|
|
{kTextDataButton, "text_button"},
|
2008-08-07 18:42:47 +00:00
|
|
|
{kTextDataButtonHover, "text_button_hover"},
|
|
|
|
{kTextDataNormalFont, "text_normal"}
|
2008-07-23 16:38:39 +00:00
|
|
|
};
|
|
|
|
|
2008-07-19 15:49:08 +00:00
|
|
|
|
2008-07-03 10:26:55 +00:00
|
|
|
ThemeRenderer::ThemeRenderer(Common::String themeName, GraphicsMode mode) :
|
2008-06-09 21:16:26 +00:00
|
|
|
_vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled),
|
2008-07-17 21:58:43 +00:00
|
|
|
_screen(0), _backBuffer(0), _bytesPerPixel(0), _initOk(false),
|
2008-07-18 16:44:42 +00:00
|
|
|
_themeOk(false), _enabled(false), _buffering(false) {
|
2008-06-09 21:16:26 +00:00
|
|
|
_system = g_system;
|
2008-07-01 15:57:30 +00:00
|
|
|
_parser = new ThemeParser(this);
|
2008-07-31 17:23:38 +00:00
|
|
|
_themeEval = new GUI::ThemeEval();
|
2008-06-09 21:16:26 +00:00
|
|
|
|
2008-06-24 19:48:01 +00:00
|
|
|
for (int i = 0; i < kDrawDataMAX; ++i) {
|
|
|
|
_widgets[i] = 0;
|
|
|
|
}
|
2008-07-23 16:38:39 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < kTextDataMAX; ++i) {
|
|
|
|
_texts[i] = 0;
|
|
|
|
}
|
2008-06-24 19:48:01 +00:00
|
|
|
|
2008-07-03 10:26:55 +00:00
|
|
|
_graphicsMode = mode;
|
|
|
|
setGraphicsMode(_graphicsMode);
|
|
|
|
|
2008-07-23 17:57:11 +00:00
|
|
|
if (_screen->w >= 400 && _screen->h >= 300) {
|
|
|
|
_font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
|
|
|
|
} else {
|
|
|
|
_font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
|
|
|
|
}
|
2008-08-09 18:34:16 +00:00
|
|
|
|
|
|
|
ImageMan.addArchive(themeName + ".zip");
|
2008-07-23 17:57:11 +00:00
|
|
|
|
2008-07-03 10:26:55 +00:00
|
|
|
_initOk = true;
|
|
|
|
_themeName = themeName;
|
|
|
|
}
|
|
|
|
|
2008-08-09 14:15:34 +00:00
|
|
|
ThemeRenderer::~ThemeRenderer() {
|
|
|
|
freeRenderer();
|
|
|
|
freeScreen();
|
|
|
|
freeBackbuffer();
|
|
|
|
unloadTheme();
|
|
|
|
delete _parser;
|
|
|
|
delete _themeEval;
|
2008-08-09 18:34:16 +00:00
|
|
|
|
|
|
|
for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i) {
|
|
|
|
// delete i->_value;
|
|
|
|
ImageMan.unregisterSurface(i->_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageMan.remArchive(_stylefile + ".zip");
|
2008-08-09 14:15:34 +00:00
|
|
|
}
|
|
|
|
|
2008-07-03 10:26:55 +00:00
|
|
|
bool ThemeRenderer::init() {
|
|
|
|
// reset everything and reload the graphics
|
|
|
|
deinit();
|
|
|
|
setGraphicsMode(_graphicsMode);
|
|
|
|
|
2008-07-21 14:03:37 +00:00
|
|
|
if (_screen->pixels && _backBuffer->pixels) {
|
2008-07-03 10:26:55 +00:00
|
|
|
_initOk = true;
|
|
|
|
clearAll();
|
|
|
|
resetDrawArea();
|
|
|
|
}
|
|
|
|
|
2008-07-04 20:05:30 +00:00
|
|
|
if (isThemeLoadingRequired() || !_themeOk) {
|
2008-07-03 10:26:55 +00:00
|
|
|
loadTheme(_themeName);
|
2008-07-03 19:42:04 +00:00
|
|
|
}
|
|
|
|
|
2008-07-03 10:26:55 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ThemeRenderer::deinit() {
|
|
|
|
if (_initOk) {
|
|
|
|
_system->hideOverlay();
|
|
|
|
freeRenderer();
|
|
|
|
freeScreen();
|
2008-07-21 14:03:37 +00:00
|
|
|
freeBackbuffer();
|
2008-07-03 10:26:55 +00:00
|
|
|
_initOk = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ThemeRenderer::clearAll() {
|
|
|
|
if (!_initOk)
|
|
|
|
return;
|
|
|
|
|
2008-07-03 19:42:04 +00:00
|
|
|
_system->clearOverlay();
|
|
|
|
_system->grabOverlay((OverlayColor*)_screen->pixels, _screen->w);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ThemeRenderer::enable() {
|
|
|
|
init();
|
|
|
|
resetDrawArea();
|
|
|
|
_system->showOverlay();
|
|
|
|
clearAll();
|
|
|
|
_enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ThemeRenderer::disable() {
|
|
|
|
_system->hideOverlay();
|
|
|
|
_enabled = false;
|
2008-06-09 21:16:26 +00:00
|
|
|
}
|
|
|
|
|
2008-05-28 14:27:22 +00:00
|
|
|
template<typename PixelType>
|
2008-07-16 10:48:14 +00:00
|
|
|
void ThemeRenderer::screenInit(bool backBuffer) {
|
2008-07-21 14:03:37 +00:00
|
|
|
uint32 width = _system->getOverlayWidth();
|
|
|
|
uint32 height = _system->getOverlayHeight();
|
2008-07-16 10:48:14 +00:00
|
|
|
|
|
|
|
if (backBuffer) {
|
2008-08-09 14:15:34 +00:00
|
|
|
freeBackbuffer();
|
2008-07-16 10:48:14 +00:00
|
|
|
_backBuffer = new Surface;
|
2008-07-21 14:03:37 +00:00
|
|
|
_backBuffer->create(width, height, sizeof(PixelType));
|
2008-07-16 10:48:14 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 14:15:34 +00:00
|
|
|
freeScreen();
|
2008-05-28 15:03:30 +00:00
|
|
|
_screen = new Surface;
|
2008-07-21 14:03:37 +00:00
|
|
|
_screen->create(width, height, sizeof(PixelType));
|
2008-05-28 14:27:22 +00:00
|
|
|
_system->clearOverlay();
|
|
|
|
}
|
|
|
|
|
2008-07-03 10:26:55 +00:00
|
|
|
void ThemeRenderer::setGraphicsMode(GraphicsMode mode) {
|
2008-05-28 14:27:22 +00:00
|
|
|
switch (mode) {
|
2008-05-28 15:03:30 +00:00
|
|
|
case kGfxStandard16bit:
|
|
|
|
case kGfxAntialias16bit:
|
2008-05-28 14:27:22 +00:00
|
|
|
_bytesPerPixel = sizeof(uint16);
|
2008-07-16 10:48:14 +00:00
|
|
|
screenInit<uint16>(kEnableBackCaching);
|
2008-05-28 14:27:22 +00:00
|
|
|
break;
|
2008-05-28 14:30:51 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
2008-05-28 14:27:22 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 11:25:00 +00:00
|
|
|
freeRenderer();
|
2008-05-28 15:03:30 +00:00
|
|
|
_vectorRenderer = createRenderer(mode);
|
2008-05-28 14:27:22 +00:00
|
|
|
_vectorRenderer->setSurface(_screen);
|
|
|
|
}
|
|
|
|
|
2008-07-21 19:15:59 +00:00
|
|
|
void ThemeRenderer::addDrawStep(const Common::String &drawDataId, Graphics::DrawStep step) {
|
2008-06-24 19:48:01 +00:00
|
|
|
DrawData id = getDrawDataId(drawDataId);
|
|
|
|
|
|
|
|
assert(_widgets[id] != 0);
|
|
|
|
_widgets[id]->_steps.push_back(step);
|
2008-06-18 00:15:21 +00:00
|
|
|
}
|
|
|
|
|
2008-07-23 16:38:39 +00:00
|
|
|
bool ThemeRenderer::addTextData(const Common::String &drawDataId, const Common::String &textDataId, TextAlign alignH, TextAlignVertical alignV) {
|
2008-07-10 15:50:44 +00:00
|
|
|
DrawData id = getDrawDataId(drawDataId);
|
2008-07-23 16:38:39 +00:00
|
|
|
TextData textId = getTextDataId(textDataId);
|
2008-07-20 22:23:35 +00:00
|
|
|
|
2008-07-23 16:38:39 +00:00
|
|
|
if (id == -1 || textId == -1 || !_widgets[id])
|
|
|
|
return false;
|
2008-07-10 15:50:44 +00:00
|
|
|
|
2008-07-23 16:38:39 +00:00
|
|
|
_widgets[id]->_textDataId = textId;
|
|
|
|
_widgets[id]->_textAlignH = alignH;
|
|
|
|
_widgets[id]->_textAlignV = alignV;
|
2008-07-20 21:47:28 +00:00
|
|
|
|
2008-07-23 16:38:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-08-07 18:42:47 +00:00
|
|
|
bool ThemeRenderer::addFont(const Common::String &fontId, const Common::String &file, int r, int g, int b) {
|
2008-07-23 16:38:39 +00:00
|
|
|
TextData textId = getTextDataId(fontId);
|
|
|
|
|
|
|
|
if (textId == -1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (_texts[textId] != 0)
|
2008-08-08 18:30:16 +00:00
|
|
|
delete _texts[textId];
|
2008-07-23 16:38:39 +00:00
|
|
|
|
|
|
|
_texts[textId] = new TextDrawData;
|
|
|
|
|
2008-08-07 18:42:47 +00:00
|
|
|
if (file == "default") {
|
|
|
|
_texts[textId]->_fontPtr = _font;
|
|
|
|
} else {
|
|
|
|
_texts[textId]->_fontPtr = FontMan.getFontByName(file);
|
|
|
|
|
|
|
|
if (!_texts[textId]->_fontPtr) {
|
|
|
|
_texts[textId]->_fontPtr = loadFont(file.c_str());
|
|
|
|
|
|
|
|
if (!_texts[textId]->_fontPtr)
|
|
|
|
error("Couldn't load %s font '%s'", fontId.c_str(), file.c_str());
|
|
|
|
|
|
|
|
FontMan.assignFontToName(file, _texts[textId]->_fontPtr);
|
|
|
|
}
|
|
|
|
}
|
2008-07-23 16:38:39 +00:00
|
|
|
|
|
|
|
_texts[textId]->_color.r = r;
|
|
|
|
_texts[textId]->_color.g = g;
|
|
|
|
_texts[textId]->_color.b = b;
|
2008-07-10 15:50:44 +00:00
|
|
|
return true;
|
2008-07-23 16:38:39 +00:00
|
|
|
|
2008-07-10 15:50:44 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 18:34:16 +00:00
|
|
|
bool ThemeRenderer::addBitmap(const Common::String &filename) {
|
|
|
|
if (_bitmaps.contains(filename)) {
|
|
|
|
delete _bitmaps[filename];
|
|
|
|
ImageMan.unregisterSurface(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageMan.registerSurface(filename, 0);
|
|
|
|
_bitmaps[filename] = ImageMan.getSurface(filename);
|
|
|
|
|
|
|
|
return _bitmaps[filename] != 0;
|
|
|
|
}
|
|
|
|
|
2008-07-21 19:15:59 +00:00
|
|
|
bool ThemeRenderer::addDrawData(const Common::String &data, bool cached) {
|
|
|
|
DrawData data_id = getDrawDataId(data);
|
2008-06-24 19:48:01 +00:00
|
|
|
|
2008-08-08 18:30:16 +00:00
|
|
|
if (data_id == -1)
|
2008-06-24 19:48:01 +00:00
|
|
|
return false;
|
2008-08-08 18:30:16 +00:00
|
|
|
|
|
|
|
if (_widgets[data_id] != 0)
|
|
|
|
delete _widgets[data_id];
|
2008-06-24 19:48:01 +00:00
|
|
|
|
|
|
|
_widgets[data_id] = new WidgetDrawData;
|
|
|
|
_widgets[data_id]->_cached = cached;
|
2008-07-21 19:15:59 +00:00
|
|
|
_widgets[data_id]->_buffer = kDrawDataDefaults[data_id].buffer;
|
2008-07-03 10:26:55 +00:00
|
|
|
_widgets[data_id]->_surfaceCache = 0;
|
2008-07-23 16:38:39 +00:00
|
|
|
_widgets[data_id]->_textDataId = -1;
|
2008-06-24 19:48:01 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2008-06-18 00:15:21 +00:00
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
bool ThemeRenderer::loadTheme(Common::String themeName) {
|
2008-06-29 12:08:53 +00:00
|
|
|
unloadTheme();
|
|
|
|
|
2008-07-06 21:38:26 +00:00
|
|
|
if (themeName == "builtin" && !loadDefaultXML())
|
|
|
|
error("Could not load default embeded theme.");
|
|
|
|
|
2008-06-25 22:30:28 +00:00
|
|
|
if (!loadThemeXML(themeName)) {
|
2008-06-26 13:50:16 +00:00
|
|
|
warning("Could not parse custom theme '%s'.\nFalling back to default theme", themeName.c_str());
|
|
|
|
|
|
|
|
if (!loadDefaultXML()) // if we can't load the embeded theme, this is a complete failure
|
2008-06-28 00:02:54 +00:00
|
|
|
error("Could not load default embeded theme");
|
2008-06-25 22:30:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < kDrawDataMAX; ++i) {
|
|
|
|
if (_widgets[i] == 0) {
|
2008-07-23 22:32:00 +00:00
|
|
|
warning("Missing data asset: '%s'", kDrawDataDefaults[i].name);
|
2008-07-17 21:58:43 +00:00
|
|
|
} else {
|
|
|
|
calcBackgroundOffset((DrawData)i);
|
|
|
|
|
|
|
|
// TODO: draw the cached widget to the cache surface
|
|
|
|
if (_widgets[i]->_cached) {}
|
2008-06-25 22:30:28 +00:00
|
|
|
}
|
|
|
|
}
|
2008-07-15 10:50:31 +00:00
|
|
|
|
2008-07-31 17:23:38 +00:00
|
|
|
// Debug print all the parsed variables. remove
|
|
|
|
_themeEval->debugPrint();
|
|
|
|
|
2008-06-25 22:30:28 +00:00
|
|
|
_themeOk = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-08-02 15:15:32 +00:00
|
|
|
bool ThemeRenderer::loadDefaultXML() {
|
|
|
|
|
|
|
|
// The default XML theme is included on runtime from a pregenerated
|
|
|
|
// file inside the themes directory.
|
|
|
|
// Use the Python script "makedeftheme.py" to convert a normal XML theme
|
|
|
|
// into the "default.inc" file, which is ready to be included in the code.
|
|
|
|
const char *defaultXML =
|
|
|
|
#include "themes/default.inc"
|
|
|
|
;
|
|
|
|
|
|
|
|
if (!parser()->loadBuffer((const byte*)defaultXML, strlen(defaultXML), false))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return parser()->parse();
|
|
|
|
}
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
bool ThemeRenderer::loadThemeXML(Common::String themeName) {
|
2008-06-25 22:30:28 +00:00
|
|
|
assert(_parser);
|
|
|
|
|
|
|
|
if (ConfMan.hasKey("themepath"))
|
|
|
|
Common::File::addDefaultDirectory(ConfMan.get("themepath"));
|
|
|
|
|
|
|
|
#ifdef DATA_PATH
|
|
|
|
Common::File::addDefaultDirectoryRecursive(DATA_PATH);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (ConfMan.hasKey("extrapath"))
|
|
|
|
Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath"));
|
2008-08-09 18:34:16 +00:00
|
|
|
|
|
|
|
if (!parser()->loadFile(themeName + ".stx")){
|
|
|
|
#ifdef USE_ZLIB
|
|
|
|
unzFile zipFile = unzOpen((themeName + ".zip").c_str());
|
|
|
|
|
|
|
|
if (zipFile && unzLocateFile(zipFile, (themeName + ".stx").c_str(), 2) == UNZ_OK) {
|
|
|
|
|
|
|
|
unz_file_info fileInfo;
|
|
|
|
unzOpenCurrentFile(zipFile);
|
|
|
|
unzGetCurrentFileInfo(zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
|
|
|
|
uint8 *buffer = new uint8[fileInfo.uncompressed_size+1];
|
|
|
|
assert(buffer);
|
|
|
|
memset(buffer, 0, (fileInfo.uncompressed_size+1)*sizeof(uint8));
|
|
|
|
unzReadCurrentFile(zipFile, buffer, fileInfo.uncompressed_size);
|
|
|
|
unzCloseCurrentFile(zipFile);
|
|
|
|
|
|
|
|
Common::MemoryReadStream *stream = new Common::MemoryReadStream(buffer, fileInfo.uncompressed_size+1, true);
|
|
|
|
|
|
|
|
if (!parser()->loadStream(stream)) {
|
|
|
|
unzClose(zipFile);
|
|
|
|
delete stream;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete[] buffer;
|
|
|
|
buffer = 0;
|
|
|
|
} else {
|
|
|
|
unzClose(zipFile);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
unzClose(zipFile);
|
|
|
|
#else
|
2008-06-25 22:30:28 +00:00
|
|
|
return false;
|
2008-08-09 18:34:16 +00:00
|
|
|
#endif
|
|
|
|
}
|
2008-06-25 22:30:28 +00:00
|
|
|
|
|
|
|
return parser()->parse();
|
|
|
|
}
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
bool ThemeRenderer::isWidgetCached(DrawData type, const Common::Rect &r) {
|
2008-06-12 11:26:11 +00:00
|
|
|
return _widgets[type] && _widgets[type]->_cached &&
|
|
|
|
_widgets[type]->_surfaceCache->w == r.width() &&
|
|
|
|
_widgets[type]->_surfaceCache->h == r.height();
|
|
|
|
}
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
void ThemeRenderer::drawCached(DrawData type, const Common::Rect &r) {
|
2008-06-12 11:26:11 +00:00
|
|
|
assert(_widgets[type]->_surfaceCache->bytesPerPixel == _screen->bytesPerPixel);
|
|
|
|
_vectorRenderer->blitSurface(_widgets[type]->_surfaceCache, r);
|
|
|
|
}
|
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
void ThemeRenderer::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic) {
|
2008-07-10 15:50:44 +00:00
|
|
|
if (_widgets[type] == 0)
|
|
|
|
return;
|
2008-07-20 21:47:28 +00:00
|
|
|
|
|
|
|
DrawQueue q;
|
|
|
|
q.type = type;
|
|
|
|
q.area = r;
|
2008-07-22 13:33:32 +00:00
|
|
|
q.area.clip(_screen->w, _screen->h);
|
2008-07-20 21:47:28 +00:00
|
|
|
q.dynData = dynamic;
|
|
|
|
|
|
|
|
if (_buffering) {
|
2008-07-21 16:14:06 +00:00
|
|
|
if (_widgets[type]->_buffer) {
|
|
|
|
_bufferQueue.push_back(q);
|
|
|
|
} else {
|
2008-07-21 19:15:59 +00:00
|
|
|
if (kDrawDataDefaults[type].parent != kDDNone && kDrawDataDefaults[type].parent != type)
|
|
|
|
queueDD(kDrawDataDefaults[type].parent, r);
|
2008-08-06 13:58:07 +00:00
|
|
|
|
|
|
|
_screenQueue.push_back(q);
|
2008-07-20 21:47:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
drawDD(q, !_widgets[type]->_buffer, _widgets[type]->_buffer);
|
|
|
|
}
|
|
|
|
}
|
2008-07-18 16:44:42 +00:00
|
|
|
|
2008-07-23 17:57:11 +00:00
|
|
|
void ThemeRenderer::queueDDText(TextData type, const Common::Rect &r, const Common::String &text, bool restoreBg,
|
2008-07-23 22:32:00 +00:00
|
|
|
bool elipsis, TextAlign alignH, TextAlignVertical alignV, int deltax) {
|
2008-07-23 16:38:39 +00:00
|
|
|
|
|
|
|
if (_texts[type] == 0)
|
|
|
|
return;
|
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
DrawQueueText q;
|
|
|
|
q.type = type;
|
|
|
|
q.area = r;
|
2008-07-22 13:33:32 +00:00
|
|
|
q.area.clip(_screen->w, _screen->h);
|
2008-07-20 21:47:28 +00:00
|
|
|
q.text = text;
|
2008-07-23 16:38:39 +00:00
|
|
|
q.alignH = alignH;
|
|
|
|
q.alignV = alignV;
|
2008-07-23 17:57:11 +00:00
|
|
|
q.restoreBg = restoreBg;
|
2008-07-23 22:32:00 +00:00
|
|
|
q.deltax = deltax;
|
2008-07-20 21:47:28 +00:00
|
|
|
|
|
|
|
if (_buffering) {
|
|
|
|
_textQueue.push_back(q);
|
2008-07-10 15:50:44 +00:00
|
|
|
} else {
|
2008-07-20 21:47:28 +00:00
|
|
|
drawDDText(q);
|
2008-06-12 11:26:11 +00:00
|
|
|
}
|
2008-07-20 21:47:28 +00:00
|
|
|
}
|
2008-07-18 16:44:42 +00:00
|
|
|
|
2008-08-09 18:34:16 +00:00
|
|
|
void ThemeRenderer::queueBitmap(const Graphics::Surface *bitmap, const Common::Rect &area, bool alpha) {
|
|
|
|
BitmapQueue q;
|
|
|
|
q.bitmap = bitmap;
|
|
|
|
q.area = area;
|
|
|
|
q.alpha = alpha;
|
|
|
|
|
|
|
|
if (_buffering) {
|
|
|
|
_bitmapQueue.push_back(q);
|
|
|
|
} else {
|
|
|
|
drawBitmap(q);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
void ThemeRenderer::drawDD(const DrawQueue &q, bool draw, bool restore) {
|
|
|
|
Common::Rect extendedRect = q.area;
|
|
|
|
extendedRect.grow(kDirtyRectangleThreshold);
|
|
|
|
extendedRect.right += _widgets[q.type]->_backgroundOffset;
|
|
|
|
extendedRect.bottom += _widgets[q.type]->_backgroundOffset;
|
|
|
|
|
|
|
|
if (restore)
|
|
|
|
restoreBackground(extendedRect);
|
|
|
|
|
|
|
|
if (draw) {
|
|
|
|
if (isWidgetCached(q.type, q.area)) {
|
|
|
|
drawCached(q.type, q.area);
|
|
|
|
} else {
|
|
|
|
for (Common::List<Graphics::DrawStep>::const_iterator step = _widgets[q.type]->_steps.begin();
|
|
|
|
step != _widgets[q.type]->_steps.end(); ++step)
|
|
|
|
_vectorRenderer->drawStep(q.area, *step, q.dynData);
|
|
|
|
}
|
2008-07-18 16:44:42 +00:00
|
|
|
}
|
2008-07-20 21:47:28 +00:00
|
|
|
|
|
|
|
addDirtyRect(extendedRect);
|
2008-06-12 11:26:11 +00:00
|
|
|
}
|
|
|
|
|
2008-07-20 22:23:35 +00:00
|
|
|
void ThemeRenderer::drawDDText(const DrawQueueText &q) {
|
2008-07-23 17:57:11 +00:00
|
|
|
if (q.restoreBg)
|
2008-07-20 22:23:35 +00:00
|
|
|
restoreBackground(q.area);
|
2008-07-22 09:23:37 +00:00
|
|
|
|
2008-07-23 16:38:39 +00:00
|
|
|
_vectorRenderer->setFgColor(_texts[q.type]->_color.r, _texts[q.type]->_color.g, _texts[q.type]->_color.b);
|
2008-07-23 22:32:00 +00:00
|
|
|
_vectorRenderer->drawString(_texts[q.type]->_fontPtr, q.text, q.area, q.alignH, q.alignV, q.deltax);
|
2008-07-22 09:23:37 +00:00
|
|
|
addDirtyRect(q.area);
|
2008-07-10 16:37:45 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 18:34:16 +00:00
|
|
|
void ThemeRenderer::drawBitmap(const BitmapQueue &q) {
|
|
|
|
|
|
|
|
if (q.alpha)
|
|
|
|
_vectorRenderer->blitAlphaBitmap(q.bitmap, q.area);
|
|
|
|
else
|
|
|
|
_vectorRenderer->blitSubSurface(q.bitmap, q.area);
|
|
|
|
|
|
|
|
addDirtyRect(q.area);
|
|
|
|
}
|
|
|
|
|
2008-07-17 21:58:43 +00:00
|
|
|
void ThemeRenderer::calcBackgroundOffset(DrawData type) {
|
|
|
|
uint maxShadow = 0;
|
|
|
|
for (Common::List<Graphics::DrawStep>::const_iterator step = _widgets[type]->_steps.begin();
|
|
|
|
step != _widgets[type]->_steps.end(); ++step) {
|
|
|
|
if (((*step).autoWidth || (*step).autoHeight) && (*step).shadow > maxShadow)
|
|
|
|
maxShadow = (*step).shadow;
|
|
|
|
}
|
|
|
|
|
|
|
|
_widgets[type]->_backgroundOffset = maxShadow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ThemeRenderer::restoreBackground(Common::Rect r, bool special) {
|
2008-07-21 14:03:37 +00:00
|
|
|
r.clip(_screen->w, _screen->h); // AHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA... Oh god. :(
|
2008-07-21 09:53:06 +00:00
|
|
|
_vectorRenderer->blitSurface(_backBuffer, r);
|
2008-07-17 21:58:43 +00:00
|
|
|
}
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
void ThemeRenderer::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) {
|
2008-06-28 16:49:39 +00:00
|
|
|
if (!ready())
|
2008-06-12 11:26:11 +00:00
|
|
|
return;
|
2008-07-10 15:50:44 +00:00
|
|
|
|
2008-07-10 16:37:45 +00:00
|
|
|
DrawData dd = kDDButtonIdle;
|
2008-06-12 11:26:11 +00:00
|
|
|
|
|
|
|
if (state == kStateEnabled)
|
2008-07-10 15:50:44 +00:00
|
|
|
dd = kDDButtonIdle;
|
2008-06-12 11:26:11 +00:00
|
|
|
else if (state == kStateHighlight)
|
2008-07-10 15:50:44 +00:00
|
|
|
dd = kDDButtonHover;
|
2008-07-03 19:42:04 +00:00
|
|
|
else if (state == kStateDisabled)
|
2008-07-10 15:50:44 +00:00
|
|
|
dd = kDDButtonDisabled;
|
2008-06-12 11:26:11 +00:00
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(dd, r);
|
2008-07-23 17:57:11 +00:00
|
|
|
queueDDText(getTextData(dd), r, str, false, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
|
2008-06-12 11:26:11 +00:00
|
|
|
}
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
void ThemeRenderer::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) {
|
2008-06-28 16:49:39 +00:00
|
|
|
if (!ready())
|
2008-06-12 11:26:11 +00:00
|
|
|
return;
|
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDSeparator, r);
|
2008-06-12 11:26:11 +00:00
|
|
|
}
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
void ThemeRenderer::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {
|
2008-06-28 16:49:39 +00:00
|
|
|
if (!ready())
|
2008-06-12 19:06:37 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
Common::Rect r2 = r;
|
2008-08-01 20:19:37 +00:00
|
|
|
DrawData dd = kDDCheckboxDefault;
|
|
|
|
|
|
|
|
if (checked)
|
|
|
|
dd = kDDCheckboxSelected;
|
|
|
|
|
|
|
|
if (state == kStateDisabled)
|
|
|
|
dd = kDDCheckboxDisabled;
|
|
|
|
|
|
|
|
TextData td = (state == kStateHighlight) ? kTextDataHover : getTextData(dd);
|
2008-07-11 13:25:23 +00:00
|
|
|
const int checkBoxSize = MIN((int)r.height(), getFontHeight());
|
2008-07-07 18:37:22 +00:00
|
|
|
|
|
|
|
r2.bottom = r2.top + checkBoxSize;
|
|
|
|
r2.right = r2.left + checkBoxSize;
|
|
|
|
|
2008-07-23 16:38:39 +00:00
|
|
|
queueDD(dd, r2);
|
2008-07-11 13:25:23 +00:00
|
|
|
|
|
|
|
r2.left = r2.right + checkBoxSize;
|
|
|
|
r2.right = r.right;
|
|
|
|
|
2008-08-01 20:19:37 +00:00
|
|
|
queueDDText(td, r2, str, false, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV);
|
2008-06-12 19:06:37 +00:00
|
|
|
}
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
void ThemeRenderer::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) {
|
2008-06-28 16:49:39 +00:00
|
|
|
if (!ready())
|
2008-06-12 19:06:37 +00:00
|
|
|
return;
|
2008-08-02 15:15:32 +00:00
|
|
|
|
|
|
|
DrawData dd = kDDSliderFull;
|
|
|
|
|
|
|
|
if (state == kStateHighlight)
|
|
|
|
dd = kDDSliderHover;
|
|
|
|
else if (state == kStateDisabled)
|
|
|
|
dd = kDDSliderDisabled;
|
2008-06-12 19:06:37 +00:00
|
|
|
|
|
|
|
Common::Rect r2 = r;
|
|
|
|
r2.setWidth(MIN((int16)width, r.width()));
|
2008-08-02 22:11:57 +00:00
|
|
|
// r2.top++; r2.bottom--; r2.left++; r2.right--;
|
2008-06-12 19:06:37 +00:00
|
|
|
|
2008-07-21 16:14:06 +00:00
|
|
|
drawWidgetBackground(r, 0, kWidgetBackgroundSlider, kStateEnabled);
|
2008-08-02 15:15:32 +00:00
|
|
|
|
|
|
|
if (width > r.width() * 5 / 100)
|
|
|
|
queueDD(dd, r2);
|
2008-06-12 19:06:37 +00:00
|
|
|
}
|
|
|
|
|
2008-07-24 18:40:36 +00:00
|
|
|
void ThemeRenderer::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) {
|
2008-06-28 16:49:39 +00:00
|
|
|
if (!ready())
|
2008-06-12 19:06:37 +00:00
|
|
|
return;
|
2008-07-15 10:50:31 +00:00
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDScrollbarBase, r);
|
2008-07-24 18:40:36 +00:00
|
|
|
|
|
|
|
Common::Rect r2 = r;
|
|
|
|
const int buttonExtra = (r.width() * 120) / 100;
|
|
|
|
|
|
|
|
r2.bottom = r2.top + buttonExtra;
|
2008-07-25 00:59:53 +00:00
|
|
|
queueDD(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleUp);
|
2008-07-24 18:40:36 +00:00
|
|
|
|
|
|
|
r2.translate(0, r.height() - r2.height());
|
2008-07-25 00:59:53 +00:00
|
|
|
queueDD(scrollState == kScrollbarStateDown ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleDown);
|
2008-07-24 18:40:36 +00:00
|
|
|
|
|
|
|
r2 = r;
|
|
|
|
r2.left += 1;
|
|
|
|
r2.right -= 1;
|
|
|
|
r2.top += sliderY;
|
|
|
|
r2.bottom = r2.top + sliderHeight - 1;
|
|
|
|
queueDD(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2);
|
2008-07-07 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ThemeRenderer::drawDialogBackground(const Common::Rect &r, uint16 hints, WidgetStateInfo state) {
|
|
|
|
if (!ready())
|
|
|
|
return;
|
2008-07-11 13:25:23 +00:00
|
|
|
|
2008-07-12 01:59:33 +00:00
|
|
|
if (hints & THEME_HINT_MAIN_DIALOG) {
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDMainDialogBackground, r);
|
2008-07-12 01:59:33 +00:00
|
|
|
} else if (hints & THEME_HINT_SPECIAL_COLOR) {
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDSpecialColorBackground, r);
|
2008-07-12 01:59:33 +00:00
|
|
|
} else if (hints & THEME_HINT_PLAIN_COLOR) {
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDPlainColorBackground, r);
|
2008-07-12 01:59:33 +00:00
|
|
|
} else {
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDDefaultBackground, r);
|
2008-07-12 01:59:33 +00:00
|
|
|
}
|
2008-07-07 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ThemeRenderer::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state) {
|
|
|
|
if (!ready())
|
|
|
|
return;
|
2008-08-07 18:42:47 +00:00
|
|
|
|
|
|
|
if (erase) {
|
|
|
|
restoreBackground(r);
|
|
|
|
addDirtyRect(r);
|
|
|
|
} else
|
|
|
|
queueDD(kDDCaret, r);
|
2008-07-07 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ThemeRenderer::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align) {
|
|
|
|
if (!ready())
|
|
|
|
return;
|
2008-07-12 18:17:11 +00:00
|
|
|
|
2008-07-14 18:42:38 +00:00
|
|
|
DrawData dd = (state == kStateHighlight) ? kDDPopUpHover : kDDPopUpIdle;
|
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(dd, r);
|
2008-07-14 18:42:38 +00:00
|
|
|
|
|
|
|
if (!sel.empty()) {
|
|
|
|
Common::Rect text(r.left, r.top, r.right - 16, r.bottom);
|
2008-07-23 17:57:11 +00:00
|
|
|
queueDDText(getTextData(dd), text, sel, false, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
|
2008-07-15 10:50:31 +00:00
|
|
|
}
|
2008-07-07 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ThemeRenderer::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) {
|
|
|
|
if (!ready())
|
|
|
|
return;
|
2008-08-08 10:37:58 +00:00
|
|
|
|
2008-08-09 18:34:16 +00:00
|
|
|
queueBitmap(&surface, r, themeTrans);
|
|
|
|
|
|
|
|
// _vectorRenderer->blitSubSurface(&surface, r);
|
|
|
|
// addDirtyRect(r);
|
2008-07-07 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ThemeRenderer::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) {
|
|
|
|
if (!ready())
|
|
|
|
return;
|
2008-07-13 11:07:56 +00:00
|
|
|
|
|
|
|
switch (background) {
|
|
|
|
case kWidgetBackgroundBorderSmall:
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDWidgetBackgroundSmall, r);
|
2008-07-13 11:07:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kWidgetBackgroundEditText:
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDWidgetBackgroundEditText, r);
|
2008-07-13 11:07:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kWidgetBackgroundSlider:
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDWidgetBackgroundSlider, r);
|
2008-07-13 11:07:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDWidgetBackgroundDefault, r);
|
2008-07-13 11:07:56 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-07-07 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ThemeRenderer::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) {
|
|
|
|
if (!ready())
|
|
|
|
return;
|
2008-07-15 18:53:22 +00:00
|
|
|
|
2008-08-02 16:23:58 +00:00
|
|
|
const int tabOffset = 2;
|
|
|
|
tabWidth -= tabOffset;
|
2008-08-01 20:19:37 +00:00
|
|
|
|
|
|
|
queueDD(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight));
|
2008-07-15 18:53:22 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < (int)tabs.size(); ++i) {
|
|
|
|
if (i == active)
|
|
|
|
continue;
|
2008-08-01 20:19:37 +00:00
|
|
|
|
2008-07-15 18:53:22 +00:00
|
|
|
Common::Rect tabRect(r.left + i * (tabWidth + tabOffset), r.top, r.left + i * (tabWidth + tabOffset) + tabWidth, r.top + tabHeight);
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDTabInactive, tabRect);
|
2008-07-23 17:57:11 +00:00
|
|
|
queueDDText(getTextData(kDDTabInactive), tabRect, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
|
2008-07-15 18:53:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (active >= 0) {
|
|
|
|
Common::Rect tabRect(r.left + active * (tabWidth + tabOffset), r.top, r.left + active * (tabWidth + tabOffset) + tabWidth, r.top + tabHeight);
|
2008-07-17 08:36:16 +00:00
|
|
|
const uint16 tabLeft = active * (tabWidth + tabOffset);
|
2008-07-22 13:32:18 +00:00
|
|
|
const uint16 tabRight = MAX(r.right - tabRect.right, 0);
|
2008-07-20 21:47:28 +00:00
|
|
|
queueDD(kDDTabActive, tabRect, (tabLeft << 16) | (tabRight & 0xFFFF));
|
2008-07-23 17:57:11 +00:00
|
|
|
queueDDText(getTextData(kDDTabActive), tabRect, tabs[active], false, false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);
|
2008-07-15 18:53:22 +00:00
|
|
|
}
|
2008-07-07 18:37:22 +00:00
|
|
|
}
|
|
|
|
|
2008-07-15 10:50:31 +00:00
|
|
|
void ThemeRenderer::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {
|
2008-07-23 17:57:11 +00:00
|
|
|
if (!ready())
|
2008-07-15 10:50:31 +00:00
|
|
|
return;
|
2008-07-23 16:38:39 +00:00
|
|
|
|
2008-08-08 15:06:28 +00:00
|
|
|
Common::Rect dr = r;
|
|
|
|
dr.left += deltax;
|
|
|
|
|
2008-07-23 17:57:11 +00:00
|
|
|
if (inverted) {
|
2008-07-23 16:38:39 +00:00
|
|
|
queueDD(kDDTextSelectionBackground, r);
|
2008-08-08 15:06:28 +00:00
|
|
|
queueDDText(kTextDataInverted, dr, str, false, useEllipsis, align);
|
2008-07-23 17:57:11 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-08-07 18:42:47 +00:00
|
|
|
|
|
|
|
switch (font) {
|
|
|
|
case kFontStyleNormal:
|
2008-08-08 15:06:28 +00:00
|
|
|
queueDDText(kTextDataNormalFont, dr, str, true, useEllipsis, align);
|
2008-08-07 18:42:47 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-07-23 17:57:11 +00:00
|
|
|
|
2008-07-23 16:38:39 +00:00
|
|
|
switch (state) {
|
|
|
|
case kStateDisabled:
|
2008-08-08 15:06:28 +00:00
|
|
|
queueDDText(kTextDataDisabled, dr, str, true, useEllipsis, align);
|
2008-08-07 18:42:47 +00:00
|
|
|
return;
|
2008-07-23 16:38:39 +00:00
|
|
|
|
|
|
|
case kStateHighlight:
|
2008-08-08 15:06:28 +00:00
|
|
|
queueDDText(kTextDataHover, dr, str, true, useEllipsis, align);
|
2008-08-07 18:42:47 +00:00
|
|
|
return;
|
2008-07-23 16:38:39 +00:00
|
|
|
|
|
|
|
case kStateEnabled:
|
2008-08-08 15:06:28 +00:00
|
|
|
queueDDText(kTextDataDefault, dr, str, true, useEllipsis, align);
|
2008-08-07 18:42:47 +00:00
|
|
|
return;
|
2008-07-23 16:38:39 +00:00
|
|
|
}
|
2008-07-15 10:50:31 +00:00
|
|
|
}
|
|
|
|
|
2008-08-08 18:30:16 +00:00
|
|
|
void ThemeRenderer::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state) {
|
|
|
|
if (!ready())
|
|
|
|
return;
|
|
|
|
|
|
|
|
restoreBackground(r);
|
|
|
|
font->drawChar(_screen, ch, r.left, r.top, 0);
|
|
|
|
addDirtyRect(r);
|
|
|
|
}
|
|
|
|
|
2008-07-12 01:59:33 +00:00
|
|
|
void ThemeRenderer::debugWidgetPosition(const char *name, const Common::Rect &r) {
|
2008-07-15 18:53:22 +00:00
|
|
|
_font->drawString(_screen, name, r.left, r.top, r.width(), 0xFFFF, Graphics::kTextAlignRight, 0, true);
|
|
|
|
_screen->hLine(r.left, r.top, r.right, 0xFFFF);
|
|
|
|
_screen->hLine(r.left, r.bottom, r.right, 0xFFFF);
|
|
|
|
_screen->vLine(r.left, r.top, r.bottom, 0xFFFF);
|
|
|
|
_screen->vLine(r.right, r.top, r.bottom, 0xFFFF);
|
2008-06-12 19:06:37 +00:00
|
|
|
}
|
|
|
|
|
2008-07-03 19:42:04 +00:00
|
|
|
void ThemeRenderer::updateScreen() {
|
2008-07-20 21:47:28 +00:00
|
|
|
if (!_bufferQueue.empty()) {
|
|
|
|
_vectorRenderer->setSurface(_backBuffer);
|
|
|
|
|
|
|
|
for (Common::List<DrawQueue>::const_iterator q = _bufferQueue.begin(); q != _bufferQueue.end(); ++q)
|
|
|
|
drawDD(*q, true, false);
|
|
|
|
|
|
|
|
_vectorRenderer->setSurface(_screen);
|
2008-07-21 14:03:37 +00:00
|
|
|
_vectorRenderer->blitSurface(_backBuffer, Common::Rect(0, 0, _screen->w, _screen->h));
|
2008-07-20 21:47:28 +00:00
|
|
|
_bufferQueue.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_screenQueue.empty()) {
|
|
|
|
_vectorRenderer->disableShadows();
|
|
|
|
for (Common::List<DrawQueue>::const_iterator q = _screenQueue.begin(); q != _screenQueue.end(); ++q)
|
|
|
|
drawDD(*q, true, false);
|
|
|
|
|
|
|
|
_vectorRenderer->enableShadows();
|
|
|
|
_screenQueue.clear();
|
|
|
|
}
|
|
|
|
|
2008-08-09 18:34:16 +00:00
|
|
|
if (!_bitmapQueue.empty()) {
|
|
|
|
for (Common::List<BitmapQueue>::const_iterator q = _bitmapQueue.begin(); q != _bitmapQueue.end(); ++q)
|
|
|
|
drawBitmap(*q);
|
|
|
|
|
|
|
|
_bitmapQueue.clear();
|
|
|
|
}
|
|
|
|
|
2008-07-20 21:47:28 +00:00
|
|
|
if (!_textQueue.empty()) {
|
|
|
|
for (Common::List<DrawQueueText>::const_iterator q = _textQueue.begin(); q != _textQueue.end(); ++q)
|
|
|
|
drawDDText(*q);
|
|
|
|
|
|
|
|
_textQueue.clear();
|
|
|
|
}
|
|
|
|
|
2008-08-05 16:23:17 +00:00
|
|
|
renderDirtyScreen();
|
2008-08-04 16:59:55 +00:00
|
|
|
|
2008-08-08 15:06:28 +00:00
|
|
|
// _vectorRenderer->fillSurface();
|
|
|
|
// themeEval()->debugDraw(_screen, _font);
|
|
|
|
// _vectorRenderer->copyWholeFrame(_system);
|
2008-07-03 19:42:04 +00:00
|
|
|
}
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
void ThemeRenderer::renderDirtyScreen() {
|
|
|
|
if (_dirtyScreen.empty())
|
|
|
|
return;
|
2008-07-22 12:07:03 +00:00
|
|
|
|
2008-07-22 17:39:30 +00:00
|
|
|
Common::List<Common::Rect>::const_iterator i, j;
|
|
|
|
for (i = _dirtyScreen.begin(); i != _dirtyScreen.end(); ++i) {
|
|
|
|
for (j = i; j != _dirtyScreen.end(); ++j)
|
2008-07-22 20:07:53 +00:00
|
|
|
if (j != i && i->contains(*j))
|
2008-07-22 17:39:30 +00:00
|
|
|
j = _dirtyScreen.reverse_erase(j);
|
|
|
|
|
|
|
|
_vectorRenderer->copyFrame(_system, *i);
|
2008-07-22 09:23:37 +00:00
|
|
|
}
|
|
|
|
|
2008-07-02 18:11:41 +00:00
|
|
|
_dirtyScreen.clear();
|
2008-05-28 14:27:22 +00:00
|
|
|
}
|
|
|
|
|
2008-08-02 16:23:58 +00:00
|
|
|
void ThemeRenderer::openDialog(bool doBuffer, ShadingStyle style) {
|
2008-07-18 16:44:42 +00:00
|
|
|
if (doBuffer)
|
|
|
|
_buffering = true;
|
2008-08-02 16:23:58 +00:00
|
|
|
|
|
|
|
if (style != kShadingNone) {
|
|
|
|
_vectorRenderer->applyScreenShading(style);
|
|
|
|
addDirtyRect(Common::Rect(0, 0, _screen->w, _screen->h));
|
|
|
|
}
|
2008-07-17 21:58:43 +00:00
|
|
|
|
2008-07-21 14:03:37 +00:00
|
|
|
_vectorRenderer->setSurface(_backBuffer);
|
|
|
|
_vectorRenderer->blitSurface(_screen, Common::Rect(0, 0, _screen->w, _screen->h));
|
|
|
|
_vectorRenderer->setSurface(_screen);
|
2008-07-17 21:58:43 +00:00
|
|
|
}
|
|
|
|
|
2008-05-25 17:06:10 +00:00
|
|
|
} // end of namespace GUI.
|