non-game-master players are now also prevented from altering race setup screens using mouse

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4266 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-12-06 19:29:35 +00:00
parent e20f805e61
commit 958c107969
3 changed files with 13 additions and 1 deletions

View File

@ -83,7 +83,8 @@ EventPropagation EventHandler::onGUIEvent(const SEvent& event)
// These events are only triggered by keyboard/mouse (or so I hope...)
const int playerID = input_manager->getPlayerKeyboardID();
if (playerID != -1) return onWidgetActivated(w, playerID);
if (input_manager->masterPlayerOnly() && playerID != 0) break;
else if (playerID != -1) return onWidgetActivated(w, playerID);
else break;
}
case EGET_ELEMENT_HOVERED:
@ -108,6 +109,8 @@ EventPropagation EventHandler::onGUIEvent(const SEvent& event)
if (ribbon == NULL) break;
const int playerID = input_manager->getPlayerKeyboardID();
if (playerID == -1) break;
if (input_manager->masterPlayerOnly() && playerID != 0) break;
if (ribbon->mouseHovered(w, playerID) == EVENT_LET) transmitEvent(ribbon, ribbon->m_properties[PROP_ID], playerID);
if (ribbon->m_event_handler != NULL) ribbon->m_event_handler->mouseHovered(w, playerID);
ribbon->setFocusForPlayer(playerID);
@ -116,6 +119,7 @@ EventPropagation EventHandler::onGUIEvent(const SEvent& event)
{
// focus on hover for other widgets
const int playerID = input_manager->getPlayerKeyboardID();
if (input_manager->masterPlayerOnly() && playerID != 0) break;
if (playerID != -1)
{
w->setFocusForPlayer(playerID);

View File

@ -399,6 +399,11 @@ void InputManager::setMasterPlayerOnly(bool enabled)
{
m_master_player_only = enabled;
}
/** Returns whether only the master player should be allowed to perform changes in menus */
bool InputManager::masterPlayerOnly() const
{
return m_device_manager->getAssignMode() == ASSIGN && m_master_player_only;
}
//-----------------------------------------------------------------------------
/**
* Called on keyboard events [indirectly] by irrLicht

View File

@ -92,6 +92,9 @@ public:
/** When this mode is enabled, only the master player will be able to play with menus (only works in 'assign' mode) */
void setMasterPlayerOnly(bool enabled);
/** Returns whether only the master player should be allowed to perform changes in menus */
bool masterPlayerOnly() const;
void update(float dt);
/** Returns the ID of the player that plays with the keyboard, or -1 if none */