| 93 | |
| 94 | public: |
| 95 | std::optional<ObjectRepositoryItem> Create([[maybe_unused]] int32_t language, const std::string& path) const override |
| 96 | { |
| 97 | std::unique_ptr<Object> object = ObjectFactory::CreateObjectFromFile(path, false); |
| 98 | |
| 99 | // All official DAT files have a JSON object counterpart. Avoid loading the obsolete .DAT versions, |
| 100 | // which can happen if the user copies the official DAT objects to their custom content folder. |
| 101 | if (object == nullptr |
| 102 | || (object->GetGeneration() == ObjectGeneration::DAT |
| 103 | && object->GetObjectEntry().GetSourceGame() != ObjectSourceGame::custom)) |
| 104 | { |
| 105 | return std::nullopt; |
| 106 | } |
| 107 | |
| 108 | ObjectRepositoryItem item = {}; |
| 109 | item.Type = object->GetObjectType(); |
| 110 | item.Generation = object->GetGeneration(); |
| 111 | item.Identifier = object->GetIdentifier(); |
| 112 | item.ObjectEntry = object->GetObjectEntry(); |
| 113 | item.Version = object->GetVersion(); |
| 114 | item.Path = path; |
| 115 | item.Name = object->GetName(); |
| 116 | item.Authors = object->GetAuthors(); |
| 117 | item.Sources = object->GetSourceGames(); |
| 118 | if (object->IsCompatibilityObject()) |
| 119 | item.Flags |= ObjectItemFlags::IsCompatibilityObject; |
| 120 | object->SetRepositoryItem(&item); |
| 121 | return item; |
| 122 | } |
| 123 | |
| 124 | protected: |
| 125 | void Serialise(DataSerialiser& ds, const ObjectRepositoryItem& item) const override |
no test coverage detected