diff --git a/Makefile b/Makefile index a30e660..9b12693 100644 --- a/Makefile +++ b/Makefile @@ -78,4 +78,4 @@ story: gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args ./builddir/storyboard animator: - gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args ./builddir/animator.exe -s "rat_king_boss" -a "rat_king_boss" -b "test_background" + gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args ./builddir/animator "rat_king_boss" diff --git a/assets/animate2.json b/assets/animate2.json index 1e0131d..119111a 100644 --- a/assets/animate2.json +++ b/assets/animate2.json @@ -21,28 +21,5 @@ "toggled": false, "looped": true } - }, - "rat_king_meth": { - "sheet": { - "frames": 2, - "frame_width": 720, - "frame_height": 720 - }, - "sequence": { - "frames": [0, 1], - "durations": [33, 33] - }, - "transform": { - "min_x": 0.6, - "min_y": 0.6, - "max_x": 0.8, - "max_y": 0.8, - "simple": false, - "flipped": false, - "ease_rate": 5.0, - "scaled": true, - "toggled": false, - "looped": true - } } } diff --git a/tools/animator.cpp b/tools/animator.cpp index 7f18cd9..bfd0e07 100644 --- a/tools/animator.cpp +++ b/tools/animator.cpp @@ -8,16 +8,6 @@ #include "constants.hpp" #include "animate2.hpp" #include "tools/animator.hpp" -#include - -/* - * TODO: - * - * - Setting a background. - * - Options parsing for that. - * - Easing functions from strings in json. - * - Map of animation forms. - */ using namespace std::chrono_literals; @@ -25,11 +15,9 @@ bool YES_SYNC=true; namespace animator { - void FSM::init(const std::string &sprite_name, const std::string &anim_name, const std::string &background) { + void FSM::init(const std::string &sprite_name) { $timer.start(); $sprite_name = sprite_name; - $anim_name = anim_name; - $background = background; // this loads the animation reload(); @@ -38,7 +26,7 @@ namespace animator { $window = sf::RenderWindow(sf::VideoMode(new_size), "Animation Crafting Tool"); $window.setPosition({0,0}); - $ui.init($sprite_name, $background, new_size.x, new_size.y); + $ui.init($sprite_name, new_size.x, new_size.y); $sprite = $ui.get_sprite(); // need to keep these aroung @@ -49,6 +37,7 @@ namespace animator { $window.setVerticalSyncEnabled(VSYNC); if(FRAME_LIMIT) $window.setFramerateLimit(FRAME_LIMIT); } + } void FSM::event(Event ev, std::any data) { @@ -122,7 +111,7 @@ namespace animator { } void FSM::reload() { - $anim = animate2::load("assets/animate2.json", $anim_name); + $anim = animate2::load("assets/animate2.json", $sprite_name); $anim.play(); $last_mod_time = std::filesystem::last_write_time("assets/animate2.json"); } @@ -164,16 +153,10 @@ namespace animator { return !in_state(State::END); } - void UI::init(const std::string& sprite_name, const std::string& background, int width, int height) { + void UI::init(const std::string& sprite_name, int width, int height) { $ui.position(0,0, width, height); $ui.layout("[=viewer]"); - if(background != "") { - $ui.set($ui.MAIN, {$ui.$parser, guecs::THEME.TRANSPARENT}); - auto& bg = $ui.get($ui.MAIN); - bg.set_sprite(background, true); - } - auto viewer = $ui.entity("viewer"); $ui.set(viewer, { sprite_name, 0, false}); @@ -198,11 +181,6 @@ namespace animator { } } -int error() { - fmt::println("USAGE: animator -h -b -s -a "); - return 1; -} - int main(int argc, char* argv[]) { shaders::init(); components::init(); @@ -211,42 +189,14 @@ int main(int argc, char* argv[]) { ai::init("ai"); animation::init(); - std::string sprite_name; - std::string background; - std::string anim_name; - int opt = 0; - - while((opt = getopt(argc, argv, "hb:s:a:")) != -1) { - switch(opt) { - case 'b': - background = optarg; - break; - case 's': - sprite_name = optarg; - break; - case 'a': - anim_name = optarg; - break; - case 'h': // fallthrough - error(); - break; - default: - return error(); - break; - } - } - - if(sprite_name == "") { - return error(); - } else if(anim_name == "") { - anim_name = sprite_name; // default to the same - } + dbc::check(argc == 2, "USAGE: animator "); + std::string sprite_name{argv[1]}; sound::mute(true); sound::play("ambient_1", true); animator::FSM main; - main.init(sprite_name, anim_name, background); + main.init(sprite_name); while(main.active()) { main.tick(); diff --git a/tools/animator.hpp b/tools/animator.hpp index 66a745b..7fce351 100644 --- a/tools/animator.hpp +++ b/tools/animator.hpp @@ -25,7 +25,7 @@ namespace animator { guecs::UI $ui; void button(const std::string& name, std::function cb); - void init(const std::string& sprite_name, const std::string& background, int width, int height); + void init(const std::string& sprite_name, int width, int height); void render(sf::RenderWindow& window, bool debug=false); bool mouse(float x, float y, guecs::Modifiers mods); std::shared_ptr get_sprite(); @@ -40,12 +40,10 @@ namespace animator { std::shared_ptr $sprite = nullptr; animate2::Animate2 $anim; std::string $sprite_name=""; - std::string $anim_name=""; - std::string $background=""; std::filesystem::file_time_type $last_mod_time; sf::Clock $timer; - void init(const std::string &sprite_name, const std::string& background, const std::string &anim_name); + void init(const std::string &sprite_name); void event(Event ev, std::any data={}); void START(Event ev); void ANIMATE(Event ev);