2002-04-16 17:31:00 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: GameDef
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2002-04-16 17:31:00 +00:00
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "GameDef.h"
|
2002-05-01 19:14:55 +00:00
|
|
|
#include "RageLog.h"
|
2002-04-16 17:31:00 +00:00
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "ErrorCatcher/ErrorCatcher.h"
|
2002-04-28 20:42:32 +00:00
|
|
|
#include "IniFile.h"
|
|
|
|
|
#include "StyleDef.h"
|
|
|
|
|
|
|
|
|
|
|
2002-04-16 17:31:00 +00:00
|
|
|
CString GameDef::ElementToGraphicSuffix( const GameButtonGraphic gbg )
|
|
|
|
|
{
|
|
|
|
|
CString sAssetPath; // fill this in below
|
|
|
|
|
|
|
|
|
|
switch( gbg )
|
|
|
|
|
{
|
|
|
|
|
case GRAPHIC_NOTE_COLOR_PART: sAssetPath = "note color part"; break;
|
|
|
|
|
case GRAPHIC_NOTE_GRAY_PART: sAssetPath = "note gray part"; 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:
|
|
|
|
|
FatalError( ssprintf("Unhandled StyleElement %d", gbg) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sAssetPath;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-28 20:42:32 +00:00
|
|
|
CString GameDef::GetPathToGraphic( const CString sSkinName, const int iInstrumentButton, const GameButtonGraphic gbg )
|
2002-04-16 17:31:00 +00:00
|
|
|
{
|
2002-05-27 08:23:27 +00:00
|
|
|
const CString sSkinDir = ssprintf("Skins\\%s\\%s\\", m_szName, sSkinName);
|
|
|
|
|
const CString sButtonName = m_szButtonNames[ iInstrumentButton ];
|
2002-04-16 17:31:00 +00:00
|
|
|
const CString sGraphicSuffix = ElementToGraphicSuffix( gbg );
|
|
|
|
|
|
|
|
|
|
CStringArray arrayPossibleFileNames; // fill this with the possible files
|
|
|
|
|
|
2002-04-28 20:42:32 +00:00
|
|
|
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 );
|
2002-04-16 17:31:00 +00:00
|
|
|
|
|
|
|
|
if( arrayPossibleFileNames.GetSize() > 0 )
|
2002-04-28 20:42:32 +00:00
|
|
|
return sSkinDir + arrayPossibleFileNames[0];
|
2002-04-16 17:31:00 +00:00
|
|
|
|
2002-04-28 20:42:32 +00:00
|
|
|
FatalError( "The game button graphic '%s%s %s' is missing.", sSkinDir, sButtonName, sGraphicSuffix );
|
2002-04-16 17:31:00 +00:00
|
|
|
return "";
|
|
|
|
|
}
|
2002-05-19 01:59:48 +00:00
|
|
|
|
|
|
|
|
void GameDef::GetTweenColors( const CString sSkinName, const int iInstrumentButton, CArray<D3DXCOLOR,D3DXCOLOR> &arrayTweenColors )
|
|
|
|
|
{
|
2002-05-27 08:23:27 +00:00
|
|
|
const CString sSkinDir = ssprintf("Skins\\%s\\%s\\", m_szName, sSkinName);
|
|
|
|
|
const CString sButtonName = m_szButtonNames[ iInstrumentButton ];
|
2002-05-19 01:59:48 +00:00
|
|
|
|
|
|
|
|
const CString sColorsFilePath = sSkinDir + sButtonName + ".colors";
|
|
|
|
|
|
|
|
|
|
FILE* file = fopen( sColorsFilePath, "r" );
|
|
|
|
|
ASSERT( file != NULL );
|
|
|
|
|
if( file == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool bSuccess;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
D3DXCOLOR color;
|
|
|
|
|
int retval = fscanf( file, "%f,%f,%f,%f\n", &color.r, &color.g, &color.b, &color.a );
|
|
|
|
|
bSuccess = retval == 4;
|
|
|
|
|
if( bSuccess )
|
|
|
|
|
arrayTweenColors.Add( color );
|
|
|
|
|
} while( bSuccess );
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-27 08:23:27 +00:00
|
|
|
void GameDef::GetSkinNames( CStringArray &AddTo )
|
|
|
|
|
{
|
|
|
|
|
CString sBaseSkinFolder = "Skins\\" + CString(m_szName) + "\\";
|
|
|
|
|
GetDirListing( sBaseSkinFolder + "*.*", AddTo, true );
|
2002-05-27 18:36:01 +00:00
|
|
|
|
|
|
|
|
// strip out "CVS"
|
|
|
|
|
for( int i=AddTo.GetSize()-1; i>=0; i-- )
|
|
|
|
|
if( 0 == stricmp("cvs", AddTo[i]) )
|
|
|
|
|
AddTo.RemoveAt( i );
|
|
|
|
|
|
2002-05-27 08:23:27 +00:00
|
|
|
if( AddTo.GetSize() == 0 )
|
|
|
|
|
FatalError( "The folder '%s' must contain at least one skin.", sBaseSkinFolder );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GameDef::HasASkinNamed( CString sSkin )
|
|
|
|
|
{
|
|
|
|
|
CStringArray asSkinNames;
|
|
|
|
|
GetSkinNames( asSkinNames );
|
|
|
|
|
|
|
|
|
|
for( int i=0; i<asSkinNames.GetSize(); i++ )
|
|
|
|
|
if( asSkinNames[i] == sSkin )
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GameDef::AssertSkinsAreComplete()
|
|
|
|
|
{
|
|
|
|
|
CStringArray asSkinNames;
|
|
|
|
|
GetSkinNames( asSkinNames );
|
|
|
|
|
|
|
|
|
|
for( int i=0; i<asSkinNames.GetSize(); i++ )
|
|
|
|
|
{
|
|
|
|
|
CString sSkin = asSkinNames[i];
|
|
|
|
|
CString sGameSkinFolder = "Skins\\" + sSkin + "\\";
|
|
|
|
|
|
|
|
|
|
for( int i=0; i<NUM_GAME_BUTTON_GRAPHICS; i++ )
|
|
|
|
|
{
|
|
|
|
|
GameButtonGraphic gbg = (GameButtonGraphic)i;
|
|
|
|
|
CString sPathToGraphic = GetPathToGraphic( sSkin, INSTRUMENT_1, gbg );
|
|
|
|
|
if( !DoesFileExist(sPathToGraphic) )
|
|
|
|
|
FatalError( "Game button graphic at %s is missing.", sPathToGraphic );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|