Improvements

This commit is contained in:
antopilo
2024-09-18 17:10:12 -04:00
parent 67d7865a20
commit 7fc10b4e56
15 changed files with 968 additions and 756 deletions

View File

@@ -41,6 +41,7 @@ EditorSelectionPanel::EditorSelectionPanel()
RegisterTypeDrawer<bool, &EditorSelectionPanel::DrawFieldTypeBool>(this);
RegisterTypeDrawer<float, &EditorSelectionPanel::DrawFieldTypeFloat>(this);
RegisterTypeDrawer<Vector2, &EditorSelectionPanel::DrawFieldTypeVector2>(this);
RegisterTypeDrawer<Vector3, &EditorSelectionPanel::DrawFieldTypeVector3>(this);
RegisterTypeDrawer<std::string, &EditorSelectionPanel::DrawFieldTypeString>(this);
RegisterTypeDrawer<ResourceFile, &EditorSelectionPanel::DrawFieldTypeResourceFile>(this);
@@ -722,7 +723,7 @@ void EditorSelectionPanel::DrawFieldTypeVector3(entt::meta_data& field, entt::me
std::string controlId = std::string("##") + displayName;
ImGui::PushID(controlId.c_str());
if (ImGuiHelper::DrawVec3("BoxSize", vec3Ptr, 0.5f, 100.0, 0.01f))
if (ImGuiHelper::DrawVec3(controlId, vec3Ptr, 0.5f, 100.0, 0.01f))
{
field.set(component, *vec3Ptr);
}
@@ -731,6 +732,31 @@ void EditorSelectionPanel::DrawFieldTypeVector3(entt::meta_data& field, entt::me
}
}
void EditorSelectionPanel::DrawFieldTypeVector2(entt::meta_data& field, entt::meta_any& component)
{
auto prop = field.prop(HashedName::DisplayName);
auto propVal = prop.value();
const char* displayName = *propVal.try_cast<const char*>();
if (displayName != nullptr)
{
ImGui::Text(displayName);
ImGui::TableNextColumn();
auto fieldVal = field.get(component);
Vector2* vec2Ptr = fieldVal.try_cast<Vector2>();
std::string controlId = std::string("##") + displayName;
ImGui::PushID(controlId.c_str());
if (ImGuiHelper::DrawVec2(controlId, vec2Ptr, 0.5f, 100.0, 0.01f))
{
field.set(component, *vec2Ptr);
}
ImGui::PopID();
}
}
void EditorSelectionPanel::DrawFieldTypeString(entt::meta_data& field, entt::meta_any& component)
{
auto prop = field.prop(HashedName::DisplayName);