mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-30 01:05:24 +00:00
Merge branch 'develop' of github.com:AnonymusRaccoon/Bomberman into soundfix
This commit is contained in:
@@ -62,4 +62,7 @@ namespace BBM
|
||||
// interact with bombs (getting damage etc) but doesn't stop explosion
|
||||
constexpr const char BlowablePass[] = "BlowablePass";
|
||||
constexpr const char Timer[] = "Timer";
|
||||
constexpr const char RestartTimer[] = "RestartTimer";
|
||||
constexpr const char ResumeButton[] = "ResumeButton";
|
||||
constexpr const char PlayButton[] = "PlayButton";
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
#include "Runner.hpp"
|
||||
#include <map>
|
||||
#include "Component/Tag/TagComponent.hpp"
|
||||
#include <Parser/ParserYaml.hpp>
|
||||
#include <Component/Bonus/PlayerBonusComponent.hpp>
|
||||
#include <Component/Renderer/Drawable2DComponent.hpp>
|
||||
#include "Component/Music/MusicComponent.hpp"
|
||||
#include "Component/Sound/SoundComponent.hpp"
|
||||
#include "Component/Controllable/ControllableComponent.hpp"
|
||||
@@ -18,7 +16,6 @@
|
||||
#include "Component/Collision/CollisionComponent.hpp"
|
||||
#include "Component/Movable/MovableComponent.hpp"
|
||||
#include "Component/BombHolder/BombHolderComponent.hpp"
|
||||
#include "Component/Tag/TagComponent.hpp"
|
||||
#include "Component/Renderer/Drawable3DComponent.hpp"
|
||||
#include "Component/Shaders/Items/AlphaCtxShaderComponent.hpp"
|
||||
#include "Component/Speed/SpeedComponent.hpp"
|
||||
@@ -26,7 +23,6 @@
|
||||
#include "Component/Shaders/ShaderComponent.hpp"
|
||||
#include "Component/Gravity/GravityComponent.hpp"
|
||||
#include "Component/BumperTimer/BumperTimerComponent.hpp"
|
||||
#include "Component/Timer/TimerComponent.hpp"
|
||||
#include "Model/Model.hpp"
|
||||
#include "Map/Map.hpp"
|
||||
#include "Component/Score/ScoreComponent.hpp"
|
||||
@@ -48,6 +44,7 @@ namespace BBM
|
||||
scene->addEntity("background image")
|
||||
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/map/breakable_wall.obj", true, std::make_pair(MAP_DIFFUSE, "assets/backgrounds/gameWall.png"), Vector3f(50, 1, 50), -90, Vector3f(), Vector3f(1, 0, 0))
|
||||
.addComponent<PositionComponent>(5, 14, 22);
|
||||
addMenuControl(*scene);
|
||||
return scene;
|
||||
}
|
||||
|
||||
@@ -129,6 +126,7 @@ namespace BBM
|
||||
if (!ent.hasComponent<SoundComponent>())
|
||||
return;
|
||||
ent.removeComponent<SoundComponent>();
|
||||
ent.removeComponent<HealthComponent>();
|
||||
ent.removeComponent<CollisionComponent>();
|
||||
ent.removeComponent<PositionComponent>();
|
||||
});
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace BBM
|
||||
return;
|
||||
LobbySystem::switchToGame(wal);
|
||||
})
|
||||
.addComponent<TagComponent<"PlayButton">>();
|
||||
.addComponent<TagComponent<PlayButton>>();
|
||||
auto &back = scene->addEntity("back to menu")
|
||||
.addComponent<PositionComponent>(10, 1080 - 85, 0)
|
||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
|
||||
@@ -186,7 +186,6 @@ namespace BBM
|
||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/player/icons/none.png");
|
||||
auto &ready = scene->addEntity("ready")
|
||||
.addComponent<PositionComponent>(224 * (i + 1) + 200 * i, 1080 / 3 - 50, 0)
|
||||
// todo check why it does this | hacky way to fix ready texture
|
||||
.addComponent<Drawable2DComponent, RAY::Texture>();
|
||||
player.addComponent<LobbyComponent>(i, ready, playerTile);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#include <memory>
|
||||
#include <Wal.hpp>
|
||||
#include "Runner.hpp"
|
||||
#include <map>
|
||||
@@ -59,6 +58,10 @@ namespace BBM
|
||||
.addComponent<OnClickComponent>([](WAL::Entity &, WAL::Wal &)
|
||||
{
|
||||
auto &gameScene = gameState.loadedScenes[BBM::GameState::SceneID::GameScene];
|
||||
|
||||
for (WAL::Entity &entity : gameScene->view<TagComponent<RestartTimer>>())
|
||||
entity.scheduleDeletion();
|
||||
|
||||
for (auto &[entity, controller, _] : gameScene->view<ControllableComponent, HealthComponent>()) {
|
||||
controller.disabled = true;
|
||||
controller.pause = false;
|
||||
@@ -78,6 +81,7 @@ namespace BBM
|
||||
})
|
||||
.addComponent<PositionComponent>(1920 / 2 - 2 * 30, 1080 / 2, 0)
|
||||
.addComponent<TagComponent<Timer>>()
|
||||
.addComponent<TagComponent<RestartTimer>>()
|
||||
.addComponent<Drawable2DComponent, RAY2D::Text>("", 60, RAY::Vector2(), ORANGE);
|
||||
gameState.nextScene = BBM::GameState::SceneID::GameScene;
|
||||
});
|
||||
@@ -86,17 +90,17 @@ namespace BBM
|
||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_save.png")
|
||||
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||
{
|
||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||
|
||||
texture->use("assets/buttons/button_save.png");
|
||||
})
|
||||
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||
{
|
||||
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||
|
||||
texture->use("assets/buttons/button_save_hovered.png");
|
||||
})
|
||||
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
|
||||
.addComponent<OnClickComponent>([](WAL::Entity &, WAL::Wal &wal)
|
||||
{
|
||||
if (!std::filesystem::exists("save"))
|
||||
std::filesystem::create_directories("save");
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
#include <Component/Tag/TagComponent.hpp>
|
||||
#include <Drawables/Texture.hpp>
|
||||
#include <System/Lobby/ResumeLobbySystem.hpp>
|
||||
#include "System/Sound/PlayerSoundManagerSystem.hpp"
|
||||
#include "System/Music/MusicSystem.hpp"
|
||||
#include "System/Lobby/LobbySystem.hpp"
|
||||
#include "Component/Lobby/LobbyComponent.hpp"
|
||||
|
||||
namespace RAY3D = RAY::Drawables::Drawables3D;
|
||||
@@ -67,7 +65,7 @@ namespace BBM
|
||||
return;
|
||||
ResumeLobbySystem::resumeToGame(wal);
|
||||
})
|
||||
.addComponent<TagComponent<"PlayButton">>();
|
||||
.addComponent<TagComponent<ResumeButton>>();
|
||||
auto &back = scene->addEntity("back to menu")
|
||||
.addComponent<PositionComponent>(10, 1080 - 85, 0)
|
||||
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace BBM
|
||||
tilesColor[place]);
|
||||
scene->addEntity("player")
|
||||
.addComponent<PositionComponent>(224 * (i + 1) + 200 * i, 1080 / 2.5, 0)
|
||||
.addComponent<Drawable2DComponent, RAY::Texture>(playersIconPath[place]);
|
||||
.addComponent<Drawable2DComponent, RAY::Texture>(playersIconPath[i]);
|
||||
}
|
||||
auto &play = scene->addEntity("play button")
|
||||
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 180, 0)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <Component/Renderer/Drawable3DComponent.hpp>
|
||||
#include <Map/Map.hpp>
|
||||
#include <Component/BombHolder/BombHolderComponent.hpp>
|
||||
#include <Parser/ParserYaml.hpp>
|
||||
#include <Drawables/2D/Text.hpp>
|
||||
#include "Component/Color/ColorComponent.hpp"
|
||||
#include "Component/Stat/StatComponent.hpp"
|
||||
@@ -66,7 +65,7 @@ namespace BBM
|
||||
lobby.coloredTile.getComponent<Drawable2DComponent>().drawable->setColor(_rayColors[lobby.color]);
|
||||
}
|
||||
|
||||
void LobbySystem::onUpdate(WAL::ViewEntity<LobbyComponent, Drawable2DComponent> &entity, std::chrono::nanoseconds dtime)
|
||||
void LobbySystem::onUpdate(WAL::ViewEntity<LobbyComponent, Drawable2DComponent> &entity, std::chrono::nanoseconds)
|
||||
{
|
||||
auto &lobby = entity.get<LobbyComponent>();
|
||||
|
||||
@@ -77,7 +76,7 @@ namespace BBM
|
||||
if (lobby.layout == ControllableComponent::NONE) {
|
||||
for (auto &[_, ctrl] : this->_wal.getScene()->view<ControllableComponent>()) {
|
||||
auto &controller = ctrl;
|
||||
if (controller.bomb) {
|
||||
if (controller.bomb && this->_canJoin()) {
|
||||
if (std::any_of(this->getView().begin(), this->getView().end(), [&controller](WAL::ViewEntity<LobbyComponent, Drawable2DComponent> &view) {
|
||||
return view.get<LobbyComponent>().layout == controller.layout;
|
||||
}))
|
||||
@@ -95,7 +94,7 @@ namespace BBM
|
||||
for (auto &[_, controller] : this->_wal.getScene()->view<ControllableComponent>()) {
|
||||
if (controller.layout != lobby.layout)
|
||||
continue;
|
||||
if (controller.bomb && !lobby.ready) {
|
||||
if (controller.bomb && !lobby.ready && this->_canJoin()) {
|
||||
lobby.ready = true;
|
||||
lobby.lastInput = lastTick;
|
||||
controller.bomb = false;
|
||||
@@ -104,13 +103,22 @@ namespace BBM
|
||||
if (texture)
|
||||
texture->use("assets/player/icons/ready.png");
|
||||
}
|
||||
if (controller.secondary && !lobby.ready) {
|
||||
if (controller.secondary) {
|
||||
lobby.lastInput = lastTick;
|
||||
this->_nextColor(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool LobbySystem::_canJoin()
|
||||
{
|
||||
auto *button = this->_wal.getSystem<MenuControllableSystem>().currentButton;
|
||||
|
||||
if (!button)
|
||||
return true;
|
||||
return button->hasComponent<TagComponent<PlayButton>>();
|
||||
}
|
||||
|
||||
void LobbySystem::addAI()
|
||||
{
|
||||
for (auto entity : this->getView()) {
|
||||
@@ -152,9 +160,9 @@ namespace BBM
|
||||
texture->unload();
|
||||
}
|
||||
|
||||
void LobbySystem::onSelfUpdate(std::chrono::nanoseconds dtime)
|
||||
void LobbySystem::onSelfUpdate(std::chrono::nanoseconds)
|
||||
{
|
||||
auto &view = this->_wal.getScene()->view<TagComponent<"PlayButton">, Drawable2DComponent>();
|
||||
auto &view = this->_wal.getScene()->view<TagComponent<PlayButton>, Drawable2DComponent>();
|
||||
if (view.size() == 0)
|
||||
return;
|
||||
auto *texture = dynamic_cast<RAY::Texture *>(view.front().get<Drawable2DComponent>().drawable.get());
|
||||
@@ -209,7 +217,7 @@ namespace BBM
|
||||
player.getComponent<ControllableComponent>().layout = layout;
|
||||
}
|
||||
|
||||
void LobbySystem::createTile(std::shared_ptr<WAL::Scene> scene, WAL::Entity &player, int color, int playerCount)
|
||||
void LobbySystem::createTile(const std::shared_ptr<WAL::Scene>& scene, WAL::Entity &player, int color, int playerCount)
|
||||
{
|
||||
std::string texturePath = "assets/player/ui/" + colors[color] + ".png";
|
||||
int x = (playerCount % 2 == 0) ? 1920 - 10 - 320 : 10;
|
||||
@@ -223,25 +231,25 @@ namespace BBM
|
||||
scene->addEntity("player hide fireup")
|
||||
.addComponent<PositionComponent>(x + 220, y + 35, 0)
|
||||
.addComponent<Drawable2DComponent, RAY2D::Text>("", 20, x, y, WHITE)
|
||||
.addComponent<StatComponent>([&player](Drawable2DComponent &drawble) {
|
||||
.addComponent<StatComponent>([&player](Drawable2DComponent &drawable) {
|
||||
const BombHolderComponent *bonus = player.tryGetComponent<BombHolderComponent>();
|
||||
|
||||
if (!bonus)
|
||||
return;
|
||||
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(drawble.drawable.get());
|
||||
auto *text = dynamic_cast<RAY2D::Text *>(drawable.drawable.get());
|
||||
if (!text)
|
||||
return;
|
||||
text->setText(std::to_string(static_cast<int>(bonus->explosionRadius)));
|
||||
});
|
||||
scene->addEntity("player hide bombup")
|
||||
scene->addEntity("player hide bomb-up")
|
||||
.addComponent<PositionComponent>(x + 220, y + 77, 0)
|
||||
.addComponent<Drawable2DComponent, RAY2D::Text>("", 20, x, y, WHITE)
|
||||
.addComponent<StatComponent>([&player](Drawable2DComponent &drawble) {
|
||||
.addComponent<StatComponent>([&player](Drawable2DComponent &drawable) {
|
||||
const BombHolderComponent *bonus = player.tryGetComponent<BombHolderComponent>();
|
||||
|
||||
if (!bonus)
|
||||
return;
|
||||
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(drawble.drawable.get());
|
||||
auto *text = dynamic_cast<RAY2D::Text *>(drawable.drawable.get());
|
||||
if (!text)
|
||||
return;
|
||||
text->setText(std::to_string(bonus->bombCount) + " / " + std::to_string(bonus->maxBombCount));
|
||||
@@ -249,12 +257,12 @@ namespace BBM
|
||||
scene->addEntity("player hide speedup")
|
||||
.addComponent<PositionComponent>(x + 220, y + 122, 0)
|
||||
.addComponent<Drawable2DComponent, RAY2D::Text>("", 20, x, y, WHITE)
|
||||
.addComponent<StatComponent>([&player](Drawable2DComponent &drawble) {
|
||||
.addComponent<StatComponent>([&player](Drawable2DComponent &drawable) {
|
||||
auto *speed = player.tryGetComponent<SpeedComponent>();
|
||||
|
||||
if (!speed)
|
||||
return;
|
||||
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(drawble.drawable.get());
|
||||
auto *text = dynamic_cast<RAY2D::Text *>(drawable.drawable.get());
|
||||
if (!text)
|
||||
return;
|
||||
text->setText(std::to_string(static_cast<int>(speed->speed * 100)));
|
||||
@@ -262,12 +270,12 @@ namespace BBM
|
||||
scene->addEntity("player hide wall")
|
||||
.addComponent<PositionComponent>(x + 220, y + 161, 0)
|
||||
.addComponent<Drawable2DComponent, RAY2D::Text>("", 20, x, y, WHITE)
|
||||
.addComponent<StatComponent>([&player](Drawable2DComponent &drawble) {
|
||||
.addComponent<StatComponent>([&player](Drawable2DComponent &drawable) {
|
||||
const PlayerBonusComponent *bonus = player.tryGetComponent<PlayerBonusComponent>();
|
||||
|
||||
if (!bonus)
|
||||
return;
|
||||
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(drawble.drawable.get());
|
||||
auto *text = dynamic_cast<RAY2D::Text *>(drawable.drawable.get());
|
||||
if (!text)
|
||||
return;
|
||||
text->setText(bonus->isNoClipOn ? "YES" : "NO");
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace BBM
|
||||
{
|
||||
private:
|
||||
|
||||
bool _canJoin();
|
||||
|
||||
void _nextColor(WAL::ViewEntity<LobbyComponent, Drawable2DComponent> &entity);
|
||||
|
||||
|
||||
@@ -31,7 +33,7 @@ namespace BBM
|
||||
static void addController(WAL::Entity &player, ControllableComponent::Layout layout);
|
||||
|
||||
//! @brief Create ingame tile
|
||||
static void createTile(std::shared_ptr<WAL::Scene> scene, WAL::Entity &player, int color, int playerCount);
|
||||
static void createTile(const std::shared_ptr<WAL::Scene>& drawable, WAL::Entity &player, int color, int playerCount);
|
||||
|
||||
//! @inherit
|
||||
void onUpdate(WAL::ViewEntity<LobbyComponent, Drawable2DComponent> &entity, std::chrono::nanoseconds dtime) override;
|
||||
|
||||
@@ -9,20 +9,12 @@
|
||||
#include "Component/Speed/SpeedComponent.hpp"
|
||||
#include "System/MenuControllable/MenuControllableSystem.hpp"
|
||||
#include "Component/Tag/TagComponent.hpp"
|
||||
#include <algorithm>
|
||||
#include <Runner/Runner.hpp>
|
||||
#include <Component/Keyboard/KeyboardComponent.hpp>
|
||||
#include <Component/Gamepad/GamepadComponent.hpp>
|
||||
#include "Component/IAControllable/IAControllableComponent.hpp"
|
||||
#include <Component/Position/PositionComponent.hpp>
|
||||
#include <Component/Renderer/Drawable3DComponent.hpp>
|
||||
#include <Map/Map.hpp>
|
||||
#include <Component/BombHolder/BombHolderComponent.hpp>
|
||||
#include <Parser/ParserYaml.hpp>
|
||||
#include <Drawables/2D/Text.hpp>
|
||||
#include "Component/Color/ColorComponent.hpp"
|
||||
#include "Component/Stat/StatComponent.hpp"
|
||||
#include "Component/Bonus/PlayerBonusComponent.hpp"
|
||||
#include "System/Lobby/LobbySystem.hpp"
|
||||
|
||||
namespace RAY3D = RAY::Drawables::Drawables3D;
|
||||
@@ -66,7 +58,7 @@ namespace BBM
|
||||
|
||||
void ResumeLobbySystem::onSelfUpdate(std::chrono::nanoseconds dtime)
|
||||
{
|
||||
auto &view = this->_wal.getScene()->view<TagComponent<"PlayButton">, Drawable2DComponent>();
|
||||
auto &view = this->_wal.getScene()->view<TagComponent<ResumeButton>, Drawable2DComponent>();
|
||||
if (view.size() == 0)
|
||||
return;
|
||||
auto *texture = dynamic_cast<RAY::Texture *>(view.front().get<Drawable2DComponent>().drawable.get());
|
||||
|
||||
@@ -18,13 +18,14 @@ namespace BBM
|
||||
{
|
||||
MenuControllableSystem::MenuControllableSystem(WAL::Wal &wal)
|
||||
: System(wal),
|
||||
_currentButton(), _oldMousePosition(-1, -1)
|
||||
_oldMousePosition(-1, -1),
|
||||
currentButton()
|
||||
{
|
||||
}
|
||||
|
||||
void MenuControllableSystem::_updateCurrentButton(bool selected, Vector2f move)
|
||||
{
|
||||
auto &buttonComponent = this->_currentButton->getComponent<OnClickComponent>();
|
||||
auto &buttonComponent = this->currentButton->getComponent<OnClickComponent>();
|
||||
WAL::Entity *newButton = nullptr;
|
||||
|
||||
if (move.y > 0 && buttonComponent._up)
|
||||
@@ -44,12 +45,12 @@ namespace BBM
|
||||
}
|
||||
|
||||
if (newButton) {
|
||||
this->_currentButton->getComponent<OnIdleComponent>().onEvent(*this->_currentButton, this->_wal);
|
||||
this->_currentButton = newButton;
|
||||
this->_currentButton->getComponent<OnHoverComponent>().onEvent(*this->_currentButton, this->_wal);
|
||||
this->currentButton->getComponent<OnIdleComponent>().onEvent(*this->currentButton, this->_wal);
|
||||
this->currentButton = newButton;
|
||||
this->currentButton->getComponent<OnHoverComponent>().onEvent(*this->currentButton, this->_wal);
|
||||
}
|
||||
if (selected)
|
||||
this->_currentButton->getComponent<OnClickComponent>().onEvent(*this->_currentButton, this->_wal);
|
||||
this->currentButton->getComponent<OnClickComponent>().onEvent(*this->currentButton, this->_wal);
|
||||
}
|
||||
|
||||
bool MenuControllableSystem::_mouseOnButton(const Vector2f &mousePos, WAL::ViewEntity<OnClickComponent, OnHoverComponent, OnIdleComponent, PositionComponent, Drawable2DComponent> &entity) const
|
||||
@@ -83,16 +84,16 @@ namespace BBM
|
||||
|
||||
if (this->_oldMousePosition == Vector2f(-1, -1))
|
||||
this->_oldMousePosition = relativeMousePos;
|
||||
if (this->_currentButton && this->_currentButton->_scene.getID() != this->_wal.getScene()->getID()) {
|
||||
this->_currentButton->getComponent<OnIdleComponent>().onEvent(*this->_currentButton, this->_wal);
|
||||
this->_currentButton = nullptr;
|
||||
if (this->currentButton && this->currentButton->_scene.getID() != this->_wal.getScene()->getID()) {
|
||||
this->currentButton->getComponent<OnIdleComponent>().onEvent(*this->currentButton, this->_wal);
|
||||
this->currentButton = nullptr;
|
||||
return;
|
||||
}
|
||||
if (this->_currentButton == nullptr && buttons.size()) {
|
||||
this->_currentButton = &(*buttons.front());
|
||||
this->_currentButton->getComponent<OnHoverComponent>().onEvent(*this->_currentButton, this->_wal);
|
||||
if (this->currentButton == nullptr && buttons.size()) {
|
||||
this->currentButton = &(*buttons.front());
|
||||
this->currentButton->getComponent<OnHoverComponent>().onEvent(*this->currentButton, this->_wal);
|
||||
}
|
||||
if (!this->_currentButton)
|
||||
if (!this->currentButton)
|
||||
return;
|
||||
for (auto &[_, controllable]: controllableView)
|
||||
if (controllable.move.x || controllable.move.y || controllable.bomb) {
|
||||
@@ -104,12 +105,12 @@ namespace BBM
|
||||
this->_oldMousePosition = relativeMousePos;
|
||||
for (auto &entity: buttons) {
|
||||
if (_mouseOnButton(relativeMousePos, entity)) {
|
||||
if (this->_currentButton)
|
||||
this->_currentButton->getComponent<OnIdleComponent>().onEvent(*this->_currentButton, this->_wal);
|
||||
this->_currentButton = &(*entity);
|
||||
this->_currentButton->getComponent<OnHoverComponent>().onEvent(*this->_currentButton, this->_wal);
|
||||
if (this->currentButton)
|
||||
this->currentButton->getComponent<OnIdleComponent>().onEvent(*this->currentButton, this->_wal);
|
||||
this->currentButton = &(*entity);
|
||||
this->currentButton->getComponent<OnHoverComponent>().onEvent(*this->currentButton, this->_wal);
|
||||
if (RAYControl::Mouse::isPressed(RAYControl::Mouse::Button::MOUSE_BUTTON_LEFT))
|
||||
this->_currentButton->getComponent<OnClickComponent>().onEvent(*this->_currentButton, this->_wal);
|
||||
this->currentButton->getComponent<OnClickComponent>().onEvent(*this->currentButton, this->_wal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@ namespace BBM
|
||||
class MenuControllableSystem : public WAL::System<>
|
||||
{
|
||||
private:
|
||||
//! @brief index of the current button selected
|
||||
WAL::Entity *_currentButton;
|
||||
|
||||
//! @brief position of the mouse at the precedent scene (to know which controller event to watch)
|
||||
Vector2f _oldMousePosition;
|
||||
|
||||
@@ -30,6 +27,9 @@ namespace BBM
|
||||
//! @return true if mouse on entity
|
||||
bool _mouseOnButton(const Vector2f &mousePos, WAL::ViewEntity<OnClickComponent, OnHoverComponent, OnIdleComponent, PositionComponent, Drawable2DComponent> &entity) const;
|
||||
public:
|
||||
//! @brief index of the current button selected
|
||||
WAL::Entity *currentButton;
|
||||
|
||||
//! @brief time (in millisecond) since last check
|
||||
std::chrono::time_point<std::chrono::steady_clock> now;
|
||||
//! @inherit
|
||||
|
||||
Reference in New Issue
Block a user