示例#1
0
bool Window::unlinkFrom(shared_ptr<BaseObject> obj)
{
    if (dynamic_pointer_cast<Texture>(obj).get() != nullptr)
    {
        TexturePtr tex = dynamic_pointer_cast<Texture>(obj);
        unsetTexture(tex);
    }
    else if (dynamic_pointer_cast<Image>(obj).get() != nullptr)
    {
        // Look for the corresponding texture
        string texName = getName() + "_" + obj->getName() + "_tex";
        TexturePtr tex = nullptr;
        for (auto& inTex : _inTextures)
        {
            if (inTex.expired())
                continue;
            auto lockedTex = inTex.lock();
            if (lockedTex->getName() == texName)
                tex = lockedTex;
        }
        if (tex != nullptr)
        {
            tex->unlinkFrom(obj);
            unsetTexture(tex);
        }
    }
    else if (dynamic_pointer_cast<Camera>(obj).get() != nullptr)
    {
        CameraPtr cam = dynamic_pointer_cast<Camera>(obj);
        for (auto& tex : cam->getTextures())
            unsetTexture(tex);
    }
    else if (dynamic_pointer_cast<Gui>(obj).get() != nullptr)
    {
        GuiPtr gui = dynamic_pointer_cast<Gui>(obj);
        if (gui->getTexture() == _guiTexture)
        {
            _screenGui->removeTexture(_guiTexture);
            _guiTexture = nullptr;
        }
    }

    return BaseObject::unlinkFrom(obj);
}
示例#2
0
文件: base.c 项目: flavioheleno/otd
void drawBase() {
	//muda para o modelview (altera apenas o desenho e não as coordenadas)
	glMatrixMode(GL_MODELVIEW);
	//garantir que o desenho seja com relação ao sistema de coordenadas
	glLoadIdentity();
	//move a base para o ponto correto
	glTranslated((home.position.x - (home.dimension.w / 2)), (home.position.y - (home.dimension.h / 2)), 0);
	//desenha a base
	setTexture(home.view.id);
	drawTexture(home.view.width, home.view.height);
	unsetTexture();
}
示例#3
0
static PyObject* pyUnsetTexture(PyObject *self) {
	unsetTexture();
	Py_RETURN_NONE;
}
示例#4
0
/* QGUISkin */
QGUISkin::QGUISkin(plCreatable* pCre, QWidget* parent)
        : QCreatable(pCre, kGUISkin, parent), fCurElement(-1)
{
    pfGUISkin* skin = pfGUISkin::Convert(fCreatable);

    fItemMargin = new QIntEdit(this);
    fItemMargin->setRange(0, 0xFFFF);
    fItemMargin->setValue(skin->getItemMargin());

    fBorderMargin = new QIntEdit(this);
    fBorderMargin->setRange(0, 0xFFFF);
    fBorderMargin->setValue(skin->getBorderMargin());

    fTexture = new QCreatableLink(this);
    fTexture->setKey(skin->getTexture());

    fElements = new QComboBox(this);
    fElements->addItems(QStringList() << tr("Upper-Left Corner") << tr("Top Span")
                                      << tr("Upper-Right Corner") << tr("Right Span")
                                      << tr("Lower-Right Corner") << tr("Bottom Span")
                                      << tr("Lower-Left Corner") << tr("Left Span")
                                      << tr("Middle Fill") << tr("Selection Fill")
                                      << tr("Submenu Arrow") << tr("Selected Submenu Arrow")
                                      << tr("Tree Button Closed") << tr("Tree Button Open"));

    QGroupBox* grpElement = new QGroupBox(tr("Element Texture Source"), this);
    fX = new QIntEdit(grpElement);
    fX->setRange(0, 0xFFFF);
    fY = new QIntEdit(grpElement);
    fY->setRange(0, 0xFFFF);
    fWidth = new QIntEdit(grpElement);
    fWidth->setRange(0, 0xFFFF);
    fHeight = new QIntEdit(grpElement);
    fHeight->setRange(0, 0xFFFF);
    setElement(0);
    QGridLayout* layElement = new QGridLayout(grpElement);
    layElement->setContentsMargins(8, 8, 8, 8);
    layElement->setHorizontalSpacing(4);
    layElement->setVerticalSpacing(4);
    layElement->addWidget(new QLabel("X", grpElement), 0, 1, 1, 1, Qt::AlignCenter);
    layElement->addWidget(new QLabel("Y", grpElement), 0, 2, 1, 1, Qt::AlignCenter);
    layElement->addWidget(new QLabel("Position:", grpElement), 1, 0);
    layElement->addWidget(new QLabel("Size:", grpElement), 2, 0);
    layElement->addWidget(fX, 1, 1);
    layElement->addWidget(fY, 1, 2);
    layElement->addWidget(fWidth, 2, 1);
    layElement->addWidget(fHeight, 2, 2);

    QGridLayout* layout = new QGridLayout(this);
    layout->setContentsMargins(8, 8, 8, 8);
    layout->addWidget(new QLabel(tr("Item Margin:"), this), 0, 0);
    layout->addWidget(fItemMargin, 0, 1);
    layout->addWidget(new QLabel(tr("Border:"), this), 1, 0);
    layout->addWidget(fBorderMargin, 1, 1);
    layout->addWidget(new QLabel(tr("Texture:"), this), 2, 0);
    layout->addWidget(fTexture, 2, 1);
    layout->addItem(new QSpacerItem(0, 16, QSizePolicy::Minimum, QSizePolicy::Minimum), 3, 0, 1, 2);
    layout->addWidget(new QLabel(tr("Element:"), this), 4, 0);
    layout->addWidget(fElements, 4, 1);
    layout->addWidget(grpElement, 5, 0, 1, 2);

    connect(fTexture, SIGNAL(addObject()), this, SLOT(setTexture()));
    connect(fTexture, SIGNAL(delObject()), this, SLOT(unsetTexture()));
    connect(fElements, SIGNAL(currentIndexChanged(int)), this, SLOT(setElement(int)));
}