From 63044f756adf33e8317186de2e99ab4d3dc9acda Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 18 Jun 2021 13:43:28 +0200 Subject: [PATCH] Switching keyboard layouts --- .../Component/Controllable/ControllableComponent.hpp | 6 +++--- sources/Component/Gamepad/GamepadComponent.hpp | 4 ++-- sources/Component/Keyboard/KeyboardComponent.cpp | 8 ++++---- sources/Component/Keyboard/KeyboardComponent.hpp | 2 +- sources/Runner/LobbyScene.cpp | 7 ++++--- sources/System/Gamepad/GamepadSystem.cpp | 6 +++--- sources/System/IAControllable/IAControllableSystem.cpp | 2 +- sources/System/Keyboard/KeyboardSystem.cpp | 6 +++--- sources/System/Lobby/LobbySystem.cpp | 10 +++++----- .../System/MenuControllable/MenuControllableSystem.cpp | 4 ++-- sources/System/Sound/MenuSoundManagerSystem.cpp | 2 +- sources/System/Sound/PlayerSoundManagerSystem.cpp | 1 - 12 files changed, 29 insertions(+), 29 deletions(-) diff --git a/sources/Component/Controllable/ControllableComponent.hpp b/sources/Component/Controllable/ControllableComponent.hpp index a3b28b04..0eafbdeb 100644 --- a/sources/Component/Controllable/ControllableComponent.hpp +++ b/sources/Component/Controllable/ControllableComponent.hpp @@ -31,9 +31,9 @@ namespace BBM //! @brief The X and Z abscis of the movement. Vector2f move; - //! @brief input value to select - bool select = false; - //! @brief input value for bomb + //! @brief input value for secondary inputs. + bool secondary = false; + //! @brief input value for bomb and selection bool bomb = false; //! @brief input value for pause bool pause = false; diff --git a/sources/Component/Gamepad/GamepadComponent.hpp b/sources/Component/Gamepad/GamepadComponent.hpp index 696926ce..9796b991 100644 --- a/sources/Component/Gamepad/GamepadComponent.hpp +++ b/sources/Component/Gamepad/GamepadComponent.hpp @@ -22,9 +22,9 @@ namespace BBM int _ID; public: //! @brief jump key - Button keyJump = GAMEPAD_BUTTON_RIGHT_FACE_DOWN; + Button keySecondary = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; //! @brief bomb key - Button keyBomb = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; + Button keyBomb = GAMEPAD_BUTTON_RIGHT_FACE_DOWN; //! @brief pause key Button keyPause = GAMEPAD_BUTTON_MIDDLE; //! @brief move right key diff --git a/sources/Component/Keyboard/KeyboardComponent.cpp b/sources/Component/Keyboard/KeyboardComponent.cpp index 632300be..60acae13 100644 --- a/sources/Component/Keyboard/KeyboardComponent.cpp +++ b/sources/Component/Keyboard/KeyboardComponent.cpp @@ -16,16 +16,16 @@ namespace BBM this->keyDown = KEY_S; this->keyLeft = KEY_A; this->keyRight = KEY_D; - this->keyJump = KEY_SPACE; - this->keyBomb = KEY_E; + this->keyBomb = KEY_SPACE; + this->keySecondary = KEY_LEFT_CONTROL; this->keyPause = KEY_ESCAPE; } else { this->keyUp = KEY_UP; this->keyDown = KEY_DOWN; this->keyLeft = KEY_LEFT; this->keyRight = KEY_RIGHT; - this->keyJump = KEY_RIGHT_CONTROL; - this->keyBomb = KEY_ENTER; + this->keyBomb = KEY_RIGHT_CONTROL; + this->keySecondary = KEY_RIGHT_SHIFT; this->keyPause = KEY_BACKSPACE; } } diff --git a/sources/Component/Keyboard/KeyboardComponent.hpp b/sources/Component/Keyboard/KeyboardComponent.hpp index d7608ed5..c809ab44 100644 --- a/sources/Component/Keyboard/KeyboardComponent.hpp +++ b/sources/Component/Keyboard/KeyboardComponent.hpp @@ -18,7 +18,7 @@ namespace BBM { public: //! @brief jump key - Key keyJump = KEY_SPACE; + Key keySecondary = KEY_SPACE; //! @brief bomb key Key keyBomb = KEY_E; //! @brief pause key diff --git a/sources/Runner/LobbyScene.cpp b/sources/Runner/LobbyScene.cpp index 6c0f6f3a..c65819bb 100644 --- a/sources/Runner/LobbyScene.cpp +++ b/sources/Runner/LobbyScene.cpp @@ -67,19 +67,20 @@ namespace BBM auto &back = scene->addEntity("back to menu") .addComponent(10, 1080 - 85, 0) .addComponent("assets/buttons/button_back.png") - .addComponent([](WAL::Entity &entity, WAL::Wal &) + .addComponent([](WAL::Entity &, WAL::Wal &wal) { + wal.getSystem().unloadLobby(); gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + auto *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_back.png"); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + auto *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_back_hovered.png"); }); diff --git a/sources/System/Gamepad/GamepadSystem.cpp b/sources/System/Gamepad/GamepadSystem.cpp index 627b6d56..bf271ddf 100644 --- a/sources/System/Gamepad/GamepadSystem.cpp +++ b/sources/System/Gamepad/GamepadSystem.cpp @@ -24,9 +24,9 @@ namespace BBM Gamepad gamepad(gamepadComponent.getID()); const std::map keyPressedMap = { - {gamepadComponent.keyJump, controllable.select}, - {gamepadComponent.keyBomb, controllable.bomb}, - {gamepadComponent.keyPause, controllable.pause} + {gamepadComponent.keySecondary, controllable.secondary}, + {gamepadComponent.keyBomb, controllable.bomb}, + {gamepadComponent.keyPause, controllable.pause} }; for (auto key : keyPressedMap) diff --git a/sources/System/IAControllable/IAControllableSystem.cpp b/sources/System/IAControllable/IAControllableSystem.cpp index cec372fc..294d703d 100644 --- a/sources/System/IAControllable/IAControllableSystem.cpp +++ b/sources/System/IAControllable/IAControllableSystem.cpp @@ -166,7 +166,7 @@ namespace BBM pushInfo(ia._state, player, bombHolder); ia._state.callFunction(1, 4); controllable.bomb = ia._state.getReturnBool(); - controllable.select = ia._state.getReturnBool(); + controllable.secondary = ia._state.getReturnBool(); controllable.move.y = ia._state.getReturnNumber(); controllable.move.x = ia._state.getReturnNumber(); ia._state.popLast(); diff --git a/sources/System/Keyboard/KeyboardSystem.cpp b/sources/System/Keyboard/KeyboardSystem.cpp index 7f539f44..0910f3e7 100644 --- a/sources/System/Keyboard/KeyboardSystem.cpp +++ b/sources/System/Keyboard/KeyboardSystem.cpp @@ -22,9 +22,9 @@ namespace BBM auto &controllable = entity.get(); const std::map keyPressedMap = { - {keyboard.keyJump, controllable.select}, - {keyboard.keyBomb, controllable.bomb}, - {keyboard.keyPause, controllable.pause} + {keyboard.keySecondary, controllable.secondary}, + {keyboard.keyBomb, controllable.bomb}, + {keyboard.keyPause, controllable.pause} }; for (auto key : keyPressedMap) diff --git a/sources/System/Lobby/LobbySystem.cpp b/sources/System/Lobby/LobbySystem.cpp index 7bb64885..b36b6196 100644 --- a/sources/System/Lobby/LobbySystem.cpp +++ b/sources/System/Lobby/LobbySystem.cpp @@ -75,7 +75,7 @@ namespace BBM if (lobby.layout == ControllableComponent::NONE) { for (auto &[_, ctrl] : this->_wal.getScene()->view()) { auto &controller = ctrl; - if (controller.select) { + if (controller.bomb) { if (std::any_of(this->getView().begin(), this->getView().end(), [&controller](WAL::ViewEntity &view) { return view.get().layout == controller.layout; })) @@ -84,7 +84,7 @@ namespace BBM lobby.color = -1; this->_nextColor(entity); lobby.layout = controller.layout; - controller.select = false; + controller.bomb = false; return; } } @@ -93,16 +93,16 @@ namespace BBM for (auto &[_, controller] : this->_wal.getScene()->view()) { if (controller.layout != lobby.layout) continue; - if (controller.select && !lobby.ready) { + if (controller.bomb && !lobby.ready) { lobby.ready = true; lobby.lastInput = lastTick; - controller.select = false; + controller.bomb = false; this->_wal.getSystem().now = lastTick; auto *texture = dynamic_cast(lobby.readyButton.getComponent().drawable.get()); if (texture) texture->use("assets/player/icons/ready.png"); } - if (controller.bomb && !lobby.ready) { + if (controller.secondary && !lobby.ready) { lobby.lastInput = lastTick; this->_nextColor(entity); } diff --git a/sources/System/MenuControllable/MenuControllableSystem.cpp b/sources/System/MenuControllable/MenuControllableSystem.cpp index 0b05031b..766d575d 100644 --- a/sources/System/MenuControllable/MenuControllableSystem.cpp +++ b/sources/System/MenuControllable/MenuControllableSystem.cpp @@ -95,8 +95,8 @@ namespace BBM if (!this->_currentButton) return; for (auto &[_, controllable]: controllableView) - if (controllable.move.x || controllable.move.y || controllable.select) { - this->_updateCurrentButton(controllable.select, controllable.move); + if (controllable.move.x || controllable.move.y || controllable.bomb) { + this->_updateCurrentButton(controllable.bomb, controllable.move); return; } if (relativeMousePos == this->_oldMousePosition && !RAYControl::Mouse::isPressed(RAYControl::Mouse::Button::MOUSE_BUTTON_LEFT)) diff --git a/sources/System/Sound/MenuSoundManagerSystem.cpp b/sources/System/Sound/MenuSoundManagerSystem.cpp index 7f3e57e4..2e827a86 100644 --- a/sources/System/Sound/MenuSoundManagerSystem.cpp +++ b/sources/System/Sound/MenuSoundManagerSystem.cpp @@ -20,7 +20,7 @@ namespace BBM { std::map soundIndex = { {controllable.move.x, SoundComponent::MOVE}, {controllable.move.y, SoundComponent::MOVE}, - {controllable.select, SoundComponent::JUMP}, + {controllable.bomb, SoundComponent::BOMB}, }; for (auto &a : soundIndex) { if (a.first) { diff --git a/sources/System/Sound/PlayerSoundManagerSystem.cpp b/sources/System/Sound/PlayerSoundManagerSystem.cpp index 4068a5e3..4e13dcac 100644 --- a/sources/System/Sound/PlayerSoundManagerSystem.cpp +++ b/sources/System/Sound/PlayerSoundManagerSystem.cpp @@ -21,7 +21,6 @@ namespace BBM { std::map soundIndex = { {health.getHealthPoint() <= 0, SoundComponent::DEATH}, {controllable.bomb, SoundComponent::BOMB}, - {controllable.select, SoundComponent::JUMP}, {controllable.move.x != 0 || controllable.move.y != 0, SoundComponent::MOVE} }; for (auto &a : soundIndex) {