Ejemplo n.º 1
0
boost::shared_ptr<tcGeometry> tcContainerSlot::GetIcon()
{
    if (item == 0)
    {
        boost::shared_ptr<tcGeometry> nullIcon((tcGeometry*)0);
        return nullIcon;
    }
    else if (!useSmallIcon)
    {
        return item->GetIcon();
    }
    else
    {
        return item->GetIconSmall();
    }
}
Ejemplo n.º 2
0
/**
* If slot has tcStoresContainerItem then update it, otherwise create
* a new item for slot.
*/
void tcStoresGui::AddOrUpdateItem(tcContainerSlot& slot, const std::string& itemName,
                      unsigned int quantity, bool isMoving, unsigned int itemId, tcStores* stores)
{
	wxASSERT(stores);

    tcStoresContainerItem* item = dynamic_cast<tcStoresContainerItem*>(slot.GetItem());
   
    if (item == 0)
    {
        item = new tcStoresContainerItem();    
		slot.SetItem(item);
    }
 
    tcDatabaseObject* databaseObject = 0;
    if (!isMoving)
    {
        databaseObject = stores->GetDatabaseObjectForItem(itemName);
    }
    else
    {
        databaseObject = tcDatabase::Get()->GetObject(itemName);
    }
    
    
    if (databaseObject)
    {
	    boost::shared_ptr<tcGeometry> icon = databaseObject->GetIcon();
        item->SetIcon(icon);
		item->SetId(itemId);
	    item->SetItemName(itemName);
	    item->SetQuantity(quantity);
		item->SetStores(platformId, hostId, storesIdx);        
        item->SetMoving(isMoving);
        item->SetOpId(itemId);
        item->SetGui(this); // be careful with this! see ~tcContainerItem APR2009 was wiping out parentItem reference
        if (isMoving) item->SetDrawState(tcContainerItem::BLINK);
        else item->SetDrawState(tcContainerItem::NORMAL);
    }
    else
    {
        boost::shared_ptr<tcGeometry> nullIcon((tcGeometry*)0);
        item->SetIcon(nullIcon);
        wxASSERT(false);
    }

}
Ejemplo n.º 3
0
AddContentWindow::AddContentWindow(const ScenePtr &dest, QWidget *parent) :
    QWidget(parent),
    framework(dest->GetFramework()),
    scene(dest),
    position(float3::zero),
    uploadProgressStep(0),
    numFailedUploads(0),
    numSuccessfulUploads(0),
    numTotalUploads(0)
{
    setWindowModality(Qt::ApplicationModal/*Qt::WindowModal*/);
    setAttribute(Qt::WA_DeleteOnClose);
    setWindowTitle(tr("Entity And Asset Import"));

    QPixmap nullIcon(16,16); // do a null icon to hide the default ugly one
    nullIcon.fill(Qt::transparent);
    setWindowIcon(nullIcon);

    setStyleSheet(
        "QProgressBar {"
            "border: 1px solid grey; border-radius: 0px; text-align: center; background-color: rgb(244, 244, 244);"
        "}"
        "QProgressBar::chunk {"
            "background-color: qlineargradient(spread:pad, x1:0.028, y1:1, x2:0.972, y2:1, stop:0 rgba(194, 194, 194, 100), stop:1 rgba(115, 115, 115, 100));"
        "}"
    );

    QFont titleFont("Arial", 11);
    titleFont.setBold(true);

    QVBoxLayout *layout = new QVBoxLayout();
    layout->setContentsMargins(5, 5, 5, 5);
    setLayout(layout);

    // Entities ui
    entityView = new QWidget(this);
    QVBoxLayout *entitiesLayout = new QVBoxLayout();
    entitiesLayout->setContentsMargins(0, 0, 0, 0);
    entityView->setLayout(entitiesLayout);

    QLabel *entityLabel = new QLabel(tr("Entities"), this);
    entityLabel->setFont(titleFont);
    entityLabel->setStyleSheet("color: rgb(63, 63, 63);");

    entityTreeWidget = new EntityAndAssetTreeWidget(this);
    entityTreeWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
    entityTreeWidget->setColumnCount(3);
    entityTreeWidget->setHeaderLabels(QStringList(QStringList() << tr("Create") << tr("ID") << tr("Name")));
    entityTreeWidget->header()->setResizeMode(QHeaderView::ResizeToContents);

    QPushButton *selectAllEntitiesButton = new QPushButton(tr("Select All"));
    QPushButton *deselectAllEntitiesButton = new QPushButton(tr("Deselect All"));
    QHBoxLayout *entityButtonsLayout = new QHBoxLayout;
    QSpacerItem *entityButtonSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    QSpacerItem *middleSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed);

    QVBoxLayout *entitiesProgressLayout = new QVBoxLayout();
    entityStatusLabel = new QLabel(this);
    entityProgressBar = new QProgressBar(this);
    entityProgressBar->setFixedHeight(20);

    entitiesLayout->addWidget(entityLabel);
    entitiesLayout->addLayout(entitiesProgressLayout);
    entitiesLayout->addWidget(entityTreeWidget);
    entitiesProgressLayout->addWidget(entityStatusLabel);
    entitiesProgressLayout->addWidget(entityProgressBar);
    entityButtonsLayout->addWidget(selectAllEntitiesButton);
    entityButtonsLayout->addWidget(deselectAllEntitiesButton);
    entityButtonsLayout->addSpacerItem(entityButtonSpacer);
    //entitiesLayout->insertLayout(-1, entitiesProgressLayout);
    entitiesLayout->insertLayout(-1, entityButtonsLayout);
    entitiesLayout->insertSpacerItem(-1, middleSpacer);
    layout->addWidget(entityView);

    // Assets ui
    assetView = new QWidget(this);
    QVBoxLayout *assetsLayout = new QVBoxLayout();
    assetsLayout->setContentsMargins(0, 0, 0, 0);
    assetView->setLayout(assetsLayout);

    QLabel *assetLabel = new QLabel(tr("Assets"), this);
    assetLabel->setFont(titleFont);
    assetLabel->setStyleSheet("color: rgb(63, 63, 63);");

    assetTreeWidget = new EntityAndAssetTreeWidget(this);
    assetTreeWidget->setColumnCount(5);
    QStringList labels;
    labels << tr("Upload") << tr("Type") << tr("Source name") << tr("Source subname") << tr("Destination name");
    assetTreeWidget->setHeaderLabels(labels);

    QPushButton *selectAllAssetsButton = new QPushButton(tr("Select All"), this);
    QPushButton *deselectAllAssetsButton = new QPushButton(tr("Deselect All"), this);
    QHBoxLayout *assetButtonsLayout = new QHBoxLayout(this);
    QSpacerItem *assetButtonSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    QLabel *storageLabel = new QLabel(tr("Asset storage:"), this);
    storageComboBox = new QComboBox(this);

    QVBoxLayout *uploadLayout = new QVBoxLayout();
    uploadStatusLabel = new QLabel(this);
    uploadProgressBar = new QProgressBar(this);
    uploadProgressBar->setFixedHeight(20);

    GenerateStorageComboBoxContents();

    uploadLayout->addWidget(uploadStatusLabel);
    uploadLayout->addWidget(uploadProgressBar);

    assetsLayout->addWidget(assetLabel);
    assetsLayout->addLayout(uploadLayout);
    assetsLayout->addWidget(assetTreeWidget);

    assetButtonsLayout->addWidget(selectAllAssetsButton);
    assetButtonsLayout->addWidget(deselectAllAssetsButton);
    assetButtonsLayout->addSpacerItem(assetButtonSpacer);
    assetButtonsLayout->addWidget(storageLabel);
    assetButtonsLayout->addWidget(storageComboBox);
    assetsLayout->insertLayout(-1, assetButtonsLayout);
    layout->addWidget(assetView);

    uploadStatusLabel->hide();
    uploadProgressBar->hide();
    entityStatusLabel->hide();
    entityProgressBar->hide();

    // General controls
    addContentButton = new QPushButton(tr("Add content"), this);
    cancelButton = new QPushButton(tr("Cancel"), this);

    QHBoxLayout *buttonsLayout = new QHBoxLayout();
    QSpacerItem *buttonSpacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    buttonsLayout->addSpacerItem(buttonSpacer);
    buttonsLayout->addWidget(addContentButton);
    buttonsLayout->addWidget(cancelButton);
    layout->insertLayout(-1, buttonsLayout);

    resize(800, 400);

    connect(addContentButton, SIGNAL(clicked()), SLOT(AddContent()));
    connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
    connect(selectAllEntitiesButton, SIGNAL(clicked()), SLOT(SelectAllEntities()));
    connect(deselectAllEntitiesButton, SIGNAL(clicked()), SLOT(DeselectAllEntities()));
    connect(selectAllAssetsButton, SIGNAL(clicked()), SLOT(SelectAllAssets()));
    connect(deselectAllAssetsButton, SIGNAL(clicked()), SLOT(DeselectAllAssets()));
    connect(assetTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), SLOT(CheckIfColumnIsEditable(QTreeWidgetItem *, int)));
    connect(storageComboBox, SIGNAL(currentIndexChanged(int)), SLOT(RewriteDestinationNames()));

    // If we saved recently used storage, and the storage exists in the current combo box, set it as current index.
    ConfigData configData(ConfigAPI::FILE_FRAMEWORK, cAddContentDialogSetting, cRecentStorageSetting, "", "");
    QString storageName = framework->Config()->Get(configData).toString();
    if (!storageName.isEmpty())
        for(int i = 0; i < storageComboBox->count(); ++i)
            if (storageComboBox->itemData(i) == storageName)
            {
                storageComboBox->setCurrentIndex(i);
                break;
            }

    connect(this, SIGNAL(AssetUploadCompleted(const AssetStoragePtr &, int, int)), SLOT(CreateEntities()));
}