Added a search box to the script component's drop down menu

master
Joey Pollack 3 years ago
parent de8bc580df
commit c507273ac4

@ -159,12 +159,26 @@ namespace lunarium { namespace editor
std::string preview = (pScript ? pScript->GetScriptFile().filename().string().c_str() : "NOT SET");
if (ImGui::BeginCombo("Script", preview.c_str()))
{
char search_buf[256] = "";
ImGui::InputText("Search ##SCRIPT", search_buf, 256);
std::string ssearch = search_buf;
std::vector<EditorAsset*> assets;
ContentManager::GetInstance().GetAllAssetsByType(assets, AssetType::EATYPE_SCRIPT);
for (auto iter = assets.begin(); iter != assets.end(); iter++)
{
editor::Script* pScript = (editor::Script*)(*iter);
if (ssearch.size() > 0)
{
// Filter items based on search term
if (pScript->GetScriptFile().string().find(ssearch) == std::string::npos)
{
continue;
}
}
bool selected = false;
if (ImGui::Selectable(pScript->GetScriptFile().string().c_str(), &selected))
{

Loading…
Cancel
Save