This commit is contained in:
parent
27b38ed250
commit
f189469926
@ -50,7 +50,6 @@ void SceneEditorImGui::onActivated() noexcept {
|
||||
ox::Error SceneEditorImGui::saveItem() noexcept {
|
||||
const auto sctx = applicationData<studio::StudioContext>(m_ctx);
|
||||
oxReturnError(sctx->project->writeObj(itemPath(), m_editor.scene()));
|
||||
oxReturnError(keelCtx(m_ctx).assetManager.setAsset(itemPath(), m_editor.scene()));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -212,28 +212,6 @@ class AssetManager {
|
||||
return AssetRef<T>(out->get());
|
||||
}
|
||||
|
||||
ox::Result<AssetRef<T>> setAsset(ox::StringView const assetId, T const&obj) noexcept {
|
||||
auto &p = m_cache[assetId];
|
||||
if (!p) {
|
||||
p = ox::make_unique<AssetContainer<T>>(obj);
|
||||
} else {
|
||||
p->set(obj);
|
||||
p->updated.emit();
|
||||
}
|
||||
return AssetRef<T>(p.get());
|
||||
}
|
||||
|
||||
ox::Result<AssetRef<T>> setAsset(ox::StringView const assetId, T &&obj) noexcept {
|
||||
auto &p = m_cache[assetId];
|
||||
if (!p) {
|
||||
p = ox::make_unique<AssetContainer<T>>(obj);
|
||||
} else {
|
||||
p->set(std::move(obj));
|
||||
p->updated.emit();
|
||||
}
|
||||
return AssetRef<T>(p.get());
|
||||
}
|
||||
|
||||
ox::Result<AssetRef<T>> loadAsset(ox::StringView const assetId) noexcept {
|
||||
auto &p = m_cache[assetId];
|
||||
oxRequireM(obj, m_loader(assetId));
|
||||
@ -303,13 +281,6 @@ class AssetManager {
|
||||
return m->getAsset(assetId);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ox::Result<AssetRef<T>> setAsset(ox::StringView assetId, T const&obj) noexcept {
|
||||
oxRequire(m, getTypeManager<T>());
|
||||
oxReturnError(m->setAsset(assetId, obj));
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error reloadAsset(ox::StringView assetId) noexcept {
|
||||
m_fileTrackers[assetId].updated.emit(assetId);
|
||||
return {};
|
||||
|
@ -129,28 +129,6 @@ ox::Result<keel::AssetRef<T>> readObjNoCache(
|
||||
|
||||
ox::Error reloadAsset(keel::Context &ctx, ox::StringView assetId) noexcept;
|
||||
|
||||
template<typename T>
|
||||
ox::Result<AssetRef<T>> setAsset(
|
||||
keel::Context &ctx,
|
||||
ox::StringView assetId,
|
||||
T const&asset) noexcept {
|
||||
#ifndef OX_BARE_METAL
|
||||
if (assetId.len() == 0) {
|
||||
return OxError(1, "Invalid asset ID");
|
||||
}
|
||||
ox::UUIDStr uuidStr;
|
||||
if (assetId[0] == '/') {
|
||||
oxRequire(id, ctx.pathToUuid.at(assetId));
|
||||
uuidStr = id->toString();
|
||||
assetId = uuidStr;
|
||||
}
|
||||
ctx.assetManager.initTypeManager<T>(detail::makeLoader<T>, ctx);
|
||||
return ctx.assetManager.setAsset(assetId, asset);
|
||||
#else
|
||||
return OxError(1, "Not supported on this platform");
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ox::Result<keel::AssetRef<T>> readObj(
|
||||
keel::Context &ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user