#BANNER tag for course files
This commit is contained in:
@@ -136,7 +136,7 @@ void Banner::LoadFromSongGroup( RString sSongGroup )
|
|||||||
void Banner::LoadFromCourse( const Course *pCourse ) // NULL means no course
|
void Banner::LoadFromCourse( const Course *pCourse ) // NULL means no course
|
||||||
{
|
{
|
||||||
if( pCourse == NULL ) LoadFallback();
|
if( pCourse == NULL ) LoadFallback();
|
||||||
else if( pCourse->m_sBannerPath != "" ) Load( pCourse->m_sBannerPath );
|
else if( pCourse->GetBannerPath() != "" ) Load( pCourse->GetBannerPath() );
|
||||||
else LoadCourseFallback();
|
else LoadCourseFallback();
|
||||||
|
|
||||||
m_bScrolling = false;
|
m_bScrolling = false;
|
||||||
|
|||||||
@@ -834,9 +834,18 @@ bool Course::CourseHasBestOrWorst() const
|
|||||||
return false;
|
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
|
bool Course::HasBanner() const
|
||||||
{
|
{
|
||||||
return m_sBannerPath != "" && IsAFile(m_sBannerPath);
|
return GetBannerPath() != "" && IsAFile(GetBannerPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Course::UpdateCourseStats( StepsType st )
|
void Course::UpdateCourseStats( StepsType st )
|
||||||
@@ -978,7 +987,7 @@ public:
|
|||||||
LuaHelpers::CreateTableFromArray<Trail*>( v, L );
|
LuaHelpers::CreateTableFromArray<Trail*>( v, L );
|
||||||
return 1;
|
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 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 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; }
|
static int GetEstimatedNumStages( T* p, lua_State *L ) { lua_pushnumber(L, p->GetEstimatedNumStages() ); return 1; }
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ class Course
|
|||||||
public:
|
public:
|
||||||
Course();
|
Course();
|
||||||
|
|
||||||
|
RString GetBannerPath() const;
|
||||||
bool HasBanner() const;
|
bool HasBanner() const;
|
||||||
|
|
||||||
/* If PREFSMAN->m_bShowNative is off, these are the same as GetTranslit* below.
|
/* If PREFSMAN->m_bShowNative is off, these are the same as GetTranslit* below.
|
||||||
|
|||||||
@@ -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 )
|
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;
|
AttackArray attacks;
|
||||||
float fGainSeconds = 0;
|
float fGainSeconds = 0;
|
||||||
for( unsigned i=0; i<msd.GetNumValues(); i++ )
|
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;
|
out.m_bRepeat = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if( 0 == stricmp(sValueName, "BANNER") )
|
||||||
|
{
|
||||||
|
out.m_sBannerPath = sParams[1];
|
||||||
|
}
|
||||||
else if( 0 == stricmp(sValueName, "LIVES") )
|
else if( 0 == stricmp(sValueName, "LIVES") )
|
||||||
{
|
{
|
||||||
out.m_iLives = max( atoi(sParams[1]), 0 );
|
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() );
|
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");
|
static TitleSubst tsub("Courses");
|
||||||
|
|
||||||
TitleFields title;
|
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
|
/* Cache and load the course banner. Only bother doing this if at least one
|
||||||
* song was found in the course. */
|
* song was found in the course. */
|
||||||
if( out.m_sBannerPath != "" && !out.m_vEntries.empty() )
|
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
|
/* Cache each trail RadarValues that's slow to load, so we
|
||||||
* don't have to do it at runtime. */
|
* don't have to do it at runtime. */
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ bool CourseWriterCRS::Write( const Course &course, RageFileBasic &f, bool bSavin
|
|||||||
f.PutLine( "#REPEAT:YES;" );
|
f.PutLine( "#REPEAT:YES;" );
|
||||||
if( course.m_iLives != -1 )
|
if( course.m_iLives != -1 )
|
||||||
f.PutLine( ssprintf("#LIVES:%i;", course.m_iLives) );
|
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() )
|
if( !course.m_setStyles.empty() )
|
||||||
{
|
{
|
||||||
vector<RString> asStyles;
|
vector<RString> asStyles;
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ void FadingBanner::LoadFromCourse( const Course* pCourse )
|
|||||||
|
|
||||||
/* Don't call HasBanner. That'll do disk access and cause the music wheel
|
/* Don't call HasBanner. That'll do disk access and cause the music wheel
|
||||||
* to skip. */
|
* to skip. */
|
||||||
RString sPath = pCourse->m_sBannerPath;
|
RString sPath = pCourse->GetBannerPath();
|
||||||
if( sPath.empty() )
|
if( sPath.empty() )
|
||||||
LoadCourseFallback();
|
LoadCourseFallback();
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1547,7 +1547,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
|||||||
feat.iScore = hs.GetScore();
|
feat.iScore = hs.GetScore();
|
||||||
feat.fPercentDP = hs.GetPercentDP();
|
feat.fPercentDP = hs.GetPercentDP();
|
||||||
if( pCourse->HasBanner() )
|
if( pCourse->HasBanner() )
|
||||||
feat.Banner = pCourse->m_sBannerPath;
|
feat.Banner = pCourse->GetBannerPath();
|
||||||
asFeatsOut.push_back( feat );
|
asFeatsOut.push_back( feat );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1571,7 +1571,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
|
|||||||
feat.iScore = hs.GetScore();
|
feat.iScore = hs.GetScore();
|
||||||
feat.fPercentDP = hs.GetPercentDP();
|
feat.fPercentDP = hs.GetPercentDP();
|
||||||
if( pCourse->HasBanner() )
|
if( pCourse->HasBanner() )
|
||||||
feat.Banner = pCourse->m_sBannerPath;
|
feat.Banner = pCourse->GetBannerPath();
|
||||||
asFeatsOut.push_back( feat );
|
asFeatsOut.push_back( feat );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1218,7 +1218,7 @@ void ScreenSelectMusic::AfterMusicChange()
|
|||||||
m_fSampleStartSeconds = 0;
|
m_fSampleStartSeconds = 0;
|
||||||
m_fSampleLengthSeconds = -1;
|
m_fSampleLengthSeconds = -1;
|
||||||
|
|
||||||
g_sBannerPath = pCourse->m_sBannerPath;
|
g_sBannerPath = pCourse->GetBannerPath();
|
||||||
if( g_sBannerPath.empty() )
|
if( g_sBannerPath.empty() )
|
||||||
m_Banner.LoadFallback();
|
m_Banner.LoadFallback();
|
||||||
|
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ void SongManager::PreloadSongImages()
|
|||||||
if( !courses[i]->HasBanner() )
|
if( !courses[i]->HasBanner() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const RageTextureID ID = Sprite::SongBannerTexture( courses[i]->m_sBannerPath );
|
const RageTextureID ID = Sprite::SongBannerTexture( courses[i]->GetBannerPath() );
|
||||||
preload.Load( ID );
|
preload.Load( ID );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ RString UnlockEntry::GetBannerFile() const
|
|||||||
case UnlockRewardType_Steps:
|
case UnlockRewardType_Steps:
|
||||||
return m_pSong ? m_pSong->GetBannerPath() : "";
|
return m_pSong ? m_pSong->GetBannerPath() : "";
|
||||||
case UnlockRewardType_Course:
|
case UnlockRewardType_Course:
|
||||||
return m_pCourse ? m_pCourse->m_sBannerPath : "";
|
return m_pCourse ? m_pCourse->GetBannerPath() : "";
|
||||||
case UnlockRewardType_Modifier:
|
case UnlockRewardType_Modifier:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user