Add sorts by meter
Choose a random dancing character on GameState::Reset()
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "NoteTypes.h"
|
||||
#include <math.h> // for fmodf
|
||||
#include "DancingCharacters.h"
|
||||
|
||||
|
||||
const float FADE_SECONDS = 1.0f;
|
||||
@@ -60,6 +61,14 @@ Background::Background()
|
||||
m_quadBorder[2].SetDiffuse( RageColor(0,0,0,1) );
|
||||
m_quadBorder[3].StretchTo( RectI(LEFT_EDGE,BOTTOM_EDGE,RIGHT_EDGE,SCREEN_BOTTOM) );
|
||||
m_quadBorder[3].SetDiffuse( RageColor(0,0,0,1) );
|
||||
|
||||
bool bOneOrMoreChars = false;
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
bOneOrMoreChars = true;
|
||||
if( bOneOrMoreChars )
|
||||
m_pDancingCharacters = new DancingCharacters;
|
||||
else
|
||||
m_pDancingCharacters = NULL;
|
||||
}
|
||||
|
||||
Background::~Background()
|
||||
@@ -416,8 +425,8 @@ void Background::Update( float fDeltaTime )
|
||||
}
|
||||
}
|
||||
|
||||
if( PREFSMAN->m_bShowDancingCharacters )
|
||||
m_DancingCharacters.Update( fDeltaTime );
|
||||
if( m_pDancingCharacters )
|
||||
m_pDancingCharacters->Update( fDeltaTime );
|
||||
|
||||
m_quadBGBrightness.Update( fDeltaTime );
|
||||
}
|
||||
@@ -438,8 +447,8 @@ void Background::DrawPrimitives()
|
||||
m_pFadingBGA->Draw();
|
||||
}
|
||||
|
||||
if( PREFSMAN->m_bShowDancingCharacters )
|
||||
m_DancingCharacters.Draw();
|
||||
if( m_pDancingCharacters )
|
||||
m_pDancingCharacters->Draw();
|
||||
|
||||
m_quadBGBrightness.Draw();
|
||||
for( int i=0; i<4; i++ )
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "ActorFrame.h"
|
||||
#include "BGAnimation.h"
|
||||
#include "song.h"
|
||||
#include "DancingCharacters.h"
|
||||
class DancingCharacters;
|
||||
|
||||
|
||||
class Background : public ActorFrame
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
protected:
|
||||
bool IsDangerVisible();
|
||||
|
||||
DancingCharacters m_DancingCharacters;
|
||||
DancingCharacters* m_pDancingCharacters;
|
||||
|
||||
BGAnimation m_BGADanger;
|
||||
|
||||
|
||||
@@ -43,27 +43,25 @@ const float MODEL_X_TWO_PLAYERS[NUM_PLAYERS] = { -8, 8 };
|
||||
|
||||
DancingCharacters::DancingCharacters()
|
||||
{
|
||||
if( PREFSMAN->m_bShowDancingCharacters )
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
if( !GAMESTATE->IsPlayerEnabled(p) )
|
||||
continue;
|
||||
if( !GAMESTATE->IsPlayerEnabled(p) )
|
||||
continue;
|
||||
|
||||
Character* pChar = GAMESTATE->m_pCurCharacters[p];
|
||||
if( !pChar )
|
||||
continue;
|
||||
if( GAMESTATE->GetNumPlayersEnabled()==2 )
|
||||
m_Character[p].SetX( MODEL_X_TWO_PLAYERS[p] );
|
||||
else
|
||||
m_Character[p].SetX( MODEL_X_ONE_PLAYER );
|
||||
m_Character[p].LoadMilkshapeAscii( pChar->GetModelPath() );
|
||||
m_Character[p].LoadMilkshapeAsciiBones( "rest", pChar->GetRestAnimationPath() );
|
||||
m_Character[p].LoadMilkshapeAsciiBones( "warmup", pChar->GetWarmUpAnimationPath() );
|
||||
m_Character[p].LoadMilkshapeAsciiBones( "dance", pChar->GetDanceAnimationPath() );
|
||||
m_Character[p].PlayAnimation( "rest" );
|
||||
this->AddChild( &m_Character[p] );
|
||||
}
|
||||
Character* pChar = GAMESTATE->m_pCurCharacters[p];
|
||||
if( !pChar )
|
||||
continue;
|
||||
|
||||
if( GAMESTATE->GetNumPlayersEnabled()==2 )
|
||||
m_Character[p].SetX( MODEL_X_TWO_PLAYERS[p] );
|
||||
else
|
||||
m_Character[p].SetX( MODEL_X_ONE_PLAYER );
|
||||
m_Character[p].LoadMilkshapeAscii( pChar->GetModelPath() );
|
||||
m_Character[p].LoadMilkshapeAsciiBones( "rest", pChar->GetRestAnimationPath() );
|
||||
m_Character[p].LoadMilkshapeAsciiBones( "warmup", pChar->GetWarmUpAnimationPath() );
|
||||
m_Character[p].LoadMilkshapeAsciiBones( "dance", pChar->GetDanceAnimationPath() );
|
||||
m_Character[p].PlayAnimation( "rest" );
|
||||
this->AddChild( &m_Character[p] );
|
||||
}
|
||||
|
||||
// initial camera sweep is still
|
||||
|
||||
@@ -119,6 +119,11 @@ CString SongSortOrderToString( SongSortOrder so )
|
||||
case SORT_MOST_PLAYED: return "PLAYERS BEST";
|
||||
case SORT_GRADE: return "TOP GRADE";
|
||||
case SORT_ARTIST: return "ARTIST";
|
||||
case SORT_EASY_METER: return "EASY METER";
|
||||
case SORT_MEDIUM_METER: return "MEDIUM METER";
|
||||
case SORT_HARD_METER: return "HARD METER";
|
||||
case SORT_SORT: return "SORT";
|
||||
case SORT_ROULETTE: return "ROULETTE";
|
||||
default:
|
||||
ASSERT(0);
|
||||
return "";
|
||||
|
||||
@@ -110,6 +110,9 @@ enum SongSortOrder {
|
||||
SORT_MOST_PLAYED,
|
||||
SORT_GRADE,
|
||||
SORT_ARTIST,
|
||||
SORT_EASY_METER,
|
||||
SORT_MEDIUM_METER,
|
||||
SORT_HARD_METER,
|
||||
SORT_SORT,
|
||||
SORT_ROULETTE,
|
||||
NUM_SORT_ORDERS,
|
||||
|
||||
@@ -88,17 +88,26 @@ void GameState::Reset()
|
||||
m_StoredPlayerOptions[p].Init();
|
||||
}
|
||||
m_SongOptions.Init();
|
||||
SAFE_DELETE( m_pPosition );
|
||||
m_pPosition = new NoteFieldPositioning("Positioning.ini");
|
||||
|
||||
for( p=0; p<NUM_PLAYERS; p++ )
|
||||
ApplyModifiers( (PlayerNumber)p, PREFSMAN->m_sDefaultModifiers );
|
||||
|
||||
for( p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
if( PREFSMAN->m_bShowDancingCharacters )
|
||||
m_pCurCharacters[p] = m_pCharacters[rand()%m_pCharacters.size()];
|
||||
else
|
||||
m_pCurCharacters[p] = NULL;
|
||||
}
|
||||
|
||||
for( p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
m_fSuperMeterGrowth[p] = 1;
|
||||
m_iCpuSkill[p] = 5;
|
||||
}
|
||||
|
||||
SAFE_DELETE( m_pPosition );
|
||||
m_pPosition = new NoteFieldPositioning("Positioning.ini");
|
||||
}
|
||||
|
||||
void GameState::Update( float fDelta )
|
||||
|
||||
@@ -21,11 +21,9 @@
|
||||
|
||||
MusicSortDisplay::MusicSortDisplay()
|
||||
{
|
||||
Load( THEME->GetPathToG(ssprintf("MusicSortDisplay icons 1x%d",NUM_SORT_ORDERS)) );
|
||||
StopAnimating();
|
||||
}
|
||||
|
||||
void MusicSortDisplay::Set( SongSortOrder so )
|
||||
{
|
||||
SetState( so );
|
||||
Load( THEME->GetPathToG(ssprintf("MusicSortDisplay %s",SongSortOrderToString(so).c_str())) );
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "RageDisplay.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include "Banner.h"
|
||||
#include "Notes.h"
|
||||
|
||||
|
||||
#define NUM_WHEEL_ITEMS min( MAX_WHEEL_ITEMS, THEME->GetMetricI("MusicWheel","NumWheelItems") )
|
||||
@@ -393,6 +394,15 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
|
||||
case SORT_ARTIST:
|
||||
SortSongPointerArrayByArtist( arraySongs );
|
||||
break;
|
||||
case SORT_EASY_METER:
|
||||
SortSongPointerArrayByMeter( arraySongs, DIFFICULTY_EASY );
|
||||
break;
|
||||
case SORT_MEDIUM_METER:
|
||||
SortSongPointerArrayByMeter( arraySongs, DIFFICULTY_MEDIUM );
|
||||
break;
|
||||
case SORT_HARD_METER:
|
||||
SortSongPointerArrayByMeter( arraySongs, DIFFICULTY_HARD );
|
||||
break;
|
||||
default:
|
||||
ASSERT(0); // unhandled SortOrder
|
||||
}
|
||||
@@ -413,6 +423,9 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
|
||||
case SORT_MOST_PLAYED: bUseSections = false; break;
|
||||
case SORT_GRADE: bUseSections = true; break;
|
||||
case SORT_ARTIST: bUseSections = true; break;
|
||||
case SORT_EASY_METER: bUseSections = true; break;
|
||||
case SORT_MEDIUM_METER: bUseSections = true; break;
|
||||
case SORT_HARD_METER: bUseSections = true; break;
|
||||
case SORT_ROULETTE: bUseSections = false; break;
|
||||
default: ASSERT( 0 );
|
||||
}
|
||||
@@ -761,6 +774,9 @@ void MusicWheel::Update( float fDeltaTime )
|
||||
case SORT_ARTIST:
|
||||
case SORT_MOST_PLAYED:
|
||||
case SORT_ROULETTE:
|
||||
case SORT_EASY_METER:
|
||||
case SORT_MEDIUM_METER:
|
||||
case SORT_HARD_METER:
|
||||
// Look for the last selected song or course
|
||||
if( GAMESTATE->m_pCurCourse )
|
||||
SelectCourse( GAMESTATE->m_pCurCourse );
|
||||
@@ -774,6 +790,32 @@ void MusicWheel::Update( float fDeltaTime )
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
// Change difficulty for sorts by meter
|
||||
switch( GAMESTATE->m_SongSortOrder )
|
||||
{
|
||||
case SORT_EASY_METER:
|
||||
{
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
if( GAMESTATE->IsPlayerEnabled(p) )
|
||||
GAMESTATE->m_PreferredDifficulty[p] = DIFFICULTY_EASY;
|
||||
}
|
||||
break;
|
||||
case SORT_MEDIUM_METER:
|
||||
{
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
if( GAMESTATE->IsPlayerEnabled(p) )
|
||||
GAMESTATE->m_PreferredDifficulty[p] = DIFFICULTY_MEDIUM;
|
||||
}
|
||||
break;
|
||||
case SORT_HARD_METER:
|
||||
{
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
if( GAMESTATE->IsPlayerEnabled(p) )
|
||||
GAMESTATE->m_PreferredDifficulty[p] = DIFFICULTY_HARD;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
SCREENMAN->PostMessageToTopScreen( SM_SongChanged, 0 );
|
||||
RebuildMusicWheelItems();
|
||||
TweenOnScreen(true);
|
||||
@@ -1284,6 +1326,27 @@ CString MusicWheel::GetSectionNameFromSongAndSort( const Song* pSong, SongSortOr
|
||||
}
|
||||
return "NO DATA";
|
||||
}
|
||||
case SORT_EASY_METER:
|
||||
{
|
||||
Notes* pNotes = pSong->GetNotes(GAMESTATE->GetCurrentStyleDef()->m_NotesType,DIFFICULTY_EASY);
|
||||
if( pNotes )
|
||||
return ssprintf("%02d", pNotes->GetMeter() );
|
||||
return "N/A";
|
||||
}
|
||||
case SORT_MEDIUM_METER:
|
||||
{
|
||||
Notes* pNotes = pSong->GetNotes(GAMESTATE->GetCurrentStyleDef()->m_NotesType,DIFFICULTY_MEDIUM);
|
||||
if( pNotes )
|
||||
return ssprintf("%02d", pNotes->GetMeter() );
|
||||
return "N/A";
|
||||
}
|
||||
case SORT_HARD_METER:
|
||||
{
|
||||
Notes* pNotes = pSong->GetNotes(GAMESTATE->GetCurrentStyleDef()->m_NotesType,DIFFICULTY_HARD);
|
||||
if( pNotes )
|
||||
return ssprintf("%02d", pNotes->GetMeter() );
|
||||
return "N/A";
|
||||
}
|
||||
case SORT_SORT:
|
||||
return "";
|
||||
default:
|
||||
|
||||
@@ -36,7 +36,7 @@ OptionRow g_BackgroundOptionsLines[NUM_BACKGROUND_OPTIONS_LINES] = {
|
||||
OptionRow( "Mode", "OFF","ANIMATIONS","VISUALIZATIONS","RANDOM MOVIES" ),
|
||||
OptionRow( "Brightness", "0%","10%","20%","30%","40%","50%","60%","70%","80%","90%","100%" ),
|
||||
OptionRow( "Danger", "HIDE","SHOW" ),
|
||||
OptionRow( "Dancing\nCharacters", "HIDE","SHOW" ),
|
||||
OptionRow( "Dancing\nCharacters", "DEFAULT TO OFF","DEFAULT TO RANDOM" ),
|
||||
OptionRow( "Random\nBackgrounds", "5","10","15","20" ),
|
||||
};
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ void ScreenPlayerOptions::ImportOptions()
|
||||
// fill in character names
|
||||
//
|
||||
m_OptionRow[PO_CHARACTER].choices.clear();
|
||||
m_OptionRow[PO_CHARACTER].choices.push_back( "OFF" );
|
||||
m_OptionRow[PO_CHARACTER].choices.push_back( "OFF" );
|
||||
for( i=0; i<GAMESTATE->m_pCharacters.size(); i++ )
|
||||
{
|
||||
CString s = GAMESTATE->m_pCharacters[i]->m_sName;
|
||||
@@ -312,13 +312,13 @@ void ScreenPlayerOptions::ExportOptions()
|
||||
GAMESTATE->m_pCurNotes[p] = vNotes[ m_iSelectedOption[p][PO_STEP] ];
|
||||
}
|
||||
|
||||
if( m_iSelectedOption[p][PO_CHARACTER] > 0 )
|
||||
if( m_iSelectedOption[p][PO_CHARACTER] == 0 )
|
||||
GAMESTATE->m_pCurCharacters[p] = NULL;
|
||||
else
|
||||
{
|
||||
int choice = m_iSelectedOption[p][PO_CHARACTER] - 1;
|
||||
GAMESTATE->m_pCurCharacters[p] = GAMESTATE->m_pCharacters[choice];
|
||||
}
|
||||
else
|
||||
GAMESTATE->m_pCurCharacters[p] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1349,6 +1349,45 @@ void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers )
|
||||
song_sort_val.clear();
|
||||
}
|
||||
|
||||
template <Difficulty dc>
|
||||
int CompareSongByMeter(const Song* pSong1, const Song* pSong2)
|
||||
{
|
||||
Notes* pNotes1 = pSong1->GetNotes( GAMESTATE->GetCurrentStyleDef()->m_NotesType, dc );
|
||||
Notes* pNotes2 = pSong2->GetNotes( GAMESTATE->GetCurrentStyleDef()->m_NotesType, dc );
|
||||
|
||||
int iMeter1 = pNotes1 ? pNotes1->GetMeter() : 0;
|
||||
int iMeter2 = pNotes2 ? pNotes2->GetMeter() : 0;
|
||||
|
||||
if( iMeter1 < iMeter2 )
|
||||
return true;
|
||||
if( iMeter1 > iMeter2 )
|
||||
return false;
|
||||
return CompareSongPointersByTitle( pSong1, pSong2 );
|
||||
}
|
||||
|
||||
// Hack for VC6: There's no other way I could get this to work. Types of templated functions
|
||||
// are totally hosed if a templated function is used on the RHS or as a parameter a function
|
||||
// (e.g. to sort()).
|
||||
int CompareSongByEasyMeter(const Song* pSong1, const Song* pSong2)
|
||||
{ return CompareSongByMeter<DIFFICULTY_EASY>(pSong1,pSong2); };
|
||||
|
||||
int CompareSongByMediumMeter(const Song* pSong1, const Song* pSong2)
|
||||
{ return CompareSongByMeter<DIFFICULTY_MEDIUM>(pSong1,pSong2); };
|
||||
|
||||
int CompareSongByHardMeter(const Song* pSong1, const Song* pSong2)
|
||||
{ return CompareSongByMeter<DIFFICULTY_HARD>(pSong1,pSong2); };
|
||||
|
||||
void SortSongPointerArrayByMeter( vector<Song*> &arraySongPointers, Difficulty dc )
|
||||
{
|
||||
switch( dc )
|
||||
{
|
||||
case DIFFICULTY_EASY: sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongByEasyMeter ); break;
|
||||
case DIFFICULTY_MEDIUM: sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongByMediumMeter ); break;
|
||||
case DIFFICULTY_HARD: sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongByHardMeter ); break;
|
||||
default: ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool Song::NormallyDisplayed() const
|
||||
{
|
||||
if(!PREFSMAN->m_bHiddenSongs) return true;
|
||||
|
||||
@@ -272,6 +272,7 @@ void SortSongPointerArrayByArtist( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByGroupAndDifficulty( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByGroupAndTitle( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByMeter( vector<Song*> &arraySongPointers, Difficulty dc );
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user