Beispiel #1
0
void Tile::decrementHealth(int amount)
{
	if (isDestructable_ == false)
		if (amount > 0)
			return;

	health.damage(amount);

	if (health.getHealthRef() <= 0)
	{
		if (isWall_)
		{
			isWall_ = false;
			setGraphic(TG_StoneFloor);
			setColor(TGC_StoneFloor);
			setBackground(TGB_StoneFloor);
			isWalkable_ = true;
			isDestructable_ = true;
			isClaimable(true);
		}
		health.getHealthRef() = health.getMaxHealthRef();
	}
	else if (health.getHealthRef() > health.getMaxHealthRef())
	{
		health.getHealthRef() = health.getMaxHealthRef();
	}
	game::server.UpdateTile(pos_.getX(), pos_.getY());
}
Beispiel #2
0
GuiStatusBar::GuiStatusBar(const Context& context) : GuiStaticGraphicElement(context), textElement(context) {
    const IGraphic* backgroundGraphic = context.graphicsMgr->getGraphicSet("statusbar")->getStatic()->getGraphic();
    setPosition(0, 734);
    setGraphic(backgroundGraphic);

    constexpr int paddingX = 15;
    textElement.setCoords(paddingX, 0, backgroundGraphic->getWidth() - 2*paddingX, backgroundGraphic->getHeight());
    textElement.setColor(&Color::white);
    textElement.setFontName("DroidSans-Bold.ttf");
    textElement.setFontSize(14);
    textElement.setAlign(RENDERTEXT_HALIGN_RIGHT | RENDERTEXT_VALIGN_MIDDLE);

    addChildElement(&textElement);
}
Beispiel #3
0
GuiPanelHeader::GuiPanelHeader(const Context& context) : GuiStaticGraphicElement(context) {
    // Größe ist fix
    width = 248;
    height = 40;

    setGraphic(context.graphicsMgr->getGraphicSet("panel-header")->getStatic()->getGraphic());

    textElement = new GuiStaticTextElement(context);
    textElement->setCoords(35, 10, 178, 18);
    textElement->setColor(&Color::lightBrown);
    textElement->setShadowColor(&Color::black);
    textElement->setFontName("DroidSans-Bold.ttf");
    textElement->setFontSize(14);
    textElement->setAlign(RENDERTEXT_HALIGN_CENTER | RENDERTEXT_VALIGN_MIDDLE);

    addChildElement(textElement);
}
Beispiel #4
0
RFile::RFile(const std::string & name, const vec3 & colour, const vec2 & pos, int tagid) : Pawn(name,pos,tagid) {
    hidden = true;
    size = gGourceFileDiameter * 1.05;
    radius = size * 0.5;

    setGraphic(gGourceSettings.file_graphic);

    speed = 5.0;
    nametime = 4.0;
    name_interval = nametime;

    namecol     = vec3(1.0, 1.0, 1.0);
    file_colour = colour;

    last_action    = 0.0f;
    fade_start     = -1.0f;
    expired        = false;
    forced_removal = false;

    shadow = true;

    distance = 0;

    setFilename(name);

    if(!file_selected_font.initialized()) {
        file_selected_font = fontmanager.grab("FreeSans.ttf", 18);
        file_selected_font.dropShadow(true);
        file_selected_font.roundCoordinates(false);
        file_selected_font.setColour(vec4(gGourceSettings.selection_colour, 1.0f));
    }

    if(!file_font.initialized()) {
        file_font = fontmanager.grab("FreeSans.ttf", 14);
        file_font.dropShadow(true);
        file_font.roundCoordinates(false);
        file_font.setColour(vec4(1.0f, 1.0f, 1.0f, 1.0f));
    }

    //namelist = glGenLists(1);
    //label = 0;
    setSelected(false);

    dir = 0;
}
void CompareSideBySideView::setupItem(DiffSingleNodeResult *node, QTreeWidgetItem *currentNodeItem, const bool isReference, QList<QTreeWidgetItem*> &itemsList, QList<DiffInfo*> &diffList, const bool isChildrenBlocked)
{
    SourceElementDiffOperation *sourceRef = node->referenceElement();
    SourceElementDiffOperation *compareRef = node->compareElement();
    SourceElementDiffOperation *source = getSource(node, isReference);
    bool isEmpty = isNodeEmpty(node, isReference);
    QString text = getText(source, node->type(), isEmpty);
    setGraphic(currentNodeItem, node->type(), isEmpty) ;

    currentNodeItem->setText(0, text);

    if(node->hasAttributes()) {
        QTreeWidgetItem *attributeTextItem = newTreeItem(itemsList);
        if(isReference) {
            DiffInfo *info = NULL ;
            // if blocked, use the last item
            if(isChildrenBlocked) {
                info = diffList.at(diffList.size() - 1);
            }
            setLastItemDiff(isReference, itemsList, diffList, info);
        }
        if(!isEmpty) {
            //attributeTextItem->setBackgroundColor(0, colo);aaa
            attributeTextItem->setBackgroundColor(0, currentNodeItem->backgroundColor(0));
            attributeTextItem->setText(0, tr("Attributes:"));
        } else {
            attributeTextItem->setBackgroundColor(0, _chrome.emptyColor());
        }
        currentNodeItem->addChild(attributeTextItem);

        // added only if it is the reference
        bool emptyAddedAttributes = !isReference || isEmpty ;
        bool emptyDeletedAttributes = isReference || isEmpty ;

        if(NULL != sourceRef) {
            appendAttributes(node, attributeTextItem, EDiff::ED_ADDED, isReference, emptyAddedAttributes, sourceRef->addedAttributes(), itemsList, diffList, isChildrenBlocked);
        }
        appendAttributes(node, attributeTextItem, EDiff::ED_MODIFIED, isReference, isEmpty, source->modifiedAttributes(), itemsList, diffList, isChildrenBlocked);
        appendAttributes(node, attributeTextItem, EDiff::ED_EQUAL, isReference, isEmpty, node->equalsAttributes(), itemsList, diffList, isChildrenBlocked);

        if(NULL != compareRef) {
            appendAttributes(node, attributeTextItem, EDiff::ED_DELETED, isReference, emptyDeletedAttributes, compareRef->addedAttributes(), itemsList, diffList, isChildrenBlocked);
        }
    }
}
Beispiel #6
0
void Tile::mine(int damage, Player& underlord)
{
	if (isWall_ == false)
		return;

	if (isDestructable_ == false)
		if (damage > 0)
			return;

	health.getHealthRef() -= damage;

	if (health.getHealthRef() <= 0)
	{
		isWall_ = false;
		setGraphic(TG_StoneFloor);
		setColor(TGC_StoneFloor);
		setBackground(TGB_StoneFloor);
		isWalkable_ = true;
		isDestructable_ = false;
		isClaimable_ = true;;
		canFlyOver_ = true;
		health.getMaxHealthRef() = 100;

		if (hasGold_)
		{
			underlord.addGold(gold_);
			hasGold_ = false;
			gold_ = 0;
		}

		health.getHealthRef() = health.getMaxHealthRef();
	}
	else if (health.getHealthRef() > health.getMaxHealthRef())
	{
		health.getHealthRef() = health.getMaxHealthRef();
	}
	updateTile(pos_);
}
Beispiel #7
0
RFile::RFile(const std::string & name, const vec3f & colour, const vec2f & pos, int tagid) : Pawn(name,pos,tagid) {
    hidden = true;
    size = gGourceFileDiameter;
    radius = size * 0.5;

    setGraphic(gGourceSettings.file_graphic);

    speed = 5.0;
    nametime = 4.0;
    name_interval = nametime;

    namecol     = vec3f(1.0, 1.0, 1.0);
    file_colour = colour;

    last_action = 0.0;
    expiring=false;
    removing=false;

    shadow = true;

    distance = 0;

    this->fullpath = name;
    this->name = name;

    path_hash = 0;

    setPath();

    namelist = glGenLists(1);

    font = 0;
    setSelected(false);

    dir = 0;

    if(path.size()) path_hash = stringHash(path);
}
Beispiel #8
0
    MySymbol( QwtSymbol::Style style, const QBrush &brush )
    {
        QPen pen( Qt::black, 0 );
        pen.setJoinStyle( Qt::MiterJoin );
        pen.setCosmetic( true );

        QPainterPath path = createArrow( QSize( 16, 24 ) );

        const QSizeF pathSize = path.boundingRect().size();

        setSize( 0.8 * pathSize.toSize() );

        setPinPoint( QPointF( 0.0, 0.0 ) );

        switch( style )
        {
            case QwtSymbol::Pixmap:
            {
                const QSize sz = size();

                const double ratio = qMin( sz.width() / pathSize.width(),
                    sz.height() / pathSize.height() );

                QTransform transform;
                transform.scale( ratio, ratio );

                path = transform.map( path );

                if ( isPinPointEnabled() )
                {
                    QPointF pos = transform.map( pinPoint() );
                    setPinPoint( pos );
                }

                const QRectF br = path.boundingRect();

                int m = 2 + qCeil( pen.widthF() );

                QPixmap pm( sz + QSize( 2 * m, 2 * m ) );
                pm.fill( Qt::transparent );

                QPainter painter( &pm );
                painter.setRenderHint( QPainter::Antialiasing, true );
                
                painter.setPen( pen ); 
                painter.setBrush( brush );

                painter.translate( m, m );
                painter.translate( -br.left(), br.top() );
                painter.drawPath( path );
                
                setPixmap( pm );
                setSize( pm.size() );
                if ( isPinPointEnabled() )
                    setPinPoint( pinPoint() + QPointF( m, m ) );

                break;
            }
            case QwtSymbol::Graphic:
            {
                QwtGraphic graphic;
                graphic.setRenderHint( QwtGraphic::RenderPensUnscaled );
        
                QPainter painter( &graphic );
                painter.setRenderHint( QPainter::Antialiasing, true );
                painter.setPen( pen ); 
                painter.setBrush( brush );
        
                painter.drawPath( path );
                painter.end();
        
                setGraphic( graphic );
                break;
            }
            case QwtSymbol::SvgDocument:
            {
                QBuffer buf;

                QSvgGenerator generator;
                generator.setOutputDevice( &buf );

                QPainter painter( &generator );
                painter.setRenderHint( QPainter::Antialiasing, true );
                painter.setPen( pen );
                painter.setBrush( brush );

                painter.drawPath( path );
                painter.end();

                setSvgDocument( buf.data() );
                break;
            }
            case QwtSymbol::Path:
            default:
            {
                setPen( pen );
                setBrush( brush );
                setPath( path );
            }
        }

    }