summaryrefslogtreecommitdiffhomepage
path: root/loader/atlas.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-25 19:37:06 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-25 19:37:06 +0100
commite46dd0f45d1cab35c7441d72f5dcac83720cc539 (patch)
tree1611ed041680e6dcccb115cbc7c99e098b809d33 /loader/atlas.cpp
parent1831d5d1eab5c9a607270a8a9b72a2ac1e6ce62a (diff)
add scenery horizontal mirroring
Diffstat (limited to 'loader/atlas.cpp')
-rw-r--r--loader/atlas.cpp16
1 files changed, 16 insertions, 0 deletions
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 <algorithm>
#include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/StridedArrayView.h>
@@ -34,6 +35,21 @@ std::shared_ptr<anim_atlas> 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());