Reordered initialization lists to kill a ton of warnings.

svn-id: r34892
This commit is contained in:
Nicola Mettifogo 2008-11-04 05:29:53 +00:00
parent f12b76b7fb
commit 33b6bc4215
4 changed files with 286 additions and 286 deletions

View file

@ -44,7 +44,7 @@ namespace Graphics {
class VectorRenderer; class VectorRenderer;
struct DrawStep { struct DrawStep {
struct Color { struct Color {
uint8 r, g, b; uint8 r, g, b;
bool set; bool set;
}; };
@ -57,7 +57,7 @@ struct DrawStep {
bool autoWidth, autoHeight; bool autoWidth, autoHeight;
int16 x, y, w, h; /**< width, height and position, if not measured automatically. int16 x, y, w, h; /**< width, height and position, if not measured automatically.
negative values mean counting from the opposite direction */ negative values mean counting from the opposite direction */
enum VectorAlignment { enum VectorAlignment {
kVectorAlignManual, kVectorAlignManual,
kVectorAlignLeft, kVectorAlignLeft,
@ -92,7 +92,7 @@ VectorRenderer *createRenderer(int mode);
* *
* When specifying define DISABLE_FANCY_THEMES eye candy related code * When specifying define DISABLE_FANCY_THEMES eye candy related code
* gets stripped off. This is especially useful for small devices like NDS. * gets stripped off. This is especially useful for small devices like NDS.
* Also note that if you specify DISABLE_FANCY_THEMES, you'll need to * Also note that if you specify DISABLE_FANCY_THEMES, you'll need to
* specify a forced overlay bit format via VECTOR_RENDERER_FORMAT define. * specify a forced overlay bit format via VECTOR_RENDERER_FORMAT define.
* The value looks like 'XYZ' for RXGYBZ mode, so R5G5B5 would be specified * The value looks like 'XYZ' for RXGYBZ mode, so R5G5B5 would be specified
* via: * via:
@ -105,9 +105,9 @@ VectorRenderer *createRenderer(int mode);
*/ */
class VectorRenderer { class VectorRenderer {
public: public:
VectorRenderer() : _shadowOffset(0), _fillMode(kFillDisabled), VectorRenderer() : _activeSurface(NULL), _fillMode(kFillDisabled), _shadowOffset(0),
_activeSurface(NULL), _strokeWidth(1), _gradientFactor(1), _disableShadows(false) { _disableShadows(false), _strokeWidth(1), _gradientFactor(1) {
} }
virtual ~VectorRenderer() {} virtual ~VectorRenderer() {}
@ -127,7 +127,7 @@ public:
kTriangleLeft, kTriangleLeft,
kTriangleRight kTriangleRight
}; };
#ifndef DISABLE_FANCY_THEMES #ifndef DISABLE_FANCY_THEMES
enum ConvolutionData { enum ConvolutionData {
kConvolutionSoftBlur, kConvolutionSoftBlur,
@ -138,7 +138,7 @@ public:
kConvolutionEdgeDetect, kConvolutionEdgeDetect,
kConvolutionMAX kConvolutionMAX
}; };
struct ConvolutionDataSet { struct ConvolutionDataSet {
int matrix[3][3]; int matrix[3][3];
int divisor; int divisor;
@ -212,7 +212,7 @@ public:
* @param bevel Amount of bevel. Must be positive. * @param bevel Amount of bevel. Must be positive.
*/ */
virtual void drawBeveledSquare(int x, int y, int w, int h, int bevel) = 0; virtual void drawBeveledSquare(int x, int y, int w, int h, int bevel) = 0;
/** /**
* Draws a tab-like shape, specially thought for the Tab widget. * Draws a tab-like shape, specially thought for the Tab widget.
* If a radius is given, the tab will have rounded corners. Otherwise, * If a radius is given, the tab will have rounded corners. Otherwise,
@ -225,8 +225,8 @@ public:
* @param r Radius of the corners of the tab (0 for squared tabs). * @param r Radius of the corners of the tab (0 for squared tabs).
*/ */
virtual void drawTab(int x, int y, int r, int w, int h) = 0; virtual void drawTab(int x, int y, int r, int w, int h) = 0;
/** /**
* Simple helper function to draw a cross. * Simple helper function to draw a cross.
*/ */
@ -282,7 +282,7 @@ public:
* @param b value of the blue color byte * @param b value of the blue color byte
*/ */
virtual void setBgColor(uint8 r, uint8 g, uint8 b) = 0; virtual void setBgColor(uint8 r, uint8 g, uint8 b) = 0;
virtual void setBevelColor(uint8 r, uint8 g, uint8 b) = 0; virtual void setBevelColor(uint8 r, uint8 g, uint8 b) = 0;
/** /**
@ -356,7 +356,7 @@ public:
if (offset >= 0) if (offset >= 0)
_shadowOffset = offset; _shadowOffset = offset;
} }
virtual void setBevel(int amount) { virtual void setBevel(int amount) {
if (amount >= 0) if (amount >= 0)
_bevel = amount; _bevel = amount;
@ -386,7 +386,7 @@ public:
int stepGetRadius(const DrawStep &step, const Common::Rect &area); int stepGetRadius(const DrawStep &step, const Common::Rect &area);
/** /**
* DrawStep callback functions for each drawing feature * DrawStep callback functions for each drawing feature
*/ */
void drawCallback_CIRCLE(const Common::Rect &area, const DrawStep &step) { void drawCallback_CIRCLE(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h, radius; uint16 x, y, w, h, radius;
@ -430,19 +430,19 @@ public:
stepGetPositions(step, area, x, y, w, h); stepGetPositions(step, area, x, y, w, h);
drawBeveledSquare(x, y, w, h, _bevel); drawBeveledSquare(x, y, w, h, _bevel);
} }
void drawCallback_TAB(const Common::Rect &area, const DrawStep &step) { void drawCallback_TAB(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h; uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h); stepGetPositions(step, area, x, y, w, h);
drawTab(x, y, stepGetRadius(step, area), w, h); drawTab(x, y, stepGetRadius(step, area), w, h);
} }
void drawCallback_BITMAP(const Common::Rect &area, const DrawStep &step) { void drawCallback_BITMAP(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h; uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h); stepGetPositions(step, area, x, y, w, h);
blitAlphaBitmap(step.blitSrc, Common::Rect(x, y, x + w, y + h)); blitAlphaBitmap(step.blitSrc, Common::Rect(x, y, x + w, y + h));
} }
void drawCallback_CROSS(const Common::Rect &area, const DrawStep &step) { void drawCallback_CROSS(const Common::Rect &area, const DrawStep &step) {
uint16 x, y, w, h; uint16 x, y, w, h;
stepGetPositions(step, area, x, y, w, h); stepGetPositions(step, area, x, y, w, h);
@ -453,7 +453,7 @@ public:
/** /**
* Draws the specified draw step on the screen. * Draws the specified draw step on the screen.
* *
* @see DrawStep * @see DrawStep
* @param area Zone to paint on * @param area Zone to paint on
* @param step Pointer to a DrawStep struct. * @param step Pointer to a DrawStep struct.
@ -467,9 +467,9 @@ public:
* @param r Zone of the surface to copy into the overlay. * @param r Zone of the surface to copy into the overlay.
*/ */
virtual void copyFrame(OSystem *sys, const Common::Rect &r) = 0; virtual void copyFrame(OSystem *sys, const Common::Rect &r) = 0;
/** /**
* Copies the current surface to the system overlay * Copies the current surface to the system overlay
* *
* @param sys Pointer to the global System class * @param sys Pointer to the global System class
*/ */
@ -480,7 +480,7 @@ public:
* *
* Note that the source surface and the active * Note that the source surface and the active
* surface are expected to be of the same size, hence the area delimited * surface are expected to be of the same size, hence the area delimited
* by "r" in the source surface will be blitted into the area delimited by * by "r" in the source surface will be blitted into the area delimited by
* "r" on the current surface. * "r" on the current surface.
* *
* If you wish to blit a smaller surface into the active drawing area, use * If you wish to blit a smaller surface into the active drawing area, use
@ -490,7 +490,7 @@ public:
* @param r Position in the active drawing surface to do the blitting. * @param r Position in the active drawing surface to do the blitting.
*/ */
virtual void blitSurface(const Graphics::Surface *source, const Common::Rect &r) = 0; virtual void blitSurface(const Graphics::Surface *source, const Common::Rect &r) = 0;
/** /**
* Blits a given graphics surface into a small area of the current drawing surface. * Blits a given graphics surface into a small area of the current drawing surface.
* *
@ -499,24 +499,24 @@ public:
* blitted into the active surface, at the position specified by "r". * blitted into the active surface, at the position specified by "r".
*/ */
virtual void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) = 0; virtual void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) = 0;
virtual void blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r) = 0; virtual void blitAlphaBitmap(const Graphics::Surface *source, const Common::Rect &r) = 0;
/** /**
* Draws a string into the screen. Wrapper for the Graphics::Font string drawing * Draws a string into the screen. Wrapper for the Graphics::Font string drawing
* method. * method.
*/ */
virtual void drawString(const Graphics::Font *font, const Common::String &text, virtual void drawString(const Graphics::Font *font, const Common::String &text,
const Common::Rect &area, GUI::Theme::TextAlign alignH, const Common::Rect &area, GUI::Theme::TextAlign alignH,
GUI::Theme::TextAlignVertical alignV, int deltax, bool useEllipsis) = 0; GUI::Theme::TextAlignVertical alignV, int deltax, bool useEllipsis) = 0;
/** /**
* Allows to temporarily enable/disable all shadows drawing. * Allows to temporarily enable/disable all shadows drawing.
* i.e. for performance issues, blitting, etc * i.e. for performance issues, blitting, etc
*/ */
virtual void disableShadows() { _disableShadows = true; } virtual void disableShadows() { _disableShadows = true; }
virtual void enableShadows() { _disableShadows = false; } virtual void enableShadows() { _disableShadows = false; }
#ifndef DISABLE_FANCY_THEMES #ifndef DISABLE_FANCY_THEMES
/** /**
* Applies a convolution matrix on the given surface area. * Applies a convolution matrix on the given surface area.
@ -531,7 +531,7 @@ public:
* @param offset Offset on the convolution area. * @param offset Offset on the convolution area.
*/ */
virtual void areaConvolution(const Common::Rect &area, const int filter[3][3], int filterDiv, int offset) = 0; virtual void areaConvolution(const Common::Rect &area, const int filter[3][3], int filterDiv, int offset) = 0;
/** /**
* Applies one of the predefined convolution effects on the given area. * Applies one of the predefined convolution effects on the given area.
* *
@ -544,7 +544,7 @@ public:
areaConvolution(area, _convolutionData[id].matrix, _convolutionData[id].divisor, _convolutionData[id].offset); areaConvolution(area, _convolutionData[id].matrix, _convolutionData[id].divisor, _convolutionData[id].offset);
} }
#endif #endif
/** /**
* Applies a whole-screen shading effect, used before opening a new dialog. * Applies a whole-screen shading effect, used before opening a new dialog.
* Currently supports screen dimmings and luminance (b&w). * Currently supports screen dimmings and luminance (b&w).
@ -555,7 +555,7 @@ protected:
Surface *_activeSurface; /**< Pointer to the surface currently being drawn */ Surface *_activeSurface; /**< Pointer to the surface currently being drawn */
FillMode _fillMode; /**< Defines in which way (if any) are filled the drawn shapes */ FillMode _fillMode; /**< Defines in which way (if any) are filled the drawn shapes */
int _shadowOffset; /**< offset for drawn shadows */ int _shadowOffset; /**< offset for drawn shadows */
int _bevel; /**< amount of fake bevel */ int _bevel; /**< amount of fake bevel */
bool _disableShadows; /**< Disables temporarily shadow drawing for overlayed images. */ bool _disableShadows; /**< Disables temporarily shadow drawing for overlayed images. */
@ -564,7 +564,7 @@ protected:
int _gradientFactor; /**< Multiplication factor of the active gradient */ int _gradientFactor; /**< Multiplication factor of the active gradient */
int _gradientBytes[3]; /**< Color bytes of the active gradient, used to speed up calculation */ int _gradientBytes[3]; /**< Color bytes of the active gradient, used to speed up calculation */
#ifndef DISABLE_FANCY_THEMES #ifndef DISABLE_FANCY_THEMES
static const ConvolutionDataSet _convolutionData[kConvolutionMAX]; static const ConvolutionDataSet _convolutionData[kConvolutionMAX];
#endif #endif

View file

@ -55,7 +55,7 @@ const ThemeEngine::Renderer ThemeEngine::_rendererModes[] = {
const uint ThemeEngine::_rendererModesSize = ARRAYSIZE(ThemeEngine::_rendererModes); const uint ThemeEngine::_rendererModesSize = ARRAYSIZE(ThemeEngine::_rendererModes);
const ThemeEngine::GraphicsMode ThemeEngine::_defaultRendererMode = const ThemeEngine::GraphicsMode ThemeEngine::_defaultRendererMode =
#ifndef DISABLE_FANCY_THEMES #ifndef DISABLE_FANCY_THEMES
ThemeEngine::kGfxAntialias16bit; ThemeEngine::kGfxAntialias16bit;
#else #else
@ -96,14 +96,14 @@ void ThemeItemDrawData::drawSelf(bool draw, bool restore) {
for (step = _data->_steps.begin(); step != _data->_steps.end(); ++step) for (step = _data->_steps.begin(); step != _data->_steps.end(); ++step)
_engine->renderer()->drawStep(_area, *step, _dynamicData); _engine->renderer()->drawStep(_area, *step, _dynamicData);
} }
_engine->addDirtyRect(extendedRect); _engine->addDirtyRect(extendedRect);
} }
void ThemeItemTextData::drawSelf(bool draw, bool restore) { void ThemeItemTextData::drawSelf(bool draw, bool restore) {
if (_restoreBg || restore) if (_restoreBg || restore)
_engine->restoreBackground(_area); _engine->restoreBackground(_area);
if (draw) { if (draw) {
_engine->renderer()->setFgColor(_data->_color.r, _data->_color.g, _data->_color.b); _engine->renderer()->setFgColor(_data->_color.r, _data->_color.g, _data->_color.b);
_engine->renderer()->drawString(_data->_fontPtr, _text, _area, _alignH, _alignV, _deltax, _ellipsis); _engine->renderer()->drawString(_data->_fontPtr, _text, _area, _alignH, _alignV, _deltax, _ellipsis);
@ -160,10 +160,10 @@ const ThemeEngine::DrawDataInfo ThemeEngine::kDrawDataDefaults[] = {
{kDDTabBackground, "tab_background", true, kDDNone}, {kDDTabBackground, "tab_background", true, kDDNone},
{kDDScrollbarBase, "scrollbar_base", true, kDDNone}, {kDDScrollbarBase, "scrollbar_base", true, kDDNone},
{kDDScrollbarButtonIdle, "scrollbar_button_idle", true, kDDNone}, {kDDScrollbarButtonIdle, "scrollbar_button_idle", true, kDDNone},
{kDDScrollbarButtonHover, "scrollbar_button_hover", false, kDDScrollbarButtonIdle}, {kDDScrollbarButtonHover, "scrollbar_button_hover", false, kDDScrollbarButtonIdle},
{kDDScrollbarHandleIdle, "scrollbar_handle_idle", false, kDDNone}, {kDDScrollbarHandleIdle, "scrollbar_handle_idle", false, kDDNone},
{kDDScrollbarHandleHover, "scrollbar_handle_hover", false, kDDScrollbarBase}, {kDDScrollbarHandleHover, "scrollbar_handle_hover", false, kDDScrollbarBase},
@ -188,20 +188,20 @@ const ThemeEngine::TextDataInfo ThemeEngine::kTextDataDefaults[] = {
/********************************************************** /**********************************************************
* ThemeEngine class * ThemeEngine class
*********************************************************/ *********************************************************/
ThemeEngine::ThemeEngine(Common::String fileName, GraphicsMode mode) : ThemeEngine::ThemeEngine(Common::String fileName, GraphicsMode mode) :
_vectorRenderer(0), _system(0), _graphicsMode(kGfxDisabled), _font(0), _system(0), _vectorRenderer(0), _screen(0), _backBuffer(0),
_screen(0), _backBuffer(0), _bytesPerPixel(0), _initOk(false), _buffering(false), _bytesPerPixel(0), _graphicsMode(kGfxDisabled),
_themeOk(false), _enabled(false), _buffering(false), _cursor(0) { _font(0), _initOk(false), _themeOk(false), _enabled(false), _cursor(0) {
_system = g_system; _system = g_system;
_parser = new ThemeParser(this); _parser = new ThemeParser(this);
_themeEval = new GUI::ThemeEval(); _themeEval = new GUI::ThemeEval();
_useCursor = false; _useCursor = false;
for (int i = 0; i < kDrawDataMAX; ++i) { for (int i = 0; i < kDrawDataMAX; ++i) {
_widgets[i] = 0; _widgets[i] = 0;
} }
for (int i = 0; i < kTextDataMAX; ++i) { for (int i = 0; i < kTextDataMAX; ++i) {
_texts[i] = 0; _texts[i] = 0;
} }
@ -219,7 +219,7 @@ ThemeEngine::~ThemeEngine() {
delete _parser; delete _parser;
delete _themeEval; delete _themeEval;
delete[] _cursor; delete[] _cursor;
for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i) for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i)
ImageMan.unregisterSurface(i->_key); ImageMan.unregisterSurface(i->_key);
} }
@ -238,7 +238,7 @@ bool ThemeEngine::init() {
clearAll(); clearAll();
resetDrawArea(); resetDrawArea();
} }
if (_screen->w >= 400 && _screen->h >= 300) { if (_screen->w >= 400 && _screen->h >= 300) {
_font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); _font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
} else { } else {
@ -270,17 +270,17 @@ void ThemeEngine::unloadTheme() {
delete _widgets[i]; delete _widgets[i];
_widgets[i] = 0; _widgets[i] = 0;
} }
for (int i = 0; i < kTextDataMAX; ++i) { for (int i = 0; i < kTextDataMAX; ++i) {
delete _texts[i]; delete _texts[i];
_texts[i] = 0; _texts[i] = 0;
} }
for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i) for (ImagesMap::iterator i = _bitmaps.begin(); i != _bitmaps.end(); ++i)
ImageMan.unregisterSurface(i->_key); ImageMan.unregisterSurface(i->_key);
ImageMan.removeArchive(_themeFileName); ImageMan.removeArchive(_themeFileName);
_themeEval->reset(); _themeEval->reset();
_themeOk = false; _themeOk = false;
} }
@ -297,7 +297,7 @@ void ThemeEngine::refresh() {
init(); init();
if (_enabled) { if (_enabled) {
_system->showOverlay(); _system->showOverlay();
if (_useCursor) { if (_useCursor) {
CursorMan.replaceCursorPalette(_cursorPal, 0, MAX_CURS_COLORS); CursorMan.replaceCursorPalette(_cursorPal, 0, MAX_CURS_COLORS);
CursorMan.replaceCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY, 255, _cursorTargetScale); CursorMan.replaceCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY, 255, _cursorTargetScale);
@ -308,10 +308,10 @@ void ThemeEngine::refresh() {
void ThemeEngine::enable() { void ThemeEngine::enable() {
init(); init();
resetDrawArea(); resetDrawArea();
if (_useCursor) if (_useCursor)
setUpCursor(); setUpCursor();
_system->showOverlay(); _system->showOverlay();
clearAll(); clearAll();
_enabled = true; _enabled = true;
@ -319,26 +319,26 @@ void ThemeEngine::enable() {
void ThemeEngine::disable() { void ThemeEngine::disable() {
_system->hideOverlay(); _system->hideOverlay();
if (_useCursor) { if (_useCursor) {
CursorMan.popCursorPalette(); CursorMan.popCursorPalette();
CursorMan.popCursor(); CursorMan.popCursor();
} }
_enabled = false; _enabled = false;
} }
template<typename PixelType> template<typename PixelType>
void ThemeEngine::screenInit(bool backBuffer) { void ThemeEngine::screenInit(bool backBuffer) {
uint32 width = _system->getOverlayWidth(); uint32 width = _system->getOverlayWidth();
uint32 height = _system->getOverlayHeight(); uint32 height = _system->getOverlayHeight();
if (backBuffer) { if (backBuffer) {
freeBackbuffer(); freeBackbuffer();
_backBuffer = new Surface; _backBuffer = new Surface;
_backBuffer->create(width, height, sizeof(PixelType)); _backBuffer->create(width, height, sizeof(PixelType));
} }
freeScreen(); freeScreen();
_screen = new Surface; _screen = new Surface;
_screen->create(width, height, sizeof(PixelType)); _screen->create(width, height, sizeof(PixelType));
@ -366,7 +366,7 @@ void ThemeEngine::setGraphicsMode(GraphicsMode mode) {
bool ThemeEngine::isWidgetCached(DrawData type, const Common::Rect &r) { bool ThemeEngine::isWidgetCached(DrawData type, const Common::Rect &r) {
return _widgets[type] && _widgets[type]->_cached && return _widgets[type] && _widgets[type]->_cached &&
_widgets[type]->_surfaceCache->w == r.width() && _widgets[type]->_surfaceCache->w == r.width() &&
_widgets[type]->_surfaceCache->h == r.height(); _widgets[type]->_surfaceCache->h == r.height();
} }
@ -377,11 +377,11 @@ void ThemeEngine::drawCached(DrawData type, const Common::Rect &r) {
void ThemeEngine::calcBackgroundOffset(DrawData type) { void ThemeEngine::calcBackgroundOffset(DrawData type) {
uint maxShadow = 0; uint maxShadow = 0;
for (Common::List<Graphics::DrawStep>::const_iterator step = _widgets[type]->_steps.begin(); for (Common::List<Graphics::DrawStep>::const_iterator step = _widgets[type]->_steps.begin();
step != _widgets[type]->_steps.end(); ++step) { step != _widgets[type]->_steps.end(); ++step) {
if ((step->autoWidth || step->autoHeight) && step->shadow > maxShadow) if ((step->autoWidth || step->autoHeight) && step->shadow > maxShadow)
maxShadow = step->shadow; maxShadow = step->shadow;
if (step->drawingCall == &Graphics::VectorRenderer::drawCallback_BEVELSQ && step->bevel > maxShadow) if (step->drawingCall == &Graphics::VectorRenderer::drawCallback_BEVELSQ && step->bevel > maxShadow)
maxShadow = step->bevel; maxShadow = step->bevel;
} }
@ -402,7 +402,7 @@ void ThemeEngine::restoreBackground(Common::Rect r, bool special) {
*********************************************************/ *********************************************************/
void ThemeEngine::addDrawStep(const Common::String &drawDataId, Graphics::DrawStep step) { void ThemeEngine::addDrawStep(const Common::String &drawDataId, Graphics::DrawStep step) {
DrawData id = getDrawDataId(drawDataId); DrawData id = getDrawDataId(drawDataId);
assert(_widgets[id] != 0); assert(_widgets[id] != 0);
_widgets[id]->_steps.push_back(step); _widgets[id]->_steps.push_back(step);
} }
@ -413,25 +413,25 @@ bool ThemeEngine::addTextData(const Common::String &drawDataId, const Common::St
if (id == -1 || textId == -1 || !_widgets[id]) if (id == -1 || textId == -1 || !_widgets[id])
return false; return false;
_widgets[id]->_textDataId = textId; _widgets[id]->_textDataId = textId;
_widgets[id]->_textAlignH = alignH; _widgets[id]->_textAlignH = alignH;
_widgets[id]->_textAlignV = alignV; _widgets[id]->_textAlignV = alignV;
return true; return true;
} }
bool ThemeEngine::addFont(const Common::String &fontId, const Common::String &file, int r, int g, int b) { bool ThemeEngine::addFont(const Common::String &fontId, const Common::String &file, int r, int g, int b) {
TextData textId = getTextDataId(fontId); TextData textId = getTextDataId(fontId);
if (textId == -1) if (textId == -1)
return false; return false;
if (_texts[textId] != 0) if (_texts[textId] != 0)
delete _texts[textId]; delete _texts[textId];
_texts[textId] = new TextDrawData; _texts[textId] = new TextDrawData;
if (file == "default") { if (file == "default") {
_texts[textId]->_fontPtr = _font; _texts[textId]->_fontPtr = _font;
} else { } else {
@ -439,29 +439,29 @@ bool ThemeEngine::addFont(const Common::String &fontId, const Common::String &fi
if (!_texts[textId]->_fontPtr) { if (!_texts[textId]->_fontPtr) {
_texts[textId]->_fontPtr = loadFont(file); _texts[textId]->_fontPtr = loadFont(file);
if (!_texts[textId]->_fontPtr) if (!_texts[textId]->_fontPtr)
error("Couldn't load %s font '%s'", fontId.c_str(), file.c_str()); error("Couldn't load %s font '%s'", fontId.c_str(), file.c_str());
FontMan.assignFontToName(file, _texts[textId]->_fontPtr); FontMan.assignFontToName(file, _texts[textId]->_fontPtr);
} }
} }
_texts[textId]->_color.r = r; _texts[textId]->_color.r = r;
_texts[textId]->_color.g = g; _texts[textId]->_color.g = g;
_texts[textId]->_color.b = b; _texts[textId]->_color.b = b;
return true; return true;
} }
bool ThemeEngine::addBitmap(const Common::String &filename) { bool ThemeEngine::addBitmap(const Common::String &filename) {
if (_bitmaps.contains(filename)) { if (_bitmaps.contains(filename)) {
ImageMan.unregisterSurface(filename); ImageMan.unregisterSurface(filename);
} }
ImageMan.registerSurface(filename, 0); ImageMan.registerSurface(filename, 0);
_bitmaps[filename] = ImageMan.getSurface(filename); _bitmaps[filename] = ImageMan.getSurface(filename);
return _bitmaps[filename] != 0; return _bitmaps[filename] != 0;
} }
@ -470,7 +470,7 @@ bool ThemeEngine::addDrawData(const Common::String &data, bool cached) {
if (data_id == -1) if (data_id == -1)
return false; return false;
if (_widgets[data_id] != 0) if (_widgets[data_id] != 0)
delete _widgets[data_id]; delete _widgets[data_id];
@ -498,7 +498,7 @@ bool ThemeEngine::loadTheme(Common::String fileName) {
error("Could not load default embedded theme"); error("Could not load default embedded theme");
} else if (!loadThemeXML(fileName)) { } else if (!loadThemeXML(fileName)) {
warning("Could not parse custom theme '%s'. Falling back to default theme", fileName.c_str()); warning("Could not parse custom theme '%s'. Falling back to default theme", fileName.c_str());
if (!loadDefaultXML()) // if we can't load the embedded theme, this is a complete failure if (!loadDefaultXML()) // if we can't load the embedded theme, this is a complete failure
error("Could not load default embedded theme"); error("Could not load default embedded theme");
} }
@ -513,13 +513,13 @@ bool ThemeEngine::loadTheme(Common::String fileName) {
if (_widgets[i]->_cached) {} if (_widgets[i]->_cached) {}
} }
} }
_themeOk = true; _themeOk = true;
return true; return true;
} }
bool ThemeEngine::loadDefaultXML() { bool ThemeEngine::loadDefaultXML() {
// The default XML theme is included on runtime from a pregenerated // The default XML theme is included on runtime from a pregenerated
// file inside the themes directory. // file inside the themes directory.
// Use the Python script "makedeftheme.py" to convert a normal XML theme // Use the Python script "makedeftheme.py" to convert a normal XML theme
@ -530,16 +530,16 @@ bool ThemeEngine::loadDefaultXML() {
const char *defaultXML = const char *defaultXML =
#include "themes/default.inc" #include "themes/default.inc"
; ;
if (!_parser->loadBuffer((const byte*)defaultXML, strlen(defaultXML), false)) if (!_parser->loadBuffer((const byte*)defaultXML, strlen(defaultXML), false))
return false; return false;
_themeName = "ScummVM Classic Theme (Builtin Version)"; _themeName = "ScummVM Classic Theme (Builtin Version)";
_themeFileName = "builtin"; _themeFileName = "builtin";
result = _parser->parse(); result = _parser->parse();
_parser->close(); _parser->close();
return result; return result;
#else #else
warning("The built-in theme is not enabled in the current build. Please load an external theme"); warning("The built-in theme is not enabled in the current build. Please load an external theme");
@ -550,7 +550,7 @@ bool ThemeEngine::loadDefaultXML() {
bool ThemeEngine::loadThemeXML(const Common::String &themeName) { bool ThemeEngine::loadThemeXML(const Common::String &themeName) {
assert(_parser); assert(_parser);
_themeName.clear(); _themeName.clear();
FSNode node(themeName); FSNode node(themeName);
if (!node.exists() || !node.isReadable()) if (!node.exists() || !node.isReadable())
return false; return false;
@ -568,7 +568,7 @@ bool ThemeEngine::loadThemeXML(const Common::String &themeName) {
warning("Failed to open Zip archive '%s'.", themeName.c_str()); warning("Failed to open Zip archive '%s'.", themeName.c_str());
return false; return false;
} }
#endif #endif
} else if (node.isDirectory()) { } else if (node.isDirectory()) {
archive = new Common::FSDirectory(node); archive = new Common::FSDirectory(node);
@ -608,14 +608,14 @@ bool ThemeEngine::loadThemeXML(const Common::String &themeName) {
_parser->close(); _parser->close();
return false; return false;
} }
if (_parser->parse() == false) { if (_parser->parse() == false) {
delete archive; delete archive;
warning("Failed to parse STX file '%s'", (*i)->getName().c_str()); warning("Failed to parse STX file '%s'", (*i)->getName().c_str());
_parser->close(); _parser->close();
return false; return false;
} }
_parser->close(); _parser->close();
} }
@ -632,19 +632,19 @@ bool ThemeEngine::loadThemeXML(const Common::String &themeName) {
void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic) { void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic) {
if (_widgets[type] == 0) if (_widgets[type] == 0)
return; return;
Common::Rect area = r; Common::Rect area = r;
area.clip(_screen->w, _screen->h); area.clip(_screen->w, _screen->h);
ThemeItemDrawData *q = new ThemeItemDrawData(this, _widgets[type], area, dynamic); ThemeItemDrawData *q = new ThemeItemDrawData(this, _widgets[type], area, dynamic);
if (_buffering) { if (_buffering) {
if (_widgets[type]->_buffer) { if (_widgets[type]->_buffer) {
_bufferQueue.push_back(q); _bufferQueue.push_back(q);
} else { } else {
if (kDrawDataDefaults[type].parent != kDDNone && kDrawDataDefaults[type].parent != type) if (kDrawDataDefaults[type].parent != kDDNone && kDrawDataDefaults[type].parent != type)
queueDD(kDrawDataDefaults[type].parent, r); queueDD(kDrawDataDefaults[type].parent, r);
_screenQueue.push_back(q); _screenQueue.push_back(q);
} }
} else { } else {
@ -655,7 +655,7 @@ void ThemeEngine::queueDD(DrawData type, const Common::Rect &r, uint32 dynamic)
void ThemeEngine::queueDDText(TextData type, const Common::Rect &r, const Common::String &text, bool restoreBg, void ThemeEngine::queueDDText(TextData type, const Common::Rect &r, const Common::String &text, bool restoreBg,
bool ellipsis, TextAlign alignH, TextAlignVertical alignV, int deltax) { bool ellipsis, TextAlign alignH, TextAlignVertical alignV, int deltax) {
if (_texts[type] == 0) if (_texts[type] == 0)
return; return;
@ -663,8 +663,8 @@ void ThemeEngine::queueDDText(TextData type, const Common::Rect &r, const Common
area.clip(_screen->w, _screen->h); area.clip(_screen->w, _screen->h);
ThemeItemTextData *q = new ThemeItemTextData(this, _texts[type], area, text, alignH, alignV, ellipsis, restoreBg, deltax); ThemeItemTextData *q = new ThemeItemTextData(this, _texts[type], area, text, alignH, alignV, ellipsis, restoreBg, deltax);
if (_buffering) { if (_buffering) {
_screenQueue.push_back(q); _screenQueue.push_back(q);
} else { } else {
q->drawSelf(true, false); q->drawSelf(true, false);
@ -678,7 +678,7 @@ void ThemeEngine::queueBitmap(const Graphics::Surface *bitmap, const Common::Rec
area.clip(_screen->w, _screen->h); area.clip(_screen->w, _screen->h);
ThemeItemBitmap *q = new ThemeItemBitmap(this, area, bitmap, alpha); ThemeItemBitmap *q = new ThemeItemBitmap(this, area, bitmap, alpha);
if (_buffering) { if (_buffering) {
_bufferQueue.push_back(q); _bufferQueue.push_back(q);
} else { } else {
@ -695,7 +695,7 @@ void ThemeEngine::queueBitmap(const Graphics::Surface *bitmap, const Common::Rec
void ThemeEngine::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) { void ThemeEngine::drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, uint16 hints) {
if (!ready()) if (!ready())
return; return;
DrawData dd = kDDButtonIdle; DrawData dd = kDDButtonIdle;
if (state == kStateEnabled) if (state == kStateEnabled)
@ -722,13 +722,13 @@ void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str,
Common::Rect r2 = r; Common::Rect r2 = r;
DrawData dd = kDDCheckboxDefault; DrawData dd = kDDCheckboxDefault;
if (checked) if (checked)
dd = kDDCheckboxSelected; dd = kDDCheckboxSelected;
if (state == kStateDisabled) if (state == kStateDisabled)
dd = kDDCheckboxDisabled; dd = kDDCheckboxDisabled;
TextData td = (state == kStateHighlight) ? kTextDataHover : getTextData(dd); TextData td = (state == kStateHighlight) ? kTextDataHover : getTextData(dd);
const int checkBoxSize = MIN((int)r.height(), getFontHeight()); const int checkBoxSize = MIN((int)r.height(), getFontHeight());
@ -736,19 +736,19 @@ void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str,
r2.right = r2.left + checkBoxSize; r2.right = r2.left + checkBoxSize;
queueDD(dd, r2); queueDD(dd, r2);
r2.left = r2.right + checkBoxSize; r2.left = r2.right + checkBoxSize;
r2.right = r.right; r2.right = r.right;
queueDDText(td, r2, str, false, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV); queueDDText(td, r2, str, false, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV);
} }
void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) { void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) {
if (!ready()) if (!ready())
return; return;
DrawData dd = kDDSliderFull; DrawData dd = kDDSliderFull;
if (state == kStateHighlight) if (state == kStateHighlight)
dd = kDDSliderHover; dd = kDDSliderHover;
else if (state == kStateDisabled) else if (state == kStateDisabled)
@ -759,7 +759,7 @@ void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo s
// r2.top++; r2.bottom--; r2.left++; r2.right--; // r2.top++; r2.bottom--; r2.left++; r2.right--;
drawWidgetBackground(r, 0, kWidgetBackgroundSlider, kStateEnabled); drawWidgetBackground(r, 0, kWidgetBackgroundSlider, kStateEnabled);
if (width > r.width() * 5 / 100) if (width > r.width() * 5 / 100)
queueDD(dd, r2); queueDD(dd, r2);
} }
@ -767,46 +767,46 @@ void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo s
void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) { void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) {
if (!ready()) if (!ready())
return; return;
queueDD(kDDScrollbarBase, r); queueDD(kDDScrollbarBase, r);
Common::Rect r2 = r; Common::Rect r2 = r;
const int buttonExtra = (r.width() * 120) / 100; const int buttonExtra = (r.width() * 120) / 100;
r2.bottom = r2.top + buttonExtra; r2.bottom = r2.top + buttonExtra;
queueDD(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleUp); queueDD(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleUp);
r2.translate(0, r.height() - r2.height()); r2.translate(0, r.height() - r2.height());
queueDD(scrollState == kScrollbarStateDown ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleDown); queueDD(scrollState == kScrollbarStateDown ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleDown);
r2 = r; r2 = r;
r2.left += 1; r2.left += 1;
r2.right -= 1; r2.right -= 1;
r2.top += sliderY; r2.top += sliderY;
r2.bottom = r2.top + sliderHeight - 1; r2.bottom = r2.top + sliderHeight - 1;
r2.top += r.width() / 5; r2.top += r.width() / 5;
r2.bottom -= r.width() / 5; r2.bottom -= r.width() / 5;
queueDD(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2); queueDD(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2);
} }
void ThemeEngine::drawDialogBackground(const Common::Rect &r, DialogBackground bgtype, WidgetStateInfo state) { void ThemeEngine::drawDialogBackground(const Common::Rect &r, DialogBackground bgtype, WidgetStateInfo state) {
if (!ready()) if (!ready())
return; return;
switch (bgtype) { switch (bgtype) {
case kDialogBackgroundMain: case kDialogBackgroundMain:
queueDD(kDDMainDialogBackground, r); queueDD(kDDMainDialogBackground, r);
break; break;
case kDialogBackgroundSpecial: case kDialogBackgroundSpecial:
queueDD(kDDSpecialColorBackground, r); queueDD(kDDSpecialColorBackground, r);
break; break;
case kDialogBackgroundPlain: case kDialogBackgroundPlain:
queueDD(kDDPlainColorBackground, r); queueDD(kDDPlainColorBackground, r);
break; break;
case kDialogBackgroundDefault: case kDialogBackgroundDefault:
queueDD(kDDDefaultBackground, r); queueDD(kDDDefaultBackground, r);
break; break;
@ -816,7 +816,7 @@ void ThemeEngine::drawDialogBackground(const Common::Rect &r, DialogBackground b
void ThemeEngine::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state) { void ThemeEngine::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state) {
if (!ready()) if (!ready())
return; return;
if (erase) { if (erase) {
restoreBackground(r); restoreBackground(r);
addDirtyRect(r); addDirtyRect(r);
@ -827,11 +827,11 @@ void ThemeEngine::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo s
void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align) { void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, TextAlign align) {
if (!ready()) if (!ready())
return; return;
DrawData dd = (state == kStateHighlight) ? kDDPopUpHover : kDDPopUpIdle; DrawData dd = (state == kStateHighlight) ? kDDPopUpHover : kDDPopUpIdle;
queueDD(dd, r); queueDD(dd, r);
if (!sel.empty()) { if (!sel.empty()) {
Common::Rect text(r.left, r.top, r.right - 16, r.bottom); Common::Rect text(r.left, r.top, r.right - 16, r.bottom);
queueDDText(getTextData(dd), text, sel, false, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV, deltax); queueDDText(getTextData(dd), text, sel, false, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV, deltax);
@ -841,27 +841,27 @@ void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &s
void ThemeEngine::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) { void ThemeEngine::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) {
if (!ready()) if (!ready())
return; return;
queueBitmap(&surface, r, themeTrans); queueBitmap(&surface, r, themeTrans);
} }
void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) { void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) {
if (!ready()) if (!ready())
return; return;
switch (background) { switch (background) {
case kWidgetBackgroundBorderSmall: case kWidgetBackgroundBorderSmall:
queueDD(kDDWidgetBackgroundSmall, r); queueDD(kDDWidgetBackgroundSmall, r);
break; break;
case kWidgetBackgroundEditText: case kWidgetBackgroundEditText:
queueDD(kDDWidgetBackgroundEditText, r); queueDD(kDDWidgetBackgroundEditText, r);
break; break;
case kWidgetBackgroundSlider: case kWidgetBackgroundSlider:
queueDD(kDDWidgetBackgroundSlider, r); queueDD(kDDWidgetBackgroundSlider, r);
break; break;
default: default:
queueDD(kDDWidgetBackgroundDefault, r); queueDD(kDDWidgetBackgroundDefault, r);
break; break;
@ -871,21 +871,21 @@ void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, Widg
void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) { void ThemeEngine::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()) if (!ready())
return; return;
const int tabOffset = 2; const int tabOffset = 2;
tabWidth -= tabOffset; tabWidth -= tabOffset;
queueDD(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight)); queueDD(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight));
for (int i = 0; i < (int)tabs.size(); ++i) { for (int i = 0; i < (int)tabs.size(); ++i) {
if (i == active) if (i == active)
continue; continue;
Common::Rect tabRect(r.left + i * (tabWidth + tabOffset), r.top, r.left + i * (tabWidth + tabOffset) + tabWidth, r.top + tabHeight); Common::Rect tabRect(r.left + i * (tabWidth + tabOffset), r.top, r.left + i * (tabWidth + tabOffset) + tabWidth, r.top + tabHeight);
queueDD(kDDTabInactive, tabRect); queueDD(kDDTabInactive, tabRect);
queueDDText(getTextData(kDDTabInactive), tabRect, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV); queueDDText(getTextData(kDDTabInactive), tabRect, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
} }
if (active >= 0) { if (active >= 0) {
Common::Rect tabRect(r.left + active * (tabWidth + tabOffset), r.top, r.left + active * (tabWidth + tabOffset) + tabWidth, r.top + tabHeight); Common::Rect tabRect(r.left + active * (tabWidth + tabOffset), r.top, r.left + active * (tabWidth + tabOffset) + tabWidth, r.top + tabHeight);
const uint16 tabLeft = active * (tabWidth + tabOffset); const uint16 tabLeft = active * (tabWidth + tabOffset);
@ -897,19 +897,19 @@ void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, co
void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) { void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font) {
if (!ready()) if (!ready())
return; return;
if (inverted) { if (inverted) {
queueDD(kDDTextSelectionBackground, r); queueDD(kDDTextSelectionBackground, r);
queueDDText(kTextDataInverted, r, str, false, useEllipsis, align, kTextAlignVCenter, deltax); queueDDText(kTextDataInverted, r, str, false, useEllipsis, align, kTextAlignVCenter, deltax);
return; return;
} }
switch (font) { switch (font) {
case kFontStyleNormal: case kFontStyleNormal:
queueDDText(kTextDataNormalFont, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax); queueDDText(kTextDataNormalFont, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax);
return; return;
default: default:
break; break;
} }
@ -918,11 +918,11 @@ void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, Wid
case kStateDisabled: case kStateDisabled:
queueDDText(kTextDataDisabled, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax); queueDDText(kTextDataDisabled, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax);
return; return;
case kStateHighlight: case kStateHighlight:
queueDDText(kTextDataHover, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax); queueDDText(kTextDataHover, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax);
return; return;
case kStateEnabled: case kStateEnabled:
queueDDText(kTextDataDefault, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax); queueDDText(kTextDataDefault, r, str, true, useEllipsis, align, kTextAlignVCenter, deltax);
return; return;
@ -937,7 +937,7 @@ void ThemeEngine::drawChar(const Common::Rect &r, byte ch, const Graphics::Font
charArea.clip(_screen->w, _screen->h); charArea.clip(_screen->w, _screen->h);
uint32 color = _system->RGBToColor(_texts[kTextDataDefault]->_color.r, _texts[kTextDataDefault]->_color.g, _texts[kTextDataDefault]->_color.b); uint32 color = _system->RGBToColor(_texts[kTextDataDefault]->_color.r, _texts[kTextDataDefault]->_color.g, _texts[kTextDataDefault]->_color.b);
restoreBackground(charArea); restoreBackground(charArea);
font->drawChar(_screen, ch, charArea.left, charArea.top, color); font->drawChar(_screen, ch, charArea.left, charArea.top, color);
addDirtyRect(charArea); addDirtyRect(charArea);
@ -959,28 +959,28 @@ void ThemeEngine::debugWidgetPosition(const char *name, const Common::Rect &r) {
void ThemeEngine::updateScreen() { void ThemeEngine::updateScreen() {
if (!_bufferQueue.empty()) { if (!_bufferQueue.empty()) {
_vectorRenderer->setSurface(_backBuffer); _vectorRenderer->setSurface(_backBuffer);
for (Common::List<ThemeItem*>::iterator q = _bufferQueue.begin(); q != _bufferQueue.end(); ++q) { for (Common::List<ThemeItem*>::iterator q = _bufferQueue.begin(); q != _bufferQueue.end(); ++q) {
(*q)->drawSelf(true, false); (*q)->drawSelf(true, false);
delete *q; delete *q;
} }
_vectorRenderer->setSurface(_screen); _vectorRenderer->setSurface(_screen);
_vectorRenderer->blitSurface(_backBuffer, Common::Rect(0, 0, _screen->w, _screen->h)); _vectorRenderer->blitSurface(_backBuffer, Common::Rect(0, 0, _screen->w, _screen->h));
_bufferQueue.clear(); _bufferQueue.clear();
} }
if (!_screenQueue.empty()) { if (!_screenQueue.empty()) {
_vectorRenderer->disableShadows(); _vectorRenderer->disableShadows();
for (Common::List<ThemeItem*>::iterator q = _screenQueue.begin(); q != _screenQueue.end(); ++q) { for (Common::List<ThemeItem*>::iterator q = _screenQueue.begin(); q != _screenQueue.end(); ++q) {
(*q)->drawSelf(true, false); (*q)->drawSelf(true, false);
delete *q; delete *q;
} }
_vectorRenderer->enableShadows(); _vectorRenderer->enableShadows();
_screenQueue.clear(); _screenQueue.clear();
} }
renderDirtyScreen(); renderDirtyScreen();
} }
@ -996,14 +996,14 @@ void ThemeEngine::renderDirtyScreen() {
_vectorRenderer->copyFrame(_system, *i); _vectorRenderer->copyFrame(_system, *i);
} }
_dirtyScreen.clear(); _dirtyScreen.clear();
} }
void ThemeEngine::openDialog(bool doBuffer, ShadingStyle style) { void ThemeEngine::openDialog(bool doBuffer, ShadingStyle style) {
if (doBuffer) if (doBuffer)
_buffering = true; _buffering = true;
if (style != kShadingNone) { if (style != kShadingNone) {
_vectorRenderer->applyScreenShading(style); _vectorRenderer->applyScreenShading(style);
addDirtyRect(Common::Rect(0, 0, _screen->w, _screen->h)); addDirtyRect(Common::Rect(0, 0, _screen->w, _screen->h));
@ -1023,12 +1023,12 @@ void ThemeEngine::setUpCursor() {
bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int hotspotY, int scale) { bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int hotspotY, int scale) {
if (!_system->hasFeature(OSystem::kFeatureCursorHasPalette)) if (!_system->hasFeature(OSystem::kFeatureCursorHasPalette))
return true; return true;
// Try to locate the specified file among all loaded bitmaps // Try to locate the specified file among all loaded bitmaps
const Surface *cursor = _bitmaps[filename]; const Surface *cursor = _bitmaps[filename];
if (!cursor) if (!cursor)
return false; return false;
// Set up the cursor parameters // Set up the cursor parameters
_cursorHotspotX = hotspotX; _cursorHotspotX = hotspotX;
_cursorHotspotY = hotspotY; _cursorHotspotY = hotspotY;

View file

@ -47,8 +47,8 @@ class ThemeEval;
struct TextDrawData { struct TextDrawData {
const Graphics::Font *_fontPtr; const Graphics::Font *_fontPtr;
struct { struct {
uint8 r, g, b; uint8 r, g, b;
} _color; } _color;
}; };
@ -56,13 +56,13 @@ struct TextDrawData {
struct WidgetDrawData { struct WidgetDrawData {
/** List of all the steps needed to draw this widget */ /** List of all the steps needed to draw this widget */
Common::List<Graphics::DrawStep> _steps; Common::List<Graphics::DrawStep> _steps;
int _textDataId; int _textDataId;
GUI::Theme::TextAlign _textAlignH; GUI::Theme::TextAlign _textAlignH;
GUI::Theme::TextAlignVertical _textAlignV; GUI::Theme::TextAlignVertical _textAlignV;
/** Extra space that the widget occupies when it's drawn. /** Extra space that the widget occupies when it's drawn.
E.g. when taking into account rounded corners, drop shadows, etc E.g. when taking into account rounded corners, drop shadows, etc
Used when restoring the widget background */ Used when restoring the widget background */
uint16 _backgroundOffset; uint16 _backgroundOffset;
@ -84,22 +84,22 @@ struct WidgetDrawData {
}; };
class ThemeItem { class ThemeItem {
public: public:
ThemeItem(ThemeEngine *engine, const Common::Rect &area) : ThemeItem(ThemeEngine *engine, const Common::Rect &area) :
_engine(engine), _area(area) {} _engine(engine), _area(area) {}
virtual ~ThemeItem() {} virtual ~ThemeItem() {}
virtual void drawSelf(bool doDraw, bool doRestore) = 0; virtual void drawSelf(bool doDraw, bool doRestore) = 0;
protected: protected:
Common::Rect _area;
ThemeEngine *_engine; ThemeEngine *_engine;
Common::Rect _area;
}; };
class ThemeItemDrawData : public ThemeItem { class ThemeItemDrawData : public ThemeItem {
public: public:
ThemeItemDrawData(ThemeEngine *engine, const WidgetDrawData *data, const Common::Rect &area, uint32 dynData) : ThemeItemDrawData(ThemeEngine *engine, const WidgetDrawData *data, const Common::Rect &area, uint32 dynData) :
ThemeItem(engine, area), _dynamicData(dynData), _data(data) {} ThemeItem(engine, area), _dynamicData(dynData), _data(data) {}
void drawSelf(bool draw, bool restore); void drawSelf(bool draw, bool restore);
@ -113,8 +113,8 @@ class ThemeItemTextData : public ThemeItem {
public: public:
ThemeItemTextData(ThemeEngine *engine, const TextDrawData *data, const Common::Rect &area, const Common::String &text, ThemeItemTextData(ThemeEngine *engine, const TextDrawData *data, const Common::Rect &area, const Common::String &text,
GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV, GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV,
bool ellipsis, bool restoreBg, int deltaX) : bool ellipsis, bool restoreBg, int deltaX) :
ThemeItem(engine, area), _data(data), _text(text), _alignH(alignH), _alignV(alignV), ThemeItem(engine, area), _data(data), _text(text), _alignH(alignH), _alignV(alignV),
_ellipsis(ellipsis), _restoreBg(restoreBg), _deltax(deltaX) {} _ellipsis(ellipsis), _restoreBg(restoreBg), _deltax(deltaX) {}
void drawSelf(bool draw, bool restore); void drawSelf(bool draw, bool restore);
@ -131,7 +131,7 @@ protected:
class ThemeItemBitmap : public ThemeItem { class ThemeItemBitmap : public ThemeItem {
public: public:
ThemeItemBitmap(ThemeEngine *engine, const Common::Rect &area, const Graphics::Surface *bitmap, bool alpha) : ThemeItemBitmap(ThemeEngine *engine, const Common::Rect &area, const Graphics::Surface *bitmap, bool alpha) :
ThemeItem(engine, area), _bitmap(bitmap), _alpha(alpha) {} ThemeItem(engine, area), _bitmap(bitmap), _alpha(alpha) {}
void drawSelf(bool draw, bool restore); void drawSelf(bool draw, bool restore);
@ -148,11 +148,11 @@ protected:
friend class GUI::Dialog; friend class GUI::Dialog;
friend class GUI::GuiObject; friend class GUI::GuiObject;
/** Sets whether backcaching is enabled */ /** Sets whether backcaching is enabled */
static const bool kEnableBackCaching = true; static const bool kEnableBackCaching = true;
/** /**
* DrawData sets enumeration. * DrawData sets enumeration.
* Each DD set corresponds to the actual looks * Each DD set corresponds to the actual looks
* of a widget in a given state. * of a widget in a given state.
@ -163,7 +163,7 @@ protected:
kDDPlainColorBackground, kDDPlainColorBackground,
kDDDefaultBackground, kDDDefaultBackground,
kDDTextSelectionBackground, kDDTextSelectionBackground,
kDDWidgetBackgroundDefault, kDDWidgetBackgroundDefault,
kDDWidgetBackgroundSmall, kDDWidgetBackgroundSmall,
kDDWidgetBackgroundEditText, kDDWidgetBackgroundEditText,
@ -193,13 +193,13 @@ protected:
kDDPopUpIdle, kDDPopUpIdle,
kDDPopUpHover, kDDPopUpHover,
kDDCaret, kDDCaret,
kDDSeparator, kDDSeparator,
kDrawDataMAX, kDrawDataMAX,
kDDNone = -1 kDDNone = -1
}; };
/** /**
* Default values for each DrawData item. * Default values for each DrawData item.
* @see kDrawDataDefaults[] for implementation. * @see kDrawDataDefaults[] for implementation.
@ -210,8 +210,8 @@ protected:
bool buffer; /** Sets whether this item is buffered on the backbuffer or drawn directly to the screen. */ bool buffer; /** Sets whether this item is buffered on the backbuffer or drawn directly to the screen. */
DrawData parent; /** Parent DrawData item, for items that overlay. E.g. kButtonIdle -> kButtonHover */ DrawData parent; /** Parent DrawData item, for items that overlay. E.g. kButtonIdle -> kButtonHover */
} kDrawDataDefaults[]; } kDrawDataDefaults[];
enum TextData { enum TextData {
kTextDataNone = -1, kTextDataNone = -1,
kTextDataDefault = 0, kTextDataDefault = 0,
@ -223,13 +223,13 @@ protected:
kTextDataNormalFont, kTextDataNormalFont,
kTextDataMAX kTextDataMAX
}; };
static const struct TextDataInfo { static const struct TextDataInfo {
TextData id; TextData id;
const char *name; const char *name;
} kTextDataDefaults[]; } kTextDataDefaults[];
public: public:
/** Graphics mode enumeration. /** Graphics mode enumeration.
* Each item represents a set of BPP and Renderer modes for a given * Each item represents a set of BPP and Renderer modes for a given
@ -243,7 +243,7 @@ public:
/** Constant value to expand dirty rectangles, to make sure they are fully copied */ /** Constant value to expand dirty rectangles, to make sure they are fully copied */
static const int kDirtyRectangleThreshold = 1; static const int kDirtyRectangleThreshold = 1;
struct Renderer { struct Renderer {
const char *name; const char *name;
const char *cfg; const char *cfg;
@ -257,13 +257,13 @@ public:
static GraphicsMode findMode(const Common::String &cfg); static GraphicsMode findMode(const Common::String &cfg);
static const char *findModeConfigName(GraphicsMode mode); static const char *findModeConfigName(GraphicsMode mode);
/** Default constructor */ /** Default constructor */
ThemeEngine(Common::String fileName, GraphicsMode mode); ThemeEngine(Common::String fileName, GraphicsMode mode);
/** Default destructor */ /** Default destructor */
~ThemeEngine(); ~ThemeEngine();
/** /**
* VIRTUAL METHODS * VIRTUAL METHODS
* This is the implementation of the GUI::Theme API to allow * This is the implementation of the GUI::Theme API to allow
@ -278,7 +278,7 @@ public:
void refresh(); void refresh();
void enable(); void enable();
void disable(); void disable();
/** /**
* Implementation of the GUI::Theme API. Called when a * Implementation of the GUI::Theme API. Called when a
* new dialog is opened. Note that the boolean parameter * new dialog is opened. Note that the boolean parameter
@ -289,7 +289,7 @@ public:
* until disabled. * until disabled.
*/ */
void openDialog(bool enableBuffering, ShadingStyle shading = kShadingNone); void openDialog(bool enableBuffering, ShadingStyle shading = kShadingNone);
/** /**
* The updateScreen() method is called every frame. * The updateScreen() method is called every frame.
* It processes all the drawing queues and then copies dirty rects * It processes all the drawing queues and then copies dirty rects
@ -297,86 +297,86 @@ public:
*/ */
void updateScreen(); void updateScreen();
/** Since the rendering pipeline changes, closing all dialogs causes no effect /** Since the rendering pipeline changes, closing all dialogs causes no effect
TODO: remove this from the original GUI::Theme API */ TODO: remove this from the original GUI::Theme API */
void closeAllDialogs() {} void closeAllDialogs() {}
/** Drawing area has been removed: it was too hackish. A workaround is on the works. /** Drawing area has been removed: it was too hackish. A workaround is on the works.
TODO: finish the workaround for the credits dialog TODO: finish the workaround for the credits dialog
TODO: remove this from the original GUI::Theme API */ TODO: remove this from the original GUI::Theme API */
void resetDrawArea() {} void resetDrawArea() {}
/** /**
* FONT MANAGEMENT METHODS * FONT MANAGEMENT METHODS
*/ */
TextData fontStyleToData(FontStyle font) const { TextData fontStyleToData(FontStyle font) const {
switch (font) { switch (font) {
case kFontStyleNormal: case kFontStyleNormal:
return kTextDataNormalFont; return kTextDataNormalFont;
default: default:
return kTextDataDefault; return kTextDataDefault;
} }
} }
const Graphics::Font *getFont(FontStyle font) const { return _texts[fontStyleToData(font)]->_fontPtr; } const Graphics::Font *getFont(FontStyle font) const { return _texts[fontStyleToData(font)]->_fontPtr; }
int getFontHeight(FontStyle font = kFontStyleBold) const { int getFontHeight(FontStyle font = kFontStyleBold) const {
return ready() ? _texts[fontStyleToData(font)]->_fontPtr->getFontHeight() : 0; return ready() ? _texts[fontStyleToData(font)]->_fontPtr->getFontHeight() : 0;
} }
int getStringWidth(const Common::String &str, FontStyle font) const { int getStringWidth(const Common::String &str, FontStyle font) const {
return ready() ? _texts[fontStyleToData(font)]->_fontPtr->getStringWidth(str) : 0; return ready() ? _texts[fontStyleToData(font)]->_fontPtr->getStringWidth(str) : 0;
} }
int getCharWidth(byte c, FontStyle font) const { int getCharWidth(byte c, FontStyle font) const {
return ready() ? _texts[fontStyleToData(font)]->_fontPtr->getCharWidth(c) : 0; return ready() ? _texts[fontStyleToData(font)]->_fontPtr->getCharWidth(c) : 0;
} }
/** /**
* WIDGET DRAWING METHODS * WIDGET DRAWING METHODS
*/ */
void drawWidgetBackground(const Common::Rect &r, uint16 hints, void drawWidgetBackground(const Common::Rect &r, uint16 hints,
WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled); WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled);
void drawButton(const Common::Rect &r, const Common::String &str, void drawButton(const Common::Rect &r, const Common::String &str,
WidgetStateInfo state = kStateEnabled, uint16 hints = 0); WidgetStateInfo state = kStateEnabled, uint16 hints = 0);
void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, void drawSurface(const Common::Rect &r, const Graphics::Surface &surface,
WidgetStateInfo state = kStateEnabled, int alpha = 256, bool themeTrans = false); WidgetStateInfo state = kStateEnabled, int alpha = 256, bool themeTrans = false);
void drawSlider(const Common::Rect &r, int width, void drawSlider(const Common::Rect &r, int width,
WidgetStateInfo state = kStateEnabled); WidgetStateInfo state = kStateEnabled);
void drawCheckbox(const Common::Rect &r, const Common::String &str, void drawCheckbox(const Common::Rect &r, const Common::String &str,
bool checked, WidgetStateInfo state = kStateEnabled); bool checked, WidgetStateInfo state = kStateEnabled);
void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, void drawTab(const Common::Rect &r, int tabHeight, int tabWidth,
const Common::Array<Common::String> &tabs, int active, uint16 hints, const Common::Array<Common::String> &tabs, int active, uint16 hints,
int titleVPad, WidgetStateInfo state = kStateEnabled); int titleVPad, WidgetStateInfo state = kStateEnabled);
void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight,
ScrollbarState, WidgetStateInfo state = kStateEnabled); ScrollbarState, WidgetStateInfo state = kStateEnabled);
void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, void drawPopUpWidget(const Common::Rect &r, const Common::String &sel,
int deltax, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignLeft); int deltax, WidgetStateInfo state = kStateEnabled, TextAlign align = kTextAlignLeft);
void drawCaret(const Common::Rect &r, bool erase, void drawCaret(const Common::Rect &r, bool erase,
WidgetStateInfo state = kStateEnabled); WidgetStateInfo state = kStateEnabled);
void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled); void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled);
void drawDialogBackground(const Common::Rect &r, DialogBackground type, WidgetStateInfo state); void drawDialogBackground(const Common::Rect &r, DialogBackground type, WidgetStateInfo state);
void drawText(const Common::Rect &r, const Common::String &str, void drawText(const Common::Rect &r, const Common::String &str,
WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font); WidgetStateInfo state, TextAlign align, bool inverted, int deltax, bool useEllipsis, FontStyle font);
void drawChar(const Common::Rect &r, byte ch, void drawChar(const Common::Rect &r, byte ch,
const Graphics::Font *font, WidgetStateInfo state); const Graphics::Font *font, WidgetStateInfo state);
/** /**
* Actual implementation of a Dirty Rect drawing routine. * Actual implementation of a Dirty Rect drawing routine.
* Dirty rectangles are queued on a list and are later merged/calculated * Dirty rectangles are queued on a list and are later merged/calculated
@ -409,7 +409,7 @@ public:
return kDDNone; return kDDNone;
} }
TextData getTextDataId(const Common::String &name) { TextData getTextDataId(const Common::String &name) {
for (int i = 0; i < kTextDataMAX; ++i) for (int i = 0; i < kTextDataMAX; ++i)
if (name.compareToIgnoreCase(kTextDataDefaults[i].name) == 0) if (name.compareToIgnoreCase(kTextDataDefaults[i].name) == 0)
@ -428,7 +428,7 @@ public:
* @param step The actual DrawStep struct to be added. * @param step The actual DrawStep struct to be added.
*/ */
void addDrawStep(const Common::String &drawDataId, Graphics::DrawStep step); void addDrawStep(const Common::String &drawDataId, Graphics::DrawStep step);
/** /**
* Interfacefor the ThemeParser class: Parsed DrawData sets are added via this function. * Interfacefor the ThemeParser class: Parsed DrawData sets are added via this function.
* The goal of the function is to initialize each DrawData set before their DrawSteps can * The goal of the function is to initialize each DrawData set before their DrawSteps can
@ -437,10 +437,10 @@ public:
* *
* @param data The representing DrawData name, as found on Theme Description XML files. * @param data The representing DrawData name, as found on Theme Description XML files.
* @param cached Whether this DD set will be cached beforehand. * @param cached Whether this DD set will be cached beforehand.
*/ */
bool addDrawData(const Common::String &data, bool cached); bool addDrawData(const Common::String &data, bool cached);
/** /**
* Interface for the ThemeParser class: Loads a font to use on the GUI from the given * Interface for the ThemeParser class: Loads a font to use on the GUI from the given
* filename. * filename.
@ -450,8 +450,8 @@ public:
* @param r, g, b Color of the font. * @param r, g, b Color of the font.
*/ */
bool addFont(const Common::String &fontName, const Common::String &file, int r, int g, int b); bool addFont(const Common::String &fontName, const Common::String &file, int r, int g, int b);
/** /**
* Interface for the ThemeParser class: Loads a bitmap file to use on the GUI. * Interface for the ThemeParser class: Loads a bitmap file to use on the GUI.
* The filename is also used as its identifier. * The filename is also used as its identifier.
@ -459,9 +459,9 @@ public:
* @param filename Name of the bitmap file. * @param filename Name of the bitmap file.
*/ */
bool addBitmap(const Common::String &filename); bool addBitmap(const Common::String &filename);
/** /**
* Adds a new TextStep from the ThemeParser. This will be deprecated/removed once the * Adds a new TextStep from the ThemeParser. This will be deprecated/removed once the
* new Font API is in place. * new Font API is in place.
*/ */
bool addTextData(const Common::String &drawDataId, const Common::String &textDataId, TextAlign alignH, TextAlignVertical alignV); bool addTextData(const Common::String &drawDataId, const Common::String &textDataId, TextAlign alignH, TextAlignVertical alignV);
@ -478,7 +478,7 @@ public:
/** Custom implementation of the GUI::Theme API, changed to use the XML parser. */ /** Custom implementation of the GUI::Theme API, changed to use the XML parser. */
bool loadTheme(Common::String themeName); bool loadTheme(Common::String themeName);
/** /**
* Changes the active graphics mode of the GUI; may be used to either * Changes the active graphics mode of the GUI; may be used to either
* initialize the GUI or to change the mode while the GUI is already running. * initialize the GUI or to change the mode while the GUI is already running.
@ -492,26 +492,26 @@ public:
*/ */
void finishBuffering() { _buffering = false; } void finishBuffering() { _buffering = false; }
void startBuffering() { _buffering = true; } void startBuffering() { _buffering = true; }
ThemeEval *getEvaluator() { return _themeEval; } ThemeEval *getEvaluator() { return _themeEval; }
VectorRenderer *renderer() { return _vectorRenderer; } VectorRenderer *renderer() { return _vectorRenderer; }
bool supportsImages() const { return true; } bool supportsImages() const { return true; }
bool ownCursor() const { return _useCursor; } bool ownCursor() const { return _useCursor; }
Graphics::Surface *getBitmap(const Common::String &name) { Graphics::Surface *getBitmap(const Common::String &name) {
return _bitmaps.contains(name) ? _bitmaps[name] : 0; return _bitmaps.contains(name) ? _bitmaps[name] : 0;
} }
const Graphics::Surface *getImageSurface(const kThemeImages n) const { const Graphics::Surface *getImageSurface(const kThemeImages n) const {
if (n == kImageLogo) if (n == kImageLogo)
return _bitmaps.contains("logo.bmp") ? _bitmaps["logo.bmp"] : 0; return _bitmaps.contains("logo.bmp") ? _bitmaps["logo.bmp"] : 0;
else if (n == kImageLogoSmall) else if (n == kImageLogoSmall)
return _bitmaps.contains("logo_small.bmp") ? _bitmaps["logo_small.bmp"] : 0; return _bitmaps.contains("logo_small.bmp") ? _bitmaps["logo_small.bmp"] : 0;
return 0; return 0;
} }
/** /**
* Interface for the Theme Parser: Creates a new cursor by loading the given * Interface for the Theme Parser: Creates a new cursor by loading the given
* bitmap and sets it as the active cursor. * bitmap and sets it as the active cursor.
@ -546,7 +546,7 @@ protected:
const Common::String &getThemeName() const { return _themeName; } const Common::String &getThemeName() const { return _themeName; }
const Common::String &getThemeFileName() const { return _themeFileName; } const Common::String &getThemeFileName() const { return _themeFileName; }
int getGraphicsMode() const { return _graphicsMode; } int getGraphicsMode() const { return _graphicsMode; }
/** /**
* Initializes the drawing screen surfaces, _screen and _backBuffer. * Initializes the drawing screen surfaces, _screen and _backBuffer.
* If the surfaces already exist, they are cleared and re-initialized. * If the surfaces already exist, they are cleared and re-initialized.
@ -565,7 +565,7 @@ protected:
* @returns true if the theme was successfully loaded. * @returns true if the theme was successfully loaded.
*/ */
bool loadThemeXML(const Common::String &themeName); bool loadThemeXML(const Common::String &themeName);
/** /**
* Loads the default theme file (the embedded XML file found * Loads the default theme file (the embedded XML file found
* in ThemeDefaultXML.cpp). * in ThemeDefaultXML.cpp).
@ -586,7 +586,7 @@ protected:
void screenChange() { void screenChange() {
error("Screen Changes are not supported yet. Fix this!"); error("Screen Changes are not supported yet. Fix this!");
} }
/** /**
* Actual Dirty Screen handling function. * Actual Dirty Screen handling function.
* Handles all the dirty squares in the list, merges and optimizes * Handles all the dirty squares in the list, merges and optimizes
@ -602,7 +602,7 @@ protected:
delete _vectorRenderer; delete _vectorRenderer;
_vectorRenderer = 0; _vectorRenderer = 0;
} }
/** /**
* Frees the Back buffer surface, only if it's available. * Frees the Back buffer surface, only if it's available.
*/ */
@ -624,11 +624,11 @@ protected:
_screen = 0; _screen = 0;
} }
} }
TextData getTextData(DrawData ddId) { TextData getTextData(DrawData ddId) {
return _widgets[ddId] ? (TextData)_widgets[ddId]->_textDataId : kTextDataNone; return _widgets[ddId] ? (TextData)_widgets[ddId]->_textDataId : kTextDataNone;
} }
/** /**
* Draws a cached widget directly on the screen. Currently deprecated. * Draws a cached widget directly on the screen. Currently deprecated.
* *
@ -636,7 +636,7 @@ protected:
* @param r Position on screen to draw the widget. * @param r Position on screen to draw the widget.
*/ */
void drawCached(DrawData type, const Common::Rect &r); void drawCached(DrawData type, const Common::Rect &r);
/** /**
* Calculates the background threshold offset of a given DrawData item. * Calculates the background threshold offset of a given DrawData item.
* After fully loading all DrawSteps of a DrawData item, this function must be * After fully loading all DrawSteps of a DrawData item, this function must be
@ -647,7 +647,7 @@ protected:
* @param type DrawData type of the widget. * @param type DrawData type of the widget.
*/ */
void calcBackgroundOffset(DrawData type); void calcBackgroundOffset(DrawData type);
/** /**
* Generates a DrawQueue item and enqueues it so it's drawn to the screen * Generates a DrawQueue item and enqueues it so it's drawn to the screen
* when the drawing queue is processed. * when the drawing queue is processed.
@ -663,13 +663,13 @@ protected:
void queueDDText(TextData type, const Common::Rect &r, const Common::String &text, bool restoreBg, void queueDDText(TextData type, const Common::Rect &r, const Common::String &text, bool restoreBg,
bool elipsis, TextAlign alignH = kTextAlignLeft, TextAlignVertical alignV = kTextAlignVTop, int deltax = 0); bool elipsis, TextAlign alignH = kTextAlignLeft, TextAlignVertical alignV = kTextAlignVTop, int deltax = 0);
void queueBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha); void queueBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha);
/** /**
* DEBUG: Draws a white square around the given position and writes the given next to it. * DEBUG: Draws a white square around the given position and writes the given next to it.
*/ */
void debugWidgetPosition(const char *name, const Common::Rect &r); void debugWidgetPosition(const char *name, const Common::Rect &r);
/** /**
* Default values from GUI::Theme * Default values from GUI::Theme
*/ */
@ -677,29 +677,29 @@ protected:
int getTabPadding() const { return 3; } int getTabPadding() const { return 3; }
OSystem *_system; /** Global system object. */ OSystem *_system; /** Global system object. */
/** Vector Renderer object, does the actual drawing on screen */ /** Vector Renderer object, does the actual drawing on screen */
Graphics::VectorRenderer *_vectorRenderer; Graphics::VectorRenderer *_vectorRenderer;
/** XML Parser, does the Theme parsing instead of the default parser */ /** XML Parser, does the Theme parsing instead of the default parser */
GUI::ThemeParser *_parser; GUI::ThemeParser *_parser;
/** Theme getEvaluator (changed from GUI::Eval to add functionality) */ /** Theme getEvaluator (changed from GUI::Eval to add functionality) */
GUI::ThemeEval *_themeEval; GUI::ThemeEval *_themeEval;
/** Main screen surface. This is blitted straight into the overlay. */ /** Main screen surface. This is blitted straight into the overlay. */
Graphics::Surface *_screen; Graphics::Surface *_screen;
/** Backbuffer surface. Stores previous states of the screen to blit back */ /** Backbuffer surface. Stores previous states of the screen to blit back */
Graphics::Surface *_backBuffer; Graphics::Surface *_backBuffer;
/** Sets whether the current drawing is being buffered (stored for later /** Sets whether the current drawing is being buffered (stored for later
processing) or drawn directly to the screen. */ processing) or drawn directly to the screen. */
bool _buffering; bool _buffering;
/** Bytes per pixel of the Active Drawing Surface (i.e. the screen) */ /** Bytes per pixel of the Active Drawing Surface (i.e. the screen) */
int _bytesPerPixel; int _bytesPerPixel;
/** Current graphics mode */ /** Current graphics mode */
GraphicsMode _graphicsMode; GraphicsMode _graphicsMode;
@ -710,18 +710,18 @@ protected:
/** Array of all the DrawData elements than can be drawn to the screen. /** Array of all the DrawData elements than can be drawn to the screen.
Must be full so the renderer can work. */ Must be full so the renderer can work. */
WidgetDrawData *_widgets[kDrawDataMAX]; WidgetDrawData *_widgets[kDrawDataMAX];
/** Array of all the text fonts that can be drawn. */ /** Array of all the text fonts that can be drawn. */
TextDrawData *_texts[kTextDataMAX]; TextDrawData *_texts[kTextDataMAX];
ImagesMap _bitmaps; ImagesMap _bitmaps;
/** List of all the dirty screens that must be blitted to the overlay. */ /** List of all the dirty screens that must be blitted to the overlay. */
Common::List<Common::Rect> _dirtyScreen; Common::List<Common::Rect> _dirtyScreen;
/** Queue with all the drawing that must be done to the Back Buffer */ /** Queue with all the drawing that must be done to the Back Buffer */
Common::List<ThemeItem*> _bufferQueue; Common::List<ThemeItem*> _bufferQueue;
/** Queue with all the drawing that must be done to the screen */ /** Queue with all the drawing that must be done to the screen */
Common::List<ThemeItem*> _screenQueue; Common::List<ThemeItem*> _screenQueue;
@ -731,10 +731,10 @@ protected:
Common::String _themeName; /** Name of the currently loaded theme */ Common::String _themeName; /** Name of the currently loaded theme */
Common::String _themeFileName; Common::String _themeFileName;
/** Custom Cursor Management */ /** Custom Cursor Management */
void setUpCursor(); void setUpCursor();
bool _useCursor; bool _useCursor;
int _cursorHotspotX, _cursorHotspotY; int _cursorHotspotX, _cursorHotspotY;
int _cursorTargetScale; int _cursorTargetScale;

View file

@ -37,30 +37,30 @@ public:
kLayoutHorizontal, kLayoutHorizontal,
kLayoutWidget kLayoutWidget
}; };
ThemeLayout(ThemeLayout *p, const Common::String &name) : ThemeLayout(ThemeLayout *p, const Common::String &name) :
_parent(p), _name(name), _x(0), _y(0), _w(-1), _h(-1), _parent(p), _name(name), _x(0), _y(0), _w(-1), _h(-1),
_paddingLeft(0), _paddingRight(0), _paddingTop(0), _paddingBottom(0), _paddingLeft(0), _paddingRight(0), _paddingTop(0), _paddingBottom(0),
_centered(false), _defaultW(-1), _defaultH(-1) { } _centered(false), _defaultW(-1), _defaultH(-1) { }
virtual ~ThemeLayout() { virtual ~ThemeLayout() {
for (uint i = 0; i < _children.size(); ++i) for (uint i = 0; i < _children.size(); ++i)
delete _children[i]; delete _children[i];
} }
virtual void reflowLayout() = 0; virtual void reflowLayout() = 0;
virtual void resetLayout() { _x = 0; _y = 0; _w = _defaultW; _h = _defaultH; } virtual void resetLayout() { _x = 0; _y = 0; _w = _defaultW; _h = _defaultH; }
void addChild(ThemeLayout *child) { _children.push_back(child); } void addChild(ThemeLayout *child) { _children.push_back(child); }
void setPadding(int8 left, int8 right, int8 top, int8 bottom) { void setPadding(int8 left, int8 right, int8 top, int8 bottom) {
_paddingLeft = left; _paddingLeft = left;
_paddingRight = right; _paddingRight = right;
_paddingTop = top; _paddingTop = top;
_paddingBottom = bottom; _paddingBottom = bottom;
} }
void setSpacing(int8 spacing) { void setSpacing(int8 spacing) {
_spacing = spacing; _spacing = spacing;
} }
@ -73,22 +73,22 @@ public:
int16 getY() { return _y; } int16 getY() { return _y; }
int16 getWidth() { return _w; } int16 getWidth() { return _w; }
int16 getHeight() { return _h; } int16 getHeight() { return _h; }
void setX(int newX) { void setX(int newX) {
_x += newX; _x += newX;
for (uint i = 0; i < _children.size(); ++i) for (uint i = 0; i < _children.size(); ++i)
_children[i]->setX(newX); _children[i]->setX(newX);
} }
void setY(int newY) { void setY(int newY) {
_y += newY; _y += newY;
for (uint i = 0; i < _children.size(); ++i) for (uint i = 0; i < _children.size(); ++i)
_children[i]->setY(newY); _children[i]->setY(newY);
} }
void setWidth(int16 width) { _w = width; } void setWidth(int16 width) { _w = width; }
void setHeight(int16 height) { _h = height; } void setHeight(int16 height) { _h = height; }
#ifdef LAYOUT_DEBUG_DIALOG #ifdef LAYOUT_DEBUG_DIALOG
void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) { void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
uint16 color = 0xFFFF; uint16 color = 0xFFFF;
@ -102,10 +102,10 @@ public:
_children[i]->debugDraw(screen, font); _children[i]->debugDraw(screen, font);
} }
#endif #endif
virtual LayoutType getLayoutType() = 0; virtual LayoutType getLayoutType() = 0;
virtual const char *getName() { return _name.c_str(); } virtual const char *getName() { return _name.c_str(); }
virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h); virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h);
virtual bool getDialogData(int16 &x, int16 &y, uint16 &w, uint16 &h) { virtual bool getDialogData(int16 &x, int16 &y, uint16 &w, uint16 &h) {
@ -114,19 +114,19 @@ public:
w = _w; h = _h; w = _w; h = _h;
return true; return true;
} }
virtual ThemeLayout *makeClone() = 0; virtual ThemeLayout *makeClone() = 0;
void importLayout(ThemeLayout *layout); void importLayout(ThemeLayout *layout);
protected: protected:
ThemeLayout *_parent;
Common::String _name;
int16 _x, _y, _w, _h; int16 _x, _y, _w, _h;
int16 _defaultW, _defaultH; int8 _paddingLeft, _paddingRight, _paddingTop, _paddingBottom;
int8 _paddingTop, _paddingBottom, _paddingLeft, _paddingRight;
int8 _spacing; int8 _spacing;
Common::Array<ThemeLayout*> _children; Common::Array<ThemeLayout*> _children;
ThemeLayout *_parent;
bool _centered; bool _centered;
Common::String _name; int16 _defaultW, _defaultH;
}; };
class ThemeLayoutMain : public ThemeLayout { class ThemeLayoutMain : public ThemeLayout {
@ -138,22 +138,22 @@ public:
_y = _defaultY = y; _y = _defaultY = y;
} }
void reflowLayout(); void reflowLayout();
void resetLayout() { void resetLayout() {
ThemeLayout::resetLayout(); ThemeLayout::resetLayout();
_x = _defaultX; _x = _defaultX;
_y = _defaultY; _y = _defaultY;
} }
const char *getName() { return "Global Layout"; } const char *getName() { return "Global Layout"; }
LayoutType getLayoutType() { return kLayoutMain; } LayoutType getLayoutType() { return kLayoutMain; }
ThemeLayout *makeClone() { assert(!"Do not copy Main Layouts!"); return 0; } ThemeLayout *makeClone() { assert(!"Do not copy Main Layouts!"); return 0; }
protected: protected:
int16 _defaultX; int16 _defaultX;
int16 _defaultY; int16 _defaultY;
}; };
class ThemeLayoutVertical : public ThemeLayout { class ThemeLayoutVertical : public ThemeLayout {
public: public:
@ -162,40 +162,40 @@ public:
_spacing = spacing; _spacing = spacing;
_centered = center; _centered = center;
} }
void reflowLayout(); void reflowLayout();
const char *getName() { return "Vertical Layout"; } const char *getName() { return "Vertical Layout"; }
LayoutType getLayoutType() { return kLayoutVertical; } LayoutType getLayoutType() { return kLayoutVertical; }
ThemeLayout *makeClone() { ThemeLayout *makeClone() {
ThemeLayoutVertical *n = new ThemeLayoutVertical(*this); ThemeLayoutVertical *n = new ThemeLayoutVertical(*this);
for (uint i = 0; i < n->_children.size(); ++i) for (uint i = 0; i < n->_children.size(); ++i)
n->_children[i] = n->_children[i]->makeClone(); n->_children[i] = n->_children[i]->makeClone();
return n; return n;
} }
}; };
class ThemeLayoutHorizontal : public ThemeLayout { class ThemeLayoutHorizontal : public ThemeLayout {
public: public:
ThemeLayoutHorizontal(ThemeLayout *p, int spacing, bool center) : ThemeLayoutHorizontal(ThemeLayout *p, int spacing, bool center) :
ThemeLayout(p, "") { ThemeLayout(p, "") {
_spacing = spacing; _spacing = spacing;
_centered = center; _centered = center;
} }
void reflowLayout(); void reflowLayout();
const char *getName() { return "Horizontal Layout"; } const char *getName() { return "Horizontal Layout"; }
LayoutType getLayoutType() { return kLayoutHorizontal; } LayoutType getLayoutType() { return kLayoutHorizontal; }
ThemeLayout *makeClone() { ThemeLayout *makeClone() {
ThemeLayoutHorizontal *n = new ThemeLayoutHorizontal(*this); ThemeLayoutHorizontal *n = new ThemeLayoutHorizontal(*this);
for (uint i = 0; i < n->_children.size(); ++ i) for (uint i = 0; i < n->_children.size(); ++ i)
n->_children[i] = n->_children[i]->makeClone(); n->_children[i] = n->_children[i]->makeClone();
return n; return n;
} }
}; };
@ -206,11 +206,11 @@ public:
_w = _defaultW = w; _w = _defaultW = w;
_h = _defaultH = h; _h = _defaultH = h;
} }
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h); bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h);
void reflowLayout() {} void reflowLayout() {}
LayoutType getLayoutType() { return kLayoutWidget; } LayoutType getLayoutType() { return kLayoutWidget; }
ThemeLayout *makeClone() { return new ThemeLayoutWidget(*this); } ThemeLayout *makeClone() { return new ThemeLayoutWidget(*this); }
}; };
@ -225,12 +225,12 @@ public:
_h = _defaultH = size; _h = _defaultH = size;
} }
} }
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) { return false; } bool getWidgetData(const Common::String &name, int16 &x, int16 &y, uint16 &w, uint16 &h) { return false; }
void reflowLayout() {} void reflowLayout() {}
LayoutType getLayoutType() { return kLayoutWidget; } LayoutType getLayoutType() { return kLayoutWidget; }
const char *getName() { return "SPACE"; } const char *getName() { return "SPACE"; }
ThemeLayout *makeClone() { return new ThemeLayoutSpacing(*this); } ThemeLayout *makeClone() { return new ThemeLayoutSpacing(*this); }
}; };