Now uses embedded resources

This commit is contained in:
Antoine Pilote
2023-09-26 20:43:56 -04:00
parent 96bed6351e
commit ff4489a466
107 changed files with 191024 additions and 786 deletions

View File

@@ -6,8 +6,9 @@
enum EditorSelectionType {
None,
Entity,
File,
File,
Resource,
Directory
};
class EditorSelection {
@@ -17,6 +18,7 @@ public:
Nuake::Entity Entity;
Ref<Nuake::File> File;
Ref<Nuake::Directory> Directory;
Nuake::Resource Resource;
EditorSelection()
@@ -36,6 +38,12 @@ public:
File = file;
}
EditorSelection(const Ref<Nuake::Directory>& dir)
{
Type = EditorSelectionType::Directory;
Directory = dir;
}
EditorSelection(const Nuake::Resource& resource)
{
Type = EditorSelectionType::Resource;

View File

@@ -91,10 +91,6 @@ void MaterialEditor::Draw(Ref<Nuake::Material> material)
{
textureID = material->m_Albedo->GetID();
}
else
{
textureID = TextureManager::Get()->GetTexture("default")->GetID();
}
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image1"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
{
@@ -129,10 +125,6 @@ void MaterialEditor::Draw(Ref<Nuake::Material> material)
{
textureID = material->m_Normal->GetID();
}
else
{
textureID = TextureManager::Get()->GetTexture("default")->GetID();
}
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image3"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1)))
{
@@ -164,10 +156,6 @@ void MaterialEditor::Draw(Ref<Nuake::Material> material)
{
textureID = material->m_AO->GetID();
}
else
{
textureID = TextureManager::Get()->GetTexture("default")->GetID();
}
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image2"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1)))
{
@@ -202,10 +190,6 @@ void MaterialEditor::Draw(Ref<Nuake::Material> material)
{
textureID = material->m_Metalness->GetID();
}
else
{
textureID = TextureManager::Get()->GetTexture("default")->GetID();
}
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image4"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1)))
{
@@ -240,10 +224,6 @@ void MaterialEditor::Draw(Ref<Nuake::Material> material)
{
textureID = material->m_Roughness->GetID();
}
else
{
textureID = TextureManager::Get()->GetTexture("default")->GetID();
}
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image5"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
{

View File

@@ -23,7 +23,7 @@
GizmoDrawer::GizmoDrawer()
{
mLineShader = Nuake::ShaderManager::GetShader("resources/Shaders/line.shader");
mLineShader = Nuake::ShaderManager::GetShader("Resources/Shaders/line.shader");
mAxisLineBuffer = CreateRef<Nuake::VertexArray>();
mAxisLineBuffer->Bind();
@@ -80,9 +80,9 @@ GizmoDrawer::GizmoDrawer()
// Load gizmos
ModelLoader loader;
_gizmos = std::map<std::string, Ref<Model>>();
_gizmos["cam"] = loader.LoadModel("resources/Models/Camera.gltf");
_gizmos["light"] = loader.LoadModel("resources/Models/Light.gltf");
_gizmos["player"] = loader.LoadModel("resources/Models/Camera.gltf");
//_gizmos["cam"] = loader.LoadModel("Resources/Models/Camera.gltf");
//_gizmos["light"] = loader.LoadModel("Resources/Models/Light.gltf");
//_gizmos["player"] = loader.LoadModel("Resources/Models/Camera.gltf");
}
void GizmoDrawer::GenerateSphereGizmo()
@@ -287,7 +287,7 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
auto flatShader = ShaderManager::GetShader("resources/Shaders/flat.shader");
auto flatShader = ShaderManager::GetShader("Resources/Shaders/flat.shader");
flatShader->Bind();
flatShader->SetUniformMat4f("u_View", scene->m_EditorCamera->GetTransform());
flatShader->SetUniformMat4f("u_Projection", scene->m_EditorCamera->GetPerspective());
@@ -300,7 +300,7 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene)
glLineWidth(1.0f);
RenderList renderList;
auto gizmoShader = ShaderManager::GetShader("resources/Shaders/gizmo.shader");
auto gizmoShader = ShaderManager::GetShader("Resources/Shaders/gizmo.shader");
gizmoShader->Bind();
gizmoShader->SetUniformMat4f("u_View", scene->m_EditorCamera->GetTransform());
gizmoShader->SetUniformMat4f("u_Projection", scene->m_EditorCamera->GetPerspective());
@@ -311,7 +311,7 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene)
auto camView = scene->m_Registry.view<TransformComponent, CameraComponent>();
for (auto e : camView)
{
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("resources/Gizmos/camera.png").get());
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("Resources/Gizmos/camera.png").get());
auto [transform, camera] = scene->m_Registry.get<TransformComponent, CameraComponent>(e);
auto initialTransform = transform.GetGlobalTransform();
@@ -332,7 +332,7 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene)
auto lightView = scene->m_Registry.view<TransformComponent, LightComponent>();
for (auto e : lightView)
{
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("resources/Gizmos/light.png").get());
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("Resources/Gizmos/light.png").get());
auto [transform, light] = scene->m_Registry.get<TransformComponent, LightComponent>(e);
auto initialTransform = transform.GetGlobalTransform();
@@ -354,7 +354,7 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene)
auto characterControllerView = scene->m_Registry.view<TransformComponent, CharacterControllerComponent>();
for (auto e : characterControllerView)
{
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("resources/Gizmos/player.png").get());
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("Resources/Gizmos/player.png").get());
auto [transform, characterControllerComponent] = scene->m_Registry.get<TransformComponent, CharacterControllerComponent>(e);
auto initialTransform = transform.GetGlobalTransform();
@@ -376,7 +376,7 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene)
auto boneView = scene->m_Registry.view<TransformComponent, BoneComponent>();
for (auto e : boneView)
{
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("resources/Gizmos/bone.png").get());
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("Resources/Gizmos/bone.png").get());
auto [transform, boneComponent] = scene->m_Registry.get<TransformComponent, BoneComponent>(e);
auto initialTransform = transform.GetGlobalTransform();
@@ -396,7 +396,7 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene)
auto audioView = scene->m_Registry.view<TransformComponent, AudioEmitterComponent>();
for (auto e : audioView)
{
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("resources/Gizmos/speaker.png").get());
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("Resources/Gizmos/speaker.png").get());
auto [transformComponent, audioEmitterComponent] = scene->m_Registry.get<TransformComponent, AudioEmitterComponent>(e);
auto initialTransform = transformComponent.GetGlobalTransform();

View File

@@ -3,6 +3,7 @@
#include <src/Vendors/imgui/imgui.h>
#include <src/Resource/FontAwesome5.h>
#include <src/Resource/StaticResources.h>
std::map<Fonts, ImFont*> FontManager::mFonts = std::map<Fonts, ImFont*>();
void FontManager::LoadFonts()
@@ -11,14 +12,24 @@ void FontManager::LoadFonts()
static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true;
mFonts[Normal] = io.Fonts->AddFontFromFileTTF("resources/Fonts/fa-solid-900.ttf", 11.0f, &icons_config, icons_ranges);
mFonts[Bold] = io.Fonts->AddFontFromFileTTF("resources/Fonts/FiraMono-Bold.ttf", 16.0);
mFonts[LargeBold] = io.Fonts->AddFontFromFileTTF("resources/Fonts/FiraMono-Regular.ttf", 32);
mFonts[Title] = io.Fonts->AddFontFromFileTTF("resources/Fonts/FiraMono-Bold.ttf", 50.0);
mFonts[SubTitle] = io.Fonts->AddFontFromFileTTF("resources/Fonts/FiraMono-Regular.ttf", 24.0);
using namespace Nuake::StaticResources;
mFonts[Normal] = io.Fonts->AddFontFromMemoryTTF(Resources_Fonts_fa_solid_900_ttf, Resources_Fonts_fa_solid_900_ttf_len, 11.f, &icons_config, icons_ranges);
ImFontConfig iconsConfigBold;
icons_config.PixelSnapH = true;
mFonts[Bold] = io.Fonts->AddFontFromMemoryTTF(Resources_Fonts_FiraMono_Bold_ttf, Resources_Fonts_FiraMono_Bold_ttf_len, 16.0);
iconsConfigBold.MergeMode = true;
io.Fonts->AddFontFromMemoryTTF(Resources_Fonts_fa_solid_900_ttf, Resources_Fonts_fa_solid_900_ttf_len, 16.f, &iconsConfigBold, icons_ranges);
iconsConfigBold.MergeMode = false;
mFonts[LargeBold] = io.Fonts->AddFontFromMemoryTTF(Resources_Fonts_FiraMono_Regular_ttf, Resources_Fonts_FiraMono_Regular_ttf_len, 32);
mFonts[Title] = io.Fonts->AddFontFromMemoryTTF(Resources_Fonts_FiraMono_Bold_ttf, Resources_Fonts_FiraMono_Bold_ttf_len, 50.0);
mFonts[SubTitle] = io.Fonts->AddFontFromMemoryTTF(Resources_Fonts_FiraMono_Regular_ttf, Resources_Fonts_FiraMono_Regular_ttf_len, 24.0);
ImGui::GetIO().Fonts->AddFontDefault();
icons_config.MergeMode = true;
mFonts[BigIcon] = io.Fonts->AddFontFromFileTTF("resources/Fonts/fa-solid-900.ttf", 42.0f, &icons_config, icons_ranges);
mFonts[BigIcon] = io.Fonts->AddFontFromMemoryTTF(Resources_Fonts_fa_solid_900_ttf, Resources_Fonts_fa_solid_900_ttf_len, 42.0f, &icons_config, icons_ranges);
}
ImFont* FontManager::GetFont(Fonts font)

View File

@@ -76,7 +76,7 @@ Ref<Nuake::Texture> ThumbnailManager::GenerateThumbnail(const std::string& path,
RenderCommand::Disable(RendererEnum::BLENDING);
RenderCommand::Enable(RendererEnum::DEPTH_TEST);
auto shader = ShaderManager::GetShader("resources/Shaders/gbuffer.shader");
auto shader = ShaderManager::GetShader("Resources/Shaders/gbuffer.shader");
shader->Bind();
auto cam = Engine::GetCurrentScene()->GetCurrentCamera();
@@ -96,7 +96,7 @@ Ref<Nuake::Texture> ThumbnailManager::GenerateThumbnail(const std::string& path,
m_ShadedFramebuffer->Clear();
RenderCommand::Disable(RendererEnum::DEPTH_TEST);
RenderCommand::Disable(RendererEnum::FACE_CULL);
auto shader = ShaderManager::GetShader("resources/Shaders/deferred.shader");
auto shader = ShaderManager::GetShader("Resources/Shaders/deferred.shader");
shader->Bind();
shader->SetUniformVec3("u_EyePosition", Vector3(1, 0, 0));
shader->SetUniform1i("LightCount", 0);

View File

@@ -51,6 +51,8 @@
#include <src/UI/ImUI.h>
#include <src/Resource/StaticResources.h>
namespace Nuake {
Ref<UI::UserInterface> userInterface;
ImFont* normalFont;
@@ -64,6 +66,9 @@ namespace Nuake {
_audioWindow = new AudioWindow();
BuildFonts();
using namespace Nuake::StaticResources;
ImGui::LoadIniSettingsFromMemory((const char*)StaticResources::Resources_default_layout_ini);
}
void EditorInterface::Init()

View File

@@ -266,10 +266,6 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref<Nuake::Material> material)
{
textureID = material->m_Albedo->GetID();
}
else
{
textureID = TextureManager::Get()->GetTexture("default")->GetID();
}
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image1"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
{
@@ -304,10 +300,6 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref<Nuake::Material> material)
{
textureID = material->m_Normal->GetID();
}
else
{
textureID = TextureManager::Get()->GetTexture("default")->GetID();
}
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image3"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1)))
{
@@ -339,10 +331,6 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref<Nuake::Material> material)
{
textureID = material->m_AO->GetID();
}
else
{
textureID = TextureManager::Get()->GetTexture("default")->GetID();
}
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image2"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1)))
{
@@ -374,10 +362,6 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref<Nuake::Material> material)
{
textureID = material->m_Metalness->GetID();
}
else
{
textureID = TextureManager::Get()->GetTexture("default")->GetID();
}
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image4"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1)))
{
@@ -412,10 +396,6 @@ void EditorSelectionPanel::DrawMaterialPanel(Ref<Nuake::Material> material)
{
textureID = material->m_Roughness->GetID();
}
else
{
textureID = TextureManager::Get()->GetTexture("default")->GetID();
}
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image5"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
{

View File

@@ -71,11 +71,47 @@ namespace Nuake
ImGui::PushFont(FontManager::GetFont(Icons));
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
const char* icon = ICON_FA_FOLDER;
const std::string id = ICON_FA_FOLDER + std::string("##") + directory->name;
if (ImGui::Button(id.c_str(), ImVec2(100, 100)))
const std::string id = std::string("##") + directory->name;
ImVec2 prevCursor = ImGui::GetCursorPos();
ImVec2 prevScreenPos = ImGui::GetCursorScreenPos();
const bool selected = ImGui::Selectable(id.c_str(), Editor->Selection.Directory == directory, ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick, ImVec2(100, 150));
if (selected)
{
m_CurrentDirectory = directory;
if (ImGui::IsMouseDoubleClicked(0))
{
m_CurrentDirectory = directory;
}
Editor->Selection = EditorSelection(directory);
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip(directory->name.c_str());
ImGui::SetCursorPos(prevCursor);
ImGui::Image((ImTextureID)TextureManager::Get()->GetTexture("Resources/Images/folder_icon.png")->GetID(), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
auto imguiStyle = ImGui::GetStyle();
ImVec2 startOffset = ImVec2(imguiStyle.CellPadding.x / 2.0f, 0);
ImVec2 offsetEnd = ImVec2(startOffset.x, imguiStyle.CellPadding.y / 2.0f);
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 = directory->name;
const uint32_t MAX_CHAR_NAME = 35;
if (directory->name.size() > MAX_CHAR_NAME)
{
visibleName = std::string(directory->name.begin(), directory->name.begin() + MAX_CHAR_NAME - 3) + "...";
}
ImGui::TextWrapped(visibleName.c_str());
ImGui::SetCursorPosY(prevCursor.y + 150 - ImGui::GetTextLineHeight());
ImGui::TextColored({ 1, 1, 1, 0.5f }, "Folder");
ImGui::PopStyleVar();
const std::string hoverMenuId = std::string("item_hover_menu") + std::to_string(drawId);
if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1))
@@ -168,8 +204,6 @@ namespace Nuake
RefreshFileBrowser();
}
ImGui::Text(directory->name.c_str());
ImGui::PopFont();
}
@@ -197,98 +231,169 @@ namespace Nuake
{
ImGui::PushFont(EditorInterface::bigIconFont);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, {0.f, 0.f});
std::string fileExtension = file->GetExtension();
if (fileExtension == ".png" || fileExtension == ".jpg")
ImVec2 prevCursor = ImGui::GetCursorPos();
ImVec2 prevScreenPos = ImGui::GetCursorScreenPos();
std::string id = std::string("##") + file->GetAbsolutePath();
const bool selected = ImGui::Selectable(id.c_str(), Editor->Selection.File == file, ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick, ImVec2(100, 150));
bool shouldOpenScene = false;
if (selected)
{
Ref<Texture> texture = TextureManager::Get()->GetTexture(file->GetAbsolutePath());
ImGui::ImageButton((void*)texture->GetID(), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
if (ImGui::IsMouseDoubleClicked(0))
{
if (file->GetFileType() == FileType::Map)
{
OS::OpenTrenchbroomMap(file->GetAbsolutePath());
}
if (file->GetFileType() == FileType::Scene)
{
shouldOpenScene = true;
}
}
Editor->Selection = EditorSelection(file);
}
else
{
const char* icon = ICON_FA_FILE;
if (fileExtension == ".shader" || fileExtension == ".wren")
icon = ICON_FA_FILE_CODE;
if (fileExtension == ".map")
icon = ICON_FA_BROOM;
if (fileExtension == ".ogg" || fileExtension == ".mp3" || fileExtension == ".wav")
icon = ICON_FA_FILE_AUDIO;
if (fileExtension == ".gltf" || fileExtension == ".obj")
icon = ICON_FA_FILE_IMAGE;
std::string fullName = icon + std::string("##") + file->GetAbsolutePath();
if (ImGui::IsItemHovered())
ImGui::SetTooltip(file->GetName().c_str());
bool pressed = false;
if (fileExtension == ".material")
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
pressed = ImGui::ImageButton(fullName.c_str(), (void*)ThumbnailManager::Get().GetThumbnail(file->GetRelativePath())->GetID(), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
ImGui::PopStyleVar();
}
else
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
pressed = ImGui::Button(fullName.c_str(), ImVec2(100, 100));
ImGui::PopStyleVar();
}
if (Editor->Selection.File == file)
{
ThumbnailManager::Get().MarkThumbnailAsDirty(file->GetRelativePath());
}
if(pressed)
{
Editor->Selection = EditorSelection(file);
}
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
{
OS::OpenTrenchbroomMap(file->GetAbsolutePath());
}
}
ImGui::PopStyleVar();
if (ImGui::BeginDragDropSource())
{
char pathBuffer[256];
std::strncpy(pathBuffer, file->GetAbsolutePath().c_str(), sizeof(pathBuffer));
std::string dragType;
if (fileExtension == ".wren")
{
char pathBuffer[256];
std::strncpy(pathBuffer, file->GetAbsolutePath().c_str(), sizeof(pathBuffer));
std::string dragType;
if (fileExtension == ".wren")
{
dragType = "_Script";
}
else if (fileExtension == ".map")
{
dragType = "_Map";
}
else if (fileExtension == ".material")
{
dragType = "_Material";
}
else if (fileExtension == ".obj" || fileExtension == ".mdl" || fileExtension == ".gltf" || fileExtension == ".md3" || fileExtension == ".fbx" || fileExtension == ".glb")
{
dragType = "_Model";
}
else if (fileExtension == ".interface")
{
dragType = "_Interface";
}
else if (fileExtension == ".prefab")
{
dragType = "_Prefab";
}
else if (fileExtension == ".png" || fileExtension == ".jpg")
{
dragType = "_Image";
}
else if (fileExtension == ".wav" || fileExtension == ".ogg")
{
dragType = "_AudioFile";
}
ImGui::SetDragDropPayload(dragType.c_str(), (void*)(pathBuffer), sizeof(pathBuffer));
ImGui::Text(file->GetName().c_str());
ImGui::EndDragDropSource();
dragType = "_Script";
}
else if (fileExtension == ".map")
{
dragType = "_Map";
}
else if (fileExtension == ".material")
{
dragType = "_Material";
}
else if (fileExtension == ".obj" || fileExtension == ".mdl" || fileExtension == ".gltf" || fileExtension == ".md3" || fileExtension == ".fbx" || fileExtension == ".glb")
{
dragType = "_Model";
}
else if (fileExtension == ".interface")
{
dragType = "_Interface";
}
else if (fileExtension == ".prefab")
{
dragType = "_Prefab";
}
else if (fileExtension == ".png" || fileExtension == ".jpg")
{
dragType = "_Image";
}
else if (fileExtension == ".wav" || fileExtension == ".ogg")
{
dragType = "_AudioFile";
}
ImGui::SetDragDropPayload(dragType.c_str(), (void*)(pathBuffer), sizeof(pathBuffer));
ImGui::Text(file->GetName().c_str());
ImGui::EndDragDropSource();
}
Ref<Texture> textureImage =TextureManager::Get()->GetTexture("Resources/Images/folder_icon.png");
const auto textureMgr = TextureManager::Get();
const auto fileType = file->GetFileType();
if (fileType == FileType::Material)
{
textureImage = ThumbnailManager::Get().GetThumbnail(file->GetRelativePath());
}
else if (fileType == FileType::Image)
{
const std::string path = file->GetAbsolutePath();
textureImage = textureMgr->GetTexture(path);
}
else if (fileType == FileType::Project)
{
textureImage = textureMgr->GetTexture("Resources/Images/logo.png");
}
ImGui::SetCursorPos(prevCursor);
ImGui::Image((ImTextureID)textureImage->GetID(), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
ImGui::PopStyleVar();
auto imguiStyle = ImGui::GetStyle();
ImVec2 startOffset = ImVec2(imguiStyle.CellPadding.x / 2.0f, 0);
ImVec2 offsetEnd = ImVec2(startOffset.x, imguiStyle.CellPadding.y / 2.0f);
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;
if (file->GetName().size() > MAX_CHAR_NAME)
{
visibleName = std::string(file->GetName().begin(), file->GetName().begin() + MAX_CHAR_NAME - 3) + "...";
}
ImGui::TextWrapped(visibleName.c_str());
ImGui::SetCursorPosY(prevCursor.y + 150 - ImGui::GetTextLineHeight());
ImGui::TextColored({ 1, 1, 1, 0.5f }, file->GetFileTypeAsString().c_str());
//if (fileExtension == ".png" || fileExtension == ".jpg")
//{
//
//}
//else
//{
// const char* icon = ICON_FA_FILE;
// if (fileExtension == ".shader" || fileExtension == ".wren")
// icon = ICON_FA_FILE_CODE;
// if (fileExtension == ".map")
// icon = ICON_FA_BROOM;
// if (fileExtension == ".ogg" || fileExtension == ".mp3" || fileExtension == ".wav")
// icon = ICON_FA_FILE_AUDIO;
// if (fileExtension == ".gltf" || fileExtension == ".obj")
// icon = ICON_FA_FILE_IMAGE;
//
// std::string fullName = icon + std::string("##") + file->GetAbsolutePath();
//
// bool pressed = false;
// if (fileExtension == ".material")
// {
// ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
// pressed = ImGui::ImageButton(fullName.c_str(), (void*)ThumbnailManager::Get().GetThumbnail(file-//>GetRelativePath())->GetID(), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0));
// ImGui::PopStyleVar();
// }
// else
// {
// ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
// pressed = ImGui::Button(fullName.c_str(), ImVec2(100, 100));
// ImGui::PopStyleVar();
// }
//
if (Editor->Selection.File == file)
{
ThumbnailManager::Get().MarkThumbnailAsDirty(file->GetRelativePath());
}
//
// if(pressed)
// {
// Editor->Selection = EditorSelection(file);
// }
//
// if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
// {
// OS::OpenTrenchbroomMap(file->GetAbsolutePath());
// }
//}
ImGui::PopStyleVar();
const std::string hoverMenuId = std::string("item_hover_menu") + std::to_string(drawId);
if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1))
@@ -298,7 +403,7 @@ namespace Nuake
}
const std::string openSceneId = "Open Scene" + std::string("##") + hoverMenuId;
bool shouldOpenScene = false;
const std::string renameId = "Rename" + std::string("##") + hoverMenuId;
bool shouldRename = false;
@@ -385,11 +490,6 @@ namespace Nuake
ImGui::EndPopup();
}
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
{
shouldOpenScene = file->GetExtension() == ".scene";
}
// Open Scene Popup
if (shouldOpenScene)
@@ -407,6 +507,7 @@ namespace Nuake
return;
}
FileSystem::SetRootDirectory(projectPath + "/");
scene->Path = FileSystem::AbsoluteToRelative(projectPath);
Engine::LoadScene(scene);
}
@@ -445,8 +546,6 @@ namespace Nuake
RefreshFileBrowser();
}
ImGui::Text(file->GetName().c_str());
ImGui::PopFont();
}
@@ -793,6 +892,7 @@ namespace Nuake
}
ImGui::EndChild();
}
ImGui::EndChild();
}
ImGui::End();

View File

@@ -12,7 +12,7 @@ namespace Nuake
class LoadingSplash
{
private:
const std::string NUAKE_LOGO_PATH = "resources/Images/logo_white.png";
const std::string NUAKE_LOGO_PATH = "Resources/Images/logo_white.png";
Ref<Nuake::Texture> _NuakeLogo;
public:

View File

@@ -19,6 +19,8 @@
#include "EditorInterface.h"
#include "FileSystemUI.h"
#include <src/UI/ImUI.h>
namespace Nuake
{
ProjectPreview::ProjectPreview(const std::string& path)
@@ -43,7 +45,7 @@ namespace Nuake
}
else
{
ProjectIcon = TextureManager::Get()->GetTexture("resources/Images/nuake-logo.png");
ProjectIcon = TextureManager::Get()->GetTexture("Resources/Images/nuake-logo.png");
}
}
else
@@ -124,6 +126,17 @@ namespace Nuake
ImGui::Image((ImTextureID)_NuakeLogo->GetID(), imguiSize, ImVec2(0, 1), ImVec2(1, 0));
}
//ImGui::SameLine();
std::string versionInfo = "pre-alpha ";
#ifdef NK_DEBUG
versionInfo += "debug build";
#endif
#ifdef NK_DIST
versionInfo += "dist build";
#endif
ImGui::TextColored({1, 1, 1, 0.5}, versionInfo.c_str());
// ImGui::TextColored({ 1, 1, 1, 0.5 }, "239d9479");
// Add padding under logo
ImGui::Dummy(ImVec2(10, 16));
@@ -179,7 +192,6 @@ namespace Nuake
void WelcomeWindow::DrawProjectItem(const uint32_t itemIndex)
{
const ProjectPreview& project = _Projects[itemIndex];
const uint32_t itemHeight = 120;
const float cursorYStart = ImGui::GetCursorPosY();
@@ -194,16 +206,14 @@ namespace Nuake
// Channel number is like z-order. Widgets in higher channels are rendered above widgets in lower channels.
draw_list->ChannelsSetCurrent(1);
ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0, 0, 0, 0));
bool result = ImGui::Selectable(selectableName.c_str(), isSelected, ImGuiSelectableFlags_AllowItemOverlap, ImVec2(ImGui::GetContentRegionAvail().x, itemHeight));
if (isSelected)
//ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0, 0, 0, 0));
bool result = ImGui::Selectable(selectableName.c_str(), SelectedProject == itemIndex, ImGuiSelectableFlags_AllowOverlap, ImVec2(ImGui::GetContentRegionAvail().x, itemHeight));
if (result)
{
ImVec2 p_min = ImGui::GetItemRectMin();
ImVec2 p_max = ImGui::GetItemRectMax();
ImGui::GetWindowDrawList()->AddRectFilled(p_min, p_max, IM_COL32(10.0f, 182.0f, 255.f, 255.0f), 8.0f);
SelectedProject = itemIndex;
}
ImGui::PopStyleColor();
//ImGui::PopStyleColor();
draw_list->ChannelsMerge();
@@ -217,7 +227,10 @@ namespace Nuake
const ImVec2 iconSize = ImVec2(100, 100);
ImGui::SetCursorPos(ImVec2(padding.x / 2.0, padding.y / 2.0) + ImVec2(0, cursorYStart));
ImGui::Image((ImTextureID)project.ProjectIcon->GetID(), iconSize, ImVec2(0, 1), ImVec2(1, 0));
if (project.ProjectIcon)
{
ImGui::Image((ImTextureID)project.ProjectIcon->GetID(), iconSize, ImVec2(0, 1), ImVec2(1, 0));
}
ImGui::SameLine();
ImGui::SetCursorPosX(padding.x + iconSize.x + padding.x);
@@ -244,14 +257,14 @@ namespace Nuake
const float buttonHeight = 36.0f;
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0, 0, 0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 16.0f);
if (ImGui::BeginChild("Controls", ImVec2(200.0f, ImGui::GetContentRegionAvail().y), false))
if (ImGui::BeginChild("Controls", ImVec2(250.0f, ImGui::GetContentRegionAvail().y), false))
{
ImGui::PopStyleVar();
const ImVec2 buttonSize = ImVec2(ImGui::GetContentRegionAvail().x, buttonHeight);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.14f, 0.5f));
const std::string buttonLabel = std::string(ICON_FA_FOLDER_PLUS) + " New Game Project...";
if (ImGui::Button(buttonLabel.c_str(), buttonSize))
if (Nuake::UI::PrimaryButton(buttonLabel.c_str(), { buttonSize.x, buttonSize.y }))
{
std::string selectedProject = FileDialog::SaveFile("Project file\0*.project");
@@ -287,34 +300,48 @@ namespace Nuake
projectPreview.Name = project->Name;
projectPreview.Description = project->Description;
projectPreview.Path = project->FullPath;
projectPreview.ProjectIcon = nullptr;
_Projects.push_back(projectPreview);
}
}
ImGui::PopStyleVar(2);
ImGui::Separator();
if (SelectedProject != -1)
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.16f, 0.5f));
const std::string buttonLabelOpen = std::string(ICON_FA_FOLDER_OPEN) + " Load Selected Project";
bool hasProjectSelected = false;
if (SelectedProject < std::size(_Projects) && SelectedProject >= 0)
{
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.16f, 0.5f));
const std::string buttonLabelOpen = std::string(ICON_FA_FOLDER_OPEN) + " Load Selected Project";
if (ImGui::Button(buttonLabelOpen.c_str(), buttonSize) || ImGui::IsMouseDoubleClicked(0))
{
assert(SelectedProject < std::size(_Projects));
SaveRecentFile();
queuedProjectPath = _Projects[SelectedProject].Path;;
}
ImGui::PopStyleVar(2);
hasProjectSelected = true;
}
if (!hasProjectSelected)
{
ImGui::BeginDisabled(true);
}
if (Nuake::UI::SecondaryButton(buttonLabelOpen, { buttonSize.x, buttonSize.y }))
{
SaveRecentFile();
queuedProjectPath = _Projects[SelectedProject].Path;;
}
if (!hasProjectSelected)
{
ImGui::EndDisabled();
}
ImGui::PopStyleVar(2);
ImGui::Separator();
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.09f, 0.5f));
const std::string buttonLabelDoc = std::string(ICON_FA_EXTERNAL_LINK_SQUARE_ALT) + " Documentation";
if (ImGui::Button(buttonLabelDoc.c_str(), buttonSize))
if (Nuake::UI::SecondaryButton(buttonLabelDoc, { buttonSize.x, buttonSize.y }))
{
OS::OpenURL("https://nuake.readthedocs.io/en/latest/index.html");
}

View File

@@ -32,14 +32,14 @@ namespace Nuake
class WelcomeWindow
{
private:
const std::string NUAKE_LOGO_PATH = "resources/Images/logo_white.png";
const std::string NUAKE_LOGO_PATH = "Resources/Images/logo_white.png";
Ref<Texture> _NuakeLogo;
EditorInterface* _Editor;
const std::string _RecentProjectFilePath = "recent.json";
const std::string _RecentProjectFileDefaultContent = "{ \"Projects\": [ ] }";
uint32_t SelectedProject = 0;
int32_t SelectedProject = -1;
std::vector<ProjectPreview> _Projects;
std::string queuedProjectPath;
public: