Collision Tags autosave on change, fixed serialisation bug with collision tags #342
|
@ -50,7 +50,14 @@ namespace SHADE
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
ImGui::PushID(i);
|
ImGui::PushID(i);
|
||||||
SHEditorWidgets::InputText("##", [i]{return SHCollisionTagMatrix::GetTagName(i);}, [i](std::string const& value){SHCollisionTagMatrix::GetTag(i)->SetName(value);}, tagName.data(), ImGuiInputTextFlags_EnterReturnsTrue);
|
if (SHEditorWidgets::InputText("##", [i]{return SHCollisionTagMatrix::GetTagName(i);}, [i](std::string const& value){SHCollisionTagMatrix::GetTag(i)->SetName(value);}, tagName.data(), ImGuiInputTextFlags_EnterReturnsTrue))
|
||||||
|
{
|
||||||
|
isDirty = true;
|
||||||
|
std::filesystem::path defaultCollisionTagNameFilePath{ ASSET_ROOT };
|
||||||
|
defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig");
|
||||||
|
SHCollisionTagMatrix::SaveToFile(defaultCollisionTagNameFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
|
|
||||||
// The checkboxes are just to set the layers of each tag
|
// The checkboxes are just to set the layers of each tag
|
||||||
|
@ -60,10 +67,13 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
std::string label = std::format("##{}, Layer {}", tagName, j);
|
std::string label = std::format("##{}, Layer {}", tagName, j+1);
|
||||||
if (SHEditorWidgets::CheckBox(label, [tag, &j] {return tag->GetLayerState(j); }, [tag, j](bool const& value) {tag->SetLayerState(j, value); }, label.substr(2)))
|
if (SHEditorWidgets::CheckBox(label, [tag, &j] {return tag->GetLayerState(j); }, [tag, j](bool const& value) {tag->SetLayerState(j, value); }, label.substr(2)))
|
||||||
{
|
{
|
||||||
isDirty = true;
|
isDirty = true;
|
||||||
|
std::filesystem::path defaultCollisionTagNameFilePath{ ASSET_ROOT };
|
||||||
|
defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig");
|
||||||
|
SHCollisionTagMatrix::SaveToFile(defaultCollisionTagNameFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ namespace YAML
|
||||||
Node node;
|
Node node;
|
||||||
|
|
||||||
node[IsTrigger] = rhs.IsTrigger();
|
node[IsTrigger] = rhs.IsTrigger();
|
||||||
node[CollisionTag] = rhs.GetCollisionTag().GetName();
|
node[CollisionTag] = SHCollisionTagMatrix::GetTagIndex(rhs.GetCollisionTag().GetName());
|
||||||
rttr::type const shapeRttrType = rttr::type::get<SHCollisionShape::Type>();
|
rttr::type const shapeRttrType = rttr::type::get<SHCollisionShape::Type>();
|
||||||
rttr::enumeration const enumAlign = shapeRttrType.get_enumeration();
|
rttr::enumeration const enumAlign = shapeRttrType.get_enumeration();
|
||||||
SHCollisionShape::Type colliderType = rhs.GetType();
|
SHCollisionShape::Type colliderType = rhs.GetType();
|
||||||
|
@ -176,7 +176,7 @@ namespace YAML
|
||||||
rhs.SetIsTrigger(node[IsTrigger].as<bool>());
|
rhs.SetIsTrigger(node[IsTrigger].as<bool>());
|
||||||
|
|
||||||
if(node[CollisionTag].IsDefined())
|
if(node[CollisionTag].IsDefined())
|
||||||
rhs.SetCollisionTag(SHCollisionTagMatrix::GetTag(node[CollisionTag].as<std::string>()));
|
rhs.SetCollisionTag(SHCollisionTagMatrix::GetTag(node[CollisionTag].as<int>()));
|
||||||
|
|
||||||
if (!node[Type].IsDefined())
|
if (!node[Type].IsDefined())
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue