2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-08-25 23:10:28 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: ScrollingList
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Andrew Livy
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ScrollingList.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "Course.h"
|
|
|
|
|
#include "SongManager.h"
|
2002-12-10 23:16:44 +00:00
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
|
|
|
|
|
enum BANNER_PREFS_TYPES
|
|
|
|
|
{
|
|
|
|
|
BANNERPREFS_DDRFLAT=0,
|
|
|
|
|
BANNERPREFS_DDRROT,
|
|
|
|
|
BANNERPREFS_EZ2,
|
|
|
|
|
BANNERPREFS_PUMP,
|
|
|
|
|
BANNERPREFS_PARA
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define BANNER_WIDTH THEME->GetMetricF("ScreenSelectMusic","BannerWidth")
|
|
|
|
|
#define BANNER_HEIGHT THEME->GetMetricF("ScreenSelectMusic","BannerHeight")
|
2003-06-02 19:25:29 +00:00
|
|
|
#define EZ2_BANNER_WIDTH THEME->GetMetricF("ScreenSelectMusic","BannerWidth")
|
|
|
|
|
#define EZ2_BANNER_HEIGHT THEME->GetMetricF("ScreenSelectMusic","BannerHeight")
|
2002-12-10 23:16:44 +00:00
|
|
|
#define EZ2_BANNER_ZOOM 2.0
|
|
|
|
|
|
2003-06-02 19:25:29 +00:00
|
|
|
#define ZOOM_OFFSET THEME->GetMetricF("ScreenEz2SelectMusic","BannerZoomOffset")
|
|
|
|
|
#define FADE_OFFSET THEME->GetMetricF("ScreenEz2SelectMusic","BannerFadeOffset")
|
2003-06-09 01:13:25 +00:00
|
|
|
#define BANNER_ROTATION THEME->GetMetricF("ScreenEz2SelectMusic","BannerRotation")
|
|
|
|
|
|
2003-06-02 19:25:29 +00:00
|
|
|
|
2002-12-10 23:16:44 +00:00
|
|
|
#define SPRITE_TYPE_SPRITE 0
|
|
|
|
|
#define SPRITE_TYPE_CROPPEDSPRITE 1
|
|
|
|
|
#define DDRROT_ROTATION 315
|
2002-08-25 23:10:28 +00:00
|
|
|
|
2002-09-18 18:24:33 +00:00
|
|
|
const int DEFAULT_VISIBLE_ELEMENTS = 9;
|
2002-08-29 20:18:41 +00:00
|
|
|
const int DEFAULT_SPACING = 300;
|
2002-08-25 23:10:28 +00:00
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
const RageColor COLOR_SELECTED = RageColor(1.0f,1.0f,1.0f,1);
|
|
|
|
|
const RageColor COLOR_NOT_SELECTED = RageColor(0.4f,0.4f,0.4f,1);
|
2002-08-25 23:10:28 +00:00
|
|
|
|
|
|
|
|
/***************************************
|
|
|
|
|
ScrollingList
|
|
|
|
|
|
|
|
|
|
Initializes Variables for the ScrollingList
|
|
|
|
|
****************************************/
|
|
|
|
|
ScrollingList::ScrollingList()
|
|
|
|
|
{
|
2003-01-18 19:07:52 +00:00
|
|
|
m_iBouncingState = 0;
|
2003-06-02 19:25:29 +00:00
|
|
|
m_iBounceSize = 0;
|
2003-01-18 19:07:52 +00:00
|
|
|
m_fNextTween = 0;
|
2002-12-10 23:16:44 +00:00
|
|
|
m_iBannerPrefs = BANNERPREFS_EZ2;
|
|
|
|
|
m_iSpriteType = SPRITE_TYPE_SPRITE;
|
2002-08-29 20:18:41 +00:00
|
|
|
m_iSelection = 0;
|
|
|
|
|
m_fSelectionLag = 0;
|
|
|
|
|
m_iSpacing = DEFAULT_SPACING;
|
|
|
|
|
m_iNumVisible = DEFAULT_VISIBLE_ELEMENTS;
|
2003-01-18 19:07:52 +00:00
|
|
|
m_iBounceDir=0;
|
|
|
|
|
m_iBounceWait=0;
|
2003-06-02 19:25:29 +00:00
|
|
|
m_sprBannerMask.SetName( "Banner" ); // use the same metrics and animation as Banner
|
|
|
|
|
m_sprBannerMask.Load( THEME->GetPathToG("ScreenSelectMusic banner mask") );
|
2003-01-18 19:07:52 +00:00
|
|
|
m_RippleCSprite.SetXY(0,0);
|
2003-05-02 15:12:09 +00:00
|
|
|
m_RippleSprite.SetXY(0,0);
|
2003-06-02 19:25:29 +00:00
|
|
|
m_sprBannerMask.SetBlendMode( BLEND_NO_EFFECT ); // don't draw to color buffer
|
|
|
|
|
m_sprBannerMask.SetUseZBuffer( true ); // do draw to the zbuffer
|
|
|
|
|
m_sprBannerMask.SetWidth(EZ2_BANNER_WIDTH);
|
|
|
|
|
m_sprBannerMask.SetHeight(EZ2_BANNER_HEIGHT);
|
2002-08-25 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
2002-12-10 23:16:44 +00:00
|
|
|
void ScrollingList::UseSpriteType(int NewSpriteType)
|
|
|
|
|
{
|
|
|
|
|
m_iSpriteType = NewSpriteType;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-29 20:18:41 +00:00
|
|
|
ScrollingList::~ScrollingList()
|
|
|
|
|
{
|
|
|
|
|
Unload();
|
|
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
|
2002-08-29 20:18:41 +00:00
|
|
|
void ScrollingList::Unload()
|
|
|
|
|
{
|
2002-12-10 23:16:44 +00:00
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i=0; i<m_apSprites.size(); i++ )
|
|
|
|
|
delete m_apSprites[i];
|
|
|
|
|
m_apSprites.clear();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i=0; i<m_apCSprites.size(); i++ )
|
|
|
|
|
delete m_apCSprites[i];
|
|
|
|
|
m_apCSprites.clear();
|
|
|
|
|
}
|
2002-08-29 20:18:41 +00:00
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
|
2003-01-18 19:07:52 +00:00
|
|
|
void ScrollingList::StartBouncing()
|
|
|
|
|
{
|
|
|
|
|
m_iBouncingState = 1;
|
|
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
|
|
|
|
{
|
2003-05-09 00:18:37 +00:00
|
|
|
m_RippleSprite.UnloadTexture();
|
2003-05-02 15:12:09 +00:00
|
|
|
m_RippleSprite.Load( m_apSprites[m_iSelection]->GetTexturePath() );
|
|
|
|
|
m_RippleSprite.SetXY( m_apSprites[m_iSelection]->GetX(), m_apSprites[m_iSelection]->GetY() );
|
|
|
|
|
m_RippleSprite.SetZoom( 1.1f );
|
|
|
|
|
m_RippleSprite.SetDiffuse( RageColor(1,1,1,0.5f));
|
2003-01-18 19:07:52 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-05-09 00:18:37 +00:00
|
|
|
m_RippleCSprite.UnloadTexture();
|
2003-01-18 19:07:52 +00:00
|
|
|
m_RippleCSprite.Load( m_apCSprites[m_iSelection]->GetTexturePath() );
|
2003-05-09 00:18:37 +00:00
|
|
|
|
|
|
|
|
if(m_RippleCSprite.GetUnzoomedWidth() == m_RippleCSprite.GetUnzoomedHeight()) // rotated graphics need cropping
|
|
|
|
|
{
|
|
|
|
|
m_RippleCSprite.SetCroppedSize( 100, 100 );
|
|
|
|
|
}
|
|
|
|
|
else // flat, unrotated graphics need widths changing
|
|
|
|
|
{
|
|
|
|
|
m_RippleCSprite.SetCroppedSize( -1, -1 ); // default image size.
|
2003-05-09 20:28:27 +00:00
|
|
|
m_RippleCSprite.SetWH(EZ2_BANNER_WIDTH+10, EZ2_BANNER_HEIGHT+10);
|
2003-05-09 00:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-18 19:07:52 +00:00
|
|
|
m_RippleCSprite.SetXY( m_apCSprites[m_iSelection]->GetX(), m_apCSprites[m_iSelection]->GetY() );
|
|
|
|
|
m_RippleCSprite.SetZoom( 2.0f );
|
|
|
|
|
m_RippleCSprite.SetDiffuse( RageColor(1,1,1,0.5f));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScrollingList::StopBouncing()
|
|
|
|
|
{
|
|
|
|
|
m_iBouncingState = 0;
|
|
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
|
|
|
|
m_apSprites[m_iSelection]->SetZoom( 1.0f );
|
|
|
|
|
else
|
|
|
|
|
m_apCSprites[m_iSelection]->SetZoom( 1.0f );
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-29 20:18:41 +00:00
|
|
|
/************************************
|
|
|
|
|
Allows us to create a graphic element
|
|
|
|
|
in the scrolling list
|
|
|
|
|
*************************************/
|
|
|
|
|
void ScrollingList::Load( const CStringArray& asGraphicPaths )
|
2002-08-25 23:10:28 +00:00
|
|
|
{
|
2002-08-29 20:18:41 +00:00
|
|
|
Unload();
|
2002-12-10 23:16:44 +00:00
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
2002-08-25 23:10:28 +00:00
|
|
|
{
|
2002-12-10 23:16:44 +00:00
|
|
|
for( unsigned i=0; i<asGraphicPaths.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
Sprite* pNewSprite = new Sprite;
|
|
|
|
|
pNewSprite->Load( asGraphicPaths[i] );
|
|
|
|
|
m_apSprites.push_back( pNewSprite );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i=0; i<asGraphicPaths.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
CroppedSprite* pNewCSprite = new CroppedSprite;
|
2002-12-30 02:43:52 +00:00
|
|
|
pNewCSprite->Load( asGraphicPaths[i] );
|
2003-05-09 00:18:37 +00:00
|
|
|
|
2002-12-10 23:16:44 +00:00
|
|
|
m_apCSprites.push_back( pNewCSprite );
|
2003-05-09 00:18:37 +00:00
|
|
|
for(int i=m_apCSprites.size()-1; i>=0; i--)
|
|
|
|
|
Replace(asGraphicPaths[i],i);
|
2002-12-10 23:16:44 +00:00
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************
|
|
|
|
|
ShiftLeft
|
|
|
|
|
|
|
|
|
|
Make the entire list shuffle left
|
|
|
|
|
**************************************/
|
2002-08-29 20:18:41 +00:00
|
|
|
void ScrollingList::Left()
|
2002-08-25 23:10:28 +00:00
|
|
|
{
|
2002-12-10 23:16:44 +00:00
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
|
|
|
|
{
|
|
|
|
|
ASSERT( !m_apSprites.empty() ); // nothing loaded!
|
2002-08-25 23:10:28 +00:00
|
|
|
|
2002-12-10 23:16:44 +00:00
|
|
|
m_iSelection = (m_iSelection + m_apSprites.size() - 1) % m_apSprites.size(); // decrement with wrapping
|
|
|
|
|
m_fSelectionLag -= 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ASSERT( !m_apCSprites.empty() ); // nothing loaded!
|
|
|
|
|
|
|
|
|
|
m_iSelection = (m_iSelection + m_apCSprites.size() - 1) % m_apCSprites.size(); // decrement with wrapping
|
|
|
|
|
m_fSelectionLag -= 1;
|
|
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**************************************
|
|
|
|
|
ShiftRight
|
|
|
|
|
|
|
|
|
|
Make the entire list shuffle right
|
|
|
|
|
**************************************/
|
2002-08-29 20:18:41 +00:00
|
|
|
void ScrollingList::Right()
|
2002-08-25 23:10:28 +00:00
|
|
|
{
|
2002-12-10 23:16:44 +00:00
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
|
|
|
|
{
|
|
|
|
|
ASSERT( !m_apSprites.empty() ); // nothing loaded!
|
|
|
|
|
|
|
|
|
|
m_iSelection = (m_iSelection + 1) % m_apSprites.size(); // increment with wrapping
|
|
|
|
|
m_fSelectionLag += 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ASSERT( !m_apCSprites.empty() ); // nothing loaded!
|
2002-08-25 23:10:28 +00:00
|
|
|
|
2002-12-10 23:16:44 +00:00
|
|
|
m_iSelection = (m_iSelection + 1) % m_apCSprites.size(); // increment with wrapping
|
|
|
|
|
m_fSelectionLag += 1;
|
|
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************
|
|
|
|
|
SetCurrentPostion
|
|
|
|
|
|
|
|
|
|
From the current postion in the array, add graphic elements
|
|
|
|
|
in either direction to make the list seem infinite.
|
|
|
|
|
***********************************/
|
2002-08-29 20:18:41 +00:00
|
|
|
void ScrollingList::SetSelection( int iIndex )
|
2002-08-25 23:10:28 +00:00
|
|
|
{
|
2002-08-29 20:18:41 +00:00
|
|
|
m_iSelection = iIndex;
|
|
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
|
2002-08-29 20:18:41 +00:00
|
|
|
int ScrollingList::GetSelection()
|
|
|
|
|
{
|
|
|
|
|
return m_iSelection;
|
|
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
|
2002-08-29 20:18:41 +00:00
|
|
|
void ScrollingList::SetSpacing( int iSpacingInPixels )
|
|
|
|
|
{
|
|
|
|
|
m_iSpacing = iSpacingInPixels;
|
2002-08-25 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************
|
|
|
|
|
SetNumberVisibleElements
|
|
|
|
|
|
|
|
|
|
Allows us to set whether 3,4 or 5
|
|
|
|
|
elements are visible on screen at once
|
|
|
|
|
*******************************/
|
2002-08-29 20:18:41 +00:00
|
|
|
void ScrollingList::SetNumberVisible( int iNumVisibleElements )
|
2002-08-25 23:10:28 +00:00
|
|
|
{
|
2002-08-29 20:18:41 +00:00
|
|
|
m_iNumVisible = iNumVisibleElements;
|
2002-08-25 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************
|
|
|
|
|
Update
|
|
|
|
|
|
|
|
|
|
Updates the actorframe
|
|
|
|
|
********************************/
|
|
|
|
|
void ScrollingList::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
ActorFrame::Update( fDeltaTime );
|
2002-12-10 23:16:44 +00:00
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
|
|
|
|
{
|
|
|
|
|
if( m_apSprites.empty() )
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( m_apCSprites.empty() )
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-08-29 20:18:41 +00:00
|
|
|
|
|
|
|
|
// update m_fLaggingSelection
|
|
|
|
|
if( m_fSelectionLag != 0 )
|
|
|
|
|
{
|
|
|
|
|
const float fSign = m_fSelectionLag<0 ? -1.0f : +1.0f;
|
|
|
|
|
const float fVelocity = -fSign + -m_fSelectionLag*10;
|
|
|
|
|
m_fSelectionLag += fVelocity * fDeltaTime;
|
|
|
|
|
|
|
|
|
|
// check to see if m_fLaggingSelection passed its destination
|
|
|
|
|
const float fNewSign = m_fSelectionLag<0 ? -1.0f : +1.0f;
|
|
|
|
|
if( (fSign<0) ^ (fNewSign<0) ) // they have different signs
|
|
|
|
|
m_fSelectionLag = 0; // snap
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-10 23:16:44 +00:00
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
|
|
|
|
{
|
2003-05-02 15:12:09 +00:00
|
|
|
if(m_iBouncingState) // bouncing
|
|
|
|
|
{
|
|
|
|
|
if(m_fNextTween <= 0) // we're ready to update stuff
|
|
|
|
|
{
|
|
|
|
|
m_fNextTween = 0.1f; // reset the tween count
|
|
|
|
|
if(m_apSprites[m_iSelection]->GetZoom() >= 1.2f && m_iBounceDir == 1) // if we're over biggest boundary
|
|
|
|
|
{
|
|
|
|
|
m_iBounceDir = 2; // next phase will be a wait
|
|
|
|
|
m_apSprites[m_iSelection]->SetZoom( m_apSprites[m_iSelection]->GetZoom() - 0.25f); // make it smaller
|
|
|
|
|
m_RippleSprite.SetZoom( m_RippleSprite.GetZoom() - 0.30f); // make the ripple smaller
|
|
|
|
|
}
|
|
|
|
|
else if(m_apSprites[m_iSelection]->GetZoom() <= 1.0f && m_iBounceDir == 0) // if we're over smallest boundary
|
|
|
|
|
{
|
|
|
|
|
m_iBounceDir = 1; // next phase will be making graphic bigger
|
|
|
|
|
m_apSprites[m_iSelection]->SetZoom( m_apSprites[m_iSelection]->GetZoom() + 0.25f); // make it bigger
|
|
|
|
|
m_RippleSprite.SetZoom( m_RippleSprite.GetZoom() + 0.30f); // make ripple bigger
|
|
|
|
|
m_RippleSprite.SetDiffuse( RageColor(1,1,1,0.5f)); // make ripple appear semi transparent
|
|
|
|
|
}
|
|
|
|
|
else if(m_iBounceDir == 0 && m_apSprites[m_iSelection]->GetZoom() != 1.0f) // travelling smaller
|
|
|
|
|
{
|
|
|
|
|
m_apSprites[m_iSelection]->SetZoom( m_apSprites[m_iSelection]->GetZoom() - 0.25f); // make smaller
|
|
|
|
|
m_RippleSprite.SetZoom( m_RippleSprite.GetZoom() - 0.30f); // make smaller
|
|
|
|
|
}
|
|
|
|
|
else if(m_iBounceDir == 1 && m_apSprites[m_iSelection]->GetZoom() != 1.2f) // travelling bigger
|
|
|
|
|
{
|
|
|
|
|
m_apSprites[m_iSelection]->SetZoom( m_apSprites[m_iSelection]->GetZoom() + 0.25f); // make bigger
|
|
|
|
|
m_RippleSprite.SetZoom( m_RippleSprite.GetZoom() + 0.30f ); // make bigger
|
|
|
|
|
}
|
|
|
|
|
else if(m_iBounceDir == 2) // we're waiting before doing bounce processes again
|
|
|
|
|
{
|
|
|
|
|
if(m_iBounceWait == 0) // if we're at 0 from last time....
|
|
|
|
|
m_iBounceWait = 3; // start wait at 3
|
|
|
|
|
else
|
|
|
|
|
m_iBounceWait--; // otherwise decrease by 1
|
|
|
|
|
|
|
|
|
|
if(m_iBounceWait == 2) // if we're one moment after start of wait
|
|
|
|
|
m_RippleSprite.SetDiffuse( RageColor(1,1,1,0.0f)); // hide the ripple
|
|
|
|
|
|
|
|
|
|
if(m_iBounceWait == 0) // if we just turned to 0
|
|
|
|
|
m_iBounceDir = 0; // go to the 'make smaller' stage. as we SHOULD already be pretty small, we should start increasing in size a couple phases on.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_fNextTween -= fDeltaTime; // update the tween time.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-10 23:16:44 +00:00
|
|
|
for( unsigned i=0; i<m_apSprites.size(); i++ )
|
|
|
|
|
m_apSprites[i]->Update( fDeltaTime );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-01-18 19:07:52 +00:00
|
|
|
if(m_iBouncingState) // bouncing
|
|
|
|
|
{
|
|
|
|
|
if(m_fNextTween <= 0) // we're ready to update stuff
|
|
|
|
|
{
|
|
|
|
|
m_fNextTween = 0.1f; // reset the tween count
|
2003-06-02 19:25:29 +00:00
|
|
|
|
|
|
|
|
if(m_iBounceSize <= 0 && m_iBounceDir == 0 ) // going smaller
|
2003-01-18 19:07:52 +00:00
|
|
|
{
|
2003-06-02 19:25:29 +00:00
|
|
|
m_iBounceDir = 2;
|
2003-01-18 19:07:52 +00:00
|
|
|
}
|
2003-06-02 19:25:29 +00:00
|
|
|
else if(m_iBounceDir == 1 && m_iBounceSize >= 0.2f) // getting big
|
2003-01-18 19:07:52 +00:00
|
|
|
{
|
2003-06-02 19:25:29 +00:00
|
|
|
m_iBounceDir = 0;
|
2003-01-18 19:07:52 +00:00
|
|
|
}
|
2003-06-02 19:25:29 +00:00
|
|
|
else if(m_iBounceDir == 0)
|
2003-01-18 19:07:52 +00:00
|
|
|
{
|
2003-06-02 19:25:29 +00:00
|
|
|
m_iBounceSize-=0.2f;
|
2003-01-18 19:07:52 +00:00
|
|
|
}
|
2003-06-02 19:25:29 +00:00
|
|
|
else if(m_iBounceDir == 1)
|
2003-01-18 19:07:52 +00:00
|
|
|
{
|
2003-06-02 19:25:29 +00:00
|
|
|
m_iBounceSize+=0.2f;
|
2003-01-18 19:07:52 +00:00
|
|
|
}
|
|
|
|
|
else if(m_iBounceDir == 2) // we're waiting before doing bounce processes again
|
|
|
|
|
{
|
|
|
|
|
if(m_iBounceWait == 0) // if we're at 0 from last time....
|
|
|
|
|
m_iBounceWait = 3; // start wait at 3
|
|
|
|
|
else
|
|
|
|
|
m_iBounceWait--; // otherwise decrease by 1
|
|
|
|
|
|
|
|
|
|
if(m_iBounceWait == 2) // if we're one moment after start of wait
|
2003-06-02 19:25:29 +00:00
|
|
|
m_RippleSprite.SetDiffuse( RageColor(1,1,1,0.0f)); // hide the ripple
|
2003-01-18 19:07:52 +00:00
|
|
|
|
|
|
|
|
if(m_iBounceWait == 0) // if we just turned to 0
|
2003-06-02 19:25:29 +00:00
|
|
|
m_iBounceDir = 1;
|
2003-01-18 19:07:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_fNextTween -= fDeltaTime; // update the tween time.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-10 23:16:44 +00:00
|
|
|
for( unsigned i=0; i<m_apCSprites.size(); i++ )
|
|
|
|
|
m_apCSprites[i]->Update( fDeltaTime );
|
|
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-15 21:25:47 +00:00
|
|
|
void ScrollingList::Replace(CString sGraphicPath, int ElementNumber)
|
|
|
|
|
{
|
|
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
|
|
|
|
{
|
|
|
|
|
Sprite* pNewSprite = new Sprite;
|
|
|
|
|
pNewSprite->Load( sGraphicPath );
|
|
|
|
|
m_apSprites[ElementNumber] = pNewSprite;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CroppedSprite* pNewCSprite = new CroppedSprite;
|
2003-05-09 00:18:37 +00:00
|
|
|
pNewCSprite->Load( sGraphicPath );
|
2003-01-15 21:25:47 +00:00
|
|
|
if(m_iBannerPrefs == BANNERPREFS_DDRFLAT)
|
|
|
|
|
{
|
2003-05-09 00:18:37 +00:00
|
|
|
if(pNewCSprite->GetUnzoomedWidth() == pNewCSprite->GetUnzoomedHeight()) // rotated graphics need cropping
|
|
|
|
|
{
|
|
|
|
|
pNewCSprite->SetCroppedSize( BANNER_WIDTH, BANNER_HEIGHT );
|
|
|
|
|
}
|
|
|
|
|
else // flat, unrotated graphics need widths changing
|
|
|
|
|
{
|
|
|
|
|
pNewCSprite->SetWH(BANNER_WIDTH, BANNER_HEIGHT );
|
|
|
|
|
}
|
2003-01-15 21:25:47 +00:00
|
|
|
}
|
|
|
|
|
else if(m_iBannerPrefs == BANNERPREFS_DDRROT)
|
|
|
|
|
{
|
|
|
|
|
pNewCSprite->SetCroppedSize( BANNER_WIDTH, BANNER_HEIGHT );
|
2003-03-02 01:43:33 +00:00
|
|
|
pNewCSprite->SetRotationZ( DDRROT_ROTATION );
|
2003-01-15 21:25:47 +00:00
|
|
|
}
|
|
|
|
|
else if(m_iBannerPrefs == BANNERPREFS_EZ2)
|
|
|
|
|
{
|
2003-05-09 00:18:37 +00:00
|
|
|
if(pNewCSprite->GetUnzoomedWidth() == pNewCSprite->GetUnzoomedHeight()) // rotated graphics need cropping
|
|
|
|
|
{
|
2003-06-02 19:25:29 +00:00
|
|
|
pNewCSprite->SetCroppedSize( EZ2_BANNER_WIDTH, EZ2_BANNER_HEIGHT );
|
2003-05-09 00:18:37 +00:00
|
|
|
}
|
|
|
|
|
else // flat, unrotated graphics need widths changing
|
|
|
|
|
{
|
2003-06-02 19:25:29 +00:00
|
|
|
pNewCSprite->SetWH(EZ2_BANNER_WIDTH, EZ2_BANNER_HEIGHT);
|
2003-05-09 00:18:37 +00:00
|
|
|
}
|
2003-01-15 21:25:47 +00:00
|
|
|
}
|
2003-01-16 17:10:19 +00:00
|
|
|
|
2003-05-09 00:18:37 +00:00
|
|
|
m_apCSprites[ElementNumber] = pNewCSprite;
|
2003-01-15 21:25:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-25 23:10:28 +00:00
|
|
|
/********************************
|
|
|
|
|
DrawPrimitives
|
|
|
|
|
|
|
|
|
|
Draws the elements onto the screen
|
|
|
|
|
*********************************/
|
|
|
|
|
void ScrollingList::DrawPrimitives()
|
|
|
|
|
{
|
2002-12-10 23:16:44 +00:00
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
|
|
|
|
{
|
|
|
|
|
ASSERT( !m_apSprites.empty() );
|
2003-05-09 00:18:37 +00:00
|
|
|
m_RippleSprite.SetXY( m_apSprites[m_iSelection]->GetX(), m_apSprites[m_iSelection]->GetY() ); // keep the ripple sprites with the current selection
|
2002-12-10 23:16:44 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ASSERT( !m_apCSprites.empty() );
|
2003-05-09 00:18:37 +00:00
|
|
|
m_RippleCSprite.SetXY( m_apCSprites[m_iSelection]->GetX(), m_apCSprites[m_iSelection]->GetY() ); // keep the ripple sprites with the current selection
|
2002-12-10 23:16:44 +00:00
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
|
2002-08-29 20:18:41 +00:00
|
|
|
for( int i=(m_iNumVisible)/2; i>= 0; i-- ) // draw outside to inside
|
2002-08-25 23:10:28 +00:00
|
|
|
{
|
2002-08-29 20:18:41 +00:00
|
|
|
int iIndexToDraw1 = m_iSelection - i;
|
|
|
|
|
int iIndexToDraw2 = m_iSelection + i;
|
|
|
|
|
|
2002-12-10 23:16:44 +00:00
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
2002-08-25 23:10:28 +00:00
|
|
|
{
|
2002-12-10 23:16:44 +00:00
|
|
|
// wrap IndexToDraw*
|
|
|
|
|
iIndexToDraw1 = (iIndexToDraw1 + m_apSprites.size()*300) % m_apSprites.size(); // make sure this is positive
|
|
|
|
|
iIndexToDraw2 = iIndexToDraw2 % m_apSprites.size();
|
|
|
|
|
|
|
|
|
|
ASSERT( iIndexToDraw1 >= 0 );
|
|
|
|
|
|
|
|
|
|
m_apSprites[iIndexToDraw1]->SetX( (-i+m_fSelectionLag) * m_iSpacing );
|
|
|
|
|
m_apSprites[iIndexToDraw2]->SetX( (+i+m_fSelectionLag) * m_iSpacing );
|
|
|
|
|
|
|
|
|
|
if( i==0 ) // so we don't draw 0 twice
|
|
|
|
|
{
|
|
|
|
|
m_apSprites[iIndexToDraw1]->SetDiffuse( COLOR_SELECTED );
|
|
|
|
|
m_apSprites[iIndexToDraw1]->Draw();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_apSprites[iIndexToDraw1]->SetDiffuse( COLOR_NOT_SELECTED );
|
|
|
|
|
m_apSprites[iIndexToDraw2]->SetDiffuse( COLOR_NOT_SELECTED );
|
|
|
|
|
m_apSprites[iIndexToDraw1]->Draw();
|
|
|
|
|
m_apSprites[iIndexToDraw2]->Draw();
|
|
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-12-10 23:16:44 +00:00
|
|
|
// wrap IndexToDraw*
|
|
|
|
|
iIndexToDraw1 = (iIndexToDraw1 + m_apCSprites.size()*300) % m_apCSprites.size(); // make sure this is positive
|
|
|
|
|
iIndexToDraw2 = iIndexToDraw2 % m_apCSprites.size();
|
|
|
|
|
|
|
|
|
|
ASSERT( iIndexToDraw1 >= 0 );
|
|
|
|
|
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetX( (-i+m_fSelectionLag) * m_iSpacing );
|
|
|
|
|
m_apCSprites[iIndexToDraw2]->SetX( (+i+m_fSelectionLag) * m_iSpacing );
|
2003-06-02 19:25:29 +00:00
|
|
|
m_apCSprites[iIndexToDraw1]->SetZ( (m_iNumVisible)/2 - i);
|
|
|
|
|
m_apCSprites[iIndexToDraw2]->SetZ( (m_iNumVisible)/2 - i);
|
2003-06-09 01:13:25 +00:00
|
|
|
m_apCSprites[iIndexToDraw1]->SetRotationZ(BANNER_ROTATION);
|
|
|
|
|
m_apCSprites[iIndexToDraw2]->SetRotationZ(BANNER_ROTATION);
|
|
|
|
|
m_sprBannerMask.SetRotationZ(BANNER_ROTATION);
|
2002-12-10 23:16:44 +00:00
|
|
|
if( i==0 ) // so we don't draw 0 twice
|
|
|
|
|
{
|
2003-06-02 19:25:29 +00:00
|
|
|
if(!m_iBouncingState)
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetZoom( 1.0 - (ZOOM_OFFSET * i) );
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetDiffuse( COLOR_SELECTED + RageColor(0,0,0,(1.0 - (FADE_OFFSET * i))) );
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetUseZBuffer( true ); // do have to pass the z test
|
|
|
|
|
m_sprBannerMask.SetXY(m_apCSprites[iIndexToDraw1]->GetX(), m_apCSprites[iIndexToDraw1]->GetY());
|
|
|
|
|
m_sprBannerMask.SetZ( m_apCSprites[iIndexToDraw1]->GetZ()+0.05f );
|
|
|
|
|
m_sprBannerMask.SetZoom( m_apCSprites[iIndexToDraw1]->GetZoom());
|
|
|
|
|
m_sprBannerMask.Draw();
|
2002-12-10 23:16:44 +00:00
|
|
|
m_apCSprites[iIndexToDraw1]->Draw();
|
2003-06-02 19:25:29 +00:00
|
|
|
if(m_iBouncingState) // bouncing
|
|
|
|
|
{
|
|
|
|
|
if(m_iBounceDir == 1)
|
|
|
|
|
{
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetZoom(m_apCSprites[iIndexToDraw1]->GetZoom() + 0.05 );
|
|
|
|
|
m_sprBannerMask.SetZoom( m_apCSprites[iIndexToDraw1]->GetZoom() );
|
|
|
|
|
m_sprBannerMask.Draw();
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->Draw();
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetZoom(m_apCSprites[iIndexToDraw1]->GetZoom() - 0.05 );
|
|
|
|
|
m_sprBannerMask.SetZoom( m_apCSprites[iIndexToDraw1]->GetZoom() );
|
|
|
|
|
}
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetZoom(m_apCSprites[iIndexToDraw1]->GetZoom() + m_iBounceSize );
|
|
|
|
|
RageColor currentcolor = m_apCSprites[iIndexToDraw1]->GetDiffuse();
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetZ( m_apCSprites[iIndexToDraw1]->GetZ() + 1);
|
|
|
|
|
m_sprBannerMask.SetZ( m_apCSprites[iIndexToDraw1]->GetZ()+0.05f );
|
|
|
|
|
m_sprBannerMask.SetZoom( m_sprBannerMask.GetZoom() + m_iBounceSize );
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetDiffuse( RageColor( 1, 1, 1, 0.4f ) );
|
|
|
|
|
m_sprBannerMask.Draw();
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->Draw(); // again for the bounce effect
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetZoom(m_apCSprites[iIndexToDraw1]->GetZoom() - m_iBounceSize );
|
|
|
|
|
m_sprBannerMask.SetZoom( m_sprBannerMask.GetZoom() - m_iBounceSize );
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetDiffuse( currentcolor );
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetZ( m_apCSprites[iIndexToDraw1]->GetZ() - 1);
|
|
|
|
|
}
|
2002-12-10 23:16:44 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-06-02 19:25:29 +00:00
|
|
|
m_apCSprites[iIndexToDraw1]->SetZoom( 1.0 - (ZOOM_OFFSET * i) );
|
|
|
|
|
m_apCSprites[iIndexToDraw2]->SetZoom( 1.0 - (ZOOM_OFFSET * i) );
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetDiffuse( COLOR_NOT_SELECTED + RageColor(0,0,0,(- (FADE_OFFSET * i))) );
|
|
|
|
|
m_apCSprites[iIndexToDraw2]->SetDiffuse( COLOR_NOT_SELECTED + RageColor(0,0,0,(- (FADE_OFFSET * i))) );
|
|
|
|
|
m_apCSprites[iIndexToDraw1]->SetUseZBuffer( true ); // do have to pass the z test
|
|
|
|
|
m_sprBannerMask.SetXY(m_apCSprites[iIndexToDraw1]->GetX(), m_apCSprites[iIndexToDraw1]->GetY());
|
|
|
|
|
m_sprBannerMask.SetZ( m_apCSprites[iIndexToDraw1]->GetZ()+0.05f );
|
|
|
|
|
m_sprBannerMask.SetZoom( m_apCSprites[iIndexToDraw1]->GetZoom());
|
|
|
|
|
m_sprBannerMask.Draw();
|
2002-12-10 23:16:44 +00:00
|
|
|
m_apCSprites[iIndexToDraw1]->Draw();
|
2003-06-02 19:25:29 +00:00
|
|
|
m_apCSprites[iIndexToDraw2]->SetUseZBuffer( true ); // do have to pass the z test
|
|
|
|
|
m_sprBannerMask.SetXY(m_apCSprites[iIndexToDraw2]->GetX(), m_apCSprites[iIndexToDraw1]->GetY());
|
|
|
|
|
m_sprBannerMask.SetZ( m_apCSprites[iIndexToDraw2]->GetZ()+0.05f );
|
|
|
|
|
m_sprBannerMask.SetZoom( m_apCSprites[iIndexToDraw2]->GetZoom());
|
|
|
|
|
m_sprBannerMask.Draw();
|
2002-12-10 23:16:44 +00:00
|
|
|
m_apCSprites[iIndexToDraw2]->Draw();
|
|
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-01-18 19:07:52 +00:00
|
|
|
if(m_iSpriteType == SPRITE_TYPE_SPRITE)
|
|
|
|
|
{
|
2003-05-02 15:12:09 +00:00
|
|
|
if(m_iBouncingState)
|
|
|
|
|
{
|
|
|
|
|
m_RippleSprite.Draw();
|
|
|
|
|
}
|
2003-01-18 19:07:52 +00:00
|
|
|
}
|
2002-08-25 23:10:28 +00:00
|
|
|
}
|