Seperate handling of track groups and arena groups in track manager; if you have e.g. one add-on track but no add-on arena, you'd get a weird empty group in the arena selection screen

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5417 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2010-05-10 01:09:36 +00:00
parent 4e4c11b401
commit 493f24fbcf
4 changed files with 43 additions and 21 deletions

View File

@@ -53,9 +53,7 @@ void ArenasScreen::loadedFromFile()
tabs->clearAllChildren();
//FIXME: this returns groups for arenas but tracks too. this means that some of them
// may contain only tracks, no arenas, and thus add an empty tab here...
const std::vector<std::string>& groups = track_manager->getAllGroups();
const std::vector<std::string>& groups = track_manager->getAllArenaGroups();
const int group_amount = groups.size();
// add standard group first

View File

@@ -55,7 +55,7 @@ void TracksScreen::loadedFromFile()
tabs->clearAllChildren();
const std::vector<std::string>& groups = track_manager->getAllGroups();
const std::vector<std::string>& groups = track_manager->getAllTrackGroups();
const int group_amount = groups.size();
// add standard group first

View File

@@ -172,9 +172,9 @@ bool TrackManager::loadTrack(const std::string& dirname)
} // loadTrack
// ----------------------------------------------------------------------------
/** Updates the groups after a track was read in.
* \param track Pointer to the new track, whose groups are now analysed.
*/
/** \brief Updates the groups after a track was read in.
* \param track Pointer to the new track, whose groups are now analysed.
*/
void TrackManager::updateGroups(const Track* track)
{
const std::vector<std::string>& new_groups = track->getGroups();
@@ -183,14 +183,24 @@ void TrackManager::updateGroups(const Track* track)
const unsigned int groups_amount = new_groups.size();
for(unsigned int i=0; i<groups_amount; i++)
{
// if we didn't yet have this group in memory, add it to the global list
if(m_groups.find(new_groups[i])==m_groups.end() &&
m_arena_groups.find(new_groups[i])==m_arena_groups.end())
m_all_groups.push_back(new_groups[i]);
// add this track to its group
if(isArena) m_arena_groups[new_groups[i]].push_back(m_tracks.size()-1);
else m_groups[new_groups[i]].push_back(m_tracks.size()-1);
if (isArena)
{
// update the list of group names if necessary
const bool isInArenaGroupsList = (m_arena_groups.find(new_groups[i]) != m_arena_groups.end());
if (!isInArenaGroupsList) m_arena_group_names.push_back(new_groups[i]);
// add this track to its group
m_arena_groups[new_groups[i]].push_back(m_tracks.size()-1);
}
else
{
// update the list of group names if necessary
const bool isInTrackGroupsList = (m_track_groups.find(new_groups[i]) != m_track_groups.end());
if (!isInTrackGroupsList) m_track_group_names.push_back(new_groups[i]);
// add this track to its group
m_track_groups[new_groups[i]].push_back(m_tracks.size()-1);
}
}
} // updateGroups

View File

@@ -45,14 +45,20 @@ private:
Tracks m_tracks;
/** List of all racing track groups. */
std::map<std::string, std::vector<int> > m_groups;
std::map<std::string, std::vector<int> > m_track_groups;
/** List of all arena groups. */
std::map<std::string, std::vector<int> > m_arena_groups;
/** List of all groups (for both normal tracks and arenas) */
std::vector<std::string> m_all_groups;
//std::vector<std::string> m_all_group_names;
/** List of the names of all groups containing tracks */
std::vector<std::string> m_track_group_names;
/** List of the names of all groups containing arenas */
std::vector<std::string> m_arena_group_names;
/** Flag if this track is available or not. Tracks are set unavailable
* if they are not available on all clients (applies only to network mode)
*/
@@ -67,13 +73,21 @@ public:
static void addTrackSearchDir(const std::string &dir);
/** Returns a list of all directories that contain a track. */
/** \brief Returns a list of all directories that contain a track. */
const std::vector<std::string>* getAllTrackDirs() const
{ return &m_all_track_dirs; }
/** Returns a list of all used track groups. */
/** \brief Returns a list of the names of all used groups (for tracks or arenas) */
//const std::vector<std::string>&
// getAllGroups() const { return m_all_group_names; }
/** \brief Returns a list of the names of all used track groups. */
const std::vector<std::string>&
getAllGroups() const { return m_all_groups; }
getAllTrackGroups() const { return m_track_group_names; }
/** \brief Returns a list of the names of all used arena groups. */
const std::vector<std::string>&
getAllArenaGroups() const { return m_arena_group_names; }
/** Returns the number of tracks. */
size_t getNumberOfTracks() const { return m_tracks.size(); }
@@ -96,7 +110,7 @@ public:
/** Returns a list of all tracks in a given group.
* \param g Name of the group. */
const std::vector<int>&
getTracksInGroup(const std::string& g) {return m_groups[g];}
getTracksInGroup(const std::string& g) {return m_track_groups[g];}
/** Returns a list of all arenas in a given group.
* \param g Name of the group. */