Example #1
0
QGraphicsItem* CGraphicsTextItem::createItem()
{
	QGraphicsSimpleTextItem* pItem = new QGraphicsSimpleTextItem(m_Parent);
	QFont font;
	//字体宽度
	font.setWeight(GET_VALUE(p_FontWidth).toInt());
	//字体大小
	font.setPixelSize(GET_VALUE(fs).toInt());
	//字间距
	font.setWordSpacing(GET_VALUE(p_FontInterval).toInt());
	//字体高度
	//字体类型
	QString strFamily(GET_VALUE(ff));

	if (!strFamily.isEmpty())
	{
		font.setFamily(strFamily);
	}

	pItem->setFont(font);

	//字体颜色
	QPen pen;
	QStringList lstLc = GET_VALUE(lc).split(',');
	pen.setColor(QColor::fromRgb(lstLc[0].toInt(),lstLc[1].toInt(),lstLc[2].toInt()));
	pItem->setPen(pen);

	pItem->setText(GET_VALUE(ts));
	return pItem;

}
Example #2
0
asd::Waypoint* asd::Waypoint::Builder::build() {
    asd::Waypoint *waypoint = new asd::Waypoint;

    //
    // Properties
    //

    waypoint->setPen(properties_.pen());
    waypoint->setBrush(properties_.brush());
    waypoint->setZValue(properties_.zlayer());

    qreal size = properties_.size();
    waypoint->setRect(-size/2, -size/2, size, size);

    if (!name_.isEmpty()) {
        QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem(waypoint);
        text->setPen(Qt::NoPen);
        text->setBrush(properties_.pen().brush());

        text->setText(name_);
    }

    waypoint->setPos(location_);

    return waypoint;
}
Example #3
0
GameProcessor::GameProcessor(YagwScene &ygws)
  : scene(ygws),
    player(0),
    disclaimer(0),
    gia(*this, ygws.width(), ygws.height(), player),
    cfg(ConfManager("config.cfg")),
    playerFire(0)
{
    QObject::connect(&scene, SIGNAL(newEntity(Entity*)), this, SLOT(loadEntity(Entity*)));
    QObject::connect(&scene, SIGNAL(newFire(Entity*)), this, SLOT(loadFire(Entity*)));
    QObject::connect(&scene, SIGNAL(phase2()), this, SLOT(advance()));
    GameProcessor::affDelimiters();
    QObject::connect(&scene, SIGNAL(forwardKeyPressEvent(QKeyEvent*)), this, SLOT(keyPressEvent(QKeyEvent*)));
    GameProcessor::createDisclaimer("Press RETURN to start");


    QGraphicsSimpleTextItem *txt = this->scene.addSimpleText("Lives:");
// attention on perd le pointeur. a changer.
    QFont font;
    QPen pen(Qt::red, 1, Qt::DashLine, Qt::RoundCap, Qt::RoundJoin);
    font.setBold(true);
    font.setPointSize(20);
    txt->setFont(font);
    txt->setBrush(Qt::red);
    txt->setPen(pen);
    txt->setPos(WINSIZE_X / 2  + 5,- WINSIZE_Y / 2 + 10);
    QString str("Score:\n");
    str += QString::number(Score::get_instance()->getScore()) + QString::fromAscii("\nMax:\n") + QString::number(Score::get_instance()->getMax());
    txt = this->scene.addSimpleText(str);
    txt->setFont(font);
    txt->setBrush(Qt::red);
    txt->setPen(pen);
    txt->setPos(WINSIZE_X / 2  + 5,- WINSIZE_Y / 2 + 200);
    this->score = txt;
    //GameProcessor::affGrid();
}