From 5d3b7560a50c3656ec441343359508c9de1290ca Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Sat, 17 Dec 2016 21:22:15 +0100 Subject: [PATCH] Cleaned a bit mouse button shown names, added names for button 4 and 5. --- Source/Menu/Menu.cpp | 2 +- Source/Tutorial.cpp | 18 +++--------------- Source/User/Settings.cpp | 2 +- Source/Utils/Input.cpp | 29 ++++++++++++++++++----------- Source/Utils/Input.hpp | 8 +++++--- 5 files changed, 28 insertions(+), 31 deletions(-) diff --git a/Source/Menu/Menu.cpp b/Source/Menu/Menu.cpp index 54f6fc5..4c4abfa 100644 --- a/Source/Menu/Menu.cpp +++ b/Source/Menu/Menu.cpp @@ -543,7 +543,7 @@ void Menu::Tick() } if (mainmenu == 10) endgame = 2; - if (mainmenu == 18 && Input::isKeyPressed(MOUSEBUTTON2) && selected == 1) { + if (mainmenu == 18 && Input::isKeyPressed(MOUSEBUTTON_RIGHT) && selected == 1) { stereoseparation -= 0.001; updateStereoConfigMenu(); } diff --git a/Source/Tutorial.cpp b/Source/Tutorial.cpp index 675d3e8..3a134ff 100644 --- a/Source/Tutorial.cpp +++ b/Source/Tutorial.cpp @@ -584,11 +584,7 @@ void Tutorial::DrawTextInfo() string2 = "in the middle of the training area."; break; case 15: - if (Game::attackkey == MOUSEBUTTON1) { - string = "Click to attack when you are near an enemy."; - } else { - string = std::string("Press ") + Input::keyToChar(Game::attackkey) + " to attack when you are near an enemy."; - } + string = std::string("Press ") + Input::keyToChar(Game::attackkey) + " to attack when you are near an enemy."; string2 = "You can punch by standing still near an enemy and attacking."; break; case 16: @@ -610,11 +606,7 @@ void Tutorial::DrawTextInfo() break; case 20: string = "Your most powerful individual attack is the rabbit kick."; - if (Game::attackkey == MOUSEBUTTON1) { - string2 = "Run at the enemy while holding the mouse button, and press"; - } else { - string2 = std::string("Run at the enemy while holding ") + Input::keyToChar(Game::attackkey) + ", and press"; - } + string2 = std::string("Run at the enemy while holding ") + Input::keyToChar(Game::attackkey) + ", and press"; string3 = std::string("the jump key (") + Input::keyToChar(Game::jumpkey) + ") to attack."; break; case 21: @@ -638,11 +630,7 @@ void Tutorial::DrawTextInfo() break; case 24: string = "You can tackle enemies by running at them animal-style"; - if (Game::attackkey == MOUSEBUTTON1) { - string2 = std::string("and pressing jump (") + Input::keyToChar(Game::jumpkey) + ") or attack(mouse button)."; - } else { - string2 = std::string("and pressing jump (") + Input::keyToChar(Game::jumpkey) + ") or attack(" + Input::keyToChar(Game::attackkey) + ")."; - } + string2 = std::string("and pressing jump (") + Input::keyToChar(Game::jumpkey) + ") or attack (" + Input::keyToChar(Game::attackkey) + ")."; string3 = "This is especially useful when they are running away."; break; case 25: diff --git a/Source/User/Settings.cpp b/Source/User/Settings.cpp index 5f7909e..42b719b 100644 --- a/Source/User/Settings.cpp +++ b/Source/User/Settings.cpp @@ -62,7 +62,7 @@ void DefaultSettings() rightkey = SDL_SCANCODE_D; drawkey = SDL_SCANCODE_E; throwkey = SDL_SCANCODE_Q; - attackkey = MOUSEBUTTON1; + attackkey = MOUSEBUTTON_LEFT; consolekey = SDL_SCANCODE_GRAVE; newdetail = detail; diff --git a/Source/Utils/Input.cpp b/Source/Utils/Input.cpp index 04efb4b..06a7b74 100644 --- a/Source/Utils/Input.cpp +++ b/Source/Utils/Input.cpp @@ -41,33 +41,40 @@ void Input::Tick() bool Input::isKeyDown(int k) { - if (k >= SDL_NUM_SCANCODES + 6) // really useful? check that. + if (k >= SDL_NUM_SCANCODES + 6) { return false; + } return keyDown[k]; } bool Input::isKeyPressed(int k) { - if (k >= SDL_NUM_SCANCODES + 6) + if (k >= SDL_NUM_SCANCODES + 6) { return false; + } return keyPressed[k]; } const char* Input::keyToChar(unsigned short i) { - if (i < SDL_NUM_SCANCODES) + if (i < SDL_NUM_SCANCODES) { return SDL_GetKeyName(SDL_GetKeyFromScancode(SDL_Scancode(i))); - else if (i == MOUSEBUTTON1) - return "mouse1"; - else if (i == MOUSEBUTTON2) - return "mouse2"; - else if (i == MOUSEBUTTON3) - return "mouse3"; - else + } else if (i == MOUSEBUTTON_LEFT) { + return "mouse left button"; + } else if (i == MOUSEBUTTON_RIGHT) { + return "mouse right button"; + } else if (i == MOUSEBUTTON_MIDDLE) { + return "mouse middle button"; + } else if (i == MOUSEBUTTON_X1) { + return "mouse button 4"; + } else if (i == MOUSEBUTTON_X2) { + return "mouse button 5"; + } else { return "unknown"; + } } bool Input::MouseClicked() { - return isKeyPressed(SDL_NUM_SCANCODES + SDL_BUTTON_LEFT); + return isKeyPressed(MOUSEBUTTON_LEFT); } diff --git a/Source/Utils/Input.hpp b/Source/Utils/Input.hpp index 66a896d..1a77b58 100644 --- a/Source/Utils/Input.hpp +++ b/Source/Utils/Input.hpp @@ -26,9 +26,11 @@ along with Lugaru. If not, see . #include /**> CONSTANT DECLARATIONS <**/ -#define MOUSEBUTTON1 (SDL_NUM_SCANCODES + SDL_BUTTON_LEFT) -#define MOUSEBUTTON2 (SDL_NUM_SCANCODES + SDL_BUTTON_RIGHT) -#define MOUSEBUTTON3 (SDL_NUM_SCANCODES + SDL_BUTTON_MIDDLE) +#define MOUSEBUTTON_LEFT (SDL_NUM_SCANCODES + SDL_BUTTON_LEFT) +#define MOUSEBUTTON_RIGHT (SDL_NUM_SCANCODES + SDL_BUTTON_RIGHT) +#define MOUSEBUTTON_MIDDLE (SDL_NUM_SCANCODES + SDL_BUTTON_MIDDLE) +#define MOUSEBUTTON_X1 (SDL_NUM_SCANCODES + SDL_BUTTON_X1) +#define MOUSEBUTTON_X2 (SDL_NUM_SCANCODES + SDL_BUTTON_X2) /**> FUNCTION PROTOTYPES <**/ class Input -- 2.39.5