Various bug fixes. See changelog.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "IniFile.h"
|
||||
#include "GameManager.h"
|
||||
#include "GameState.h"
|
||||
|
||||
|
||||
PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our program
|
||||
@@ -21,8 +22,9 @@ PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our pro
|
||||
PrefsManager::PrefsManager()
|
||||
{
|
||||
m_bWindowed = false;
|
||||
m_bHighDetail = true;
|
||||
m_bHighTextureDetail = false;
|
||||
m_iDisplayResolution = 640;
|
||||
m_iTextureResolution = 512;
|
||||
m_iRefreshRate = 60;
|
||||
m_bIgnoreJoyAxes = false;
|
||||
m_bShowFPS = false;
|
||||
m_BackgroundMode = BGMODE_ANIMATIONS;
|
||||
@@ -33,21 +35,16 @@ PrefsManager::PrefsManager()
|
||||
m_bAutoPlay = false;
|
||||
m_fJudgeWindow = 0.18f;
|
||||
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
m_PreferredDifficultyClass[p] = CLASS_EASY;
|
||||
m_SongSortOrder = SORT_GROUP;
|
||||
m_PlayMode = PLAY_MODE_INVALID;
|
||||
m_iCurrentStageIndex = 0;
|
||||
|
||||
ReadPrefsFromDisk();
|
||||
ReadGlobalPrefsFromDisk( true );
|
||||
}
|
||||
|
||||
PrefsManager::~PrefsManager()
|
||||
{
|
||||
SavePrefsToDisk();
|
||||
SaveGlobalPrefsToDisk();
|
||||
SaveGamePrefsToDisk();
|
||||
}
|
||||
|
||||
void PrefsManager::ReadPrefsFromDisk()
|
||||
void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame )
|
||||
{
|
||||
IniFile ini;
|
||||
ini.SetPath( "StepMania.ini" );
|
||||
@@ -55,8 +52,9 @@ void PrefsManager::ReadPrefsFromDisk()
|
||||
return; // could not read config file, load nothing
|
||||
|
||||
ini.GetValueB( "Options", "Windowed", m_bWindowed );
|
||||
ini.GetValueB( "Options", "HighDetail", m_bHighDetail );
|
||||
ini.GetValueB( "Options", "HighTextureDetail", m_bHighTextureDetail );
|
||||
ini.GetValueI( "Options", "DisplayResolution", m_iDisplayResolution );
|
||||
ini.GetValueI( "Options", "TextureResolution", m_iTextureResolution );
|
||||
ini.GetValueI( "Options", "RefreshRate", m_iRefreshRate );
|
||||
ini.GetValueB( "Options", "IgnoreJoyAxes", m_bIgnoreJoyAxes );
|
||||
ini.GetValueB( "Options", "ShowFPS", m_bShowFPS );
|
||||
ini.GetValueI( "Options", "BackgroundMode", (int&)m_BackgroundMode );
|
||||
@@ -67,23 +65,28 @@ void PrefsManager::ReadPrefsFromDisk()
|
||||
ini.GetValueB( "Options", "AutoPlay", m_bAutoPlay );
|
||||
ini.GetValueF( "Options", "JudgeWindow", m_fJudgeWindow );
|
||||
|
||||
ini.GetValue( "Options", "Announcer", m_sAnnouncer );
|
||||
ini.GetValue( "Options", "NoteSkin", m_sNoteSkin );
|
||||
|
||||
CString sAdditionalSongFolders;
|
||||
ini.GetValue( "Options", "SongFolders", sAdditionalSongFolders );
|
||||
split( sAdditionalSongFolders, ",", m_asSongFolders, true );
|
||||
|
||||
if( bSwitchToLastPlayedGame )
|
||||
{
|
||||
Game game;
|
||||
if( ini.GetValueI("Options", "Game", (int&)game) )
|
||||
GAMESTATE->SwitchGame( game );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PrefsManager::SavePrefsToDisk()
|
||||
void PrefsManager::SaveGlobalPrefsToDisk()
|
||||
{
|
||||
IniFile ini;
|
||||
ini.SetPath( "StepMania.ini" );
|
||||
|
||||
ini.SetValueB( "Options", "Windowed", m_bWindowed );
|
||||
ini.SetValueB( "Options", "HighDetail", m_bHighDetail );
|
||||
ini.SetValueB( "Options", "HighTextureDetail", m_bHighTextureDetail );
|
||||
ini.SetValueI( "Options", "DisplayResolution", m_iDisplayResolution );
|
||||
ini.SetValueI( "Options", "TextureResolution", m_iTextureResolution );
|
||||
ini.SetValueI( "Options", "RefreshRate", m_iRefreshRate );
|
||||
ini.SetValueB( "Options", "IgnoreJoyAxes", m_bIgnoreJoyAxes );
|
||||
ini.SetValueB( "Options", "ShowFPS", m_bShowFPS );
|
||||
ini.SetValueI( "Options", "BackgroundMode", m_BackgroundMode);
|
||||
@@ -94,78 +97,48 @@ void PrefsManager::SavePrefsToDisk()
|
||||
ini.SetValueB( "Options", "AutoPlay", m_bAutoPlay );
|
||||
ini.SetValueF( "Options", "JudgeWindow", m_fJudgeWindow );
|
||||
|
||||
ini.SetValue( "Options", "Announcer", m_sAnnouncer );
|
||||
ini.SetValue( "Options", "NoteSkin", m_sNoteSkin );
|
||||
|
||||
ini.SetValue( "Options", "SongFolders", join(",", m_asSongFolders) );
|
||||
|
||||
ini.SetValueI( "Options", "Game", GAMESTATE->GetCurGame() );
|
||||
|
||||
ini.WriteFile();
|
||||
}
|
||||
|
||||
int PrefsManager::GetStageIndex()
|
||||
void PrefsManager::ReadGamePrefsFromDisk()
|
||||
{
|
||||
return m_iCurrentStageIndex;
|
||||
if( !GAMESTATE )
|
||||
return;
|
||||
|
||||
CString sGameName = GAMESTATE->GetCurrentGameDef()->m_szName;
|
||||
IniFile ini;
|
||||
ini.SetPath( sGameName + "Prefs.ini" );
|
||||
if( !ini.ReadFile() )
|
||||
return; // could not read config file, load nothing
|
||||
|
||||
CString sAnnouncer, sTheme, sNoteSkin;
|
||||
|
||||
ini.GetValue( "Options", "Announcer", sAnnouncer );
|
||||
ini.GetValue( "Options", "Theme", sTheme );
|
||||
ini.GetValue( "Options", "NoteSkin", sNoteSkin );
|
||||
|
||||
|
||||
ANNOUNCER->SwitchAnnouncer( sAnnouncer );
|
||||
THEME->SwitchTheme( sTheme );
|
||||
GAMEMAN->SwitchNoteSkin( sNoteSkin );
|
||||
}
|
||||
|
||||
bool PrefsManager::IsFinalStage()
|
||||
void PrefsManager::SaveGamePrefsToDisk()
|
||||
{
|
||||
if( PREFSMAN->m_bEventMode )
|
||||
return false;
|
||||
return m_iCurrentStageIndex == m_iNumArcadeStages-1;
|
||||
if( !GAMESTATE )
|
||||
return;
|
||||
|
||||
CString sGameName = GAMESTATE->GetCurrentGameDef()->m_szName;
|
||||
IniFile ini;
|
||||
ini.SetPath( sGameName + "Prefs.ini" );
|
||||
|
||||
ini.SetValue( "Options", "Announcer", ANNOUNCER->GetCurAnnouncerName() );
|
||||
ini.SetValue( "Options", "Theme", THEME->GetCurThemeName() );
|
||||
ini.SetValue( "Options", "NoteSkin", GAMEMAN->GetCurNoteSkin() );
|
||||
|
||||
ini.WriteFile();
|
||||
}
|
||||
|
||||
bool PrefsManager::IsExtraStage()
|
||||
{
|
||||
if( PREFSMAN->m_bEventMode )
|
||||
return false;
|
||||
return m_iCurrentStageIndex == m_iNumArcadeStages;
|
||||
}
|
||||
|
||||
bool PrefsManager::IsExtraStage2()
|
||||
{
|
||||
if( PREFSMAN->m_bEventMode )
|
||||
return false;
|
||||
return m_iCurrentStageIndex == m_iNumArcadeStages+1;
|
||||
}
|
||||
|
||||
CString PrefsManager::GetStageText()
|
||||
{
|
||||
if( IsFinalStage() )
|
||||
return "Final";
|
||||
else if( IsExtraStage() )
|
||||
return "Extra";
|
||||
else if( IsExtraStage2() )
|
||||
return "Extra 2";
|
||||
|
||||
|
||||
int iStageNo = m_iCurrentStageIndex+1;
|
||||
|
||||
CString sNumberSuffix;
|
||||
if( ( (iStageNo/10) % 10 ) == 1 ) // in the teens (e.g. 19, 213)
|
||||
{
|
||||
sNumberSuffix = "th";
|
||||
}
|
||||
else // not in the teens
|
||||
{
|
||||
const int iLastDigit = iStageNo%10;
|
||||
switch( iLastDigit )
|
||||
{
|
||||
case 1: sNumberSuffix = "st"; break;
|
||||
case 2: sNumberSuffix = "nd"; break;
|
||||
case 3: sNumberSuffix = "rd"; break;
|
||||
default:sNumberSuffix = "th"; break;
|
||||
}
|
||||
}
|
||||
return ssprintf( "%d%s", iStageNo, sNumberSuffix );
|
||||
}
|
||||
|
||||
D3DXCOLOR PrefsManager::GetStageColor()
|
||||
{
|
||||
if( IsFinalStage() )
|
||||
return D3DXCOLOR(1,0.1f,0.1f,1); // red
|
||||
else if( IsExtraStage() || IsExtraStage2() )
|
||||
return D3DXCOLOR(1,1,0.3f,1); // yellow
|
||||
else
|
||||
return D3DXCOLOR(0.3f,1,0.3f,1); // green
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user