bug fixes
This commit is contained in:
@@ -54,7 +54,7 @@ bool Background::LoadFromSong( Song* pSong, bool bDisableVisualizations )
|
||||
this->AddActor( &m_sprSongBackground );
|
||||
|
||||
|
||||
if( GAMEINFO->m_GameOptions.m_bRandomVis && !bDisableVisualizations )
|
||||
if( PREFS->m_GameOptions.m_bUseRandomVis && !bDisableVisualizations )
|
||||
{
|
||||
// load a random visualization
|
||||
CStringArray sVisualizationPaths;
|
||||
|
||||
@@ -28,7 +28,7 @@ void GhostArrow::Update( float fDeltaTime )
|
||||
|
||||
void GhostArrow::SetBeat( const float fSongBeat )
|
||||
{
|
||||
//SetState( fmod(fSongBeat,1)<0.25 ? 1 : 0 );
|
||||
//SetState( fmodf(fSongBeat,1)<0.25 ? 1 : 0 );
|
||||
}
|
||||
|
||||
void GhostArrow::Step( TapStepScore score )
|
||||
|
||||
@@ -24,7 +24,7 @@ GhostArrowBright::GhostArrowBright()
|
||||
|
||||
void GhostArrowBright::SetBeat( const float fSongBeat )
|
||||
{
|
||||
//SetState( fmod(fSongBeat,1)<0.25 ? 1 : 0 );
|
||||
//SetState( fmodf(fSongBeat,1)<0.25 ? 1 : 0 );
|
||||
}
|
||||
|
||||
void GhostArrowBright::Step( TapStepScore score )
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
#include "stdafx.h"
|
||||
//
|
||||
// GrayArrow.cpp: implementation of the GrayArrow class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: GrayArrow
|
||||
|
||||
Desc: A gray arrow that "receives" ColorArrows.
|
||||
|
||||
Copyright (c) 2001-2002 by the names listed below. All rights reserved.
|
||||
Ben Nordstrom
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "GrayArrow.h"
|
||||
#include "ThemeManager.h"
|
||||
@@ -10,10 +17,6 @@
|
||||
const float GRAY_ARROW_POP_UP_TIME = 0.3f;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrayArrow::GrayArrow()
|
||||
{
|
||||
Load( THEME->GetPathTo(GRAPHIC_GRAY_ARROW) );
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
File: GrayArrow.h
|
||||
Class: GrayArrow
|
||||
|
||||
Desc: Class used to represent a color arrow on the screen.
|
||||
Desc: A gray arrow that "receives" ColorArrows.
|
||||
|
||||
Copyright (c) 2001 Ben Norstrom. All rights reserved.
|
||||
Copyright (c) 2001-2002 by the names listed below. All rights reserved.
|
||||
Ben Nordstrom
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "MusicWheel.h"
|
||||
#include "RageUtil.h"
|
||||
#include "SongManager.h"
|
||||
#include "ScreenDimensions.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "RageMusic.h"
|
||||
@@ -216,7 +217,7 @@ MusicWheel::MusicWheel()
|
||||
// init m_mapGroupNameToBannerColor
|
||||
|
||||
CArray<Song*, Song*> arraySongs;
|
||||
arraySongs.Copy( GAMEINFO->m_pSongs );
|
||||
arraySongs.Copy( SONGS->m_pSongs );
|
||||
SortSongPointerArrayByGroup( arraySongs );
|
||||
|
||||
int iNextGroupBannerColor = 0;
|
||||
@@ -236,7 +237,7 @@ MusicWheel::MusicWheel()
|
||||
}
|
||||
|
||||
|
||||
m_SortOrder = GAMEINFO->m_SongSortOrder;
|
||||
m_SortOrder = PREFS->m_SongSortOrder;
|
||||
m_MusicSortDisplay.Set( m_SortOrder );
|
||||
m_MusicSortDisplay.SetXY( SORT_ICON_ON_SCREEN_X, SORT_ICON_ON_SCREEN_Y );
|
||||
|
||||
@@ -256,10 +257,10 @@ MusicWheel::MusicWheel()
|
||||
BuildWheelItemDatas( m_WheelItemDatas[so], SongSortOrder(so) );
|
||||
|
||||
|
||||
if( GAMEINFO->m_pCurSong == NULL // if there is no currently selected song
|
||||
&& GAMEINFO->m_pSongs.GetSize() > 0 ) // and there is at least one song
|
||||
if( SONGS->m_pCurSong == NULL && // if there is no currently selected song
|
||||
SONGS->m_pSongs.GetSize() > 0 ) // and there is at least one song
|
||||
{
|
||||
GAMEINFO->m_pCurSong = GAMEINFO->m_pSongs[0]; // select the first song
|
||||
SONGS->m_pCurSong = SONGS->m_pSongs[0]; // select the first song
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +269,7 @@ MusicWheel::MusicWheel()
|
||||
for( i=0; i<GetCurWheelItemDatas().GetSize(); i++ )
|
||||
{
|
||||
if( GetCurWheelItemDatas()[i].m_pSong != NULL
|
||||
&& GetCurWheelItemDatas()[i].m_pSong == GAMEINFO->m_pCurSong )
|
||||
&& GetCurWheelItemDatas()[i].m_pSong == SONGS->m_pCurSong )
|
||||
{
|
||||
m_iSelection = i; // select it
|
||||
m_sExpandedSectionName = GetCurWheelItemDatas()[m_iSelection].m_sSectionName; // make its group the currently expanded group
|
||||
@@ -283,7 +284,7 @@ MusicWheel::MusicWheel()
|
||||
|
||||
MusicWheel::~MusicWheel()
|
||||
{
|
||||
GAMEINFO->m_SongSortOrder = m_SortOrder;
|
||||
PREFS->m_SongSortOrder = m_SortOrder;
|
||||
}
|
||||
|
||||
void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arrayWheelItemDatas, SongSortOrder so )
|
||||
@@ -295,12 +296,12 @@ void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arr
|
||||
CArray<Song*, Song*> arraySongs;
|
||||
|
||||
// copy only song that have at least one Steps for the current GameMode
|
||||
for( int i=0; i<GAMEINFO->m_pSongs.GetSize(); i++ )
|
||||
for( int i=0; i<SONGS->m_pSongs.GetSize(); i++ )
|
||||
{
|
||||
Song* pSong = GAMEINFO->m_pSongs[i];
|
||||
Song* pSong = SONGS->m_pSongs[i];
|
||||
|
||||
CArray<Steps*, Steps*> arraySteps;
|
||||
pSong->GetStepsThatMatchGameMode( GAMEINFO->m_GameMode, arraySteps );
|
||||
pSong->GetStepsThatMatchGameMode( PREFS->m_GameMode, arraySteps );
|
||||
|
||||
if( arraySteps.GetSize() > 0 )
|
||||
arraySongs.Add( pSong );
|
||||
|
||||
@@ -86,14 +86,14 @@ void Player::Load( const Style& style, PlayerNumber player_no, const Steps& step
|
||||
// load step elements
|
||||
for( int i=0; i<MAX_TAP_STEP_ELEMENTS; i++ )
|
||||
{
|
||||
m_TapStepsOriginal[i] = steps.m_TapSteps[i];
|
||||
m_TapStepsRemaining[i] = steps.m_TapSteps[i];
|
||||
m_TapStepsOriginal[i] = steps2.m_TapSteps[i];
|
||||
m_TapStepsRemaining[i] = steps2.m_TapSteps[i];
|
||||
}
|
||||
for( i=0; i<steps.m_iNumHoldSteps; i++ )
|
||||
for( i=0; i<steps2.m_iNumHoldSteps; i++ )
|
||||
{
|
||||
m_HoldSteps[i] = steps.m_HoldSteps[i];
|
||||
m_HoldSteps[i] = steps2.m_HoldSteps[i];
|
||||
}
|
||||
m_iNumHoldSteps = steps.m_iNumHoldSteps;
|
||||
m_iNumHoldSteps = steps2.m_iNumHoldSteps;
|
||||
|
||||
|
||||
m_Combo.SetY( po.m_bReverseScroll ? SCREEN_HEIGHT - COMBO_Y : COMBO_Y );
|
||||
@@ -146,8 +146,8 @@ void Player::Update( float fDeltaTime, float fSongBeat, float fMaxBeatDifference
|
||||
// update the life
|
||||
if( fStartBeat < m_fSongBeat && m_fSongBeat < fEndBeat ) // if the song beat is in the range of this hold
|
||||
{
|
||||
PlayerInput PlayerI = { m_PlayerNumber, hs.m_TapStep };
|
||||
bool bIsHoldingButton = GAMEINFO->IsButtonDown( PlayerI );
|
||||
PlayerInput PlayerI( m_PlayerNumber, hs.m_TapStep );
|
||||
bool bIsHoldingButton = PREFS->IsButtonDown( PlayerI );
|
||||
if( bIsHoldingButton )
|
||||
{
|
||||
hss.m_fLife += fDeltaTime/HOLD_ARROW_NG_TIME;
|
||||
@@ -201,7 +201,7 @@ void Player::RenderPrimitives()
|
||||
{
|
||||
D3DXMATRIX matOldView, matOldProj;
|
||||
|
||||
if( m_PlayerOptions.m_EffectType == PlayerOptions::EFFECT_STARS )
|
||||
if( m_PlayerOptions.m_EffectType == PlayerOptions::EFFECT_SPACE )
|
||||
{
|
||||
// turn off Z Buffering
|
||||
SCREEN->GetDevice()->SetRenderState( D3DRS_ZENABLE, FALSE );
|
||||
@@ -229,7 +229,7 @@ void Player::RenderPrimitives()
|
||||
m_ColorArrowField.Draw();
|
||||
m_GhostArrows.Draw();
|
||||
|
||||
if( m_PlayerOptions.m_EffectType == PlayerOptions::EFFECT_STARS )
|
||||
if( m_PlayerOptions.m_EffectType == PlayerOptions::EFFECT_SPACE )
|
||||
{
|
||||
// restire old view and projection
|
||||
SCREEN->GetDevice()->SetTransform( D3DTS_VIEW, &matOldView );
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#ifndef _PLAYER_H_
|
||||
#define _PLAYER_H_
|
||||
|
||||
#include "GameInfo.h" // for ScoreSummary
|
||||
#include "PrefsManager.h" // for ScoreSummary
|
||||
#include "Steps.h"
|
||||
#include "Sprite.h"
|
||||
#include "BitmapText.h"
|
||||
|
||||
@@ -0,0 +1,407 @@
|
||||
#include "stdafx.h"
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: PrefsManager
|
||||
|
||||
Desc: See Header.
|
||||
|
||||
Copyright (c) 2001-2002 by the names listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "PrefsManager.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
|
||||
PrefsManager* PREFS = NULL; // global and accessable from anywhere in our program
|
||||
|
||||
|
||||
|
||||
|
||||
PrefsManager::PrefsManager()
|
||||
{
|
||||
m_GameMode = MODE_SINGLE;
|
||||
m_SongSortOrder = SORT_GROUP;
|
||||
m_iCurrentStage = 1;
|
||||
m_ThemeName = "default";
|
||||
|
||||
ReadPrefsFromDisk();
|
||||
SetHardCodedButtons();
|
||||
}
|
||||
|
||||
|
||||
PrefsManager::~PrefsManager()
|
||||
{
|
||||
// don't worry about releasing the Song array. Let the OS do it :-)
|
||||
SavePrefsToDisk();
|
||||
}
|
||||
|
||||
|
||||
void PrefsManager::ReadPrefsFromDisk()
|
||||
{
|
||||
IniFile ini;
|
||||
ini.SetPath( "StepMania.ini" );
|
||||
if( !ini.ReadFile() ) {
|
||||
return; // load nothing
|
||||
//RageError( "could not read config file" );
|
||||
}
|
||||
|
||||
CMapStringToString* pKey = ini.GetKeyPointer("Input");
|
||||
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 )
|
||||
{
|
||||
for( POSITION pos = pKey->GetStartPosition(); pos != NULL; )
|
||||
{
|
||||
pKey->GetNextAssoc( pos, name_string, value_string );
|
||||
|
||||
if( name_string == "Windowed" ) m_GameOptions.m_bWindowed = ( value_string == "1" );
|
||||
if( name_string == "Resolution" ) m_GameOptions.m_iResolution = atoi( value_string );
|
||||
if( name_string == "DisplayColor" ) m_GameOptions.m_iDisplayColor = atoi( value_string );
|
||||
if( name_string == "TextureColor" ) m_GameOptions.m_iTextureColor = atoi( value_string );
|
||||
if( name_string == "FilterTextures" ) m_GameOptions.m_bFilterTextures = ( value_string == "1" );
|
||||
if( name_string == "Shadows" ) m_GameOptions.m_bShadows = ( value_string == "1" );
|
||||
if( name_string == "IgnoreJoyDirs" ) m_GameOptions.m_bIgnoreJoyDirs = ( value_string == "1" );
|
||||
if( name_string == "ShowFPS" ) m_GameOptions.m_bShowFPS = ( value_string == "1" );
|
||||
if( name_string == "UseRandomVis" ) m_GameOptions.m_bUseRandomVis = ( value_string == "1" );
|
||||
if( name_string == "ShowCaution" ) m_GameOptions.m_bShowCaution = ( value_string == "1" );
|
||||
if( name_string == "Announcer" ) m_GameOptions.m_bAnnouncer = ( value_string == "1" );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PrefsManager::SavePrefsToDisk()
|
||||
{
|
||||
IniFile ini;
|
||||
ini.SetPath( "StepMania.ini" );
|
||||
// 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( "GameOptions", "Windowed", m_GameOptions.m_bWindowed ? "1":"0" );
|
||||
ini.SetValue( "GameOptions", "Resolution", ssprintf("%d", m_GameOptions.m_iResolution) );
|
||||
ini.SetValue( "GameOptions", "DisplayColor", ssprintf("%d", m_GameOptions.m_iDisplayColor) );
|
||||
ini.SetValue( "GameOptions", "TextureColor", ssprintf("%d", m_GameOptions.m_iTextureColor) );
|
||||
ini.SetValue( "GameOptions", "FilterTextures", m_GameOptions.m_bFilterTextures ? "1":"0" );
|
||||
ini.SetValue( "GameOptions", "Shadows", m_GameOptions.m_bShadows ? "1":"0" );
|
||||
ini.SetValue( "GameOptions", "IgnoreJoyDirs", m_GameOptions.m_bIgnoreJoyDirs ? "1":"0" );
|
||||
ini.SetValue( "GameOptions", "ShowFPS", m_GameOptions.m_bShowFPS ? "1":"0" );
|
||||
ini.SetValue( "GameOptions", "UseRandomVis", m_GameOptions.m_bUseRandomVis ? "1":"0" );
|
||||
ini.SetValue( "GameOptions", "ShowCaution", m_GameOptions.m_bShowCaution ? "1":"0" );
|
||||
ini.SetValue( "GameOptions", "Announcer", m_GameOptions.m_bAnnouncer ? "1":"0" );
|
||||
|
||||
|
||||
|
||||
ini.WriteFile();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// 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.step = STEP_NONE;
|
||||
|
||||
switch( m_GameMode )
|
||||
{
|
||||
case MODE_SINGLE:
|
||||
case MODE_SOLO:
|
||||
if( PadI.pad_no == PAD_1 )
|
||||
PlayerI.player_no = PLAYER_1;
|
||||
else
|
||||
PlayerI.player_no = PLAYER_NONE;
|
||||
|
||||
if ( PadI.button == BUTTON_LEFT ) PlayerI.step |= STEP_PAD1_LEFT;
|
||||
if ( PadI.button == BUTTON_UPLEFT ) PlayerI.step |= STEP_PAD1_UPLEFT;
|
||||
if ( PadI.button == BUTTON_DOWN ) PlayerI.step |= STEP_PAD1_DOWN;
|
||||
if ( PadI.button == BUTTON_UP ) PlayerI.step |= STEP_PAD1_UP;
|
||||
if ( PadI.button == BUTTON_UPRIGHT ) PlayerI.step |= STEP_PAD1_UPRIGHT;
|
||||
if ( PadI.button == BUTTON_RIGHT ) PlayerI.step |= STEP_PAD1_RIGHT;
|
||||
|
||||
break;
|
||||
case MODE_VERSUS:
|
||||
case MODE_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.step |= STEP_PAD1_LEFT;
|
||||
if ( PadI.button == BUTTON_UPLEFT ) PlayerI.step |= STEP_PAD1_UPLEFT;
|
||||
if ( PadI.button == BUTTON_DOWN ) PlayerI.step |= STEP_PAD1_DOWN;
|
||||
if ( PadI.button == BUTTON_UP ) PlayerI.step |= STEP_PAD1_UP;
|
||||
if ( PadI.button == BUTTON_UPRIGHT ) PlayerI.step |= STEP_PAD1_UPRIGHT;
|
||||
if ( PadI.button == BUTTON_RIGHT ) PlayerI.step |= STEP_PAD1_RIGHT;
|
||||
|
||||
break;
|
||||
case MODE_DOUBLE:
|
||||
|
||||
switch( PadI.pad_no )
|
||||
{
|
||||
case PAD_1:
|
||||
PlayerI.player_no = PLAYER_1;
|
||||
if ( PadI.button == BUTTON_LEFT ) PlayerI.step |= STEP_PAD1_LEFT;
|
||||
if ( PadI.button == BUTTON_DOWN ) PlayerI.step |= STEP_PAD1_DOWN;
|
||||
if ( PadI.button == BUTTON_UP ) PlayerI.step |= STEP_PAD1_UP;
|
||||
if ( PadI.button == BUTTON_RIGHT ) PlayerI.step |= STEP_PAD1_RIGHT;
|
||||
break;
|
||||
case PAD_2:
|
||||
PlayerI.player_no = PLAYER_1;
|
||||
if ( PadI.button == BUTTON_LEFT ) PlayerI.step |= STEP_PAD2_LEFT;
|
||||
if ( PadI.button == BUTTON_DOWN ) PlayerI.step |= STEP_PAD2_DOWN;
|
||||
if ( PadI.button == BUTTON_UP ) PlayerI.step |= STEP_PAD2_UP;
|
||||
if ( PadI.button == BUTTON_RIGHT ) PlayerI.step |= STEP_PAD2_RIGHT;
|
||||
break;
|
||||
case PAD_NONE:
|
||||
PlayerI.player_no = PLAYER_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
ASSERT( false ); // invalid GameMode
|
||||
}
|
||||
}
|
||||
|
||||
void PrefsManager::PlayerToPad( PlayerInput PlayerI, PadInput &PadI )
|
||||
{
|
||||
PadI.pad_no = PAD_NONE;
|
||||
PadI.button = BUTTON_NONE;
|
||||
|
||||
switch( m_GameMode )
|
||||
{
|
||||
case MODE_SINGLE:
|
||||
case MODE_SOLO:
|
||||
case MODE_VERSUS:
|
||||
case MODE_COUPLE:
|
||||
PadI.pad_no = (PadNumber)PlayerI.player_no;
|
||||
|
||||
if ( PlayerI.step == STEP_PAD1_LEFT ) PadI.button = BUTTON_LEFT;
|
||||
if ( PlayerI.step == STEP_PAD1_UPLEFT ) PadI.button = BUTTON_UPLEFT;
|
||||
if ( PlayerI.step == STEP_PAD1_DOWN ) PadI.button = BUTTON_DOWN;
|
||||
if ( PlayerI.step == STEP_PAD1_UP ) PadI.button = BUTTON_UP;
|
||||
if ( PlayerI.step == STEP_PAD1_UPRIGHT ) PadI.button = BUTTON_UPRIGHT;
|
||||
if ( PlayerI.step == STEP_PAD1_RIGHT ) PadI.button = BUTTON_RIGHT;
|
||||
|
||||
break;
|
||||
case MODE_DOUBLE:
|
||||
switch( PlayerI.step )
|
||||
{
|
||||
case STEP_PAD1_LEFT: PadI.pad_no = PAD_1; PadI.button = BUTTON_LEFT; break;
|
||||
case STEP_PAD1_DOWN: PadI.pad_no = PAD_1; PadI.button = BUTTON_DOWN; break;
|
||||
case STEP_PAD1_UP: PadI.pad_no = PAD_1; PadI.button = BUTTON_UP; break;
|
||||
case STEP_PAD1_RIGHT: PadI.pad_no = PAD_1; PadI.button = BUTTON_RIGHT; break;
|
||||
case STEP_PAD2_LEFT: PadI.pad_no = PAD_2; PadI.button = BUTTON_LEFT; break;
|
||||
case STEP_PAD2_DOWN: PadI.pad_no = PAD_2; PadI.button = BUTTON_DOWN; break;
|
||||
case STEP_PAD2_UP: PadI.pad_no = PAD_2; PadI.button = BUTTON_UP; break;
|
||||
case STEP_PAD2_RIGHT: PadI.pad_no = PAD_2; PadI.button = BUTTON_RIGHT; break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
ASSERT( false ); // invalid GameMode
|
||||
}
|
||||
}
|
||||
|
||||
bool PrefsManager::IsButtonDown( PadInput pi )
|
||||
{
|
||||
for( int i=0; i<NUM_PAD_TO_DEVICE_SLOTS; i++ )
|
||||
{
|
||||
DeviceInput di;
|
||||
|
||||
if( PadToDevice( pi, i, di ) )
|
||||
{
|
||||
if( INPUT->IsBeingPressed( di ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PrefsManager::IsButtonDown( PlayerInput PlayerI )
|
||||
{
|
||||
PadInput PadI;
|
||||
PlayerToPad( PlayerI, PadI );
|
||||
return IsButtonDown( PadI );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: PrefsManager
|
||||
|
||||
Desc: Manages input mapping, saves preferences, and holds data that is passed
|
||||
between Windows.
|
||||
|
||||
Copyright (c) 2001-2002 by the names listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _PrefsManager_H_
|
||||
#define _PrefsManager_H_
|
||||
|
||||
|
||||
#include "RageInput.h"
|
||||
#include "PadInput.h"
|
||||
#include "PlayerInput.h"
|
||||
#include "GameTypes.h"
|
||||
|
||||
|
||||
|
||||
const int NUM_PAD_TO_DEVICE_SLOTS = 3; // three device inputs may map to one pad input
|
||||
|
||||
|
||||
class Song;
|
||||
|
||||
class PrefsManager
|
||||
{
|
||||
public:
|
||||
PrefsManager();
|
||||
~PrefsManager();
|
||||
|
||||
GameMode m_GameMode;
|
||||
|
||||
ScoreSummary scoreSummaryPlayer[NUM_PLAYERS];
|
||||
|
||||
SongSortOrder m_SongSortOrder;
|
||||
|
||||
int m_iCurrentStage;
|
||||
|
||||
GameOptions m_GameOptions;
|
||||
PlayerOptions m_PlayerOptions[NUM_PLAYERS];
|
||||
SongOptions m_SongOptions;
|
||||
|
||||
bool IsPlayerEnabled( PlayerNumber PlayerNo )
|
||||
{
|
||||
switch( m_GameMode )
|
||||
{
|
||||
case MODE_VERSUS:
|
||||
case MODE_COUPLE:
|
||||
if( PlayerNo == PLAYER_1 )
|
||||
return true;
|
||||
if( PlayerNo == PLAYER_2 )
|
||||
return true;
|
||||
break;
|
||||
case MODE_SINGLE:
|
||||
case MODE_SOLO:
|
||||
case MODE_DOUBLE:
|
||||
if( PlayerNo == PLAYER_1 )
|
||||
return true;
|
||||
if( PlayerNo == PLAYER_2 )
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
ASSERT( false ); // invalid game mode
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// prefs file stuff
|
||||
void ReadPrefsFromDisk();
|
||||
void SavePrefsToDisk();
|
||||
|
||||
|
||||
// input mapping stuff
|
||||
void SetInputMap( DeviceInput di, PadInput pi, int iSlotIndex, bool bOverrideHardCoded = false );
|
||||
void ClearFromInputMap( DeviceInput di );
|
||||
void ClearFromInputMap( PadInput pi, int iSlotIndex );
|
||||
|
||||
void SetHardCodedButtons();
|
||||
bool IsAHardCodedDeviceInput( DeviceInput di );
|
||||
|
||||
bool DeviceToPad( DeviceInput di, PadInput& pi ); // return true if there is a mapping from device to pad
|
||||
bool PadToDevice( PadInput pi, int iSoltNum, DeviceInput& di ); // return true if there is a mapping from pad to device
|
||||
|
||||
void PadToPlayer( PadInput PadI, PlayerInput &PlayerI );
|
||||
void PlayerToPad( PlayerInput PlayerI, PadInput &PadI );
|
||||
|
||||
bool IsButtonDown( PadInput pi );
|
||||
bool IsButtonDown( PlayerInput PlayerI );
|
||||
|
||||
// theme stuff
|
||||
CString m_ThemeName;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
DeviceInput m_PItoDI[NUM_PADS][NUM_PAD_BUTTONS][NUM_PAD_TO_DEVICE_SLOTS]; // all the DeviceInputs that map to a PadInput
|
||||
|
||||
// lookup for efficiency from a DeviceInput to a PadInput
|
||||
// This is repopulated every time m_PItoDI changes by calling UpdateTempDItoPI().
|
||||
PadInput m_tempDItoPI[NUM_INPUT_DEVICES][NUM_DEVICE_BUTTONS];
|
||||
void UpdateTempDItoPI();
|
||||
};
|
||||
|
||||
|
||||
extern PrefsManager* PREFS; // global and accessable from anywhere in our program
|
||||
|
||||
|
||||
#endif
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "dxerr8.h"
|
||||
#include "DXUtil.h"
|
||||
#include "RageUtil.h"
|
||||
#include "GameInfo.h"
|
||||
#include "PrefsManager.h"
|
||||
|
||||
//#include <stdio.h>
|
||||
#include <assert.h>
|
||||
@@ -92,9 +92,9 @@ void RageBitmapTexture::Create( DWORD dwHints )
|
||||
|
||||
|
||||
// if the user has requested high color textures, use the higher color
|
||||
if( GAMEINFO != NULL
|
||||
&& GAMEINFO->m_GameOptions.m_iDisplayColor == 32
|
||||
&& GAMEINFO->m_GameOptions.m_iTextureColor == 32 )
|
||||
if( PREFS != NULL
|
||||
&& PREFS->m_GameOptions.m_iDisplayColor == 32
|
||||
&& PREFS->m_GameOptions.m_iTextureColor == 32 )
|
||||
{
|
||||
fmtTexture = D3DFMT_A8R8G8B8;
|
||||
}
|
||||
|
||||
@@ -12,36 +12,10 @@
|
||||
#include "RageUtil.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// UTIL globals
|
||||
//-----------------------------------------------------------------------------
|
||||
const CString g_sLogFileName = "log.txt";
|
||||
const CString g_sErrorFileName = "error.txt";
|
||||
FILE* g_fileLog = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: randomf()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
float randomf( float low, float high )
|
||||
{
|
||||
return low + ( high - low ) * ( (FLOAT)rand() ) / RAND_MAX;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: roundf()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
int roundf( float f )
|
||||
{
|
||||
return (int)((f)+0.5f);
|
||||
}
|
||||
|
||||
int roundf( double f )
|
||||
{
|
||||
return (int)((f)+0.5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool IsAnInt( CString s )
|
||||
|
||||
@@ -46,12 +46,17 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Simple function for generating random numbers
|
||||
float randomf( float low=-1.0f, float high=1.0f );
|
||||
int roundf( FLOAT f );
|
||||
int roundf( double f );
|
||||
inline float randomf( float low=-1.0f, float high=1.0f )
|
||||
{
|
||||
return low + ( high - low ) * ( (FLOAT)rand() ) / RAND_MAX;
|
||||
}
|
||||
inline int roundf( float f ) { return (int)((f)+0.5f); };
|
||||
inline int roundf( double f ) { return (int)((f)+0.5); };
|
||||
|
||||
|
||||
bool IsAnInt( CString s );
|
||||
|
||||
|
||||
CString ssprintf( LPCTSTR fmt, ...);
|
||||
CString vssprintf( LPCTSTR fmt, va_list argList );
|
||||
|
||||
|
||||
@@ -12,16 +12,16 @@
|
||||
#define _SCREENDIMENSIONS_H_
|
||||
|
||||
|
||||
const int SCREEN_WIDTH = 640;
|
||||
const int SCREEN_HEIGHT = 480;
|
||||
#define SCREEN_WIDTH (640)
|
||||
#define SCREEN_HEIGHT (480)
|
||||
|
||||
const float SCREEN_LEFT = 0;
|
||||
const float SCREEN_RIGHT = SCREEN_WIDTH;
|
||||
const float SCREEN_TOP = 0;
|
||||
const float SCREEN_BOTTOM = SCREEN_HEIGHT;
|
||||
#define SCREEN_LEFT (0)
|
||||
#define SCREEN_RIGHT (SCREEN_WIDTH)
|
||||
#define SCREEN_TOP (0)
|
||||
#define SCREEN_BOTTOM (SCREEN_HEIGHT)
|
||||
|
||||
const float CENTER_X = SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT)/2.0f;
|
||||
const float CENTER_Y = SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP)/2.0f;
|
||||
#define CENTER_X (SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT)/2.0f)
|
||||
#define CENTER_Y (SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP)/2.0f)
|
||||
|
||||
|
||||
#endif
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "Song.h"
|
||||
#include <assert.h>
|
||||
#include <math.h> // for fmod
|
||||
|
||||
|
||||
|
||||
@@ -77,6 +78,9 @@ Song::Song()
|
||||
|
||||
void Song::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut )
|
||||
{
|
||||
RageLog( "GetBeatAndBPSFromElapsedTime( fElapsedTime = %f )", fElapsedTime );
|
||||
// This function is a nightmare. Don't even try to understand it. :-)
|
||||
|
||||
fElapsedTime += m_fOffsetInSeconds;
|
||||
|
||||
|
||||
@@ -186,6 +190,8 @@ bool Song::LoadFromSongDir( CString sDir )
|
||||
RageError( ssprintf("Couldn't find any BMS or MSD files in '%s'", sDir) );
|
||||
}
|
||||
|
||||
RageLog( "m_fOffsetInSeconds is %f", m_fOffsetInSeconds );
|
||||
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -485,7 +491,7 @@ bool Song::LoadSongInfoFromDWIFile( CString sPath )
|
||||
{
|
||||
CStringArray arrayFreezeValues;
|
||||
split( arrayFreezeExpressions[f], "=", arrayFreezeValues );
|
||||
int fIndex = atoi( arrayFreezeValues[0] ) * 2;
|
||||
float fIndex = atoi( arrayFreezeValues[0] ) * ELEMENTS_PER_BEAT / 4.0f;
|
||||
float fFreezeBeat = StepIndexToBeat( fIndex );
|
||||
float fFreezeSeconds = (float)atof( arrayFreezeValues[1] ) / 1000.0f;
|
||||
|
||||
@@ -510,7 +516,7 @@ bool Song::LoadSongInfoFromDWIFile( CString sPath )
|
||||
{
|
||||
CStringArray arrayBPMChangeValues;
|
||||
split( arrayBPMChangeExpressions[b], "=", arrayBPMChangeValues );
|
||||
int fIndex = atoi( arrayBPMChangeValues[0] ) * 2;
|
||||
float fIndex = atoi( arrayBPMChangeValues[0] ) * ELEMENTS_PER_BEAT / 4.0f;
|
||||
float fBeat = StepIndexToBeat( fIndex );
|
||||
float fNewBPM = (float)atoi( arrayBPMChangeValues[1] );
|
||||
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
#include "stdafx.h"
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: SongManager
|
||||
|
||||
Desc: See header.
|
||||
|
||||
Copyright (c) 2001-2002 by the names listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "SongManager.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
|
||||
SongManager* SONGS = NULL; // global and accessable from anywhere in our program
|
||||
|
||||
|
||||
const CString g_sStatisticsFileName = "statistics.ini";
|
||||
|
||||
|
||||
SongManager::SongManager()
|
||||
{
|
||||
m_pCurSong = NULL;
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
m_pStepsPlayer[p] = NULL;
|
||||
|
||||
InitSongArrayFromDisk();
|
||||
ReadStatisticsFromDisk();
|
||||
}
|
||||
|
||||
|
||||
SongManager::~SongManager()
|
||||
{
|
||||
CleanUpSongArray();
|
||||
SaveStatisticsToDisk();
|
||||
}
|
||||
|
||||
|
||||
void SongManager::InitSongArrayFromDisk()
|
||||
{
|
||||
/////////////////////////////
|
||||
// Handle DWI support
|
||||
/////////////////////////////
|
||||
|
||||
// Find all directories in "DWIs" folder
|
||||
CStringArray arrayDirs;
|
||||
GetDirListing( "DWI Support\\DWIs\\*.*", arrayDirs, true );
|
||||
SortCStringArray( arrayDirs );
|
||||
|
||||
for( int i=0; i< arrayDirs.GetSize(); i++ ) // for each dir in /DWIs/
|
||||
{
|
||||
CString sDirName = arrayDirs[i];
|
||||
sDirName.MakeLower();
|
||||
if( sDirName == "cvs" ) // ignore the directory called "CVS"
|
||||
continue;
|
||||
|
||||
// Find all DWIs in this directory
|
||||
CStringArray arrayDWIFiles;
|
||||
GetDirListing( ssprintf("DWI Support\\DWIs\\%s\\*.dwi", sDirName), arrayDWIFiles );
|
||||
SortCStringArray( arrayDWIFiles );
|
||||
|
||||
for( int j=0; j< arrayDWIFiles.GetSize(); j++ ) // for each DWI file
|
||||
{
|
||||
CString sDWIFileName = arrayDWIFiles[j];
|
||||
sDWIFileName.MakeLower();
|
||||
|
||||
// load DWIs from the sub dirs
|
||||
Song* pNewSong = new Song;
|
||||
pNewSong->LoadSongInfoFromDWIFile( ssprintf("DWI Support\\DWIs\\%s\\%s", sDirName, sDWIFileName) );
|
||||
m_pSongs.Add( pNewSong );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Load songs from StepMania's directory structure in Songs
|
||||
/////////////////////////////
|
||||
|
||||
// Find all group directories in "Songs" folder
|
||||
CStringArray arrayGroupDirs;
|
||||
GetDirListing( "Songs\\*.*", arrayGroupDirs, true );
|
||||
SortCStringArray( arrayGroupDirs );
|
||||
|
||||
for( i=0; i< arrayGroupDirs.GetSize(); i++ ) // for each dir in /Songs/
|
||||
{
|
||||
CString sGroupDirName = arrayGroupDirs[i];
|
||||
sGroupDirName.MakeLower();
|
||||
|
||||
if( sGroupDirName == "cvs" ) // ignore the directory called "CVS"
|
||||
continue;
|
||||
|
||||
// Find all Song folders in this group directory
|
||||
CStringArray arraySongDirs;
|
||||
GetDirListing( ssprintf("Songs\\%s\\*.*", sGroupDirName, true), arraySongDirs );
|
||||
SortCStringArray( arraySongDirs );
|
||||
|
||||
for( int j=0; j< arraySongDirs.GetSize(); j++ ) // for each song dir
|
||||
{
|
||||
CString sSongDirName = arraySongDirs[j];
|
||||
sSongDirName.MakeLower();
|
||||
|
||||
if( sSongDirName == "cvs" ) // ignore the directory called "CVS"
|
||||
continue;
|
||||
|
||||
// load DWIs from the sub dirs
|
||||
Song* pNewSong = new Song;
|
||||
pNewSong->LoadFromSongDir( ssprintf("Songs\\%s\\%s", sGroupDirName, sSongDirName) );
|
||||
m_pSongs.Add( pNewSong );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RageLog( "Found %d Songs.", m_pSongs.GetSize() );
|
||||
}
|
||||
|
||||
|
||||
void SongManager::CleanUpSongArray()
|
||||
{
|
||||
for( int i=0; i<m_pSongs.GetSize(); i++ )
|
||||
{
|
||||
SAFE_DELETE( m_pSongs[i] );
|
||||
}
|
||||
|
||||
m_pSongs.RemoveAll();
|
||||
}
|
||||
|
||||
|
||||
void SongManager::ReloadSongArray()
|
||||
{
|
||||
InitSongArrayFromDisk();
|
||||
CleanUpSongArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SongManager::ReadStatisticsFromDisk()
|
||||
{
|
||||
IniFile ini;
|
||||
ini.SetPath( g_sStatisticsFileName );
|
||||
if( !ini.ReadFile() ) {
|
||||
return; // load nothing
|
||||
//RageError( "could not read config file" );
|
||||
}
|
||||
|
||||
|
||||
// load song statistics
|
||||
CMapStringToString* pKey = ini.GetKeyPointer( "Statistics" );
|
||||
if( pKey )
|
||||
{
|
||||
for( POSITION pos = pKey->GetStartPosition(); pos != NULL; )
|
||||
{
|
||||
CString name_string, value_string;
|
||||
|
||||
pKey->GetNextAssoc( pos, name_string, value_string );
|
||||
|
||||
// Each value has the format "SongName::StepsName=TimesPlayed::TopGrade::TopScore::MaxCombo".
|
||||
|
||||
char szSongName[256];
|
||||
char szStepsName[256];
|
||||
int iRetVal;
|
||||
int i;
|
||||
|
||||
// Parse for Song name and Steps name
|
||||
iRetVal = sscanf( name_string, "%[^:]::%[^\n]", szSongName, szStepsName );
|
||||
if( iRetVal != 2 )
|
||||
continue; // this line doesn't match what is expected
|
||||
|
||||
|
||||
// Search for the corresponding Song pointer.
|
||||
Song* pSong = NULL;
|
||||
for( i=0; i<m_pSongs.GetSize(); i++ )
|
||||
{
|
||||
if( m_pSongs[i]->GetTitle() == szSongName ) // match!
|
||||
{
|
||||
pSong = m_pSongs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( pSong == NULL ) // didn't find a match
|
||||
continue; // skip this entry
|
||||
|
||||
|
||||
// Search for the corresponding Steps pointer.
|
||||
Steps* pSteps = NULL;
|
||||
for( i=0; i<pSong->arraySteps.GetSize(); i++ )
|
||||
{
|
||||
if( pSong->arraySteps[i].m_sDescription == szStepsName ) // match!
|
||||
{
|
||||
pSteps = &pSong->arraySteps[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( pSteps == NULL ) // didn't find a match
|
||||
continue; // skip this entry
|
||||
|
||||
|
||||
// Parse the Steps statistics.
|
||||
char szGradeLetters[10]; // longest possible string is "AAA"
|
||||
|
||||
iRetVal = sscanf(
|
||||
value_string,
|
||||
"%d::%[^:]::%d::%d",
|
||||
&pSteps->m_iNumTimesPlayed,
|
||||
szGradeLetters,
|
||||
&pSteps->m_iTopScore,
|
||||
&pSteps->m_iMaxCombo
|
||||
);
|
||||
if( iRetVal != 4 )
|
||||
continue;
|
||||
|
||||
pSteps->m_TopGrade = StringToGrade( szGradeLetters );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SongManager::SaveStatisticsToDisk()
|
||||
{
|
||||
IniFile ini;
|
||||
ini.SetPath( g_sStatisticsFileName );
|
||||
if( !ini.ReadFile() ) {
|
||||
return; // load nothing
|
||||
//RageError( "could not read config file" );
|
||||
}
|
||||
|
||||
// save song statistics
|
||||
for( int i=0; i<m_pSongs.GetSize(); i++ ) // for each Song
|
||||
{
|
||||
Song* pSong = m_pSongs[i];
|
||||
|
||||
for( int j=0; j<pSong->arraySteps.GetSize(); j++ ) // for each Steps
|
||||
{
|
||||
Steps* pSteps = &pSong->arraySteps[j];
|
||||
|
||||
if( pSteps->m_TopGrade == GRADE_NO_DATA )
|
||||
continue;
|
||||
|
||||
// Each value has the format "SongName::StepsName=TimesPlayed::TopGrade::TopScore::MaxCombo".
|
||||
|
||||
CString sName = ssprintf( "%s::%s", pSong->GetTitle(), pSteps->m_sDescription );
|
||||
CString sValue = ssprintf(
|
||||
"%d::%s::%d::%d",
|
||||
pSteps->m_iNumTimesPlayed,
|
||||
GradeToString( pSteps->m_TopGrade ),
|
||||
pSteps->m_iTopScore,
|
||||
pSteps->m_iMaxCombo
|
||||
);
|
||||
|
||||
ini.SetValue( "Statistics", sName, sValue );
|
||||
}
|
||||
}
|
||||
|
||||
ini.WriteFile();
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: SongManager
|
||||
|
||||
Desc: Holder for all Songs and Steps. Also keeps track of the current
|
||||
Song and Steps, and loads/saves statistics.
|
||||
|
||||
Copyright (c) 2001-2002 by the names listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _SongManager_H_
|
||||
#define _SongManager_H_
|
||||
|
||||
|
||||
#include "Song.h"
|
||||
|
||||
|
||||
|
||||
class SongManager
|
||||
{
|
||||
public:
|
||||
SongManager();
|
||||
~SongManager();
|
||||
|
||||
CArray<Song*, Song*> m_pSongs;
|
||||
Song* m_pCurSong;
|
||||
Steps* m_pStepsPlayer[NUM_PLAYERS];
|
||||
|
||||
void InitSongArrayFromDisk();
|
||||
void CleanUpSongArray();
|
||||
void ReloadSongArray();
|
||||
|
||||
void ReadStatisticsFromDisk();
|
||||
void SaveStatisticsToDisk();
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern SongManager* SONGS; // global and accessable from anywhere in our program
|
||||
|
||||
|
||||
#endif
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include "Sprite.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include "GameInfo.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "IniFile.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
@@ -40,8 +40,8 @@ Sprite::Sprite()
|
||||
m_VertAlign = align_middle;
|
||||
|
||||
|
||||
if( GAMEINFO )
|
||||
m_bHasShadow = GAMEINFO->m_GameOptions.m_bShadows;
|
||||
if( PREFS )
|
||||
m_bHasShadow = PREFS->m_GameOptions.m_bShadows;
|
||||
else
|
||||
m_bHasShadow = true;
|
||||
|
||||
|
||||
+16
-13
@@ -20,7 +20,8 @@
|
||||
#include "RageMusic.h"
|
||||
#include "RageInput.h"
|
||||
|
||||
#include "GameInfo.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "SongManager.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "WindowManager.h"
|
||||
|
||||
@@ -377,7 +378,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
GameOptions &go = GAMEINFO->m_GameOptions;
|
||||
GameOptions &go = PREFS->m_GameOptions;
|
||||
switch( LOWORD(wParam) )
|
||||
{
|
||||
|
||||
@@ -472,7 +473,8 @@ HRESULT CreateObjects( HWND hWnd )
|
||||
SOUND = new RageSound( hWnd );
|
||||
MUSIC = new RageSoundStream;
|
||||
INPUT = new RageInput( hWnd );
|
||||
GAMEINFO= new GameInfo;
|
||||
PREFS = new PrefsManager;
|
||||
SONGS = new SongManager;
|
||||
SCREEN = new RageScreen( hWnd );
|
||||
|
||||
BringWindowToTop( hWnd );
|
||||
@@ -499,7 +501,7 @@ HRESULT CreateObjects( HWND hWnd )
|
||||
// go.m_iDisplayColor
|
||||
// );
|
||||
|
||||
WM->SystemMessage( ssprintf("Found %d songs.", GAMEINFO->m_pSongs.GetSize()) );
|
||||
WM->SystemMessage( ssprintf("Found %d songs.", SONGS->m_pSongs.GetSize()) );
|
||||
|
||||
|
||||
//WM->SetNewWindow( new WindowLoading );
|
||||
@@ -524,7 +526,8 @@ void DestroyObjects()
|
||||
DXUtil_Timer( TIMER_STOP );
|
||||
|
||||
SAFE_DELETE( WM );
|
||||
SAFE_DELETE( GAMEINFO );
|
||||
SAFE_DELETE( PREFS );
|
||||
SAFE_DELETE( SONGS );
|
||||
|
||||
SAFE_DELETE( INPUT );
|
||||
SAFE_DELETE( MUSIC );
|
||||
@@ -619,8 +622,8 @@ void Update()
|
||||
{
|
||||
DeviceI = diArray[i];
|
||||
|
||||
GAMEINFO->DeviceToPad( DeviceI, PadI );
|
||||
GAMEINFO->PadToPlayer( PadI, PlayerI );
|
||||
PREFS->DeviceToPad( DeviceI, PadI );
|
||||
PREFS->PadToPlayer( PadI, PlayerI );
|
||||
|
||||
WM->Input( DeviceI, PadI, PlayerI );
|
||||
}
|
||||
@@ -708,7 +711,7 @@ BOOL SwitchDisplayMode()//( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD
|
||||
|
||||
|
||||
// use GameOptions to get the display settings
|
||||
GameOptions &go = GAMEINFO->m_GameOptions;
|
||||
GameOptions &go = PREFS->m_GameOptions;
|
||||
bool bWindowed = go.m_bWindowed;
|
||||
DWORD dwWidth = go.m_iResolution;
|
||||
DWORD dwHeight = go.m_iResolution==640 ? 480 : 240;
|
||||
@@ -748,12 +751,12 @@ BOOL SwitchDisplayMode()//( BOOL bWindowed, DWORD dwWidth, DWORD dwHeight, DWORD
|
||||
|
||||
RestoreObjects();
|
||||
|
||||
if( GAMEINFO )
|
||||
if( PREFS )
|
||||
{
|
||||
GAMEINFO->m_GameOptions.m_bWindowed = bWindowed;
|
||||
GAMEINFO->m_GameOptions.m_iDisplayColor = dwBPP;
|
||||
GAMEINFO->m_GameOptions.m_iResolution = dwWidth;
|
||||
GAMEINFO->SaveConfigToDisk();
|
||||
PREFS->m_GameOptions.m_bWindowed = bWindowed;
|
||||
PREFS->m_GameOptions.m_iDisplayColor = dwBPP;
|
||||
PREFS->m_GameOptions.m_iResolution = dwWidth;
|
||||
PREFS->SavePrefsToDisk();
|
||||
}
|
||||
|
||||
if( WM )
|
||||
|
||||
+33
-13
@@ -384,11 +384,7 @@ SOURCE=.\WindowTitleMenu.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GameInfo.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GameInfo.h
|
||||
SOURCE=.\GameConstants.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -420,6 +416,14 @@ SOURCE=.\PlayerInput.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PrefsManager.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PrefsManager.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Song.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -428,6 +432,14 @@ SOURCE=.\song.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SongManager.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SongManager.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SoundSet.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -470,6 +482,14 @@ SOURCE=.\IniFile.cpp
|
||||
|
||||
SOURCE=.\IniFile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\XMLMarkup.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\XMLMarkup.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "System"
|
||||
|
||||
@@ -668,6 +688,14 @@ SOURCE=.\GradeDisplay.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GranularityIndicator.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GranularityIndicator.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MusicSortDisplay.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -792,14 +820,6 @@ SOURCE=.\GhostArrows.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GranularityIndicator.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GranularityIndicator.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GrayArrow.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#include "stdafx.h"
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
File: ThemeManager.h
|
||||
Class: ThemeManager
|
||||
|
||||
Desc: .
|
||||
Desc: See header.
|
||||
|
||||
Copyright (c) 2001 Chris Danford. All rights reserved.
|
||||
Copyright (c) 2001-2002 by the names listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -73,6 +74,7 @@ CString ThemeManager::ElementToAssetPath( ThemeElement te )
|
||||
case GRAPHIC_ARROWS_LEFT: sAssetPath = "Graphics\\arrows left 1x4"; break;
|
||||
case GRAPHIC_ARROWS_RIGHT: sAssetPath = "Graphics\\arrows right 1x4"; break;
|
||||
case GRAPHIC_EDIT_BACKGROUND: sAssetPath = "Graphics\\edit background"; break;
|
||||
case GRAPHIC_EDIT_SNAP_INDICATOR: sAssetPath = "Graphics\\edit snap indicator"; break;
|
||||
|
||||
case SOUND_FAILED: sAssetPath = "Sounds\\failed"; break;
|
||||
case SOUND_ASSIST: sAssetPath = "Sounds\\Assist"; break;
|
||||
@@ -87,6 +89,8 @@ CString ThemeManager::ElementToAssetPath( ThemeElement te )
|
||||
case SOUND_MENU_BACK: sAssetPath = "Sounds\\menu back"; break;
|
||||
case SOUND_TRAINING_MUSIC: sAssetPath = "Sounds\\training music"; break;
|
||||
case SOUND_INVALID: sAssetPath = "Sounds\\invalid"; break;
|
||||
case SOUND_EDIT_CHANGE_LINE: sAssetPath = "Sounds\\edit change line"; break;
|
||||
case SOUND_EDIT_CHANGE_SNAP: sAssetPath = "Sounds\\edit change snap"; break;
|
||||
|
||||
case FONT_OUTLINE: sAssetPath = "Fonts\\Outline"; break;
|
||||
case FONT_NORMAL: sAssetPath = "Fonts\\Normal"; break;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
File: ThemeManager.h
|
||||
Class: ThemeManager
|
||||
|
||||
Desc: .
|
||||
Desc: Manages which graphics and sounds are chosed to load. Every time
|
||||
a sound or graphic is loaded, it gets the path from the ThemeManager.
|
||||
|
||||
Copyright (c) 2001 Chris Danford. All rights reserved.
|
||||
Copyright (c) 2001-2002 by the names listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -67,6 +69,7 @@ enum ThemeElement {
|
||||
GRAPHIC_ARROWS_LEFT,
|
||||
GRAPHIC_ARROWS_RIGHT,
|
||||
GRAPHIC_EDIT_BACKGROUND,
|
||||
GRAPHIC_EDIT_SNAP_INDICATOR,
|
||||
|
||||
SOUND_FAILED,
|
||||
SOUND_ASSIST,
|
||||
@@ -81,6 +84,8 @@ enum ThemeElement {
|
||||
SOUND_MENU_BACK,
|
||||
SOUND_TRAINING_MUSIC,
|
||||
SOUND_INVALID,
|
||||
SOUND_EDIT_CHANGE_LINE,
|
||||
SOUND_EDIT_CHANGE_SNAP,
|
||||
|
||||
FONT_OUTLINE,
|
||||
FONT_NORMAL,
|
||||
|
||||
@@ -13,9 +13,9 @@ Class2=CSmpackageDlg
|
||||
|
||||
ResourceCount=3
|
||||
Resource1=IDR_MAINFRAME
|
||||
Resource2=IDD_MANAGER
|
||||
Resource2=IDD_INSTALL
|
||||
Class3=CSMPackageInstallDlg
|
||||
Resource3=IDD_INSTALL
|
||||
Resource3=IDD_MANAGER
|
||||
|
||||
[CLS:CSmpackageApp]
|
||||
Type=0
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "Steps.h"
|
||||
|
||||
#include "GameInfo.h" // for definition of GameMode
|
||||
#include "PrefsManager.h" // for definition of GameMode
|
||||
enum GameMode; // why is this needed?
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user