forked from len0rd/rockbox
Theme Editor: Rearranged and separated tag execution and rendering code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27167 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
942e427ef0
commit
aa13a5377c
2 changed files with 160 additions and 144 deletions
|
@ -525,150 +525,161 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport)
|
||||||
else if(element->type == TAG)
|
else if(element->type == TAG)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(info.device()->data(QString(element->tag->name)).isValid())
|
if(!execTag(info, viewport))
|
||||||
viewport->write(info.device()->
|
viewport->write(evalTag(info).toString());
|
||||||
data(QString(element->tag->name)).toString());
|
|
||||||
|
|
||||||
/* These are for special cases */
|
|
||||||
|
|
||||||
QString filename;
|
|
||||||
QString id;
|
|
||||||
int x, y, tiles, tile;
|
|
||||||
char c;
|
|
||||||
RBImage* image;
|
|
||||||
|
|
||||||
/* Two switch statements to narrow down the tag name */
|
|
||||||
switch(element->tag->name[0])
|
|
||||||
{
|
|
||||||
|
|
||||||
case 'x':
|
|
||||||
switch(element->tag->name[1])
|
|
||||||
{
|
|
||||||
case 'd':
|
|
||||||
/* %xd */
|
|
||||||
id = "";
|
|
||||||
id.append(element->params[0].data.text[0]);
|
|
||||||
c = element->params[0].data.text[1];
|
|
||||||
|
|
||||||
if(c == '\0')
|
|
||||||
{
|
|
||||||
tile = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(isupper(c))
|
|
||||||
tile = c - 'A' + 25;
|
|
||||||
else
|
|
||||||
tile = c - 'a';
|
|
||||||
}
|
|
||||||
|
|
||||||
image = info.screen()->getImage(id);
|
|
||||||
if(image)
|
|
||||||
{
|
|
||||||
image->setTile(tile);
|
|
||||||
image->show();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'l':
|
|
||||||
/* %xl */
|
|
||||||
id = element->params[0].data.text;
|
|
||||||
filename = info.settings()->value("imagepath", "") + "/" +
|
|
||||||
element->params[1].data.text;
|
|
||||||
x = element->params[2].data.numeric;
|
|
||||||
y = element->params[3].data.numeric;
|
|
||||||
if(element->params_count > 4)
|
|
||||||
tiles = element->params[4].data.numeric;
|
|
||||||
else
|
|
||||||
tiles = 1;
|
|
||||||
|
|
||||||
info.screen()->loadImage(id, new RBImage(filename, tiles, x, y,
|
|
||||||
viewport));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '\0':
|
|
||||||
/* %x */
|
|
||||||
id = element->params[0].data.text;
|
|
||||||
filename = info.settings()->value("imagepath", "") + "/" +
|
|
||||||
element->params[1].data.text;
|
|
||||||
x = element->params[2].data.numeric;
|
|
||||||
y = element->params[3].data.numeric;
|
|
||||||
image = new RBImage(filename, 1, x, y, viewport);
|
|
||||||
info.screen()->loadImage(id, new RBImage(filename, 1, x, y,
|
|
||||||
viewport));
|
|
||||||
info.screen()->getImage(id)->show();
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'F':
|
|
||||||
|
|
||||||
switch(element->tag->name[1])
|
|
||||||
{
|
|
||||||
|
|
||||||
case 'l':
|
|
||||||
/* %Fl */
|
|
||||||
x = element->params[0].data.numeric;
|
|
||||||
filename = info.settings()->value("themebase", "") + "/fonts/" +
|
|
||||||
element->params[1].data.text;
|
|
||||||
info.screen()->loadFont(x, new RBFont(filename));
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'V':
|
|
||||||
|
|
||||||
switch(element->tag->name[1])
|
|
||||||
{
|
|
||||||
|
|
||||||
case 'b':
|
|
||||||
/* %Vb */
|
|
||||||
viewport->setBGColor(RBScreen::
|
|
||||||
stringToColor(QString(element->params[0].
|
|
||||||
data.text),
|
|
||||||
Qt::white));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'd':
|
|
||||||
/* %Vd */
|
|
||||||
id = element->params[0].data.text;
|
|
||||||
info.screen()->showViewport(id);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'f':
|
|
||||||
/* %Vf */
|
|
||||||
viewport->setFGColor(RBScreen::
|
|
||||||
stringToColor(QString(element->params[0].
|
|
||||||
data.text),
|
|
||||||
Qt::black));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'I':
|
|
||||||
/* %VI */
|
|
||||||
info.screen()->makeCustomUI(element->params[0].data.text);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'X':
|
|
||||||
|
|
||||||
switch(element->tag->name[1])
|
|
||||||
{
|
|
||||||
case '\0':
|
|
||||||
/* %X */
|
|
||||||
filename = QString(element->params[0].data.text);
|
|
||||||
info.screen()->setBackdrop(filename);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
|
||||||
|
{
|
||||||
|
|
||||||
|
QString filename;
|
||||||
|
QString id;
|
||||||
|
int x, y, tiles, tile;
|
||||||
|
char c;
|
||||||
|
RBImage* image;
|
||||||
|
|
||||||
|
/* Two switch statements to narrow down the tag name */
|
||||||
|
switch(element->tag->name[0])
|
||||||
|
{
|
||||||
|
|
||||||
|
case 'x':
|
||||||
|
switch(element->tag->name[1])
|
||||||
|
{
|
||||||
|
case 'd':
|
||||||
|
/* %xd */
|
||||||
|
id = "";
|
||||||
|
id.append(element->params[0].data.text[0]);
|
||||||
|
c = element->params[0].data.text[1];
|
||||||
|
|
||||||
|
if(c == '\0')
|
||||||
|
{
|
||||||
|
tile = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(isupper(c))
|
||||||
|
tile = c - 'A' + 25;
|
||||||
|
else
|
||||||
|
tile = c - 'a';
|
||||||
|
}
|
||||||
|
|
||||||
|
image = info.screen()->getImage(id);
|
||||||
|
if(image)
|
||||||
|
{
|
||||||
|
image->setTile(tile);
|
||||||
|
image->show();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
/* %xl */
|
||||||
|
id = element->params[0].data.text;
|
||||||
|
filename = info.settings()->value("imagepath", "") + "/" +
|
||||||
|
element->params[1].data.text;
|
||||||
|
x = element->params[2].data.numeric;
|
||||||
|
y = element->params[3].data.numeric;
|
||||||
|
if(element->params_count > 4)
|
||||||
|
tiles = element->params[4].data.numeric;
|
||||||
|
else
|
||||||
|
tiles = 1;
|
||||||
|
|
||||||
|
info.screen()->loadImage(id, new RBImage(filename, tiles, x, y,
|
||||||
|
viewport));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case '\0':
|
||||||
|
/* %x */
|
||||||
|
id = element->params[0].data.text;
|
||||||
|
filename = info.settings()->value("imagepath", "") + "/" +
|
||||||
|
element->params[1].data.text;
|
||||||
|
x = element->params[2].data.numeric;
|
||||||
|
y = element->params[3].data.numeric;
|
||||||
|
image = new RBImage(filename, 1, x, y, viewport);
|
||||||
|
info.screen()->loadImage(id, new RBImage(filename, 1, x, y,
|
||||||
|
viewport));
|
||||||
|
info.screen()->getImage(id)->show();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 'F':
|
||||||
|
|
||||||
|
switch(element->tag->name[1])
|
||||||
|
{
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
/* %Fl */
|
||||||
|
x = element->params[0].data.numeric;
|
||||||
|
filename = info.settings()->value("themebase", "") + "/fonts/" +
|
||||||
|
element->params[1].data.text;
|
||||||
|
info.screen()->loadFont(x, new RBFont(filename));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 'V':
|
||||||
|
|
||||||
|
switch(element->tag->name[1])
|
||||||
|
{
|
||||||
|
|
||||||
|
case 'b':
|
||||||
|
/* %Vb */
|
||||||
|
viewport->setBGColor(RBScreen::
|
||||||
|
stringToColor(QString(element->params[0].
|
||||||
|
data.text),
|
||||||
|
Qt::white));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
/* %Vd */
|
||||||
|
id = element->params[0].data.text;
|
||||||
|
info.screen()->showViewport(id);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 'f':
|
||||||
|
/* %Vf */
|
||||||
|
viewport->setFGColor(RBScreen::
|
||||||
|
stringToColor(QString(element->params[0].
|
||||||
|
data.text),
|
||||||
|
Qt::black));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 'I':
|
||||||
|
/* %VI */
|
||||||
|
info.screen()->makeCustomUI(element->params[0].data.text);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 'X':
|
||||||
|
|
||||||
|
switch(element->tag->name[1])
|
||||||
|
{
|
||||||
|
case '\0':
|
||||||
|
/* %X */
|
||||||
|
filename = QString(element->params[0].data.text);
|
||||||
|
info.screen()->setBackdrop(filename);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ParseTreeNode::evalTag(const RBRenderInfo& info, bool conditional,
|
||||||
|
int branches)
|
||||||
|
{
|
||||||
|
return info.device()->data(QString(element->tag->name));
|
||||||
|
}
|
||||||
|
|
|
@ -63,6 +63,11 @@ public:
|
||||||
void render(const RBRenderInfo &info, RBViewport* viewport);
|
void render(const RBRenderInfo &info, RBViewport* viewport);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool execTag(const RBRenderInfo& info, RBViewport* viewport);
|
||||||
|
QVariant evalTag(const RBRenderInfo& info, bool conditional = false,
|
||||||
|
int branches = 0);
|
||||||
|
|
||||||
ParseTreeNode* parent;
|
ParseTreeNode* parent;
|
||||||
struct skin_element* element;
|
struct skin_element* element;
|
||||||
struct skin_tag_parameter* param;
|
struct skin_tag_parameter* param;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue