feat: cameras saving/loading
This commit is contained in:
@@ -31,7 +31,7 @@ Content::Content(
|
||||
UptrsMap<std::string, ContentPackRuntime> packs,
|
||||
UptrsMap<std::string, BlockMaterial> blockMaterials,
|
||||
UptrsMap<std::string, rigging::SkeletonConfig> skeletons,
|
||||
const ResourceIndicesSet& resourceIndices
|
||||
ResourceIndicesSet resourceIndices
|
||||
) : indices(std::move(indices)),
|
||||
packs(std::move(packs)),
|
||||
blockMaterials(std::move(blockMaterials)),
|
||||
@@ -42,7 +42,7 @@ Content::Content(
|
||||
drawGroups(std::move(drawGroups))
|
||||
{
|
||||
for (size_t i = 0; i < RESOURCE_TYPES_COUNT; i++) {
|
||||
this->resourceIndices[i] = resourceIndices[i];
|
||||
this->resourceIndices[i] = std::move(resourceIndices[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-7
@@ -111,16 +111,18 @@ public:
|
||||
class ResourceIndices {
|
||||
std::vector<std::string> names;
|
||||
std::unordered_map<std::string, size_t> indices;
|
||||
std::vector<dynamic::Map_sptr> savedData;
|
||||
std::unique_ptr<std::vector<dynamic::Map_sptr>> savedData;
|
||||
public:
|
||||
ResourceIndices() {}
|
||||
ResourceIndices()
|
||||
: savedData(std::make_unique<std::vector<dynamic::Map_sptr>>()){
|
||||
}
|
||||
|
||||
static constexpr size_t MISSING = -1;
|
||||
|
||||
void add(std::string name, dynamic::Map_sptr map) {
|
||||
indices[name] = names.size();
|
||||
names.push_back(name);
|
||||
savedData.push_back(map);
|
||||
savedData->push_back(map);
|
||||
}
|
||||
|
||||
const std::string& getName(size_t index) const {
|
||||
@@ -136,11 +138,11 @@ public:
|
||||
}
|
||||
|
||||
dynamic::Map_sptr getSavedData(size_t index) const {
|
||||
return savedData.at(index);
|
||||
return savedData->at(index);
|
||||
}
|
||||
|
||||
void saveData(size_t index, dynamic::Map_sptr map) {
|
||||
savedData.at(index) = map;
|
||||
void saveData(size_t index, dynamic::Map_sptr map) const {
|
||||
savedData->at(index) = map;
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
@@ -186,7 +188,7 @@ public:
|
||||
UptrsMap<std::string, ContentPackRuntime> packs,
|
||||
UptrsMap<std::string, BlockMaterial> blockMaterials,
|
||||
UptrsMap<std::string, rigging::SkeletonConfig> skeletons,
|
||||
const ResourceIndicesSet& resourceIndices
|
||||
ResourceIndicesSet resourceIndices
|
||||
);
|
||||
~Content();
|
||||
|
||||
@@ -194,6 +196,10 @@ public:
|
||||
return indices.get();
|
||||
}
|
||||
|
||||
inline const ResourceIndices& getIndices(ResourceType type) const {
|
||||
return resourceIndices[static_cast<size_t>(type)];
|
||||
}
|
||||
|
||||
const rigging::SkeletonConfig* getRig(const std::string& id) const;
|
||||
const BlockMaterial* findBlockMaterial(const std::string& id) const;
|
||||
const ContentPackRuntime* getPackRuntime(const std::string& id) const;
|
||||
|
||||
@@ -76,7 +76,7 @@ std::unique_ptr<Content> ContentBuilder::build() {
|
||||
std::move(packs),
|
||||
std::move(blockMaterials),
|
||||
std::move(skeletons),
|
||||
resourceIndices
|
||||
std::move(resourceIndices)
|
||||
);
|
||||
|
||||
// Now, it's time to resolve foreign keys
|
||||
|
||||
@@ -500,6 +500,7 @@ void ContentLoader::load() {
|
||||
|
||||
void ContentLoader::loadResources(ResourceType type, dynamic::List* list) {
|
||||
for (size_t i = 0; i < list->size(); i++) {
|
||||
builder.resourceIndices[static_cast<size_t>(type)].add(list->str(i), nullptr);
|
||||
builder.resourceIndices[static_cast<size_t>(type)].add(
|
||||
pack->id+":"+list->str(i), nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user