Added GUI support for disabling and enablign gamepads

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6432 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-11-08 01:40:00 +00:00
parent b34fe812f3
commit 1640542d36
2 changed files with 28 additions and 3 deletions

View File

@ -117,6 +117,8 @@ public:
/** At this time only relevant for gamepads, keyboards are always enabled */
bool isEnabled() const { return m_enabled; }
void setEnabled(bool newValue) { m_enabled = newValue; }
};
//==== K E Y B O A R D C O N F I G =============================================

View File

@ -68,7 +68,13 @@ void OptionsScreenInput2::init()
ButtonWidget* deleteBtn = this->getWidget<ButtonWidget>("delete");
if (m_config->getType() != DEVICE_CONFIG_TYPE_KEYBOARD)
{
deleteBtn->setDeactivated();
//I18N: button to disable a gamepad configuration
if (m_config->isEnabled()) deleteBtn->setLabel(_("Disable Device"));
//I18N: button to enable a gamepad configuration
else deleteBtn->setLabel(_("Enable Device"));
//deleteBtn->setDeactivated();
}
else if (input_manager->getDeviceList()->getKeyboardAmount() < 2)
{
@ -390,8 +396,25 @@ void OptionsScreenInput2::eventCallback(Widget* widget, const std::string& name,
}
else if (name == "delete")
{
//I18N: shown before deleting an input configuration
new ConfirmDialog( _("Are you sure you want to permanently delete this configuration?"), this );
if (m_config->getType() == DEVICE_CONFIG_TYPE_KEYBOARD)
{
// keyboard configs may be deleted
//I18N: shown before deleting an input configuration
new ConfirmDialog( _("Are you sure you want to permanently delete this configuration?"), this );
}
else
{
// gamepad configs may be disabled
if (m_config->isEnabled()) m_config->setEnabled(false);
else m_config->setEnabled(true);
// update widget label
ButtonWidget* deleteBtn = this->getWidget<ButtonWidget>("delete");
if (m_config->isEnabled()) deleteBtn->setLabel(_("Disable Device"));
else deleteBtn->setLabel(_("Enable Device"));
input_manager->getDeviceList()->serialize();
}
}
} // eventCallback