diff --git a/ui/src/Application.cpp b/ui/src/Application.cpp index 9a6c2fe6..cf231c04 100644 --- a/ui/src/Application.cpp +++ b/ui/src/Application.cpp @@ -30,10 +30,8 @@ bool Application::Initialize(HWND hwnd) { ImGuiIO& io = ImGui::GetIO(); io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; - ImFont* font = io.Fonts->AddFontFromFileTTF("C:/Windows/Fonts/msyh.ttc", 16.0f); - ImFont* defaultFont = io.Fonts->AddFontDefault(); - (void)font; - (void)defaultFont; + io.Fonts->AddFontFromFileTTF("C:/Windows/Fonts/msyh.ttc", 16.0f); + io.Fonts->AddFontDefault(); unsigned char* pixels; int width, height; diff --git a/ui/src/Managers/ProjectManager.cpp b/ui/src/Managers/ProjectManager.cpp index 7451bab7..c4f0908c 100644 --- a/ui/src/Managers/ProjectManager.cpp +++ b/ui/src/Managers/ProjectManager.cpp @@ -34,10 +34,10 @@ void ProjectManager::NavigateBack() { } std::string ProjectManager::GetCurrentPath() const { - if (m_path.empty()) return ""; - std::string result; - for (size_t i = 0; i < m_path.size(); i++) { - if (i > 0) result += "/"; + if (m_path.empty()) return "Assets"; + std::string result = "Assets"; + for (size_t i = 1; i < m_path.size(); i++) { + result += "/"; result += m_path[i]->name; } return result; @@ -99,8 +99,10 @@ void ProjectManager::Initialize(const std::string& projectPath) { } std::wstring ProjectManager::GetCurrentFullPathW() const { + if (m_path.empty()) return Utf8ToWstring(m_projectPath); + std::wstring fullPath = Utf8ToWstring(m_projectPath); - for (size_t i = 0; i < m_path.size(); i++) { + for (size_t i = 1; i < m_path.size(); i++) { fullPath += L"/" + Utf8ToWstring(m_path[i]->name); } return fullPath; diff --git a/ui/src/panels/InspectorPanel.cpp b/ui/src/panels/InspectorPanel.cpp index 14f4b560..73cf074f 100644 --- a/ui/src/panels/InspectorPanel.cpp +++ b/ui/src/panels/InspectorPanel.cpp @@ -2,6 +2,7 @@ #include "Managers/SceneManager.h" #include "Managers/SelectionManager.h" #include +#include namespace UI { @@ -45,7 +46,9 @@ void InspectorPanel::RenderComponent(Component* component) { const char* name = component->GetName().c_str(); - if (ImGui::CollapsingHeader(name, ImGuiTreeNodeFlags_DefaultOpen)) { + std::string headerId = name + std::string("##") + std::to_string(reinterpret_cast(component)); + + if (ImGui::CollapsingHeader(headerId.c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::Indent(10.0f); if (auto* transform = dynamic_cast(component)) { @@ -65,15 +68,23 @@ void InspectorPanel::RenderComponent(Component* component) { ImGui::DragFloat3("##Scale", transform->scale, 0.1f); } else if (auto* meshRenderer = dynamic_cast(component)) { + char materialBuffer[256] = {}; + strncpy_s(materialBuffer, meshRenderer->materialName.c_str(), sizeof(materialBuffer) - 1); ImGui::Text("Material"); ImGui::SameLine(80); ImGui::SetNextItemWidth(180); - ImGui::InputText("##Material", meshRenderer->materialName.data(), meshRenderer->materialName.capacity()); + if (ImGui::InputText("##Material", materialBuffer, sizeof(materialBuffer))) { + meshRenderer->materialName = materialBuffer; + } + char meshBuffer[256] = {}; + strncpy_s(meshBuffer, meshRenderer->meshName.c_str(), sizeof(meshBuffer) - 1); ImGui::Text("Mesh"); ImGui::SameLine(80); ImGui::SetNextItemWidth(180); - ImGui::InputText("##Mesh", meshRenderer->meshName.data(), meshRenderer->meshName.capacity()); + if (ImGui::InputText("##Mesh", meshBuffer, sizeof(meshBuffer))) { + meshRenderer->meshName = meshBuffer; + } } ImGui::Unindent(10.0f); diff --git a/ui/src/panels/ProjectPanel.cpp b/ui/src/panels/ProjectPanel.cpp index d22fb112..0adb0b60 100644 --- a/ui/src/panels/ProjectPanel.cpp +++ b/ui/src/panels/ProjectPanel.cpp @@ -18,27 +18,24 @@ void ProjectPanel::Render() { auto& manager = ProjectManager::Get(); - if (manager.CanNavigateBack()) { - if (ImGui::Button("<")) { + bool canGoBack = manager.CanNavigateBack(); + ImGui::BeginDisabled(!canGoBack); + if (ImGui::Button("<")) { + if (canGoBack) { manager.NavigateBack(); } - ImGui::SameLine(); } + ImGui::EndDisabled(); + ImGui::SameLine(); ImGui::Text("%s", manager.GetCurrentPath().c_str()); ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetWindowWidth() - 140.0f); + ImGui::SetCursorPosX(ImGui::GetWindowWidth() - 80.0f); if (ImGui::Button("Refresh")) { manager.RefreshCurrentFolder(); } - ImGui::SameLine(); - if (ImGui::Button("+")) { - m_showCreateFolderPopup = true; - strcpy_s(m_newFolderName, "NewFolder"); - } - ImGui::Separator(); ImGui::PushItemWidth(-1); @@ -69,7 +66,7 @@ void ProjectPanel::Render() { if (itemIndex > 0 && itemIndex % columns != 0) { ImGui::SameLine(); } - RenderAssetItem(items[i], i); + RenderAssetItem(items[i], itemIndex); itemIndex++; }