GUI: Load SVGs from theme
This commit is contained in:
parent
55ae2e4367
commit
4a58f08a37
2 changed files with 30 additions and 2 deletions
|
@ -33,6 +33,7 @@
|
||||||
#include "graphics/cursorman.h"
|
#include "graphics/cursorman.h"
|
||||||
#include "graphics/fontman.h"
|
#include "graphics/fontman.h"
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
|
#include "graphics/svg.h"
|
||||||
#include "graphics/transparent_surface.h"
|
#include "graphics/transparent_surface.h"
|
||||||
#include "graphics/VectorRenderer.h"
|
#include "graphics/VectorRenderer.h"
|
||||||
#include "graphics/fonts/bdf.h"
|
#include "graphics/fonts/bdf.h"
|
||||||
|
@ -265,6 +266,14 @@ ThemeEngine::~ThemeEngine() {
|
||||||
}
|
}
|
||||||
_abitmaps.clear();
|
_abitmaps.clear();
|
||||||
|
|
||||||
|
for (SVGMap::iterator i = _svgs.begin(); i != _svgs.end(); ++i) {
|
||||||
|
Graphics::SVGBitmap *svg = i->_value;
|
||||||
|
if (svg) {
|
||||||
|
delete svg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_svgs.clear();
|
||||||
|
|
||||||
delete _parser;
|
delete _parser;
|
||||||
delete _themeEval;
|
delete _themeEval;
|
||||||
delete[] _cursor;
|
delete[] _cursor;
|
||||||
|
@ -689,7 +698,7 @@ bool ThemeEngine::addTextColor(TextColor colorId, int r, int g, int b) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThemeEngine::addBitmap(const Common::String &filename) {
|
bool ThemeEngine::addBitmap(const Common::String &filename, const Common::String &scalablefile) {
|
||||||
// Nothing has to be done if the bitmap already has been loaded.
|
// Nothing has to be done if the bitmap already has been loaded.
|
||||||
Graphics::Surface *surf = _bitmaps[filename];
|
Graphics::Surface *surf = _bitmaps[filename];
|
||||||
if (surf) {
|
if (surf) {
|
||||||
|
@ -745,6 +754,21 @@ bool ThemeEngine::addBitmap(const Common::String &filename) {
|
||||||
surf = srcSurface->convertTo(_overlayFormat);
|
surf = srcSurface->convertTo(_overlayFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!scalablefile.empty()) {
|
||||||
|
Graphics::SVGBitmap *image = nullptr;
|
||||||
|
Common::ArchiveMemberList members;
|
||||||
|
_themeFiles.listMatchingMembers(members, filename);
|
||||||
|
for (Common::ArchiveMemberList::const_iterator i = members.begin(), end = members.end(); i != end; ++i) {
|
||||||
|
Common::SeekableReadStream *stream = (*i)->createReadStream();
|
||||||
|
if (stream) {
|
||||||
|
image = new Graphics::SVGBitmap(stream);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_svgs[filename] = image;
|
||||||
|
}
|
||||||
|
|
||||||
if (_scaleFactor != 1.0) {
|
if (_scaleFactor != 1.0) {
|
||||||
Graphics::Surface *tmp2 = surf->scale(surf->w * _scaleFactor, surf->h * _scaleFactor, false);
|
Graphics::Surface *tmp2 = surf->scale(surf->w * _scaleFactor, surf->h * _scaleFactor, false);
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ class OSystem;
|
||||||
namespace Graphics {
|
namespace Graphics {
|
||||||
struct DrawStep;
|
struct DrawStep;
|
||||||
class VectorRenderer;
|
class VectorRenderer;
|
||||||
|
class SVGBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
@ -202,6 +203,7 @@ private:
|
||||||
class ThemeEngine {
|
class ThemeEngine {
|
||||||
protected:
|
protected:
|
||||||
typedef Common::HashMap<Common::String, Graphics::Surface *> ImagesMap;
|
typedef Common::HashMap<Common::String, Graphics::Surface *> ImagesMap;
|
||||||
|
typedef Common::HashMap<Common::String, Graphics::SVGBitmap *> SVGMap;
|
||||||
typedef Common::HashMap<Common::String, Graphics::TransparentSurface *> AImagesMap;
|
typedef Common::HashMap<Common::String, Graphics::TransparentSurface *> AImagesMap;
|
||||||
|
|
||||||
friend class GUI::Dialog;
|
friend class GUI::Dialog;
|
||||||
|
@ -582,8 +584,9 @@ public:
|
||||||
* The filename is also used as its identifier.
|
* The filename is also used as its identifier.
|
||||||
*
|
*
|
||||||
* @param filename Name of the bitmap file.
|
* @param filename Name of the bitmap file.
|
||||||
|
* @param filename Name of the scalable (SVG) file, could be empty
|
||||||
*/
|
*/
|
||||||
bool addBitmap(const Common::String &filename);
|
bool addBitmap(const Common::String &filename, const Common::String &scalablefile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for the ThemeParser class: Loads a bitmap with transparency file to use on the GUI.
|
* Interface for the ThemeParser class: Loads a bitmap with transparency file to use on the GUI.
|
||||||
|
@ -799,6 +802,7 @@ protected:
|
||||||
Common::Array<LangExtraFont> _langExtraFonts;
|
Common::Array<LangExtraFont> _langExtraFonts;
|
||||||
|
|
||||||
ImagesMap _bitmaps;
|
ImagesMap _bitmaps;
|
||||||
|
SVGMap _svgs;
|
||||||
AImagesMap _abitmaps;
|
AImagesMap _abitmaps;
|
||||||
Graphics::PixelFormat _overlayFormat;
|
Graphics::PixelFormat _overlayFormat;
|
||||||
Graphics::PixelFormat _cursorFormat;
|
Graphics::PixelFormat _cursorFormat;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue