Initial work towards selecting the most used profile for game master, and guest profile for others (by default). not really there yet so expect weird stuff to happen if you don't play with the spinner and leave the defaults.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5078 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
2b68412239
commit
f9cb8b125d
@ -366,6 +366,14 @@ void UserConfig::addDefaultPlayer()
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** comparison function used to sort players */
|
||||
bool comparePlayers(PlayerProfile* a, PlayerProfile* b)
|
||||
{
|
||||
return a->m_use_frequency > b->m_use_frequency;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Load configuration values from file. */
|
||||
bool UserConfig::loadConfig()
|
||||
@ -445,7 +453,11 @@ bool UserConfig::loadConfig()
|
||||
//std::string name;
|
||||
//players[i]->get("name", &name);
|
||||
UserConfigParams::m_all_players.push_back( new PlayerProfile(players[i]) );
|
||||
}
|
||||
}
|
||||
|
||||
// sort players by frequency of use
|
||||
std::sort (UserConfigParams::m_all_players.contentsVector.begin(),
|
||||
UserConfigParams::m_all_players.contentsVector.end(), comparePlayers);
|
||||
|
||||
|
||||
delete root;
|
||||
@ -453,6 +465,7 @@ bool UserConfig::loadConfig()
|
||||
return true;
|
||||
} // loadConfig
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Write settings to config file. */
|
||||
void UserConfig::saveConfig()
|
||||
|
@ -273,6 +273,9 @@ public:
|
||||
//playerName->m_event_handler = this;
|
||||
m_children.push_back(playerName);
|
||||
|
||||
//TODO: select the right player profile in the spinner
|
||||
//associatedPlayer->getProfile()->getName()
|
||||
|
||||
// ----- Kart model view
|
||||
modelView = new ModelViewWidget();
|
||||
|
||||
@ -815,7 +818,7 @@ void KartSelectionScreen::forgetWhatWasLoaded()
|
||||
// Return true if event was handled successfully
|
||||
bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
|
||||
{
|
||||
if(UserConfigParams::m_verbosity>=5) std::cout << "playerJoin() ==========\n";
|
||||
if (UserConfigParams::m_verbosity>=5) std::cout << "playerJoin() ==========\n";
|
||||
|
||||
if (g_dispatcher == NULL)
|
||||
{
|
||||
@ -847,7 +850,22 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
|
||||
kartsArea.x = irr_driver->getFrameSize().Width; // start at the rightmost of the screen
|
||||
|
||||
// ---- Create new active player
|
||||
const int new_player_id = StateManager::get()->createActivePlayer( UserConfigParams::m_all_players.get(0), device );
|
||||
PlayerProfile* profileToUse = UserConfigParams::m_all_players.get(0);
|
||||
|
||||
if (!firstPlayer)
|
||||
{
|
||||
const int playerProfileCount = UserConfigParams::m_all_players.size();
|
||||
for (int n=0; n<playerProfileCount; n++)
|
||||
{
|
||||
if (UserConfigParams::m_all_players[n].isGuestAccount())
|
||||
{
|
||||
profileToUse = UserConfigParams::m_all_players.get(n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const int new_player_id = StateManager::get()->createActivePlayer( profileToUse, device );
|
||||
StateManager::ActivePlayer* aplayer = StateManager::get()->getActivePlayer(new_player_id);
|
||||
|
||||
// ---- Create focus dispatcher
|
||||
|
Loading…
Reference in New Issue
Block a user