simplify
This commit is contained in:
@@ -42,7 +42,7 @@ UnlockSystem::UnlockSystem()
|
|||||||
{
|
{
|
||||||
UNLOCKMAN = this;
|
UNLOCKMAN = this;
|
||||||
|
|
||||||
LoadFromDATFile();
|
Load();
|
||||||
|
|
||||||
memset( m_fScores, 0, sizeof(m_fScores) );
|
memset( m_fScores, 0, sizeof(m_fScores) );
|
||||||
|
|
||||||
@@ -153,9 +153,31 @@ bool UnlockEntry::IsLocked() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UnlockSystem::LoadFromDATFile()
|
static const char *g_ShortUnlockNames[NUM_UNLOCK_TYPES] =
|
||||||
{
|
{
|
||||||
LOG->Trace( "UnlockSystem::LoadFromDATFile()" );
|
"AP",
|
||||||
|
"DP",
|
||||||
|
"SP",
|
||||||
|
"EC",
|
||||||
|
"EF",
|
||||||
|
"!!",
|
||||||
|
"CS"
|
||||||
|
};
|
||||||
|
|
||||||
|
static UnlockType StringToUnlockType( const CString &s )
|
||||||
|
{
|
||||||
|
for( int i = 0; i < NUM_UNLOCK_TYPES; ++i )
|
||||||
|
if( g_ShortUnlockNames[i] == s )
|
||||||
|
return (UnlockType) i;
|
||||||
|
return UNLOCK_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UnlockSystem::Load()
|
||||||
|
{
|
||||||
|
LOG->Trace( "UnlockSystem::Load()" );
|
||||||
|
|
||||||
|
if( !IsAFile(UNLOCKS_PATH) )
|
||||||
|
return false;
|
||||||
|
|
||||||
MsdFile msd;
|
MsdFile msd;
|
||||||
if( !msd.ReadFile( UNLOCKS_PATH ) )
|
if( !msd.ReadFile( UNLOCKS_PATH ) )
|
||||||
@@ -164,7 +186,7 @@ bool UnlockSystem::LoadFromDATFile()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned i, j;
|
unsigned i;
|
||||||
|
|
||||||
for( i=0; i<msd.GetNumValues(); i++ )
|
for( i=0; i<msd.GetNumValues(); i++ )
|
||||||
{
|
{
|
||||||
@@ -198,37 +220,27 @@ bool UnlockSystem::LoadFromDATFile()
|
|||||||
CStringArray UnlockTypes;
|
CStringArray UnlockTypes;
|
||||||
split( sParams[2], ",", UnlockTypes );
|
split( sParams[2], ",", UnlockTypes );
|
||||||
|
|
||||||
for( j=0; j<UnlockTypes.size(); ++j )
|
for( unsigned j=0; j<UnlockTypes.size(); ++j )
|
||||||
{
|
{
|
||||||
CStringArray readparam;
|
CStringArray readparam;
|
||||||
|
|
||||||
split(UnlockTypes[j], "=", readparam);
|
split( UnlockTypes[j], "=", readparam );
|
||||||
CString unlock_type = readparam[0];
|
const CString &unlock_type = readparam[0];
|
||||||
float datavalue = (float) atof(readparam[1]);
|
|
||||||
|
|
||||||
LOG->Trace("UnlockTypes line: %s", UnlockTypes[j].c_str() );
|
LOG->Trace("UnlockTypes line: %s", UnlockTypes[j].c_str() );
|
||||||
LOG->Trace("Unlock info: %s %f", unlock_type.c_str(), datavalue);
|
|
||||||
|
|
||||||
if( unlock_type == "AP" )
|
const float val = (float) atof( readparam[1] );
|
||||||
current.m_fRequired[UNLOCK_ARCADE_POINTS] = datavalue;
|
LOG->Trace("Unlock info: %s %f", unlock_type.c_str(), val);
|
||||||
if( unlock_type == "DP" )
|
|
||||||
current.m_fRequired[UNLOCK_DANCE_POINTS] = datavalue;
|
const UnlockType ut = StringToUnlockType( unlock_type );
|
||||||
if( unlock_type == "SP" )
|
if( ut != UNLOCK_INVALID )
|
||||||
current.m_fRequired[UNLOCK_SONG_POINTS] = datavalue;
|
current.m_fRequired[ut] = val;
|
||||||
if( unlock_type == "EC" )
|
|
||||||
current.m_fRequired[UNLOCK_EXTRA_CLEARED] = datavalue;
|
|
||||||
if( unlock_type == "EF" )
|
|
||||||
current.m_fRequired[UNLOCK_EXTRA_CLEARED] = datavalue;
|
|
||||||
if( unlock_type == "!!" )
|
|
||||||
current.m_fRequired[UNLOCK_TOASTY] = datavalue;
|
|
||||||
if( unlock_type == "CS" )
|
|
||||||
current.m_fRequired[UNLOCK_CLEARED] = datavalue;
|
|
||||||
if( unlock_type == "CODE" )
|
if( unlock_type == "CODE" )
|
||||||
current.m_iCode = (int) datavalue;
|
current.m_iCode = (int) val;
|
||||||
if( unlock_type == "RO" )
|
if( unlock_type == "RO" )
|
||||||
{
|
{
|
||||||
m_UnlockedCodes.insert( (int)datavalue );
|
m_UnlockedCodes.insert( (int)val );
|
||||||
m_RouletteCodes.insert( (int)datavalue );
|
m_RouletteCodes.insert( (int)val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,21 +251,18 @@ bool UnlockSystem::LoadFromDATFile()
|
|||||||
|
|
||||||
for(i=0; i < m_SongEntries.size(); i++)
|
for(i=0; i < m_SongEntries.size(); i++)
|
||||||
{
|
{
|
||||||
CString tmp = " ";
|
|
||||||
if (!m_SongEntries[i].IsLocked()) tmp = "un";
|
|
||||||
|
|
||||||
LOG->Trace( "UnlockSystem Entry %s", m_SongEntries[i].m_sSongName.c_str() );
|
LOG->Trace( "UnlockSystem Entry %s", m_SongEntries[i].m_sSongName.c_str() );
|
||||||
if (m_SongEntries[i].m_pSong != NULL)
|
if (m_SongEntries[i].m_pSong != NULL)
|
||||||
LOG->Trace( " Translit %s", m_SongEntries[i].m_pSong->GetTranslitMainTitle().c_str() );
|
LOG->Trace( " Translit %s", m_SongEntries[i].m_pSong->GetTranslitMainTitle().c_str() );
|
||||||
LOG->Trace( " AP %f", m_SongEntries[i].m_fRequired[UNLOCK_ARCADE_POINTS] );
|
for( int j = 0; j < NUM_UNLOCK_TYPES; ++j )
|
||||||
LOG->Trace( " DP %f", m_SongEntries[i].m_fRequired[UNLOCK_DANCE_POINTS] );
|
if( m_SongEntries[i].m_fRequired[j] )
|
||||||
LOG->Trace( " SP %f", m_SongEntries[i].m_fRequired[UNLOCK_SONG_POINTS] );
|
LOG->Trace( " %s %f", g_UnlockNames[j], m_SongEntries[i].m_fRequired[j] );
|
||||||
LOG->Trace( " CS %f", m_SongEntries[i].m_fRequired[UNLOCK_CLEARED] );
|
|
||||||
LOG->Trace( " CODE %i", m_SongEntries[i].m_iCode );
|
LOG->Trace( " CODE %i", m_SongEntries[i].m_iCode );
|
||||||
LOG->Trace( " Status %slocked", tmp.c_str() );
|
LOG->Trace( " Status %s", m_SongEntries[i].IsLocked()? "locked":"unlocked" );
|
||||||
if (m_SongEntries[i].m_pSong)
|
if( m_SongEntries[i].m_pSong )
|
||||||
LOG->Trace( " Found matching song entry" );
|
LOG->Trace( " Found matching song entry" );
|
||||||
if (m_SongEntries[i].m_pCourse)
|
if( m_SongEntries[i].m_pCourse )
|
||||||
LOG->Trace( " Found matching course entry" );
|
LOG->Trace( " Found matching course entry" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ enum UnlockType
|
|||||||
UNLOCK_EXTRA_FAILED,
|
UNLOCK_EXTRA_FAILED,
|
||||||
UNLOCK_TOASTY,
|
UNLOCK_TOASTY,
|
||||||
UNLOCK_CLEARED,
|
UNLOCK_CLEARED,
|
||||||
NUM_UNLOCK_TYPES
|
NUM_UNLOCK_TYPES,
|
||||||
|
UNLOCK_INVALID,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UnlockEntry
|
struct UnlockEntry
|
||||||
@@ -67,9 +68,6 @@ public:
|
|||||||
bool SongIsRoulette( const Song *song );
|
bool SongIsRoulette( const Song *song );
|
||||||
bool CourseIsLocked( const Course *course );
|
bool CourseIsLocked( const Course *course );
|
||||||
|
|
||||||
// executed when program is first executed
|
|
||||||
bool LoadFromDATFile();
|
|
||||||
|
|
||||||
// Gets number of unlocks for title screen
|
// Gets number of unlocks for title screen
|
||||||
int GetNumUnlocks() const;
|
int GetNumUnlocks() const;
|
||||||
|
|
||||||
@@ -97,7 +95,8 @@ public:
|
|||||||
vector<UnlockEntry> m_SongEntries;
|
vector<UnlockEntry> m_SongEntries;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// read and write unlock in values
|
// read and write unlocks
|
||||||
|
bool Load();
|
||||||
bool ReadValues();
|
bool ReadValues();
|
||||||
bool WriteValues() const;
|
bool WriteValues() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user