void AssetsWindow::AddAsset(AssetPtr asset) { ///\todo Check that the asset doesn't already exists AssetItem *item = new AssetItem(asset); AddChildren(asset, item); connect(asset.get(), SIGNAL(Loaded(AssetPtr)), SLOT(HandleAssetLoaded(AssetPtr))); connect(asset.get(), SIGNAL(Unloaded(IAsset *)), SLOT(HandleAssetUnloaded(IAsset *))); bool storageFound = false; AssetStoragePtr storage = asset->GetAssetStorage(); if (storage) for(int i = 0; i < treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem *storageItem = treeWidget->topLevelItem(i); if (storageItem->text(0) == storage->ToString()) { storageItem->addChild(item); storageFound = true; break; } } if (!storageFound) noProviderItem->addChild(item); noProviderItem->setHidden(noProviderItem->childCount() == 0); }
static duk_ret_t IAsset_AssetStorage(duk_context* ctx) { IAsset* thisObj = GetThisWeakObject<IAsset>(ctx); AssetStoragePtr ret = thisObj->AssetStorage(); PushWeakObject(ctx, ret.Get()); return 1; }
AssetStoragePtr HttpAssetProvider::TryCreateStorage(HashMap<String, String> &storageParams, bool fromNetwork) { if (!storageParams.Contains("src") || !IsValidRef(storageParams["src"], "")) return AssetStoragePtr(); if (storageParams.Contains("type") && storageParams["type"].Compare("HttpAssetStorage", false) != 0) return AssetStoragePtr(); String baseUrl = storageParams["src"]; if (!baseUrl.EndsWith("/") && baseUrl.Contains("/")) baseUrl = baseUrl.Substring(0, baseUrl.FindLast('/')+1); if (!baseUrl.EndsWith("/")) return AssetStoragePtr(); String name = UniqueName(storageParams["name"]); // @todo liveupdate, liveupload, autodiscoverable etc. when actually needed AssetStoragePtr storage = StorageForBaseURL(baseUrl); if (!storage) { storage = AssetStoragePtr(new HttpAssetStorage(framework_->GetContext(), name, baseUrl, storageParams["localdir"])); httpStorages_.Push(storage); } storage->SetReplicated(Urho3D::ToBool(storageParams["replicated"])); return storage; }
bool IAsset::IsTrusted() const { AssetStoragePtr storage = GetAssetStorage(); if (!storage) { AssetAPI::AssetRefType type = AssetAPI::ParseAssetRef(Name()); return type == AssetAPI::AssetRefLocalPath || type == AssetAPI::AssetRefLocalUrl; } return storage->Trusted(); }
void ColladaViewerModule::storageAdded(AssetStoragePtr storage) { if(storage->Type() == "HttpAssetStorage" && storage->Name() == "colladaStorage"){ remoteStorage_ = storage; LogInfo("Added a remote collada storage: " + remoteStorage_->ToString()); // Listening for assets changes in the remote storage bool check = connect(remoteStorage_.get(), SIGNAL(AssetChanged(QString,QString,IAssetStorage::ChangeType)), this, SLOT(remoteAssetChanged(QString,QString,IAssetStorage::ChangeType)), Qt::QueuedConnection); Q_ASSERT(check); //Getting all the asset refs from remote storage remoteStorage_->RefreshAssetRefs(); } }
AssetUploadTransferPtr HttpAssetProvider::UploadAssetFromFileInMemory(const u8 *data, size_t numBytes, AssetStoragePtr destination, const char *assetName) { QString dstUrl = destination->GetFullAssetURL(assetName); QNetworkRequest request; request.setUrl(QUrl(dstUrl)); request.setRawHeader("User-Agent", "realXtend Naali"); QByteArray dataArray((const char*)data, numBytes); QNetworkReply *reply = networkAccessManager->put(request, dataArray); AssetUploadTransferPtr transfer = AssetUploadTransferPtr(new IAssetUploadTransfer()); transfer->destinationStorage = destination; transfer->destinationProvider = shared_from_this(); transfer->destinationName = assetName; uploadTransfers[reply] = transfer; return transfer; }
AssetStorageItem::AssetStorageItem(const AssetStoragePtr &storage, QTreeWidgetItem *parent) : QTreeWidgetItem(parent), assetStorage(storage) { setText(0, storage->ToString() + (!storage->Writable() ? QApplication::translate("AssetStorageItem", " (Read-only)") : QString())); }