Files
itgmania212121/stepmania/src/ScreenSelectMusic.cpp
T

1069 lines
30 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-05-20 08:59:37 +00:00
#include "ScreenSelectMusic.h"
#include "ScreenManager.h"
#include "PrefsManager.h"
#include "SongManager.h"
#include "GameManager.h"
2004-07-08 00:10:34 +00:00
#include "GameSoundManager.h"
2002-05-20 08:59:37 +00:00
#include "GameConstantsAndTypes.h"
#include "RageLog.h"
#include "InputMapper.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
#include "CodeDetector.h"
#include "ThemeManager.h"
2003-08-03 00:13:55 +00:00
#include "Steps.h"
2003-04-13 21:17:14 +00:00
#include "ActorUtil.h"
#include "RageTextureManager.h"
#include "Course.h"
2003-09-08 07:21:41 +00:00
#include "ProfileManager.h"
2005-07-01 05:07:22 +00:00
#include "Profile.h"
2003-11-07 20:10:38 +00:00
#include "MenuTimer.h"
2003-11-16 04:45:12 +00:00
#include "LightsManager.h"
2005-02-16 03:25:45 +00:00
#include "StatsManager.h"
#include "StepsUtil.h"
#include "Foreach.h"
#include "Style.h"
#include "PlayerState.h"
2005-02-12 21:03:39 +00:00
#include "CommonMetrics.h"
#include "BannerCache.h"
2005-09-03 06:12:43 +00:00
#include "song.h"
#include "InputEventPlus.h"
2003-04-13 21:17:14 +00:00
const int NUM_SCORE_DIGITS = 9;
2006-08-06 02:01:27 +00:00
#define SHOW_OPTIONS_MESSAGE_SECONDS THEME->GetMetricF( m_sName, "ShowOptionsMessageSeconds" )
2002-05-20 08:59:37 +00:00
AutoScreenMessage( SM_AllowOptionsMenuRepeat )
AutoScreenMessage( SM_SongChanged )
AutoScreenMessage( SM_SortOrderChanging )
AutoScreenMessage( SM_SortOrderChanged )
2002-05-20 08:59:37 +00:00
2006-01-22 01:00:06 +00:00
static RString g_sCDTitlePath;
static bool g_bWantFallbackCdTitle;
static bool g_bCDTitleWaiting = false;
2006-01-22 01:00:06 +00:00
static RString g_sBannerPath;
static bool g_bBannerWaiting = false;
static bool g_bSampleMusicWaiting = false;
static RageTimer g_StartedLoadingAt(RageZeroTimer);
2006-01-15 20:46:15 +00:00
REGISTER_SCREEN_CLASS( ScreenSelectMusic );
2006-01-15 19:49:02 +00:00
ScreenSelectMusic::ScreenSelectMusic()
2002-05-20 08:59:37 +00:00
{
2005-04-01 05:26:59 +00:00
if( PREFSMAN->m_bScreenTestMode )
{
2005-07-25 03:59:24 +00:00
GAMESTATE->m_PlayMode.Set( PLAY_MODE_REGULAR );
2005-05-07 08:34:20 +00:00
GAMESTATE->m_pCurStyle.Set( GAMEMAN->GameAndStringToStyle(GAMEMAN->GetDefaultGame(),"versus") );
GAMESTATE->JoinPlayer( PLAYER_1 );
2005-04-01 05:26:59 +00:00
GAMESTATE->m_MasterPlayerNumber = PLAYER_1;
}
}
void ScreenSelectMusic::Init()
{
2006-01-15 19:48:11 +00:00
SAMPLE_MUSIC_DELAY.Load( m_sName, "SampleMusicDelay" );
DO_ROULETTE_ON_MENU_TIMER.Load( m_sName, "DoRouletteOnMenuTimer" );
ALIGN_MUSIC_BEATS.Load( m_sName, "AlignMusicBeat" );
CODES.Load( m_sName, "Codes" );
MUSIC_WHEEL_TYPE.Load( m_sName, "MusicWheelType" );
SELECT_MENU_AVAILABLE.Load( m_sName, "SelectMenuAvailable" );
MODE_MENU_AVAILABLE.Load( m_sName, "ModeMenuAvailable" );
LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );
/* Finish any previous stage. It's OK to call this when we havn't played a stage yet.
* Do this before anything that might look at GAMESTATE->m_iCurrentStageIndex. */
GAMESTATE->FinishStage();
m_bSelectIsDown = false; // used by UpdateSelectButton
2005-04-26 06:41:57 +00:00
ScreenWithMenuElements::Init();
/* Cache: */
m_sSectionMusicPath = THEME->GetPathS(m_sName,"section music");
m_sSortMusicPath = THEME->GetPathS(m_sName,"sort music");
m_sRouletteMusicPath = THEME->GetPathS(m_sName,"roulette music");
m_sRandomMusicPath = THEME->GetPathS(m_sName,"random music");
m_sCourseMusicPath = THEME->GetPathS(m_sName,"course music");
m_sFallbackCDTitlePath = THEME->GetPathG(m_sName,"fallback cdtitle");
2005-06-30 22:41:22 +00:00
m_TexturePreload.Load( m_sFallbackCDTitlePath );
if( PREFSMAN->m_BannerCache != PrefsManager::BNCACHE_OFF )
{
m_TexturePreload.Load( Banner::SongBannerTexture(THEME->GetPathG("Banner","all music")) );
m_TexturePreload.Load( Banner::SongBannerTexture(THEME->GetPathG("Common","fallback banner")) );
m_TexturePreload.Load( Banner::SongBannerTexture(THEME->GetPathG("Banner","roulette")) );
m_TexturePreload.Load( Banner::SongBannerTexture(THEME->GetPathG("Banner","random")) );
2005-09-09 05:51:29 +00:00
m_TexturePreload.Load( Banner::SongBannerTexture(THEME->GetPathG("Banner","mode")) );
}
2004-06-28 07:26:00 +00:00
if( GAMESTATE->m_pCurStyle == NULL )
RageException::Throw( "The Style has not been set. A theme must set the Style before loading ScreenSelectMusic." );
if( GAMESTATE->m_PlayMode == PLAY_MODE_INVALID )
RageException::Throw( "The PlayMode has not been set. A theme must set the PlayMode before loading ScreenSelectMusic." );
/* Load low-res banners, if needed. */
BANNERCACHE->Demand();
2005-05-31 07:37:57 +00:00
m_MusicWheel.SetName( "MusicWheel" );
m_MusicWheel.Load( MUSIC_WHEEL_TYPE );
SET_XY( m_MusicWheel );
2003-05-02 20:36:26 +00:00
this->AddChild( &m_MusicWheel );
2003-04-13 21:17:14 +00:00
// this is loaded SetSong and TweenToSong
m_Banner.SetName( "Banner" );
2004-05-15 18:35:03 +00:00
m_Banner.SetZTestMode( ZTEST_WRITE_ON_PASS ); // do have to pass the z test
SET_XY( m_Banner );
this->AddChild( &m_Banner );
m_sprCDTitleFront.SetName( "CDTitle" );
2004-05-22 02:24:40 +00:00
m_sprCDTitleFront.Load( THEME->GetPathG(m_sName,"fallback cdtitle") );
SET_XY( m_sprCDTitleFront );
COMMAND( m_sprCDTitleFront, "Front" );
this->AddChild( &m_sprCDTitleFront );
m_sprCDTitleBack.SetName( "CDTitle" );
2004-05-22 02:24:40 +00:00
m_sprCDTitleBack.Load( THEME->GetPathG(m_sName,"fallback cdtitle") );
SET_XY( m_sprCDTitleBack );
COMMAND( m_sprCDTitleBack, "Back" );
this->AddChild( &m_sprCDTitleBack );
2004-06-03 08:22:02 +00:00
FOREACH_HumanPlayer( p )
2002-05-20 08:59:37 +00:00
{
2003-04-13 21:17:14 +00:00
m_sprHighScoreFrame[p].SetName( ssprintf("ScoreFrameP%d",p+1) );
2004-05-22 02:24:40 +00:00
m_sprHighScoreFrame[p].Load( THEME->GetPathG(m_sName,ssprintf("score frame p%d",p+1)) );
SET_XY( m_sprHighScoreFrame[p] );
this->AddChild( &m_sprHighScoreFrame[p] );
2003-04-13 21:17:14 +00:00
m_textHighScore[p].SetName( ssprintf("ScoreP%d",p+1) );
2004-07-25 06:29:50 +00:00
m_textHighScore[p].LoadFromFont( THEME->GetPathF(m_sName,"score") );
m_textHighScore[p].SetShadowLength( 0 );
m_textHighScore[p].RunCommands( CommonMetrics::PLAYER_COLOR.GetValue(p) );
SET_XY( m_textHighScore[p] );
this->AddChild( &m_textHighScore[p] );
}
2004-05-22 02:24:40 +00:00
m_soundDifficultyEasier.Load( THEME->GetPathS(m_sName,"difficulty easier") );
m_soundDifficultyHarder.Load( THEME->GetPathS(m_sName,"difficulty harder") );
m_soundOptionsChange.Load( THEME->GetPathS(m_sName,"options") );
m_soundLocked.Load( THEME->GetPathS(m_sName,"locked") );
2005-05-04 01:08:35 +00:00
m_soundSelectPressed.Load( THEME->GetPathS(m_sName,"select down"), true );
2002-05-20 08:59:37 +00:00
2005-07-22 22:38:53 +00:00
this->SortByDrawOrder();
}
void ScreenSelectMusic::BeginScreen()
{
ScreenWithMenuElements::BeginScreen();
2006-08-08 04:01:55 +00:00
OPTIONS_MENU_AVAILABLE.Load( m_sName, "OptionsMenuAvailable" );
m_MusicWheel.BeginScreen();
2006-08-18 01:26:22 +00:00
2002-06-14 22:25:22 +00:00
m_bMadeChoice = false;
m_bGoToOptions = false;
m_bAllowOptionsMenu = m_bAllowOptionsMenuRepeat = false;
2005-06-23 01:49:47 +00:00
ZERO( m_iSelection );
2002-05-20 08:59:37 +00:00
AfterMusicChange();
2004-02-13 05:39:15 +00:00
2005-07-22 22:38:53 +00:00
SOUND->PlayOnceFromAnnouncer( "select music intro" );
}
2002-05-20 08:59:37 +00:00
ScreenSelectMusic::~ScreenSelectMusic()
{
LOG->Trace( "ScreenSelectMusic::~ScreenSelectMusic()" );
BANNERCACHE->Undemand();
2002-05-20 08:59:37 +00:00
}
/* If bForce is true, the next request will be started even if it might cause a skip. */
void ScreenSelectMusic::CheckBackgroundRequests( bool bForce )
{
if( g_bCDTitleWaiting )
2002-10-06 16:56:58 +00:00
{
/* The CDTitle is normally very small, so we don't bother waiting to display it. */
2006-01-22 01:00:06 +00:00
RString sPath;
2006-08-14 18:28:02 +00:00
if( !m_BackgroundLoader.IsCacheFileFinished(g_sCDTitlePath, sPath) )
return;
2006-08-14 18:28:02 +00:00
g_bCDTitleWaiting = false;
2006-08-14 18:28:02 +00:00
RString sCDTitlePath = sPath;
2006-08-14 18:28:02 +00:00
if( sCDTitlePath.empty() || !IsAFile(sCDTitlePath) )
sCDTitlePath = g_bWantFallbackCdTitle? m_sFallbackCDTitlePath:RString("");
2006-08-14 18:28:02 +00:00
if( !sCDTitlePath.empty() )
{
TEXTUREMAN->DisableOddDimensionWarning();
m_sprCDTitleFront.Load( sCDTitlePath );
m_sprCDTitleBack.Load( sCDTitlePath );
TEXTUREMAN->EnableOddDimensionWarning();
}
2006-08-14 18:28:02 +00:00
m_BackgroundLoader.FinishedWithCachedFile( g_sCDTitlePath );
}
2004-09-10 03:37:33 +00:00
/* Loading the rest can cause small skips, so don't do it until the wheel settles.
* Do load if we're transitioning out, though, so we don't miss starting the music
* for the options screen if a song is selected quickly. Also, don't do this
* if the wheel is locked, since we're just bouncing around after selecting TYPE_RANDOM,
* and it'll take a while before the wheel will settle. */
if( !m_MusicWheel.IsSettled() && !m_MusicWheel.WheelIsLocked() && !bForce )
return;
if( g_bBannerWaiting )
{
2005-04-23 06:20:26 +00:00
if( m_Banner.GetTweenTimeLeft() > 0 )
return;
2006-01-22 01:00:06 +00:00
RString sPath;
2005-04-23 06:19:36 +00:00
bool bFreeCache = false;
if( TEXTUREMAN->IsTextureRegistered( Sprite::SongBannerTexture(g_sBannerPath) ) )
{
/* If the file is already loaded into a texture, it's finished,
* and we only do this to honor the HighQualTime value. */
sPath = g_sBannerPath;
}
else
{
if( !m_BackgroundLoader.IsCacheFileFinished( g_sBannerPath, sPath ) )
return;
2005-04-23 06:19:36 +00:00
bFreeCache = true;
}
g_bBannerWaiting = false;
2005-04-23 10:19:47 +00:00
m_Banner.Load( sPath, true );
2005-04-23 06:19:36 +00:00
if( bFreeCache )
m_BackgroundLoader.FinishedWithCachedFile( g_sBannerPath );
}
/* Nothing else is going. Start the music, if we havn't yet. */
if( g_bSampleMusicWaiting )
{
/* Don't start the music sample when moving fast. */
2006-03-29 08:37:54 +00:00
if( g_StartedLoadingAt.Ago() < SAMPLE_MUSIC_DELAY && !bForce )
2006-03-29 08:11:07 +00:00
return;
g_bSampleMusicWaiting = false;
2006-03-29 08:11:07 +00:00
SOUND->PlayMusic(
m_sSampleMusicToPlay, m_pSampleMusicTimingData,
true, m_fSampleStartSeconds, m_fSampleLengthSeconds,
1.5f, /* fade out for 1.5 seconds */
ALIGN_MUSIC_BEATS );
2002-10-06 16:56:58 +00:00
}
}
void ScreenSelectMusic::Update( float fDeltaTime )
{
Screen::Update( fDeltaTime );
CheckBackgroundRequests( false );
}
void ScreenSelectMusic::Input( const InputEventPlus &input )
2002-05-20 08:59:37 +00:00
{
2003-02-25 00:33:42 +00:00
// LOG->Trace( "ScreenSelectMusic::Input()" );
2004-01-11 09:42:37 +00:00
// debugging?
2004-06-11 21:35:57 +00:00
// I just like being able to see untransliterated titles occasionally.
if( input.DeviceI.device == DEVICE_KEYBOARD && input.DeviceI.button == KEY_F9 )
2003-02-11 23:52:18 +00:00
{
if( input.type != IET_FIRST_PRESS )
return;
2005-05-06 20:41:05 +00:00
PREFSMAN->m_bShowNativeLanguage.Set( !PREFSMAN->m_bShowNativeLanguage );
2006-08-10 04:29:48 +00:00
m_MusicWheel.RebuildWheelItems();
2003-02-11 23:52:18 +00:00
return;
}
if( !input.GameI.IsValid() )
return; // don't care
2004-01-21 06:14:49 +00:00
2006-09-14 03:43:34 +00:00
PlayerNumber pn = input.pn;
2004-01-21 06:14:49 +00:00
if( !GAMESTATE->IsHumanPlayer(pn) )
return;
2005-04-26 04:22:53 +00:00
// Check for "Press START again for options" button press
if( m_bMadeChoice &&
2006-09-14 20:52:34 +00:00
input.MenuI == MENU_BUTTON_START &&
input.type != IET_RELEASE &&
2006-08-08 03:45:56 +00:00
OPTIONS_MENU_AVAILABLE.GetValue() )
{
2006-03-01 08:37:04 +00:00
if( m_bGoToOptions )
return; /* got it already */
if( !m_bAllowOptionsMenu )
return; /* not allowed */
2006-09-13 02:59:05 +00:00
if( !m_bAllowOptionsMenuRepeat && input.type == IET_REPEAT )
{
return; /* not allowed yet */
}
m_bGoToOptions = true;
SCREENMAN->PlayStartSound();
this->PlayCommand( "ShowEnteringOptions" );
// Re-queue SM_BeginFadingOut, since ShowEnteringOptions may have
// short-circuited animations.
this->ClearMessageQueue( SM_BeginFadingOut );
this->PostScreenMessage( SM_BeginFadingOut, this->GetTweenTimeLeft() );
2005-06-11 10:30:13 +00:00
return;
}
if( IsTransitioning() )
return; // ignore
2005-09-18 11:43:32 +00:00
if( m_bMadeChoice )
return; // ignore
2004-01-11 09:42:37 +00:00
UpdateSelectButton();
2005-04-26 06:41:57 +00:00
2006-09-14 20:52:34 +00:00
if( input.MenuI == MENU_BUTTON_SELECT )
{
if( input.type == IET_FIRST_PRESS )
m_MusicWheel.Move( 0 );
return;
}
2006-09-14 04:07:52 +00:00
if( SELECT_MENU_AVAILABLE && INPUTMAPPER->IsBeingPressed( MENU_BUTTON_SELECT, pn ) )
2005-04-26 06:41:57 +00:00
{
if( input.type == IET_FIRST_PRESS )
2005-04-26 06:41:57 +00:00
{
2006-09-14 20:52:34 +00:00
switch( input.MenuI )
2005-04-26 06:41:57 +00:00
{
case MENU_BUTTON_LEFT:
ChangeDifficulty( pn, -1 );
return;
2005-04-26 06:41:57 +00:00
case MENU_BUTTON_RIGHT:
ChangeDifficulty( pn, +1 );
return;
2005-04-26 06:41:57 +00:00
case MENU_BUTTON_START:
2005-04-27 04:35:55 +00:00
if( MODE_MENU_AVAILABLE )
m_MusicWheel.ChangeSort( SORT_MODE_MENU );
else
m_soundLocked.Play();
return;
2005-04-26 06:41:57 +00:00
}
}
return;
2005-04-26 06:41:57 +00:00
}
2006-09-14 20:52:34 +00:00
switch( input.MenuI )
2003-01-02 03:00:53 +00:00
{
case MENU_BUTTON_RIGHT:
case MENU_BUTTON_LEFT:
{
/* If we're rouletting, hands off. */
if( m_MusicWheel.IsRouletting() )
return;
bool bLeftIsDown = false;
bool bRightIsDown = false;
FOREACH_EnabledPlayer( p )
2005-04-26 06:41:57 +00:00
{
2006-09-14 04:07:52 +00:00
bLeftIsDown |= INPUTMAPPER->IsBeingPressed( MENU_BUTTON_LEFT, p );
bRightIsDown |= INPUTMAPPER->IsBeingPressed( MENU_BUTTON_RIGHT, p );
2005-04-26 06:41:57 +00:00
}
bool bBothDown = bLeftIsDown && bRightIsDown;
bool bNeitherDown = !bLeftIsDown && !bRightIsDown;
2004-01-11 09:42:37 +00:00
if( bNeitherDown )
{
/* Both buttons released. */
m_MusicWheel.Move( 0 );
}
else if( bBothDown )
2004-01-11 09:42:37 +00:00
{
m_MusicWheel.Move( 0 );
if( input.type == IET_FIRST_PRESS )
{
2006-09-14 20:52:34 +00:00
switch( input.MenuI )
{
case MENU_BUTTON_LEFT:
m_MusicWheel.ChangeMusicUnlessLocked( -1 );
break;
case MENU_BUTTON_RIGHT:
m_MusicWheel.ChangeMusicUnlessLocked( +1 );
break;
}
}
}
else if( bLeftIsDown )
{
if( input.type != IET_RELEASE )
m_MusicWheel.Move( -1 );
}
else if( bRightIsDown )
{
if( input.type != IET_RELEASE )
m_MusicWheel.Move( +1 );
}
else
{
ASSERT(0);
}
// Reset the repeat timer when the button is released.
// This fixes jumping when you release Left and Right after entering the sort
// code at the same if L & R aren't released at the exact same time.
if( input.type == IET_RELEASE )
{
FOREACH_HumanPlayer( p )
{
2006-09-14 04:07:52 +00:00
INPUTMAPPER->ResetKeyRepeat( MENU_BUTTON_LEFT, p );
INPUTMAPPER->ResetKeyRepeat( MENU_BUTTON_RIGHT, p );
}
2004-01-11 09:42:37 +00:00
}
}
break;
2003-01-02 03:00:53 +00:00
}
if( input.type == IET_FIRST_PRESS && DetectCodes(input) )
return;
Screen::Input( input );
}
bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input )
{
if( CodeDetector::EnteredEasierDifficulty(input.GameI.controller) )
2002-08-20 21:00:56 +00:00
{
if( GAMESTATE->IsAnExtraStage() )
m_soundLocked.Play();
else
ChangeDifficulty( input.pn, -1 );
}
else if( CodeDetector::EnteredHarderDifficulty(input.GameI.controller) )
{
if( GAMESTATE->IsAnExtraStage() )
m_soundLocked.Play();
else
ChangeDifficulty( input.pn, +1 );
}
else if( CodeDetector::EnteredModeMenu(input.GameI.controller) )
{
if( MODE_MENU_AVAILABLE )
m_MusicWheel.ChangeSort( SORT_MODE_MENU );
else
m_soundLocked.Play();
}
else if( CodeDetector::EnteredNextSort(input.GameI.controller) )
{
if( ( GAMESTATE->IsExtraStage() && !PREFSMAN->m_bPickExtraStage ) || GAMESTATE->IsExtraStage2() )
m_soundLocked.Play();
else
m_MusicWheel.NextSort();
}
else if( !GAMESTATE->IsExtraStage() && !GAMESTATE->IsExtraStage2() && CodeDetector::DetectAndAdjustMusicOptions(input.GameI.controller) )
{
m_soundOptionsChange.Play();
MESSAGEMAN->Broadcast( ssprintf("PlayerOptionsChangedP%i", input.pn+1) );
MESSAGEMAN->Broadcast( "SongOptionsChanged" );
}
else
{
return false;
}
return true;
}
2002-05-20 08:59:37 +00:00
void ScreenSelectMusic::UpdateSelectButton()
2005-04-26 06:41:57 +00:00
{
bool bSelectIsDown = false;
2006-09-14 03:43:34 +00:00
FOREACH_EnabledPlayer( pn )
2006-09-14 04:07:52 +00:00
bSelectIsDown |= INPUTMAPPER->IsBeingPressed( MENU_BUTTON_SELECT, pn );
2005-04-26 06:41:57 +00:00
if( !SELECT_MENU_AVAILABLE )
bSelectIsDown = false;
/* If m_soundSelectPressed isn't loaded yet, wait until it is before we do this. */
if( m_bSelectIsDown != bSelectIsDown && m_soundSelectPressed.IsLoaded() )
2005-04-26 06:41:57 +00:00
{
2005-05-04 01:08:35 +00:00
if( bSelectIsDown )
m_soundSelectPressed.Play();
2005-04-26 06:41:57 +00:00
m_bSelectIsDown = bSelectIsDown;
if( bSelectIsDown )
MESSAGEMAN->Broadcast( "SelectMenuOn" );
else
MESSAGEMAN->Broadcast( "SelectMenuOff" );
}
}
void ScreenSelectMusic::ChangeDifficulty( PlayerNumber pn, int dir )
2002-05-20 08:59:37 +00:00
{
LOG->Trace( "ScreenSelectMusic::ChangeDifficulty( %d, %d )", pn, dir );
2002-05-20 08:59:37 +00:00
2004-06-03 08:22:02 +00:00
ASSERT( GAMESTATE->IsHumanPlayer(pn) );
2006-08-17 01:42:06 +00:00
if( GAMESTATE->m_pCurSong )
{
2006-08-17 01:23:25 +00:00
m_iSelection[pn] += dir;
if( CLAMP(m_iSelection[pn],0,m_vpSteps.size()-1) )
return;
// the user explicity switched difficulties. Update the preferred difficulty
GAMESTATE->ChangePreferredDifficulty( pn, m_vpSteps[ m_iSelection[pn] ]->GetDifficulty() );
2006-08-17 01:42:06 +00:00
}
else if( GAMESTATE->m_pCurCourse )
{
2006-08-17 01:23:25 +00:00
m_iSelection[pn] += dir;
if( CLAMP(m_iSelection[pn],0,m_vpTrails.size()-1) )
return;
2004-06-03 08:22:02 +00:00
2006-08-17 01:23:25 +00:00
// the user explicity switched difficulties. Update the preferred difficulty
GAMESTATE->ChangePreferredCourseDifficulty( pn, m_vpTrails[ m_iSelection[pn] ]->m_CourseDifficulty );
2006-08-17 01:42:06 +00:00
}
else
{
2006-08-17 01:23:25 +00:00
if( !GAMESTATE->ChangePreferredDifficulty( pn, dir ) )
return;
}
2006-08-17 01:19:34 +00:00
2006-08-17 01:23:25 +00:00
vector<PlayerNumber> vpns;
FOREACH_HumanPlayer( p )
{
if( pn == p || GAMESTATE->DifficultiesLocked() )
{
m_iSelection[p] = m_iSelection[pn];
vpns.push_back( p );
}
}
AfterStepsOrTrailChange( vpns );
2006-08-17 01:19:34 +00:00
if( dir < 0 )
m_soundDifficultyEasier.Play();
else
m_soundDifficultyHarder.Play();
2002-05-20 08:59:37 +00:00
}
void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_AllowOptionsMenuRepeat )
2002-05-20 08:59:37 +00:00
{
m_bAllowOptionsMenuRepeat = true;
}
else if( SM == SM_MenuTimer )
{
2002-08-20 21:00:56 +00:00
if( m_MusicWheel.IsRouletting() )
{
2006-09-15 01:47:24 +00:00
MenuStart( InputEventPlus() );
m_MenuTimer->SetSeconds( 15 );
m_MenuTimer->Start();
2002-08-20 21:00:56 +00:00
}
else if( DO_ROULETTE_ON_MENU_TIMER )
2002-08-20 21:00:56 +00:00
{
2006-08-17 02:47:35 +00:00
if( m_MusicWheel.GetSelectedSong() == NULL && m_MusicWheel.GetSelectedCourse() == NULL )
{
m_MusicWheel.StartRoulette();
m_MenuTimer->SetSeconds( 15 );
m_MenuTimer->Start();
}
else
{
2006-09-15 01:47:24 +00:00
MenuStart( InputEventPlus() );
}
2002-08-20 21:00:56 +00:00
}
else
{
// Finish sort changing so that the wheel can respond immediately to our
// request to choose random.
m_MusicWheel.FinishChangingSorts();
2006-08-17 02:47:35 +00:00
if( m_MusicWheel.GetSelectedSong() == NULL && m_MusicWheel.GetSelectedCourse() == NULL )
m_MusicWheel.StartRandom();
2006-08-17 02:47:35 +00:00
2006-09-15 01:47:24 +00:00
MenuStart( InputEventPlus() );
2002-08-20 21:00:56 +00:00
}
2004-05-08 06:19:14 +00:00
return;
}
else if( SM == SM_GoToPrevScreen )
{
/* We may have stray SM_SongChanged messages from the music wheel. We can't
* handle them anymore, since the title menu (and attract screens) reset
* the game state, so just discard them. */
ClearMessageQueue();
}
else if( SM == SM_BeginFadingOut )
{
m_bAllowOptionsMenu = false;
if( OPTIONS_MENU_AVAILABLE && !m_bGoToOptions )
this->PlayCommand( "HidePressStartForOptions" );
this->PostScreenMessage( SM_GoToNextScreen, this->GetTweenTimeLeft() );
}
else if( SM == SM_GoToNextScreen )
{
2005-07-12 05:52:52 +00:00
if( !m_bGoToOptions )
2003-07-26 23:05:16 +00:00
SOUND->StopMusic();
}
else if( SM == SM_SongChanged )
{
2002-06-30 23:19:33 +00:00
AfterMusicChange();
}
else if( SM == SM_SortOrderChanging ) /* happens immediately */
{
2006-08-16 22:17:58 +00:00
this->PlayCommand( "SortChange" );
}
else if( SM == SM_GainFocus )
{
2004-05-22 23:57:01 +00:00
CodeDetector::RefreshCacheItems( CODES );
}
else if( SM == SM_LoseFocus )
{
2004-05-22 23:57:01 +00:00
CodeDetector::RefreshCacheItems(); /* reset for other screens */
2002-05-20 08:59:37 +00:00
}
2006-09-14 03:44:27 +00:00
ScreenWithMenuElements::HandleScreenMessage( SM );
2002-05-20 08:59:37 +00:00
}
2006-09-15 01:47:24 +00:00
void ScreenSelectMusic::MenuStart( const InputEventPlus &input )
2002-05-20 08:59:37 +00:00
{
if( input.type != IET_FIRST_PRESS )
return;
2003-01-02 23:20:18 +00:00
/* If false, we don't have a selection just yet. */
2006-08-10 04:29:48 +00:00
if( !m_MusicWheel.Select() )
2002-09-07 09:37:27 +00:00
return;
// a song was selected
2006-08-17 02:49:54 +00:00
if( m_MusicWheel.GetSelectedSong() != NULL )
2002-05-20 08:59:37 +00:00
{
2006-08-17 02:49:54 +00:00
const bool bIsNew = PROFILEMAN->IsSongNew( m_MusicWheel.GetSelectedSong() );
bool bIsHard = false;
FOREACH_HumanPlayer( p )
2002-09-07 09:37:27 +00:00
{
2006-08-17 02:49:54 +00:00
if( GAMESTATE->m_pCurSteps[p] && GAMESTATE->m_pCurSteps[p]->GetMeter() >= 10 )
bIsHard = true;
2004-06-02 07:22:55 +00:00
}
2006-08-17 02:49:54 +00:00
/* See if this song is a repeat. If we're in event mode, only check the last five songs. */
bool bIsRepeat = false;
int i = 0;
if( GAMESTATE->IsEventMode() )
i = max( 0, int(STATSMAN->m_vPlayedStageStats.size())-5 );
for( ; i < (int)STATSMAN->m_vPlayedStageStats.size(); ++i )
if( STATSMAN->m_vPlayedStageStats[i].vpPlayedSongs.back() == m_MusicWheel.GetSelectedSong() )
bIsRepeat = true;
/* Don't complain about repeats if the user didn't get to pick. */
if( GAMESTATE->IsExtraStage() && !PREFSMAN->m_bPickExtraStage )
bIsRepeat = false;
if( bIsRepeat )
SOUND->PlayOnceFromAnnouncer( "select music comment repeat" );
else if( bIsNew )
SOUND->PlayOnceFromAnnouncer( "select music comment new" );
else if( bIsHard )
SOUND->PlayOnceFromAnnouncer( "select music comment hard" );
else
SOUND->PlayOnceFromAnnouncer( "select music comment general" );
2002-09-07 09:37:27 +00:00
2006-08-17 02:49:54 +00:00
/* If we're in event mode, we may have just played a course (putting us
* in course mode). Make sure we're in a single song mode. */
if( GAMESTATE->IsCourseMode() )
GAMESTATE->m_PlayMode.Set( PLAY_MODE_REGULAR );
}
else if( m_MusicWheel.GetSelectedCourse() != NULL )
{
SOUND->PlayOnceFromAnnouncer( "select course comment general" );
2004-06-02 07:22:55 +00:00
2006-08-17 02:49:54 +00:00
Course *pCourse = m_MusicWheel.GetSelectedCourse();
ASSERT( pCourse );
GAMESTATE->m_PlayMode.Set( pCourse->GetPlayMode() );
// apply #LIVES
if( pCourse->m_iLives != -1 )
{
SO_GROUP_ASSIGN( GAMESTATE->m_SongOptions, ModsLevel_Stage, m_LifeType, SongOptions::LIFE_BATTERY );
SO_GROUP_ASSIGN( GAMESTATE->m_SongOptions, ModsLevel_Stage, m_iBatteryLives, pCourse->m_iLives );
2004-06-02 07:22:55 +00:00
}
2006-08-19 22:08:33 +00:00
if( pCourse->GetCourseType() == COURSE_TYPE_SURVIVAL)
SO_GROUP_ASSIGN( GAMESTATE->m_SongOptions, ModsLevel_Stage, m_LifeType, SongOptions::LIFE_TIME );
2006-08-17 02:49:54 +00:00
}
else
{
2006-08-10 04:29:48 +00:00
/* We havn't made a selection yet. */
2006-08-17 02:44:25 +00:00
return;
}
2006-08-17 02:50:21 +00:00
m_bMadeChoice = true;
2006-08-17 02:43:15 +00:00
SCREENMAN->PlayStartSound();
2006-08-31 20:56:11 +00:00
/* If we're currently waiting on song assets, abort all except the music and
* start the music, so if we make a choice quickly before background requests
* come through, the music will still start. */
g_bCDTitleWaiting = g_bBannerWaiting = false;
m_BackgroundLoader.Abort();
CheckBackgroundRequests( true );
2006-08-17 02:43:15 +00:00
if( OPTIONS_MENU_AVAILABLE )
{
2006-08-17 02:43:15 +00:00
// show "hold START for options"
this->PlayCommand( "ShowPressStartForOptions" );
2002-09-07 09:37:27 +00:00
2006-08-17 02:43:15 +00:00
m_bAllowOptionsMenu = true;
2006-08-31 20:56:11 +00:00
2006-08-17 02:43:15 +00:00
/* Don't accept a held START for a little while, so it's not
2006-08-17 02:45:11 +00:00
* hit accidentally. Accept an initial START right away, though,
* so we don't ignore deliberate fast presses (which would be
* annoying). */
2006-08-17 02:43:15 +00:00
this->PostScreenMessage( SM_AllowOptionsMenuRepeat, 0.5f );
2002-09-07 09:37:27 +00:00
2006-08-17 02:43:15 +00:00
StartTransitioningScreen( SM_None );
float fTime = max( SHOW_OPTIONS_MESSAGE_SECONDS, this->GetTweenTimeLeft() );
this->PostScreenMessage( SM_BeginFadingOut, fTime );
}
else
{
StartTransitioningScreen( SM_BeginFadingOut );
2002-09-07 09:37:27 +00:00
}
2002-05-20 08:59:37 +00:00
}
2006-09-15 01:47:24 +00:00
void ScreenSelectMusic::MenuBack( const InputEventPlus &input )
2002-05-20 08:59:37 +00:00
{
m_BackgroundLoader.Abort();
2002-05-20 08:59:37 +00:00
Cancel( SM_GoToPrevScreen );
2002-05-20 08:59:37 +00:00
}
2006-08-17 01:22:20 +00:00
void ScreenSelectMusic::AfterStepsOrTrailChange( const vector<PlayerNumber> &vpns )
2002-05-20 08:59:37 +00:00
{
FOREACH_CONST( PlayerNumber, vpns, p )
{
PlayerNumber pn = *p;
ASSERT( GAMESTATE->IsHumanPlayer(pn) );
2006-08-17 01:22:20 +00:00
if( GAMESTATE->m_pCurSong )
{
CLAMP( m_iSelection[pn], 0, m_vpSteps.size()-1 );
2002-05-20 08:59:37 +00:00
2006-08-17 01:22:20 +00:00
Song* pSong = GAMESTATE->m_pCurSong;
Steps* pSteps = m_vpSteps.empty()? NULL: m_vpSteps[m_iSelection[pn]];
2002-05-20 08:59:37 +00:00
2006-08-17 01:22:20 +00:00
GAMESTATE->m_pCurSteps[pn].Set( pSteps );
GAMESTATE->m_pCurTrail[pn].Set( NULL );
2002-05-20 08:59:37 +00:00
2006-08-17 01:22:20 +00:00
int iScore = 0;
if( pSteps )
{
const Profile *pProfile = PROFILEMAN->IsPersistentProfile(pn) ? PROFILEMAN->GetProfile(pn) : PROFILEMAN->GetMachineProfile();
iScore = pProfile->GetStepsHighScoreList(pSong,pSteps).GetTopScore().GetScore();
}
2006-08-17 01:22:20 +00:00
m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) );
}
else
2006-08-17 01:25:09 +00:00
{
2006-08-17 01:22:20 +00:00
CLAMP( m_iSelection[pn], 0, m_vpTrails.size()-1 );
2004-06-03 08:22:02 +00:00
2006-08-17 01:22:20 +00:00
Course* pCourse = GAMESTATE->m_pCurCourse;
Trail* pTrail = m_vpTrails.empty()? NULL: m_vpTrails[m_iSelection[pn]];
2004-06-03 08:22:02 +00:00
2006-08-17 01:22:20 +00:00
GAMESTATE->m_pCurSteps[pn].Set( NULL );
GAMESTATE->m_pCurTrail[pn].Set( pTrail );
2004-06-03 08:22:02 +00:00
2006-08-17 01:22:20 +00:00
int iScore = 0;
if( pTrail )
{
const Profile *pProfile = PROFILEMAN->IsPersistentProfile(pn) ? PROFILEMAN->GetProfile(pn) : PROFILEMAN->GetMachineProfile();
iScore = pProfile->GetCourseHighScoreList(pCourse,pTrail).GetTopScore().GetScore();
}
2004-06-03 08:22:02 +00:00
2006-08-17 01:22:20 +00:00
m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) );
}
2004-06-03 08:22:02 +00:00
}
2002-05-20 08:59:37 +00:00
}
void ScreenSelectMusic::SwitchToPreferredDifficulty()
{
if( !GAMESTATE->m_pCurCourse )
{
FOREACH_HumanPlayer( pn )
{
/* Find the closest match to the user's preferred difficulty. */
2006-04-05 01:01:01 +00:00
int iCurDifference = -1;
int &iSelection = m_iSelection[pn];
for( unsigned i=0; i<m_vpSteps.size(); i++ )
{
/* If the current steps are listed, use them. */
if( GAMESTATE->m_pCurSteps[pn] == m_vpSteps[i] )
{
iSelection = i;
break;
}
if( GAMESTATE->m_PreferredDifficulty[pn] != DIFFICULTY_INVALID )
{
int iDiff = abs(m_vpSteps[i]->GetDifficulty() - GAMESTATE->m_PreferredDifficulty[pn]);
if( iCurDifference == -1 || iDiff < iCurDifference )
{
iSelection = i;
iCurDifference = iDiff;
}
}
}
CLAMP( iSelection, 0, m_vpSteps.size()-1 );
}
}
else
{
FOREACH_HumanPlayer( pn )
{
/* Find the closest match to the user's preferred difficulty. */
2006-04-05 01:01:01 +00:00
int iCurDifference = -1;
int &iSelection = m_iSelection[pn];
for( unsigned i=0; i<m_vpTrails.size(); i++ )
{
/* If the current trail is listed, use it. */
if( GAMESTATE->m_pCurTrail[pn] == m_vpTrails[i] )
{
iSelection = i;
break;
}
2006-04-05 01:01:01 +00:00
int iDiff = abs(m_vpTrails[i]->m_CourseDifficulty - GAMESTATE->m_PreferredCourseDifficulty[pn]);
2006-04-05 01:01:01 +00:00
if( iCurDifference == -1 || iDiff < iCurDifference )
{
iSelection = i;
2006-04-05 01:01:01 +00:00
iCurDifference = iDiff;
}
}
CLAMP( iSelection, 0, m_vpTrails.size()-1 );
}
}
if( GAMESTATE->DifficultiesLocked() )
{
FOREACH_HumanPlayer( p )
m_iSelection[p] = m_iSelection[GAMESTATE->m_MasterPlayerNumber];
}
}
2002-05-20 08:59:37 +00:00
void ScreenSelectMusic::AfterMusicChange()
{
if( !m_MusicWheel.IsRouletting() )
m_MenuTimer->Stall();
2002-08-20 21:00:56 +00:00
2002-05-20 08:59:37 +00:00
Song* pSong = m_MusicWheel.GetSelectedSong();
GAMESTATE->m_pCurSong.Set( pSong );
if( pSong )
GAMESTATE->m_pPreferredSong = pSong;
2002-05-20 08:59:37 +00:00
Course* pCourse = m_MusicWheel.GetSelectedCourse();
2005-05-18 07:14:19 +00:00
GAMESTATE->m_pCurCourse.Set( pCourse );
if( pCourse )
GAMESTATE->m_pPreferredCourse = pCourse;
2006-04-05 01:07:53 +00:00
m_vpSteps.clear();
m_vpTrails.clear();
m_Banner.SetMovingFast( !!m_MusicWheel.IsMoving() );
2003-01-02 03:00:53 +00:00
2006-01-22 01:00:06 +00:00
vector<RString> m_Artists, m_AltArtists;
m_sSampleMusicToPlay = "";
m_pSampleMusicTimingData = NULL;
g_sCDTitlePath = "";
g_sBannerPath = "";
g_bWantFallbackCdTitle = false;
bool bWantBanner = true;
2005-04-15 07:18:40 +00:00
static SortOrder s_lastSortOrder = SORT_INVALID;
if( GAMESTATE->m_SortOrder != s_lastSortOrder )
2005-04-15 07:18:40 +00:00
{
// Reload to let Lua metrics have a chance to change the help text.
s_lastSortOrder = GAMESTATE->m_SortOrder;
2005-04-15 07:18:40 +00:00
}
2002-05-20 08:59:37 +00:00
switch( m_MusicWheel.GetSelectedType() )
{
case TYPE_SECTION:
2003-06-16 17:28:58 +00:00
case TYPE_SORT:
2006-08-17 02:07:00 +00:00
case TYPE_ROULETTE:
case TYPE_RANDOM:
2006-08-17 02:04:21 +00:00
FOREACH_PlayerNumber( p )
m_iSelection[p] = -1;
2006-08-17 02:04:21 +00:00
g_sCDTitlePath = ""; // none
2003-04-21 22:26:07 +00:00
2006-08-17 02:04:21 +00:00
m_fSampleStartSeconds = 0;
m_fSampleLengthSeconds = -1;
2004-05-22 22:56:58 +00:00
2006-08-17 02:04:21 +00:00
switch( m_MusicWheel.GetSelectedType() )
{
case TYPE_SECTION:
g_sBannerPath = SONGMAN->GetSongGroupBannerPath( m_MusicWheel.GetSelectedSection() );
m_sSampleMusicToPlay = m_sSectionMusicPath;
break;
case TYPE_SORT:
bWantBanner = false; /* we load it ourself */
m_Banner.LoadMode();
m_sSampleMusicToPlay = m_sSortMusicPath;
break;
2006-08-17 02:07:00 +00:00
case TYPE_ROULETTE:
bWantBanner = false; /* we load it ourself */
m_Banner.LoadRoulette();
m_sSampleMusicToPlay = m_sRouletteMusicPath;
break;
case TYPE_RANDOM:
bWantBanner = false; /* we load it ourself */
m_Banner.LoadRandom();
m_sSampleMusicToPlay = m_sRandomMusicPath;
break;
2006-08-17 02:04:21 +00:00
default:
ASSERT(0);
2002-05-20 08:59:37 +00:00
}
break;
case TYPE_SONG:
2004-06-02 05:12:45 +00:00
case TYPE_PORTAL:
2006-08-17 02:08:38 +00:00
m_sSampleMusicToPlay = pSong->GetMusicPath();
m_pSampleMusicTimingData = &pSong->m_Timing;
m_fSampleStartSeconds = pSong->m_fMusicSampleStartSeconds;
m_fSampleLengthSeconds = pSong->m_fMusicSampleLengthSeconds;
2006-08-17 02:08:38 +00:00
SongUtil::GetSteps( pSong, m_vpSteps, GAMESTATE->GetCurrentStyle()->m_StepsType );
StepsUtil::RemoveLockedSteps( pSong, m_vpSteps );
StepsUtil::SortNotesArrayByDifficulty( m_vpSteps );
2006-08-17 02:08:38 +00:00
if ( PREFSMAN->m_bShowBanners )
g_sBannerPath = pSong->GetBannerPath();
2006-08-17 02:08:38 +00:00
g_sCDTitlePath = pSong->GetCDTitlePath();
g_bWantFallbackCdTitle = true;
2006-08-17 02:08:38 +00:00
SwitchToPreferredDifficulty();
break;
2006-08-17 02:08:38 +00:00
case TYPE_COURSE:
{
Course* pCourse = m_MusicWheel.GetSelectedCourse();
2004-06-28 07:26:00 +00:00
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
Trail *pTrail = pCourse->GetTrail( st );
ASSERT( pTrail );
2004-06-28 07:26:00 +00:00
pCourse->GetTrails( m_vpTrails, GAMESTATE->GetCurrentStyle()->m_StepsType );
2004-06-03 08:22:02 +00:00
m_sSampleMusicToPlay = m_sCourseMusicPath;
m_fSampleStartSeconds = 0;
m_fSampleLengthSeconds = -1;
g_sBannerPath = pCourse->m_sBannerPath;
if( g_sBannerPath.empty() )
m_Banner.LoadFallback();
SwitchToPreferredDifficulty();
break;
}
default:
ASSERT(0);
2002-05-20 08:59:37 +00:00
}
m_sprCDTitleFront.UnloadTexture();
m_sprCDTitleBack.UnloadTexture();
2004-10-16 17:53:47 +00:00
/* Cancel any previous, incomplete requests for song assets, since we need new ones. */
m_BackgroundLoader.Abort();
g_bCDTitleWaiting = false;
if( !g_sCDTitlePath.empty() || g_bWantFallbackCdTitle )
{
LOG->Trace( "cache \"%s\"", g_sCDTitlePath.c_str());
m_BackgroundLoader.CacheFile( g_sCDTitlePath ); // empty OK
g_bCDTitleWaiting = true;
}
g_bBannerWaiting = false;
if( bWantBanner )
{
LOG->Trace("LoadFromCachedBanner(%s)",g_sBannerPath .c_str());
if( m_Banner.LoadFromCachedBanner( g_sBannerPath ) )
{
/* If the high-res banner is already loaded, just
* delay before loading it, so the low-res one has
* time to fade in. */
if( !TEXTUREMAN->IsTextureRegistered( Sprite::SongBannerTexture(g_sBannerPath) ) )
m_BackgroundLoader.CacheFile( g_sBannerPath );
g_bBannerWaiting = true;
}
}
2003-11-25 18:25:43 +00:00
// Don't stop music if it's already playing the right file.
g_bSampleMusicWaiting = false;
if( !m_MusicWheel.IsRouletting() && SOUND->GetMusicPath() != m_sSampleMusicToPlay )
{
2003-07-26 23:05:16 +00:00
SOUND->StopMusic();
if( !m_sSampleMusicToPlay.empty() )
g_bSampleMusicWaiting = true;
}
g_StartedLoadingAt.Touch();
vector<PlayerNumber> vpns;
2004-06-03 08:22:02 +00:00
FOREACH_HumanPlayer( p )
vpns.push_back( p );
2006-08-17 01:22:20 +00:00
AfterStepsOrTrailChange( vpns );
2002-05-20 08:59:37 +00:00
}
2005-07-12 05:52:52 +00:00
// lua start
#include "LuaBinding.h"
class LunaScreenSelectMusic: public Luna<ScreenSelectMusic>
{
public:
LunaScreenSelectMusic() { LUA->Register( Register ); }
static int GetGoToOptions( T* p, lua_State *L ) { lua_pushboolean( L, p->GetGoToOptions() ); return 1; }
static void Register( Lua *L )
{
ADD_METHOD( GetGoToOptions );
2005-07-12 05:52:52 +00:00
Luna<T>::Register( L );
}
};
LUA_REGISTER_DERIVED_CLASS( ScreenSelectMusic, ScreenWithMenuElements )
// lua end
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.
*/