Initially implemented 'ritual blanket' UI for the crafting of rituals in combat.
This commit is contained in:
parent
263b7741f6
commit
65c9e4b0c6
5 changed files with 56 additions and 30 deletions
|
@ -250,7 +250,7 @@ namespace gui {
|
|||
}
|
||||
} else {
|
||||
$combat_ui.$gui.mouse(pos.x, pos.y);
|
||||
$status_ui.$gui.mouse(pos.x, pos.y);
|
||||
$status_ui.mouse(pos.x, pos.y);
|
||||
$main_ui.mouse(pos.x, pos.y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,31 +12,40 @@ namespace gui {
|
|||
{
|
||||
$gui.position(STATUS_UI_X, STATUS_UI_Y, STATUS_UI_WIDTH, STATUS_UI_HEIGHT);
|
||||
$gui.layout(
|
||||
"[ ritual_ui ]"
|
||||
"[inv_slot1 | inv_slot2 | inv_slot3]"
|
||||
"[inv_slot4 | inv_slot5 | inv_slot6]"
|
||||
"[*%(100,300)circle_area]"
|
||||
"[_]"
|
||||
"[_]");
|
||||
"[inv_slot5 | inv_slot6 | inv_slot7| inv_slot8]"
|
||||
"[inv_slot9 | inv_slot10 | inv_slot11| inv_slot12]"
|
||||
"[inv_slot13 | inv_slot14 | inv_slot15| inv_slot16]"
|
||||
"[inv_slot17 | inv_slot18 | inv_slot19| inv_slot20]"
|
||||
"[inv_slot21 | inv_slot22 | inv_slot23| inv_slot24]"
|
||||
"[*%(100,500)circle_area]"
|
||||
"[_]"
|
||||
"[_]"
|
||||
"[_]"
|
||||
"[_]"
|
||||
"[ ritual_ui ]");
|
||||
}
|
||||
|
||||
void RitualUI::init() {
|
||||
$gui.world().set_the<Background>({$gui.$parser});
|
||||
// $gui.world().set_the<Background>({$gui.$parser});
|
||||
|
||||
for(auto& [name, cell] : $gui.cells()) {
|
||||
if(name == "circle_area") {
|
||||
dbc::log("circle area not setup...");
|
||||
} else {
|
||||
auto button = $gui.entity(name);
|
||||
$gui.set<Rectangle>(button, {});
|
||||
$gui.set<Textual>(button, {""});
|
||||
$gui.set<ActionData>(button, {make_any<string>(name)});
|
||||
auto button = $gui.entity(name);
|
||||
|
||||
if(name == "ritual_ui") {
|
||||
$gui.set<Clickable>(button, {
|
||||
[this](auto, auto){ select_ritual(); }
|
||||
});
|
||||
}
|
||||
if(name == "circle_area") {
|
||||
// $gui.set<Rectangle>(button, {});
|
||||
$gui.set<Clickable>(button, {
|
||||
[this](auto, auto){ dbc::log("circle clicked"); }
|
||||
});
|
||||
} else if(name.starts_with("inv_slot")) {
|
||||
// $gui.set<Rectangle>(button, {});
|
||||
$gui.set<Clickable>(button, {
|
||||
[this, name](auto, auto){ dbc::log(fmt::format("inv_slot {}", name)); }
|
||||
});
|
||||
} else if(name == "ritual_ui") {
|
||||
$gui.set<Clickable>(button, {
|
||||
[this](auto, auto){ toggle(); }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +64,15 @@ namespace gui {
|
|||
$gui.init();
|
||||
}
|
||||
|
||||
void RitualUI::select_ritual() {
|
||||
bool RitualUI::is_open() {
|
||||
return $ritual_state != RitualUIState::CLOSED;
|
||||
}
|
||||
|
||||
bool RitualUI::mouse(float x, float y) {
|
||||
return $gui.mouse(x, y);
|
||||
}
|
||||
|
||||
void RitualUI::toggle() {
|
||||
using enum RitualUIState;
|
||||
|
||||
switch($ritual_state) {
|
||||
|
@ -117,5 +134,6 @@ namespace gui {
|
|||
$ritual_ui.sprite->setScale(scale);
|
||||
|
||||
window.draw(*$ritual_ui.sprite);
|
||||
if($ritual_state == OPEN) $gui.render(window);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,9 @@ namespace gui {
|
|||
GameLevel $level;
|
||||
|
||||
RitualUI(GameLevel level);
|
||||
void select_ritual();
|
||||
bool mouse(float x, float y);
|
||||
void toggle();
|
||||
bool is_open();
|
||||
void init();
|
||||
void render(sf::RenderWindow &window);
|
||||
void update();
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace gui {
|
|||
using std::any, std::any_cast, std::string, std::make_any;
|
||||
|
||||
StatusUI::StatusUI(GameLevel level) :
|
||||
$level(level)
|
||||
$level(level), $ritual_ui(level)
|
||||
{
|
||||
$gui.position(STATUS_UI_X, STATUS_UI_Y, STATUS_UI_WIDTH, STATUS_UI_HEIGHT);
|
||||
$gui.layout(
|
||||
|
@ -55,14 +55,20 @@ namespace gui {
|
|||
}
|
||||
}
|
||||
|
||||
$ritual_ui = textures::get("ritual_crafting_area");
|
||||
$ritual_ui.sprite->setPosition({0,0});
|
||||
$ritual_ui.sprite->setTextureRect($ritual_closed_rect);
|
||||
$ritual_ui.init();
|
||||
$gui.init();
|
||||
}
|
||||
|
||||
bool StatusUI::mouse(float x, float y) {
|
||||
if($ritual_ui.is_open()) {
|
||||
return $ritual_ui.mouse(x, y);
|
||||
} else {
|
||||
return $gui.mouse(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void StatusUI::select_ritual() {
|
||||
dbc::log("ritual selected but no way to trigger it yet");
|
||||
$ritual_ui.toggle();
|
||||
}
|
||||
|
||||
void StatusUI::select_slot(DinkyECS::Entity ent, any slot_name) {
|
||||
|
@ -128,7 +134,7 @@ namespace gui {
|
|||
|
||||
void StatusUI::render(sf::RenderWindow &window) {
|
||||
$gui.render(window);
|
||||
window.draw(*$ritual_ui.sprite);
|
||||
$ritual_ui.render(window);
|
||||
}
|
||||
|
||||
void StatusUI::log(string msg) {
|
||||
|
|
|
@ -4,23 +4,23 @@
|
|||
#include <deque>
|
||||
#include "textures.hpp"
|
||||
#include "guecs.hpp"
|
||||
#include "ritual_ui.hpp"
|
||||
|
||||
namespace gui {
|
||||
class StatusUI {
|
||||
public:
|
||||
sf::IntRect $ritual_closed_rect{{0,0},{380,720}};
|
||||
textures::SpriteTexture $ritual_ui;
|
||||
components::Animation $ritual_anim;
|
||||
guecs::UI $gui;
|
||||
DinkyECS::Entity $log_to;
|
||||
std::map<std::string, size_t> $slots;
|
||||
std::deque<std::string> $messages;
|
||||
GameLevel $level;
|
||||
RitualUI $ritual_ui;
|
||||
|
||||
StatusUI(GameLevel level);
|
||||
void select_slot(DinkyECS::Entity ent, std::any data);
|
||||
void select_ritual();
|
||||
void update_level(GameLevel &level);
|
||||
bool mouse(float x, float y);
|
||||
void log(std::string msg);
|
||||
void init();
|
||||
void render(sf::RenderWindow &window);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue