cleanups, fix memleaks
This commit is contained in:
@@ -54,13 +54,6 @@ ScreenSelectGroup::ScreenSelectGroup( CString sClassName ) : Screen( sClassName
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
// The new process by which the group and song lists are formed
|
|
||||||
// is bizarre and complex but yields the end result that songs
|
|
||||||
// and groups that do not contain any steps for the current
|
|
||||||
// style (such as solo) are omitted. Bear with me!
|
|
||||||
// -- dro kulix
|
|
||||||
|
|
||||||
|
|
||||||
vector<Song*> aAllSongs;
|
vector<Song*> aAllSongs;
|
||||||
SONGMAN->GetSongs( aAllSongs );
|
SONGMAN->GetSongs( aAllSongs );
|
||||||
|
|
||||||
@@ -69,14 +62,8 @@ ScreenSelectGroup::ScreenSelectGroup( CString sClassName ) : Screen( sClassName
|
|||||||
{
|
{
|
||||||
bool DisplaySong = aAllSongs[j]->NormallyDisplayed();
|
bool DisplaySong = aAllSongs[j]->NormallyDisplayed();
|
||||||
|
|
||||||
// check if song is locked
|
if( UNLOCKSYS->SongIsLocked( aAllSongs[j] ) )
|
||||||
if (PREFSMAN->m_bUseUnlockSystem)
|
DisplaySong = false;
|
||||||
{
|
|
||||||
UnlockEntry* m_UnlockSong = UNLOCKSYS->FindSong( aAllSongs[j] );
|
|
||||||
|
|
||||||
if (m_UnlockSong)
|
|
||||||
DisplaySong = (m_UnlockSong->SelectableWheel());
|
|
||||||
}
|
|
||||||
|
|
||||||
if( aAllSongs[j]->SongCompleteForStyle(GAMESTATE->GetCurrentStyleDef()) &&
|
if( aAllSongs[j]->SongCompleteForStyle(GAMESTATE->GetCurrentStyleDef()) &&
|
||||||
DisplaySong )
|
DisplaySong )
|
||||||
|
|||||||
@@ -59,6 +59,21 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
|||||||
CString IconCommand = ICON_COMMAND;
|
CString IconCommand = ICON_COMMAND;
|
||||||
for(i=1; i <= NumUnlocks; i++)
|
for(i=1; i <= NumUnlocks; i++)
|
||||||
{
|
{
|
||||||
|
// get pertaining UnlockEntry
|
||||||
|
CString SongTitle = DISPLAYED_SONG(i);
|
||||||
|
if (USE_UNLOCKS_DAT == 1)
|
||||||
|
if ((unsigned)i <= UNLOCKSYS->m_SongEntries.size() )
|
||||||
|
SongTitle = UNLOCKSYS->m_SongEntries[i-1].m_sSongName;
|
||||||
|
LOG->Trace("UnlockScreen: Searching for %s", SongTitle.c_str());
|
||||||
|
|
||||||
|
const UnlockEntry *pSong = UNLOCKSYS->FindLockEntry( SongTitle );
|
||||||
|
|
||||||
|
if( pSong == NULL)
|
||||||
|
{
|
||||||
|
LOG->Trace("Can't find song %s", SongTitle.c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Sprite* entry = new Sprite;
|
Sprite* entry = new Sprite;
|
||||||
|
|
||||||
// new unlock graphic
|
// new unlock graphic
|
||||||
@@ -68,22 +83,6 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
|||||||
entry->SetName( ssprintf("Unlock%d",i) );
|
entry->SetName( ssprintf("Unlock%d",i) );
|
||||||
SET_XY( *entry );
|
SET_XY( *entry );
|
||||||
|
|
||||||
// get pertaining UnlockEntry
|
|
||||||
CString SongTitle = DISPLAYED_SONG(i);
|
|
||||||
if (USE_UNLOCKS_DAT == 1)
|
|
||||||
if ((unsigned)i <= UNLOCKSYS->m_SongEntries.size() )
|
|
||||||
SongTitle = UNLOCKSYS->m_SongEntries[i-1].m_sSongName;
|
|
||||||
LOG->Trace("UnlockScreen: Searching for %s", SongTitle.c_str());
|
|
||||||
|
|
||||||
UnlockEntry *pSong = UNLOCKSYS->FindLockEntry( SongTitle );
|
|
||||||
|
|
||||||
if( pSong == NULL)
|
|
||||||
{
|
|
||||||
LOG->Trace("Can't find song %s", SongTitle.c_str());
|
|
||||||
delete entry; // oops, memory leak
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
entry->Command(IconCommand);
|
entry->Command(IconCommand);
|
||||||
Unlocks.push_back(entry);
|
Unlocks.push_back(entry);
|
||||||
|
|
||||||
@@ -114,11 +113,6 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
|||||||
|
|
||||||
for(i = 1; i <= NumUnlocks; i++)
|
for(i = 1; i <= NumUnlocks; i++)
|
||||||
{
|
{
|
||||||
BitmapText* text = new BitmapText;
|
|
||||||
|
|
||||||
text->LoadFromFont( THEME->GetPathToF("ScreenUnlock text") );
|
|
||||||
text->SetHorizAlign( Actor::align_left );
|
|
||||||
|
|
||||||
CString DisplayedSong = DISPLAYED_SONG(i);
|
CString DisplayedSong = DISPLAYED_SONG(i);
|
||||||
if (USE_UNLOCKS_DAT == 1)
|
if (USE_UNLOCKS_DAT == 1)
|
||||||
if ((unsigned)i <= UNLOCKSYS->m_SongEntries.size() )
|
if ((unsigned)i <= UNLOCKSYS->m_SongEntries.size() )
|
||||||
@@ -129,6 +123,10 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
|||||||
if ( pSong == NULL ) // no such song
|
if ( pSong == NULL ) // no such song
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
BitmapText* text = new BitmapText;
|
||||||
|
|
||||||
|
text->LoadFromFont( THEME->GetPathToF("ScreenUnlock text") );
|
||||||
|
text->SetHorizAlign( Actor::align_left );
|
||||||
text->SetZoom(ScrollingTextZoom);
|
text->SetZoom(ScrollingTextZoom);
|
||||||
|
|
||||||
if (pSong && pSong->m_pSong != NULL)
|
if (pSong && pSong->m_pSong != NULL)
|
||||||
@@ -241,12 +239,6 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
|||||||
|
|
||||||
unsigned NextIcon = LastUnlocks[LastUnlocks.size() - i];
|
unsigned NextIcon = LastUnlocks[LastUnlocks.size() - i];
|
||||||
|
|
||||||
Sprite* NewIcon = new Sprite;
|
|
||||||
BitmapText* NewText = new BitmapText;
|
|
||||||
|
|
||||||
NewText->LoadFromFont( THEME->GetPathToF("ScreenUnlock text") );
|
|
||||||
NewText->SetHorizAlign( Actor::align_left );
|
|
||||||
|
|
||||||
CString DisplayedSong = DISPLAYED_SONG(NextIcon);
|
CString DisplayedSong = DISPLAYED_SONG(NextIcon);
|
||||||
if (USE_UNLOCKS_DAT == 1)
|
if (USE_UNLOCKS_DAT == 1)
|
||||||
{
|
{
|
||||||
@@ -257,21 +249,20 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
|||||||
DisplayedSong.MakeUpper();
|
DisplayedSong.MakeUpper();
|
||||||
UnlockEntry *pSong = UNLOCKSYS->FindLockEntry(DisplayedSong);
|
UnlockEntry *pSong = UNLOCKSYS->FindLockEntry(DisplayedSong);
|
||||||
|
|
||||||
NewText->SetZoom(UNLOCK_TEXT_SCROLL_ZOOM);
|
|
||||||
|
|
||||||
CString title;
|
|
||||||
CString subtitle;
|
|
||||||
|
|
||||||
if (pSong->m_pSong == NULL)
|
if (pSong->m_pSong == NULL)
|
||||||
continue;
|
continue;
|
||||||
else
|
|
||||||
{
|
BitmapText* NewText = new BitmapText;
|
||||||
title = pSong->m_pSong->GetDisplayMainTitle();
|
|
||||||
subtitle = pSong->m_pSong->GetDisplaySubTitle();
|
NewText->LoadFromFont( THEME->GetPathToF("ScreenUnlock text") );
|
||||||
}
|
NewText->SetHorizAlign( Actor::align_left );
|
||||||
|
|
||||||
|
CString title = pSong->m_pSong->GetDisplayMainTitle();
|
||||||
|
CString subtitle = pSong->m_pSong->GetDisplaySubTitle();
|
||||||
|
|
||||||
if( subtitle != "" )
|
if( subtitle != "" )
|
||||||
title = title + "\n" + subtitle;
|
title = title + "\n" + subtitle;
|
||||||
|
NewText->SetZoom(UNLOCK_TEXT_SCROLL_ZOOM);
|
||||||
NewText->SetMaxWidth( MaxWidth );
|
NewText->SetMaxWidth( MaxWidth );
|
||||||
NewText->SetText( title );
|
NewText->SetText( title );
|
||||||
|
|
||||||
@@ -282,6 +273,7 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
|||||||
NewText->Command( ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;", SECS_PER_CYCLE * (NumUnlocks + 2 * i - 2), SECS_PER_CYCLE * ((ScrollingTextRows - i) * 2 + 1 ), (ScrollingTextStartY + (ScrollingTextEndY - ScrollingTextStartY) * (ScrollingTextRows - i + 0.5) / ScrollingTextRows )) );
|
NewText->Command( ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;", SECS_PER_CYCLE * (NumUnlocks + 2 * i - 2), SECS_PER_CYCLE * ((ScrollingTextRows - i) * 2 + 1 ), (ScrollingTextStartY + (ScrollingTextEndY - ScrollingTextStartY) * (ScrollingTextRows - i + 0.5) / ScrollingTextRows )) );
|
||||||
|
|
||||||
// new unlock graphic
|
// new unlock graphic
|
||||||
|
Sprite* NewIcon = new Sprite;
|
||||||
NewIcon->Load( THEME->GetPathToG(ssprintf("ScreenUnlock %d icon", NextIcon)) );
|
NewIcon->Load( THEME->GetPathToG(ssprintf("ScreenUnlock %d icon", NextIcon)) );
|
||||||
|
|
||||||
// set graphic location
|
// set graphic location
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ bool UnlockSystem::SongIsLocked( const Song *song )
|
|||||||
|
|
||||||
bool UnlockSystem::SongIsRoulette( const Song *song )
|
bool UnlockSystem::SongIsRoulette( const Song *song )
|
||||||
{
|
{
|
||||||
|
if( !PREFSMAN->m_bUseUnlockSystem )
|
||||||
|
return false;
|
||||||
|
|
||||||
const UnlockEntry *p = FindSong( song );
|
const UnlockEntry *p = FindSong( song );
|
||||||
|
|
||||||
return p && p->m_iRouletteSeed != 0;
|
return p && p->m_iRouletteSeed != 0;
|
||||||
@@ -286,21 +289,6 @@ bool UnlockSystem::LoadFromDATFile()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UnlockEntry::SelectableWheel() const
|
|
||||||
{
|
|
||||||
return !isLocked; // cached
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UnlockEntry::SelectableRoulette() const
|
|
||||||
{
|
|
||||||
if( !isLocked )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if( m_iRouletteSeed != 0 )
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
float UnlockSystem::DancePointsUntilNextUnlock()
|
float UnlockSystem::DancePointsUntilNextUnlock()
|
||||||
{
|
{
|
||||||
float fSmallestPoints = 400000000; // or an arbitrarily large value
|
float fSmallestPoints = 400000000; // or an arbitrarily large value
|
||||||
|
|||||||
@@ -39,10 +39,6 @@ struct UnlockEntry
|
|||||||
bool isLocked; // cached locked tag
|
bool isLocked; // cached locked tag
|
||||||
bool IsCourse() const { return m_pCourse != NULL; }
|
bool IsCourse() const { return m_pCourse != NULL; }
|
||||||
|
|
||||||
// if song is selectable vai two means
|
|
||||||
bool SelectableWheel() const;
|
|
||||||
bool SelectableRoulette() const;
|
|
||||||
|
|
||||||
void UpdateLocked(); // updates isLocked
|
void UpdateLocked(); // updates isLocked
|
||||||
|
|
||||||
void UpdateData();
|
void UpdateData();
|
||||||
@@ -68,10 +64,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
UnlockSystem();
|
UnlockSystem();
|
||||||
|
|
||||||
|
// returns # of points till next unlock - used for ScreenUnlock
|
||||||
float DancePointsUntilNextUnlock();
|
float DancePointsUntilNextUnlock();
|
||||||
float ArcadePointsUntilNextUnlock();
|
float ArcadePointsUntilNextUnlock();
|
||||||
float SongPointsUntilNextUnlock();
|
float SongPointsUntilNextUnlock();
|
||||||
// returns # of points till next unlock - used for ScreenUnlock
|
|
||||||
|
|
||||||
// Used on select screens:
|
// Used on select screens:
|
||||||
bool SongIsLocked( const Song *song );
|
bool SongIsLocked( const Song *song );
|
||||||
@@ -95,8 +91,8 @@ public:
|
|||||||
float UnlockClearStage();
|
float UnlockClearStage();
|
||||||
float UnlockToasty();
|
float UnlockToasty();
|
||||||
|
|
||||||
void RouletteUnlock( const Song *song );
|
|
||||||
// unlocks given song in roulette
|
// unlocks given song in roulette
|
||||||
|
void RouletteUnlock( const Song *song );
|
||||||
|
|
||||||
// read and write unlock in values
|
// read and write unlock in values
|
||||||
bool ReadValues( CString filename);
|
bool ReadValues( CString filename);
|
||||||
@@ -106,8 +102,9 @@ public:
|
|||||||
|
|
||||||
UnlockEntry *FindLockEntry( CString lockname );
|
UnlockEntry *FindLockEntry( CString lockname );
|
||||||
|
|
||||||
// so class can access FindSong
|
// All locked songs are stored here
|
||||||
friend class ScreenSelectGroup;
|
vector<UnlockEntry> m_SongEntries;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UnlockEntry *FindSong( const Song *pSong );
|
UnlockEntry *FindSong( const Song *pSong );
|
||||||
UnlockEntry *FindCourse( const Course *pCourse );
|
UnlockEntry *FindCourse( const Course *pCourse );
|
||||||
@@ -115,10 +112,6 @@ private:
|
|||||||
void InitRouletteSeeds(int MaxRouletteSlot);
|
void InitRouletteSeeds(int MaxRouletteSlot);
|
||||||
// makes RouletteSeeds more efficient
|
// makes RouletteSeeds more efficient
|
||||||
|
|
||||||
public: // XXX
|
|
||||||
// All locked songs are stored here
|
|
||||||
vector<UnlockEntry> m_SongEntries;
|
|
||||||
|
|
||||||
// float m_fScores[NUM_UNLOCK_TYPES];
|
// float m_fScores[NUM_UNLOCK_TYPES];
|
||||||
|
|
||||||
// unlock values, cached
|
// unlock values, cached
|
||||||
|
|||||||
Reference in New Issue
Block a user