From b504afef2ac7a151c7969cd29355b69d2af22282 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Mon, 23 Feb 2026 12:05:56 -0500 Subject: [PATCH] The ritual blanket now has the new animation and gained the ability to play the animation reversed for the closing animation. --- assets/animate2.json | 40 +++++++++++++++++++++++++++++++++++++++- gui/ritual_ui.cpp | 27 ++++++++++++++++++--------- gui/ritual_ui.hpp | 4 +++- 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/assets/animate2.json b/assets/animate2.json index c2e7fae..9ae360e 100644 --- a/assets/animate2.json +++ b/assets/animate2.json @@ -160,5 +160,43 @@ "sounds": { "idle": [] } - } + }, + "ritual_crafting_area": { + "sheet": { + "frames": 3, + "frame_width": 380, + "frame_height": 720 + }, + "sequences": { + "idle": {"frames": [0], "durations": [5] }, + "open": {"frames": [0, 1, 2], "durations": [5, 5, 5] }, + "close": {"frames": [2, 1, 0], "durations": [5, 5, 5] } + }, + "transforms": { + "basic": { + "min_x": 1.0, + "min_y": 1.0, + "max_x": 1.0, + "max_y": 1.0, + "flipped": false, + "scaled": false, + "toggled": true, + "looped": false, + "relative": false, + "easing": "none", + "motion": "move_none" + } + }, + "forms": { + "idle": ["idle", "basic"], + "open": ["open", "basic"], + "close": ["close", "basic"] + }, + "sounds": { + "idle": [], + "open": [], + "close": [] + } + + } } diff --git a/gui/ritual_ui.cpp b/gui/ritual_ui.cpp index 93af3d6..9670c58 100644 --- a/gui/ritual_ui.cpp +++ b/gui/ritual_ui.cpp @@ -1,9 +1,6 @@ #include "gui/ritual_ui.hpp" -#include "components.hpp" #include #include "rand.hpp" -#include "animation.hpp" -#include "rand.hpp" #include "sound.hpp" #include "events.hpp" #include "game_level.hpp" @@ -45,23 +42,24 @@ namespace gui { $ritual_ui = textures::get_sprite("ritual_crafting_area"); $ritual_ui.sprite->setPosition($gui.get_position()); $ritual_ui.sprite->setTextureRect($ritual_closed_rect); - $ritual_anim = animation::load("ritual_crafting_area"); + $ritual_anim = animate2::load("assets/animate2.json", "ritual_crafting_area"); auto open_close_toggle = $gui.entity("ritual_ui"); $gui.set(open_close_toggle, { [&](auto){ event(Event::TOGGLE); } }); - $craft_state = $ritual_engine.start(); $gui.init(); + play_blanket("idle"); state(State::CLOSED); } void UI::OPENED(Event ev, std::any data) { if(ev == Event::TOGGLE) { clear_blanket(); + play_blanket("close"); state(State::CLOSING); } else if(ev == Event::SELECT) { // do this before transitioning @@ -73,6 +71,7 @@ namespace gui { void UI::CRAFTING(Event ev, std::any data) { if(ev == Event::TOGGLE) { clear_blanket(); + play_blanket("close"); state(State::CLOSING); } else if(ev == Event::COMBINE) { complete_combine(); @@ -86,23 +85,28 @@ namespace gui { void UI::CLOSED(Event ev) { if(ev == Event::TOGGLE) { - $ritual_anim.play(); load_blanket(); + play_blanket("open"); state(State::OPENING); } } void UI::OPENING(Event ev) { if(ev == Event::TICK) { - if(!$ritual_anim.apply(*$ritual_ui.sprite, {0,0})) { + if($ritual_anim.playing) { + $ritual_anim.update(); + $ritual_anim.apply(*$ritual_ui.sprite); + } else { state(State::OPENED); } } } void UI::CLOSING(Event ev) { - if(ev == Event::TICK) { - $ritual_ui.sprite->setTextureRect($ritual_closed_rect); + if($ritual_anim.playing) { + $ritual_anim.update(); + $ritual_anim.apply(*$ritual_ui.sprite); + } else { state(State::CLOSED); } } @@ -247,6 +251,11 @@ namespace gui { $gui.close("result_image"); } + void UI::play_blanket(const std::string& form) { + $ritual_anim.set_form(form); + $ritual_anim.play(); + } + ::ritual::Blanket& UI::blanket() { auto world = GameDB::current_world(); return world->get_the<::ritual::Blanket>(); diff --git a/gui/ritual_ui.hpp b/gui/ritual_ui.hpp index 60d2736..ebcaba8 100644 --- a/gui/ritual_ui.hpp +++ b/gui/ritual_ui.hpp @@ -5,6 +5,7 @@ #include #include "rituals.hpp" #include "simplefsm.hpp" +#include "animate2.hpp" namespace gui { namespace ritual { @@ -34,7 +35,7 @@ namespace gui { public: sf::IntRect $ritual_closed_rect{{0,0},{380,720}}; sf::IntRect $ritual_open_rect{{380 * 2,0},{380,720}}; - components::Animation $ritual_anim; + animate2::Animate2 $ritual_anim; guecs::UI $gui; textures::SpriteTexture $ritual_ui; ::ritual::Engine $ritual_engine; @@ -61,6 +62,7 @@ namespace gui { void run_crafting_engine(); void complete_combine(); void update_selection_state(); + void play_blanket(const std::string& form); ::ritual::Blanket& blanket(); }; }