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, SavedGrandPrix::SavedGrandPrix(unsigned int player_id,
const std::string &gp_id, const std::string &gp_id,
RaceManager::MinorRaceModeType race_type,
RaceManager::Difficulty difficulty, RaceManager::Difficulty difficulty,
int player_karts, int player_karts,
int last_track, int last_track,
@ -74,6 +75,7 @@ SavedGrandPrix::SavedGrandPrix(unsigned int player_id,
"Represents the saved state of a GP"), "Represents the saved state of a GP"),
m_player_id(player_id, "player_id", &m_savedgp_group), m_player_id(player_id, "player_id", &m_savedgp_group),
m_gp_id(gp_id.c_str(), "gp_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_difficulty((int)difficulty,"difficulty", &m_savedgp_group),
m_player_karts(player_karts,"player_karts", &m_savedgp_group), m_player_karts(player_karts,"player_karts", &m_savedgp_group),
m_next_track(last_track,"last_track", &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"), "Represents the saved state of a GP"),
m_player_id (0, "player_id", &m_savedgp_group), m_player_id (0, "player_id", &m_savedgp_group),
m_gp_id ("-", "gp_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_difficulty (0,"difficulty", &m_savedgp_group),
m_player_karts(0,"player_karts", &m_savedgp_group), m_player_karts(0,"player_karts", &m_savedgp_group),
m_next_track (0,"last_track", &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_group.findYourDataInAChildOf(node);
m_player_id. findYourDataInAnAttributeOf(node); m_player_id. findYourDataInAnAttributeOf(node);
m_gp_id. findYourDataInAnAttributeOf(node); m_gp_id. findYourDataInAnAttributeOf(node);
m_race_type. findYourDataInAnAttributeOf(node);
m_difficulty. findYourDataInAnAttributeOf(node); m_difficulty. findYourDataInAnAttributeOf(node);
m_player_karts.findYourDataInAnAttributeOf(node); m_player_karts.findYourDataInAnAttributeOf(node);
m_next_track. findYourDataInAnAttributeOf(node); m_next_track. findYourDataInAnAttributeOf(node);

View File

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

View File

@ -690,7 +690,8 @@ EventPropagation RibbonWidget::transmitEvent(Widget* w,
// bring focus back to enclosing ribbon widget // bring focus back to enclosing ribbon widget
this->setFocusForPlayer( playerID ); 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) if (m_active_children[m_selection[playerID]].m_deactivated)
{ {

View File

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

View File

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

View File

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