mark conflicts between configuration in blue for #39 (commit with Auria's blessing)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9656 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c4d06b5c1e
commit
c4a24ad6b6
@ -22,16 +22,23 @@
|
|||||||
<spacer height="16" width="10"/>
|
<spacer height="16" width="10"/>
|
||||||
|
|
||||||
<!-- List of key bindings -->
|
<!-- List of key bindings -->
|
||||||
<list id="actions" proportion="5" width="75%" align="center"/>
|
<list id="actions" proportion="8" width="75%" align="center"/>
|
||||||
|
|
||||||
<!-- Bottom buttons -->
|
<!-- Bottom buttons -->
|
||||||
|
|
||||||
<spacer width="50" height="20" />
|
<spacer width="50" height="20" />
|
||||||
<button id="delete"
|
<div proportion="2" width="100%" layout="horizontal-row">
|
||||||
I18N="To delete a keyboard configuration" text="Delete Configuration"/>
|
<div height="100%" width="fit" layout="vertical-row">
|
||||||
<spacer width="50" height="10" />
|
<button id="delete"
|
||||||
<button id="back_to_device_list" I18N="In the input configuration screen" text="Back to device list"/>
|
I18N="To delete a keyboard configuration" text="Delete Configuration"/>
|
||||||
|
<spacer width="50" height="10" />
|
||||||
<spacer width="50" height="10" />
|
<button id="back_to_device_list" I18N="In the input configuration screen" text="Back to device list"/>
|
||||||
|
|
||||||
|
<spacer width="50" height="10" />
|
||||||
|
</div>
|
||||||
|
<spacer width="20" height="10" />
|
||||||
|
<label id="conflict" proportion="1" text="" word_wrap="true" align="center"/>
|
||||||
|
</div>
|
||||||
</box>
|
</box>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -371,3 +371,14 @@ bool DeviceConfig::hasBindingFor(const int button_id) const
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool DeviceConfig::hasBindingFor(const int button_id, PlayerAction from, PlayerAction to) const
|
||||||
|
{
|
||||||
|
for (int n=from; n<=to; n++)
|
||||||
|
{
|
||||||
|
if (m_bindings[n].getId() == button_id) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -125,6 +125,7 @@ public:
|
|||||||
Binding& getBinding (int i) {return m_bindings[i];}
|
Binding& getBinding (int i) {return m_bindings[i];}
|
||||||
|
|
||||||
bool hasBindingFor(const int buttonID) const;
|
bool hasBindingFor(const int buttonID) const;
|
||||||
|
bool hasBindingFor(const int buttonID, PlayerAction from, PlayerAction to) const;
|
||||||
|
|
||||||
/** At this time only relevant for gamepads, keyboards are always enabled */
|
/** At this time only relevant for gamepads, keyboards are always enabled */
|
||||||
bool isEnabled() const { return m_enabled; }
|
bool isEnabled() const { return m_enabled; }
|
||||||
|
@ -338,6 +338,27 @@ void ListWidget::markItemRed(const int id, bool red)
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void ListWidget::markItemBlue(const int id, bool blue)
|
||||||
|
{
|
||||||
|
// May only be called AFTER this widget has been add()ed
|
||||||
|
assert(m_element != NULL);
|
||||||
|
|
||||||
|
IGUIListBox* irritem = getIrrlichtElement<IGUIListBox>();
|
||||||
|
|
||||||
|
if (blue)
|
||||||
|
{
|
||||||
|
irritem->setItemOverrideColor( id, EGUI_LBC_TEXT, video::SColor(255,0,0,255) );
|
||||||
|
irritem->setItemOverrideColor( id, EGUI_LBC_TEXT_HIGHLIGHT, video::SColor(255,0,0,255) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
irritem->setItemOverrideColor( id, EGUI_LBC_TEXT, video::SColor(255,0,0,0) );
|
||||||
|
irritem->setItemOverrideColor( id, EGUI_LBC_TEXT_HIGHLIGHT, video::SColor(255,255,255,255) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
EventPropagation ListWidget::transmitEvent(Widget* w, std::string& originator, const int playerID)
|
EventPropagation ListWidget::transmitEvent(Widget* w, std::string& originator, const int playerID)
|
||||||
{
|
{
|
||||||
if (originator.find(m_properties[PROP_ID] + "_column_") != std::string::npos)
|
if (originator.find(m_properties[PROP_ID] + "_column_") != std::string::npos)
|
||||||
|
@ -183,6 +183,7 @@ namespace GUIEngine
|
|||||||
* \pre may only be called after the widget has been added to the screen with add()
|
* \pre may only be called after the widget has been added to the screen with add()
|
||||||
*/
|
*/
|
||||||
void markItemRed(const int id, bool red=true);
|
void markItemRed(const int id, bool red=true);
|
||||||
|
void markItemBlue(const int id, bool blue=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Make an item red to mark an error, for instance
|
* \brief Make an item red to mark an error, for instance
|
||||||
@ -195,6 +196,13 @@ namespace GUIEngine
|
|||||||
markItemRed( id, red );
|
markItemRed( id, red );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void markItemBlue(const std::string internalName, bool blue=true)
|
||||||
|
{
|
||||||
|
const int id = getItemID(internalName);
|
||||||
|
assert(id != -1);
|
||||||
|
markItemBlue( id, blue );
|
||||||
|
}
|
||||||
|
|
||||||
/** Override callback from Widget */
|
/** Override callback from Widget */
|
||||||
virtual EventPropagation transmitEvent(Widget* w, std::string& originator, const int playerID);
|
virtual EventPropagation transmitEvent(Widget* w, std::string& originator, const int playerID);
|
||||||
|
|
||||||
|
@ -223,6 +223,8 @@ void OptionsScreenInput2::updateInputButtons()
|
|||||||
actions->renameItem(i++, makeLabel( _("Cancel/Back"), PA_MENU_CANCEL) );
|
actions->renameItem(i++, makeLabel( _("Cancel/Back"), PA_MENU_CANCEL) );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool conflicts = false;
|
||||||
// ---- make sure there are no binding conflicts (same key used for two actions)
|
// ---- make sure there are no binding conflicts (same key used for two actions)
|
||||||
std::set<irr::core::stringw> currentlyUsedKeys;
|
std::set<irr::core::stringw> currentlyUsedKeys;
|
||||||
for (PlayerAction action = PA_FIRST_GAME_ACTION;
|
for (PlayerAction action = PA_FIRST_GAME_ACTION;
|
||||||
@ -233,6 +235,12 @@ void OptionsScreenInput2::updateInputButtons()
|
|||||||
if (currentlyUsedKeys.find(item) == currentlyUsedKeys.end())
|
if (currentlyUsedKeys.find(item) == currentlyUsedKeys.end())
|
||||||
{
|
{
|
||||||
currentlyUsedKeys.insert( item );
|
currentlyUsedKeys.insert( item );
|
||||||
|
if (m_config->getType() == DEVICE_CONFIG_TYPE_KEYBOARD
|
||||||
|
&& conflictsBetweenKbdConfig(action, PA_FIRST_GAME_ACTION, PA_LAST_GAME_ACTION))
|
||||||
|
{
|
||||||
|
conflicts = true;
|
||||||
|
actions->markItemBlue (KartActionStrings[action]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -264,6 +272,12 @@ void OptionsScreenInput2::updateInputButtons()
|
|||||||
if (currentlyUsedKeys.find(item) == currentlyUsedKeys.end())
|
if (currentlyUsedKeys.find(item) == currentlyUsedKeys.end())
|
||||||
{
|
{
|
||||||
currentlyUsedKeys.insert( item );
|
currentlyUsedKeys.insert( item );
|
||||||
|
if (m_config->getType() == DEVICE_CONFIG_TYPE_KEYBOARD
|
||||||
|
&& conflictsBetweenKbdConfig(action, PA_FIRST_MENU_ACTION, PA_LAST_MENU_ACTION))
|
||||||
|
{
|
||||||
|
conflicts = true;
|
||||||
|
actions->markItemBlue (KartActionStrings[action]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -284,6 +298,13 @@ void OptionsScreenInput2::updateInputButtons()
|
|||||||
//actions->renameItem( KartActionStrings[action], _("Binding Conflict!") );
|
//actions->renameItem( KartActionStrings[action], _("Binding Conflict!") );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GUIEngine::Widget* conflict_label = this->getWidget<GUIEngine::LabelWidget>("conflict");
|
||||||
|
if (conflicts)
|
||||||
|
conflict_label->setText( _("* A blue item means a conflict with another configuration") );
|
||||||
|
else
|
||||||
|
conflict_label->setText("");
|
||||||
|
|
||||||
} // updateInputButtons
|
} // updateInputButtons
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -301,9 +322,9 @@ void OptionsScreenInput2::gotSensedInput(const Input& sensed_input)
|
|||||||
|
|
||||||
if (keyboard)
|
if (keyboard)
|
||||||
{
|
{
|
||||||
if (UserConfigParams::logMisc())
|
if (UserConfigParams::logMisc())
|
||||||
{
|
{
|
||||||
std::cout << "% Binding " << KartActionStrings[binding_to_set]
|
std::cout << "% Binding " << KartActionStrings[binding_to_set]
|
||||||
<< " : setting to keyboard key " << sensed_input.m_button_id
|
<< " : setting to keyboard key " << sensed_input.m_button_id
|
||||||
<< " \n\n";
|
<< " \n\n";
|
||||||
}
|
}
|
||||||
@ -318,9 +339,9 @@ void OptionsScreenInput2::gotSensedInput(const Input& sensed_input)
|
|||||||
}
|
}
|
||||||
else if (gamepad)
|
else if (gamepad)
|
||||||
{
|
{
|
||||||
if (UserConfigParams::logMisc())
|
if (UserConfigParams::logMisc())
|
||||||
{
|
{
|
||||||
std::cout << "% Binding " << KartActionStrings[binding_to_set]
|
std::cout << "% Binding " << KartActionStrings[binding_to_set]
|
||||||
<< " : setting to gamepad #"
|
<< " : setting to gamepad #"
|
||||||
<< sensed_input.m_device_id<< " : ";
|
<< sensed_input.m_device_id<< " : ";
|
||||||
|
|
||||||
@ -491,3 +512,20 @@ void OptionsScreenInput2::onConfirm()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
bool OptionsScreenInput2::conflictsBetweenKbdConfig(PlayerAction action,
|
||||||
|
PlayerAction from, PlayerAction to)
|
||||||
|
{
|
||||||
|
KeyboardConfig* other_kbd_config;
|
||||||
|
int id = m_config->getBinding(action).getId();
|
||||||
|
for (int i=0; i < input_manager->getDeviceList()->getKeyboardAmount(); i++) {
|
||||||
|
other_kbd_config = input_manager->getDeviceList()->getKeyboardConfig(i);
|
||||||
|
|
||||||
|
if (m_config != other_kbd_config && other_kbd_config->hasBindingFor(id, from, to)
|
||||||
|
&& (other_kbd_config->getBinding(action).getId() != id || action == PA_FIRE)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -45,6 +45,8 @@ class OptionsScreenInput2 : public GUIEngine::Screen,
|
|||||||
|
|
||||||
void updateInputButtons();
|
void updateInputButtons();
|
||||||
|
|
||||||
|
bool conflictsBetweenKbdConfig(PlayerAction action, PlayerAction from, PlayerAction to);
|
||||||
|
|
||||||
DeviceConfig* m_config;
|
DeviceConfig* m_config;
|
||||||
|
|
||||||
irr::core::stringw makeLabel(const irr::core::stringw translatedName, PlayerAction action) const;
|
irr::core::stringw makeLabel(const irr::core::stringw translatedName, PlayerAction action) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user