|
|
|
|
@ -17,6 +17,7 @@
|
|
|
|
|
#include <editor/contents/content_manager.h>
|
|
|
|
|
#include <editor/contents/editor_asset.h>
|
|
|
|
|
#include <editor/contents/world.h>
|
|
|
|
|
#include <editor/contents/script.h>
|
|
|
|
|
#include <renderer/texture.h>
|
|
|
|
|
|
|
|
|
|
namespace lunarium
|
|
|
|
|
@ -222,7 +223,9 @@ namespace editor
|
|
|
|
|
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
|
|
|
|
{
|
|
|
|
|
// Logger::Info(Editor::LogCat, "Asset double clicked on. Relevant editor should open!");
|
|
|
|
|
HandleAssetDoubleClick((*iter));
|
|
|
|
|
//HandleAssetDoubleClick((*iter));
|
|
|
|
|
|
|
|
|
|
mpEditor->OnAssetOpen((*iter));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
|
|
|
|
@ -258,6 +261,11 @@ namespace editor
|
|
|
|
|
{
|
|
|
|
|
OpenPopup(PopUp::NEW_WORLD).LogIfFailed(Editor::LogCat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("New Script"))
|
|
|
|
|
{
|
|
|
|
|
OpenPopup(PopUp::NEW_SCRIPT).LogIfFailed(Editor::LogCat);
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndMenu();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@ -323,7 +331,37 @@ namespace editor
|
|
|
|
|
{
|
|
|
|
|
auto assets_dir = ab->mpEditor->GetProject()->MakeRelativeToAssets(ab->mSelectedDir);
|
|
|
|
|
EditorAsset* pAsset = new editor::World(assets_dir / name_buf);
|
|
|
|
|
u64 id;
|
|
|
|
|
LUUID id;
|
|
|
|
|
|
|
|
|
|
ContentManager::GetInstance().AddGeneratedAsset(pAsset, id).LogIfFailed(Editor::LogCat);
|
|
|
|
|
stay_open = false;
|
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Core::Input().IsKeyDown(KeyCode::ESCAPE, true))
|
|
|
|
|
{
|
|
|
|
|
stay_open = false;
|
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
|
}
|
|
|
|
|
return stay_open;
|
|
|
|
|
}).LogIfFailed(Editor::LogCat);
|
|
|
|
|
|
|
|
|
|
// New script asset
|
|
|
|
|
AddPopup(PopUp::NEW_SCRIPT, "New Script Name", [](Panel *p)
|
|
|
|
|
{
|
|
|
|
|
bool stay_open = true;
|
|
|
|
|
AssetBrowser* ab = (AssetBrowser*)p;
|
|
|
|
|
char name_buf[64] = "New Script";
|
|
|
|
|
ImGui::TextUnformatted("Script Name: ");
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
if (ImGui::InputText("##Script Name", name_buf, 64, ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue))
|
|
|
|
|
{
|
|
|
|
|
auto assets_dir = ab->mpEditor->GetProject()->MakeRelativeToAssets(ab->mSelectedDir);
|
|
|
|
|
std::string sname_buf = name_buf;
|
|
|
|
|
sname_buf.append(".wren");
|
|
|
|
|
std::filesystem::path location = assets_dir / sname_buf;
|
|
|
|
|
EditorAsset* pAsset = new editor::Script(location, ab->mpEditor->GetProject()->GetAssetDirectory());
|
|
|
|
|
LUUID id;
|
|
|
|
|
|
|
|
|
|
ContentManager::GetInstance().AddGeneratedAsset(pAsset, id).LogIfFailed(Editor::LogCat);
|
|
|
|
|
stay_open = false;
|
|
|
|
|
@ -341,14 +379,14 @@ namespace editor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AssetBrowser::HandleAssetDoubleClick(EditorAsset* pAsset)
|
|
|
|
|
{
|
|
|
|
|
if (pAsset->GetType() == AssetType::EATYPE_WORLD)
|
|
|
|
|
{
|
|
|
|
|
World* pAssetWorld = (World*)pAsset;
|
|
|
|
|
mpEditor->ChangeWorld(pAssetWorld->GetWorld());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// void AssetBrowser::HandleAssetDoubleClick(EditorAsset* pAsset)
|
|
|
|
|
// {
|
|
|
|
|
// if (pAsset->GetType() == AssetType::EATYPE_WORLD)
|
|
|
|
|
// {
|
|
|
|
|
// World* pAssetWorld = (World*)pAsset;
|
|
|
|
|
// mpEditor->ChangeWorld(pAssetWorld->GetWorld());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|