Skip to content

Commit

Permalink
add ObjectSet
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz-h committed Jan 8, 2025
1 parent 27f65ac commit 06d9803
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 4 deletions.
7 changes: 4 additions & 3 deletions docs/SATISFACTORY_SAVE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

#include "../ObjectSet.h"
#include "../StructSet.h"
#include "../UInt32Set.h"
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

namespace SatisfactorySave {

class ObjectSet;
class StructSet;
class UInt32Set;

class SATISFACTORYSAVE_API SetVisitor {
public:
virtual ~SetVisitor() = default;

virtual void visit(ObjectSet& s) = 0;
virtual void visit(StructSet& s) = 0;
virtual void visit(UInt32Set& s) = 0;
};
Expand Down
12 changes: 12 additions & 0 deletions libsave/include/SatisfactorySave/GameTypes/Sets/ObjectSet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include "../FactoryGame/FGObjectReference.h"
#include "Base/SetImpl.h"

namespace SatisfactorySave {

class SATISFACTORYSAVE_API ObjectSet final : public SetImpl<ObjectSet, FObjectReferenceDisc> {
public:
static constexpr std::string_view TypeName = "ObjectProperty";
};
} // namespace SatisfactorySave
4 changes: 3 additions & 1 deletion libsave/src/GameTypes/Sets/Base/Set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ std::shared_ptr<SatisfactorySave::Set> SatisfactorySave::Set::create(const FName
IStreamArchive& ar) {
std::shared_ptr<Set> set;

if (set_type == StructSet::TypeName) {
if (set_type == ObjectSet::TypeName) {
set = std::make_shared<ObjectSet>();
} else if (set_type == StructSet::TypeName) {
auto struct_name = FName(StructSet::structNameLookup(name, ar.getParentClassInfo()));
set = std::make_shared<StructSet>(std::move(struct_name));
} else if (set_type == UInt32Set::TypeName) {
Expand Down
4 changes: 4 additions & 0 deletions libsavepy/src/GameTypes/Sets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
void init_GameTypes_Sets(py::module_& m) {
py::class_<s::Set, std::shared_ptr<s::Set>>(m, "Set");

py::class_<s::ObjectSet, s::Set, std::shared_ptr<s::ObjectSet>>(m, "ObjectSet")
.def(py::init<>())
.def_readwrite("Values", &s::ObjectSet::Values);

py::class_<s::StructSet, s::Set, std::shared_ptr<s::StructSet>>(m, "StructSet")
.def(py::init<s::FName>())
.def_readwrite("Values", &s::StructSet::Values)
Expand Down
6 changes: 6 additions & 0 deletions map/src/MapWindow/UI/PropertyEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions map/src/MapWindow/UI/PropertyEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 06d9803

Please sign in to comment.