diff options
author | Vicent Marti | 2008-08-08 10:37:58 +0000 |
---|---|---|
committer | Vicent Marti | 2008-08-08 10:37:58 +0000 |
commit | 1ea3301a8a358e9da9be644b8de54a9fec952dce (patch) | |
tree | 7069c4ca807da2f98b464d78c4424c481e96c2c2 | |
parent | 39c28e434beb94addd9788e7ab7c4dd9d66ca12e (diff) | |
download | scummvm-rg350-1ea3301a8a358e9da9be644b8de54a9fec952dce.tar.gz scummvm-rg350-1ea3301a8a358e9da9be644b8de54a9fec952dce.tar.bz2 scummvm-rg350-1ea3301a8a358e9da9be644b8de54a9fec952dce.zip |
SCUMM save/load dialog.
Expanded documentation.
Added support for sub-blitting in the vector renderer.
svn-id: r33697
-rw-r--r-- | engines/scumm/dialogs.cpp | 40 | ||||
-rw-r--r-- | graphics/VectorRenderer.h | 90 | ||||
-rw-r--r-- | gui/ThemeEval.cpp | 17 | ||||
-rw-r--r-- | gui/ThemeEval.h | 40 | ||||
-rw-r--r-- | gui/ThemeRenderer.cpp | 11 | ||||
-rw-r--r-- | gui/themes/default.inc | 23 | ||||
-rw-r--r-- | gui/themes/modern.stx | 24 |
7 files changed, 204 insertions, 41 deletions
diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 51c012d46d..bdb7118f56 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -39,6 +39,7 @@ #include "gui/eval.h" #include "gui/newgui.h" #include "gui/ListWidget.h" +#include "gui/ThemeEval.h" #include "scumm/dialogs.h" #include "scumm/sound.h" @@ -233,14 +234,14 @@ enum { }; SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode, ScummEngine *engine) - : Dialog("scummsaveload"), _saveMode(saveMode), _list(0), _chooseButton(0), _gfxWidget(0), _vm(engine) { + : Dialog("ScummSaveLoad"), _saveMode(saveMode), _list(0), _chooseButton(0), _gfxWidget(0), _vm(engine) { _drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR; - new StaticTextWidget(this, "scummsaveload_title", title); + new StaticTextWidget(this, "ScummSaveload.Title", title); // Add choice list - _list = new GUI::ListWidget(this, "scummsaveload_list"); + _list = new GUI::ListWidget(this, "ScummSaveLoad.List"); _list->setEditable(saveMode); _list->setNumberingMode(saveMode ? GUI::kListNumberingOne : GUI::kListNumberingZero); @@ -254,8 +255,8 @@ SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, _playtime = new StaticTextWidget(this, 0, 0, 10, 10, "No playtime saved", kTextAlignCenter); // Buttons - new GUI::ButtonWidget(this, "scummsaveload_cancel", "Cancel", kCloseCmd, 0); - _chooseButton = new GUI::ButtonWidget(this, "scummsaveload_choose", buttonLabel, kChooseCmd, 0); + new GUI::ButtonWidget(this, "ScummSaveLoad.Cancel", "Cancel", kCloseCmd, 0); + _chooseButton = new GUI::ButtonWidget(this, "ScummSaveLoad.Choose", buttonLabel, kChooseCmd, 0); _chooseButton->setEnabled(false); } @@ -318,16 +319,21 @@ void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 da void SaveLoadChooser::reflowLayout() { if (g_gui.evaluator()->getVar("scummsaveload_extinfo.visible") == 1) { - int thumbX = g_gui.evaluator()->getVar("scummsaveload_thumbnail.x"); - int thumbY = g_gui.evaluator()->getVar("scummsaveload_thumbnail.y"); - int hPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.hPad"); - int vPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.vPad"); + int16 x, y; + uint16 w, h; + + if (!g_gui.xmlEval()->getWidgetData("ScummSaveLoad.Thumbnail", x, y, w, h)) + error("Error when loading position data for Save/Load Thumbnails."); + + _container->resize(x, y, w, h); + + int thumbW = kThumbnailWidth; int thumbH = ((g_system->getHeight() % 200 && g_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1); - - _container->resize(thumbX - hPad, thumbY - vPad, kThumbnailWidth + hPad * 2, thumbH + vPad * 2 + kLineHeight * 4); - - // Add the thumbnail display - _gfxWidget->resize(thumbX, thumbY, kThumbnailWidth, thumbH); + int thumbX = x + (w >> 1) - (thumbW >> 1); + int thumbY = y + kLineHeight; + + _container->resize(x, y, w, h); + _gfxWidget->resize(thumbX, thumbY, thumbW, thumbH); int height = thumbY + thumbH + kLineHeight; @@ -347,9 +353,9 @@ void SaveLoadChooser::reflowLayout() { _time->clearFlags(GUI::WIDGET_INVISIBLE); _playtime->clearFlags(GUI::WIDGET_INVISIBLE); - _fillR = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillR"); - _fillG = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillG"); - _fillB = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillB"); + _fillR = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillR"); + _fillG = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillG"); + _fillB = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillB"); updateInfos(false); } else { _container->setFlags(GUI::WIDGET_INVISIBLE); diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 2c5530c07c..a2352762a7 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -349,8 +349,16 @@ public: _gradientFactor = factor; } + /** + * Translates the position data inside a DrawStep into actual + * screen drawing positions. + */ void stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h); + /** + * Translates the radius data inside a drawstep into the real radius + * for the shape. Used for automatic radius calculations. + */ int stepGetRadius(const DrawStep &step, const Common::Rect &area); /** @@ -417,34 +425,90 @@ public: virtual void drawStep(const Common::Rect &area, const DrawStep &step, uint32 extra = 0); /** - * Copies the current surface to the system overlay + * Copies the part of the current frame to the system overlay. * * @param sys Pointer to the global System class + * @param r Zone of the surface to copy into the overlay. */ virtual void copyFrame(OSystem *sys, const Common::Rect &r) = 0; + + /** + * Copies the current surface to the system overlay + * + * @param sys Pointer to the global System class + */ virtual void copyWholeFrame(OSystem *sys) = 0; /** * Blits a given graphics surface on top of the current drawing surface. * + * Note that the source surface and the active + * 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 + * "r" on the current surface. + * + * If you wish to blit a smaller surface into the active drawing area, use + * VectorRenderer::blitSubSurface(). + * * @param source Surface to blit into the drawing surface. * @param r Position in the active drawing surface to do the blitting. */ - virtual void blitSurface(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. + * + * Note that the given surface is expected to be smaller than the + * active drawing surface, hence the WHOLE source surface will be + * blitted into the active surface, at the position specified by "r". + */ + virtual void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) = 0; + /** + * Draws a string into the screen. Wrapper for the Graphics::Font string drawing + * method. + */ virtual void drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV, int deltax) = 0; + /** + * Allows to temporarily enable/disable all shadows drawing. + * i.e. for performance issues, blitting, etc + */ virtual void disableShadows() { _disableShadows = true; } virtual void enableShadows() { _disableShadows = false; } + /** + * Applies a convolution matrix on the given surface area. + * Call applyConvolutionMatrix() instead if you want to use + * the embeded matrixes (blur/sharpen masks, bevels, etc). + * + * @param area Area in which the convolution matrix will be applied. + * @param filter Convolution matrix (3X3) + * @param filterDiv Divisor for the convolution matrix. + * Make sure this equals the total sum of the elements + * of the matrix or brightness data will be distorted. + * @param offset Offset on the convolution area. + */ 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. + * + * WARNING: Because of performance issues, this is currently disabled on all renderers. + * + * @param id Id of the convolution data set (see VectorRenderer::ConvolutionData) + * @param area Area in which the convolution effect will be applied. + */ virtual void applyConvolutionMatrix(const ConvolutionData id, const Common::Rect &area) { #ifdef ENABLE_CONVOLUTIONS areaConvolution(area, _convolutionData[id].matrix, _convolutionData[id].divisor, _convolutionData[id].offset); #endif } + /** + * Applies a whole-screen shading effect, used before opening a new dialog. + * Currently supports screen dimmings and luminance (b&w). + */ virtual void applyScreenShading(GUI::Theme::ShadingStyle) = 0; protected: @@ -453,7 +517,7 @@ protected: FillMode _fillMode; /** Defines in which way (if any) are filled the drawn shapes */ int _shadowOffset; /** offset for drawn shadows */ - int _bevel; + int _bevel; /** amount of fake bevel */ bool _disableShadows; /** Disables temporarily shadow drawing for overlayed images. */ int _strokeWidth; /** Width of the stroke of all drawn shapes */ uint32 _dynamicData; /** Dynamic data from the GUI Theme that modifies the drawing of the current shape */ @@ -463,7 +527,7 @@ protected: static const ConvolutionDataSet _convolutionData[kConvolutionMAX]; - static const int _dimPercentValue = 256 * 50 / 100; + static const int _dimPercentValue = 256 * 50 / 100; /** default value for screen dimming (50%) */ }; /** @@ -607,7 +671,7 @@ public: /** * @see VectorRenderer::blitSurface() */ - virtual void blitSurface(Graphics::Surface *source, const Common::Rect &r) { + virtual void blitSurface(const Graphics::Surface *source, const Common::Rect &r) { PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(r.left, r.top); PixelType *src_ptr = (PixelType *)source->getBasePtr(r.left, r.top); @@ -623,6 +687,22 @@ public: } } + virtual void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) { + PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(r.left, r.top); + PixelType *src_ptr = (PixelType *)source->getBasePtr(0, 0); + + int dst_pitch = surfacePitch(); + int src_pitch = source->pitch / source->bytesPerPixel; + + int h = r.height(), w = r.width(); + + while (h--) { + colorCopy(src_ptr, dst_ptr, w); + dst_ptr += dst_pitch; + src_ptr += src_pitch; + } + } + virtual void applyScreenShading(GUI::Theme::ShadingStyle shadingStyle) { int pixels = _activeSurface->w * _activeSurface->h; PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(0, 0); diff --git a/gui/ThemeEval.cpp b/gui/ThemeEval.cpp index 426ca4fc40..b452e1c2f5 100644 --- a/gui/ThemeEval.cpp +++ b/gui/ThemeEval.cpp @@ -29,6 +29,7 @@ #include "common/hashmap.h" #include "common/hash-str.h" #include "common/xmlparser.h" +#include "graphics/scaler.h" #include "gui/ThemeRenderer.h" #include "gui/ThemeParser.h" @@ -160,6 +161,22 @@ void ThemeLayoutHorizontal::reflowLayout() { } } +void ThemeEval::buildBuiltinVars() { + _builtin["kThumbnailWidth"] = kThumbnailWidth; + _builtin["kThumbnailHeight"] = kThumbnailHeight1; + _builtin["kThumbnailHeight2"] = kThumbnailHeight2; + + _builtin["kButtonWidth"] = GUI::kButtonWidth; + _builtin["kButtonHeight"] = GUI::kButtonHeight; + _builtin["kSliderWidth"] = GUI::kSliderWidth; + _builtin["kSliderHeight"] = GUI::kSliderHeight; + _builtin["kBigButtonWidth"] = GUI::kBigButtonWidth; + _builtin["kBigButtonHeight"] = GUI::kBigButtonHeight; + _builtin["kBigSliderWidth"] = GUI::kBigSliderWidth; + _builtin["kBigSliderWidth"] = GUI::kBigSliderWidth; + _builtin["kBigSliderHeight"] = GUI::kBigSliderHeight; +} + void ThemeEval::addWidget(const Common::String &name, int w, int h, const Common::String &type, bool enabled) { int typeW = -1; diff --git a/gui/ThemeEval.h b/gui/ThemeEval.h index ba6e3381ac..7df4d60aa4 100644 --- a/gui/ThemeEval.h +++ b/gui/ThemeEval.h @@ -91,8 +91,7 @@ public: width += p->_paddingRight + p->_paddingLeft; if (p->getLayoutType() == kLayoutHorizontal) { for (uint i = 0; i < p->_children.size(); ++i) - if (p->_children[i]->getLayoutType() == kLayoutWidget) - width += p->_children[i]->getHeight() + p->_spacing; + width += p->_children[i]->getHeight() + p->_spacing; } p = p->_parent; } @@ -108,8 +107,7 @@ public: height += p->_paddingBottom + p->_paddingTop; if (p->getLayoutType() == kLayoutVertical) { for (uint i = 0; i < p->_children.size(); ++i) - if (p->_children[i]->getLayoutType() == kLayoutWidget) - height += p->_children[i]->getHeight() + p->_spacing; + height += p->_children[i]->getHeight() + p->_spacing; } p = p->_parent; } @@ -304,25 +302,37 @@ class ThemeEval { typedef Common::HashMap<Common::String, ThemeLayout*> LayoutsMap; public: - ThemeEval() {} + ThemeEval() { + buildBuiltinVars(); + } ~ThemeEval() {} + void buildBuiltinVars(); + int getVar(const Common::String &s) { - if (!_vars.contains(s)) { - error("CRITICAL: Missing variable: '%s'", s.c_str()); - return -13375; //EVAL_UNDEF_VAR - } - - return _vars[s]; + if (_vars.contains(s)) + return _vars[s]; + + if (_builtin.contains(s)) + return _builtin[s]; + + error("CRITICAL: Missing variable: '%s'", s.c_str()); + return -13375; //EVAL_UNDEF_VAR } int getVar(const Common::String &s, int def) { - return (_vars.contains(s)) ? _vars[s] : def; + if (_vars.contains(s)) + return _vars[s]; + + if (_builtin.contains(s)) + return _builtin[s]; + + return def; } void setVar(const String &name, int val) { _vars[name] = val; } - bool hasVar(const Common::String &name) { return _vars.contains(name); } + bool hasVar(const Common::String &name) { return _vars.contains(name) || _builtin.contains(name); } void addDialog(const Common::String &name, const Common::String &overlays, bool enabled = true); void addLayout(ThemeLayout::LayoutType type, int spacing, bool reverse, bool center = false); @@ -365,12 +375,14 @@ public: } void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) { - _layouts["Dialog.ScummConfig"]->debugDraw(screen, font); + _layouts["Dialog.ScummSaveLoad"]->debugDraw(screen, font); // _layouts["Dialog.GameOptions_Graphics"]->debugDraw(screen, font); } private: VariablesMap _vars; + VariablesMap _builtin; + LayoutsMap _layouts; Common::Stack<ThemeLayout*> _curLayout; Common::String _curDialog; diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp index 49e0d3bb35..6244895719 100644 --- a/gui/ThemeRenderer.cpp +++ b/gui/ThemeRenderer.cpp @@ -592,8 +592,9 @@ void ThemeRenderer::drawPopUpWidget(const Common::Rect &r, const Common::String void ThemeRenderer::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) { if (!ready()) return; - - debugWidgetPosition("Surface", r); + + _vectorRenderer->blitSubSurface(&surface, r); + addDirtyRect(r); } void ThemeRenderer::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) { @@ -718,9 +719,9 @@ void ThemeRenderer::updateScreen() { renderDirtyScreen(); -// _vectorRenderer->fillSurface(); -// themeEval()->debugDraw(_screen, _font); -// _vectorRenderer->copyWholeFrame(_system); + // _vectorRenderer->fillSurface(); + // themeEval()->debugDraw(_screen, _font); + // _vectorRenderer->copyWholeFrame(_system); } void ThemeRenderer::renderDirtyScreen() { diff --git a/gui/themes/default.inc b/gui/themes/default.inc index 1206ffc914..4c1e57a52c 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -858,4 +858,27 @@ "</layout> " "</layout> " "</dialog> " +"<dialog name = 'ScummSaveLoad' overlays = 'screen'> " +"<layout type = 'vertical' padding = '8, 8, 8, 8' center = 'true' direction = 'bottom2top'> " +"<layout type = 'horizontal' padding = '0, 0, 16, 0' direction = 'right2left'> " +"<widget name = 'Choose' " +"type = 'Button' " +"/> " +"<widget name = 'Cancel' " +"type = 'Button' " +"/> " +"<space/> " +"</layout> " +"<layout type = 'horizontal' padding = '0, 0, 0, 0' direction = 'right2left' spacing = '16'> " +"<layout type = 'vertical' padding = '0, 0, 0, 0'> " +"<widget name = 'Thumbnail' " +"width = '180' " +"height = '200' " +"/> " +"<space/> " +"</layout> " +"<widget name = 'List' /> " +"</layout> " +"</layout> " +"</dialog> " "</layout_info> " diff --git a/gui/themes/modern.stx b/gui/themes/modern.stx index 26c0fcdfff..a0a4bfad0a 100644 --- a/gui/themes/modern.stx +++ b/gui/themes/modern.stx @@ -938,4 +938,28 @@ </layout> </layout> </dialog> + + <dialog name = 'ScummSaveLoad' overlays = 'screen'> + <layout type = 'vertical' padding = '8, 8, 8, 8' center = 'true' direction = 'bottom2top'> + <layout type = 'horizontal' padding = '0, 0, 16, 0' direction = 'right2left'> + <widget name = 'Choose' + type = 'Button' + /> + <widget name = 'Cancel' + type = 'Button' + /> + <space/> + </layout> + <layout type = 'horizontal' padding = '0, 0, 0, 0' direction = 'right2left' spacing = '16'> + <layout type = 'vertical' padding = '0, 0, 0, 0'> + <widget name = 'Thumbnail' + width = '180' + height = '200' + /> + <space/> + </layout> + <widget name = 'List' /> + </layout> + </layout> + </dialog> </layout_info>
\ No newline at end of file |