Animator now starts off as being the size of the sprite.
This commit is contained in:
parent
ce3d142208
commit
961a470844
2 changed files with 21 additions and 11 deletions
|
|
@ -18,21 +18,26 @@ namespace animator {
|
|||
void FSM::init(const std::string &sprite_name) {
|
||||
$timer.start();
|
||||
$sprite_name = sprite_name;
|
||||
$ui.init($sprite_name);
|
||||
|
||||
// this loads the animation
|
||||
reload();
|
||||
|
||||
sf::Vector2u new_size{(unsigned int)$anim.sheet.frame_width, (unsigned int)$anim.sheet.frame_height};
|
||||
$window = sf::RenderWindow(sf::VideoMode(new_size), "Animation Crafting Tool");
|
||||
$window.setPosition({0,0});
|
||||
|
||||
$ui.init($sprite_name, win_size.x, win_size.y);
|
||||
$sprite = $ui.get_sprite();
|
||||
|
||||
// need to keep these aroung
|
||||
$pos = $sprite->getPosition();
|
||||
$scale = $sprite->getScale();
|
||||
|
||||
$window.setPosition({0,0});
|
||||
|
||||
if(YES_SYNC) {
|
||||
$window.setVerticalSyncEnabled(VSYNC);
|
||||
if(FRAME_LIMIT) $window.setFramerateLimit(FRAME_LIMIT);
|
||||
}
|
||||
|
||||
reload();
|
||||
}
|
||||
|
||||
void FSM::event(Event ev, std::any data) {
|
||||
|
|
@ -136,7 +141,7 @@ namespace animator {
|
|||
|
||||
void FSM::render() {
|
||||
$window.clear();
|
||||
$ui.render($window);
|
||||
$ui.render($window, true);
|
||||
$window.display();
|
||||
}
|
||||
|
||||
|
|
@ -144,8 +149,9 @@ namespace animator {
|
|||
return !in_state(State::END);
|
||||
}
|
||||
|
||||
void UI::init(const std::string& sprite_name) {
|
||||
$ui.position(0,0, BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT);
|
||||
void UI::init(const std::string& sprite_name, int width, int height) {
|
||||
fmt::println("IN UI SIZE IS {},{}", width, height);
|
||||
$ui.position(0,0, width, height);
|
||||
$ui.layout("[=viewer]");
|
||||
|
||||
auto viewer = $ui.entity("viewer");
|
||||
|
|
@ -154,8 +160,12 @@ namespace animator {
|
|||
$ui.init();
|
||||
}
|
||||
|
||||
void UI::render(sf::RenderWindow& window) {
|
||||
void UI::render(sf::RenderWindow& window, bool debug) {
|
||||
$ui.render(window);
|
||||
|
||||
if(debug) {
|
||||
$ui.debug_layout(window);
|
||||
}
|
||||
}
|
||||
|
||||
bool UI::mouse(float x, float y, guecs::Modifiers mods) {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ namespace animator {
|
|||
guecs::UI $ui;
|
||||
|
||||
void button(const std::string& name, std::function<void(guecs::Modifiers mods)> cb);
|
||||
void init(const std::string& sprite_name);
|
||||
void render(sf::RenderWindow& window);
|
||||
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<sf::Sprite> get_sprite();
|
||||
};
|
||||
|
|
@ -34,7 +34,7 @@ namespace animator {
|
|||
struct FSM : public DeadSimpleFSM<State, Event> {
|
||||
UI $ui;
|
||||
gui::routing::Router $router;
|
||||
sf::RenderWindow $window{sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Animation Crafting Tool"};
|
||||
sf::RenderWindow $window;
|
||||
sf::Vector2f $pos{0,0};
|
||||
sf::Vector2f $scale{0,0};
|
||||
std::shared_ptr<sf::Sprite> $sprite = nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue