Small error in how mouse events are processed. I need to do them _outside_ of the guecs::UI so that the event is checked once and then confirmed in all grids. Then created a tombstone device to be used as a dead enemy marker that will later allow looting.
This commit is contained in:
parent
6447f86954
commit
e04c03b381
8 changed files with 37 additions and 17 deletions
21
guecs.cpp
21
guecs.cpp
|
@ -91,18 +91,15 @@ namespace guecs {
|
|||
});
|
||||
}
|
||||
|
||||
void UI::mouse(sf::RenderWindow &window) {
|
||||
if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) {
|
||||
sf::Vector2f pos = window.mapPixelToCoords(sf::Mouse::getPosition(window));
|
||||
$world.query<lel::Cell, Clickable>([&](auto ent, auto& cell, auto &clicked) {
|
||||
if((pos.x >= cell.x && pos.x <= cell.x + cell.w) &&
|
||||
(pos.y >= cell.y && pos.y <= cell.y + cell.h))
|
||||
{
|
||||
auto& cn = $world.get<CellName>(ent);
|
||||
clicked.action(ent, cn.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
void UI::mouse(float x, float y) {
|
||||
$world.query<lel::Cell, Clickable>([&](auto ent, auto& cell, auto &clicked) {
|
||||
if((x >= cell.x && x <= cell.x + cell.w) &&
|
||||
(y >= cell.y && y <= cell.y + cell.h))
|
||||
{
|
||||
auto& cn = $world.get<CellName>(ent);
|
||||
clicked.action(ent, cn.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Clickable make_action(DinkyECS::World& target, Events::GUI event) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue