In single-player mode, the user can now use all input devices
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7518 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
987d4ebd3f
commit
368a7ebd13
@ -39,6 +39,7 @@ DeviceManager::DeviceManager()
|
||||
{
|
||||
m_latest_used_device = NULL;
|
||||
m_assign_mode = NO_ASSIGN;
|
||||
m_single_player = NULL;
|
||||
} // DeviceManager
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -269,7 +270,12 @@ InputDevice* DeviceManager::mapKeyboardInput( int btnID, InputManager::InputDriv
|
||||
if (keyboard->processAndMapInput(btnID, mode, action))
|
||||
{
|
||||
//std::cout << " binding found in keyboard #" << (n+1) << "; action is " << KartActionStrings[*action] << "\n";
|
||||
if (m_assign_mode == NO_ASSIGN) // Don't set the player in NO_ASSIGN mode
|
||||
if (m_single_player != NULL)
|
||||
{
|
||||
//printf("Single player\n");
|
||||
*player = m_single_player;
|
||||
}
|
||||
else if (m_assign_mode == NO_ASSIGN) // Don't set the player in NO_ASSIGN mode
|
||||
{
|
||||
*player = NULL;
|
||||
}
|
||||
@ -301,7 +307,11 @@ InputDevice *DeviceManager::mapGamepadInput( Input::InputType type,
|
||||
{
|
||||
if (gPad->processAndMapInput(type, btnID, value, mode, gPad->getPlayer(), action))
|
||||
{
|
||||
if (m_assign_mode == NO_ASSIGN) // Don't set the player in NO_ASSIGN mode
|
||||
if (m_single_player != NULL)
|
||||
{
|
||||
*player = m_single_player;
|
||||
}
|
||||
else if (m_assign_mode == NO_ASSIGN) // Don't set the player in NO_ASSIGN mode
|
||||
{
|
||||
*player = NULL;
|
||||
}
|
||||
|
@ -76,6 +76,9 @@ private:
|
||||
StateManager::ActivePlayer **player /* out */,
|
||||
PlayerAction *action /* out */);
|
||||
|
||||
/** Will be non-null in single-player mode */
|
||||
StateManager::ActivePlayer* m_single_player;
|
||||
|
||||
/**
|
||||
* Helper method, only used internally. Takes care of analyzing keyboard input.
|
||||
*
|
||||
@ -147,6 +150,11 @@ public:
|
||||
|
||||
void clearLatestUsedDevice();
|
||||
InputDevice* getLatestUsedDevice();
|
||||
|
||||
StateManager::ActivePlayer* getSinglePlayer() { return m_single_player; }
|
||||
void setSinglePlayer(StateManager::ActivePlayer* p) { m_single_player = p; }
|
||||
|
||||
|
||||
bool initialize();
|
||||
void serialize();
|
||||
};
|
||||
|
@ -1107,6 +1107,11 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
|
||||
newPlayerWidget->m_player_ident_spinner->setFocusForPlayer(new_player_id);
|
||||
}
|
||||
|
||||
if (!m_multiplayer)
|
||||
{
|
||||
input_manager->getDeviceList()->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1502,6 +1507,15 @@ void KartSelectionScreen::allPlayersDone()
|
||||
// ---- Switch to assign mode
|
||||
input_manager->getDeviceList()->setAssignMode(ASSIGN);
|
||||
|
||||
if (!m_multiplayer)
|
||||
{
|
||||
input_manager->getDeviceList()->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
||||
}
|
||||
else
|
||||
{
|
||||
input_manager->getDeviceList()->setSinglePlayer( NULL );
|
||||
}
|
||||
|
||||
StateManager::get()->pushScreen( RaceSetupScreen::getInstance() );
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,7 @@ void MainMenuScreen::init()
|
||||
// reset in case we're coming back from a race
|
||||
StateManager::get()->resetActivePlayers();
|
||||
input_manager->getDeviceList()->setAssignMode(NO_ASSIGN);
|
||||
input_manager->getDeviceList()->setSinglePlayer( NULL );
|
||||
input_manager->setMasterPlayerOnly(false);
|
||||
|
||||
// Avoid incorrect behaviour in certain race circumstances:
|
||||
|
Loading…
Reference in New Issue
Block a user