Boss UI buttons in place and ready to work.
This commit is contained in:
parent
d398b042a7
commit
6ec43026b6
2 changed files with 38 additions and 13 deletions
48
boss/ui.cpp
48
boss/ui.cpp
|
|
@ -14,12 +14,12 @@ namespace boss {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::init() {
|
void UI::init() {
|
||||||
$gui.position(SCREEN_WIDTH-BOSS_VIEW_WIDTH,0, BOSS_VIEW_WIDTH, SCREEN_HEIGHT);
|
$arena.position(SCREEN_WIDTH-BOSS_VIEW_WIDTH,0, BOSS_VIEW_WIDTH, SCREEN_HEIGHT);
|
||||||
$gui.set<Background>($gui.MAIN, {$gui.$parser, THEME.DARK_MID});
|
$arena.set<Background>($arena.MAIN, {$arena.$parser, THEME.DARK_MID});
|
||||||
auto& background = $gui.get<Background>($gui.MAIN);
|
auto& background = $arena.get<Background>($arena.MAIN);
|
||||||
background.set_sprite("test_background", true);
|
background.set_sprite("test_background", true);
|
||||||
|
|
||||||
$gui.layout(
|
$arena.layout(
|
||||||
"[a1|boss1|boss2|boss3|e1|f1]"
|
"[a1|boss1|boss2|boss3|e1|f1]"
|
||||||
"[a2|b2|c2|d2|e2|f2]"
|
"[a2|b2|c2|d2|e2|f2]"
|
||||||
"[floor2|b3|c3|d3|e3|f3]"
|
"[floor2|b3|c3|d3|e3|f3]"
|
||||||
|
|
@ -28,16 +28,39 @@ namespace boss {
|
||||||
"[a6|b6|c6|d6|e6|f6]"
|
"[a6|b6|c6|d6|e6|f6]"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
position_sprite($boss_sprite, "boss2", 0.7, true);
|
||||||
position_sprite($boss_sprite, "boss2", 0.4, true);
|
|
||||||
position_sprite($player_sprite, "player1", 0.5, true);
|
position_sprite($player_sprite, "player1", 0.5, true);
|
||||||
position_sprite($floor_sprite, "floor2", 1.0, false);
|
position_sprite($floor_sprite, "floor2", 1.0, false);
|
||||||
|
|
||||||
$gui.init();
|
$arena.init();
|
||||||
|
|
||||||
|
$actions.position(0,0, SCREEN_WIDTH-BOSS_VIEW_WIDTH, SCREEN_HEIGHT);
|
||||||
|
$actions.layout(
|
||||||
|
"[action1|action2]"
|
||||||
|
"[action3|action4]"
|
||||||
|
"[action5|action6]"
|
||||||
|
"[*(200)dodge]"
|
||||||
|
"[*(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); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$actions.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::position_sprite(textures::SpriteTexture& st, const std::string& name, float scale, bool at_mid) {
|
void UI::position_sprite(textures::SpriteTexture& st, const std::string& name, float scale, bool at_mid) {
|
||||||
auto& cell = $gui.cell_for(name);
|
auto& cell = $arena.cell_for(name);
|
||||||
float x = float(at_mid ? cell.mid_x : cell.x);
|
float x = float(at_mid ? cell.mid_x : cell.x);
|
||||||
float y = float(at_mid ? cell.mid_y : cell.y);
|
float y = float(at_mid ? cell.mid_y : cell.y);
|
||||||
|
|
||||||
|
|
@ -46,18 +69,19 @@ namespace boss {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::render(sf::RenderWindow& window) {
|
void UI::render(sf::RenderWindow& window) {
|
||||||
$gui.render(window);
|
$arena.render(window);
|
||||||
|
$actions.render(window);
|
||||||
window.draw(*$floor_sprite.sprite);
|
window.draw(*$floor_sprite.sprite);
|
||||||
window.draw(*$boss_sprite.sprite);
|
window.draw(*$boss_sprite.sprite);
|
||||||
window.draw(*$player_sprite.sprite);
|
window.draw(*$player_sprite.sprite);
|
||||||
// $gui.debug_layout(window);
|
// $arena.debug_layout(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UI::mouse(float x, float y, Modifiers mods) {
|
bool UI::mouse(float x, float y, Modifiers mods) {
|
||||||
return $gui.mouse(x, y, mods);
|
return $actions.mouse(x, y, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UI::boss_dead() {
|
bool UI::boss_dead() {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ namespace boss {
|
||||||
SpriteTexture $boss_sprite;
|
SpriteTexture $boss_sprite;
|
||||||
SpriteTexture $player_sprite;
|
SpriteTexture $player_sprite;
|
||||||
SpriteTexture $floor_sprite;
|
SpriteTexture $floor_sprite;
|
||||||
guecs::UI $gui;
|
guecs::UI $arena;
|
||||||
|
guecs::UI $actions;
|
||||||
|
|
||||||
UI(shared_ptr<World> world, Entity boss_id);
|
UI(shared_ptr<World> world, Entity boss_id);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue