Files
itgmania212121/stepmania/src/MusicWheel.cpp
T

1245 lines
33 KiB
C++
Raw Normal View History

2002-01-16 10:01:32 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
2002-05-01 19:14:55 +00:00
Class: MusicWheel
2002-01-16 10:01:32 +00:00
2002-05-01 19:14:55 +00:00
Desc: See header.
2002-01-16 10:01:32 +00:00
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-05-01 19:14:55 +00:00
Chris Danford
2002-01-16 10:01:32 +00:00
-----------------------------------------------------------------------------
*/
#include "MusicWheel.h"
#include "RageUtil.h"
2002-02-28 19:40:40 +00:00
#include "SongManager.h"
#include "GameManager.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
2002-01-16 10:01:32 +00:00
#include "RageMusic.h"
2002-05-19 01:59:48 +00:00
#include "ScreenManager.h" // for sending SM_PlayMusicSample
2002-05-01 19:14:55 +00:00
#include "RageLog.h"
#include "GameConstantsAndTypes.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
// WheelItem stuff
#define ICON_X THEME->GetMetricF("WheelItem","IconX")
#define SONG_NAME_X THEME->GetMetricF("WheelItem","SongNameX")
#define SECTION_NAME_X THEME->GetMetricF("WheelItem","SectionNameX")
#define SECTION_ZOOM THEME->GetMetricF("WheelItem","SectionZoom")
#define ROULETTE_X THEME->GetMetricF("WheelItem","RouletteX")
#define ROULETTE_ZOOM THEME->GetMetricF("WheelItem","RouletteZoom")
#define COURSE_X THEME->GetMetricF("WheelItem","CourseX")
#define COURSE_ZOOM THEME->GetMetricF("WheelItem","CourseZoom")
#define GRADE_P1_X THEME->GetMetricF("WheelItem","GradeP1X")
#define GRADE_P2_X THEME->GetMetricF("WheelItem","GradeP2Y")
// MusicWheel stuff
#define FADE_SECONDS THEME->GetMetricF("MusicWheel","FadeSeconds")
#define SWITCH_SECONDS THEME->GetMetricF("MusicWheel","SwitchSeconds")
#define SAMPLE_MUSIC_DELAY THEME->GetMetricF("MusicWheel","SampleMusicDelay")
#define ROULETTE_SWITCH_SECONDS THEME->GetMetricF("MusicWheel","RouletteSwitchSeconds")
#define ROULETTE_SLOW_DOWN_SWITCHES THEME->GetMetricI("MusicWheel","RouletteSlowDownSwitches")
#define LOCKED_INITIAL_VELOCITY THEME->GetMetricF("MusicWheel","LockedInitialVelocity")
#define SCROLL_BAR_X THEME->GetMetricF("MusicWheel","ScrollBarX")
#define SECTION_COLOR_1 THEME->GetMetricC("MusicWheel","SectionColor1")
#define SECTION_COLOR_2 THEME->GetMetricC("MusicWheel","SectionColor2")
#define SECTION_COLOR_3 THEME->GetMetricC("MusicWheel","SectionColor3")
#define SECTION_COLOR_4 THEME->GetMetricC("MusicWheel","SectionColor4")
#define SECTION_COLOR_5 THEME->GetMetricC("MusicWheel","SectionColor5")
#define SECTION_COLOR_6 THEME->GetMetricC("MusicWheel","SectionColor6")
#define SECTION_COLOR_7 THEME->GetMetricC("MusicWheel","SectionColor7")
const int NUM_SECTION_COLORS = 7;
D3DXCOLOR SECTION_COLORS( int i ) {
switch( i ) {
case 0: return SECTION_COLOR_1;
case 1: return SECTION_COLOR_2;
case 2: return SECTION_COLOR_3;
case 3: return SECTION_COLOR_4;
case 4: return SECTION_COLOR_5;
case 5: return SECTION_COLOR_6;
case 6: return SECTION_COLOR_7;
default: ASSERT(0); return D3DXCOLOR(1,1,1,1);
}
}
inline D3DXCOLOR GetNextSectionColor() {
2002-05-19 01:59:48 +00:00
static int i=0;
i = i % NUM_SECTION_COLORS;
return SECTION_COLORS(i++);
2002-02-05 05:33:33 +00:00
}
2002-01-16 10:01:32 +00:00
2002-02-05 05:33:33 +00:00
2002-07-27 19:29:51 +00:00
WheelItemData::WheelItemData( WheelItemType wit, Song* pSong, const CString &sSectionName, Course* pCourse, const D3DXCOLOR color )
2002-01-16 10:01:32 +00:00
{
2002-05-19 01:59:48 +00:00
m_WheelItemType = wit;
2002-02-05 05:33:33 +00:00
m_pSong = pSong;
2002-05-19 01:59:48 +00:00
m_sSectionName = sSectionName;
2002-06-14 22:25:22 +00:00
m_pCourse = pCourse;
2002-05-19 01:59:48 +00:00
m_color = color;
}
WheelItemDisplay::WheelItemDisplay()
{
2002-06-30 23:19:33 +00:00
m_fPercentGray = 0;
m_MusicStatusDisplay.SetXY( ICON_X, 0 );
2002-01-16 10:01:32 +00:00
2002-05-19 01:59:48 +00:00
m_TextBanner.SetHorizAlign( align_left );
m_TextBanner.SetXY( SONG_NAME_X, 0 );
2002-04-16 17:31:00 +00:00
m_sprSongBar.Load( THEME->GetPathTo("Graphics","select music song bar") );
2002-04-16 17:31:00 +00:00
m_sprSongBar.SetXY( 0, 0 );
2002-01-16 10:01:32 +00:00
m_sprSectionBar.Load( THEME->GetPathTo("Graphics","select music section bar") );
2002-05-19 01:59:48 +00:00
m_sprSectionBar.SetXY( 0, 0 );
2002-01-16 10:01:32 +00:00
m_textSectionName.LoadFromFont( THEME->GetPathTo("Fonts","header1") );
2002-01-16 10:01:32 +00:00
m_textSectionName.TurnShadowOff();
2002-03-06 08:25:09 +00:00
m_textSectionName.SetVertAlign( align_middle );
m_textSectionName.SetXY( SECTION_NAME_X, 0 );
m_textSectionName.SetZoom( SECTION_ZOOM );
2002-05-19 01:59:48 +00:00
m_textRoulette.LoadFromFont( THEME->GetPathTo("Fonts","text banner") );
2002-05-19 01:59:48 +00:00
m_textRoulette.TurnShadowOff();
m_textRoulette.SetText( "ROULETTE" );
m_textRoulette.TurnRainbowOn();
m_textRoulette.SetZoom( ROULETTE_ZOOM );
m_textRoulette.SetXY( ROULETTE_X, 0 );
2002-04-16 17:31:00 +00:00
for( int p=0; p<NUM_PLAYERS; p++ )
{
m_GradeDisplay[p].Load( THEME->GetPathTo("Graphics","select music small grades 1x7") );
2002-05-01 19:14:55 +00:00
m_GradeDisplay[p].SetZoom( 1.0f );
m_GradeDisplay[p].SetXY( p==PLAYER_1 ? GRADE_P1_X : GRADE_P2_X, 0 );
2002-04-16 17:31:00 +00:00
}
2002-06-14 22:25:22 +00:00
m_textCourse.LoadFromFont( THEME->GetPathTo("Fonts","text banner") );
2002-06-14 22:25:22 +00:00
m_textCourse.TurnShadowOff();
m_textCourse.SetZoom( COURSE_ZOOM );
2002-06-14 22:25:22 +00:00
m_textCourse.SetHorizAlign( align_left );
m_textCourse.SetXY( COURSE_X, 0 );
2002-02-05 05:33:33 +00:00
}
2002-01-16 10:01:32 +00:00
void WheelItemDisplay::LoadFromWheelItemData( WheelItemData* pWID )
2002-01-16 10:01:32 +00:00
{
ASSERT( pWID != NULL );
// copy all data items
2002-06-14 22:25:22 +00:00
this->m_WheelItemType = pWID->m_WheelItemType;
this->m_sSectionName = pWID->m_sSectionName;
this->m_pCourse = pWID->m_pCourse;
this->m_pSong = pWID->m_pSong;
this->m_color = pWID->m_color;
// init type specific stuff
switch( pWID->m_WheelItemType )
{
case TYPE_SECTION:
2002-03-06 08:25:09 +00:00
{
2002-06-14 22:25:22 +00:00
CString sDisplayName = SONGMAN->ShortenGroupName(m_sSectionName);
m_textSectionName.SetZoom( 1 );
m_textSectionName.SetText( sDisplayName );
m_textSectionName.SetDiffuseColor( m_color );
m_textSectionName.TurnRainbowOff();
float fSourcePixelWidth = (float)m_textSectionName.GetWidestLineWidthInSourcePixels();
float fMaxTextWidth = 200;
if( fSourcePixelWidth > fMaxTextWidth )
m_textSectionName.SetZoomX( fMaxTextWidth / fSourcePixelWidth );
2002-04-16 17:31:00 +00:00
}
break;
2002-04-16 17:31:00 +00:00
case TYPE_SONG:
{
2002-05-29 09:47:24 +00:00
m_TextBanner.LoadFromSong( m_pSong );
D3DXCOLOR color = m_color;
color.r += 0.15f;
color.g += 0.15f;
color.b += 0.15f;
m_TextBanner.SetDiffuseColor( color );
m_MusicStatusDisplay.SetType( m_MusicStatusDisplayType );
RefreshGrades();
2002-04-16 17:31:00 +00:00
}
break;
2002-05-19 01:59:48 +00:00
case TYPE_ROULETTE:
{
}
break;
2002-06-14 22:25:22 +00:00
case TYPE_COURSE:
{
m_textCourse.SetZoom( 1 );
m_textCourse.SetText( m_pCourse->m_sName );
m_textCourse.SetDiffuseColor( m_color );
m_textCourse.TurnRainbowOff();
float fSourcePixelWidth = (float)m_textCourse.GetWidestLineWidthInSourcePixels();
float fMaxTextWidth = 200;
if( fSourcePixelWidth > fMaxTextWidth )
m_textCourse.SetZoomX( fMaxTextWidth / fSourcePixelWidth );
}
break;
default:
2002-02-11 04:46:31 +00:00
ASSERT( false ); // invalid type
}
}
2002-04-28 20:42:32 +00:00
void WheelItemDisplay::RefreshGrades()
{
2002-05-29 09:47:24 +00:00
// Refresh Grades
2002-04-28 20:42:32 +00:00
for( int p=0; p<NUM_PLAYERS; p++ )
{
2002-07-23 01:41:40 +00:00
if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) )
2002-05-19 01:59:48 +00:00
{
m_GradeDisplay[p].SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
continue;
}
if( m_pSong ) // this is a song display
2002-04-28 20:42:32 +00:00
{
2002-07-23 01:41:40 +00:00
const DifficultyClass dc = GAMESTATE->m_PreferredDifficultyClass[p];
const Grade grade = m_pSong->GetGradeForDifficultyClass( GAMESTATE->GetCurrentStyleDef()->m_NotesType, dc );
2002-04-28 20:42:32 +00:00
m_GradeDisplay[p].SetGrade( grade );
2002-06-14 22:25:22 +00:00
m_GradeDisplay[p].SetDiffuseColor( PlayerToColor((PlayerNumber)p) );
2002-04-28 20:42:32 +00:00
}
2002-05-19 01:59:48 +00:00
else // this is a section display
2002-04-28 20:42:32 +00:00
{
2002-05-19 01:59:48 +00:00
m_GradeDisplay[p].SetGrade( GRADE_NO_DATA );
2002-04-28 20:42:32 +00:00
}
}
2002-05-29 09:47:24 +00:00
2002-04-28 20:42:32 +00:00
}
2002-05-29 09:47:24 +00:00
void WheelItemDisplay::Update( float fDeltaTime )
2002-02-05 05:33:33 +00:00
{
2002-05-28 20:01:22 +00:00
Actor::Update( fDeltaTime );
2002-02-05 05:33:33 +00:00
switch( m_WheelItemType )
{
case TYPE_SECTION:
2002-04-16 17:31:00 +00:00
m_sprSectionBar.Update( fDeltaTime );
2002-02-05 05:33:33 +00:00
m_textSectionName.Update( fDeltaTime );
break;
2002-05-19 01:59:48 +00:00
case TYPE_ROULETTE:
m_sprSectionBar.Update( fDeltaTime );
m_textRoulette.Update( fDeltaTime );
break;
2002-04-16 17:31:00 +00:00
case TYPE_SONG:
2002-06-14 22:25:22 +00:00
{
m_sprSongBar.Update( fDeltaTime );
m_MusicStatusDisplay.Update( fDeltaTime );
m_TextBanner.Update( fDeltaTime );
for( int p=0; p<NUM_PLAYERS; p++ )
m_GradeDisplay[p].Update( fDeltaTime );
}
break;
case TYPE_COURSE:
2002-04-16 17:31:00 +00:00
m_sprSongBar.Update( fDeltaTime );
2002-06-14 22:25:22 +00:00
m_textCourse.Update( fDeltaTime );
2002-02-05 05:33:33 +00:00
break;
2002-06-14 22:25:22 +00:00
default:
ASSERT(0);
2002-02-05 05:33:33 +00:00
}
}
2002-05-19 01:59:48 +00:00
void WheelItemDisplay::DrawPrimitives()
2002-02-05 05:33:33 +00:00
{
switch( m_WheelItemType )
{
case TYPE_SECTION:
2002-04-16 17:31:00 +00:00
m_sprSectionBar.Draw();
2002-02-05 05:33:33 +00:00
break;
2002-05-19 01:59:48 +00:00
case TYPE_ROULETTE:
m_sprSectionBar.Draw();
2002-08-19 20:02:30 +00:00
break;
case TYPE_SONG:
m_sprSongBar.Draw();
break;
case TYPE_COURSE:
m_sprSongBar.Draw();
break;
default:
ASSERT(0);
}
switch( m_WheelItemType )
{
case TYPE_SECTION:
m_textSectionName.Draw();
break;
case TYPE_ROULETTE:
2002-05-19 01:59:48 +00:00
m_textRoulette.Draw();
break;
2002-04-16 17:31:00 +00:00
case TYPE_SONG:
2002-08-19 20:02:30 +00:00
m_TextBanner.Draw();
break;
case TYPE_COURSE:
m_textCourse.Draw();
break;
default:
ASSERT(0);
}
switch( m_WheelItemType )
{
case TYPE_SECTION:
break;
case TYPE_ROULETTE:
break;
case TYPE_SONG:
m_MusicStatusDisplay.Draw();
break;
case TYPE_COURSE:
break;
default:
ASSERT(0);
}
switch( m_WheelItemType )
{
case TYPE_SECTION:
break;
case TYPE_ROULETTE:
break;
case TYPE_SONG:
int p;
for( p=0; p<NUM_PLAYERS; p++ )
m_GradeDisplay[p].Draw();
break;
case TYPE_COURSE:
break;
default:
ASSERT(0);
}
switch( m_WheelItemType )
{
case TYPE_SECTION:
break;
case TYPE_ROULETTE:
break;
case TYPE_SONG:
if( m_fPercentGray > 0 )
2002-06-14 22:25:22 +00:00
{
2002-08-19 20:02:30 +00:00
m_sprSongBar.SetGlowColor( D3DXCOLOR(0,0,0,m_fPercentGray) );
2002-06-14 22:25:22 +00:00
m_sprSongBar.Draw();
2002-08-19 20:02:30 +00:00
m_sprSongBar.SetGlowColor( D3DXCOLOR(0,0,0,0) );
2002-06-14 22:25:22 +00:00
}
break;
case TYPE_COURSE:
2002-02-05 05:33:33 +00:00
break;
2002-06-14 22:25:22 +00:00
default:
ASSERT(0);
2002-02-05 05:33:33 +00:00
}
2002-01-16 10:01:32 +00:00
2002-08-19 20:02:30 +00:00
}
2002-01-16 10:01:32 +00:00
MusicWheel::MusicWheel()
{
LOG->Trace( "MusicWheel::MusicWheel()" );
2002-01-16 10:01:32 +00:00
2002-05-28 20:01:22 +00:00
// for debugging
2002-07-23 01:41:40 +00:00
if( GAMESTATE->m_CurStyle == STYLE_NONE )
GAMESTATE->m_CurStyle = STYLE_DANCE_SINGLE;
2002-05-28 20:01:22 +00:00
m_sprSelectionOverlay.Load( THEME->GetPathTo("Graphics","select music song highlight") );
2002-01-16 10:01:32 +00:00
m_sprSelectionOverlay.SetXY( 0, 0 );
2002-05-19 01:59:48 +00:00
m_sprSelectionOverlay.SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
m_sprSelectionOverlay.SetEffectGlowing( 1.0f, D3DXCOLOR(1,1,1,0.4f), D3DXCOLOR(1,1,1,1) );
AddSubActor( &m_sprSelectionOverlay );
2002-05-29 09:47:24 +00:00
m_ScrollBar.SetX( SCROLL_BAR_X );
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_ScrollBar );
2002-05-01 19:14:55 +00:00
m_soundChangeMusic.Load( THEME->GetPathTo("Sounds","select music change music"), 16 );
m_soundChangeSort.Load( THEME->GetPathTo("Sounds","select music change sort") );
m_soundExpand.Load( THEME->GetPathTo("Sounds","select music section expand") );
m_soundStart.Load( THEME->GetPathTo("Sounds","menu start") );
m_soundLocked.Load( THEME->GetPathTo("Sounds","select music wheel locked") );
2002-06-24 22:04:31 +00:00
2002-01-16 10:01:32 +00:00
2002-06-24 22:04:31 +00:00
m_fTimeLeftBeforePlayMusicSample = 0;
2002-01-16 10:01:32 +00:00
// init m_mapGroupNameToBannerColor
2002-02-11 04:46:31 +00:00
CArray<Song*, Song*> arraySongs;
2002-05-19 01:59:48 +00:00
arraySongs.Copy( SONGMAN->m_pSongs );
2002-01-16 10:01:32 +00:00
SortSongPointerArrayByGroup( arraySongs );
m_sExpandedSectionName = "";
m_iSelection = 0;
2002-06-24 22:04:31 +00:00
m_WheelState = STATE_SELECTING_MUSIC;
m_fTimeLeftInState = 0;
m_fPositionOffsetFromSelection = 0;
2002-01-16 10:01:32 +00:00
2002-06-24 22:04:31 +00:00
m_iSwitchesLeftInSpinDown = 0;
2002-01-16 10:01:32 +00:00
2002-02-09 18:53:47 +00:00
// build all of the wheel item datas
for( int so=0; so<NUM_SORT_ORDERS; so++ )
BuildWheelItemDatas( m_WheelItemDatas[so], SongSortOrder(so) );
2002-08-01 13:42:56 +00:00
if( GAMESTATE->IsExtraStage() || GAMESTATE->IsExtraStage2() )
{
2002-08-01 13:42:56 +00:00
// make the preferred group the group of the last song played.
if( GAMESTATE->m_sPreferredGroup == "ALL MUSIC" )
GAMESTATE->m_sPreferredGroup = GAMESTATE->m_pCurSong->m_sGroupName;
Song* pSong;
Notes* pNotes;
PlayerOptions po;
SongOptions so;
SONGMAN->GetExtraStageInfo(
GAMESTATE->IsExtraStage2(),
GAMESTATE->m_sPreferredGroup,
GAMESTATE->GetCurrentStyleDef()->m_NotesType,
pSong,
pNotes,
po,
so );
GAMESTATE->m_pCurSong = pSong;
for( int p=0; p<NUM_PLAYERS; p++ )
{
2002-08-01 13:42:56 +00:00
if( GAMESTATE->IsPlayerEnabled(p) )
{
2002-08-01 13:42:56 +00:00
GAMESTATE->m_pCurNotes[p] = pNotes;
GAMESTATE->m_PlayerOptions[p] = po;
}
}
2002-08-01 13:42:56 +00:00
GAMESTATE->m_SongOptions = so;
}
2002-08-01 13:42:56 +00:00
// If there is no currently selected song, select one.
if( GAMESTATE->m_pCurSong == NULL )
2002-02-24 01:43:11 +00:00
{
2002-08-01 13:42:56 +00:00
CStringArray asGroupNames;
SONGMAN->GetGroupNames( asGroupNames );
if( asGroupNames.GetSize() > 0 )
{
CArray<Song*, Song*> arraySongs;
SONGMAN->GetSongsInGroup( asGroupNames[0], arraySongs );
if( arraySongs.GetSize() > 0 ) // still nothing selected
GAMESTATE->m_pCurSong = arraySongs[0]; // select the first song
}
2002-02-24 01:43:11 +00:00
}
2002-08-01 05:11:11 +00:00
// Select the the previously selected song (if any)
2002-08-01 13:42:56 +00:00
if( GAMESTATE->m_pCurSong )
{
2002-05-01 19:14:55 +00:00
for( int i=0; i<GetCurWheelItemDatas().GetSize(); i++ )
2002-02-09 18:53:47 +00:00
{
2002-07-23 01:41:40 +00:00
if( GetCurWheelItemDatas()[i].m_pSong == GAMESTATE->m_pCurSong )
2002-04-16 17:31:00 +00:00
{
m_iSelection = i; // select it
m_sExpandedSectionName = GetCurWheelItemDatas()[m_iSelection].m_sSectionName; // make its group the currently expanded group
break;
}
2002-02-09 18:53:47 +00:00
}
}
2002-08-01 05:11:11 +00:00
// Select the the previously selected course (if any)
if( GAMESTATE->m_pCurCourse != NULL )
{
for( int i=0; i<GetCurWheelItemDatas().GetSize(); i++ )
{
if( GetCurWheelItemDatas()[i].m_pCourse == GAMESTATE->m_pCurCourse )
{
m_iSelection = i; // select it
m_sExpandedSectionName = GetCurWheelItemDatas()[m_iSelection].m_sSectionName; // make its group the currently expanded group
break;
}
}
}
2002-02-09 18:53:47 +00:00
// rebuild the WheelItems that appear on screen
RebuildWheelItemDisplays();
}
MusicWheel::~MusicWheel()
{
}
CArray<WheelItemData, WheelItemData&>& MusicWheel::GetCurWheelItemDatas()
{
return m_WheelItemDatas[GAMESTATE->m_SongSortOrder];
2002-01-16 10:01:32 +00:00
}
2002-06-30 23:19:33 +00:00
void MusicWheel::BuildWheelItemDatas( CArray<WheelItemData, WheelItemData&> &arrayWheelItemDatas, SongSortOrder so, bool bRoulette )
2002-01-16 10:01:32 +00:00
{
2002-05-01 19:14:55 +00:00
int i;
2002-07-23 01:41:40 +00:00
switch( GAMESTATE->m_PlayMode )
2002-02-09 18:53:47 +00:00
{
2002-06-14 22:25:22 +00:00
case PLAY_MODE_ARCADE:
{
///////////////////////////////////
// Make an array of Song*, then sort them
///////////////////////////////////
CArray<Song*, Song*> arraySongs;
// copy only song that have at least one Notes for the current GameMode
for( i=0; i<SONGMAN->m_pSongs.GetSize(); i++ )
{
Song* pSong = SONGMAN->m_pSongs[i];
2002-02-09 18:53:47 +00:00
2002-06-14 22:25:22 +00:00
CArray<Notes*, Notes*> arraySteps;
2002-07-23 01:41:40 +00:00
pSong->GetNotesThatMatch( GAMESTATE->GetCurrentStyleDef()->m_NotesType, arraySteps );
2002-02-09 18:53:47 +00:00
2002-06-14 22:25:22 +00:00
if( arraySteps.GetSize() > 0 )
arraySongs.Add( pSong );
}
2002-02-09 18:53:47 +00:00
2002-07-27 19:29:51 +00:00
// sort the songs
2002-06-14 22:25:22 +00:00
switch( so )
{
case SORT_GROUP:
SortSongPointerArrayByGroup( arraySongs );
break;
case SORT_TITLE:
SortSongPointerArrayByTitle( arraySongs );
break;
case SORT_BPM:
SortSongPointerArrayByBPM( arraySongs );
break;
// case SORT_ARTIST:
// SortSongPointerArrayByArtist( arraySongs );
// break;
case SORT_MOST_PLAYED:
SortSongPointerArrayByMostPlayed( arraySongs );
break;
default:
ASSERT( false ); // unhandled SORT_ORDER
}
2002-01-16 10:01:32 +00:00
2002-06-14 22:25:22 +00:00
///////////////////////////////////
2002-07-27 19:29:51 +00:00
// Build an array of WheelItemDatas from the sorted list of Song*s
2002-06-14 22:25:22 +00:00
///////////////////////////////////
2002-07-27 19:29:51 +00:00
arrayWheelItemDatas.SetSize( 0, 300 ); // clear out the previous wheel items and set large capacity jumps
2002-04-16 17:31:00 +00:00
2002-06-14 22:25:22 +00:00
bool bUseSections;
switch( so )
{
case SORT_MOST_PLAYED: bUseSections = false; break;
case SORT_BPM: bUseSections = false; break;
case SORT_GROUP: bUseSections = GAMESTATE->m_sPreferredGroup == "ALL MUSIC"; break;
2002-06-14 22:25:22 +00:00
case SORT_TITLE: bUseSections = true; break;
default: ASSERT( false );
}
2002-06-30 23:19:33 +00:00
if( bRoulette )
bUseSections = false;
2002-01-16 10:01:32 +00:00
2002-06-14 22:25:22 +00:00
if( bUseSections )
{
// make WheelItemDatas with sections
CString sLastSection = "";
D3DXCOLOR colorSection;
int iCurWheelItem = 0;
for( int i=0; i< arraySongs.GetSize(); i++ )
{
Song* pSong = arraySongs[i];
CString sThisSection = GetSectionNameFromSongAndSort( pSong, so );
int iSectionColorIndex = 0;
if( GAMESTATE->m_sPreferredGroup != "ALL MUSIC" && pSong->m_sGroupName != GAMESTATE->m_sPreferredGroup )
continue;
if( sThisSection != sLastSection) // new section, make a section item
2002-06-14 22:25:22 +00:00
{
colorSection = (so==SORT_GROUP) ? SONGMAN->GetGroupColor(pSong->m_sGroupName) : SECTION_COLORS(iSectionColorIndex);
2002-06-14 22:25:22 +00:00
iSectionColorIndex = (iSectionColorIndex+1) % NUM_SECTION_COLORS;
2002-07-27 19:29:51 +00:00
arrayWheelItemDatas.Add( WheelItemData(TYPE_SECTION, NULL, sThisSection, NULL, colorSection) );
2002-06-14 22:25:22 +00:00
sLastSection = sThisSection;
}
2002-07-27 19:29:51 +00:00
arrayWheelItemDatas.Add( WheelItemData( TYPE_SONG, pSong, sThisSection, NULL, SONGMAN->GetGroupColor(pSong->m_sGroupName)) );
2002-06-14 22:25:22 +00:00
}
}
else
2002-01-16 10:01:32 +00:00
{
2002-07-27 19:29:51 +00:00
for( int i=0; i<arraySongs.GetSize(); i++ )
2002-06-14 22:25:22 +00:00
{
2002-07-27 19:29:51 +00:00
Song* pSong = arraySongs[i];
if( GAMESTATE->m_sPreferredGroup != "ALL MUSIC" && pSong->m_sGroupName != GAMESTATE->m_sPreferredGroup )
2002-07-27 19:29:51 +00:00
continue; // skip
arrayWheelItemDatas.Add( WheelItemData(TYPE_SONG, pSong, "", NULL, SONGMAN->GetGroupColor(pSong->m_sGroupName)) );
2002-06-14 22:25:22 +00:00
}
2002-01-16 10:01:32 +00:00
}
}
2002-06-14 22:25:22 +00:00
break;
case PLAY_MODE_ONI:
case PLAY_MODE_ENDLESS:
2002-04-16 17:31:00 +00:00
{
2002-08-02 09:31:06 +00:00
int i;
2002-07-27 19:29:51 +00:00
CArray<Course*,Course*> apCourses;
switch( GAMESTATE->m_PlayMode )
2002-04-16 17:31:00 +00:00
{
case PLAY_MODE_ONI:
2002-08-02 09:31:06 +00:00
for( i=0; i<SONGMAN->m_aOniCourses.GetSize(); i++ )
apCourses.Add( &SONGMAN->m_aOniCourses[i] );
SortCoursePointerArrayByDifficulty( apCourses );
break;
case PLAY_MODE_ENDLESS:
2002-08-02 09:31:06 +00:00
for( i=0; i<SONGMAN->m_aEndlessCourses.GetSize(); i++ )
apCourses.Add( &SONGMAN->m_aEndlessCourses[i] );
break;
2002-04-16 17:31:00 +00:00
}
2002-07-29 03:06:55 +00:00
for( int c=0; c<apCourses.GetSize(); c++ ) // foreach course
{
Course* pCourse = apCourses[c];
// check that this course has at least one song playable in the current style
CArray<Song*,Song*> apSongs;
CArray<Notes*,Notes*> apNotes;
CStringArray asModifiers;
pCourse->GetSongAndNotesForCurrentStyle( apSongs, apNotes, asModifiers );
if( apNotes.GetSize() > 0 )
arrayWheelItemDatas.Add( WheelItemData(TYPE_COURSE, NULL, "", pCourse, pCourse->GetColor()) );
2002-07-29 03:06:55 +00:00
}
}
break;
2002-06-14 22:25:22 +00:00
default:
ASSERT(0); // invalid PlayMode
2002-01-16 10:01:32 +00:00
}
2002-02-10 06:25:12 +00:00
// init crowns
for( i=0; i<arrayWheelItemDatas.GetSize(); i++ )
{
Song* pSong = arrayWheelItemDatas[i].m_pSong;
if( pSong != NULL )
{
2002-05-19 01:59:48 +00:00
arrayWheelItemDatas[i].m_MusicStatusDisplayType = (pSong->GetNumTimesPlayed()==0) ? TYPE_NEW : TYPE_NONE;
2002-02-10 06:25:12 +00:00
}
}
2002-01-16 10:01:32 +00:00
if( so == SORT_MOST_PLAYED )
2002-01-16 10:01:32 +00:00
{
// init crown icons
2002-02-10 06:25:12 +00:00
for( int i=0; i<arrayWheelItemDatas.GetSize() && i<3; i++ )
2002-01-16 10:01:32 +00:00
{
2002-05-19 01:59:48 +00:00
arrayWheelItemDatas[i].m_MusicStatusDisplayType = MusicStatusDisplayType(TYPE_CROWN1 + i);
2002-01-16 10:01:32 +00:00
}
}
if( arrayWheelItemDatas.GetSize() == 0 )
2002-01-16 10:01:32 +00:00
{
arrayWheelItemDatas.Add( WheelItemData(TYPE_SECTION, NULL, "- EMPTY -", NULL, D3DXCOLOR(1,0,0,1)) );
2002-05-19 01:59:48 +00:00
}
2002-07-23 01:41:40 +00:00
else if( GAMESTATE->m_PlayMode == PLAY_MODE_ARCADE && !bRoulette )
2002-05-19 01:59:48 +00:00
{
2002-07-27 19:29:51 +00:00
arrayWheelItemDatas.Add( WheelItemData(TYPE_ROULETTE, NULL, "", NULL, D3DXCOLOR(1,0,0,1)) );
2002-01-16 10:01:32 +00:00
}
}
void MusicWheel::SwitchSortOrder()
{
}
2002-01-16 10:01:32 +00:00
float MusicWheel::GetBannerY( float fPosOffsetsFromMiddle )
{
2002-05-19 01:59:48 +00:00
return (float)roundf( fPosOffsetsFromMiddle*44 );
2002-01-16 10:01:32 +00:00
}
float MusicWheel::GetBannerBrightness( float fPosOffsetsFromMiddle )
{
2002-04-16 17:31:00 +00:00
//return 1 - fabsf(fPosOffsetsFromMiddle)*0.11f;
return 1;
2002-01-16 10:01:32 +00:00
}
float MusicWheel::GetBannerAlpha( float fPosOffsetsFromMiddle )
{
2002-04-16 17:31:00 +00:00
/*
if( m_WheelState == STATE_FLYING_OFF_BEFORE_NEXT_SORT
|| m_WheelState == STATE_TWEENING_OFF_SCREEN )
{
return m_fTimeLeftInState / FADE_SECONDS;
}
else if( m_WheelState == STATE_FLYING_ON_AFTER_NEXT_SORT
|| m_WheelState == STATE_TWEENING_ON_SCREEN )
{
return 1 - (m_fTimeLeftInState / FADE_SECONDS);
}
else if( m_WheelState == STATE_WAITING_OFF_SCREEN )
{
return 0;
}
2002-01-16 10:01:32 +00:00
else
{
2002-01-16 10:01:32 +00:00
return 1;
}
2002-04-16 17:31:00 +00:00
*/
return 1;
2002-01-16 10:01:32 +00:00
}
float MusicWheel::GetBannerX( float fPosOffsetsFromMiddle )
{
2002-02-24 01:43:11 +00:00
float fX = (1-cosf((fPosOffsetsFromMiddle)/3))*95.0f;
2002-04-16 17:31:00 +00:00
2002-05-19 01:59:48 +00:00
return (float)roundf( fX );
2002-01-16 10:01:32 +00:00
}
void MusicWheel::RebuildWheelItemDisplays()
2002-01-16 10:01:32 +00:00
{
// rewind to first index that will be displayed;
2002-01-16 10:01:32 +00:00
int iIndex = m_iSelection;
2002-02-10 06:25:12 +00:00
if( m_iSelection > GetCurWheelItemDatas().GetSize()-1 )
m_iSelection = 0;
2002-01-16 10:01:32 +00:00
for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW/2; i++ )
{
do
{
iIndex--;
if( iIndex < 0 )
iIndex = GetCurWheelItemDatas().GetSize()-1;
}
2002-04-16 17:31:00 +00:00
while( GetCurWheelItemDatas()[iIndex].m_WheelItemType == TYPE_SONG
&& GetCurWheelItemDatas()[iIndex].m_sSectionName != ""
&& GetCurWheelItemDatas()[iIndex].m_sSectionName != m_sExpandedSectionName );
}
// iIndex is now the index of the lowest WheelItem to draw
for( i=0; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ )
{
WheelItemData& data = GetCurWheelItemDatas()[iIndex];
WheelItemDisplay& display = m_WheelItemDisplays[i];
display.LoadFromWheelItemData( &data );
// increment iIndex
do
{
iIndex++;
if( iIndex > GetCurWheelItemDatas().GetSize()-1 )
iIndex = 0;
}
2002-04-16 17:31:00 +00:00
while( GetCurWheelItemDatas()[iIndex].m_WheelItemType == TYPE_SONG
&& GetCurWheelItemDatas()[iIndex].m_sSectionName != ""
&& GetCurWheelItemDatas()[iIndex].m_sSectionName != m_sExpandedSectionName );
2002-01-16 10:01:32 +00:00
}
}
2002-04-28 20:42:32 +00:00
void MusicWheel::NotesChanged( PlayerNumber pn ) // update grade graphics and top score
{
2002-07-23 01:41:40 +00:00
DifficultyClass dc = GAMESTATE->m_PreferredDifficultyClass[pn];
Song* pSong = GAMESTATE->m_pCurSong;
Notes* m_pNotes = GAMESTATE->m_pCurNotes[ pn ];
2002-04-28 20:42:32 +00:00
for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ )
{
WheelItemDisplay& display = m_WheelItemDisplays[i];
display.RefreshGrades();
}
}
2002-05-19 01:59:48 +00:00
void MusicWheel::DrawPrimitives()
{
for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ )
2002-01-16 10:01:32 +00:00
{
WheelItemDisplay& display = m_WheelItemDisplays[i];
2002-01-16 10:01:32 +00:00
2002-05-28 20:01:22 +00:00
switch( m_WheelState )
{
2002-06-24 22:04:31 +00:00
case STATE_SELECTING_MUSIC:
case STATE_ROULETTE_SPINNING:
case STATE_ROULETTE_SLOWING_DOWN:
case STATE_LOCKED:
2002-05-28 20:01:22 +00:00
{
float fThisBannerPositionOffsetFromSelection = i - NUM_WHEEL_ITEMS_TO_DRAW/2 + m_fPositionOffsetFromSelection;
2002-05-01 19:14:55 +00:00
2002-05-28 20:01:22 +00:00
float fY = GetBannerY( fThisBannerPositionOffsetFromSelection );
if( fY < -SCREEN_HEIGHT/2 || fY > SCREEN_HEIGHT/2 )
continue; // skip
2002-01-16 10:01:32 +00:00
2002-05-28 20:01:22 +00:00
float fX = GetBannerX( fThisBannerPositionOffsetFromSelection );
display.SetXY( fX, fY );
}
break;
};
2002-01-16 10:01:32 +00:00
2002-06-30 23:19:33 +00:00
if( m_WheelState == STATE_LOCKED && i != NUM_WHEEL_ITEMS_TO_DRAW/2 )
display.m_fPercentGray = 0.5f;
else
display.m_fPercentGray = 0;
display.Draw();
2002-01-16 10:01:32 +00:00
}
2002-05-19 01:59:48 +00:00
ActorFrame::DrawPrimitives();
2002-01-16 10:01:32 +00:00
}
void MusicWheel::Update( float fDeltaTime )
{
ActorFrame::Update( fDeltaTime );
for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ )
2002-01-16 10:01:32 +00:00
{
WheelItemDisplay& display = m_WheelItemDisplays[i];
display.Update( fDeltaTime );
2002-01-16 10:01:32 +00:00
}
2002-05-01 19:14:55 +00:00
float fScrollPercentage = (m_iSelection-m_fPositionOffsetFromSelection) / (float)GetCurWheelItemDatas().GetSize();
m_ScrollBar.SetPercentage( fScrollPercentage );
2002-01-16 10:01:32 +00:00
2002-06-14 22:25:22 +00:00
if( m_WheelState == STATE_ROULETTE_SPINNING )
{
2002-06-30 23:19:33 +00:00
NextMusic( false ); // spin as fast as possible
2002-06-24 22:04:31 +00:00
}
if( m_fTimeLeftBeforePlayMusicSample > 0 )
{
m_fTimeLeftBeforePlayMusicSample -= fDeltaTime;
if( m_fTimeLeftBeforePlayMusicSample < 0 )
SCREENMAN->SendMessageToTopScreen( SM_PlaySongSample, 0 );
2002-06-14 22:25:22 +00:00
}
2002-01-16 10:01:32 +00:00
// update wheel state
m_fTimeLeftInState -= fDeltaTime;
if( m_fTimeLeftInState <= 0 ) // time to go to a new state
{
switch( m_WheelState )
{
case STATE_FLYING_OFF_BEFORE_NEXT_SORT:
2002-01-16 10:01:32 +00:00
{
2002-06-14 22:25:22 +00:00
m_WheelState = STATE_FLYING_ON_AFTER_NEXT_SORT;
m_fTimeLeftInState = FADE_SECONDS;
2002-01-16 10:01:32 +00:00
2002-06-14 22:25:22 +00:00
Song* pPrevSelectedSong = GetCurWheelItemDatas()[m_iSelection].m_pSong;
CString sPrevSelectedSection = GetCurWheelItemDatas()[m_iSelection].m_sSectionName;
2002-01-16 10:01:32 +00:00
2002-06-14 22:25:22 +00:00
// change the sort order
GAMESTATE->m_SongSortOrder = SongSortOrder( (GAMESTATE->m_SongSortOrder+1) % NUM_SORT_ORDERS );
m_sExpandedSectionName = GetSectionNameFromSongAndSort( pPrevSelectedSong, GAMESTATE->m_SongSortOrder );
2002-06-14 22:25:22 +00:00
//RebuildWheelItems();
2002-01-16 10:01:32 +00:00
2002-06-14 22:25:22 +00:00
m_iSelection = 0;
2002-02-24 01:43:11 +00:00
2002-06-14 22:25:22 +00:00
if( pPrevSelectedSong != NULL ) // the previous selected item was a song
2002-02-24 01:43:11 +00:00
{
2002-06-14 22:25:22 +00:00
// find the previously selected song, and select it
for( i=0; i<GetCurWheelItemDatas().GetSize(); i++ )
2002-02-24 01:43:11 +00:00
{
2002-06-14 22:25:22 +00:00
if( GetCurWheelItemDatas()[i].m_pSong == pPrevSelectedSong )
{
m_iSelection = i;
break;
}
2002-02-24 01:43:11 +00:00
}
}
2002-06-14 22:25:22 +00:00
else // the previously selected item was a section
2002-02-24 01:43:11 +00:00
{
2002-06-14 22:25:22 +00:00
// find the previously selected song, and select it
for( i=0; i<GetCurWheelItemDatas().GetSize(); i++ )
2002-02-24 01:43:11 +00:00
{
2002-06-14 22:25:22 +00:00
if( GetCurWheelItemDatas()[i].m_sSectionName == sPrevSelectedSection )
{
m_iSelection = i;
break;
}
2002-02-24 01:43:11 +00:00
}
}
2002-06-14 22:25:22 +00:00
RebuildWheelItemDisplays();
2002-05-28 20:01:22 +00:00
2002-06-14 22:25:22 +00:00
TweenOnScreen();
2002-01-16 10:01:32 +00:00
}
break;
case STATE_FLYING_ON_AFTER_NEXT_SORT:
2002-05-19 01:59:48 +00:00
SCREENMAN->SendMessageToTopScreen( SM_PlaySongSample, 0 );
2002-06-24 22:04:31 +00:00
m_WheelState = STATE_SELECTING_MUSIC; // now, wait for input
2002-01-16 10:01:32 +00:00
break;
case STATE_TWEENING_ON_SCREEN:
2002-05-19 01:59:48 +00:00
SCREENMAN->SendMessageToTopScreen( SM_PlaySongSample, 0 );
m_fTimeLeftInState = 0;
if( GAMESTATE->IsExtraStage() || GAMESTATE->IsExtraStage2() )
{
2002-08-01 13:42:56 +00:00
// if ( m_bUseRandomExtra )
// {
// MUSIC->Stop();
// m_soundExpand.Play();
// m_WheelState = STATE_ROULETTE_SPINNING;
// m_SortOrder = SORT_GROUP;
// m_MusicSortDisplay.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
// m_MusicSortDisplay.SetEffectNone();
// BuildWheelItemDatas( m_WheelItemDatas[SORT_GROUP], SORT_GROUP, true );
// }
// else
{
m_WheelState = STATE_LOCKED;
m_soundStart.Play();
m_fLockedWheelVelocity = 0;
}
}
else
{
m_WheelState = STATE_SELECTING_MUSIC;
}
break;
case STATE_TWEENING_OFF_SCREEN:
m_WheelState = STATE_WAITING_OFF_SCREEN;
m_fTimeLeftInState = 0;
break;
2002-06-24 22:04:31 +00:00
case STATE_SELECTING_MUSIC:
2002-01-16 10:01:32 +00:00
m_fTimeLeftInState = 0;
break;
2002-06-24 22:04:31 +00:00
case STATE_ROULETTE_SPINNING:
break;
case STATE_WAITING_OFF_SCREEN:
break;
case STATE_LOCKED:
break;
2002-06-14 22:25:22 +00:00
case STATE_ROULETTE_SLOWING_DOWN:
2002-06-24 22:04:31 +00:00
if( m_iSwitchesLeftInSpinDown == 0 )
{
m_WheelState = STATE_LOCKED;
m_fTimeLeftInState = 0;
m_soundStart.Play();
m_fLockedWheelVelocity = 0;
}
else
{
m_iSwitchesLeftInSpinDown--;
switch( m_iSwitchesLeftInSpinDown )
{
case 4: m_fTimeLeftInState = 0.2f; break;
case 3: m_fTimeLeftInState = 0.4f; break;
case 2: m_fTimeLeftInState = 0.8f; break;
case 1: m_fTimeLeftInState = 1.3f; break;
case 0: m_fTimeLeftInState = 0.5f; break;
default: ASSERT(0);
}
LOG->Trace( "m_iSwitchesLeftInSpinDown id %d, m_fTimeLeftInState is %f", m_iSwitchesLeftInSpinDown, m_fTimeLeftInState );
2002-06-24 22:04:31 +00:00
if( m_iSwitchesLeftInSpinDown < 2 )
randomf(0,1) >= 0.5f ? NextMusic() : PrevMusic();
else
NextMusic();
}
break;
default:
ASSERT(0); // all state changes should be handled explitily
2002-06-14 22:25:22 +00:00
break;
2002-01-16 10:01:32 +00:00
}
}
2002-06-24 22:04:31 +00:00
if( m_WheelState == STATE_LOCKED )
{
m_fPositionOffsetFromSelection = clamp( m_fPositionOffsetFromSelection, -0.3f, +0.3f );
float fSpringForce = - m_fPositionOffsetFromSelection * LOCKED_INITIAL_VELOCITY;
2002-06-24 22:04:31 +00:00
m_fLockedWheelVelocity += fSpringForce;
float fDrag = -m_fLockedWheelVelocity * fDeltaTime*4;
m_fLockedWheelVelocity += fDrag;
m_fPositionOffsetFromSelection += m_fLockedWheelVelocity*fDeltaTime;
if( fabsf(m_fPositionOffsetFromSelection) < 0.01f && fabsf(m_fLockedWheelVelocity) < 0.01f )
{
m_fPositionOffsetFromSelection = 0;
m_fLockedWheelVelocity = 0;
}
}
else
{
2002-06-24 22:04:31 +00:00
// "rotate" wheel toward selected song
float fSpinSpeed;
if( m_WheelState == STATE_ROULETTE_SPINNING )
fSpinSpeed = 1.0f/ROULETTE_SWITCH_SECONDS;
2002-06-24 22:04:31 +00:00
else
fSpinSpeed = 0.6f + fabsf(m_fPositionOffsetFromSelection)/SWITCH_SECONDS;
2002-06-24 22:04:31 +00:00
if( m_fPositionOffsetFromSelection > 0 )
2002-06-29 11:59:09 +00:00
{
m_fPositionOffsetFromSelection -= fSpinSpeed*fDeltaTime;
if( m_fPositionOffsetFromSelection < 0 )
{
m_fPositionOffsetFromSelection = 0;
m_fTimeLeftBeforePlayMusicSample = SAMPLE_MUSIC_DELAY;
}
}
2002-06-24 22:04:31 +00:00
else if( m_fPositionOffsetFromSelection < 0 )
2002-06-29 11:59:09 +00:00
{
m_fPositionOffsetFromSelection += fSpinSpeed*fDeltaTime;
if( m_fPositionOffsetFromSelection > 0 )
{
m_fPositionOffsetFromSelection = 0;
m_fTimeLeftBeforePlayMusicSample = SAMPLE_MUSIC_DELAY;
}
}
}
2002-01-16 10:01:32 +00:00
}
2002-06-30 23:19:33 +00:00
void MusicWheel::PrevMusic( bool bSendSongChangedMessage )
2002-01-16 10:01:32 +00:00
{
2002-06-24 22:04:31 +00:00
if( m_WheelState == STATE_LOCKED )
{
m_fLockedWheelVelocity = LOCKED_INITIAL_VELOCITY;
2002-06-24 22:04:31 +00:00
m_soundLocked.Play();
return;
}
if( fabsf(m_fPositionOffsetFromSelection) > 0.5f ) // wheel is busy spinning
return;
2002-07-11 19:02:26 +00:00
m_fTimeLeftBeforePlayMusicSample = 0;
2002-01-20 07:51:09 +00:00
switch( m_WheelState )
{
2002-06-24 22:04:31 +00:00
case STATE_SELECTING_MUSIC:
2002-06-14 22:25:22 +00:00
case STATE_ROULETTE_SPINNING:
case STATE_ROULETTE_SLOWING_DOWN:
2002-01-20 07:51:09 +00:00
break; // fall through
default:
return; // don't fall through
}
2002-01-16 10:01:32 +00:00
// decrement m_iSelection
do
{
m_iSelection--;
if( m_iSelection < 0 )
m_iSelection = GetCurWheelItemDatas().GetSize()-1;
}
2002-06-14 22:25:22 +00:00
while( (GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_SONG || GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_COURSE)
&& GetCurWheelItemDatas()[m_iSelection].m_sSectionName != ""
&& GetCurWheelItemDatas()[m_iSelection].m_sSectionName != m_sExpandedSectionName );
RebuildWheelItemDisplays();
2002-01-16 10:01:32 +00:00
m_fPositionOffsetFromSelection -= 1;
2002-04-28 20:42:32 +00:00
m_soundChangeMusic.Play();
2002-06-30 23:19:33 +00:00
if( bSendSongChangedMessage )
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 );
2002-01-16 10:01:32 +00:00
}
2002-06-30 23:19:33 +00:00
void MusicWheel::NextMusic( bool bSendSongChangedMessage )
2002-01-16 10:01:32 +00:00
{
2002-06-24 22:04:31 +00:00
if( m_WheelState == STATE_LOCKED )
{
m_fLockedWheelVelocity = -LOCKED_INITIAL_VELOCITY;
2002-06-24 22:04:31 +00:00
m_soundLocked.Play();
return;
}
2002-07-11 19:02:26 +00:00
if( fabsf(m_fPositionOffsetFromSelection) > 0.5f ) // wheel is very busy spinning
2002-06-24 22:04:31 +00:00
return;
2002-07-11 19:02:26 +00:00
m_fTimeLeftBeforePlayMusicSample = 0;
2002-01-18 22:18:41 +00:00
switch( m_WheelState )
{
2002-06-24 22:04:31 +00:00
case STATE_SELECTING_MUSIC:
2002-06-14 22:25:22 +00:00
case STATE_ROULETTE_SPINNING:
case STATE_ROULETTE_SLOWING_DOWN:
2002-01-18 22:18:41 +00:00
break; // fall through
default:
LOG->Trace( "NextMusic() ignored" );
2002-01-18 22:18:41 +00:00
return; // don't continue
}
2002-01-16 10:01:32 +00:00
// increment m_iSelection
do
{
m_iSelection++;
if( m_iSelection > GetCurWheelItemDatas().GetSize()-1 )
m_iSelection = 0;
}
2002-06-14 22:25:22 +00:00
while( (GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_SONG || GetCurWheelItemDatas()[m_iSelection].m_WheelItemType == TYPE_COURSE)
&& GetCurWheelItemDatas()[m_iSelection].m_sSectionName != ""
&& GetCurWheelItemDatas()[m_iSelection].m_sSectionName != m_sExpandedSectionName );
RebuildWheelItemDisplays();
2002-01-16 10:01:32 +00:00
m_fPositionOffsetFromSelection += 1;
2002-04-28 20:42:32 +00:00
m_soundChangeMusic.Play();
2002-06-30 23:19:33 +00:00
if( bSendSongChangedMessage )
SCREENMAN->SendMessageToTopScreen( SM_SongChanged, 0 );
2002-01-16 10:01:32 +00:00
}
2002-05-19 01:59:48 +00:00
void MusicWheel::PrevSort()
{
NextSort();
}
2002-01-16 10:01:32 +00:00
void MusicWheel::NextSort()
{
2002-01-18 22:18:41 +00:00
switch( m_WheelState )
{
2002-06-24 22:04:31 +00:00
case STATE_SELECTING_MUSIC:
case STATE_FLYING_ON_AFTER_NEXT_SORT:
2002-01-18 22:18:41 +00:00
break; // fall through
default:
return; // don't continue
}
2002-01-16 10:01:32 +00:00
2002-04-28 20:42:32 +00:00
m_soundChangeSort.Play();
2002-01-16 10:01:32 +00:00
2002-05-28 20:01:22 +00:00
TweenOffScreen();
m_WheelState = STATE_FLYING_OFF_BEFORE_NEXT_SORT;
m_fTimeLeftInState = FADE_SECONDS;
2002-01-16 10:01:32 +00:00
}
2002-06-14 22:25:22 +00:00
bool MusicWheel::Select() // return true of a playable item was chosen
2002-01-16 10:01:32 +00:00
{
LOG->Trace( "MusicWheel::Select()" );
2002-06-24 22:04:31 +00:00
2002-06-14 22:25:22 +00:00
if( m_WheelState == STATE_ROULETTE_SPINNING )
{
m_WheelState = STATE_ROULETTE_SLOWING_DOWN;
m_iSwitchesLeftInSpinDown = ROULETTE_SLOW_DOWN_SWITCHES/2+1 + rand()%(ROULETTE_SLOW_DOWN_SWITCHES/2);
2002-06-24 22:04:31 +00:00
m_fTimeLeftInState = 0.1f;
2002-06-14 22:25:22 +00:00
return false;
}
switch( GetCurWheelItemDatas()[m_iSelection].m_WheelItemType )
2002-01-16 10:01:32 +00:00
{
case TYPE_SECTION:
2002-01-16 10:01:32 +00:00
{
CString sThisItemSectionName = GetCurWheelItemDatas()[m_iSelection].m_sSectionName;
2002-01-16 10:01:32 +00:00
if( m_sExpandedSectionName == sThisItemSectionName ) // already expanded
m_sExpandedSectionName = ""; // collapse it
else // already collapsed
m_sExpandedSectionName = sThisItemSectionName; // expand it
RebuildWheelItemDisplays();
2002-01-16 10:01:32 +00:00
2002-04-28 20:42:32 +00:00
m_soundExpand.Play();
2002-01-16 10:01:32 +00:00
m_iSelection = 0; // reset in case we can't find the last selected song
// find the section header and select it
for( int i=0; i<GetCurWheelItemDatas().GetSize(); i++ )
2002-01-16 10:01:32 +00:00
{
if( GetCurWheelItemDatas()[i].m_WheelItemType == TYPE_SECTION
&& GetCurWheelItemDatas()[i].m_sSectionName == sThisItemSectionName )
2002-01-16 10:01:32 +00:00
{
m_iSelection = i;
break;
}
}
}
return false;
2002-05-19 01:59:48 +00:00
case TYPE_ROULETTE:
2002-06-14 22:25:22 +00:00
m_soundExpand.Play();
m_WheelState = STATE_ROULETTE_SPINNING;
GAMESTATE->m_SongSortOrder = SORT_GROUP;
2002-06-30 23:19:33 +00:00
BuildWheelItemDatas( m_WheelItemDatas[SORT_GROUP], SORT_GROUP, true );
2002-05-19 01:59:48 +00:00
return false;
2002-01-16 10:01:32 +00:00
2002-04-16 17:31:00 +00:00
case TYPE_SONG:
2002-01-16 10:01:32 +00:00
default:
return true;
}
}
void MusicWheel::TweenOnScreen()
{
2002-02-07 02:16:14 +00:00
m_WheelState = STATE_TWEENING_ON_SCREEN;
m_fTimeLeftInState = FADE_SECONDS;
2002-05-28 20:01:22 +00:00
2002-05-29 09:47:24 +00:00
float fX, fY;
fX = GetBannerX(0);
fY = GetBannerY(0);
m_sprSelectionOverlay.SetXY( fX+320, fY );
m_sprSelectionOverlay.BeginTweeningQueued( 0.5f ); // sleep
m_sprSelectionOverlay.BeginTweeningQueued( 0.4f, Actor::TWEEN_BIAS_BEGIN );
m_sprSelectionOverlay.SetTweenX( fX );
2002-05-29 09:47:24 +00:00
2002-06-14 22:25:22 +00:00
2002-05-29 09:47:24 +00:00
fX = m_ScrollBar.GetX();
fY = m_ScrollBar.GetY();
m_ScrollBar.SetXY( fX+30, fY );
m_ScrollBar.BeginTweeningQueued( 0.7f ); // sleep
m_ScrollBar.BeginTweeningQueued( 0.2f, Actor::TWEEN_BIAS_BEGIN );
m_ScrollBar.SetTweenX( fX );
2002-05-28 20:01:22 +00:00
for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ )
{
WheelItemDisplay& display = m_WheelItemDisplays[i];
float fThisBannerPositionOffsetFromSelection = i - NUM_WHEEL_ITEMS_TO_DRAW/2 + m_fPositionOffsetFromSelection;
float fX = GetBannerX(fThisBannerPositionOffsetFromSelection);
float fY = GetBannerY(fThisBannerPositionOffsetFromSelection);
display.SetXY( fX+320, fY );
display.BeginTweeningQueued( 0.04f*i ); // sleep
display.BeginTweeningQueued( 0.2f, Actor::TWEEN_BIAS_BEGIN );
display.SetTweenX( fX );
}
2002-02-07 02:16:14 +00:00
}
void MusicWheel::TweenOffScreen()
{
2002-02-07 02:16:14 +00:00
m_WheelState = STATE_TWEENING_OFF_SCREEN;
m_fTimeLeftInState = FADE_SECONDS;
2002-05-28 20:01:22 +00:00
2002-05-29 09:47:24 +00:00
float fX, fY;
fX = GetBannerX(0);
fY = GetBannerY(0);
m_sprSelectionOverlay.SetXY( fX, fY );
m_sprSelectionOverlay.BeginTweeningQueued( 0 ); // sleep
m_sprSelectionOverlay.BeginTweeningQueued( 0.2f, Actor::TWEEN_BIAS_END );
m_sprSelectionOverlay.SetTweenX( fX+320 );
2002-05-29 09:47:24 +00:00
m_ScrollBar.BeginTweeningQueued( 0 );
m_ScrollBar.BeginTweeningQueued( 0.2f, Actor::TWEEN_BIAS_BEGIN );
m_ScrollBar.SetTweenX( m_ScrollBar.GetX()+30 );
2002-05-28 20:01:22 +00:00
for( int i=0; i<NUM_WHEEL_ITEMS_TO_DRAW; i++ )
{
WheelItemDisplay& display = m_WheelItemDisplays[i];
float fThisBannerPositionOffsetFromSelection = i - NUM_WHEEL_ITEMS_TO_DRAW/2 + m_fPositionOffsetFromSelection;
float fX = GetBannerX(fThisBannerPositionOffsetFromSelection);
float fY = GetBannerY(fThisBannerPositionOffsetFromSelection);
display.SetXY( fX, fY );
display.BeginTweeningQueued( 0.04f*i ); // sleep
display.BeginTweeningQueued( 0.2f, Actor::TWEEN_BIAS_END );
display.SetTweenX( fX+320 );
}
2002-02-09 18:53:47 +00:00
2002-06-24 22:04:31 +00:00
}