Moved the camera into the scene where it belongs.
This commit is contained in:
parent
c71566048e
commit
5676382fbb
5 changed files with 29 additions and 27 deletions
|
|
@ -99,7 +99,6 @@ namespace boss {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Fight::next_combat_dumb_name() {
|
void Fight::next_combat_dumb_name() {
|
||||||
if(auto action = $battle.next()) {
|
if(auto action = $battle.next()) {
|
||||||
System::combat(*action, $world, $boss_id, 0);
|
System::combat(*action, $world, $boss_id, 0);
|
||||||
|
|
@ -107,7 +106,6 @@ namespace boss {
|
||||||
$ui.status(L"YOU DIED", L"DEAD");
|
$ui.status(L"YOU DIED", L"DEAD");
|
||||||
state(State::END);
|
state(State::END);
|
||||||
} else {
|
} else {
|
||||||
$ui.zoom("", 1.0);
|
|
||||||
$ui.status(L"PLAYER REQUESTS", L"COMMIT");
|
$ui.status(L"PLAYER REQUESTS", L"COMMIT");
|
||||||
$battle.ap_refresh();
|
$battle.ap_refresh();
|
||||||
$battle.clear_requests();
|
$battle.clear_requests();
|
||||||
|
|
|
||||||
15
boss/ui.cpp
15
boss/ui.cpp
|
|
@ -22,7 +22,6 @@ namespace boss {
|
||||||
$view_sprite($view_texture.getTexture())
|
$view_sprite($view_texture.getTexture())
|
||||||
{
|
{
|
||||||
$view_sprite.setPosition({BOSS_VIEW_X, BOSS_VIEW_Y});
|
$view_sprite.setPosition({BOSS_VIEW_X, BOSS_VIEW_Y});
|
||||||
$camera.style("shake");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::init() {
|
void UI::init() {
|
||||||
|
|
@ -80,7 +79,6 @@ namespace boss {
|
||||||
$combat_ui.render(*$window);
|
$combat_ui.render(*$window);
|
||||||
|
|
||||||
$arena.render($view_texture);
|
$arena.render($view_texture);
|
||||||
$camera.render($view_texture);
|
|
||||||
$view_texture.display();
|
$view_texture.display();
|
||||||
$window->draw($view_sprite);
|
$window->draw($view_sprite);
|
||||||
}
|
}
|
||||||
|
|
@ -115,17 +113,4 @@ namespace boss {
|
||||||
$arena.apply_effect(actor, "flame");
|
$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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
#include <guecs/ui.hpp>
|
#include <guecs/ui.hpp>
|
||||||
#include "gui/combat_ui.hpp"
|
#include "gui/combat_ui.hpp"
|
||||||
#include "scene.hpp"
|
#include "scene.hpp"
|
||||||
#include "camera.hpp"
|
|
||||||
|
|
||||||
namespace components {
|
namespace components {
|
||||||
struct Animation;
|
struct Animation;
|
||||||
|
|
@ -27,7 +26,6 @@ namespace boss {
|
||||||
guecs::UI $actions;
|
guecs::UI $actions;
|
||||||
sf::RenderTexture $view_texture;
|
sf::RenderTexture $view_texture;
|
||||||
sf::Sprite $view_sprite;
|
sf::Sprite $view_sprite;
|
||||||
cinematic::Camera $camera;
|
|
||||||
|
|
||||||
UI(shared_ptr<DinkyECS::World> world, DinkyECS::Entity boss_id, DinkyECS::Entity player_id);
|
UI(shared_ptr<DinkyECS::World> world, DinkyECS::Entity boss_id, DinkyECS::Entity player_id);
|
||||||
|
|
||||||
|
|
@ -40,7 +38,6 @@ namespace boss {
|
||||||
void animate_actor(const std::string& actor);
|
void animate_actor(const std::string& actor);
|
||||||
void update_stats();
|
void update_stats();
|
||||||
void play_animations();
|
void play_animations();
|
||||||
void zoom(const std::string& cell, double ratio);
|
|
||||||
void damage(const std::string& actor, int amount);
|
void damage(const std::string& actor, int amount);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
29
scene.cpp
29
scene.cpp
|
|
@ -34,6 +34,8 @@ namespace scene {
|
||||||
Engine::Engine(components::AnimatedScene& scene) :
|
Engine::Engine(components::AnimatedScene& scene) :
|
||||||
$scene(scene)
|
$scene(scene)
|
||||||
{
|
{
|
||||||
|
$camera.style("shake");
|
||||||
|
|
||||||
for(auto& config : $scene.actors) {
|
for(auto& config : $scene.actors) {
|
||||||
auto element = config_scene_element(config, false, false);
|
auto element = config_scene_element(config, false, false);
|
||||||
dbc::check(!$actor_name_ids.contains(element.name),
|
dbc::check(!$actor_name_ids.contains(element.name),
|
||||||
|
|
@ -90,19 +92,20 @@ namespace scene {
|
||||||
return $ui.mouse(x, y, mods);
|
return $ui.mouse(x, y, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::render(sf::RenderTarget& window) {
|
void Engine::render(sf::RenderTexture& view) {
|
||||||
$ui.render(window);
|
$ui.render(view);
|
||||||
|
|
||||||
for(auto& fixture : $fixtures) {
|
for(auto& fixture : $fixtures) {
|
||||||
window.draw(*fixture.st.sprite, fixture.effect.get());
|
view.draw(*fixture.st.sprite, fixture.effect.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& actor : $actors) {
|
for(auto& actor : $actors) {
|
||||||
window.draw(*actor.st.sprite, actor.effect.get());
|
view.draw(*actor.st.sprite, actor.effect.get());
|
||||||
if(actor.anim.playing) window.draw(actor.text);
|
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) {
|
Element& Engine::actor_config(const std::string& actor) {
|
||||||
|
|
@ -154,4 +157,18 @@ namespace scene {
|
||||||
|
|
||||||
return pos;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include "textures.hpp"
|
#include "textures.hpp"
|
||||||
#include <SFML/Graphics/RenderWindow.hpp>
|
#include <SFML/Graphics/RenderWindow.hpp>
|
||||||
#include <guecs/ui.hpp>
|
#include <guecs/ui.hpp>
|
||||||
|
#include "camera.hpp"
|
||||||
|
|
||||||
namespace scene {
|
namespace scene {
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
|
@ -33,11 +34,12 @@ namespace scene {
|
||||||
std::unordered_map<std::string, int> $actor_name_ids;
|
std::unordered_map<std::string, int> $actor_name_ids;
|
||||||
std::vector<Element> $fixtures;
|
std::vector<Element> $fixtures;
|
||||||
std::vector<Element> $actors;
|
std::vector<Element> $actors;
|
||||||
|
cinematic::Camera $camera;
|
||||||
|
|
||||||
Engine(components::AnimatedScene& scene);
|
Engine(components::AnimatedScene& scene);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void render(sf::RenderTarget& window);
|
void render(sf::RenderTexture& view);
|
||||||
bool mouse(float x, float y, guecs::Modifiers mods);
|
bool mouse(float x, float y, guecs::Modifiers mods);
|
||||||
void attach_text(const std::string& actor, const std::string& text);
|
void attach_text(const std::string& actor, const std::string& text);
|
||||||
Element config_scene_element(nlohmann::json& config, bool and_play, bool duped);
|
Element config_scene_element(nlohmann::json& config, bool and_play, bool duped);
|
||||||
|
|
@ -49,5 +51,8 @@ namespace scene {
|
||||||
void play_animations();
|
void play_animations();
|
||||||
void apply_effect(const std::string& actor, const std::string& shader);
|
void apply_effect(const std::string& actor, const std::string& shader);
|
||||||
Element& actor_config(const std::string& actor);
|
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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue