Fixed #856: when changing resolution overworld did still
assume that the textures were cached. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12348 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include "physics/physics.hpp"
|
||||
#include "states_screens/dialogs/confirm_resolution_dialog.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/profiler.hpp"
|
||||
|
||||
@@ -577,12 +578,12 @@ void IrrDriver::applyResolutionSettings()
|
||||
UserConfigParams::m_prev_width,
|
||||
UserConfigParams::m_prev_height) );
|
||||
m_video_driver->endScene();
|
||||
|
||||
attachment_manager -> removeTextures();
|
||||
projectile_manager -> removeTextures();
|
||||
track_manager->removeAllCachedData();
|
||||
attachment_manager->removeTextures();
|
||||
projectile_manager->removeTextures();
|
||||
ItemManager::removeTextures();
|
||||
kart_properties_manager -> unloadAllKarts();
|
||||
powerup_manager -> unloadPowerups();
|
||||
powerup_manager-> unloadPowerups();
|
||||
Referee::cleanup();
|
||||
ParticleKindManager::get()->cleanup();
|
||||
delete input_manager;
|
||||
@@ -625,9 +626,9 @@ void IrrDriver::applyResolutionSettings()
|
||||
material_manager->addSharedMaterial(materials_file);
|
||||
}
|
||||
|
||||
powerup_manager -> loadAllPowerups ();
|
||||
powerup_manager->loadAllPowerups ();
|
||||
ItemManager::loadDefaultItemMeshes();
|
||||
projectile_manager -> loadData();
|
||||
projectile_manager->loadData();
|
||||
Referee::init();
|
||||
GUIEngine::addLoadingIcon(
|
||||
irr_driver->getTexture(file_manager->getGUIDir() + "/gift.png") );
|
||||
@@ -635,11 +636,13 @@ void IrrDriver::applyResolutionSettings()
|
||||
file_manager->popTextureSearchPath();
|
||||
|
||||
KartPropertiesManager::addKartSearchDir(file_manager->getAddonsFile("karts"));
|
||||
kart_properties_manager -> loadAllKarts();
|
||||
|
||||
attachment_manager -> loadModels();
|
||||
GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getGUIDir() + "/banana.png") );
|
||||
kart_properties_manager->loadAllKarts();
|
||||
|
||||
attachment_manager->loadModels();
|
||||
GUIEngine::addLoadingIcon(irr_driver->getTexture(file_manager->getGUIDir()
|
||||
+ "/banana.png") );
|
||||
// No need to reload cached track data (track_manager->cleanAllCachedData
|
||||
// above) - this happens dynamically when the tracks are loaded.
|
||||
GUIEngine::reshowCurrentScreen();
|
||||
|
||||
} // applyResolutionSettings
|
||||
|
||||
@@ -123,6 +123,15 @@ Track::~Track()
|
||||
#endif
|
||||
} // ~Track
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Removes all cached data structures. This is called before the resolution
|
||||
* is changed.
|
||||
*/
|
||||
void Track::removeCachedData()
|
||||
{
|
||||
m_materials_loaded = false;
|
||||
} // cleanCachedData
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Prepates the track for a new race. This function must be called after all
|
||||
* karts are created, since the check objects allocate data structures
|
||||
|
||||
@@ -380,6 +380,7 @@ public:
|
||||
Track (const std::string &filename);
|
||||
~Track ();
|
||||
void cleanup ();
|
||||
void removeCachedData ();
|
||||
void startMusic () const;
|
||||
|
||||
bool setTerrainHeight(Vec3 *pos) const;
|
||||
|
||||
@@ -74,6 +74,15 @@ Track* TrackManager::getTrack(const std::string& ident) const
|
||||
|
||||
} // getTrack
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Removes all cached data from all tracks. This is called when the screen
|
||||
* resolution is changed and all textures need to be bound again.
|
||||
*/
|
||||
void TrackManager::removeAllCachedData()
|
||||
{
|
||||
for(Tracks::const_iterator i = m_tracks.begin(); i != m_tracks.end(); ++i)
|
||||
(*i)->removeCachedData();
|
||||
} // removeAllCachedData
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets all tracks that are not in the list a to be unavailable. This is used
|
||||
* by the network manager upon receiving the list of available tracks from
|
||||
|
||||
@@ -67,60 +67,68 @@ private:
|
||||
void updateGroups(const Track* track);
|
||||
|
||||
public:
|
||||
TrackManager();
|
||||
~TrackManager();
|
||||
TrackManager();
|
||||
~TrackManager();
|
||||
|
||||
static void addTrackSearchDir(const std::string &dir);
|
||||
bool loadTrack(const std::string& dirname);
|
||||
|
||||
/** \brief Returns a list of all directories that contain a track. */
|
||||
const std::vector<std::string>* getAllTrackDirs() const
|
||||
{ return &m_all_track_dirs; }
|
||||
|
||||
/** \brief Returns a list of the names of all used track groups. */
|
||||
const std::vector<std::string>&
|
||||
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(); }
|
||||
|
||||
/** Returns the track with a given index number.
|
||||
* \param index The index number of the track. */
|
||||
Track *getTrack(unsigned int index) const { return m_tracks[index];}
|
||||
|
||||
Track *getTrack(const std::string& ident) const;
|
||||
|
||||
/** Sets a list of track as being unavailable (e.g. in network mode the
|
||||
* track is not on all connected machines.
|
||||
* \param tracks List of tracks to mark as unavilable. */
|
||||
void setUnavailableTracks(const std::vector<std::string> &tracks);
|
||||
|
||||
/** Checks if a certain track is available.
|
||||
* \param n Index of the track to check. */
|
||||
bool isAvailable(unsigned int n) const {return m_track_avail[n];}
|
||||
|
||||
/** 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_track_groups[g];}
|
||||
|
||||
/** Returns a list of all arenas in a given group.
|
||||
* \param g Name of the group. */
|
||||
const std::vector<int>&
|
||||
getArenasInGroup(const std::string& g) {return m_arena_groups[g];}
|
||||
|
||||
static void addTrackSearchDir(const std::string &dir);
|
||||
/** Returns a list of all track identifiers. */
|
||||
std::vector<std::string> getAllTrackIdentifiers();
|
||||
|
||||
/** Load all .track files from all directories */
|
||||
void loadTrackList();
|
||||
|
||||
void removeTrack(const std::string &ident);
|
||||
|
||||
void loadTrackList();
|
||||
void removeTrack(const std::string &ident);
|
||||
bool loadTrack(const std::string& dirname);
|
||||
void removeAllCachedData();
|
||||
Track* getTrack(const std::string& ident) const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets a list of track as being unavailable (e.g. in network mode the
|
||||
* track is not on all connected machines.
|
||||
* \param tracks List of tracks to mark as unavilable. */
|
||||
void setUnavailableTracks(const std::vector<std::string> &tracks);
|
||||
// ------------------------------------------------------------------------
|
||||
/** \brief Returns a list of all directories that contain a track. */
|
||||
const std::vector<std::string>* getAllTrackDirs() const
|
||||
{
|
||||
return &m_all_track_dirs;
|
||||
} // getAllTrackDirs
|
||||
// ------------------------------------------------------------------------
|
||||
/** \brief Returns a list of the names of all used track groups. */
|
||||
const std::vector<std::string>& getAllTrackGroups() const
|
||||
{
|
||||
return m_track_group_names;
|
||||
} // getAllTrackGroups
|
||||
// ------------------------------------------------------------------------
|
||||
/** \brief Returns a list of the names of all used arena groups. */
|
||||
const std::vector<std::string>& getAllArenaGroups() const
|
||||
{
|
||||
return m_arena_group_names;
|
||||
} // getAllArenaGRoups
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the number of tracks. */
|
||||
size_t getNumberOfTracks() const { return m_tracks.size(); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the track with a given index number.
|
||||
* \param index The index number of the track. */
|
||||
Track* getTrack(unsigned int index) const { return m_tracks[index];}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Checks if a certain track is available.
|
||||
* \param n Index of the track to check. */
|
||||
bool isAvailable(unsigned int n) const {return m_track_avail[n];}
|
||||
// ------------------------------------------------------------------------
|
||||
/** 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_track_groups[g];
|
||||
} // getTracksInGroup
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a list of all arenas in a given group.
|
||||
* \param g Name of the group. */
|
||||
const std::vector<int>& getArenasInGroup(const std::string& g)
|
||||
{
|
||||
return m_arena_groups[g];
|
||||
// getArenasInGroup}
|
||||
}
|
||||
}; // TrackManager
|
||||
|
||||
extern TrackManager* track_manager;
|
||||
|
||||
Reference in New Issue
Block a user