mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-31 09:32:02 +00:00
Handling buttons on key up
This commit is contained in:
@@ -55,24 +55,24 @@ namespace BBM
|
||||
bool MenuControllableSystem::_mouseOnButton(const Vector2f &mousePos, WAL::ViewEntity<OnClickComponent, OnHoverComponent, OnIdleComponent, PositionComponent, Drawable2DComponent> &entity) const
|
||||
{
|
||||
auto &positionComponent = entity.get<PositionComponent>();
|
||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.get<Drawable2DComponent>().drawable.get());
|
||||
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(entity.get<Drawable2DComponent>().drawable.get());
|
||||
Vector2f buttonPos(positionComponent.getX(), positionComponent.getY());
|
||||
Vector2f dimensions;
|
||||
|
||||
if (texture) {
|
||||
if (auto *texture = dynamic_cast<RAY::Texture *>(entity.get<Drawable2DComponent>().drawable.get())) {
|
||||
dimensions.x = texture->getDimensions().x;
|
||||
dimensions.y = texture->getDimensions().y;
|
||||
} else if (text) {
|
||||
}
|
||||
else if (auto *text = dynamic_cast<RAY2D::Text *>(entity.get<Drawable2DComponent>().drawable.get())) {
|
||||
dimensions.y = text->getFontSize();
|
||||
dimensions.x = text->getString().size() * (text->getFontSize());
|
||||
} else
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return ((buttonPos.x <= mousePos.x && mousePos.x <= buttonPos.x + dimensions.x)
|
||||
&& (buttonPos.y <= mousePos.y && mousePos.y <= buttonPos.y + dimensions.y));
|
||||
&& (buttonPos.y <= mousePos.y && mousePos.y <= buttonPos.y + dimensions.y));
|
||||
}
|
||||
|
||||
void MenuControllableSystem::onSelfUpdate(std::chrono::nanoseconds dtime)
|
||||
void MenuControllableSystem::onSelfUpdate(std::chrono::nanoseconds)
|
||||
{
|
||||
RAY::Vector2 rayMousePos = RAYControl::Mouse::getCursorPosition();
|
||||
RAY::Vector2 winSize = RAY::Window::getInstance().getDimensions();
|
||||
|
||||
Reference in New Issue
Block a user