2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
#include "ScreenSelectGroup.h"
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "GameManager.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "SongManager.h"
|
|
|
|
|
#include "AnnouncerManager.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
#include "GameState.h"
|
2004-07-08 00:10:34 +00:00
|
|
|
#include "GameSoundManager.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include <map>
|
2003-04-13 21:17:14 +00:00
|
|
|
#include "ActorUtil.h"
|
2003-08-02 09:56:24 +00:00
|
|
|
#include "GameState.h"
|
2005-02-21 06:22:46 +00:00
|
|
|
#include "UnlockManager.h"
|
2003-11-07 20:10:38 +00:00
|
|
|
#include "MenuTimer.h"
|
2004-04-18 07:34:37 +00:00
|
|
|
#include "SongUtil.h"
|
2006-01-08 18:40:20 +00:00
|
|
|
#include "LocalizedString.h"
|
2006-08-17 18:52:46 +00:00
|
|
|
#include "song.h"
|
2002-08-27 03:59:22 +00:00
|
|
|
|
2003-03-10 01:28:53 +00:00
|
|
|
#define BANNER_WIDTH THEME->GetMetricF("ScreenSelectGroup","BannerWidth")
|
|
|
|
|
#define BANNER_HEIGHT THEME->GetMetricF("ScreenSelectGroup","BannerHeight")
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
|
2006-01-15 20:46:15 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenSelectGroup );
|
2002-07-12 19:35:19 +00:00
|
|
|
|
2006-01-08 19:49:14 +00:00
|
|
|
static LocalizedString ALL_MUSIC_STRING( "ScreenSelectGroup", "ALL MUSIC" );
|
2005-02-23 22:36:00 +00:00
|
|
|
void ScreenSelectGroup::Init()
|
|
|
|
|
{
|
2005-09-03 00:38:42 +00:00
|
|
|
ScreenWithMenuElements::Init();
|
|
|
|
|
|
2005-10-15 06:20:59 +00:00
|
|
|
ASSERT( PREFSMAN->m_bShowSelectGroup );
|
2002-12-15 10:25:20 +00:00
|
|
|
|
2003-02-03 05:53:59 +00:00
|
|
|
vector<Song*> aAllSongs;
|
2003-02-10 05:30:12 +00:00
|
|
|
SONGMAN->GetSongs( aAllSongs );
|
2002-07-12 19:35:19 +00:00
|
|
|
|
2002-08-18 23:20:18 +00:00
|
|
|
// Filter out Songs that can't be played by the current Style
|
2004-09-21 07:53:39 +00:00
|
|
|
for( int j=aAllSongs.size()-1; j>=0; j-- ) // foreach Song, back to front
|
2002-08-18 23:20:18 +00:00
|
|
|
{
|
2003-08-02 09:56:24 +00:00
|
|
|
bool DisplaySong = aAllSongs[j]->NormallyDisplayed();
|
|
|
|
|
|
2004-02-21 01:06:35 +00:00
|
|
|
if( UNLOCKMAN->SongIsLocked( aAllSongs[j] ) )
|
2004-01-24 22:55:59 +00:00
|
|
|
DisplaySong = false;
|
2003-08-02 09:56:24 +00:00
|
|
|
|
2004-06-28 07:26:00 +00:00
|
|
|
if( aAllSongs[j]->SongCompleteForStyle(GAMESTATE->GetCurrentStyle()) &&
|
2003-08-02 09:56:24 +00:00
|
|
|
DisplaySong )
|
2002-09-06 08:56:28 +00:00
|
|
|
continue;
|
|
|
|
|
|
2002-10-31 04:11:08 +00:00
|
|
|
aAllSongs.erase( aAllSongs.begin()+j, aAllSongs.begin()+j+1 );
|
2002-08-18 23:20:18 +00:00
|
|
|
}
|
2002-07-12 19:35:19 +00:00
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
// Add all group names to a map.
|
2006-01-22 01:00:06 +00:00
|
|
|
map<RString, RString> mapGroupNames;
|
2004-09-21 07:53:39 +00:00
|
|
|
for( unsigned i=0; i<aAllSongs.size(); i++ )
|
2002-11-11 04:53:31 +00:00
|
|
|
{
|
2006-01-22 01:00:06 +00:00
|
|
|
const RString& sGroupName = aAllSongs[i]->m_sGroupName;
|
2002-11-11 04:53:31 +00:00
|
|
|
mapGroupNames[ sGroupName ] = ""; // group name maps to nothing
|
2002-09-07 06:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-11 04:53:31 +00:00
|
|
|
// copy group names into a vector
|
2006-01-22 01:00:06 +00:00
|
|
|
vector<RString> asGroupNames;
|
2006-01-08 19:49:14 +00:00
|
|
|
asGroupNames.push_back( ALL_MUSIC_STRING ); // special group
|
2006-01-22 01:00:06 +00:00
|
|
|
for( map<RString, RString>::const_iterator iter = mapGroupNames.begin(); iter != mapGroupNames.end(); ++iter )
|
2002-11-11 19:02:33 +00:00
|
|
|
asGroupNames.push_back( iter->first );
|
2002-07-12 19:35:19 +00:00
|
|
|
|
2002-08-24 06:30:32 +00:00
|
|
|
// Add songs to the MusicList.
|
2003-10-19 19:59:11 +00:00
|
|
|
m_MusicList.Load();
|
2002-10-31 04:36:35 +00:00
|
|
|
for( unsigned g=0; g < asGroupNames.size(); g++ ) /* for each group */
|
2002-08-18 23:20:18 +00:00
|
|
|
{
|
2003-01-03 05:56:28 +00:00
|
|
|
vector<Song*> aSongsInGroup;
|
2002-08-24 06:30:32 +00:00
|
|
|
/* find all songs */
|
2004-09-21 07:53:39 +00:00
|
|
|
for( unsigned i=0; i<aAllSongs.size(); i++ ) // foreach Song
|
2002-07-12 19:35:19 +00:00
|
|
|
{
|
2002-08-24 20:36:29 +00:00
|
|
|
/* group 0 gets all songs */
|
2002-10-31 04:36:35 +00:00
|
|
|
if( g != 0 && aAllSongs[i]->m_sGroupName != asGroupNames[g] )
|
2002-08-24 06:30:32 +00:00
|
|
|
continue;
|
|
|
|
|
|
2002-10-31 04:23:39 +00:00
|
|
|
aSongsInGroup.push_back( aAllSongs[i] );
|
2002-08-18 23:20:18 +00:00
|
|
|
}
|
2002-07-12 19:35:19 +00:00
|
|
|
|
2004-04-18 07:34:37 +00:00
|
|
|
SongUtil::SortSongPointerArrayByTitle( aSongsInGroup );
|
2002-07-12 19:35:19 +00:00
|
|
|
|
2002-08-24 06:30:32 +00:00
|
|
|
m_MusicList.AddGroup();
|
|
|
|
|
m_MusicList.AddSongsToGroup(aSongsInGroup);
|
|
|
|
|
}
|
2002-07-12 19:35:19 +00:00
|
|
|
|
2002-05-20 08:59:37 +00:00
|
|
|
m_bChosen = false;
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprExplanation.SetName( "Explanation" );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprExplanation.Load( THEME->GetPathG("ScreenSelectGroup","explanation") );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_sprExplanation );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
// these guys get loaded SetSong and TweenToSong
|
2003-04-12 06:16:12 +00:00
|
|
|
m_Banner.SetName( "Banner" );
|
2003-07-03 06:38:57 +00:00
|
|
|
m_Banner.ScaleToClipped( BANNER_WIDTH, BANNER_HEIGHT );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_Banner );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprFrame.SetName( "Frame" );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprFrame.Load( THEME->GetPathG("ScreenSelectGroup","frame") );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_sprFrame );
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_textNumber.SetName( "Number" );
|
2004-07-25 07:22:31 +00:00
|
|
|
m_textNumber.LoadFromFont( THEME->GetPathF(m_sName, "num songs") );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textNumber );
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_sprContents.SetName( "Contents" );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprContents.Load( THEME->GetPathG("ScreenSelectGroup","contents") );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_sprContents );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_MusicList.SetName( "MusicList" );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_MusicList );
|
2002-08-24 20:36:29 +00:00
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_GroupList.SetName( "GroupList" );
|
2003-03-10 00:16:49 +00:00
|
|
|
m_GroupList.Load( asGroupNames );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_GroupList );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
|
2005-09-03 00:37:57 +00:00
|
|
|
m_soundChange.Load( THEME->GetPathS("ScreenSelectGroup","change"), true );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2004-04-12 20:11:36 +00:00
|
|
|
SOUND->PlayOnceFromAnnouncer( "select group intro" );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
AfterChange();
|
2002-08-24 20:36:29 +00:00
|
|
|
m_GroupList.SetSelection(0);
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-09-05 02:26:50 +00:00
|
|
|
void ScreenSelectGroup::Input( const InputEventPlus &input )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScreenSelectGroup::Input()" );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2004-05-01 23:19:33 +00:00
|
|
|
if( IsTransitioning() )
|
2002-05-20 08:59:37 +00:00
|
|
|
return;
|
|
|
|
|
|
2006-11-21 20:03:28 +00:00
|
|
|
ScreenWithMenuElements::Input( input ); // default input handler
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelectGroup::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
2006-02-24 00:20:41 +00:00
|
|
|
if( SM == SM_BeginFadingOut )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2005-10-13 22:17:13 +00:00
|
|
|
StartTransitioningScreen( SM_GoToNextScreen );
|
2004-05-08 06:43:06 +00:00
|
|
|
return;
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
2006-11-21 20:03:28 +00:00
|
|
|
ScreenWithMenuElements::HandleScreenMessage( SM );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSelectGroup::AfterChange()
|
|
|
|
|
{
|
2002-08-24 20:36:29 +00:00
|
|
|
int sel = m_GroupList.GetSelection();
|
|
|
|
|
m_MusicList.SetGroupNo(sel);
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString sSelectedGroupName = m_GroupList.GetSelectionName();
|
2006-01-08 18:40:20 +00:00
|
|
|
if( sSelectedGroupName == ALL_MUSIC_STRING.GetValue() )
|
2003-03-09 00:55:49 +00:00
|
|
|
m_Banner.LoadAllMusic();
|
|
|
|
|
else
|
2005-06-23 08:05:09 +00:00
|
|
|
m_Banner.LoadFromSongGroup( sSelectedGroupName );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-08-24 06:30:32 +00:00
|
|
|
const int iNumSongs = m_MusicList.GetNumSongs();
|
2002-08-13 23:26:46 +00:00
|
|
|
m_textNumber.SetText( ssprintf("%d", iNumSongs) );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-14 21:18:39 +00:00
|
|
|
void ScreenSelectGroup::MenuLeft( const InputEventPlus &input )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2006-09-14 21:18:39 +00:00
|
|
|
MenuUp( input );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-14 21:18:39 +00:00
|
|
|
void ScreenSelectGroup::MenuRight( const InputEventPlus &input )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2006-09-14 21:18:39 +00:00
|
|
|
MenuDown( input );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-14 21:18:39 +00:00
|
|
|
void ScreenSelectGroup::MenuUp( const InputEventPlus &input )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
|
|
|
|
if( m_bChosen )
|
|
|
|
|
return;
|
|
|
|
|
|
2002-08-24 20:36:29 +00:00
|
|
|
m_GroupList.Up();
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
AfterChange();
|
|
|
|
|
|
2005-09-03 00:37:57 +00:00
|
|
|
m_soundChange.Play();
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-14 21:18:39 +00:00
|
|
|
void ScreenSelectGroup::MenuDown( const InputEventPlus &input )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
|
|
|
|
if( m_bChosen )
|
|
|
|
|
return;
|
|
|
|
|
|
2002-08-24 20:36:29 +00:00
|
|
|
m_GroupList.Down();
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
AfterChange();
|
|
|
|
|
|
2005-09-03 00:37:57 +00:00
|
|
|
m_soundChange.Play();
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-14 21:18:39 +00:00
|
|
|
void ScreenSelectGroup::MenuStart( const InputEventPlus &input )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-03-12 03:44:55 +00:00
|
|
|
if( m_bChosen )
|
|
|
|
|
return;
|
|
|
|
|
|
2004-05-01 23:28:53 +00:00
|
|
|
SCREENMAN->PlayStartSound();
|
2004-05-01 23:19:33 +00:00
|
|
|
m_MenuTimer->Stop();
|
2002-05-20 08:59:37 +00:00
|
|
|
m_bChosen = true;
|
|
|
|
|
|
2005-02-24 12:27:30 +00:00
|
|
|
GAMESTATE->m_pCurSong.Set( NULL );
|
2006-01-08 18:40:20 +00:00
|
|
|
GAMESTATE->m_sPreferredSongGroup.Set( m_GroupList.GetSelectionName()==ALL_MUSIC_STRING.GetValue() ? GROUP_ALL : m_GroupList.GetSelectionName() );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2005-06-24 06:06:16 +00:00
|
|
|
if( GAMESTATE->m_sPreferredSongGroup == GROUP_ALL )
|
2006-02-14 11:30:53 +00:00
|
|
|
SOUND->PlayOnceFromAnnouncer( "select group comment all music" );
|
2002-05-20 08:59:37 +00:00
|
|
|
else
|
2006-02-14 11:30:53 +00:00
|
|
|
SOUND->PlayOnceFromAnnouncer( "select group comment general" );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2005-10-14 02:31:55 +00:00
|
|
|
this->PostScreenMessage( SM_BeginFadingOut, 0 );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-14 21:18:39 +00:00
|
|
|
void ScreenSelectGroup::MenuBack( const InputEventPlus &input )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2005-03-20 06:14:41 +00:00
|
|
|
Cancel( SM_GoToPrevScreen );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2005-10-14 02:31:55 +00:00
|
|
|
void ScreenSelectGroup::TweenOffScreen()
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2005-10-14 02:31:55 +00:00
|
|
|
ScreenWithMenuElements::TweenOffScreen();
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
OFF_COMMAND( m_sprExplanation );
|
|
|
|
|
OFF_COMMAND( m_sprFrame );
|
|
|
|
|
OFF_COMMAND( m_Banner );
|
|
|
|
|
OFF_COMMAND( m_textNumber );
|
|
|
|
|
OFF_COMMAND( m_sprContents );
|
|
|
|
|
OFF_COMMAND( m_MusicList );
|
|
|
|
|
OFF_COMMAND( m_GroupList );
|
2002-08-24 06:30:32 +00:00
|
|
|
m_MusicList.TweenOffScreen();
|
2002-08-24 20:36:29 +00:00
|
|
|
m_GroupList.TweenOffScreen();
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2005-10-14 03:11:50 +00:00
|
|
|
void ScreenSelectGroup::TweenOnScreen()
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2007-02-19 09:30:07 +00:00
|
|
|
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_sprExplanation );
|
|
|
|
|
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_sprFrame );
|
|
|
|
|
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_Banner );
|
|
|
|
|
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_textNumber );
|
|
|
|
|
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_sprContents );
|
|
|
|
|
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_MusicList );
|
|
|
|
|
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_GroupList );
|
2002-08-24 06:30:32 +00:00
|
|
|
m_MusicList.TweenOnScreen();
|
2002-08-24 20:36:29 +00:00
|
|
|
m_GroupList.TweenOnScreen();
|
2005-10-14 03:11:50 +00:00
|
|
|
|
|
|
|
|
ScreenWithMenuElements::TweenOnScreen();
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
2004-06-08 05:22:33 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|