This commit is contained in:
hiker 2015-10-22 11:04:07 +11:00
commit 65454db0ce
6 changed files with 21 additions and 1 deletions

View File

@ -65,6 +65,7 @@ SavedGrandPrix::SavedGPKart::SavedGPKart(GroupUserConfigParam * group,
// ============================================================================
SavedGrandPrix::SavedGrandPrix(unsigned int player_id,
const std::string &gp_id,
RaceManager::MinorRaceModeType race_type,
RaceManager::Difficulty difficulty,
int player_karts,
int last_track,
@ -74,6 +75,7 @@ SavedGrandPrix::SavedGrandPrix(unsigned int player_id,
"Represents the saved state of a GP"),
m_player_id(player_id, "player_id", &m_savedgp_group),
m_gp_id(gp_id.c_str(), "gp_id", &m_savedgp_group),
m_race_type((int)race_type,"race_type", &m_savedgp_group),
m_difficulty((int)difficulty,"difficulty", &m_savedgp_group),
m_player_karts(player_karts,"player_karts", &m_savedgp_group),
m_next_track(last_track,"last_track", &m_savedgp_group),
@ -98,6 +100,7 @@ SavedGrandPrix::SavedGrandPrix(const XMLNode* node)
"Represents the saved state of a GP"),
m_player_id (0, "player_id", &m_savedgp_group),
m_gp_id ("-", "gp_id", &m_savedgp_group),
m_race_type (0,"race_type", &m_savedgp_group),
m_difficulty (0,"difficulty", &m_savedgp_group),
m_player_karts(0,"player_karts", &m_savedgp_group),
m_next_track (0,"last_track", &m_savedgp_group),
@ -106,6 +109,7 @@ SavedGrandPrix::SavedGrandPrix(const XMLNode* node)
//m_player_group.findYourDataInAChildOf(node);
m_player_id. findYourDataInAnAttributeOf(node);
m_gp_id. findYourDataInAnAttributeOf(node);
m_race_type. findYourDataInAnAttributeOf(node);
m_difficulty. findYourDataInAnAttributeOf(node);
m_player_karts.findYourDataInAnAttributeOf(node);
m_next_track. findYourDataInAnAttributeOf(node);

View File

@ -67,6 +67,9 @@ protected:
/** Identifier of this GP. */
StringUserConfigParam m_gp_id;
/** Race type at which this GP was run. */
IntUserConfigParam m_race_type;
/** Difficulty at which this GP was run. */
IntUserConfigParam m_difficulty;
@ -88,6 +91,7 @@ public:
*/
SavedGrandPrix(unsigned int player_id,
const std::string &gp_id,
RaceManager::MinorRaceModeType race_type,
RaceManager::Difficulty difficulty,
int player_karts,
int last_track,
@ -110,6 +114,10 @@ public:
/** Returns the grand prix id. */
std::string getGPID() const { return m_gp_id; }
// ------------------------------------------------------------------------
/** Returns the race type of this GP. */
int getRaceType() const { return m_race_type; }
// ------------------------------------------------------------------------
/** Returns the difficulty of this GP. */
int getDifficulty() const { return m_difficulty; }
@ -148,12 +156,14 @@ public:
* NULL if no matching GP was found. */
static SavedGrandPrix* getSavedGP(unsigned int player,
const std::string &gpid,
RaceManager::MinorRaceModeType race_type,
const unsigned int number_of_players)
{
for (unsigned int n=0; n<UserConfigParams::m_saved_grand_prix_list.size(); n++)
{
SavedGrandPrix* gp = &UserConfigParams::m_saved_grand_prix_list[n];
if (gp->getGPID() == gpid &&
gp->getRaceType() == race_type &&
gp->getPlayerID() == player &&
gp->getPlayerKarts() == (int)number_of_players)
return gp;

View File

@ -690,7 +690,8 @@ EventPropagation RibbonWidget::transmitEvent(Widget* w,
// bring focus back to enclosing ribbon widget
this->setFocusForPlayer( playerID );
if (m_selection[playerID] != -1)
if (m_selection[playerID] > -1 &&
m_selection[playerID] < (int)(m_active_children.size()))
{
if (m_active_children[m_selection[playerID]].m_deactivated)
{

View File

@ -305,6 +305,7 @@ void RaceManager::startNew(bool from_overworld)
->getActivePlayerProfile(0)
->getUniqueID(),
m_grand_prix.getId(),
m_minor_mode,
m_player_karts.size());
// Saved GP only in offline mode
@ -398,6 +399,7 @@ void RaceManager::startNew(bool from_overworld)
->getActivePlayerProfile(0)
->getUniqueID(),
m_grand_prix.getId(),
m_minor_mode,
m_player_karts.size());
}
}
@ -551,6 +553,7 @@ void RaceManager::saveGP()
m_saved_gp = new SavedGrandPrix(
StateManager::get()->getActivePlayerProfile(0)->getUniqueID(),
m_grand_prix.getId(),
m_minor_mode,
m_difficulty,
(int)m_player_karts.size(),
m_track_number,

View File

@ -205,6 +205,7 @@ void GPInfoDialog::addButtons()
->getActivePlayerProfile(0)
->getUniqueID(),
m_gp.getId(),
race_manager->getMinorMode(),
race_manager->getNumLocalPlayers());
okBtn->m_properties[PROP_ID] = "start";

View File

@ -134,6 +134,7 @@ void GPInfoScreen::beforeAddingWidget()
SavedGrandPrix* saved_gp = SavedGrandPrix::getSavedGP(
StateManager::get()->getActivePlayerProfile(0)->getUniqueID(),
m_gp.getId(),
race_manager->getMinorMode(),
race_manager->getNumLocalPlayers());
int tracks = m_gp.getTrackNames().size();