forked from len0rd/rockbox
Theme Editor: Added warning messages for missing resources
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27803 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e60de9e5bb
commit
dfc109ac65
5 changed files with 28 additions and 1 deletions
|
@ -39,6 +39,8 @@ RBFont::RBFont(QString file)
|
||||||
: valid(false), imageData(0), offsetData(0), widthData(0)
|
: valid(false), imageData(0), offsetData(0), widthData(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
bool badFile = false;
|
||||||
|
|
||||||
/* Attempting to locate the correct file name */
|
/* Attempting to locate the correct file name */
|
||||||
if(!QFile::exists(file))
|
if(!QFile::exists(file))
|
||||||
{
|
{
|
||||||
|
@ -52,7 +54,11 @@ RBFont::RBFont(QString file)
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
if(!QFile::exists(file))
|
if(!QFile::exists(file))
|
||||||
|
{
|
||||||
file = ":/fonts/08-Schumacher-Clean.fnt";
|
file = ":/fonts/08-Schumacher-Clean.fnt";
|
||||||
|
|
||||||
|
badFile = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
header.insert("filename", file);
|
header.insert("filename", file);
|
||||||
|
|
||||||
|
@ -65,6 +71,9 @@ RBFont::RBFont(QString file)
|
||||||
widthData = cache->widthData;
|
widthData = cache->widthData;
|
||||||
header = cache->header;
|
header = cache->header;
|
||||||
|
|
||||||
|
if(!badFile)
|
||||||
|
valid = true;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +171,9 @@ RBFont::RBFont(QString file)
|
||||||
cache->header = header;
|
cache->header = header;
|
||||||
RBFontCache::insert(file, cache);
|
RBFontCache::insert(file, cache);
|
||||||
|
|
||||||
|
if(!badFile)
|
||||||
|
valid = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RBFont::~RBFont()
|
RBFont::~RBFont()
|
||||||
|
|
|
@ -41,6 +41,8 @@ public:
|
||||||
|
|
||||||
static quint16 maxFontSizeFor16BitOffsets;
|
static quint16 maxFontSizeFor16BitOffsets;
|
||||||
|
|
||||||
|
bool isValid(){ return valid; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QString, QVariant> header;
|
QHash<QString, QVariant> header;
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "rbimage.h"
|
#include "rbimage.h"
|
||||||
#include "parsetreenode.h"
|
#include "parsetreenode.h"
|
||||||
|
#include <rbscene.h>
|
||||||
|
|
||||||
RBImage::RBImage(QString file, int tiles, int x, int y, ParseTreeNode* node,
|
RBImage::RBImage(QString file, int tiles, int x, int y, ParseTreeNode* node,
|
||||||
QGraphicsItem* parent)
|
QGraphicsItem* parent)
|
||||||
|
@ -56,6 +57,9 @@ RBImage::RBImage(QString file, int tiles, int x, int y, ParseTreeNode* node,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
RBScene* s = dynamic_cast<RBScene*>(scene());
|
||||||
|
s->addWarning(QObject::tr("Image not found: ") + file);
|
||||||
|
|
||||||
size = QRectF(0, 0, 0, 0);
|
size = QRectF(0, 0, 0, 0);
|
||||||
image = 0;
|
image = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,11 @@ void RBScreen::setBackdrop(QString filename)
|
||||||
if(QFile::exists(filename))
|
if(QFile::exists(filename))
|
||||||
backdrop = new QPixmap(filename);
|
backdrop = new QPixmap(filename);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
RBScene* s = dynamic_cast<RBScene*>(scene());
|
||||||
|
s->addWarning(QObject::tr("Image not found: ") + filename);
|
||||||
backdrop = 0;
|
backdrop = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RBScreen::makeCustomUI(QString id)
|
void RBScreen::makeCustomUI(QString id)
|
||||||
|
|
|
@ -641,6 +641,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
|
||||||
char c, hAlign, vAlign;
|
char c, hAlign, vAlign;
|
||||||
RBImage* image;
|
RBImage* image;
|
||||||
QPixmap temp;
|
QPixmap temp;
|
||||||
|
RBFont* fLoad;
|
||||||
|
|
||||||
/* Two switch statements to narrow down the tag name */
|
/* Two switch statements to narrow down the tag name */
|
||||||
switch(element->tag->name[0])
|
switch(element->tag->name[0])
|
||||||
|
@ -857,7 +858,11 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
|
||||||
x = element->params[0].data.number;
|
x = element->params[0].data.number;
|
||||||
filename = info.settings()->value("themebase", "") + "/fonts/" +
|
filename = info.settings()->value("themebase", "") + "/fonts/" +
|
||||||
element->params[1].data.text;
|
element->params[1].data.text;
|
||||||
info.screen()->loadFont(x, new RBFont(filename));
|
fLoad = new RBFont(filename);
|
||||||
|
if(!fLoad->isValid())
|
||||||
|
dynamic_cast<RBScene*>(info.screen()->scene())
|
||||||
|
->addWarning(QObject::tr("Missing font file: ") + filename);
|
||||||
|
info.screen()->loadFont(x, fLoad);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue