fix: 修复多个UI框架问题
- 修复 InspectorPanel InputText 使用 data()/capacity() 的错误 - 修复未使用变量警告 - 修复 ProjectManager 路径重复拼接 bug (Assets/Assets) - 返回按钮在 Assets 目录时禁用但保持显示 - 删除 ProjectPanel 创建按钮,调整 Refresh 位置 - 修复 ProjectPanel 搜索过滤时的 ID 冲突 - 修复 InspectorPanel CollapsingHeader ID 冲突
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Managers/SceneManager.h"
|
||||
#include "Managers/SelectionManager.h"
|
||||
#include <imgui.h>
|
||||
#include <string>
|
||||
|
||||
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<uintptr_t>(component));
|
||||
|
||||
if (ImGui::CollapsingHeader(headerId.c_str(), ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
ImGui::Indent(10.0f);
|
||||
|
||||
if (auto* transform = dynamic_cast<TransformComponent*>(component)) {
|
||||
@@ -65,15 +68,23 @@ void InspectorPanel::RenderComponent(Component* component) {
|
||||
ImGui::DragFloat3("##Scale", transform->scale, 0.1f);
|
||||
}
|
||||
else if (auto* meshRenderer = dynamic_cast<MeshRendererComponent*>(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);
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user