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; }
AssetStoragePtr HttpAssetProvider::StorageForAssetRef(const String &assetRef) const { if (!IsValidRef(assetRef, "")) return AssetStoragePtr(); foreach(const AssetStoragePtr &httpStorage, httpStorages_) { if (assetRef.StartsWith(httpStorage->BaseURL(), true)) return httpStorage; } return AssetStoragePtr(); }
AssetStoragePtr HttpAssetProvider::StorageByName(const String &name) const { foreach(const AssetStoragePtr &httpStorage, httpStorages_) { if (httpStorage->Name() == name) return httpStorage; } return AssetStoragePtr(); }
AssetStoragePtr AssetBundleItem::Storage() const { if (assetBundle.expired()) return AssetStoragePtr(); return assetBundle.lock()->AssetStorage(); }