diff --git a/docs/SATISFACTORY_SAVE.md b/docs/SATISFACTORY_SAVE.md index 283ea68..925ed09 100644 --- a/docs/SATISFACTORY_SAVE.md +++ b/docs/SATISFACTORY_SAVE.md @@ -861,9 +861,10 @@ The layout of the data is: With using the following types: -| InnerType | T | -|------------------|----------| -| `UInt32Property` | `uint32` | +| InnerType | T | +|------------------|------------------------| +| `ObjectProperty` | `FObjectReferenceDisc` | +| `UInt32Property` | `uint32` | In addition, `StructProperty` is used as type. Similar to maps, sets have the problem that no information about which struct type is used is being serialized to the save game. diff --git a/libsave/include/SatisfactorySave/GameTypes/Sets/Base/SetAll.h b/libsave/include/SatisfactorySave/GameTypes/Sets/Base/SetAll.h index 3d547cb..5c47164 100644 --- a/libsave/include/SatisfactorySave/GameTypes/Sets/Base/SetAll.h +++ b/libsave/include/SatisfactorySave/GameTypes/Sets/Base/SetAll.h @@ -1,4 +1,5 @@ #pragma once +#include "../ObjectSet.h" #include "../StructSet.h" #include "../UInt32Set.h" diff --git a/libsave/include/SatisfactorySave/GameTypes/Sets/Base/SetVisitor.h b/libsave/include/SatisfactorySave/GameTypes/Sets/Base/SetVisitor.h index b038618..54e7224 100644 --- a/libsave/include/SatisfactorySave/GameTypes/Sets/Base/SetVisitor.h +++ b/libsave/include/SatisfactorySave/GameTypes/Sets/Base/SetVisitor.h @@ -4,6 +4,7 @@ namespace SatisfactorySave { + class ObjectSet; class StructSet; class UInt32Set; @@ -11,6 +12,7 @@ namespace SatisfactorySave { public: virtual ~SetVisitor() = default; + virtual void visit(ObjectSet& s) = 0; virtual void visit(StructSet& s) = 0; virtual void visit(UInt32Set& s) = 0; }; diff --git a/libsave/include/SatisfactorySave/GameTypes/Sets/ObjectSet.h b/libsave/include/SatisfactorySave/GameTypes/Sets/ObjectSet.h new file mode 100644 index 0000000..d57f2c2 --- /dev/null +++ b/libsave/include/SatisfactorySave/GameTypes/Sets/ObjectSet.h @@ -0,0 +1,12 @@ +#pragma once + +#include "../FactoryGame/FGObjectReference.h" +#include "Base/SetImpl.h" + +namespace SatisfactorySave { + + class SATISFACTORYSAVE_API ObjectSet final : public SetImpl { + public: + static constexpr std::string_view TypeName = "ObjectProperty"; + }; +} // namespace SatisfactorySave diff --git a/libsave/src/GameTypes/Sets/Base/Set.cpp b/libsave/src/GameTypes/Sets/Base/Set.cpp index 6e0b475..87eeae2 100644 --- a/libsave/src/GameTypes/Sets/Base/Set.cpp +++ b/libsave/src/GameTypes/Sets/Base/Set.cpp @@ -8,7 +8,9 @@ std::shared_ptr SatisfactorySave::Set::create(const FName IStreamArchive& ar) { std::shared_ptr set; - if (set_type == StructSet::TypeName) { + if (set_type == ObjectSet::TypeName) { + set = std::make_shared(); + } else if (set_type == StructSet::TypeName) { auto struct_name = FName(StructSet::structNameLookup(name, ar.getParentClassInfo())); set = std::make_shared(std::move(struct_name)); } else if (set_type == UInt32Set::TypeName) { diff --git a/libsavepy/src/GameTypes/Sets.cpp b/libsavepy/src/GameTypes/Sets.cpp index 315928e..c8f98a5 100644 --- a/libsavepy/src/GameTypes/Sets.cpp +++ b/libsavepy/src/GameTypes/Sets.cpp @@ -5,6 +5,10 @@ void init_GameTypes_Sets(py::module_& m) { py::class_>(m, "Set"); + py::class_>(m, "ObjectSet") + .def(py::init<>()) + .def_readwrite("Values", &s::ObjectSet::Values); + py::class_>(m, "StructSet") .def(py::init()) .def_readwrite("Values", &s::StructSet::Values) diff --git a/map/src/MapWindow/UI/PropertyEditor.cpp b/map/src/MapWindow/UI/PropertyEditor.cpp index b8d9c88..6802cdc 100644 --- a/map/src/MapWindow/UI/PropertyEditor.cpp +++ b/map/src/MapWindow/UI/PropertyEditor.cpp @@ -294,6 +294,12 @@ void Satisfactory3DMap::UI::PropertyEditor::MapTypeEditor::visit(s::StructMapTyp } } +void Satisfactory3DMap::UI::PropertyEditor::SetEditor::visit(s::ObjectSet& s) { + EditorList("Values", s.Values, [&](std::size_t idx, auto& item) { + parent_.changed_ |= EditorObjectReference(("#" + std::to_string(idx)).c_str(), item, parent_.ctx_); + }); +} + void Satisfactory3DMap::UI::PropertyEditor::SetEditor::visit(s::StructSet& s) { ImGui::BeginDisabled(); EditorShowText("StructName", s.getStructName().toString().c_str()); diff --git a/map/src/MapWindow/UI/PropertyEditor.h b/map/src/MapWindow/UI/PropertyEditor.h index 6699c8f..3bc84ac 100644 --- a/map/src/MapWindow/UI/PropertyEditor.h +++ b/map/src/MapWindow/UI/PropertyEditor.h @@ -109,6 +109,7 @@ namespace Satisfactory3DMap::UI { public: explicit SetEditor(PropertyEditor& parent) : parent_(parent) {} + void visit(s::ObjectSet& s) override; void visit(s::StructSet& s) override; void visit(s::UInt32Set& s) override; };