UI system now working well with the new component changes, fixed trait compile issues, fixed inspector rendering issues

This commit is contained in:
WiggleWizard
2024-09-13 23:24:34 +01:00
parent 59505b0664
commit aed98dd648
8 changed files with 100 additions and 64 deletions

View File

@@ -15,47 +15,47 @@ public:
void Draw(Nuake::Entity entity) override
{
using namespace Nuake;
if (!entity.HasComponent<UIComponent>())
return;
auto& component = entity.GetComponent<UIComponent>();
BeginComponentTable(UI EMITTER, UIComponent);
{
{
ImGui::Text("HTML File");
ImGui::TableNextColumn();
std::string path = component.UIFilePath;
ImGui::Button(component.UIFilePath.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0));
if (ImGui::BeginDragDropTarget())
{
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_UIFile"))
{
char* file = (char*)payload->Data;
std::string fullPath = std::string(file, 256);
path = Nuake::FileSystem::AbsoluteToRelative(fullPath);
component.UIFilePath = path;
}
ImGui::EndDragDropTarget();
}
ImGui::TableNextColumn();
ComponentTableReset(component.UIFilePath, "");
}
ImGui::TableNextColumn();
{
ImGui::Text("Worldspace");
ImGui::TableNextColumn();
ImGui::Checkbox("##WorldSpace", &component.IsWorldSpace);
ImGui::TableNextColumn();
ComponentTableReset(component.IsWorldSpace, false);
}
}
EndComponentTable();
// using namespace Nuake;
//
// if (!entity.HasComponent<UIComponent>())
// return;
//
// auto& component = entity.GetComponent<UIComponent>();
// BeginComponentTable(UI EMITTER, UIComponent);
// {
// {
// ImGui::Text("HTML File");
// ImGui::TableNextColumn();
//
// std::string path = component.UIFilePath;
// ImGui::Button(component.UIFilePath.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0));
// if (ImGui::BeginDragDropTarget())
// {
// if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_UIFile"))
// {
// char* file = (char*)payload->Data;
// std::string fullPath = std::string(file, 256);
// path = Nuake::FileSystem::AbsoluteToRelative(fullPath);
// component.UIFilePath = path;
// }
// ImGui::EndDragDropTarget();
// }
//
// ImGui::TableNextColumn();
//
// ComponentTableReset(component.UIFilePath, "");
// }
// ImGui::TableNextColumn();
// {
// ImGui::Text("Worldspace");
// ImGui::TableNextColumn();
//
// ImGui::Checkbox("##WorldSpace", &component.IsWorldSpace);
// ImGui::TableNextColumn();
//
// ComponentTableReset(component.IsWorldSpace, false);
// }
// }
// EndComponentTable();
}
};

View File

@@ -598,8 +598,15 @@ void EditorSelectionPanel::DrawComponentContent(entt::meta_any& component)
entt::meta_type componentMeta = component.type();
for (auto [fst, dataType] : componentMeta.data())
{
const ComponentFieldTrait fieldTraits = dataType.traits<ComponentFieldTrait>();
// Field marked as internal and thus not exposed to the inspector
if ((fieldTraits & ComponentFieldTrait::Internal) == ComponentFieldTrait::Internal)
{
continue;
}
ImGui::TableNextColumn();
// Search for the appropriate drawer for the type
entt::id_type dataId = dataType.type().id();
if (FieldTypeDrawers.contains(dataId))
@@ -607,6 +614,12 @@ void EditorSelectionPanel::DrawComponentContent(entt::meta_any& component)
auto drawerFn = FieldTypeDrawers[dataId];
drawerFn(dataType, component);
}
else
{
ImGui::Text("ERR");
}
ImGui::TableNextRow();
}
}
@@ -647,8 +660,6 @@ void EditorSelectionPanel::DrawFieldTypeFloat(entt::meta_data& field, entt::meta
ImGui::Text("ERR");
}
}
ImGui::TableNextRow();
}
void EditorSelectionPanel::DrawFieldTypeBool(entt::meta_data& field, entt::meta_any& component)
@@ -678,8 +689,6 @@ void EditorSelectionPanel::DrawFieldTypeBool(entt::meta_data& field, entt::meta_
ImGui::Text("ERR");
}
}
ImGui::TableNextRow();
}
void EditorSelectionPanel::DrawFieldTypeVector3(entt::meta_data& field, entt::meta_any& component)
@@ -705,8 +714,6 @@ void EditorSelectionPanel::DrawFieldTypeVector3(entt::meta_data& field, entt::me
ImGui::PopID();
}
ImGui::TableNextRow();
}
void EditorSelectionPanel::DrawFieldTypeString(entt::meta_data& field, entt::meta_any& component)
@@ -733,8 +740,6 @@ void EditorSelectionPanel::DrawFieldTypeString(entt::meta_data& field, entt::met
ImGui::Text("ERR");
}
}
ImGui::TableNextRow();
}
void EditorSelectionPanel::DrawFieldTypeResourceFile(entt::meta_data& field, entt::meta_any& component)
@@ -776,7 +781,5 @@ void EditorSelectionPanel::DrawFieldTypeResourceFile(entt::meta_data& field, ent
ImGui::Text("ERR");
}
}
ImGui::TableNextRow();
}