MusicMod: Added music modification, it currently only works in Windows

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1736 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson
2009-01-03 01:38:44 +00:00
parent 55db229929
commit 264056972d
69 changed files with 5299 additions and 511 deletions

View File

@ -34,6 +34,10 @@ ConfVar::ConfVar( TCHAR * szKey, ConfMode mode )
{
// MessageBox( 0, TEXT( "no const @ ConfVar" ), TEXT( "" ), 0 );
// ---------------------------------------------------------------------------------------
//wprintf("ConfVar::ConfVar(TCHAR) > Got <%s>\n", szKey);
// ---------------------------------------------------------------------------------------
// Init
const int iLen = ( int )_tcslen( szKey );
m_szKey = new TCHAR[ iLen + 1 ];
@ -57,6 +61,10 @@ ConfVar::ConfVar( TCHAR * szKey, ConfMode mode )
////////////////////////////////////////////////////////////////////////////////
ConfVar::ConfVar( const TCHAR * szKey, ConfMode mode )
{
// ---------------------------------------------------------------------------------------
//wprintf("ConfVar::ConfVar(const TCHAR) > Got <%s>\n", szKey);
// ---------------------------------------------------------------------------------------
// Init
m_szKey = ( TCHAR * )szKey;
@ -68,6 +76,11 @@ ConfVar::ConfVar( const TCHAR * szKey, ConfMode mode )
// Register
if( !conf_map ) conf_map = new map<TCHAR *, ConfVar *>;
conf_map->insert( pair<TCHAR *, ConfVar *>( m_szKey, this ) );
// ---------------------------------------------------------------------------------------
//wprintf("ConfVar::ConfVar(const TCHAR) > Insert <%s>\n", ConfVar::m_szKey);
// ---------------------------------------------------------------------------------------
}
@ -82,6 +95,8 @@ ConfVar::~ConfVar()
// =======================================================================================
// The line name is collected in ConfVar, then ConfBool gets the boolean
////////////////////////////////////////////////////////////////////////////////
///
////////////////////////////////////////////////////////////////////////////////
@ -89,11 +104,16 @@ ConfBool::ConfBool( bool * pbData, TCHAR * szKey, ConfMode mode, bool bDefault )
{
// MessageBox( 0, TEXT( "no const @ ConfBool" ), TEXT( "" ), 0 );
// ---------------------------------------------------------------------------------------
wprintf("ConfBool(TCHAR) > Get <%s>\n", szKey);
// ---------------------------------------------------------------------------------------
m_pbData = pbData;
m_bDefault = bDefault;
// *pbData = bDefault;
}
// =======================================================================================
@ -102,6 +122,10 @@ ConfBool::ConfBool( bool * pbData, TCHAR * szKey, ConfMode mode, bool bDefault )
////////////////////////////////////////////////////////////////////////////////
ConfBool::ConfBool( bool * pbData, const TCHAR * szKey, ConfMode mode, bool bDefault ) : ConfVar( szKey, mode )
{
// ---------------------------------------------------------------------------------------
wprintf("ConfBool(TCHAR) > Get <%s>\n", szKey);
// ---------------------------------------------------------------------------------------
m_pbData = pbData;
m_bDefault = bDefault;
@ -115,6 +139,8 @@ ConfBool::ConfBool( bool * pbData, const TCHAR * szKey, ConfMode mode, bool bDef
////////////////////////////////////////////////////////////////////////////////
void ConfBool::Read()
{
wprintf("ConfBool::Read() > Begin <m_bRead:%i> and <szIniPath:%s>\n", m_bRead, szIniPath);
if( m_bRead || !szIniPath ) return;
*m_pbData = ( GetPrivateProfileInt( SECTION, m_szKey, ( int )m_bDefault, szIniPath ) != 0 );
@ -493,22 +519,31 @@ ConfString::ConfString( TCHAR * szData, const TCHAR * szKey, ConfMode mode, TCHA
////////////////////////////////////////////////////////////////////////////////
void ConfString::Read()
{
wprintf( "ConfString::Read() > Begin\n");
if( m_bRead || !szIniPath ) return;
GetPrivateProfileString( SECTION, m_szKey, m_szDefault, m_szData, m_iMaxLen, szIniPath );
wprintf( "ConfString::Read() > GetPrivateProfileString <%s> <%s> <%s>\n", m_szKey, m_szData, szIniPath);
m_bRead = true;
}
// =======================================================================================
// I don't use this
////////////////////////////////////////////////////////////////////////////////
///
////////////////////////////////////////////////////////////////////////////////
void ConfString::Write()
{
/*
WritePrivateProfileString( SECTION, m_szKey, m_szData, szIniPath );
m_bRead = true;
}
*/
}
// =======================================================================================
@ -531,7 +566,9 @@ ConfCurDir::ConfCurDir( TCHAR * szData, const TCHAR * szKey ) : ConfString( szDa
}
// =======================================================================================
// MAJOR FUNCTION: This changes the relative path for the whole application
// =======================================================================================
////////////////////////////////////////////////////////////////////////////////
///
////////////////////////////////////////////////////////////////////////////////
@ -542,9 +579,12 @@ void ConfCurDir::Read()
// MessageBox( 0, m_szData, TEXT( "CurDir" ), 0 );
// Apply
SetCurrentDirectory( m_szData );
}
//SetCurrentDirectory( m_szData );
wprintf("ConfCurDir::Read > End <%s>\n", m_szData);
}
// =======================================================================================
// =======================================================================================
////////////////////////////////////////////////////////////////////////////////
@ -556,6 +596,7 @@ void ConfCurDir::Write()
GetCurrentDirectory( MAX_PATH, m_szData ); // Note: without trailing slash
// MessageBox( 0, m_szData, TEXT( "CurDir" ), 0 );
//wprintf("ConfCurDir::Read <%s>\n", m_szData);
ConfString::Write();
}
@ -565,10 +606,12 @@ void ConfCurDir::Write()
////////////////////////////////////////////////////////////////////////////////
///
////////////////////////////////////////////////////////////////////////////////
void Conf::Init( HINSTANCE hInstance )
void Conf::Init()
{
if( szIniPath ) return;
// =======================================================================================
// Find the right ini file
// Long filename
szIniPath = new TCHAR[ _MAX_PATH ];
@ -578,40 +621,65 @@ void Conf::Init( HINSTANCE hInstance )
TCHAR szDir[ _MAX_DIR ] = TEXT( "" );
GetModuleFileName( hInstance, szFull, _MAX_PATH );
// ---------------------------------------------------------------------------------------
// We place the full path in szFull
//GetModuleFileName( hInstance, szFull, _MAX_PATH );
GetModuleFileName( NULL, szFull, _MAX_PATH ); // No don't use that
// ---------------------------------------------------------------------------------------
_tsplitpath( szFull, szDrive, szDir, NULL, NULL );
// Convert short to long path
GetLongPathName( szDir, szDir, _MAX_DIR );
// ---------------------------------------------------------------------------------------
// We place information about the file in fd
// ---------------------------------------------------------------------------------------
// Convert short to long file
WIN32_FIND_DATA fd;
HANDLE h = FindFirstFile( szFull, &fd );
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// Convert File.exe to File.ini
// ---------------------------------------------------------------------------------------
// Search last dot
TCHAR * szSearch = fd.cFileName + _tcslen( fd.cFileName ) - 1;
while( ( *szSearch != TEXT( '.' ) ) && ( szSearch > fd.cFileName ) )
{
szSearch--;
}
// ---------------------------------------------------------------------------------------
// Replace extension
_tcscpy( szSearch, TEXT( ".ini" ) );
// ---------------------------------------------------------------------------------------
// Copy full filename
_sntprintf( szIniPath, _MAX_PATH, TEXT( "%s%s%s" ), szDrive, szDir, fd.cFileName );
//_sntprintf( szIniPath, _MAX_PATH, TEXT( "%s%s%s" ), szDrive, szDir, fd.cFileName );
_sntprintf( szIniPath, _MAX_PATH, TEXT( "%s%s%s" ), szDrive, szDir, TEXT( "Plainamp.ini" ) );
wprintf("DLL > We got the ini path <%s>\n", szIniPath);
// =======================================================================================
// Read all
// ---------------------------------------------------------------------------------------
// Read all settings in it
// ---------------------------------------------------------------------------------------
// Read all (original comment)
map<TCHAR *, ConfVar *>::iterator iter = conf_map->begin();
// =======================================================================================
// *** Something changes the API relative paths here
while( iter != conf_map->end() )
{
iter->second->Read();
iter++;
iter->second->Read(); // *** This changes the relative path
iter++;
}
// =======================================================================================
// ---------------------------------------------------------------------------------------
}