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