2010-05-29 00:04:04 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Robert Bieber
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2010-05-26 21:13:14 +00:00
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
#include "symbols.h"
|
2010-06-01 16:44:52 +00:00
|
|
|
#include "tag_table.h"
|
2010-05-26 21:13:14 +00:00
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
#include "parsetreenode.h"
|
2010-06-01 19:55:20 +00:00
|
|
|
#include "parsetreemodel.h"
|
2010-05-29 00:04:04 +00:00
|
|
|
|
2010-06-23 07:18:22 +00:00
|
|
|
#include "rbimage.h"
|
2010-07-02 00:20:36 +00:00
|
|
|
#include "rbprogressbar.h"
|
2010-07-10 06:43:50 +00:00
|
|
|
#include "rbtoucharea.h"
|
2010-06-23 07:18:22 +00:00
|
|
|
|
2010-06-21 20:11:58 +00:00
|
|
|
#include <iostream>
|
2010-07-07 22:25:42 +00:00
|
|
|
#include <cmath>
|
2010-06-21 20:11:58 +00:00
|
|
|
|
2010-06-02 07:48:48 +00:00
|
|
|
int ParseTreeNode::openConditionals = 0;
|
2010-07-04 01:39:57 +00:00
|
|
|
bool ParseTreeNode::breakFlag = false;
|
2010-06-02 07:48:48 +00:00
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
/* Root element constructor */
|
2010-08-05 00:43:33 +00:00
|
|
|
ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeModel* model)
|
|
|
|
: parent(0), element(0), param(0), children(), model(model)
|
2010-05-29 00:04:04 +00:00
|
|
|
{
|
|
|
|
while(data)
|
2010-05-27 19:57:15 +00:00
|
|
|
{
|
2010-08-05 00:43:33 +00:00
|
|
|
children.append(new ParseTreeNode(data, this, model));
|
2010-05-29 00:04:04 +00:00
|
|
|
data = data->next;
|
2010-05-27 19:57:15 +00:00
|
|
|
}
|
2010-05-26 21:13:14 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
/* Normal element constructor */
|
2010-08-05 00:43:33 +00:00
|
|
|
ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent,
|
|
|
|
ParseTreeModel* model)
|
|
|
|
: parent(parent), element(data), param(0),
|
|
|
|
children(), model(model)
|
2010-05-27 19:57:15 +00:00
|
|
|
{
|
2010-05-29 00:04:04 +00:00
|
|
|
switch(element->type)
|
|
|
|
{
|
2010-05-27 19:57:15 +00:00
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
case TAG:
|
|
|
|
for(int i = 0; i < element->params_count; i++)
|
|
|
|
{
|
|
|
|
if(element->params[i].type == skin_tag_parameter::CODE)
|
|
|
|
children.append(new ParseTreeNode(element->params[i].data.code,
|
2010-08-05 00:43:33 +00:00
|
|
|
this, model));
|
2010-05-29 00:04:04 +00:00
|
|
|
else
|
2010-08-05 00:43:33 +00:00
|
|
|
children.append(new ParseTreeNode(&element->params[i], this,
|
|
|
|
model));
|
2010-05-29 00:04:04 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-05-27 19:57:15 +00:00
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
case CONDITIONAL:
|
2010-06-10 21:02:44 +00:00
|
|
|
for(int i = 0; i < element->params_count; i++)
|
2010-08-05 00:43:33 +00:00
|
|
|
children.append(new ParseTreeNode(&data->params[i], this, model));
|
2010-06-10 21:02:44 +00:00
|
|
|
for(int i = 0; i < element->children_count; i++)
|
2010-08-05 00:43:33 +00:00
|
|
|
children.append(new ParseTreeNode(data->children[i], this, model));
|
2010-06-10 21:02:44 +00:00
|
|
|
break;
|
|
|
|
|
2010-07-04 02:04:14 +00:00
|
|
|
case LINE_ALTERNATOR:
|
2010-05-29 00:04:04 +00:00
|
|
|
for(int i = 0; i < element->children_count; i++)
|
|
|
|
{
|
2010-08-05 00:43:33 +00:00
|
|
|
children.append(new ParseTreeNode(data->children[i], this, model));
|
2010-05-29 00:04:04 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-05-27 19:57:15 +00:00
|
|
|
|
2010-06-11 19:51:34 +00:00
|
|
|
case VIEWPORT:
|
|
|
|
for(int i = 0; i < element->params_count; i++)
|
2010-08-05 00:43:33 +00:00
|
|
|
children.append(new ParseTreeNode(&data->params[i], this, model));
|
2010-06-11 19:51:34 +00:00
|
|
|
/* Deliberate fall-through here */
|
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
case LINE:
|
2010-06-01 18:31:58 +00:00
|
|
|
for(int i = 0; i < data->children_count; i++)
|
2010-05-29 00:04:04 +00:00
|
|
|
{
|
2010-06-01 18:31:58 +00:00
|
|
|
for(struct skin_element* current = data->children[i]; current;
|
|
|
|
current = current->next)
|
|
|
|
{
|
2010-08-05 00:43:33 +00:00
|
|
|
children.append(new ParseTreeNode(current, this, model));
|
2010-06-01 18:31:58 +00:00
|
|
|
}
|
2010-05-29 00:04:04 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-05-26 21:13:14 +00:00
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-05-26 21:13:14 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
/* Parameter constructor */
|
2010-08-05 00:43:33 +00:00
|
|
|
ParseTreeNode::ParseTreeNode(skin_tag_parameter *data, ParseTreeNode *parent,
|
|
|
|
ParseTreeModel *model)
|
|
|
|
: parent(parent), element(0), param(data),
|
|
|
|
children(), model(model)
|
2010-05-26 21:13:14 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-06-18 21:10:01 +00:00
|
|
|
ParseTreeNode::~ParseTreeNode()
|
|
|
|
{
|
|
|
|
for(int i = 0; i < children.count(); i++)
|
|
|
|
delete children[i];
|
|
|
|
}
|
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
QString ParseTreeNode::genCode() const
|
2010-05-26 21:13:14 +00:00
|
|
|
{
|
2010-05-29 00:04:04 +00:00
|
|
|
QString buffer = "";
|
2010-05-26 21:13:14 +00:00
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
if(element)
|
|
|
|
{
|
|
|
|
switch(element->type)
|
|
|
|
{
|
2010-06-13 03:13:01 +00:00
|
|
|
case UNKNOWN:
|
|
|
|
break;
|
2010-06-01 07:11:23 +00:00
|
|
|
case VIEWPORT:
|
2010-06-11 08:03:32 +00:00
|
|
|
/* Generating the Viewport tag, if necessary */
|
|
|
|
if(element->tag)
|
|
|
|
{
|
|
|
|
buffer.append(TAGSYM);
|
|
|
|
buffer.append(element->tag->name);
|
|
|
|
buffer.append(ARGLISTOPENSYM);
|
|
|
|
for(int i = 0; i < element->params_count; i++)
|
|
|
|
{
|
|
|
|
buffer.append(children[i]->genCode());
|
|
|
|
if(i != element->params_count - 1)
|
|
|
|
buffer.append(ARGLISTSEPERATESYM);
|
|
|
|
}
|
|
|
|
buffer.append(ARGLISTCLOSESYM);
|
2010-06-02 06:41:41 +00:00
|
|
|
buffer.append('\n');
|
2010-06-11 08:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = element->params_count; i < children.count(); i++)
|
2010-06-02 06:41:41 +00:00
|
|
|
buffer.append(children[i]->genCode());
|
|
|
|
break;
|
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
case LINE:
|
|
|
|
for(int i = 0; i < children.count(); i++)
|
|
|
|
{
|
|
|
|
buffer.append(children[i]->genCode());
|
|
|
|
}
|
2010-06-10 21:52:53 +00:00
|
|
|
if(openConditionals == 0
|
2010-08-05 06:25:53 +00:00
|
|
|
&& !(parent && parent->element->type == LINE_ALTERNATOR)
|
|
|
|
&& !(children.count() > 0 &&
|
|
|
|
children[children.count() - 1]->getElement()->type
|
|
|
|
== COMMENT))
|
2010-06-10 21:52:53 +00:00
|
|
|
{
|
2010-06-02 07:48:48 +00:00
|
|
|
buffer.append('\n');
|
2010-06-10 21:52:53 +00:00
|
|
|
}
|
2010-05-29 00:04:04 +00:00
|
|
|
break;
|
|
|
|
|
2010-07-04 02:04:14 +00:00
|
|
|
case LINE_ALTERNATOR:
|
2010-05-29 00:04:04 +00:00
|
|
|
for(int i = 0; i < children.count(); i++)
|
|
|
|
{
|
|
|
|
buffer.append(children[i]->genCode());
|
|
|
|
if(i != children.count() - 1)
|
|
|
|
buffer.append(MULTILINESYM);
|
|
|
|
}
|
2010-06-10 21:52:53 +00:00
|
|
|
if(openConditionals == 0)
|
|
|
|
buffer.append('\n');
|
2010-05-29 00:04:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CONDITIONAL:
|
2010-06-02 07:48:48 +00:00
|
|
|
openConditionals++;
|
2010-06-10 21:52:53 +00:00
|
|
|
|
|
|
|
/* Inserting the tag part */
|
2010-05-29 00:04:04 +00:00
|
|
|
buffer.append(TAGSYM);
|
|
|
|
buffer.append(CONDITIONSYM);
|
2010-06-10 21:52:53 +00:00
|
|
|
buffer.append(element->tag->name);
|
|
|
|
if(element->params_count > 0)
|
|
|
|
{
|
|
|
|
buffer.append(ARGLISTOPENSYM);
|
|
|
|
for(int i = 0; i < element->params_count; i++)
|
|
|
|
{
|
|
|
|
buffer.append(children[i]->genCode());
|
|
|
|
if( i != element->params_count - 1)
|
|
|
|
buffer.append(ARGLISTSEPERATESYM);
|
|
|
|
buffer.append(ARGLISTCLOSESYM);
|
|
|
|
}
|
|
|
|
}
|
2010-05-29 00:04:04 +00:00
|
|
|
|
|
|
|
/* Inserting the sublines */
|
|
|
|
buffer.append(ENUMLISTOPENSYM);
|
2010-06-10 21:52:53 +00:00
|
|
|
for(int i = element->params_count; i < children.count(); i++)
|
2010-05-29 00:04:04 +00:00
|
|
|
{
|
|
|
|
buffer.append(children[i]->genCode());
|
|
|
|
if(i != children.count() - 1)
|
|
|
|
buffer.append(ENUMLISTSEPERATESYM);
|
|
|
|
}
|
|
|
|
buffer.append(ENUMLISTCLOSESYM);
|
2010-06-02 07:48:48 +00:00
|
|
|
openConditionals--;
|
2010-05-29 00:04:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG:
|
2010-06-10 21:52:53 +00:00
|
|
|
buffer.append(TAGSYM);
|
2010-06-01 16:44:52 +00:00
|
|
|
buffer.append(element->tag->name);
|
2010-05-29 00:04:04 +00:00
|
|
|
|
|
|
|
if(element->params_count > 0)
|
|
|
|
{
|
|
|
|
/* Rendering parameters if there are any */
|
|
|
|
buffer.append(ARGLISTOPENSYM);
|
|
|
|
for(int i = 0; i < children.count(); i++)
|
|
|
|
{
|
|
|
|
buffer.append(children[i]->genCode());
|
|
|
|
if(i != children.count() - 1)
|
|
|
|
buffer.append(ARGLISTSEPERATESYM);
|
|
|
|
}
|
|
|
|
buffer.append(ARGLISTCLOSESYM);
|
|
|
|
}
|
2010-07-03 23:31:08 +00:00
|
|
|
if(element->tag->params[strlen(element->tag->params) - 1] == '\n')
|
|
|
|
buffer.append('\n');
|
2010-05-29 00:04:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TEXT:
|
2010-06-10 21:02:44 +00:00
|
|
|
for(char* cursor = (char*)element->data; *cursor; cursor++)
|
2010-06-02 05:55:41 +00:00
|
|
|
{
|
|
|
|
if(find_escape_character(*cursor))
|
|
|
|
buffer.append(TAGSYM);
|
|
|
|
buffer.append(*cursor);
|
|
|
|
}
|
2010-05-29 00:04:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COMMENT:
|
|
|
|
buffer.append(COMMENTSYM);
|
2010-06-10 21:02:44 +00:00
|
|
|
buffer.append((char*)element->data);
|
2010-06-01 20:19:51 +00:00
|
|
|
buffer.append('\n');
|
2010-05-29 00:04:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(param)
|
|
|
|
{
|
|
|
|
switch(param->type)
|
|
|
|
{
|
|
|
|
case skin_tag_parameter::STRING:
|
2010-06-02 05:55:41 +00:00
|
|
|
for(char* cursor = param->data.text; *cursor; cursor++)
|
|
|
|
{
|
|
|
|
if(find_escape_character(*cursor))
|
|
|
|
buffer.append(TAGSYM);
|
|
|
|
buffer.append(*cursor);
|
|
|
|
}
|
2010-05-29 00:04:04 +00:00
|
|
|
break;
|
|
|
|
|
2010-07-15 06:24:11 +00:00
|
|
|
case skin_tag_parameter::INTEGER:
|
|
|
|
buffer.append(QString::number(param->data.number, 10));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case skin_tag_parameter::DECIMAL:
|
|
|
|
buffer.append(QString::number(param->data.number / 10., 'f', 1));
|
2010-05-29 00:04:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case skin_tag_parameter::DEFAULT:
|
|
|
|
buffer.append(DEFAULTSYM);
|
|
|
|
break;
|
|
|
|
|
2010-05-30 01:20:05 +00:00
|
|
|
case skin_tag_parameter::CODE:
|
|
|
|
buffer.append(QObject::tr("This doesn't belong here"));
|
|
|
|
break;
|
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
}
|
|
|
|
}
|
2010-05-26 21:13:14 +00:00
|
|
|
else
|
2010-05-29 00:04:04 +00:00
|
|
|
{
|
|
|
|
for(int i = 0; i < children.count(); i++)
|
|
|
|
buffer.append(children[i]->genCode());
|
|
|
|
}
|
2010-05-26 21:13:14 +00:00
|
|
|
|
2010-05-29 00:04:04 +00:00
|
|
|
return buffer;
|
2010-05-26 21:13:14 +00:00
|
|
|
}
|
2010-05-30 01:20:05 +00:00
|
|
|
|
2010-06-02 20:36:30 +00:00
|
|
|
/* A more or less random hashing algorithm */
|
|
|
|
int ParseTreeNode::genHash() const
|
|
|
|
{
|
|
|
|
int hash = 0;
|
2010-06-10 21:02:44 +00:00
|
|
|
char *text;
|
2010-06-02 20:36:30 +00:00
|
|
|
|
|
|
|
if(element)
|
|
|
|
{
|
|
|
|
hash += element->type;
|
|
|
|
switch(element->type)
|
|
|
|
{
|
2010-06-13 03:13:01 +00:00
|
|
|
case UNKNOWN:
|
|
|
|
break;
|
2010-06-02 20:36:30 +00:00
|
|
|
case VIEWPORT:
|
|
|
|
case LINE:
|
2010-07-04 02:04:14 +00:00
|
|
|
case LINE_ALTERNATOR:
|
2010-06-02 20:36:30 +00:00
|
|
|
case CONDITIONAL:
|
|
|
|
hash += element->children_count;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TAG:
|
|
|
|
for(unsigned int i = 0; i < strlen(element->tag->name); i++)
|
|
|
|
hash += element->tag->name[i];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMMENT:
|
|
|
|
case TEXT:
|
2010-06-10 21:02:44 +00:00
|
|
|
text = (char*)element->data;
|
|
|
|
for(unsigned int i = 0; i < strlen(text); i++)
|
2010-06-02 20:36:30 +00:00
|
|
|
{
|
|
|
|
if(i % 2)
|
2010-06-10 21:02:44 +00:00
|
|
|
hash += text[i] % element->type;
|
2010-06-02 20:36:30 +00:00
|
|
|
else
|
2010-06-10 21:02:44 +00:00
|
|
|
hash += text[i] % element->type * 2;
|
2010-06-02 20:36:30 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(param)
|
|
|
|
{
|
|
|
|
hash += param->type;
|
|
|
|
switch(param->type)
|
|
|
|
{
|
|
|
|
case skin_tag_parameter::DEFAULT:
|
|
|
|
case skin_tag_parameter::CODE:
|
|
|
|
break;
|
|
|
|
|
2010-07-15 06:24:11 +00:00
|
|
|
case skin_tag_parameter::INTEGER:
|
|
|
|
hash += param->data.number * (param->data.number / 4);
|
2010-06-02 20:36:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case skin_tag_parameter::STRING:
|
|
|
|
for(unsigned int i = 0; i < strlen(param->data.text); i++)
|
|
|
|
{
|
|
|
|
if(i % 2)
|
|
|
|
hash += param->data.text[i] * 2;
|
|
|
|
else
|
|
|
|
hash += param->data.text[i];
|
|
|
|
}
|
|
|
|
break;
|
2010-07-15 06:24:11 +00:00
|
|
|
|
|
|
|
case skin_tag_parameter::DECIMAL:
|
|
|
|
hash += param->data.number;
|
|
|
|
break;
|
2010-06-02 20:36:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = 0; i < children.count(); i++)
|
|
|
|
{
|
|
|
|
hash += children[i]->genHash();
|
|
|
|
}
|
|
|
|
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
2010-05-30 01:20:05 +00:00
|
|
|
ParseTreeNode* ParseTreeNode::child(int row)
|
|
|
|
{
|
|
|
|
if(row < 0 || row >= children.count())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return children[row];
|
|
|
|
}
|
|
|
|
|
|
|
|
int ParseTreeNode::numChildren() const
|
|
|
|
{
|
2010-06-02 20:36:30 +00:00
|
|
|
return children.count();
|
2010-05-30 01:20:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVariant ParseTreeNode::data(int column) const
|
|
|
|
{
|
|
|
|
switch(column)
|
|
|
|
{
|
2010-06-01 19:55:20 +00:00
|
|
|
case ParseTreeModel::typeColumn:
|
2010-05-30 01:20:05 +00:00
|
|
|
if(element)
|
|
|
|
{
|
|
|
|
switch(element->type)
|
|
|
|
{
|
2010-06-13 03:13:01 +00:00
|
|
|
case UNKNOWN:
|
|
|
|
return QObject::tr("Unknown");
|
2010-06-01 07:11:23 +00:00
|
|
|
case VIEWPORT:
|
|
|
|
return QObject::tr("Viewport");
|
|
|
|
|
2010-05-30 01:20:05 +00:00
|
|
|
case LINE:
|
|
|
|
return QObject::tr("Logical Line");
|
|
|
|
|
2010-07-04 02:04:14 +00:00
|
|
|
case LINE_ALTERNATOR:
|
2010-05-30 01:20:05 +00:00
|
|
|
return QObject::tr("Alternator");
|
|
|
|
|
|
|
|
case COMMENT:
|
|
|
|
return QObject::tr("Comment");
|
|
|
|
|
|
|
|
case CONDITIONAL:
|
|
|
|
return QObject::tr("Conditional Tag");
|
|
|
|
|
|
|
|
case TAG:
|
|
|
|
return QObject::tr("Tag");
|
|
|
|
|
|
|
|
case TEXT:
|
|
|
|
return QObject::tr("Plaintext");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(param)
|
|
|
|
{
|
|
|
|
switch(param->type)
|
|
|
|
{
|
|
|
|
case skin_tag_parameter::STRING:
|
|
|
|
return QObject::tr("String");
|
|
|
|
|
2010-07-15 06:24:11 +00:00
|
|
|
case skin_tag_parameter::INTEGER:
|
|
|
|
return QObject::tr("Integer");
|
|
|
|
|
|
|
|
case skin_tag_parameter::DECIMAL:
|
|
|
|
return QObject::tr("Decimal");
|
2010-05-30 01:20:05 +00:00
|
|
|
|
|
|
|
case skin_tag_parameter::DEFAULT:
|
|
|
|
return QObject::tr("Default Argument");
|
|
|
|
|
|
|
|
case skin_tag_parameter::CODE:
|
|
|
|
return QObject::tr("This doesn't belong here");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return QObject::tr("Root");
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2010-06-01 19:55:20 +00:00
|
|
|
case ParseTreeModel::valueColumn:
|
2010-05-30 01:20:05 +00:00
|
|
|
if(element)
|
|
|
|
{
|
|
|
|
switch(element->type)
|
|
|
|
{
|
2010-06-13 03:13:01 +00:00
|
|
|
case UNKNOWN:
|
2010-06-01 07:11:23 +00:00
|
|
|
case VIEWPORT:
|
2010-05-30 01:20:05 +00:00
|
|
|
case LINE:
|
2010-07-04 02:04:14 +00:00
|
|
|
case LINE_ALTERNATOR:
|
2010-05-30 01:20:05 +00:00
|
|
|
return QString();
|
|
|
|
|
2010-06-10 21:02:44 +00:00
|
|
|
case CONDITIONAL:
|
|
|
|
return QString(element->tag->name);
|
|
|
|
|
2010-05-30 01:20:05 +00:00
|
|
|
case TEXT:
|
|
|
|
case COMMENT:
|
2010-06-10 21:02:44 +00:00
|
|
|
return QString((char*)element->data);
|
2010-05-30 01:20:05 +00:00
|
|
|
|
|
|
|
case TAG:
|
2010-06-01 16:44:52 +00:00
|
|
|
return QString(element->tag->name);
|
2010-05-30 01:20:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(param)
|
|
|
|
{
|
|
|
|
switch(param->type)
|
|
|
|
{
|
|
|
|
case skin_tag_parameter::DEFAULT:
|
|
|
|
return QObject::tr("-");
|
|
|
|
|
|
|
|
case skin_tag_parameter::STRING:
|
|
|
|
return QString(param->data.text);
|
|
|
|
|
2010-07-15 06:24:11 +00:00
|
|
|
case skin_tag_parameter::INTEGER:
|
|
|
|
return QString::number(param->data.number, 10);
|
|
|
|
|
|
|
|
case skin_tag_parameter::DECIMAL:
|
|
|
|
return QString::number(param->data.number / 10., 'f', 1);
|
2010-05-30 01:20:05 +00:00
|
|
|
|
|
|
|
case skin_tag_parameter::CODE:
|
|
|
|
return QObject::tr("Seriously, something's wrong here");
|
2010-07-15 06:24:11 +00:00
|
|
|
|
2010-05-30 01:20:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-06-01 19:55:20 +00:00
|
|
|
case ParseTreeModel::lineColumn:
|
2010-05-30 01:20:05 +00:00
|
|
|
if(element)
|
|
|
|
return QString::number(element->line, 10);
|
|
|
|
else
|
|
|
|
return QString();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ParseTreeNode::getRow() const
|
|
|
|
{
|
|
|
|
if(!parent)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return parent->children.indexOf(const_cast<ParseTreeNode*>(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
ParseTreeNode* ParseTreeNode::getParent() const
|
|
|
|
{
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2010-06-22 07:55:50 +00:00
|
|
|
/* This version is called for the root node and for viewports */
|
2010-06-18 21:10:01 +00:00
|
|
|
void ParseTreeNode::render(const RBRenderInfo& info)
|
2010-05-30 01:20:05 +00:00
|
|
|
{
|
2010-06-18 21:10:01 +00:00
|
|
|
/* Parameters don't get rendered */
|
|
|
|
if(!element && param)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* If we're at the root, we need to render each viewport */
|
|
|
|
if(!element && !param)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < children.count(); i++)
|
|
|
|
{
|
|
|
|
children[i]->render(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-06-21 20:11:58 +00:00
|
|
|
if(element->type != VIEWPORT)
|
2010-06-18 21:10:01 +00:00
|
|
|
{
|
2010-06-21 20:11:58 +00:00
|
|
|
std::cerr << QObject::tr("Error in parse tree").toStdString()
|
|
|
|
<< std::endl;
|
|
|
|
return;
|
2010-06-18 21:10:01 +00:00
|
|
|
}
|
2010-06-21 20:11:58 +00:00
|
|
|
|
2010-08-04 09:16:52 +00:00
|
|
|
rendered = new RBViewport(element, info, this);
|
2010-06-22 07:55:50 +00:00
|
|
|
|
|
|
|
for(int i = element->params_count; i < children.count(); i++)
|
|
|
|
children[i]->render(info, dynamic_cast<RBViewport*>(rendered));
|
2010-06-23 07:18:22 +00:00
|
|
|
|
2010-05-30 01:20:05 +00:00
|
|
|
}
|
2010-06-18 21:10:01 +00:00
|
|
|
|
2010-06-29 06:14:36 +00:00
|
|
|
/* This version is called for logical lines, tags, conditionals and such */
|
2010-06-29 20:39:45 +00:00
|
|
|
void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport,
|
|
|
|
bool noBreak)
|
2010-06-22 07:55:50 +00:00
|
|
|
{
|
|
|
|
if(element->type == LINE)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < children.count(); i++)
|
|
|
|
children[i]->render(info, viewport);
|
2010-07-04 01:39:57 +00:00
|
|
|
if(!noBreak && !breakFlag)
|
2010-07-01 20:30:19 +00:00
|
|
|
viewport->newLine();
|
2010-07-07 08:41:36 +00:00
|
|
|
else
|
|
|
|
viewport->flushText();
|
2010-07-04 01:39:57 +00:00
|
|
|
|
|
|
|
if(breakFlag)
|
|
|
|
breakFlag = false;
|
2010-06-25 05:14:13 +00:00
|
|
|
}
|
|
|
|
else if(element->type == TEXT)
|
|
|
|
{
|
|
|
|
viewport->write(QString(static_cast<char*>(element->data)));
|
2010-06-22 07:55:50 +00:00
|
|
|
}
|
|
|
|
else if(element->type == TAG)
|
|
|
|
{
|
2010-06-29 05:23:22 +00:00
|
|
|
if(!execTag(info, viewport))
|
|
|
|
viewport->write(evalTag(info).toString());
|
2010-07-04 01:39:57 +00:00
|
|
|
if(element->tag->flags & NOBREAK)
|
|
|
|
breakFlag = true;
|
2010-06-29 06:14:36 +00:00
|
|
|
}
|
|
|
|
else if(element->type == CONDITIONAL)
|
|
|
|
{
|
|
|
|
int child = evalTag(info, true, element->children_count).toInt();
|
2010-07-29 06:41:33 +00:00
|
|
|
if(child < children.count())
|
|
|
|
children[element->params_count + child]
|
|
|
|
->render(info, viewport, true);
|
2010-06-29 05:23:22 +00:00
|
|
|
}
|
2010-07-04 02:04:14 +00:00
|
|
|
else if(element->type == LINE_ALTERNATOR)
|
2010-06-29 19:59:33 +00:00
|
|
|
{
|
|
|
|
/* First we build a list of the times for each branch */
|
|
|
|
QList<double> times;
|
|
|
|
for(int i = 0; i < children.count() ; i++)
|
|
|
|
times.append(findBranchTime(children[i], info));
|
|
|
|
|
2010-07-07 22:25:42 +00:00
|
|
|
double totalTime = 0;
|
|
|
|
for(int i = 0; i < children.count(); i++)
|
|
|
|
totalTime += times[i];
|
|
|
|
|
2010-06-29 19:59:33 +00:00
|
|
|
/* Now we figure out which branch to select */
|
2010-07-07 20:56:16 +00:00
|
|
|
double timeLeft = info.device()->data(QString("simtime")).toDouble();
|
2010-07-07 22:25:42 +00:00
|
|
|
|
|
|
|
/* Skipping any full cycles */
|
|
|
|
timeLeft -= totalTime * std::floor(timeLeft / totalTime);
|
|
|
|
|
2010-06-29 19:59:33 +00:00
|
|
|
int branch = 0;
|
|
|
|
while(timeLeft > 0)
|
|
|
|
{
|
|
|
|
timeLeft -= times[branch];
|
|
|
|
if(timeLeft >= 0)
|
|
|
|
branch++;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
if(branch >= times.count())
|
|
|
|
branch = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* In case we end up on a disabled branch, skip ahead. If we find that
|
|
|
|
* all the branches are disabled, don't render anything
|
|
|
|
*/
|
|
|
|
int originalBranch = branch;
|
|
|
|
while(times[branch] == 0)
|
|
|
|
{
|
|
|
|
branch++;
|
|
|
|
if(branch == originalBranch)
|
|
|
|
{
|
|
|
|
branch = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(branch >= times.count())
|
|
|
|
branch = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ...and finally render the selected branch */
|
|
|
|
if(branch >= 0)
|
2010-06-29 20:39:45 +00:00
|
|
|
children[branch]->render(info, viewport, true);
|
2010-06-29 19:59:33 +00:00
|
|
|
}
|
2010-06-29 05:23:22 +00:00
|
|
|
}
|
2010-06-26 05:51:07 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
|
|
|
|
{
|
2010-06-22 07:55:50 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
QString filename;
|
|
|
|
QString id;
|
2010-06-30 19:35:00 +00:00
|
|
|
int x, y, tiles, tile, maxWidth, maxHeight, width, height;
|
|
|
|
char c, hAlign, vAlign;
|
2010-06-29 05:23:22 +00:00
|
|
|
RBImage* image;
|
2010-06-22 07:55:50 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
/* Two switch statements to narrow down the tag name */
|
|
|
|
switch(element->tag->name[0])
|
|
|
|
{
|
2010-06-23 07:37:48 +00:00
|
|
|
|
2010-06-30 07:00:05 +00:00
|
|
|
case 'a':
|
|
|
|
switch(element->tag->name[1])
|
|
|
|
{
|
|
|
|
case 'c':
|
|
|
|
/* %ac */
|
|
|
|
viewport->alignText(RBViewport::Center);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case 'l':
|
|
|
|
/* %al */
|
|
|
|
viewport->alignText(RBViewport::Left);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case 'r':
|
|
|
|
/* %ar */
|
|
|
|
viewport->alignText(RBViewport::Right);
|
|
|
|
return true;
|
2010-07-05 19:02:40 +00:00
|
|
|
|
|
|
|
case 'x':
|
|
|
|
/* %ax */
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case 'L':
|
|
|
|
/* %aL */
|
|
|
|
if(info.device()->data("rtl").toBool())
|
|
|
|
viewport->alignText(RBViewport::Right);
|
|
|
|
else
|
|
|
|
viewport->alignText(RBViewport::Left);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case 'R':
|
|
|
|
/* %aR */
|
|
|
|
if(info.device()->data("rtl").toBool())
|
|
|
|
viewport->alignText(RBViewport::Left);
|
|
|
|
else
|
|
|
|
viewport->alignText(RBViewport::Right);
|
|
|
|
return true;
|
2010-06-30 07:00:05 +00:00
|
|
|
}
|
|
|
|
|
2010-06-30 19:35:00 +00:00
|
|
|
return false;
|
2010-06-30 07:00:05 +00:00
|
|
|
|
2010-07-02 00:20:36 +00:00
|
|
|
case 'p':
|
|
|
|
switch(element->tag->name[1])
|
|
|
|
{
|
|
|
|
case 'b':
|
|
|
|
/* %pb */
|
2010-08-05 19:05:36 +00:00
|
|
|
new RBProgressBar(viewport, info, this);
|
2010-07-02 00:20:36 +00:00
|
|
|
return true;
|
2010-07-12 06:07:50 +00:00
|
|
|
|
|
|
|
case 'v':
|
|
|
|
/* %pv */
|
|
|
|
if(element->params_count > 0)
|
|
|
|
{
|
2010-08-05 19:05:36 +00:00
|
|
|
new RBProgressBar(viewport, info, this, true);
|
2010-07-12 06:07:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
2010-07-02 00:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
2010-07-07 22:25:42 +00:00
|
|
|
case 's':
|
|
|
|
switch(element->tag->name[1])
|
|
|
|
{
|
|
|
|
case '\0':
|
|
|
|
/* %s */
|
|
|
|
viewport->scrollText(info.device()->data("simtime").toDouble());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
2010-06-30 21:28:11 +00:00
|
|
|
case 'w':
|
|
|
|
switch(element->tag->name[1])
|
|
|
|
{
|
|
|
|
case 'd':
|
2010-07-03 21:56:29 +00:00
|
|
|
/* %wd */
|
2010-07-03 22:57:42 +00:00
|
|
|
info.screen()->breakSBS();
|
2010-06-30 21:28:11 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case 'e':
|
2010-07-03 21:56:29 +00:00
|
|
|
/* %we */
|
|
|
|
/* Totally extraneous */
|
2010-06-30 21:28:11 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case 'i':
|
2010-07-03 21:56:29 +00:00
|
|
|
/* %wi */
|
2010-06-30 21:28:11 +00:00
|
|
|
viewport->enableStatusBar();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
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];
|
2010-06-23 07:37:48 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
if(c == '\0')
|
|
|
|
{
|
|
|
|
tile = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(isupper(c))
|
|
|
|
tile = c - 'A' + 25;
|
2010-06-23 07:18:22 +00:00
|
|
|
else
|
2010-06-29 05:23:22 +00:00
|
|
|
tile = c - 'a';
|
2010-06-23 07:18:22 +00:00
|
|
|
}
|
|
|
|
|
2010-06-29 07:15:41 +00:00
|
|
|
if(info.screen()->getImage(id))
|
2010-06-29 05:23:22 +00:00
|
|
|
{
|
2010-06-29 07:15:41 +00:00
|
|
|
image = new RBImage(*(info.screen()->getImage(id)), viewport);
|
2010-06-29 05:23:22 +00:00
|
|
|
image->setTile(tile);
|
|
|
|
image->show();
|
2010-08-05 07:28:01 +00:00
|
|
|
image->enableMovement();
|
2010-06-29 05:23:22 +00:00
|
|
|
}
|
2010-06-29 07:15:41 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case 'l':
|
|
|
|
/* %xl */
|
|
|
|
id = element->params[0].data.text;
|
|
|
|
filename = info.settings()->value("imagepath", "") + "/" +
|
|
|
|
element->params[1].data.text;
|
2010-07-15 06:24:11 +00:00
|
|
|
x = element->params[2].data.number;
|
|
|
|
y = element->params[3].data.number;
|
2010-06-29 05:23:22 +00:00
|
|
|
if(element->params_count > 4)
|
2010-07-15 06:24:11 +00:00
|
|
|
tiles = element->params[4].data.number;
|
2010-06-29 05:23:22 +00:00
|
|
|
else
|
|
|
|
tiles = 1;
|
|
|
|
|
|
|
|
info.screen()->loadImage(id, new RBImage(filename, tiles, x, y,
|
2010-08-05 07:28:01 +00:00
|
|
|
this, viewport));
|
2010-06-29 05:23:22 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case '\0':
|
|
|
|
/* %x */
|
|
|
|
id = element->params[0].data.text;
|
|
|
|
filename = info.settings()->value("imagepath", "") + "/" +
|
|
|
|
element->params[1].data.text;
|
2010-07-15 06:24:11 +00:00
|
|
|
x = element->params[2].data.number;
|
|
|
|
y = element->params[3].data.number;
|
2010-08-05 07:28:01 +00:00
|
|
|
image = new RBImage(filename, 1, x, y, this, viewport);
|
|
|
|
info.screen()->loadImage(id, image);
|
|
|
|
image->show();
|
|
|
|
image->enableMovement();
|
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
return true;
|
2010-06-23 07:18:22 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
}
|
2010-06-23 20:18:31 +00:00
|
|
|
|
2010-06-30 19:35:00 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
case 'C':
|
|
|
|
switch(element->tag->name[1])
|
|
|
|
{
|
|
|
|
case 'd':
|
|
|
|
/* %Cd */
|
|
|
|
info.screen()->showAlbumArt(viewport);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case 'l':
|
|
|
|
/* %Cl */
|
2010-07-15 06:24:11 +00:00
|
|
|
x = element->params[0].data.number;
|
|
|
|
y = element->params[1].data.number;
|
|
|
|
maxWidth = element->params[2].data.number;
|
|
|
|
maxHeight = element->params[3].data.number;
|
2010-06-30 19:35:00 +00:00
|
|
|
hAlign = element->params_count > 4
|
|
|
|
? element->params[4].data.text[0] : 'c';
|
|
|
|
vAlign = element->params_count > 5
|
|
|
|
? element->params[5].data.text[0] : 'c';
|
|
|
|
width = info.device()->data("artwidth").toInt();
|
|
|
|
height = info.device()->data("artheight").toInt();
|
|
|
|
info.screen()->setAlbumArt(new RBAlbumArt(viewport, x, y, maxWidth,
|
|
|
|
maxHeight, width, height,
|
2010-08-05 08:03:32 +00:00
|
|
|
this, hAlign, vAlign));
|
2010-06-30 19:35:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2010-06-23 20:18:31 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
case 'F':
|
2010-06-23 20:18:31 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
switch(element->tag->name[1])
|
|
|
|
{
|
2010-06-23 20:18:31 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
case 'l':
|
|
|
|
/* %Fl */
|
2010-07-15 06:24:11 +00:00
|
|
|
x = element->params[0].data.number;
|
2010-06-29 05:23:22 +00:00
|
|
|
filename = info.settings()->value("themebase", "") + "/fonts/" +
|
|
|
|
element->params[1].data.text;
|
|
|
|
info.screen()->loadFont(x, new RBFont(filename));
|
|
|
|
return true;
|
2010-06-23 20:18:31 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
}
|
2010-06-23 19:41:30 +00:00
|
|
|
|
2010-06-30 19:35:00 +00:00
|
|
|
return false;
|
2010-06-23 19:41:30 +00:00
|
|
|
|
2010-07-10 06:43:50 +00:00
|
|
|
case 'T':
|
|
|
|
switch(element->tag->name[1])
|
|
|
|
{
|
|
|
|
case '\0':
|
|
|
|
/* %T */
|
|
|
|
if(element->params_count < 5)
|
|
|
|
return false;
|
2010-07-15 06:24:11 +00:00
|
|
|
int x = element->params[0].data.number;
|
|
|
|
int y = element->params[1].data.number;
|
|
|
|
int width = element->params[2].data.number;
|
|
|
|
int height = element->params[3].data.number;
|
2010-07-10 06:43:50 +00:00
|
|
|
QString action(element->params[4].data.text);
|
|
|
|
RBTouchArea* temp = new RBTouchArea(width, height, action, info);
|
2010-07-15 19:04:01 +00:00
|
|
|
x += viewport->x();
|
|
|
|
y += viewport->y();
|
2010-07-10 06:43:50 +00:00
|
|
|
temp->setPos(x, y);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
case 'V':
|
2010-06-23 19:41:30 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
switch(element->tag->name[1])
|
|
|
|
{
|
2010-06-23 19:41:30 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
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;
|
|
|
|
|
2010-07-01 21:49:55 +00:00
|
|
|
case 'p':
|
|
|
|
/* %Vp */
|
2010-07-15 06:24:11 +00:00
|
|
|
viewport->showPlaylist(info, element->params[0].data.number,
|
2010-07-02 05:17:57 +00:00
|
|
|
element->params[1].data.code,
|
|
|
|
element->params[2].data.code);
|
2010-07-01 21:49:55 +00:00
|
|
|
return true;
|
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
case 'I':
|
|
|
|
/* %VI */
|
|
|
|
info.screen()->makeCustomUI(element->params[0].data.text);
|
|
|
|
return true;
|
2010-06-23 19:41:30 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
}
|
2010-06-22 07:55:50 +00:00
|
|
|
|
2010-06-30 19:35:00 +00:00
|
|
|
return false;
|
2010-06-22 07:55:50 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
case 'X':
|
2010-06-22 07:55:50 +00:00
|
|
|
|
2010-06-29 05:23:22 +00:00
|
|
|
switch(element->tag->name[1])
|
|
|
|
{
|
|
|
|
case '\0':
|
|
|
|
/* %X */
|
|
|
|
filename = QString(element->params[0].data.text);
|
2010-07-05 19:02:40 +00:00
|
|
|
if(info.sbsScreen() && info.screen()->parentItem())
|
2010-07-04 01:47:04 +00:00
|
|
|
info.sbsScreen()->setBackdrop(filename);
|
|
|
|
else
|
|
|
|
info.screen()->setBackdrop(filename);
|
2010-06-29 05:23:22 +00:00
|
|
|
return true;
|
2010-06-22 07:55:50 +00:00
|
|
|
}
|
2010-06-29 05:23:22 +00:00
|
|
|
|
2010-06-30 19:35:00 +00:00
|
|
|
return false;
|
2010-06-29 05:23:22 +00:00
|
|
|
|
2010-06-22 07:55:50 +00:00
|
|
|
}
|
2010-06-29 05:23:22 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant ParseTreeNode::evalTag(const RBRenderInfo& info, bool conditional,
|
|
|
|
int branches)
|
|
|
|
{
|
2010-06-29 07:15:41 +00:00
|
|
|
if(!conditional)
|
|
|
|
{
|
2010-08-03 05:47:59 +00:00
|
|
|
if(QString(element->tag->name) == "Sx")
|
|
|
|
return element->params[0].data.text;
|
2010-07-08 06:54:08 +00:00
|
|
|
return info.device()->data(QString(element->tag->name),
|
|
|
|
element->params_count, element->params);
|
2010-06-29 07:15:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* If we're evaluating for a conditional, we return the child branch
|
|
|
|
* index that should be selected. For true/false values, this is
|
|
|
|
* 0 for true, 1 for false, and we also have to make sure not to
|
|
|
|
* ever exceed the number of available children
|
|
|
|
*/
|
|
|
|
|
|
|
|
int child;
|
|
|
|
QVariant val = info.device()->data("?" + QString(element->tag->name));
|
|
|
|
if(val.isNull())
|
2010-07-08 06:54:08 +00:00
|
|
|
val = info.device()->data(QString(element->tag->name),
|
|
|
|
element->params_count, element->params);
|
2010-06-29 07:15:41 +00:00
|
|
|
|
|
|
|
if(val.isNull())
|
|
|
|
{
|
|
|
|
child = 1;
|
|
|
|
}
|
|
|
|
else if(QString(element->tag->name) == "bl")
|
|
|
|
{
|
|
|
|
/* bl has to be scaled to the number of available children, but it
|
|
|
|
* also has an initial -1 value for an unknown state */
|
|
|
|
child = val.toInt();
|
|
|
|
if(child == -1)
|
|
|
|
{
|
|
|
|
child = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
child = ((branches - 1) * child / 100) + 1;
|
|
|
|
}
|
|
|
|
}
|
2010-07-12 06:07:50 +00:00
|
|
|
else if(QString(element->tag->name) == "pv")
|
|
|
|
{
|
|
|
|
/* ?pv gets scaled to the number of available children, sandwiched
|
|
|
|
* in between mute and 0/>0dB. I assume a floor of -50dB for the
|
|
|
|
* time being
|
|
|
|
*/
|
|
|
|
int dB = val.toInt();
|
|
|
|
|
|
|
|
if(dB < -50)
|
|
|
|
child = 0;
|
|
|
|
else if(dB == 0)
|
|
|
|
child = branches - 2;
|
|
|
|
else if(dB > 0)
|
|
|
|
child = branches - 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int options = branches - 3;
|
|
|
|
child = (options * (dB + 50)) / 50;
|
|
|
|
}
|
|
|
|
}
|
2010-06-29 07:15:41 +00:00
|
|
|
else if(QString(element->tag->name) == "px")
|
|
|
|
{
|
|
|
|
child = val.toInt();
|
|
|
|
child = branches * child / 100;
|
|
|
|
}
|
|
|
|
else if(val.type() == QVariant::Bool)
|
|
|
|
{
|
|
|
|
/* Boolean values have to be reversed, because conditionals are
|
|
|
|
* always of the form %?tag<true|false>
|
|
|
|
*/
|
|
|
|
if(val.toBool())
|
|
|
|
child = 0;
|
|
|
|
else
|
|
|
|
child = 1;
|
|
|
|
}
|
|
|
|
else if(val.type() == QVariant::String)
|
|
|
|
{
|
|
|
|
if(val.toString().length() > 0)
|
|
|
|
child = 0;
|
|
|
|
else
|
|
|
|
child = 1;
|
|
|
|
}
|
2010-07-05 19:12:52 +00:00
|
|
|
else if(element->tag->name[0] == 'i' || element->tag->name[0] == 'I'
|
|
|
|
|| element->tag->name[0] == 'f' || element->tag->name[0] == 'F')
|
|
|
|
{
|
|
|
|
if(info.device()->data("id3available").toBool())
|
|
|
|
child = 0;
|
|
|
|
else
|
|
|
|
child = 1;
|
|
|
|
}
|
2010-06-29 07:15:41 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
child = val.toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(child < 0)
|
|
|
|
child = 0;
|
|
|
|
|
|
|
|
if(child < branches)
|
|
|
|
return child;
|
2010-07-29 06:41:33 +00:00
|
|
|
else if(branches == 1)
|
|
|
|
return 2;
|
2010-06-29 07:15:41 +00:00
|
|
|
else
|
|
|
|
return branches - 1;
|
|
|
|
}
|
2010-06-22 07:55:50 +00:00
|
|
|
}
|
2010-06-29 19:59:33 +00:00
|
|
|
|
|
|
|
double ParseTreeNode::findBranchTime(ParseTreeNode *branch,
|
|
|
|
const RBRenderInfo& info)
|
|
|
|
{
|
|
|
|
double retval = 2;
|
|
|
|
for(int i = 0; i < branch->children.count(); i++)
|
|
|
|
{
|
|
|
|
ParseTreeNode* current = branch->children[i];
|
|
|
|
if(current->element->type == TAG)
|
|
|
|
{
|
|
|
|
if(current->element->tag->name[0] == 't'
|
|
|
|
&& current->element->tag->name[1] == '\0')
|
|
|
|
{
|
2010-07-15 06:24:11 +00:00
|
|
|
retval = current->element->params[0].data.number / 10.;
|
2010-06-29 19:59:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(current->element->type == CONDITIONAL)
|
|
|
|
{
|
|
|
|
retval = findConditionalTime(current, info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
double ParseTreeNode::findConditionalTime(ParseTreeNode *conditional,
|
|
|
|
const RBRenderInfo& info)
|
|
|
|
{
|
|
|
|
int child = conditional->evalTag(info, true,
|
|
|
|
conditional->children.count()).toInt();
|
2010-08-05 08:49:34 +00:00
|
|
|
if(child >= conditional->children.count())
|
|
|
|
child = conditional->children.count() - 1;
|
|
|
|
|
2010-06-29 19:59:33 +00:00
|
|
|
return findBranchTime(conditional->children[child], info);
|
|
|
|
}
|
2010-08-04 09:16:52 +00:00
|
|
|
|
|
|
|
void ParseTreeNode::modParam(QVariant value, int index)
|
|
|
|
{
|
|
|
|
if(element)
|
|
|
|
{
|
2010-08-05 19:05:36 +00:00
|
|
|
if(index < 0)
|
2010-08-04 09:16:52 +00:00
|
|
|
return;
|
2010-08-05 19:05:36 +00:00
|
|
|
while(index >= children.count())
|
|
|
|
{
|
|
|
|
/* Padding children with defaults until we make the necessary
|
|
|
|
* parameter available
|
|
|
|
*/
|
|
|
|
skin_tag_parameter* newParam = new skin_tag_parameter;
|
|
|
|
newParam->type = skin_tag_parameter::DEFAULT;
|
|
|
|
/* We'll need to manually delete the extra parameters in the
|
|
|
|
* destructor
|
|
|
|
*/
|
|
|
|
extraParams.append(children.count());
|
|
|
|
|
|
|
|
children.append(new ParseTreeNode(newParam, this, model));
|
|
|
|
element->params_count++;
|
|
|
|
}
|
|
|
|
|
2010-08-04 09:16:52 +00:00
|
|
|
children[index]->modParam(value);
|
|
|
|
}
|
|
|
|
else if(param)
|
|
|
|
{
|
|
|
|
if(value.type() == QVariant::Double)
|
|
|
|
{
|
|
|
|
param->type = skin_tag_parameter::DECIMAL;
|
|
|
|
param->data.number = static_cast<int>(value.toDouble() * 10);
|
|
|
|
}
|
|
|
|
else if(value.type() == QVariant::String)
|
|
|
|
{
|
|
|
|
param->type = skin_tag_parameter::STRING;
|
|
|
|
free(param->data.text);
|
|
|
|
param->data.text = strdup(value.toString().toStdString().c_str());
|
|
|
|
}
|
|
|
|
else if(value.type() == QVariant::Int)
|
|
|
|
{
|
|
|
|
param->type = skin_tag_parameter::INTEGER;
|
|
|
|
param->data.number = value.toInt();
|
|
|
|
}
|
|
|
|
|
2010-08-05 00:43:33 +00:00
|
|
|
model->paramChanged(this);
|
|
|
|
|
2010-08-04 09:16:52 +00:00
|
|
|
}
|
|
|
|
}
|