예제 #1
0
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;
}
예제 #2
0
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();
}
예제 #3
0
AssetStoragePtr HttpAssetProvider::StorageByName(const String &name) const
{
    foreach(const AssetStoragePtr &httpStorage, httpStorages_)
    {
        if (httpStorage->Name() == name)
            return httpStorage;
    }
    return AssetStoragePtr();
}
예제 #4
0
AssetStoragePtr AssetBundleItem::Storage() const
{
    if (assetBundle.expired())
        return AssetStoragePtr();
    return assetBundle.lock()->AssetStorage();
}