Added NoteSkin metrics to accomodate Prex NoteSkin

This commit is contained in:
Chris Danford
2002-09-17 23:02:37 +00:00
parent 94e9475440
commit 44baba9fd3
13 changed files with 276 additions and 361 deletions
-149
View File
@@ -21,155 +21,6 @@
#include "PrefsManager.h"
const CString NOTESKIN_DIR = "NoteSkins\\";
CString GameDef::ElementToGraphicSuffix( const SkinElement gbg ) const
{
CString sAssetPath; // fill this in below
switch( gbg )
{
case GRAPHIC_TAP_PARTS: sAssetPath = "tap parts"; break;
case GRAPHIC_HOLD_PARTS: sAssetPath = "hold parts"; break;
case GRAPHIC_RECEPTOR: sAssetPath = "receptor"; break;
case GRAPHIC_HOLD_EXPLOSION: sAssetPath = "hold explosion"; break;
case GRAPHIC_TAP_EXPLOSION_BRIGHT: sAssetPath = "tap explosion bright"; break;
case GRAPHIC_TAP_EXPLOSION_DIM: sAssetPath = "tap explosion dim"; break;
default:
ASSERT(0); // invalid SkinElement
}
return sAssetPath;
}
CString GameDef::GetPathToGraphic( const CString sSkinName, const CString sButtonName, const SkinElement gbg ) const
{
const CString sSkinDir = NOTESKIN_DIR + ssprintf("%s\\%s\\", m_szName, sSkinName);
const CString sGraphicSuffix = ElementToGraphicSuffix( gbg );
CStringArray arrayPossibleFileNames; // fill this with the possible files
GetDirListing( ssprintf("%s%s %s*.sprite", sSkinDir, sButtonName, sGraphicSuffix), arrayPossibleFileNames );
GetDirListing( ssprintf("%s%s %s*.png", sSkinDir, sButtonName, sGraphicSuffix), arrayPossibleFileNames );
GetDirListing( ssprintf("%s%s %s*.jpg", sSkinDir, sButtonName, sGraphicSuffix), arrayPossibleFileNames );
GetDirListing( ssprintf("%s%s %s*.bmp", sSkinDir, sButtonName, sGraphicSuffix), arrayPossibleFileNames );
if( arrayPossibleFileNames.GetSize() > 0 )
return sSkinDir + arrayPossibleFileNames[0];
ASSERT(0);
throw RageException( "The game button graphic '%s%s %s' is missing.", sSkinDir, sButtonName, sGraphicSuffix );
}
void GameDef::GetTapTweenColors( const CString sSkinName, const CString sButtonName, CArray<D3DXCOLOR,D3DXCOLOR> &aTapColorsOut ) const
{
const CString sSkinDir = NOTESKIN_DIR + ssprintf("%s\\%s\\", m_szName, sSkinName);
const CString sColorsFilePath = sSkinDir + sButtonName + " Tap.colors";
FILE* fp = fopen( sColorsFilePath, "r" );
ASSERT( fp != NULL );
if( fp == NULL )
{
ASSERT(0);
aTapColorsOut.Add( D3DXCOLOR(1,1,1,1) );
LOG->Warn( "Couldn't open .colors file '%s'", sColorsFilePath );
return;
}
bool bSuccess;
do
{
D3DXCOLOR color;
int retval = fscanf( fp, "%f,%f,%f,%f\n", &color.r, &color.g, &color.b, &color.a );
bSuccess = retval == 4;
if( bSuccess )
aTapColorsOut.Add( color );
} while( bSuccess );
if( aTapColorsOut.GetSize() == 0 )
aTapColorsOut.Add( D3DXCOLOR(1,1,1,1) );
fclose( fp );
return;
}
void GameDef::GetHoldTweenColors( const CString sSkinName, const CString sButtonName, CArray<D3DXCOLOR,D3DXCOLOR> &aHoldColorsOut ) const
{
const CString sSkinDir = NOTESKIN_DIR + ssprintf("%s\\%s\\", m_szName, sSkinName);
const CString sColorsFilePath = sSkinDir + sButtonName + " Hold.colors";
FILE* fp = fopen( sColorsFilePath, "r" );
ASSERT( fp != NULL );
if( fp == NULL )
{
ASSERT(0);
aHoldColorsOut.Add( D3DXCOLOR(1,1,1,1) );
LOG->Warn( "Couldn't open .colors file '%s'", sColorsFilePath );
return;
}
bool bSuccess;
do
{
D3DXCOLOR color;
int retval = fscanf( fp, "%f,%f,%f,%f\n", &color.r, &color.g, &color.b, &color.a );
bSuccess = retval == 4;
if( bSuccess )
aHoldColorsOut.Add( color );
} while( bSuccess );
fclose( fp );
return;
}
void GameDef::GetSkinNames( CStringArray &AddTo ) const
{
CString sBaseSkinFolder = NOTESKIN_DIR + CString(m_szName) + "\\";
GetDirListing( sBaseSkinFolder + "*.*", AddTo, true );
// strip out "CVS"
for( int i=AddTo.GetSize()-1; i>=0; i-- )
if( 0 == stricmp("cvs", AddTo[i]) )
AddTo.RemoveAt( i );
}
bool GameDef::HasASkinNamed( CString sSkin ) const
{
CStringArray asSkinNames;
GetSkinNames( asSkinNames );
for( int i=0; i<asSkinNames.GetSize(); i++ )
if( asSkinNames[i] == sSkin )
return true;
return false;
}
void GameDef::AssertSkinsAreComplete() const
{
CStringArray asSkinNames;
GetSkinNames( asSkinNames );
for( int i=0; i<asSkinNames.GetSize(); i++ )
AssertSkinIsComplete( asSkinNames[i] );
}
void GameDef::AssertSkinIsComplete( CString sSkin ) const
{
CString sGameSkinFolder = NOTESKIN_DIR + sSkin + "\\";
for( int j=0; j<NUM_GAME_BUTTON_GRAPHICS; j++ )
{
SkinElement gbg = (SkinElement)j;
CString sButtonName = m_szButtonNames[j];
CString sPathToGraphic = GetPathToGraphic( sSkin, sButtonName, gbg );
if( !DoesFileExist(sPathToGraphic) )
throw RageException( "Game button graphic at %s is missing.", sPathToGraphic );
}
}
MenuInput GameDef::GameInputToMenuInput( GameInput GameI ) const
{