Editor Tweaks #192
|
@ -36,13 +36,30 @@ namespace SHADE
|
||||||
DrawCurrentFolder();
|
DrawCurrentFolder();
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
if(refreshQueued)
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHAssetBrowser::QueueRefresh() noexcept
|
||||||
|
{
|
||||||
|
refreshQueued = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHAssetBrowser::Refresh() noexcept
|
||||||
|
{
|
||||||
|
SHAssetManager::RefreshDirectory();
|
||||||
|
rootFolder = SHAssetManager::GetRootFolder();
|
||||||
|
refreshQueued = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHAssetBrowser::DrawMenuBar()
|
void SHAssetBrowser::DrawMenuBar()
|
||||||
{
|
{
|
||||||
if (ImGui::BeginMenuBar())
|
if (ImGui::BeginMenuBar())
|
||||||
{
|
{
|
||||||
|
if(ImGui::SmallButton(ICON_MD_SYNC))
|
||||||
|
{
|
||||||
|
QueueRefresh();
|
||||||
|
}
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +88,7 @@ namespace SHADE
|
||||||
//TODO: Change to rttr type enum align
|
//TODO: Change to rttr type enum align
|
||||||
if (ImGui::Selectable("Material"))
|
if (ImGui::Selectable("Material"))
|
||||||
{
|
{
|
||||||
assetBeingCreated = { folder, AssetType::MATERIAL, "New Material" };
|
assetBeingCreated = { folder, AssetType::MATERIAL, "NewMaterial" };
|
||||||
ImGui::TreeNodeSetOpen(folderID, true);
|
ImGui::TreeNodeSetOpen(folderID, true);
|
||||||
isOpen = true;
|
isOpen = true;
|
||||||
}
|
}
|
||||||
|
@ -162,6 +179,7 @@ namespace SHADE
|
||||||
if(ImGui::Selectable("Compile"))
|
if(ImGui::Selectable("Compile"))
|
||||||
{
|
{
|
||||||
SHAssetManager::CompileAsset(file.path, !file.compiled);
|
SHAssetManager::CompileAsset(file.path, !file.compiled);
|
||||||
|
QueueRefresh();
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
@ -269,7 +287,7 @@ namespace SHADE
|
||||||
auto& path = std::get<0>(assetBeingCreated.value());
|
auto& path = std::get<0>(assetBeingCreated.value());
|
||||||
auto& type = std::get<1>(assetBeingCreated.value());
|
auto& type = std::get<1>(assetBeingCreated.value());
|
||||||
auto& assetName = std::get<2>(assetBeingCreated.value());
|
auto& assetName = std::get<2>(assetBeingCreated.value());
|
||||||
if (ImGui::InputText("##newAssetName", &assetName, ImGuiInputTextFlags_EnterReturnsTrue))
|
if (ImGui::InputText("##newAssetName", &assetName, ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CharsNoBlank))
|
||||||
{
|
{
|
||||||
AssetID assetId = SHAssetManager::CreateNewAsset(type, assetName);
|
AssetID assetId = SHAssetManager::CreateNewAsset(type, assetName);
|
||||||
if (auto matInspector = SHEditorWindowManager::GetEditorWindow<SHMaterialInspector>())
|
if (auto matInspector = SHEditorWindowManager::GetEditorWindow<SHMaterialInspector>())
|
||||||
|
@ -277,6 +295,8 @@ namespace SHADE
|
||||||
matInspector->OpenMaterial(assetId, true);
|
matInspector->OpenMaterial(assetId, true);
|
||||||
}
|
}
|
||||||
assetBeingCreated.reset();
|
assetBeingCreated.reset();
|
||||||
|
QueueRefresh();
|
||||||
}
|
}
|
||||||
|
ImGui::ActivateItem(ImGui::GetItemID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace SHADE
|
||||||
void Init();
|
void Init();
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
void Refresh();
|
void QueueRefresh() noexcept;
|
||||||
private:
|
private:
|
||||||
void DrawMenuBar();
|
void DrawMenuBar();
|
||||||
ImRect RecursivelyDrawTree(FolderPointer folder);
|
ImRect RecursivelyDrawTree(FolderPointer folder);
|
||||||
|
@ -25,10 +25,13 @@ namespace SHADE
|
||||||
ImRect DrawAsset(SHAsset const* const asset, FileExt const& ext = "") noexcept;
|
ImRect DrawAsset(SHAsset const* const asset, FileExt const& ext = "") noexcept;
|
||||||
void DrawAssetBeingCreated() noexcept;
|
void DrawAssetBeingCreated() noexcept;
|
||||||
|
|
||||||
|
void Refresh() noexcept;
|
||||||
|
|
||||||
FolderPointer rootFolder, prevFolder, currentFolder;
|
FolderPointer rootFolder, prevFolder, currentFolder;
|
||||||
std::optional<AssetEntry> assetBeingCreated;
|
std::optional<AssetEntry> assetBeingCreated;
|
||||||
std::vector<FolderPointer> selectedFolders;
|
std::vector<FolderPointer> selectedFolders;
|
||||||
std::vector<AssetID> selectedAssets;
|
std::vector<AssetID> selectedAssets;
|
||||||
static constexpr float tileWidth = 50.0f;
|
static constexpr float tileWidth = 50.0f;
|
||||||
|
bool refreshQueued = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue