tweak credits text

fix memory card profile creation
This commit is contained in:
Chris Danford
2003-11-08 15:49:48 +00:00
parent e1b38458d9
commit 3098d41e7a
5 changed files with 66 additions and 49 deletions
+3
View File
@@ -270,6 +270,9 @@ void ModeChoice::ApplyToAllPlayers() const
void ModeChoice::Apply( PlayerNumber pn ) const void ModeChoice::Apply( PlayerNumber pn ) const
{ {
if( !GAMESTATE->IsHumanPlayer(pn) )
return;
const PlayMode OldPlayMode = GAMESTATE->m_PlayMode; const PlayMode OldPlayMode = GAMESTATE->m_PlayMode;
if( m_game != GAME_INVALID ) if( m_game != GAME_INVALID )
GAMESTATE->m_CurGame = m_game; GAMESTATE->m_CurGame = m_game;
+27 -20
View File
@@ -26,6 +26,7 @@ ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our
#define STEPS_MEM_CARD_DATA_FILE "StepsMemCardData.dat" #define STEPS_MEM_CARD_DATA_FILE "StepsMemCardData.dat"
#define COURSE_MEM_CARD_DATA_FILE "CourseMemCardData.dat" #define COURSE_MEM_CARD_DATA_FILE "CourseMemCardData.dat"
#define NEW_MEM_CARD_NAME "NewCard"
#define NEW_PROFILE_NAME "NewProfile" #define NEW_PROFILE_NAME "NewProfile"
ProfileManager::ProfileManager() ProfileManager::ProfileManager()
@@ -114,13 +115,21 @@ bool ProfileManager::LoadDefaultProfileFromMachine( PlayerNumber pn )
return LoadProfile( pn, sDir, false ); return LoadProfile( pn, sDir, false );
} }
bool ProfileManager::IsMemoryCardInserted( PlayerNumber pn ) CString GetMemCardDir( PlayerNumber pn )
{ {
CString sDir = PREFSMAN->m_sMemoryCardDir[pn]; CString sDir = PREFSMAN->m_sMemoryCardDir[pn];
if( sDir.empty() ) if( sDir.empty() )
return false; return sDir;
if( sDir.Right(1) != SLASH ) if( sDir.Right(1) != SLASH )
sDir += SLASH; sDir += SLASH;
return sDir;
}
bool ProfileManager::IsMemoryCardInserted( PlayerNumber pn )
{
CString sDir = GetMemCardDir( pn );
if( sDir.empty() )
return false;
// //
// Test whether a memory card is available by trying to write a file. // Test whether a memory card is available by trying to write a file.
@@ -141,35 +150,33 @@ bool ProfileManager::IsMemoryCardInserted( PlayerNumber pn )
bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn ) bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
{ {
CString sDir = PREFSMAN->m_sMemoryCardDir[pn]; CString sDir = GetMemCardDir( pn );
if( sDir.empty() ) if( sDir.empty() )
return false; return false;
if( sDir.Right(1) != SLASH )
sDir += SLASH;
m_bUsingMemoryCard[pn] = true; m_bUsingMemoryCard[pn] = true;
bool bResult; bool bResult;
bResult = LoadProfile( pn, sDir, false ); bResult = LoadProfile( pn, sDir, false );
if( bResult ) return bResult;
{
return true;
}
else
{
// silently create memory card data here
bResult = CreateProfile( sDir, NEW_PROFILE_NAME );
return bResult;
}
} }
bool ProfileManager::LoadFirstAvailableProfile( PlayerNumber pn ) bool ProfileManager::LoadFirstAvailableProfile( PlayerNumber pn )
{ {
if( IsMemoryCardInserted(pn) && LoadProfileFromMemoryCard(pn) ) if( LoadProfileFromMemoryCard(pn) )
return true; return true;
else if( LoadDefaultProfileFromMachine(pn) )
CString sDir = GetMemCardDir( pn );
if( !sDir.empty() )
{
CreateProfile( sDir, NEW_MEM_CARD_NAME );
if( LoadProfileFromMemoryCard(pn) )
return true;
}
if( LoadDefaultProfileFromMachine(pn) )
return true; return true;
else
return false; return false;
} }
bool ProfileManager::SaveProfile( PlayerNumber pn ) bool ProfileManager::SaveProfile( PlayerNumber pn )
@@ -240,7 +247,7 @@ bool Profile::SaveToIni( CString sIniPath )
bool ProfileManager::CreateMachineProfile( CString sName ) bool ProfileManager::CreateMachineProfile( CString sName )
{ {
if( sName.empty() ) if( sName.empty() )
sName = NEW_PROFILE_NAME; sName = "Machine";
// //
// Find a free directory name in the profiles directory // Find a free directory name in the profiles directory
+15 -14
View File
@@ -318,20 +318,16 @@ bool CreateDirectories( CString Path )
if( mkdir(curpath, 0755) == 0 ) if( mkdir(curpath, 0755) == 0 )
continue; continue;
if(errno != EEXIST) if(errno == EEXIST)
{ continue; // we expect to see this error
if( LOG )
LOG->Warn("Couldn't create %s: %s", curpath.c_str(), strerror(errno) );
/* When creating a directory that already exists over Samba, Windows is // Log the error, but continue on.
* returning ENOENT instead of EEXIST. Continue if we get that error, but /* When creating a directory that already exists over Samba, Windows is
* log it just in case it was a real ENOENT. (Otherwise, we'll fail to * returning ENOENT instead of EEXIST. */
* create a directory when we could have succeeded.) */ /* On Win32 when Path is only a drive letter (e.g. "i:\"), the result is
if( errno != ENOENT ) * EINVAL. */
return false; if( LOG )
else LOG->Warn("Couldn't create %s: %s", curpath.c_str(), strerror(errno) );
continue;
}
/* Make sure it's a directory. */ /* Make sure it's a directory. */
FlushDirCache(); FlushDirCache();
@@ -339,7 +335,12 @@ bool CreateDirectories( CString Path )
{ {
if( LOG ) if( LOG )
LOG->Warn("Couldn't create %s: path exists and is not a directory", curpath.c_str() ); LOG->Warn("Couldn't create %s: path exists and is not a directory", curpath.c_str() );
return false;
// HACK: IsADirectory doesn't work if Path contains a drive letter.
// So, ignore IsADirectory's result and continue trying to create
// directories anyway. This shouldn't change behavior, but
// is inefficient because we don't bail early on an error.
//return false;
} }
} }
+20 -14
View File
@@ -39,12 +39,14 @@ ScreenManager* SCREENMAN = NULL; // global and accessable from anywhere in our p
#define CREDITS_COLOR THEME->GetMetricC("ScreenSystemLayer","CreditsColor") #define CREDITS_COLOR THEME->GetMetricC("ScreenSystemLayer","CreditsColor")
#define CREDITS_SHADOW_LENGTH THEME->GetMetricF("ScreenSystemLayer","CreditsShadowLength") #define CREDITS_SHADOW_LENGTH THEME->GetMetricF("ScreenSystemLayer","CreditsShadowLength")
#define CREDITS_ZOOM THEME->GetMetricF("ScreenSystemLayer","CreditsZoom") #define CREDITS_ZOOM THEME->GetMetricF("ScreenSystemLayer","CreditsZoom")
#define CREDITS_TEXT_PRESS_START THEME->GetMetric ("ScreenSystemLayer","CreditsTextPressStart") #define PLAYER_INFO_PRESS_START THEME->GetMetric ("ScreenSystemLayer","PlayerInfoPressStart")
#define CREDITS_TEXT_JOINED THEME->GetMetric ("ScreenSystemLayer","CreditsTextJoined") #define PLAYER_INFO_INSERT_CARD THEME->GetMetric ("ScreenSystemLayer","PlayerInfoInsertCard")
#define CREDITS_TEXT_TOO_LATE THEME->GetMetric ("ScreenSystemLayer","CreditsTextTooLate") #define PLAYER_INFO_NO_CARD THEME->GetMetric ("ScreenSystemLayer","PlayerInfoNoCard")
#define CREDITS_TEXT_INSERT_MORE THEME->GetMetric ("ScreenSystemLayer","CreditsTextInsertMore") #define PLAYER_INFO_NOT_PRESENT THEME->GetMetric ("ScreenSystemLayer","PlayerInfoNotPresent")
#define PLAYER_INFO_INSERT_MORE THEME->GetMetric ("ScreenSystemLayer","PlayerInfoInsertMore")
#define CREDITS_TEXT_HOME THEME->GetMetric ("ScreenSystemLayer","CreditsTextHome")
#define CREDITS_TEXT_FREE_PLAY THEME->GetMetric ("ScreenSystemLayer","CreditsTextFreePlay")
#define CREDITS_TEXT_CREDITS THEME->GetMetric ("ScreenSystemLayer","CreditsTextCredits") #define CREDITS_TEXT_CREDITS THEME->GetMetric ("ScreenSystemLayer","CreditsTextCredits")
#define CREDITS_TEXT_FREE THEME->GetMetric ("ScreenSystemLayer","CreditsTextFree")
const int NUM_SKIPS = 5; const int NUM_SKIPS = 5;
@@ -173,7 +175,7 @@ void ScreenSystemLayer::RefreshCreditsMessages()
} }
break; break;
case COIN_FREE: case COIN_FREE:
sCredits = CREDITS_TEXT_FREE; sCredits = CREDITS_TEXT_FREE_PLAY;
break; break;
default: default:
ASSERT(0); ASSERT(0);
@@ -194,24 +196,28 @@ void ScreenSystemLayer::RefreshCreditsMessages()
CString sPlayerInfo; CString sPlayerInfo;
if( GAMESTATE->m_bSideIsJoined[p] ) if( GAMESTATE->m_bSideIsJoined[p] )
{ {
sPlayerInfo = CREDITS_TEXT_JOINED; Profile* pProfile = PROFILEMAN->GetProfile( (PlayerNumber)p );
if( pProfile )
sPlayerInfo = pProfile->m_sName;
else if( GAMESTATE->m_bPlayersCanJoin )
sPlayerInfo = PLAYER_INFO_INSERT_CARD;
else if( GAMESTATE->m_bIsOnSystemMenu )
sPlayerInfo = "";
else
sPlayerInfo = PLAYER_INFO_NO_CARD;
} }
else if( GAMESTATE->m_bPlayersCanJoin ) else if( GAMESTATE->m_bPlayersCanJoin )
{ {
if( PREFSMAN->m_iCoinMode==COIN_PAY && GAMESTATE->m_iCoins<PREFSMAN->m_iCoinsPerCredit ) if( PREFSMAN->m_iCoinMode==COIN_PAY && GAMESTATE->m_iCoins<PREFSMAN->m_iCoinsPerCredit )
sPlayerInfo = CREDITS_TEXT_INSERT_MORE; sPlayerInfo = PLAYER_INFO_INSERT_MORE;
else else
sPlayerInfo = CREDITS_TEXT_PRESS_START; sPlayerInfo = PLAYER_INFO_PRESS_START;
} }
else else
{ {
sPlayerInfo = CREDITS_TEXT_TOO_LATE; sPlayerInfo = PLAYER_INFO_NOT_PRESENT;
} }
Profile* pProfile = PROFILEMAN->GetProfile( (PlayerNumber)p );
if( pProfile )
sPlayerInfo += " " + pProfile->m_sName;
m_textPlayerInfo[p].SetText( sPlayerInfo ); m_textPlayerInfo[p].SetText( sPlayerInfo );
} }
} }
+1 -1
View File
@@ -393,7 +393,7 @@ struct VideoCardDefaults
640,480, 640,480,
16,16,16, 16,16,16,
2048, 2048,
0 // accelerated? 1 // accelerated
}, },
{ {
"GeForce|Radeon", "GeForce|Radeon",