mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Added prefab thumbnails in filebrowser + fix filebrowser crash
This commit is contained in:
@@ -69,13 +69,26 @@ Ref<Nuake::Texture> ThumbnailManager::GenerateThumbnail(const std::string& path,
|
||||
Matrix4 view = Matrix4(1.0f);
|
||||
view = glm::lookAt(Vector3(1, -1.0, 0), Vector3(0, 0, 0), Vector3(0, 1, 0));;
|
||||
|
||||
|
||||
auto file = FileSystem::GetFile(path);
|
||||
if (file->GetFileType() == FileType::Prefab)
|
||||
{
|
||||
Ref<Scene> scene = Scene::New();
|
||||
auto cam = scene->CreateEntity("Camera");
|
||||
cam.AddComponent<CameraComponent>();
|
||||
TransformComponent& camTransform = cam.GetComponent<TransformComponent>();
|
||||
camTransform.SetLocalPosition({ 0.0f, 0.0f, 2.0f });
|
||||
|
||||
auto& previewLight = scene->CreateEntity("_directionalLight").AddComponent<LightComponent>();
|
||||
previewLight.SetCastShadows(false);
|
||||
previewLight.Type = LightType::Directional;
|
||||
|
||||
scene->GetEnvironment()->CurrentSkyType = SkyType::ProceduralSky;
|
||||
scene->GetEnvironment()->ProceduralSkybox->SunDirection = { 0.58f, 0.34f, -0.74f };
|
||||
auto& camComponent = cam.AddComponent<CameraComponent>();
|
||||
camComponent.CameraInstance->Fov = 45.0f;
|
||||
camComponent.CameraInstance->AspectRatio = 1.0f;
|
||||
m_ShadedFramebuffer->SetTexture(texture);
|
||||
|
||||
Ref<Prefab> prefab = Prefab::InstanceInScene(path, scene);
|
||||
|
||||
scene->Update(0.01f);
|
||||
scene->Draw(*m_ShadedFramebuffer.get());
|
||||
|
||||
@@ -369,10 +369,10 @@ namespace Nuake
|
||||
ImU32 rectColor = IM_COL32(255, 255, 255, 16);
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(prevScreenPos + ImVec2(0, 100) - startOffset, prevScreenPos + ImVec2(100, 150) + offsetEnd, rectColor, 1.0f);
|
||||
std::string visibleName = file->GetName();
|
||||
const uint32_t MAX_CHAR_NAME = 35;
|
||||
const uint32_t MAX_CHAR_NAME = 32;
|
||||
if (file->GetName().size() >= MAX_CHAR_NAME)
|
||||
{
|
||||
visibleName = std::string(file->GetName().begin(), file->GetName().begin() + MAX_CHAR_NAME - 3) + "...";
|
||||
visibleName = std::string(visibleName.begin(), visibleName.begin() + MAX_CHAR_NAME - 3) + "...";
|
||||
}
|
||||
|
||||
ImGui::TextWrapped(visibleName.c_str());
|
||||
@@ -412,11 +412,11 @@ namespace Nuake
|
||||
// ImGui::PopStyleVar();
|
||||
// }
|
||||
//
|
||||
if (Editor->Selection.File == file)
|
||||
if (Editor->Selection.File == file && Editor->Selection.File->GetFileType() != FileType::Prefab)
|
||||
{
|
||||
ThumbnailManager::Get().MarkThumbnailAsDirty(file->GetRelativePath());
|
||||
}
|
||||
//
|
||||
|
||||
// if(pressed)
|
||||
// {
|
||||
// Editor->Selection = EditorSelection(file);
|
||||
|
||||
Reference in New Issue
Block a user