diff --git a/sources.cmake b/sources.cmake index d4f28ae4d..ba4868d71 100644 --- a/sources.cmake +++ b/sources.cmake @@ -1,5 +1,5 @@ # Modify this file to change the last-modified date when you add/remove a file. -# This will then trigger a new cmake run automatically. +# This will then trigger a new cmake run automatically. file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp") file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*") diff --git a/src/input/device_config.cpp b/src/input/device_config.cpp index 457aa0b8a..77109cbbd 100644 --- a/src/input/device_config.cpp +++ b/src/input/device_config.cpp @@ -20,7 +20,6 @@ #include "input/device_config.hpp" #include "input/gamepad_config.hpp" -#include "input/gamepad_android_config.hpp" #include "input/keyboard_config.hpp" #include "io/xml_node.hpp" #include "io/utf_writer.hpp" @@ -49,10 +48,6 @@ DeviceConfig* DeviceConfig::create(const XMLNode *config) { device_config = new GamepadConfig(); } - else if(config->getName()=="gamepad_android") - { - device_config = new GamepadAndroidConfig(); - } else { Log::error("DeviceConfig", "Incorrect type: '%s'.", diff --git a/src/input/device_config.hpp b/src/input/device_config.hpp index 1ef97d513..e1eb90ef8 100644 --- a/src/input/device_config.hpp +++ b/src/input/device_config.hpp @@ -98,7 +98,6 @@ public: irr::core::stringw getMappingIdString (const PlayerAction action) const; virtual irr::core::stringw getBindingAsString(const PlayerAction action) const; virtual bool isGamePad() const = 0; - virtual bool isGamePadAndroid() const = 0; virtual bool isKeyboard() const = 0; virtual void save(std::ofstream& stream); diff --git a/src/input/gamepad_android_config.cpp b/src/input/gamepad_android_config.cpp deleted file mode 100644 index e0e4a51c9..000000000 --- a/src/input/gamepad_android_config.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2010-2015 SuperTuxKart-Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#include "input/gamepad_android_config.hpp" -#include "utils/string_utils.hpp" -#include "utils/translation.hpp" - -#include - -using namespace irr; - -GamepadAndroidConfig::GamepadAndroidConfig() -{ - setDefaultBinds(); -} - -// ---------------------------------------------------------------------------- -/** Saves the configuration to a file. It writes the name for a gamepad - * config, saves the device specific parameters, and calls - * DeviceConfig::save() to save the rest. - * \param stream The stream to save to. - */ -void GamepadAndroidConfig::save(std::ofstream& stream) -{ - stream << "\n\n"; -} // save - -// ---------------------------------------------------------------------------- - -irr::core::stringw GamepadAndroidConfig::getBindingAsString(const PlayerAction action) const -{ - const Binding &b = getBinding(action); - int id = b.getId(); - - irr::core::stringw button_name; - - switch (id) - { - case IRR_KEY_BUTTON_LEFT: - button_name = _C("input_key", "Left"); - break; - case IRR_KEY_BUTTON_RIGHT: - button_name = _C("input_key", "Right"); - break; - case IRR_KEY_BUTTON_UP: - button_name = _C("input_key", "Up"); - break; - case IRR_KEY_BUTTON_DOWN: - button_name = _C("input_key", "Down"); - break; - case IRR_KEY_BUTTON_A: - button_name = "A"; - break; - case IRR_KEY_BUTTON_B: - button_name = "B"; - break; - case IRR_KEY_BUTTON_C: - button_name = "C"; - break; - case IRR_KEY_BUTTON_X: - button_name = "X"; - break; - case IRR_KEY_BUTTON_Y: - button_name = "Y"; - break; - case IRR_KEY_BUTTON_Z: - button_name = "Z"; - break; - case IRR_KEY_BUTTON_L1: - button_name = "L1"; - break; - case IRR_KEY_BUTTON_R1: - button_name = "R1"; - break; - case IRR_KEY_BUTTON_L2: - button_name = "L2"; - break; - case IRR_KEY_BUTTON_R2: - button_name = "R2"; - break; - case IRR_KEY_BUTTON_THUMBL: - button_name = _C("input_key", "Thumb Left"); - break; - case IRR_KEY_BUTTON_THUMBR: - button_name = _C("input_key", "Thumb Right"); - break; - case IRR_KEY_BUTTON_START: - button_name = _C("input_key", "Start"); - break; - case IRR_KEY_BUTTON_SELECT: - button_name = _C("input_key", "Select"); - break; - case IRR_KEY_BUTTON_MODE: - button_name = _C("input_key", "Mode"); - break; - default: - button_name = DeviceConfig::getBindingAsString(action); - break; - } - - return button_name; -} - -// ---------------------------------------------------------------------------- - -void GamepadAndroidConfig::setDefaultBinds() -{ - setBinding(PA_NITRO, Input::IT_KEYBOARD, IRR_KEY_BUTTON_X); - setBinding(PA_ACCEL, Input::IT_KEYBOARD, IRR_KEY_BUTTON_UP); - setBinding(PA_BRAKE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_DOWN); - setBinding(PA_STEER_LEFT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_LEFT); - setBinding(PA_STEER_RIGHT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_RIGHT); - setBinding(PA_DRIFT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_Y); - setBinding(PA_RESCUE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_L1); - setBinding(PA_FIRE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_A); - setBinding(PA_LOOK_BACK, Input::IT_KEYBOARD, IRR_KEY_BUTTON_R1); - setBinding(PA_PAUSE_RACE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_B); - - setBinding(PA_MENU_UP, Input::IT_KEYBOARD, IRR_KEY_BUTTON_UP); - setBinding(PA_MENU_DOWN, Input::IT_KEYBOARD, IRR_KEY_BUTTON_DOWN); - setBinding(PA_MENU_LEFT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_LEFT); - setBinding(PA_MENU_RIGHT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_RIGHT); - setBinding(PA_MENU_SELECT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_A); - setBinding(PA_MENU_CANCEL, Input::IT_KEYBOARD, IRR_KEY_BUTTON_B); -} - -//------------------------------------------------------------------------------ - diff --git a/src/input/gamepad_android_config.hpp b/src/input/gamepad_android_config.hpp deleted file mode 100644 index 324af98cf..000000000 --- a/src/input/gamepad_android_config.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2010-2015 SuperTuxKart-Team -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 3 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef HEADER_GAMEPAD_ANDROID_CONFIG_HPP -#define HEADER_GAMEPAD_ANDROID_CONFIG_HPP - -#include "input/binding.hpp" -#include "input/keyboard_config.hpp" -#include "input/input.hpp" -#include "utils/no_copy.hpp" -#include "utils/cpp2011.hpp" - -#include - -/** - * \brief specialisation of DeviceConfig for android gamepad devices - * \ingroup config - */ -class GamepadAndroidConfig : public KeyboardConfig -{ - -public: - - GamepadAndroidConfig(); - virtual ~GamepadAndroidConfig() {} - - virtual void setDefaultBinds(); - virtual void save(std::ofstream& stream); - virtual irr::core::stringw getBindingAsString(const PlayerAction action) const; - - // ------------------------------------------------------------------------ - virtual bool isGamePad() const { return false; } - // ------------------------------------------------------------------------ - virtual bool isGamePadAndroid() const { return true; } - // ------------------------------------------------------------------------ - virtual bool isKeyboard() const { return true; } - -}; // class GamepadAndroidConfig - -#endif diff --git a/src/input/gamepad_config.hpp b/src/input/gamepad_config.hpp index ac505a776..346fd47d0 100644 --- a/src/input/gamepad_config.hpp +++ b/src/input/gamepad_config.hpp @@ -112,8 +112,6 @@ public: // ------------------------------------------------------------------------ virtual bool isGamePad() const OVERRIDE { return true; } // ------------------------------------------------------------------------ - virtual bool isGamePadAndroid() const OVERRIDE { return false; } - // ------------------------------------------------------------------------ virtual bool isKeyboard() const OVERRIDE { return false; } // ------------------------------------------------------------------------ void initSDLController(const std::string& mapping, int buttons, int axes, diff --git a/src/input/keyboard_config.hpp b/src/input/keyboard_config.hpp index e43cc47ee..5a8abb8ac 100644 --- a/src/input/keyboard_config.hpp +++ b/src/input/keyboard_config.hpp @@ -45,8 +45,6 @@ public: // ------------------------------------------------------------------------ virtual bool isGamePad() const { return false; } // ------------------------------------------------------------------------ - virtual bool isGamePadAndroid() const { return false; } - // ------------------------------------------------------------------------ virtual bool isKeyboard() const { return true; } }; // class KeyboardConfig diff --git a/src/states_screens/options/options_screen_device.cpp b/src/states_screens/options/options_screen_device.cpp index c40a6355f..4ccd5834d 100644 --- a/src/states_screens/options/options_screen_device.cpp +++ b/src/states_screens/options/options_screen_device.cpp @@ -88,53 +88,45 @@ void OptionsScreenDevice::init() ButtonWidget* delete_button = getWidget("delete"); ButtonWidget* disable_toggle = getWidget("disable_toggle"); - if (m_config->isGamePadAndroid()) + core::stringw label; + + if (!m_config->isKeyboard()) { + // Only allow to enable or disable a gamepad, + // as it is only in the list when connected delete_button->setActive(false); - disable_toggle->setActive(false); + + label = (m_config->isEnabled() + ? //I18N: button to disable a gamepad configuration + _("Disable Device") + : //I18N: button to enable a gamepad configuration + _("Enable Device")); } else { - core::stringw label; + // Don't allow deleting or disabling the last enabled config + bool enable = (input_manager->getDeviceManager() + ->getActiveKeyboardAmount() > 1 || + !m_config->isEnabled()); + delete_button->setActive(enable); + disable_toggle->setActive(enable); - if (!m_config->isKeyboard()) - { - // Only allow to enable or disable a gamepad, - // as it is only in the list when connected - delete_button->setActive(false); - - label = (m_config->isEnabled() - ? //I18N: button to disable a gamepad configuration - _("Disable Device") - : //I18N: button to enable a gamepad configuration - _("Enable Device")); - } - else - { - // Don't allow deleting or disabling the last enabled config - bool enable = (input_manager->getDeviceManager() - ->getActiveKeyboardAmount() > 1 || - !m_config->isEnabled()); - delete_button->setActive(enable); - disable_toggle->setActive(enable); - - label = (m_config->isEnabled() - ? //I18N: button to disable a keyboard configuration - _("Disable Configuration") - : //I18N: button to enable a keyboard configuration - _("Enable Configuration")); - } - - // Make sure button is wide enough as the text is being changed away - // from the original value - core::dimension2d size = - GUIEngine::getFont()->getDimension(label.c_str()); - const int needed = size.Width + disable_toggle->getWidthNeededAroundLabel(); - if (disable_toggle->m_w < needed) disable_toggle->m_w = needed; - - disable_toggle->setLabel(label); + label = (m_config->isEnabled() + ? //I18N: button to disable a keyboard configuration + _("Disable Configuration") + : //I18N: button to enable a keyboard configuration + _("Enable Configuration")); } + // Make sure button is wide enough as the text is being changed away + // from the original value + core::dimension2d size = + GUIEngine::getFont()->getDimension(label.c_str()); + const int needed = size.Width + disable_toggle->getWidthNeededAroundLabel(); + if (disable_toggle->m_w < needed) disable_toggle->m_w = needed; + + disable_toggle->setLabel(label); + // Make the three buttons the same length, not strictly needed but will // look nicer... ButtonWidget* backBtn = getWidget("back_to_device_list"); @@ -162,8 +154,8 @@ void OptionsScreenDevice::init() delete_button->moveIrrlichtElement(); disable_toggle->moveIrrlichtElement(); - LabelWidget* label = getWidget("title"); - label->setText( m_config->getName().c_str(), false ); + LabelWidget* label_widget = getWidget("title"); + label_widget->setText( m_config->getName().c_str(), false ); // ---- create list skeleton (right number of items, right internal names) // their actualy contents will be adapted as needed after diff --git a/src/states_screens/options/options_screen_input.cpp b/src/states_screens/options/options_screen_input.cpp index 5e5a4a452..4b497b7f6 100644 --- a/src/states_screens/options/options_screen_input.cpp +++ b/src/states_screens/options/options_screen_input.cpp @@ -100,30 +100,20 @@ void OptionsScreenInput::buildDeviceList() kbname << "keyboard" << i; const std::string internal_name = kbname.str(); - if (config->isGamePadAndroid()) + const int icon = (config->isEnabled() ? 0 : 1); + + //Display the configName instead of default name if it exists + if (!config->getConfigName().empty()) { // since irrLicht's list widget has the nasty tendency to put the // icons very close to the text, I'm adding spaces to compensate. - devices->addItem(internal_name, (core::stringw(" ") + - _("Gamepad")).c_str(), 2 /* icon */); + devices->addItem(internal_name, (core::stringw(" ") + + config->getConfigName()), icon); } else { - const int icon = (config->isEnabled() ? 0 : 1); - - //Display the configName instead of default name if it exists - if (!config->getConfigName().empty()) - { - // since irrLicht's list widget has the nasty tendency to put the - // icons very close to the text, I'm adding spaces to compensate. - devices->addItem(internal_name, (core::stringw(" ") + - config->getConfigName()), icon); - } - else - { - devices->addItem(internal_name, (core::stringw(" ") + - _("Keyboard %i", i)).c_str(), icon); - } + devices->addItem(internal_name, (core::stringw(" ") + + _("Keyboard %i", i)).c_str(), icon); } }