diff --git a/code/application/game/componentinspection.cc b/code/application/game/componentinspection.cc index 41eda37ae..66f6508cf 100644 --- a/code/application/game/componentinspection.cc +++ b/code/application/game/componentinspection.cc @@ -195,4 +195,60 @@ ComponentDrawFuncT(ComponentId component, void* data, bool* commit) *commit = true; } +//------------------------------------------------------------------------------ +/** +*/ +template<> +void +ComponentDrawFuncT(ComponentId component, void* data, bool* commit) +{ + MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); + + ImGui::Text(desc->name.Value()); + if (ImGui::InputFloat3("##vec", (float*)data)) + *commit = true; +} + +//------------------------------------------------------------------------------ +/** +*/ +template<> +void +ComponentDrawFuncT(ComponentId component, void* data, bool* commit) +{ + MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); + + ImGui::SameLine(); + if (ImGui::InputFloat3("##pos", (float*)data)) + *commit = true; +} + +//------------------------------------------------------------------------------ +/** +*/ +template<> +void +ComponentDrawFuncT(ComponentId component, void* data, bool* commit) +{ + MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); + + ImGui::SameLine(); + if (ImGui::InputFloat4("##orient", (float*)data)) + *commit = true; +} + +//------------------------------------------------------------------------------ +/** +*/ +template<> +void +ComponentDrawFuncT(ComponentId component, void* data, bool* commit) +{ + MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); + + ImGui::SameLine(); + if (ImGui::InputFloat3("##scl", (float*)data)) + *commit = true; +} + } // namespace Game diff --git a/code/application/game/componentinspection.h b/code/application/game/componentinspection.h index 8a84ac286..c8a942da8 100644 --- a/code/application/game/componentinspection.h +++ b/code/application/game/componentinspection.h @@ -15,6 +15,10 @@ #include "util/stringatom.h" #include "game/entity.h" #include "game/componentid.h" +#include "basegamefeature/components/position.h" +#include "basegamefeature/components/orientation.h" +#include "basegamefeature/components/scale.h" +#include "imgui.h" namespace Game { @@ -47,6 +51,13 @@ template void ComponentDrawFuncT(ComponentId, void*, bool*) { + if constexpr (TYPE::Traits::num_fields > 0) + { + for (size_t i = 0; i < TYPE::Traits::num_fields; i++) + { + ImGui::Text(TYPE::Traits::field_names[i]); + } + } return; } @@ -56,5 +67,9 @@ template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); +template<> void ComponentDrawFuncT(ComponentId, void*, bool*); +template<> void ComponentDrawFuncT(ComponentId, void*, bool*); +template<> void ComponentDrawFuncT(ComponentId, void*, bool*); +template<> void ComponentDrawFuncT(ComponentId, void*, bool*); } // namespace Game diff --git a/fips-files/generators/IDLC/idlcomponent.py b/fips-files/generators/IDLC/idlcomponent.py index a1b10caad..c72e04416 100644 --- a/fips-files/generators/IDLC/idlcomponent.py +++ b/fips-files/generators/IDLC/idlcomponent.py @@ -139,7 +139,7 @@ def WriteComponentHeaderDeclarations(f, document): if (len(c.variables) > 0): f.WriteLine('static constexpr const char* field_names[num_fields] = {') for v in c.variables: - f.WriteLine(' "{}"'.format(v.name)) + f.WriteLine(' "{}",'.format(v.name)) f.WriteLine('};') f.DecreaseIndent() f.WriteLine("};") diff --git a/fips-files/generators/NIDL.py b/fips-files/generators/NIDL.py index 6259fa7a6..5f006dd6f 100644 --- a/fips-files/generators/NIDL.py +++ b/fips-files/generators/NIDL.py @@ -1,4 +1,4 @@ -Version = 131 +Version = 133 import sys if __name__ == '__main__': diff --git a/toolkit/editor/editor/ui/windows/inspector.cc b/toolkit/editor/editor/ui/windows/inspector.cc index 8bc690a59..0e88a7c2f 100644 --- a/toolkit/editor/editor/ui/windows/inspector.cc +++ b/toolkit/editor/editor/ui/windows/inspector.cc @@ -100,12 +100,11 @@ Inspector::Run() (entityMapping.table != lastEntityMapping.table || entityMapping.instance != lastEntityMapping.instance); lastEntityMapping = Editor::state.editorWorld->GetEntityMapping(entity); - Util::StringAtom const ownerAtom = "Owner"_atm; for (int i = 0; i < components.Size(); i++) { auto component = components[i]; - if (MemDb::AttributeRegistry::GetAttribute(component)->name == ownerAtom) + if (component == Game::GetComponentId()) { continue; } @@ -113,11 +112,16 @@ Inspector::Run() ImGui::Text(MemDb::AttributeRegistry::GetAttribute(component)->name.Value()); ImGui::SameLine(); - if (ImGui::Button("Remove")) + if (component != Game::GetComponentId() && + component != Game::GetComponentId() && + component != Game::GetComponentId()) { - Edit::RemoveComponent(entity, component); - ImGui::PopID(); - return; // return, otherwise we're reading stale data. + if (ImGui::Button("Remove")) + { + Edit::RemoveComponent(entity, component); + ImGui::PopID(); + return; // return, otherwise we're reading stale data. + } } auto& tempComponent = this->tempComponents[i];