From e46dd0f45d1cab35c7441d72f5dcac83720cc539 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Nov 2022 19:37:06 +0100 Subject: add scenery horizontal mirroring --- loader/atlas.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'loader') diff --git a/loader/atlas.cpp b/loader/atlas.cpp index 1aaa4e31..659f716a 100644 --- a/loader/atlas.cpp +++ b/loader/atlas.cpp @@ -3,6 +3,7 @@ #include "src/emplacer.hpp" #include "src/tile-atlas.hpp" #include "src/anim-atlas.hpp" +#include #include #include #include @@ -34,6 +35,21 @@ std::shared_ptr loader_impl::anim_atlas(StringView name) { const auto path = Path::join(ANIM_PATH, Path::splitExtension(name).first()); auto anim_info = deserialize_anim(path + ".json"); + + for (anim_group& group : anim_info.groups) + { + if (!group.mirror_from.isEmpty()) + { + auto it = std::find_if(anim_info.groups.cbegin(), anim_info.groups.cend(), + [&](const anim_group& x) { return x.name == group.mirror_from; }); + if (it == anim_info.groups.cend()) + fm_abort("can't find group '%s' to mirror from '%s'", group.mirror_from.data(), group.name.data()); + group.frames = it->frames; + for (anim_frame& f : group.frames) + f.ground = Vector2i((Int)f.size[0] - f.ground[0], f.ground[1]); + } + } + auto tex = texture("", path); fm_assert(!anim_info.object_name.isEmpty()); -- cgit v1.2.3