Boss fight now reuses the combat_ui.cpp to do the combat panel, so next is making it work with the mechanics I want but no art.
This commit is contained in:
parent
6ec43026b6
commit
8a828fbd31
11 changed files with 107 additions and 91 deletions
30
boss/ui.cpp
30
boss/ui.cpp
|
|
@ -7,6 +7,7 @@ namespace boss {
|
|||
UI::UI(shared_ptr<World> world, Entity boss_id) :
|
||||
$world(world),
|
||||
$boss_id(boss_id),
|
||||
$combat_ui(true),
|
||||
$boss_sprite(textures::get_sprite("test_boss")),
|
||||
$player_sprite(textures::get_sprite("test_player")),
|
||||
$floor_sprite(textures::get_sprite("test_floor"))
|
||||
|
|
@ -30,33 +31,27 @@ namespace boss {
|
|||
|
||||
position_sprite($boss_sprite, "boss2", 0.7, true);
|
||||
position_sprite($player_sprite, "player1", 0.5, true);
|
||||
position_sprite($floor_sprite, "floor2", 1.0, false);
|
||||
position_sprite($floor_sprite, "floor1", 1.0, false);
|
||||
|
||||
$arena.init();
|
||||
|
||||
$actions.position(0,0, SCREEN_WIDTH-BOSS_VIEW_WIDTH, SCREEN_HEIGHT);
|
||||
$actions.layout(
|
||||
"[action1|action2]"
|
||||
"[action3|action4]"
|
||||
"[action5|action6]"
|
||||
"[*(200)dodge]"
|
||||
"[*(200,400)combat|_]"
|
||||
"[_|_]"
|
||||
"[_|_]"
|
||||
"[_|_]"
|
||||
"[*(200,300)stats]"
|
||||
"[_]"
|
||||
"[_]");
|
||||
|
||||
for(auto& [name, cell] : $actions.cells()) {
|
||||
auto id = $actions.entity(name);
|
||||
$actions.set<Rectangle>(id, {});
|
||||
$actions.set<Text>(id, {guecs::to_wstring(name)});
|
||||
|
||||
if(name != "stats") {
|
||||
$actions.set<Clickable>(id, {
|
||||
[name](auto){ fmt::println("clicked {}", name); }
|
||||
});
|
||||
}
|
||||
}
|
||||
auto stats = $actions.entity("stats");
|
||||
$actions.set<Rectangle>(stats, {});
|
||||
$actions.set<Text>(stats, {L"stats"});
|
||||
|
||||
$actions.init();
|
||||
|
||||
auto& cell = $actions.cell_for("combat");
|
||||
$combat_ui.init(cell.x, cell.y, cell.w, cell.h);
|
||||
}
|
||||
|
||||
void UI::position_sprite(textures::SpriteTexture& st, const std::string& name, float scale, bool at_mid) {
|
||||
|
|
@ -71,6 +66,7 @@ namespace boss {
|
|||
void UI::render(sf::RenderWindow& window) {
|
||||
$arena.render(window);
|
||||
$actions.render(window);
|
||||
$combat_ui.render(window);
|
||||
window.draw(*$floor_sprite.sprite);
|
||||
window.draw(*$boss_sprite.sprite);
|
||||
window.draw(*$player_sprite.sprite);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include <guecs/ui.hpp>
|
||||
#include "textures.hpp"
|
||||
#include "gui/combat_ui.hpp"
|
||||
|
||||
namespace boss {
|
||||
using std::shared_ptr;
|
||||
|
|
@ -13,6 +14,7 @@ namespace boss {
|
|||
struct UI {
|
||||
shared_ptr<World> $world = nullptr;
|
||||
Entity $boss_id = NONE;
|
||||
gui::CombatUI $combat_ui;
|
||||
SpriteTexture $boss_sprite;
|
||||
SpriteTexture $player_sprite;
|
||||
SpriteTexture $floor_sprite;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue