2.50 checkin

This commit is contained in:
Chris Danford
2002-04-16 17:31:00 +00:00
parent 6b925217b7
commit 78f3e80118
135 changed files with 4566 additions and 1725 deletions
+25 -310
View File
@@ -5,7 +5,7 @@
Desc: See Header.
Copyright (c) 2001-2002 by the names listed below. All rights reserved.
Copyright (c) 2001-2002 by the persons listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
@@ -25,8 +25,10 @@ PrefsManager::PrefsManager()
m_SongSortOrder = SORT_GROUP;
m_iCurrentStage = 1;
for( int p=0; p<NUM_PLAYERS; p++ )
m_PreferredDifficultyClass[p] = CLASS_EASY;
ReadPrefsFromDisk();
SetHardCodedButtons();
}
@@ -43,36 +45,12 @@ void PrefsManager::ReadPrefsFromDisk()
ini.SetPath( "StepMania.ini" );
if( !ini.ReadFile() ) {
return; // load nothing
//HELPER.FatalError( "could not read config file" );
//FatalError( "could not read config file" );
}
CMapStringToString* pKey = ini.GetKeyPointer("Input");
CMapStringToString* pKey;
CString name_string, value_string;
if( pKey != NULL )
{
for( POSITION pos = pKey->GetStartPosition(); pos != NULL; )
{
pKey->GetNextAssoc( pos, name_string, value_string );
PadInput pi;
pi.fromString(name_string);
CStringArray sDeviceInputStrings;
split( value_string, ",", sDeviceInputStrings, false );
for( int i=0; i<sDeviceInputStrings.GetSize() && i<NUM_PAD_TO_DEVICE_SLOTS; i++ )
{
DeviceInput di;
di.fromString( sDeviceInputStrings[i] );
if( !di.IsBlank() )
SetInputMap( di, pi, i );
}
}
}
this->SetHardCodedButtons();
pKey = ini.GetKeyPointer( "GameOptions" );
if( pKey )
@@ -97,6 +75,15 @@ void PrefsManager::ReadPrefsFromDisk()
pKey->GetNextAssoc( pos, name_string, value_string );
if( name_string == "Windowed" ) m_GraphicOptions.m_bWindowed = ( value_string == "1" );
if( name_string == "Profile" )
{
if( value_string == "super low" ) m_GraphicOptions.m_Profile = PROFILE_SUPER_LOW;
else if( value_string == "low" ) m_GraphicOptions.m_Profile = PROFILE_LOW;
else if( value_string == "medium" ) m_GraphicOptions.m_Profile = PROFILE_MEDIUM;
else if( value_string == "high" ) m_GraphicOptions.m_Profile = PROFILE_HIGH;
else if( value_string == "custom" ) m_GraphicOptions.m_Profile = PROFILE_CUSTOM;
else m_GraphicOptions.m_Profile = PROFILE_MEDIUM;
}
if( name_string == "Resolution" ) m_GraphicOptions.m_iResolution = atoi( value_string );
if( name_string == "MaxTextureSize" ) m_GraphicOptions.m_iMaxTextureSize = atoi( value_string );
if( name_string == "DisplayColor" ) m_GraphicOptions.m_iDisplayColor = atoi( value_string );
@@ -117,24 +104,17 @@ void PrefsManager::SavePrefsToDisk()
// ini.ReadFile(); // don't read the file so that we overwrite everything there
// iterate over our input map and write all mappings to the ini file
for( int i=0; i<NUM_PADS; i++ )
{
for( int j=0; j<NUM_PAD_BUTTONS; j++ )
{
CString sNameString, sValueString;
PadInput pi( (PadNumber)i, (PadButton)j );
sNameString = pi.toString();
sValueString = ssprintf( "%s,%s,%s",
m_PItoDI[i][j][0].toString(), m_PItoDI[i][j][1].toString(), m_PItoDI[i][j][2].toString() );
ini.SetValue( "Input", sNameString, sValueString );
}
}
// save the GameOptions
ini.SetValue( "GraphicOptions", "Windowed", m_GraphicOptions.m_bWindowed ? "1":"0" );
switch( m_GraphicOptions.m_Profile )
{
case PROFILE_SUPER_LOW: ini.SetValue( "GraphicOptions", "Profile", "super low" ); break;
case PROFILE_LOW: ini.SetValue( "GraphicOptions", "Profile", "low" ); break;
case PROFILE_MEDIUM: ini.SetValue( "GraphicOptions", "Profile", "medium" ); break;
case PROFILE_HIGH: ini.SetValue( "GraphicOptions", "Profile", "high" ); break;
case PROFILE_CUSTOM: ini.SetValue( "GraphicOptions", "Profile", "custom" ); break;
default: ASSERT( false );
}
ini.SetValue( "GraphicOptions", "Resolution", ssprintf("%d", m_GraphicOptions.m_iResolution) );
ini.SetValue( "GraphicOptions", "MaxTextureSize", ssprintf("%d", m_GraphicOptions.m_iMaxTextureSize) );
ini.SetValue( "GraphicOptions", "DisplayColor", ssprintf("%d", m_GraphicOptions.m_iDisplayColor) );
@@ -156,269 +136,6 @@ void PrefsManager::SavePrefsToDisk()
}
///////////////////////////////////////
// Input mapping stuff
///////////////////////////////////////
void PrefsManager::SetInputMap( DeviceInput di, PadInput pi, int iSlotIndex, bool bOverrideHardCoded )
{
if( IsAHardCodedDeviceInput(di) && !bOverrideHardCoded )
return; // don't allow hard coded inputs to be overwritten
// remove the old input
ClearFromInputMap( di );
ClearFromInputMap( pi, iSlotIndex );
m_PItoDI[pi.pad_no][pi.button][iSlotIndex] = di;
UpdateTempDItoPI();
}
void PrefsManager::ClearFromInputMap( DeviceInput di )
{
// search for where this di maps to
for( int p=0; p<NUM_PADS; p++ )
{
for( int b=0; b<NUM_PAD_BUTTONS; b++ )
{
for( int s=0; s<NUM_PAD_TO_DEVICE_SLOTS; s++ )
{
if( m_PItoDI[p][b][s] == di )
m_PItoDI[p][b][s].MakeBlank();
}
}
}
UpdateTempDItoPI();
}
void PrefsManager::ClearFromInputMap( PadInput pi, int iSlotIndex )
{
if( pi.IsBlank() )
return;
m_PItoDI[pi.pad_no][pi.button][iSlotIndex].MakeBlank();
UpdateTempDItoPI();
}
void PrefsManager::UpdateTempDItoPI()
{
// clear out m_tempDItoPI
for( int d=0; d<NUM_INPUT_DEVICES; d++ )
{
for( int b=0; b<NUM_DEVICE_BUTTONS; b++ )
{
m_tempDItoPI[d][b].MakeBlank();
}
}
// repopulate m_tempDItoPI
for( int p=0; p<NUM_PADS; p++ )
{
for( int b=0; b<NUM_PAD_BUTTONS; b++ )
{
for( int s=0; s<NUM_PAD_TO_DEVICE_SLOTS; s++ )
{
PadInput PadI( (PadNumber)p, (PadButton)b );
DeviceInput DeviceI = m_PItoDI[p][b][s];
if( DeviceI.IsBlank() )
continue;
m_tempDItoPI[DeviceI.device][DeviceI.button] = PadI;
}
}
}
}
const PadInput g_HardCodedPadInputs[] = {
PadInput(PAD_1,BUTTON_LEFT),
PadInput(PAD_1,BUTTON_RIGHT),
PadInput(PAD_1,BUTTON_UP),
PadInput(PAD_1,BUTTON_DOWN),
PadInput(PAD_1,BUTTON_BACK),
PadInput(PAD_1,BUTTON_NEXT),
};
const int NUM_HARD_CODED_INPUTS = sizeof(g_HardCodedPadInputs) / sizeof(PadInput);
const DeviceInput g_HardCodedDeviceInputs[NUM_HARD_CODED_INPUTS] = {
DeviceInput(DEVICE_KEYBOARD,DIK_LEFT),
DeviceInput(DEVICE_KEYBOARD,DIK_RIGHT),
DeviceInput(DEVICE_KEYBOARD,DIK_UP),
DeviceInput(DEVICE_KEYBOARD,DIK_DOWN),
DeviceInput(DEVICE_KEYBOARD,DIK_ESCAPE),
DeviceInput(DEVICE_KEYBOARD,DIK_RETURN),
};
void PrefsManager::SetHardCodedButtons()
{
for( int i=0; i<NUM_HARD_CODED_INPUTS; i++ )
{
SetInputMap( g_HardCodedDeviceInputs[i], g_HardCodedPadInputs[i], NUM_PAD_TO_DEVICE_SLOTS-1, true ); // always go in the last slot
}
}
bool PrefsManager::IsAHardCodedDeviceInput( DeviceInput di )
{
for( int i=0; i<NUM_HARD_CODED_INPUTS; i++ )
{
if( di == g_HardCodedDeviceInputs[i] )
return true;
}
return false;
}
bool PrefsManager::DeviceToPad( DeviceInput di, PadInput& pi ) // return true if there is a mapping from device to pad
{
pi = m_tempDItoPI[di.device][di.button];
return pi.pad_no != PAD_NONE;
}
bool PrefsManager::PadToDevice( PadInput pi, int iSoltNum, DeviceInput& di ) // return true if there is a mapping from pad to device
{
di = m_PItoDI[pi.pad_no][pi.button][iSoltNum];
return di.device != DEVICE_NONE;
}
void PrefsManager::PadToPlayer( PadInput PadI, PlayerInput &PlayerI )
{
PlayerI.player_no = PLAYER_NONE;
PlayerI.note = NOTE_NONE;
switch( GAME->m_DanceStyle )
{
case STYLE_SINGLE:
case STYLE_SOLO:
if( PadI.pad_no == PAD_1 )
PlayerI.player_no = PLAYER_1;
else
PlayerI.player_no = PLAYER_NONE;
if ( PadI.button == BUTTON_LEFT ) PlayerI.note |= NOTE_PAD1_LEFT;
if ( PadI.button == BUTTON_UPLEFT ) PlayerI.note |= NOTE_PAD1_UPLEFT;
if ( PadI.button == BUTTON_DOWN ) PlayerI.note |= NOTE_PAD1_DOWN;
if ( PadI.button == BUTTON_UP ) PlayerI.note |= NOTE_PAD1_UP;
if ( PadI.button == BUTTON_UPRIGHT ) PlayerI.note |= NOTE_PAD1_UPRIGHT;
if ( PadI.button == BUTTON_RIGHT ) PlayerI.note |= NOTE_PAD1_RIGHT;
break;
case STYLE_VERSUS:
case STYLE_COUPLE:
if( PadI.pad_no == PAD_1 )
PlayerI.player_no = PLAYER_1;
else if( PadI.pad_no == PAD_2 )
PlayerI.player_no = PLAYER_2;
else
PlayerI.player_no = PLAYER_NONE;
if ( PadI.button == BUTTON_LEFT ) PlayerI.note |= NOTE_PAD1_LEFT;
if ( PadI.button == BUTTON_UPLEFT ) PlayerI.note |= NOTE_PAD1_UPLEFT;
if ( PadI.button == BUTTON_DOWN ) PlayerI.note |= NOTE_PAD1_DOWN;
if ( PadI.button == BUTTON_UP ) PlayerI.note |= NOTE_PAD1_UP;
if ( PadI.button == BUTTON_UPRIGHT ) PlayerI.note |= NOTE_PAD1_UPRIGHT;
if ( PadI.button == BUTTON_RIGHT ) PlayerI.note |= NOTE_PAD1_RIGHT;
break;
case STYLE_DOUBLE:
switch( PadI.pad_no )
{
case PAD_1:
PlayerI.player_no = PLAYER_1;
if ( PadI.button == BUTTON_LEFT ) PlayerI.note |= NOTE_PAD1_LEFT;
if ( PadI.button == BUTTON_DOWN ) PlayerI.note |= NOTE_PAD1_DOWN;
if ( PadI.button == BUTTON_UP ) PlayerI.note |= NOTE_PAD1_UP;
if ( PadI.button == BUTTON_RIGHT ) PlayerI.note |= NOTE_PAD1_RIGHT;
break;
case PAD_2:
PlayerI.player_no = PLAYER_1;
if ( PadI.button == BUTTON_LEFT ) PlayerI.note |= NOTE_PAD2_LEFT;
if ( PadI.button == BUTTON_DOWN ) PlayerI.note |= NOTE_PAD2_DOWN;
if ( PadI.button == BUTTON_UP ) PlayerI.note |= NOTE_PAD2_UP;
if ( PadI.button == BUTTON_RIGHT ) PlayerI.note |= NOTE_PAD2_RIGHT;
break;
case PAD_NONE:
PlayerI.player_no = PLAYER_NONE;
break;
}
break;
default:
ASSERT( false ); // invalid DanceStyle
}
}
void PrefsManager::PlayerToPad( PlayerInput PlayerI, PadInput &PadI )
{
PadI.pad_no = PAD_NONE;
PadI.button = BUTTON_NONE;
switch( GAME->m_DanceStyle )
{
case STYLE_SINGLE:
case STYLE_SOLO:
case STYLE_VERSUS:
case STYLE_COUPLE:
PadI.pad_no = (PadNumber)PlayerI.player_no;
if ( PlayerI.note == NOTE_PAD1_LEFT ) PadI.button = BUTTON_LEFT;
if ( PlayerI.note == NOTE_PAD1_UPLEFT ) PadI.button = BUTTON_UPLEFT;
if ( PlayerI.note == NOTE_PAD1_DOWN ) PadI.button = BUTTON_DOWN;
if ( PlayerI.note == NOTE_PAD1_UP ) PadI.button = BUTTON_UP;
if ( PlayerI.note == NOTE_PAD1_UPRIGHT ) PadI.button = BUTTON_UPRIGHT;
if ( PlayerI.note == NOTE_PAD1_RIGHT ) PadI.button = BUTTON_RIGHT;
break;
case STYLE_DOUBLE:
switch( PlayerI.note )
{
case NOTE_PAD1_LEFT: PadI.pad_no = PAD_1; PadI.button = BUTTON_LEFT; break;
case NOTE_PAD1_DOWN: PadI.pad_no = PAD_1; PadI.button = BUTTON_DOWN; break;
case NOTE_PAD1_UP: PadI.pad_no = PAD_1; PadI.button = BUTTON_UP; break;
case NOTE_PAD1_RIGHT: PadI.pad_no = PAD_1; PadI.button = BUTTON_RIGHT; break;
case NOTE_PAD2_LEFT: PadI.pad_no = PAD_2; PadI.button = BUTTON_LEFT; break;
case NOTE_PAD2_DOWN: PadI.pad_no = PAD_2; PadI.button = BUTTON_DOWN; break;
case NOTE_PAD2_UP: PadI.pad_no = PAD_2; PadI.button = BUTTON_UP; break;
case NOTE_PAD2_RIGHT: PadI.pad_no = PAD_2; PadI.button = BUTTON_RIGHT; break;
}
break;
default:
ASSERT( false ); // invalid DanceStyle
}
}
bool PrefsManager::IsButtonDown( PadInput pi )
{
for( int i=0; i<NUM_PAD_TO_DEVICE_SLOTS; i++ )
{
DeviceInput di;
if( PadToDevice( pi, i, di ) )
{
if( INPUTM->IsBeingPressed( di ) )
return true;
}
}
return false;
}
bool PrefsManager::IsButtonDown( PlayerInput PlayerI )
{
PadInput PadI;
PlayerToPad( PlayerI, PadI );
return IsButtonDown( PadI );
}
CString PrefsManager::GetStageText()
{
if( m_iCurrentStage == 3 )
@@ -443,5 +160,3 @@ CString PrefsManager::GetStageText()
return ssprintf( "%d%s", PREFS->m_iCurrentStage, sNumberSuffix );
}