2003-02-17 02:45:30 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: CourseContentsList
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "CourseContentsList.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "Course.h"
|
|
|
|
|
#include "SongManager.h"
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include "ThemeManager.h"
|
2003-08-03 00:13:55 +00:00
|
|
|
#include "Steps.h"
|
2003-02-17 02:45:30 +00:00
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "StyleDef.h"
|
2003-11-07 20:46:04 +00:00
|
|
|
#include "RageTexture.h"
|
2003-02-17 02:45:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
CourseContentsList::CourseContentsList()
|
|
|
|
|
{
|
|
|
|
|
m_iNumContents = 0;
|
2003-05-29 01:30:41 +00:00
|
|
|
m_quad.SetDiffuse( RageColor(0,0,0,1) );
|
|
|
|
|
m_quad.SetBlendMode( BLEND_NO_EFFECT ); // invisible, since we want to write only to the Zbuffer
|
2003-02-17 02:45:30 +00:00
|
|
|
|
|
|
|
|
m_fTimeUntilScroll = 0;
|
|
|
|
|
m_fItemAtTopOfList = 0;
|
|
|
|
|
|
2003-05-29 01:30:41 +00:00
|
|
|
m_quad.SetUseZBuffer( true );
|
|
|
|
|
for( int i = 0; i < MAX_TOTAL_CONTENTS; ++i )
|
|
|
|
|
m_CourseContentDisplays[i].SetUseZBuffer( true );
|
|
|
|
|
|
2003-02-17 02:45:30 +00:00
|
|
|
/* These are all the same; grab the dimensions. */
|
|
|
|
|
ContentsBarHeight = m_CourseContentDisplays[0].m_sprFrame.GetTexture()->GetSourceFrameHeight();
|
|
|
|
|
ContentsBarWidth = m_CourseContentDisplays[0].m_sprFrame.GetTexture()->GetSourceFrameWidth();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CourseContentsList::SetFromCourse( Course* pCourse )
|
|
|
|
|
{
|
2003-07-20 02:27:37 +00:00
|
|
|
if( pCourse == NULL )
|
|
|
|
|
{
|
|
|
|
|
m_iNumContents = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-02-17 02:45:30 +00:00
|
|
|
|
|
|
|
|
m_iNumContents = 0;
|
|
|
|
|
|
2003-07-21 21:54:07 +00:00
|
|
|
vector<Course::Info> ci;
|
2003-08-07 06:36:34 +00:00
|
|
|
pCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_StepsType, ci );
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2003-07-21 21:54:07 +00:00
|
|
|
for( int i=0; i<min((int)ci.size(), MAX_TOTAL_CONTENTS); i++ )
|
2003-02-17 02:45:30 +00:00
|
|
|
{
|
|
|
|
|
CourseEntryDisplay& display = m_CourseContentDisplays[m_iNumContents];
|
|
|
|
|
|
2003-07-30 21:33:20 +00:00
|
|
|
if( ci[i].Mystery )
|
2003-02-17 02:45:30 +00:00
|
|
|
{
|
2003-07-21 22:21:03 +00:00
|
|
|
Difficulty dc = pCourse->GetDifficulty( ci[i] );
|
2003-02-17 02:45:30 +00:00
|
|
|
int iMeterLow, iMeterHigh;
|
2003-07-21 22:21:03 +00:00
|
|
|
pCourse->GetMeterRange(ci[i], iMeterLow, iMeterHigh);
|
2003-02-17 02:45:30 +00:00
|
|
|
|
|
|
|
|
if( dc == DIFFICULTY_INVALID )
|
2003-07-21 21:54:07 +00:00
|
|
|
display.LoadFromMeterRange( m_iNumContents+1, iMeterLow, iMeterHigh, ci[i].Modifiers );
|
2003-02-17 02:45:30 +00:00
|
|
|
else
|
2003-07-21 21:54:07 +00:00
|
|
|
display.LoadFromDifficulty( m_iNumContents+1, dc, ci[i].Modifiers );
|
2003-02-17 02:45:30 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-07-21 23:16:06 +00:00
|
|
|
display.LoadFromSongAndNotes( m_iNumContents+1, ci[i].pSong, ci[i].pNotes, ci[i].Modifiers );
|
2003-02-17 02:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_iNumContents ++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CourseContentsList::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
ActorFrame::Update( fDeltaTime );
|
|
|
|
|
|
|
|
|
|
if( m_fTimeUntilScroll > 0 && m_iNumContents > MAX_VISIBLE_CONTENTS)
|
|
|
|
|
m_fTimeUntilScroll -= fDeltaTime;
|
|
|
|
|
if( m_fTimeUntilScroll <= 0 ) {
|
|
|
|
|
m_fItemAtTopOfList += fDeltaTime;
|
|
|
|
|
m_fItemAtTopOfList = fmodf(m_fItemAtTopOfList, float(m_iNumContents));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( int i=0; i<m_iNumContents; i++ )
|
|
|
|
|
m_CourseContentDisplays[i].Update( fDeltaTime );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CourseContentsList::DrawPrimitives()
|
|
|
|
|
{
|
|
|
|
|
// write to z buffer so that top and bottom are clipped
|
|
|
|
|
m_quad.SetZ( 1 );
|
|
|
|
|
|
|
|
|
|
RectI rectBarSize(-ContentsBarWidth/2, -ContentsBarHeight/2,
|
|
|
|
|
ContentsBarWidth/2, ContentsBarHeight/2);
|
|
|
|
|
m_quad.StretchTo( rectBarSize );
|
|
|
|
|
|
|
|
|
|
m_quad.SetY( (-(MAX_VISIBLE_CONTENTS-1)/2 - 1) * float(ContentsBarHeight) );
|
|
|
|
|
m_quad.Draw();
|
|
|
|
|
|
|
|
|
|
m_quad.SetY( ((MAX_VISIBLE_CONTENTS-1)/2 + 1) * float(ContentsBarHeight) );
|
|
|
|
|
m_quad.Draw();
|
|
|
|
|
|
|
|
|
|
int iItemToDraw = (int)m_fItemAtTopOfList;
|
|
|
|
|
|
|
|
|
|
// HACK: Insert a little pause as a new item appears on the screen
|
|
|
|
|
float fRemainder = m_fItemAtTopOfList - (int)m_fItemAtTopOfList;
|
|
|
|
|
fRemainder = min( fRemainder*1.5f, 1 );
|
|
|
|
|
|
|
|
|
|
const float fY = (-fRemainder-(MAX_VISIBLE_CONTENTS-1)/2) * ContentsBarHeight;
|
|
|
|
|
|
|
|
|
|
for( int i=0; i<min(MAX_VISIBLE_CONTENTS+1, m_iNumContents); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_fTimeUntilScroll <= 0 )
|
|
|
|
|
m_CourseContentDisplays[iItemToDraw].SetY( fY + i*ContentsBarHeight);
|
|
|
|
|
m_CourseContentDisplays[iItemToDraw].Draw();
|
|
|
|
|
iItemToDraw = (iItemToDraw+1) % m_iNumContents;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CourseContentsList::TweenInAfterChangedCourse()
|
|
|
|
|
{
|
|
|
|
|
m_fItemAtTopOfList = 0;
|
|
|
|
|
m_fTimeUntilScroll = 3;
|
|
|
|
|
|
|
|
|
|
for( int i=0; i<m_iNumContents; i++ )
|
|
|
|
|
{
|
|
|
|
|
CourseEntryDisplay& display = m_CourseContentDisplays[i];
|
|
|
|
|
|
|
|
|
|
display.StopTweening();
|
2003-03-28 02:15:29 +00:00
|
|
|
display.SetXY( 0, -((MAX_VISIBLE_CONTENTS-1)/2) * float(ContentsBarHeight) );
|
2003-02-17 02:45:30 +00:00
|
|
|
display.BeginTweening( i*0.1f );
|
2003-04-12 06:16:12 +00:00
|
|
|
display.SetY( (-(MAX_VISIBLE_CONTENTS-1)/2 + i) * float(ContentsBarHeight) );
|
2003-02-17 02:45:30 +00:00
|
|
|
}
|
|
|
|
|
}
|