#BANNER tag for course files

This commit is contained in:
Glenn Maynard
2007-05-25 22:26:43 +00:00
parent 5a77e83b8a
commit 7226e5a962
10 changed files with 41 additions and 20 deletions
+1 -1
View File
@@ -136,7 +136,7 @@ void Banner::LoadFromSongGroup( RString sSongGroup )
void Banner::LoadFromCourse( const Course *pCourse ) // NULL means no course
{
if( pCourse == NULL ) LoadFallback();
else if( pCourse->m_sBannerPath != "" ) Load( pCourse->m_sBannerPath );
else if( pCourse->GetBannerPath() != "" ) Load( pCourse->GetBannerPath() );
else LoadCourseFallback();
m_bScrolling = false;
+11 -2
View File
@@ -834,9 +834,18 @@ bool Course::CourseHasBestOrWorst() const
return false;
}
RString Course::GetBannerPath() const
{
if( m_sBannerPath.empty() )
return RString();
if( m_sBannerPath[0] == '/' )
return m_sBannerPath;
return Dirname(m_sPath) + m_sBannerPath;
}
bool Course::HasBanner() const
{
return m_sBannerPath != "" && IsAFile(m_sBannerPath);
return GetBannerPath() != "" && IsAFile(GetBannerPath());
}
void Course::UpdateCourseStats( StepsType st )
@@ -978,7 +987,7 @@ public:
LuaHelpers::CreateTableFromArray<Trail*>( v, L );
return 1;
}
static int GetBannerPath( T* p, lua_State *L ) { if( p->m_sBannerPath.empty() ) return 0; lua_pushstring(L, p->m_sBannerPath ); return 1; }
static int GetBannerPath( T* p, lua_State *L ) { RString s = p->GetBannerPath(); if( s.empty() ) return 0; LuaHelpers::Push(L, s); return 1; }
static int GetGroupName( T* p, lua_State *L ) { lua_pushstring(L, p->m_sGroupName ); return 1; }
static int IsAutogen( T* p, lua_State *L ) { lua_pushboolean(L, p->m_bIsAutogen ); return 1; }
static int GetEstimatedNumStages( T* p, lua_State *L ) { lua_pushnumber(L, p->GetEstimatedNumStages() ); return 1; }
+1
View File
@@ -101,6 +101,7 @@ class Course
public:
Course();
RString GetBannerPath() const;
bool HasBanner() const;
/* If PREFSMAN->m_bShowNative is off, these are the same as GetTranslit* below.
+19 -11
View File
@@ -45,16 +45,6 @@ bool CourseLoaderCRS::LoadFromBuffer( const RString &sPath, const RString &sBuff
bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Course &out, bool bFromCache )
{
const RString sFName = SetExtension( out.m_sPath, "" );
vector<RString> arrayPossibleBanners;
GetDirListing( sFName + "*.png", arrayPossibleBanners, false, true );
GetDirListing( sFName + "*.jpg", arrayPossibleBanners, false, true );
GetDirListing( sFName + "*.bmp", arrayPossibleBanners, false, true );
GetDirListing( sFName + "*.gif", arrayPossibleBanners, false, true );
if( !arrayPossibleBanners.empty() )
out.m_sBannerPath = arrayPossibleBanners[0];
AttackArray attacks;
float fGainSeconds = 0;
for( unsigned i=0; i<msd.GetNumValues(); i++ )
@@ -75,6 +65,10 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
out.m_bRepeat = true;
}
else if( 0 == stricmp(sValueName, "BANNER") )
{
out.m_sBannerPath = sParams[1];
}
else if( 0 == stricmp(sValueName, "LIVES") )
{
out.m_iLives = max( atoi(sParams[1]), 0 );
@@ -296,6 +290,20 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
LOG->UserLog( "Course file", sPath, "contains an unexpected value named \"%s\"", sValueName.c_str() );
}
}
if( out.m_sBannerPath.empty() )
{
const RString sFName = SetExtension( out.m_sPath, "" );
vector<RString> arrayPossibleBanners;
GetDirListing( sFName + "*.png", arrayPossibleBanners, false, false );
GetDirListing( sFName + "*.jpg", arrayPossibleBanners, false, false );
GetDirListing( sFName + "*.bmp", arrayPossibleBanners, false, false );
GetDirListing( sFName + "*.gif", arrayPossibleBanners, false, false );
if( !arrayPossibleBanners.empty() )
out.m_sBannerPath = arrayPossibleBanners[0];
}
static TitleSubst tsub("Courses");
TitleFields title;
@@ -308,7 +316,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
/* Cache and load the course banner. Only bother doing this if at least one
* song was found in the course. */
if( out.m_sBannerPath != "" && !out.m_vEntries.empty() )
BANNERCACHE->CacheBanner( out.m_sBannerPath );
BANNERCACHE->CacheBanner( out.GetBannerPath() );
/* Cache each trail RadarValues that's slow to load, so we
* don't have to do it at runtime. */
+3
View File
@@ -44,6 +44,9 @@ bool CourseWriterCRS::Write( const Course &course, RageFileBasic &f, bool bSavin
f.PutLine( "#REPEAT:YES;" );
if( course.m_iLives != -1 )
f.PutLine( ssprintf("#LIVES:%i;", course.m_iLives) );
if( !course.m_sBannerPath.empty() )
f.PutLine( ssprintf("#BANNER:%s;", course.m_sBannerPath.c_str()) );
if( !course.m_setStyles.empty() )
{
vector<RString> asStyles;
+1 -1
View File
@@ -195,7 +195,7 @@ void FadingBanner::LoadFromCourse( const Course* pCourse )
/* Don't call HasBanner. That'll do disk access and cause the music wheel
* to skip. */
RString sPath = pCourse->m_sBannerPath;
RString sPath = pCourse->GetBannerPath();
if( sPath.empty() )
LoadCourseFallback();
else
+2 -2
View File
@@ -1547,7 +1547,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
feat.iScore = hs.GetScore();
feat.fPercentDP = hs.GetPercentDP();
if( pCourse->HasBanner() )
feat.Banner = pCourse->m_sBannerPath;
feat.Banner = pCourse->GetBannerPath();
asFeatsOut.push_back( feat );
}
}
@@ -1571,7 +1571,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
feat.iScore = hs.GetScore();
feat.fPercentDP = hs.GetPercentDP();
if( pCourse->HasBanner() )
feat.Banner = pCourse->m_sBannerPath;
feat.Banner = pCourse->GetBannerPath();
asFeatsOut.push_back( feat );
}
}
+1 -1
View File
@@ -1218,7 +1218,7 @@ void ScreenSelectMusic::AfterMusicChange()
m_fSampleStartSeconds = 0;
m_fSampleLengthSeconds = -1;
g_sBannerPath = pCourse->m_sBannerPath;
g_sBannerPath = pCourse->GetBannerPath();
if( g_sBannerPath.empty() )
m_Banner.LoadFallback();
+1 -1
View File
@@ -324,7 +324,7 @@ void SongManager::PreloadSongImages()
if( !courses[i]->HasBanner() )
continue;
const RageTextureID ID = Sprite::SongBannerTexture( courses[i]->m_sBannerPath );
const RageTextureID ID = Sprite::SongBannerTexture( courses[i]->GetBannerPath() );
preload.Load( ID );
}
+1 -1
View File
@@ -367,7 +367,7 @@ RString UnlockEntry::GetBannerFile() const
case UnlockRewardType_Steps:
return m_pSong ? m_pSong->GetBannerPath() : "";
case UnlockRewardType_Course:
return m_pCourse ? m_pCourse->m_sBannerPath : "";
return m_pCourse ? m_pCourse->GetBannerPath() : "";
case UnlockRewardType_Modifier:
return "";
}