Allow preloading all song banners.
This commit is contained in:
@@ -17,6 +17,10 @@
|
|||||||
#include "SDL_dither.h"
|
#include "SDL_dither.h"
|
||||||
#include "SDL_image.h"
|
#include "SDL_image.h"
|
||||||
#include "SDL_rotozoom.h"
|
#include "SDL_rotozoom.h"
|
||||||
|
#include "SDL_utils.h"
|
||||||
|
#include "RageDisplay.h"
|
||||||
|
#include "RageTexture.h"
|
||||||
|
#include "RageTextureManager.h"
|
||||||
|
|
||||||
#include "Banner.h"
|
#include "Banner.h"
|
||||||
|
|
||||||
@@ -55,7 +59,7 @@ CString BannerCache::GetBannerCachePath( CString BannerPath )
|
|||||||
|
|
||||||
void BannerCache::LoadBanner( CString BannerPath )
|
void BannerCache::LoadBanner( CString BannerPath )
|
||||||
{
|
{
|
||||||
if( !PREFSMAN->m_bBannerCache || BannerPath == "" )
|
if( PREFSMAN->m_BannerCache != PrefsManager::BNCACHE_LOW_RES || BannerPath == "" )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Load it. */
|
/* Load it. */
|
||||||
@@ -125,11 +129,6 @@ BannerCache::~BannerCache()
|
|||||||
UnloadAllBanners();
|
UnloadAllBanners();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "SDL_utils.h"
|
|
||||||
#include "RageDisplay.h"
|
|
||||||
#include "RageTexture.h"
|
|
||||||
#include "RageTextureManager.h"
|
|
||||||
|
|
||||||
struct BannerTexture: public RageTexture
|
struct BannerTexture: public RageTexture
|
||||||
{
|
{
|
||||||
unsigned m_uTexHandle;
|
unsigned m_uTexHandle;
|
||||||
@@ -397,7 +396,7 @@ void BannerCache::CacheBannerInternal( CString BannerPath )
|
|||||||
const CString CachePath = GetBannerCachePath(BannerPath);
|
const CString CachePath = GetBannerCachePath(BannerPath);
|
||||||
mySDL_SaveSurface( img, CachePath );
|
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 an old image is loaded, free it. */
|
||||||
if( m_BannerPathToImage.find(BannerPath) != m_BannerPathToImage.end() )
|
if( m_BannerPathToImage.find(BannerPath) != m_BannerPathToImage.end() )
|
||||||
|
|||||||
@@ -112,8 +112,13 @@ void FadingBanner::LoadFromCachedBanner( const CString &path )
|
|||||||
/* No matter what we load, ensure we don't fade to a stale path. */
|
/* No matter what we load, ensure we don't fade to a stale path. */
|
||||||
m_sPendingBanner = "";
|
m_sPendingBanner = "";
|
||||||
|
|
||||||
|
RageTextureID ID;
|
||||||
|
if( PREFSMAN->m_BannerCache == PrefsManager::BNCACHE_FULL )
|
||||||
|
ID = Banner::BannerTex( path );
|
||||||
|
else
|
||||||
/* Try to load the low quality version. */
|
/* Try to load the low quality version. */
|
||||||
RageTextureID ID = BANNERCACHE->LoadCachedBanner( path );
|
ID = BANNERCACHE->LoadCachedBanner( path );
|
||||||
|
|
||||||
if( !TEXTUREMAN->IsTextureRegistered(ID) )
|
if( !TEXTUREMAN->IsTextureRegistered(ID) )
|
||||||
{
|
{
|
||||||
/* Oops. We couldn't load a banner quickly. We can load the actual
|
/* Oops. We couldn't load a banner quickly. We can load the actual
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ PrefsManager::PrefsManager()
|
|||||||
m_bDelayedTextureDelete = true;
|
m_bDelayedTextureDelete = true;
|
||||||
m_bTexturePreload = false;
|
m_bTexturePreload = false;
|
||||||
m_bDelayedScreenLoad = false;
|
m_bDelayedScreenLoad = false;
|
||||||
m_bBannerCache = true;
|
m_BannerCache = BNCACHE_LOW_RES;
|
||||||
m_MusicWheelUsesSections = ALWAYS;
|
m_MusicWheelUsesSections = ALWAYS;
|
||||||
m_iMusicWheelSwitchSpeed = 10;
|
m_iMusicWheelSwitchSpeed = 10;
|
||||||
m_bEasterEggs = true;
|
m_bEasterEggs = true;
|
||||||
@@ -283,7 +283,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk()
|
|||||||
ini.GetValue( "Options", "DelayedTextureDelete", m_bDelayedTextureDelete );
|
ini.GetValue( "Options", "DelayedTextureDelete", m_bDelayedTextureDelete );
|
||||||
ini.GetValue( "Options", "TexturePreload", m_bTexturePreload );
|
ini.GetValue( "Options", "TexturePreload", m_bTexturePreload );
|
||||||
ini.GetValue( "Options", "DelayedScreenLoad", m_bDelayedScreenLoad );
|
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", "MusicWheelUsesSections", (int&)m_MusicWheelUsesSections );
|
||||||
ini.GetValue( "Options", "MusicWheelSwitchSpeed", m_iMusicWheelSwitchSpeed );
|
ini.GetValue( "Options", "MusicWheelSwitchSpeed", m_iMusicWheelSwitchSpeed );
|
||||||
ini.GetValue( "Options", "SoundDrivers", m_sSoundDrivers );
|
ini.GetValue( "Options", "SoundDrivers", m_sSoundDrivers );
|
||||||
@@ -445,7 +445,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
|
|||||||
ini.SetValue( "Options", "DelayedTextureDelete", m_bDelayedTextureDelete );
|
ini.SetValue( "Options", "DelayedTextureDelete", m_bDelayedTextureDelete );
|
||||||
ini.SetValue( "Options", "TexturePreload", m_bTexturePreload );
|
ini.SetValue( "Options", "TexturePreload", m_bTexturePreload );
|
||||||
ini.SetValue( "Options", "DelayedScreenLoad", m_bDelayedScreenLoad );
|
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", "MusicWheelUsesSections", m_MusicWheelUsesSections );
|
||||||
ini.SetValue( "Options", "MusicWheelSwitchSpeed", m_iMusicWheelSwitchSpeed );
|
ini.SetValue( "Options", "MusicWheelSwitchSpeed", m_iMusicWheelSwitchSpeed );
|
||||||
ini.SetValue( "Options", "EasterEggs", m_bEasterEggs );
|
ini.SetValue( "Options", "EasterEggs", m_bEasterEggs );
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ public:
|
|||||||
bool m_bDelayedTextureDelete;
|
bool m_bDelayedTextureDelete;
|
||||||
bool m_bTexturePreload;
|
bool m_bTexturePreload;
|
||||||
bool m_bDelayedScreenLoad;
|
bool m_bDelayedScreenLoad;
|
||||||
bool m_bBannerCache;
|
enum BannerCacheMode { BNCACHE_OFF, BNCACHE_LOW_RES, BNCACHE_FULL };
|
||||||
|
BannerCacheMode m_BannerCache;
|
||||||
|
|
||||||
bool m_bOnlyDedicatedMenuButtons;
|
bool m_bOnlyDedicatedMenuButtons;
|
||||||
bool m_bMenuTimer;
|
bool m_bMenuTimer;
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
#include "GameManager.h"
|
#include "GameManager.h"
|
||||||
#include "RageFile.h"
|
#include "RageFile.h"
|
||||||
#include "ProductInfo.h"
|
#include "ProductInfo.h"
|
||||||
|
#include "RageTextureManager.h"
|
||||||
|
#include "Banner.h"
|
||||||
|
|
||||||
SongManager* SONGMAN = NULL; // global and accessable from anywhere in our program
|
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()
|
void SongManager::FreeSongs()
|
||||||
{
|
{
|
||||||
for( unsigned i=0; i<m_pSongs.size(); i++ )
|
for( unsigned i=0; i<m_pSongs.size(); i++ )
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
void FreeCourses();
|
void FreeCourses();
|
||||||
|
|
||||||
void Reload(); // songs, courses, groups - everything.
|
void Reload(); // songs, courses, groups - everything.
|
||||||
|
void PreloadSongImages();
|
||||||
|
|
||||||
|
|
||||||
CString GetGroupBannerPath( CString sGroupName );
|
CString GetGroupBannerPath( CString sGroupName );
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ static void CheckSettings()
|
|||||||
/* Preloaded banners takes about 9k per song. Although it's smaller than the
|
/* 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
|
* actual song data, it still adds up with a lot of songs. Disable it for 64-meg
|
||||||
* systems. */
|
* systems. */
|
||||||
PREFSMAN->m_bBannerCache = !LowMemory;
|
PREFSMAN->m_BannerCache = LowMemory? PrefsManager::BNCACHE_OFF:PrefsManager::BNCACHE_LOW_RES;
|
||||||
|
|
||||||
PREFSMAN->SaveGlobalPrefsToDisk();
|
PREFSMAN->SaveGlobalPrefsToDisk();
|
||||||
#endif
|
#endif
|
||||||
@@ -757,12 +757,10 @@ void SaveGamePrefsToDisk()
|
|||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
char *xboxargv[] = { "d:\\default.xbe" };
|
char *xboxargv[] = { "d:\\default.xbe" };
|
||||||
extern RageDisplay::VideoModeParams g_CurrentParams;
|
extern RageDisplay::VideoModeParams g_CurrentParams;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
argc = 1;
|
argc = 1;
|
||||||
argv = xboxargv;
|
argv = xboxargv;
|
||||||
@@ -881,6 +879,8 @@ int main(int argc, char* argv[])
|
|||||||
g_hWndMain = info.window;
|
g_hWndMain = info.window;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SONGMAN->PreloadSongImages();
|
||||||
|
|
||||||
/* This initializes objects that change the SDL event mask, and has other
|
/* This initializes objects that change the SDL event mask, and has other
|
||||||
* dependencies on the SDL video subsystem, so it must be initialized after
|
* dependencies on the SDL video subsystem, so it must be initialized after
|
||||||
* DISPLAY and setting the default SDL event mask. */
|
* DISPLAY and setting the default SDL event mask. */
|
||||||
@@ -903,6 +903,8 @@ int main(int argc, char* argv[])
|
|||||||
SONGMAN->UpdateRankingCourses();
|
SONGMAN->UpdateRankingCourses();
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
|
/* 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.width = 600;
|
||||||
g_CurrentParams.height= 400;
|
g_CurrentParams.height= 400;
|
||||||
DISPLAY->ResolutionChanged();
|
DISPLAY->ResolutionChanged();
|
||||||
|
|||||||
Reference in New Issue
Block a user