From ef56b8171e81be5148e1789dd3f447e33aba5f2c Mon Sep 17 00:00:00 2001 From: Cvolton Date: Fri, 13 Sep 2024 19:40:59 +0200 Subject: [PATCH] Revert "separate keybinds for different modes" This reverts commit f9d2700ec4630ffd080af9425b490eb07f1cf313. --- include/Keybinds.hpp | 4 - src/EditorUI.cpp | 46 ++---- src/UILayer.cpp | 328 ++++++------------------------------------- 3 files changed, 52 insertions(+), 326 deletions(-) diff --git a/include/Keybinds.hpp b/include/Keybinds.hpp index 6f60307..b1ed5c2 100644 --- a/include/Keybinds.hpp +++ b/include/Keybinds.hpp @@ -173,10 +173,6 @@ namespace keybinds { bool operator==(Category const&) const; static constexpr auto PLAY { "Play" }; - static constexpr auto PLAY_1P_CLASSIC { "Play/Classic 1P" }; - static constexpr auto PLAY_1P_PLATFORMER { "Play/Platformer 1P" }; - static constexpr auto PLAY_2P_CLASSIC { "Play/Classic 2P" }; - static constexpr auto PLAY_2P_PLATFORMER { "Play/Platformer 2P" }; static constexpr auto PLAY_PAUSE { "Play/Pause" }; static constexpr auto EDITOR { "Editor" }; static constexpr auto GLOBAL { "Global" }; diff --git a/src/EditorUI.cpp b/src/EditorUI.cpp index 34e2c28..9cc6510 100644 --- a/src/EditorUI.cpp +++ b/src/EditorUI.cpp @@ -74,64 +74,34 @@ struct $modify(EditorUI) { return false; Loader::get()->queueInMainThread([this, lel] { - this->defineKeybind("robtop.geometry-dash/jump", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && !lel->m_levelSettings->m_twoPlayerMode && !lel->m_isPlatformer) { - lel->queueButton(platformButton(), down, false); - } - }); this->defineKeybind("robtop.geometry-dash/jump-p1", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && lel->m_levelSettings->m_twoPlayerMode && !lel->m_isPlatformer) { + if (lel->m_playbackMode == PlaybackMode::Playing) { lel->queueButton(platformButton(), down, false); } }); this->defineKeybind("robtop.geometry-dash/jump-p2", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && lel->m_levelSettings->m_twoPlayerMode && !lel->m_isPlatformer) { - lel->queueButton(platformButton(), down, true); - } - }); - this->defineKeybind("robtop.geometry-dash/jump-plat", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && !lel->m_levelSettings->m_twoPlayerMode && lel->m_isPlatformer) { - lel->queueButton(platformButton(), down, false); - } - }); - this->defineKeybind("robtop.geometry-dash/jump-p1-plat", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && lel->m_levelSettings->m_twoPlayerMode && lel->m_isPlatformer) { - lel->queueButton(platformButton(), down, false); - } - }); - this->defineKeybind("robtop.geometry-dash/jump-p2-plat", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && lel->m_levelSettings->m_twoPlayerMode && lel->m_isPlatformer) { + if (lel->m_playbackMode == PlaybackMode::Playing) { lel->queueButton(platformButton(), down, true); } }); - this->defineKeybind("robtop.geometry-dash/move-left", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && !lel->m_levelSettings->m_twoPlayerMode) { - lel->queueButton(static_cast(PlayerButton::Left), down, false); - } - }); - this->defineKeybind("robtop.geometry-dash/move-right", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && !lel->m_levelSettings->m_twoPlayerMode) { - lel->queueButton(static_cast(PlayerButton::Right), down, false); - } - }); this->defineKeybind("robtop.geometry-dash/move-left-p1", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && lel->m_levelSettings->m_twoPlayerMode) { + if (lel->m_playbackMode == PlaybackMode::Playing) { lel->queueButton(static_cast(PlayerButton::Left), down, false); } }); this->defineKeybind("robtop.geometry-dash/move-right-p1", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && lel->m_levelSettings->m_twoPlayerMode) { + if (lel->m_playbackMode == PlaybackMode::Playing) { lel->queueButton(static_cast(PlayerButton::Right), down, false); } }); this->defineKeybind("robtop.geometry-dash/move-left-p2", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && lel->m_levelSettings->m_twoPlayerMode) { - lel->queueButton(static_cast(PlayerButton::Left), down, lel->m_player2); + if (lel->m_playbackMode == PlaybackMode::Playing) { + lel->queueButton(static_cast(PlayerButton::Left), down, true); } }); this->defineKeybind("robtop.geometry-dash/move-right-p2", [lel](bool down) { - if (lel->m_playbackMode == PlaybackMode::Playing && lel->m_levelSettings->m_twoPlayerMode) { - lel->queueButton(static_cast(PlayerButton::Right), down, lel->m_player2); + if (lel->m_playbackMode == PlaybackMode::Playing) { + lel->queueButton(static_cast(PlayerButton::Right), down, true); } }); this->defineKeybind("robtop.geometry-dash/pause-level", [this](bool down) { diff --git a/src/UILayer.cpp b/src/UILayer.cpp index 9f295e7..3581e80 100644 --- a/src/UILayer.cpp +++ b/src/UILayer.cpp @@ -161,20 +161,8 @@ struct $modify(UILayer) { // do not do anything in the editor if (!PlayLayer::get()) return; - this->defineKeybind("robtop.geometry-dash/jump", [this](bool down) { - if (this->isPaused() || this->m_gameLayer->m_levelSettings->m_twoPlayerMode || this->m_gameLayer->m_isPlatformer) { - return ListenerResult::Propagate; - } - PlayLayer::get()->queueButton(1, down, false); - if (down) { - m_p1Jumping = true; - } else { - m_p1Jumping = false; - } - return ListenerResult::Stop; - }); this->defineKeybind("robtop.geometry-dash/jump-p1", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode || this->m_gameLayer->m_isPlatformer) { + if (this->isPaused()) { return ListenerResult::Propagate; } PlayLayer::get()->queueButton(1, down, false); @@ -186,183 +174,79 @@ struct $modify(UILayer) { return ListenerResult::Stop; }); this->defineKeybind("robtop.geometry-dash/jump-p2", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode || this->m_gameLayer->m_isPlatformer) { + if (this->isPaused()) { return ListenerResult::Propagate; } - PlayLayer::get()->queueButton(1, down, m_dualMode); + PlayLayer::get()->queueButton(1, down, true); if (down) { - if (!m_dualMode) { - m_p1Jumping = true; - } - m_p2Jumping = m_dualMode; + m_p2Jumping = true; } else { - if (!m_dualMode) { - m_p1Jumping = false; - } m_p2Jumping = false; } return ListenerResult::Stop; }); - this->defineKeybind("robtop.geometry-dash/jump-plat", [this](bool down) { - if (this->isPaused() || this->m_gameLayer->m_levelSettings->m_twoPlayerMode || !this->m_gameLayer->m_isPlatformer) { + this->defineKeybind("robtop.geometry-dash/place-checkpoint", [this](bool down) { + if (this->isPaused()) { return ListenerResult::Propagate; } - PlayLayer::get()->queueButton(1, down, false); - if (down) { - m_p1Jumping = true; - } else { - m_p1Jumping = false; - } + this->pressKeyFallthrough(KEY_Z, down); return ListenerResult::Stop; }); - this->defineKeybind("robtop.geometry-dash/jump-p1-plat", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode || !this->m_gameLayer->m_isPlatformer) { + this->defineKeybind("robtop.geometry-dash/delete-checkpoint", [this](bool down) { + if (this->isPaused()) { return ListenerResult::Propagate; } - PlayLayer::get()->queueButton(1, down, false); - if (down) { - m_p1Jumping = true; - } else { - m_p1Jumping = false; - } + this->pressKeyFallthrough(KEY_X, down); return ListenerResult::Stop; }); - this->defineKeybind("robtop.geometry-dash/jump-p2-plat", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode || !this->m_gameLayer->m_isPlatformer) { - return ListenerResult::Propagate; - } - PlayLayer::get()->queueButton(1, down, m_dualMode); - if (down) { - if (!m_dualMode) { - m_p1Jumping = true; - } - m_p2Jumping = m_dualMode; - } else { - if (!m_dualMode) { - m_p1Jumping = false; - } - m_p2Jumping = false; + this->defineKeybind("robtop.geometry-dash/pause-level", [this](bool down) { + if (down && this->isCurrentPlayLayer() && !this->isPaused()) { + PlayLayer::get()->pauseGame(true); } - return ListenerResult::Stop; + return ListenerResult::Propagate; }); - this->defineKeybind("robtop.geometry-dash/move-left", [this](bool down) { - if (this->isPaused() || this->m_gameLayer->m_levelSettings->m_twoPlayerMode) { + this->defineKeybind("robtop.geometry-dash/restart-level", [this](bool down) { + if (this->isPaused() || !this->isCurrentPlayLayer()) { return ListenerResult::Propagate; } - this->pressKeyFallthrough(KEY_A, down); - return ListenerResult::Stop; + this->pressKeyFallthrough(KEY_R, down, false, false, false, false); + return ListenerResult::Propagate; }); - this->defineKeybind("robtop.geometry-dash/move-right", [this](bool down) { - if (this->isPaused() || this->m_gameLayer->m_levelSettings->m_twoPlayerMode) { + this->defineKeybind("robtop.geometry-dash/full-restart-level", [this](bool down) { + if (this->isPaused() || !this->isCurrentPlayLayer()) { return ListenerResult::Propagate; } - this->pressKeyFallthrough(KEY_D, down); - return ListenerResult::Stop; + this->pressKeyFallthrough(KEY_R, down, false, true, false, false); + return ListenerResult::Propagate; }); this->defineKeybind("robtop.geometry-dash/move-left-p1", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode) { + if (this->isPaused()) { return ListenerResult::Propagate; } this->pressKeyFallthrough(KEY_A, down); return ListenerResult::Stop; }); this->defineKeybind("robtop.geometry-dash/move-right-p1", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode) { + if (this->isPaused()) { return ListenerResult::Propagate; } this->pressKeyFallthrough(KEY_D, down); return ListenerResult::Stop; }); this->defineKeybind("robtop.geometry-dash/move-left-p2", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode) { + if (this->isPaused()) { return ListenerResult::Propagate; } this->pressKeyFallthrough(KEY_Left, down); return ListenerResult::Stop; }); this->defineKeybind("robtop.geometry-dash/move-right-p2", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode) { + if (this->isPaused()) { return ListenerResult::Propagate; } this->pressKeyFallthrough(KEY_Right, down); return ListenerResult::Stop; }); - this->defineKeybind("robtop.geometry-dash/place-checkpoint", [this](bool down) { - if (this->isPaused() || this->m_gameLayer->m_levelSettings->m_twoPlayerMode || this->m_gameLayer->m_isPlatformer) { - return ListenerResult::Propagate; - } - this->pressKeyFallthrough(KEY_Z, down); - return ListenerResult::Stop; - }); - this->defineKeybind("robtop.geometry-dash/delete-checkpoint", [this](bool down) { - if (this->isPaused() || this->m_gameLayer->m_levelSettings->m_twoPlayerMode || this->m_gameLayer->m_isPlatformer) { - return ListenerResult::Propagate; - } - this->pressKeyFallthrough(KEY_X, down); - return ListenerResult::Stop; - }); - this->defineKeybind("robtop.geometry-dash/place-checkpoint-plat", [this](bool down) { - if (this->isPaused() || this->m_gameLayer->m_levelSettings->m_twoPlayerMode || !this->m_gameLayer->m_isPlatformer) { - return ListenerResult::Propagate; - } - this->pressKeyFallthrough(KEY_Z, down); - return ListenerResult::Stop; - }); - this->defineKeybind("robtop.geometry-dash/delete-checkpoint-plat", [this](bool down) { - if (this->isPaused() || this->m_gameLayer->m_levelSettings->m_twoPlayerMode || !this->m_gameLayer->m_isPlatformer) { - return ListenerResult::Propagate; - } - this->pressKeyFallthrough(KEY_X, down); - return ListenerResult::Stop; - }); - this->defineKeybind("robtop.geometry-dash/place-checkpoint-2p", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode || this->m_gameLayer->m_isPlatformer) { - return ListenerResult::Propagate; - } - this->pressKeyFallthrough(KEY_Z, down); - return ListenerResult::Stop; - }); - this->defineKeybind("robtop.geometry-dash/delete-checkpoint-2p", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode || this->m_gameLayer->m_isPlatformer) { - return ListenerResult::Propagate; - } - this->pressKeyFallthrough(KEY_X, down); - return ListenerResult::Stop; - }); - this->defineKeybind("robtop.geometry-dash/place-checkpoint-2p-plat", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode || !this->m_gameLayer->m_isPlatformer) { - return ListenerResult::Propagate; - } - this->pressKeyFallthrough(KEY_Z, down); - return ListenerResult::Stop; - }); - this->defineKeybind("robtop.geometry-dash/delete-checkpoint-2p-plat", [this](bool down) { - if (this->isPaused() || !this->m_gameLayer->m_levelSettings->m_twoPlayerMode || !this->m_gameLayer->m_isPlatformer) { - return ListenerResult::Propagate; - } - this->pressKeyFallthrough(KEY_X, down); - return ListenerResult::Stop; - }); - this->defineKeybind("robtop.geometry-dash/pause-level", [this](bool down) { - if (down && this->isCurrentPlayLayer() && !this->isPaused()) { - PlayLayer::get()->pauseGame(true); - } - return ListenerResult::Propagate; - }); - this->defineKeybind("robtop.geometry-dash/restart-level", [this](bool down) { - if (this->isPaused() || !this->isCurrentPlayLayer()) { - return ListenerResult::Propagate; - } - this->pressKeyFallthrough(KEY_R, down, false, false, false, false); - return ListenerResult::Propagate; - }); - this->defineKeybind("robtop.geometry-dash/full-restart-level", [this](bool down) { - if (this->isPaused() || !this->isCurrentPlayLayer()) { - return ListenerResult::Propagate; - } - this->pressKeyFallthrough(KEY_R, down, false, true, false, false); - return ListenerResult::Propagate; - }); this->defineKeybind("robtop.geometry-dash/toggle-hitboxes", [this](bool down) { if (down && this->isCurrentPlayLayer() && !this->isPaused()) { // This assumes you have quick keys on @@ -407,211 +291,87 @@ struct $modify(UILayer) { }; $execute { - BindManager::get()->registerBindable({ - "robtop.geometry-dash/jump", - "Jump", - "Jump in 1P classic levels", - { - Keybind::create(KEY_Space), - Keybind::create(KEY_W), - Keybind::create(KEY_Up), - ControllerBind::create(CONTROLLER_A), - ControllerBind::create(CONTROLLER_Up), - ControllerBind::create(CONTROLLER_RB), - ControllerBind::create(CONTROLLER_LB) - }, - Category::PLAY_1P_CLASSIC, - false - }); BindManager::get()->registerBindable({ "robtop.geometry-dash/jump-p1", "Jump P1", - "Player 1 jump in 2P classic levels", + "Player 1 Jump", { - Keybind::create(KEY_Space), + Keybind::create(KEY_Space), Keybind::create(KEY_W), ControllerBind::create(CONTROLLER_A), ControllerBind::create(CONTROLLER_Up), - ControllerBind::create(CONTROLLER_RB) + ControllerBind::create(CONTROLLER_RB) }, - Category::PLAY_2P_CLASSIC, + Category::PLAY, false }); BindManager::get()->registerBindable({ "robtop.geometry-dash/jump-p2", "Jump P2", - "Player 2 jump in 2P classic levels", + "Player 2 Jump", { Keybind::create(KEY_Up), ControllerBind::create(CONTROLLER_LB) }, - Category::PLAY_2P_CLASSIC, - false - }); - BindManager::get()->registerBindable({ - "robtop.geometry-dash/jump-plat", - "Jump", - "Jump in 1P platformer levels", - { - Keybind::create(KEY_Space), - Keybind::create(KEY_W), - Keybind::create(KEY_Up), - ControllerBind::create(CONTROLLER_A), - ControllerBind::create(CONTROLLER_Up), - ControllerBind::create(CONTROLLER_RB), - ControllerBind::create(CONTROLLER_LB) - }, - Category::PLAY_1P_PLATFORMER, - false - }); - BindManager::get()->registerBindable({ - "robtop.geometry-dash/jump-p1-plat", - "Jump P1", - "Player 1 jump in 2P platformer levels", - { - Keybind::create(KEY_Space), - Keybind::create(KEY_W), - ControllerBind::create(CONTROLLER_A), - ControllerBind::create(CONTROLLER_Up), - ControllerBind::create(CONTROLLER_RB) - }, - Category::PLAY_2P_PLATFORMER, - false - }); - BindManager::get()->registerBindable({ - "robtop.geometry-dash/jump-p2-plat", - "Jump P2", - "Player 2 jump in 2P platformer levels", - { Keybind::create(KEY_Up), ControllerBind::create(CONTROLLER_LB) }, - Category::PLAY_2P_PLATFORMER, - false - }); - BindManager::get()->registerBindable({ - "robtop.geometry-dash/move-left", - "Move left", - "Move left in 1P platformer levels", - { - Keybind::create(cocos2d::KEY_A), - ControllerBind::create(CONTROLLER_Left), - ControllerBind::create(CONTROLLER_LTHUMBSTICK_LEFT), - Keybind::create(KEY_Left), - ControllerBind::create(CONTROLLER_RTHUMBSTICK_LEFT) - }, - Category::PLAY_1P_PLATFORMER, - false - }); - BindManager::get()->registerBindable({ - "robtop.geometry-dash/move-right", - "Move right", - "Move right in 1P platformer levels", - { - Keybind::create(cocos2d::KEY_D), - ControllerBind::create(CONTROLLER_Right), - ControllerBind::create(CONTROLLER_LTHUMBSTICK_RIGHT), - Keybind::create(KEY_Right), - ControllerBind::create(CONTROLLER_RTHUMBSTICK_RIGHT) - }, - Category::PLAY_1P_PLATFORMER, + Category::PLAY, false }); BindManager::get()->registerBindable({ "robtop.geometry-dash/move-left-p1", "Move left P1", - "Player 1 move left in 2P platformer levels", + "Player 1 move left", { Keybind::create(cocos2d::KEY_A), ControllerBind::create(CONTROLLER_Left), ControllerBind::create(CONTROLLER_LTHUMBSTICK_LEFT) }, - Category::PLAY_2P_PLATFORMER, + Category::PLAY, false }); BindManager::get()->registerBindable({ "robtop.geometry-dash/move-right-p1", "Move right P1", - "Player 1 move right in 2P platformer levels", + "Player 1 move right", { Keybind::create(cocos2d::KEY_D), ControllerBind::create(CONTROLLER_Right), ControllerBind::create(CONTROLLER_LTHUMBSTICK_RIGHT) }, - Category::PLAY_2P_PLATFORMER, + Category::PLAY, false }); BindManager::get()->registerBindable({ "robtop.geometry-dash/move-left-p2", "Move left P2", - "Player 2 move left in 2P platformer levels", + "Player 2 move left", { Keybind::create(KEY_Left), ControllerBind::create(CONTROLLER_RTHUMBSTICK_LEFT) }, - Category::PLAY_2P_PLATFORMER, + Category::PLAY, false }); BindManager::get()->registerBindable({ "robtop.geometry-dash/move-right-p2", "Move right P2", - "Player 2 move right in 2P platformer levels", + "Player 2 move right", { Keybind::create(KEY_Right), ControllerBind::create(CONTROLLER_RTHUMBSTICK_RIGHT) }, - Category::PLAY_2P_PLATFORMER, + Category::PLAY, false }); BindManager::get()->registerBindable({ "robtop.geometry-dash/place-checkpoint", "Place Checkpoint", - "Place a checkpoint in practice mode in 1P classic levels", + "Place a Checkpoint in Practice Mode", { Keybind::create(KEY_Z, Modifier::None), ControllerBind::create(CONTROLLER_X) }, - Category::PLAY_1P_CLASSIC, false + Category::PLAY, false }); BindManager::get()->registerBindable({ "robtop.geometry-dash/delete-checkpoint", "Delete Checkpoint", - "Delete a checkpoint in practice mode in 1P classic levels", + "Delete a Checkpoint in Practice Mode", { Keybind::create(KEY_X, Modifier::None), ControllerBind::create(CONTROLLER_B) }, - Category::PLAY_1P_CLASSIC, false - }); - BindManager::get()->registerBindable({ - "robtop.geometry-dash/place-checkpoint-plat", - "Place Checkpoint", - "Place a checkpoint in practice mode in 1P platformer levels", - { Keybind::create(KEY_Z, Modifier::None), ControllerBind::create(CONTROLLER_X) }, - Category::PLAY_1P_PLATFORMER, false - }); - BindManager::get()->registerBindable({ - "robtop.geometry-dash/delete-checkpoint-plat", - "Delete Checkpoint", - "Delete a checkpoint in practice mode in 1P platformer levels", - { Keybind::create(KEY_X, Modifier::None), ControllerBind::create(CONTROLLER_B) }, - Category::PLAY_1P_PLATFORMER, false - }); - BindManager::get()->registerBindable({ - "robtop.geometry-dash/place-checkpoint-2p", - "Place Checkpoint", - "Place a checkpoint in practice mode in 2P classic levels", - { Keybind::create(KEY_Z, Modifier::None), ControllerBind::create(CONTROLLER_X) }, - Category::PLAY_2P_CLASSIC, false - }); - BindManager::get()->registerBindable({ - "robtop.geometry-dash/delete-checkpoint-2p", - "Delete Checkpoint", - "Delete a checkpoint in practice mode in 2P classic levels", - { Keybind::create(KEY_X, Modifier::None), ControllerBind::create(CONTROLLER_B) }, - Category::PLAY_2P_CLASSIC, false - }); - BindManager::get()->registerBindable({ - "robtop.geometry-dash/place-checkpoint-2p-plat", - "Place Checkpoint", - "Place a checkpoint in practice mode in 2P platformer levels", - { Keybind::create(KEY_Z, Modifier::None), ControllerBind::create(CONTROLLER_X) }, - Category::PLAY_2P_PLATFORMER, false - }); - BindManager::get()->registerBindable({ - "robtop.geometry-dash/delete-checkpoint-2p-plat", - "Delete Checkpoint", - "Delete a checkpoint in practice mode in 2P platformer levels", - { Keybind::create(KEY_X, Modifier::None), ControllerBind::create(CONTROLLER_B) }, - Category::PLAY_2P_PLATFORMER, false + Category::PLAY, false }); BindManager::get()->registerBindable({