cleanups, fix memleaks
This commit is contained in:
@@ -53,13 +53,6 @@ ScreenSelectGroup::ScreenSelectGroup( CString sClassName ) : Screen( sClassName
|
||||
|
||||
unsigned i;
|
||||
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;
|
||||
SONGMAN->GetSongs( aAllSongs );
|
||||
@@ -69,14 +62,8 @@ ScreenSelectGroup::ScreenSelectGroup( CString sClassName ) : Screen( sClassName
|
||||
{
|
||||
bool DisplaySong = aAllSongs[j]->NormallyDisplayed();
|
||||
|
||||
// check if song is locked
|
||||
if (PREFSMAN->m_bUseUnlockSystem)
|
||||
{
|
||||
UnlockEntry* m_UnlockSong = UNLOCKSYS->FindSong( aAllSongs[j] );
|
||||
|
||||
if (m_UnlockSong)
|
||||
DisplaySong = (m_UnlockSong->SelectableWheel());
|
||||
}
|
||||
if( UNLOCKSYS->SongIsLocked( aAllSongs[j] ) )
|
||||
DisplaySong = false;
|
||||
|
||||
if( aAllSongs[j]->SongCompleteForStyle(GAMESTATE->GetCurrentStyleDef()) &&
|
||||
DisplaySong )
|
||||
|
||||
@@ -59,6 +59,21 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
||||
CString IconCommand = ICON_COMMAND;
|
||||
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;
|
||||
|
||||
// new unlock graphic
|
||||
@@ -68,22 +83,6 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
||||
entry->SetName( ssprintf("Unlock%d",i) );
|
||||
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);
|
||||
Unlocks.push_back(entry);
|
||||
|
||||
@@ -114,11 +113,6 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
||||
|
||||
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);
|
||||
if (USE_UNLOCKS_DAT == 1)
|
||||
if ((unsigned)i <= UNLOCKSYS->m_SongEntries.size() )
|
||||
@@ -129,6 +123,10 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
||||
if ( pSong == NULL ) // no such song
|
||||
continue;
|
||||
|
||||
BitmapText* text = new BitmapText;
|
||||
|
||||
text->LoadFromFont( THEME->GetPathToF("ScreenUnlock text") );
|
||||
text->SetHorizAlign( Actor::align_left );
|
||||
text->SetZoom(ScrollingTextZoom);
|
||||
|
||||
if (pSong && pSong->m_pSong != NULL)
|
||||
@@ -241,12 +239,6 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
||||
|
||||
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);
|
||||
if (USE_UNLOCKS_DAT == 1)
|
||||
{
|
||||
@@ -257,21 +249,20 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
||||
DisplayedSong.MakeUpper();
|
||||
UnlockEntry *pSong = UNLOCKSYS->FindLockEntry(DisplayedSong);
|
||||
|
||||
NewText->SetZoom(UNLOCK_TEXT_SCROLL_ZOOM);
|
||||
|
||||
CString title;
|
||||
CString subtitle;
|
||||
|
||||
if (pSong->m_pSong == NULL)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
title = pSong->m_pSong->GetDisplayMainTitle();
|
||||
subtitle = pSong->m_pSong->GetDisplaySubTitle();
|
||||
}
|
||||
|
||||
BitmapText* NewText = new BitmapText;
|
||||
|
||||
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 != "" )
|
||||
title = title + "\n" + subtitle;
|
||||
NewText->SetZoom(UNLOCK_TEXT_SCROLL_ZOOM);
|
||||
NewText->SetMaxWidth( MaxWidth );
|
||||
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 )) );
|
||||
|
||||
// new unlock graphic
|
||||
Sprite* NewIcon = new Sprite;
|
||||
NewIcon->Load( THEME->GetPathToG(ssprintf("ScreenUnlock %d icon", NextIcon)) );
|
||||
|
||||
// set graphic location
|
||||
|
||||
@@ -96,6 +96,9 @@ bool UnlockSystem::SongIsLocked( const Song *song )
|
||||
|
||||
bool UnlockSystem::SongIsRoulette( const Song *song )
|
||||
{
|
||||
if( !PREFSMAN->m_bUseUnlockSystem )
|
||||
return false;
|
||||
|
||||
const UnlockEntry *p = FindSong( song );
|
||||
|
||||
return p && p->m_iRouletteSeed != 0;
|
||||
@@ -286,21 +289,6 @@ bool UnlockSystem::LoadFromDATFile()
|
||||
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 fSmallestPoints = 400000000; // or an arbitrarily large value
|
||||
|
||||
@@ -39,10 +39,6 @@ struct UnlockEntry
|
||||
bool isLocked; // cached locked tag
|
||||
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 UpdateData();
|
||||
@@ -68,10 +64,10 @@ public:
|
||||
*/
|
||||
UnlockSystem();
|
||||
|
||||
// returns # of points till next unlock - used for ScreenUnlock
|
||||
float DancePointsUntilNextUnlock();
|
||||
float ArcadePointsUntilNextUnlock();
|
||||
float SongPointsUntilNextUnlock();
|
||||
// returns # of points till next unlock - used for ScreenUnlock
|
||||
|
||||
// Used on select screens:
|
||||
bool SongIsLocked( const Song *song );
|
||||
@@ -95,8 +91,8 @@ public:
|
||||
float UnlockClearStage();
|
||||
float UnlockToasty();
|
||||
|
||||
void RouletteUnlock( const Song *song );
|
||||
// unlocks given song in roulette
|
||||
void RouletteUnlock( const Song *song );
|
||||
|
||||
// read and write unlock in values
|
||||
bool ReadValues( CString filename);
|
||||
@@ -106,8 +102,9 @@ public:
|
||||
|
||||
UnlockEntry *FindLockEntry( CString lockname );
|
||||
|
||||
// so class can access FindSong
|
||||
friend class ScreenSelectGroup;
|
||||
// All locked songs are stored here
|
||||
vector<UnlockEntry> m_SongEntries;
|
||||
|
||||
private:
|
||||
UnlockEntry *FindSong( const Song *pSong );
|
||||
UnlockEntry *FindCourse( const Course *pCourse );
|
||||
@@ -115,10 +112,6 @@ private:
|
||||
void InitRouletteSeeds(int MaxRouletteSlot);
|
||||
// makes RouletteSeeds more efficient
|
||||
|
||||
public: // XXX
|
||||
// All locked songs are stored here
|
||||
vector<UnlockEntry> m_SongEntries;
|
||||
|
||||
// float m_fScores[NUM_UNLOCK_TYPES];
|
||||
|
||||
// unlock values, cached
|
||||
|
||||
Reference in New Issue
Block a user