In multiplayer mode, players other than the game master should not be able to select stuff in race setup menus

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4265 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-12-06 19:22:57 +00:00
parent 51d6af8853
commit e20f805e61
4 changed files with 19 additions and 1 deletions

View File

@ -59,6 +59,7 @@ InputManager::InputManager() : m_sensed_input(0), m_mode(BOOTSTRAP),
m_device_manager->initialize(); m_device_manager->initialize();
m_timer_in_use = false; m_timer_in_use = false;
m_master_player_only = false;
m_timer = 0; m_timer = 0;
} }
@ -380,6 +381,9 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID, int btnID,
m_timer = 0.25; m_timer = 0.25;
} }
int playerID = (player == NULL ? 0 : player->m_id); int playerID = (player == NULL ? 0 : player->m_id);
// If only the master player can act, and this player is not the master, ignore his input
if (m_device_manager->getAssignMode() == ASSIGN && m_master_player_only && playerID != 0) return;
GUIEngine::EventHandler::get()->processAction(action, abs(value), type, playerID); GUIEngine::EventHandler::get()->processAction(action, abs(value), type, playerID);
} }
} }
@ -390,7 +394,11 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID, int btnID,
handleStaticAction( btnID, value ); handleStaticAction( btnID, value );
} }
} // input } // input
//-----------------------------------------------------------------------------
void InputManager::setMasterPlayerOnly(bool enabled)
{
m_master_player_only = enabled;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** /**
* Called on keyboard events [indirectly] by irrLicht * Called on keyboard events [indirectly] by irrLicht

View File

@ -63,6 +63,9 @@ private:
InputDriverMode m_mode; InputDriverMode m_mode;
/** When at true, only the master player can play with menus */
bool m_master_player_only;
/* Helper values to store and track the relative mouse movements. If these /* Helper values to store and track the relative mouse movements. If these
* values exceed the deadzone value the input is reported to the game. This * values exceed the deadzone value the input is reported to the game. This
* makes the mouse behave like an analog axis on a gamepad/joystick. * makes the mouse behave like an analog axis on a gamepad/joystick.
@ -86,6 +89,9 @@ public:
void setMode(InputDriverMode); void setMode(InputDriverMode);
bool isInMode(InputDriverMode); bool isInMode(InputDriverMode);
/** 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);
void update(float dt); void update(float dt);
/** Returns the ID of the player that plays with the keyboard, or -1 if none */ /** Returns the ID of the player that plays with the keyboard, or -1 if none */

View File

@ -396,6 +396,7 @@ void RaceManager::exitRace()
StateManager::get()->resetActivePlayers(); StateManager::get()->resetActivePlayers();
input_manager->getDeviceList()->setAssignMode(NO_ASSIGN); input_manager->getDeviceList()->setAssignMode(NO_ASSIGN);
input_manager->setMasterPlayerOnly(false);
} // exitRace } // exitRace
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -938,6 +938,9 @@ void KartSelectionScreen::init()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void KartSelectionScreen::allPlayersDone() void KartSelectionScreen::allPlayersDone()
{ {
// FIXME: cancel this when leaving back to main menu
input_manager->setMasterPlayerOnly(true);
DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("karts"); DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("karts");
assert( w != NULL ); assert( w != NULL );