From b22447a9315a88ab82f9d76dcfbea46b6e315aba Mon Sep 17 00:00:00 2001 From: redstrate Date: Mon, 19 Jul 2021 07:15:34 -0400 Subject: [PATCH] Add scene asset type to editor --- tools/common/include/commoneditor.hpp | 12 +++++++++++- tools/common/src/commoneditor.cpp | 18 +++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/tools/common/include/commoneditor.hpp b/tools/common/include/commoneditor.hpp index 7b980b7..612ec21 100755 --- a/tools/common/include/commoneditor.hpp +++ b/tools/common/include/commoneditor.hpp @@ -84,7 +84,8 @@ enum class AssetType { Unknown, Mesh, Texture, - Material + Material, + Scene }; template @@ -95,6 +96,8 @@ AssetType get_asset_type() { return AssetType::Material; } else if constexpr(std::is_same::value) { return AssetType::Texture; + } else if constexpr(std::is_same::value) { + return AssetType::Scene; } return AssetType::Unknown; @@ -296,6 +299,13 @@ public: return false; } } + + template + void open_asset(const AssetType type, const std::function func_ptr) { + current_asset_type = type; + open_asset_popup = true; + on_asset_select = func_ptr; + } DebugPass* debugPass = nullptr; diff --git a/tools/common/src/commoneditor.cpp b/tools/common/src/commoneditor.cpp index b1df649..e7844c7 100755 --- a/tools/common/src/commoneditor.cpp +++ b/tools/common/src/commoneditor.cpp @@ -264,7 +264,13 @@ void CommonEditor::begin_frame() { on_asset_select(p); ImGui::CloseCurrentPopup(); } - + + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text(p.c_str()); + ImGui::EndTooltip(); + } + column++; if(column != 5) @@ -760,6 +766,8 @@ void cacheAssetFilesystem() { asset_files[std::filesystem::relative(p, data_directory)] = AssetType::Material; } else if(p.path().extension() == ".png") { asset_files[std::filesystem::relative(p, data_directory)] = AssetType::Texture; + } else if(p.path().extension() == ".scene") { + asset_files[std::filesystem::relative(p, data_directory)] = AssetType::Scene; } } @@ -785,16 +793,16 @@ void CommonEditor::drawAssets() { if(ImGui::ImageButton(get_asset_thumbnail(prism::app_domain / p), ImVec2(64, 64))) asset_selected(prism::app_domain / p, type); - + if(ImGui::BeginPopupContextItem()) { ImGui::TextDisabled("%s", p.string().c_str()); - + ImGui::Separator(); - + if(ImGui::Button("Regenerate thumbnail")) { asset_thumbnails.erase(asset_thumbnails.find((prism::app_domain / p).string())); } - + ImGui::EndPopup(); }