Allow preloading all song banners.

This commit is contained in:
Glenn Maynard
2003-11-25 22:56:48 +00:00
parent 262f80e8dd
commit da160607b8
7 changed files with 52 additions and 23 deletions
+6 -7
View File
@@ -17,6 +17,10 @@
#include "SDL_dither.h"
#include "SDL_image.h"
#include "SDL_rotozoom.h"
#include "SDL_utils.h"
#include "RageDisplay.h"
#include "RageTexture.h"
#include "RageTextureManager.h"
#include "Banner.h"
@@ -55,7 +59,7 @@ CString BannerCache::GetBannerCachePath( CString BannerPath )
void BannerCache::LoadBanner( CString BannerPath )
{
if( !PREFSMAN->m_bBannerCache || BannerPath == "" )
if( PREFSMAN->m_BannerCache != PrefsManager::BNCACHE_LOW_RES || BannerPath == "" )
return;
/* Load it. */
@@ -125,11 +129,6 @@ BannerCache::~BannerCache()
UnloadAllBanners();
}
#include "SDL_utils.h"
#include "RageDisplay.h"
#include "RageTexture.h"
#include "RageTextureManager.h"
struct BannerTexture: public RageTexture
{
unsigned m_uTexHandle;
@@ -397,7 +396,7 @@ void BannerCache::CacheBannerInternal( CString BannerPath )
const CString CachePath = GetBannerCachePath(BannerPath);
mySDL_SaveSurface( img, CachePath );
if( PREFSMAN->m_bBannerCache )
if( PREFSMAN->m_BannerCache == PrefsManager::BNCACHE_LOW_RES )
{
/* If an old image is loaded, free it. */
if( m_BannerPathToImage.find(BannerPath) != m_BannerPathToImage.end() )
+7 -2
View File
@@ -112,8 +112,13 @@ void FadingBanner::LoadFromCachedBanner( const CString &path )
/* No matter what we load, ensure we don't fade to a stale path. */
m_sPendingBanner = "";
/* Try to load the low quality version. */
RageTextureID ID = BANNERCACHE->LoadCachedBanner( path );
RageTextureID ID;
if( PREFSMAN->m_BannerCache == PrefsManager::BNCACHE_FULL )
ID = Banner::BannerTex( path );
else
/* Try to load the low quality version. */
ID = BANNERCACHE->LoadCachedBanner( path );
if( !TEXTUREMAN->IsTextureRegistered(ID) )
{
/* Oops. We couldn't load a banner quickly. We can load the actual
+3 -3
View File
@@ -93,7 +93,7 @@ PrefsManager::PrefsManager()
m_bDelayedTextureDelete = true;
m_bTexturePreload = false;
m_bDelayedScreenLoad = false;
m_bBannerCache = true;
m_BannerCache = BNCACHE_LOW_RES;
m_MusicWheelUsesSections = ALWAYS;
m_iMusicWheelSwitchSpeed = 10;
m_bEasterEggs = true;
@@ -283,7 +283,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk()
ini.GetValue( "Options", "DelayedTextureDelete", m_bDelayedTextureDelete );
ini.GetValue( "Options", "TexturePreload", m_bTexturePreload );
ini.GetValue( "Options", "DelayedScreenLoad", m_bDelayedScreenLoad );
ini.GetValue( "Options", "BannerCache", m_bBannerCache );
ini.GetValue( "Options", "BannerCache", (int&)m_BannerCache );
ini.GetValue( "Options", "MusicWheelUsesSections", (int&)m_MusicWheelUsesSections );
ini.GetValue( "Options", "MusicWheelSwitchSpeed", m_iMusicWheelSwitchSpeed );
ini.GetValue( "Options", "SoundDrivers", m_sSoundDrivers );
@@ -445,7 +445,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
ini.SetValue( "Options", "DelayedTextureDelete", m_bDelayedTextureDelete );
ini.SetValue( "Options", "TexturePreload", m_bTexturePreload );
ini.SetValue( "Options", "DelayedScreenLoad", m_bDelayedScreenLoad );
ini.SetValue( "Options", "BannerCache", m_bBannerCache );
ini.SetValue( "Options", "BannerCache", m_BannerCache );
ini.SetValue( "Options", "MusicWheelUsesSections", m_MusicWheelUsesSections );
ini.SetValue( "Options", "MusicWheelSwitchSpeed", m_iMusicWheelSwitchSpeed );
ini.SetValue( "Options", "EasterEggs", m_bEasterEggs );
+2 -1
View File
@@ -46,7 +46,8 @@ public:
bool m_bDelayedTextureDelete;
bool m_bTexturePreload;
bool m_bDelayedScreenLoad;
bool m_bBannerCache;
enum BannerCacheMode { BNCACHE_OFF, BNCACHE_LOW_RES, BNCACHE_FULL };
BannerCacheMode m_BannerCache;
bool m_bOnlyDedicatedMenuButtons;
bool m_bMenuTimer;
+21
View File
@@ -29,6 +29,8 @@
#include "GameManager.h"
#include "RageFile.h"
#include "ProductInfo.h"
#include "RageTextureManager.h"
#include "Banner.h"
SongManager* SONGMAN = NULL; // global and accessable from anywhere in our program
@@ -302,6 +304,25 @@ void SongManager::LoadGroupSymLinks(CString sDir, CString sGroupFolder)
}
}
void SongManager::PreloadSongImages()
{
ASSERT( TEXTUREMAN );
if( PREFSMAN->m_BannerCache != PrefsManager::BNCACHE_FULL )
return;
const vector<Song*> &songs = SONGMAN->GetAllSongs();
unsigned i;
for( i = 0; i < songs.size(); ++i )
{
if( !songs[i]->HasBanner() )
continue;
const RageTextureID ID = Banner::BannerTex( songs[i]->GetBannerPath() );
TEXTUREMAN->CacheTexture( ID );
}
}
void SongManager::FreeSongs()
{
for( unsigned i=0; i<m_pSongs.size(); i++ )
+1
View File
@@ -42,6 +42,7 @@ public:
void FreeCourses();
void Reload(); // songs, courses, groups - everything.
void PreloadSongImages();
CString GetGroupBannerPath( CString sGroupName );
+12 -10
View File
@@ -353,7 +353,7 @@ static void CheckSettings()
/* Preloaded banners takes about 9k per song. Although it's smaller than the
* actual song data, it still adds up with a lot of songs. Disable it for 64-meg
* systems. */
PREFSMAN->m_bBannerCache = !LowMemory;
PREFSMAN->m_BannerCache = LowMemory? PrefsManager::BNCACHE_OFF:PrefsManager::BNCACHE_LOW_RES;
PREFSMAN->SaveGlobalPrefsToDisk();
#endif
@@ -755,18 +755,16 @@ void SaveGamePrefsToDisk()
#define UNLOCKS_PATH BASE_PATH "Data" SLASH "Unlocks.dat"
#ifdef _XBOX
char *xboxargv[] = { "d:\\default.xbe" } ;
char *xboxargv[] = { "d:\\default.xbe" };
extern RageDisplay::VideoModeParams g_CurrentParams;
#endif
int main(int argc, char* argv[])
{
#ifdef _XBOX
argc = 1 ;
argv = xboxargv ;
XGetCustomLaunchData() ;
argc = 1;
argv = xboxargv;
XGetCustomLaunchData();
#endif
g_argc = argc;
@@ -881,6 +879,8 @@ int main(int argc, char* argv[])
g_hWndMain = info.window;
#endif
SONGMAN->PreloadSongImages();
/* This initializes objects that change the SDL event mask, and has other
* dependencies on the SDL video subsystem, so it must be initialized after
* DISPLAY and setting the default SDL event mask. */
@@ -903,9 +903,11 @@ int main(int argc, char* argv[])
SONGMAN->UpdateRankingCourses();
#ifdef _XBOX
g_CurrentParams.width = 600 ;
g_CurrentParams.height= 400 ;
DISPLAY->ResolutionChanged() ;
/* XXX: This is a bad way to do this. Instead, add an "XBOX" entry to
* g_VideoCardDefaults (and make sure the name shows up, so it matches). */
g_CurrentParams.width = 600;
g_CurrentParams.height= 400;
DISPLAY->ResolutionChanged();
#endif
/* Run the main loop. */