[olympic,nostalgia] Move item name/path studio::Editor

This commit is contained in:
2023-12-12 23:06:14 -06:00
parent d056323679
commit 1b93b2038f
8 changed files with 37 additions and 70 deletions

View File

@@ -11,23 +11,13 @@
namespace nostalgia::scene {
SceneEditorImGui::SceneEditorImGui(turbine::Context &ctx, ox::StringView path):
Editor(path),
m_ctx(ctx),
m_itemPath(path),
m_editor(m_ctx, m_itemPath),
m_editor(m_ctx, path),
m_view(m_ctx, m_editor.scene()) {
const auto lastSlash = std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset();
m_itemName = m_itemPath.substr(lastSlash + 1);
setRequiresConstantRefresh(false);
}
ox::CStringView SceneEditorImGui::itemName() const noexcept {
return m_itemPath;
}
ox::CStringView SceneEditorImGui::itemDisplayName() const noexcept {
return m_itemName;
}
void SceneEditorImGui::draw(turbine::Context&) noexcept {
auto const paneSize = ImGui::GetContentRegionAvail();
m_view.draw(ox::Size{static_cast<int>(paneSize.x), static_cast<int>(paneSize.y)});
@@ -59,8 +49,8 @@ void SceneEditorImGui::onActivated() noexcept {
ox::Error SceneEditorImGui::saveItem() noexcept {
const auto sctx = applicationData<studio::StudioContext>(m_ctx);
oxReturnError(sctx->project->writeObj(m_itemPath, m_editor.scene()));
oxReturnError(keelCtx(m_ctx).assetManager.setAsset(m_itemPath, m_editor.scene()));
oxReturnError(sctx->project->writeObj(itemName(), m_editor.scene()));
oxReturnError(keelCtx(m_ctx).assetManager.setAsset(itemName(), m_editor.scene()));
return {};
}

View File

@@ -17,21 +17,12 @@ class SceneEditorImGui: public studio::Editor {
private:
turbine::Context &m_ctx;
ox::String m_itemName;
ox::String m_itemPath;
SceneEditor m_editor;
SceneEditorView m_view;
public:
SceneEditorImGui(turbine::Context &ctx, ox::StringView path);
/**
* Returns the name of item being edited.
*/
ox::CStringView itemName() const noexcept final;
ox::CStringView itemDisplayName() const noexcept final;
void draw(turbine::Context&) noexcept final;
void onActivated() noexcept override;