diff --git a/boss/fight.cpp b/boss/fight.cpp index 7d75147..2224fd6 100644 --- a/boss/fight.cpp +++ b/boss/fight.cpp @@ -99,7 +99,6 @@ namespace boss { } } - void Fight::next_combat_dumb_name() { if(auto action = $battle.next()) { System::combat(*action, $world, $boss_id, 0); @@ -107,7 +106,6 @@ namespace boss { $ui.status(L"YOU DIED", L"DEAD"); state(State::END); } else { - $ui.zoom("", 1.0); $ui.status(L"PLAYER REQUESTS", L"COMMIT"); $battle.ap_refresh(); $battle.clear_requests(); diff --git a/boss/ui.cpp b/boss/ui.cpp index 9889665..0c244fa 100644 --- a/boss/ui.cpp +++ b/boss/ui.cpp @@ -22,7 +22,6 @@ namespace boss { $view_sprite($view_texture.getTexture()) { $view_sprite.setPosition({BOSS_VIEW_X, BOSS_VIEW_Y}); - $camera.style("shake"); } void UI::init() { @@ -80,7 +79,6 @@ namespace boss { $combat_ui.render(*$window); $arena.render($view_texture); - $camera.render($view_texture); $view_texture.display(); $window->draw($view_sprite); } @@ -115,17 +113,4 @@ namespace boss { $arena.apply_effect(actor, "flame"); } } - - void UI::zoom(const std::string &cell_name, double ratio) { - if(cell_name == "") { - dbc::log("!!!!!!!!! you should add this to guecs"); - $camera.reset($view_texture, BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT); - } else { - auto& cell = $arena.$ui.cell_for(cell_name); - - $camera.resize(double(BOSS_VIEW_WIDTH)/ratio, double(BOSS_VIEW_HEIGHT)/ratio); - $camera.move(float(cell.mid_x), float(cell.mid_y)); - $camera.play(); - } - } } diff --git a/boss/ui.hpp b/boss/ui.hpp index f7a9dd5..48a177a 100644 --- a/boss/ui.hpp +++ b/boss/ui.hpp @@ -3,7 +3,6 @@ #include #include "gui/combat_ui.hpp" #include "scene.hpp" -#include "camera.hpp" namespace components { struct Animation; @@ -27,7 +26,6 @@ namespace boss { guecs::UI $actions; sf::RenderTexture $view_texture; sf::Sprite $view_sprite; - cinematic::Camera $camera; UI(shared_ptr world, DinkyECS::Entity boss_id, DinkyECS::Entity player_id); @@ -40,7 +38,6 @@ namespace boss { void animate_actor(const std::string& actor); void update_stats(); void play_animations(); - void zoom(const std::string& cell, double ratio); void damage(const std::string& actor, int amount); }; } diff --git a/scene.cpp b/scene.cpp index 5489c54..d9f5ca3 100644 --- a/scene.cpp +++ b/scene.cpp @@ -34,6 +34,8 @@ namespace scene { Engine::Engine(components::AnimatedScene& scene) : $scene(scene) { + $camera.style("shake"); + for(auto& config : $scene.actors) { auto element = config_scene_element(config, false, false); dbc::check(!$actor_name_ids.contains(element.name), @@ -90,19 +92,20 @@ namespace scene { return $ui.mouse(x, y, mods); } - void Engine::render(sf::RenderTarget& window) { - $ui.render(window); + void Engine::render(sf::RenderTexture& view) { + $ui.render(view); for(auto& fixture : $fixtures) { - window.draw(*fixture.st.sprite, fixture.effect.get()); + view.draw(*fixture.st.sprite, fixture.effect.get()); } for(auto& actor : $actors) { - window.draw(*actor.st.sprite, actor.effect.get()); - if(actor.anim.playing) window.draw(actor.text); + view.draw(*actor.st.sprite, actor.effect.get()); + if(actor.anim.playing) view.draw(actor.text); } - if(DEBUG) $ui.debug_layout(window); + $camera.render(view); + if(DEBUG) $ui.debug_layout(view); } Element& Engine::actor_config(const std::string& actor) { @@ -154,4 +157,18 @@ namespace scene { return pos; } + + void Engine::zoom(int mid_x, int mid_y, int width, int height) { + $camera.resize(float(width), float(height)); + $camera.move(float(mid_x), float(mid_y)); + } + + void Engine::zoom(const std::string &cell_name) { + auto& cell = $ui.cell_for(cell_name); + zoom(cell.w, cell.h, cell.mid_x, cell.mid_y); + } + + void Engine::reset(sf::RenderTexture& view, float width, float height) { + $camera.reset(view, width, height); + } } diff --git a/scene.hpp b/scene.hpp index b23ebc0..1be458e 100644 --- a/scene.hpp +++ b/scene.hpp @@ -5,6 +5,7 @@ #include "textures.hpp" #include #include +#include "camera.hpp" namespace scene { using std::shared_ptr; @@ -33,11 +34,12 @@ namespace scene { std::unordered_map $actor_name_ids; std::vector $fixtures; std::vector $actors; + cinematic::Camera $camera; Engine(components::AnimatedScene& scene); void init(); - void render(sf::RenderTarget& window); + void render(sf::RenderTexture& view); bool mouse(float x, float y, guecs::Modifiers mods); void attach_text(const std::string& actor, const std::string& text); Element config_scene_element(nlohmann::json& config, bool and_play, bool duped); @@ -49,5 +51,8 @@ namespace scene { void play_animations(); void apply_effect(const std::string& actor, const std::string& shader); Element& actor_config(const std::string& actor); + void zoom(const std::string& cell); + void reset(sf::RenderTexture& view, float width, float height); + void zoom(int mid_x, int mid_y, int width, int height); }; }