allow anm2s with variable layers per animation. it'll just load all of them. not 1:1 to the behavior of nicalis editor but it'll make those sorts of files load in an editable fashion
This commit is contained in:
25
src/anm2.cpp
25
src/anm2.cpp
@@ -327,7 +327,6 @@ bool anm2_deserialize(Anm2* self, const std::string& path, bool isTextures)
|
|||||||
Anm2Spritesheet addSpritesheet;
|
Anm2Spritesheet addSpritesheet;
|
||||||
s32 layerMapIndex = 0;
|
s32 layerMapIndex = 0;
|
||||||
bool isLayerMapSet = false;
|
bool isLayerMapSet = false;
|
||||||
bool isFirstAnimationDone = false;
|
|
||||||
std::string defaultAnimation{};
|
std::string defaultAnimation{};
|
||||||
|
|
||||||
if (!self) return false;
|
if (!self) return false;
|
||||||
@@ -385,11 +384,6 @@ bool anm2_deserialize(Anm2* self, const std::string& path, bool isTextures)
|
|||||||
id = map_next_id_get(self->animations);
|
id = map_next_id_get(self->animations);
|
||||||
self->animations[id] = Anm2Animation{};
|
self->animations[id] = Anm2Animation{};
|
||||||
animation = &self->animations[id];
|
animation = &self->animations[id];
|
||||||
|
|
||||||
if (isFirstAnimationDone)
|
|
||||||
isLayerMapSet = true;
|
|
||||||
|
|
||||||
isFirstAnimationDone = true;
|
|
||||||
break;
|
break;
|
||||||
case ANM2_ELEMENT_ROOT_ANIMATION: // RootAnimation
|
case ANM2_ELEMENT_ROOT_ANIMATION: // RootAnimation
|
||||||
item = &animation->rootAnimation;
|
item = &animation->rootAnimation;
|
||||||
@@ -456,13 +450,10 @@ bool anm2_deserialize(Anm2* self, const std::string& path, bool isTextures)
|
|||||||
break;
|
break;
|
||||||
case ANM2_ATTRIBUTE_LAYER_ID: // LayerId
|
case ANM2_ATTRIBUTE_LAYER_ID: // LayerId
|
||||||
id = std::atoi(xmlAttribute->Value());
|
id = std::atoi(xmlAttribute->Value());
|
||||||
|
|
||||||
|
self->layerMap[layerMapIndex] = id;
|
||||||
|
layerMapIndex++;
|
||||||
|
|
||||||
if (!isLayerMapSet)
|
|
||||||
{
|
|
||||||
self->layerMap[layerMapIndex] = id;
|
|
||||||
layerMapIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
animation->layerAnimations[id] = addItem;
|
animation->layerAnimations[id] = addItem;
|
||||||
item = &animation->layerAnimations[id];
|
item = &animation->layerAnimations[id];
|
||||||
break;
|
break;
|
||||||
@@ -608,6 +599,9 @@ bool anm2_deserialize(Anm2* self, const std::string& path, bool isTextures)
|
|||||||
texture_from_path_init(&spritesheet->texture, spritesheet->path);
|
texture_from_path_init(&spritesheet->texture, spritesheet->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (anm2Element == ANM2_ELEMENT_ANIMATION)
|
||||||
|
layerMapIndex = 0;
|
||||||
|
|
||||||
xmlChild = xmlElement->FirstChildElement();
|
xmlChild = xmlElement->FirstChildElement();
|
||||||
|
|
||||||
if (xmlChild)
|
if (xmlChild)
|
||||||
@@ -633,9 +627,16 @@ bool anm2_deserialize(Anm2* self, const std::string& path, bool isTextures)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto& [id, animation] : self->animations)
|
for (auto& [id, animation] : self->animations)
|
||||||
|
{
|
||||||
if (animation.name == defaultAnimation)
|
if (animation.name == defaultAnimation)
|
||||||
self->defaultAnimationID = id;
|
self->defaultAnimationID = id;
|
||||||
|
|
||||||
|
for (auto& [i, id] : self->layerMap)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isTextures) anm2_spritesheet_texture_pixels_download(self);
|
if (isTextures) anm2_spritesheet_texture_pixels_download(self);
|
||||||
|
|
||||||
std::filesystem::current_path(workingPath);
|
std::filesystem::current_path(workingPath);
|
||||||
|
Reference in New Issue
Block a user