merge ListDisplay into ActorScroller

This commit is contained in:
Chris Danford
2005-04-10 23:42:47 +00:00
parent c9c9e5dbeb
commit 8e6637dd0d
12 changed files with 232 additions and 423 deletions
+128 -25
View File
@@ -28,11 +28,22 @@ ActorScroller::ActorScroller()
m_fDestinationItem = 0;
m_fSecondsPerItem = 1;
m_fNumItemsToDraw = 7;
m_fSecondsPauseBetweenItems = 0;
m_fNumItemsToDraw = 7;
m_bLoop = false;
m_fPauseCountdownSeconds = 0;
m_fMaskWidth = 1;
m_fMaskHeight = 1;
m_vRotationDegrees = RageVector3(0,0,0);
m_vTranslateTerm0 = RageVector3(0,0,0);
m_vTranslateTerm1 = RageVector3(0,0,0);
m_vTranslateTerm2 = RageVector3(0,0,0);
m_quadMask.SetBlendMode( BLEND_NO_EFFECT ); // don't change color values
m_quadMask.SetUseZBuffer( true ); // we want to write to the Zbuffer
m_quadMask.SetHidden( true );
}
void ActorScroller::Load(
@@ -54,6 +65,50 @@ void ActorScroller::Load(
m_bLoaded = true;
}
void ActorScroller::Load2(
float fNumItemsToDraw,
float fItemWidth,
float fItemHeight,
bool bLoop,
float fSecondsPerItem,
float fSecondsPauseBetweenItems )
{
CLAMP( fNumItemsToDraw, 1, 10000 );
CLAMP( fItemWidth, 1, 10000 );
CLAMP( fItemHeight, 1, 10000 );
CLAMP( fSecondsPerItem, 0.01f, 10000 );
CLAMP( fSecondsPauseBetweenItems, 0, 10000 );
m_fNumItemsToDraw = fNumItemsToDraw;
m_fMaskWidth = fItemWidth;
m_fMaskHeight = fItemHeight;
m_vTranslateTerm1 = RageVector3( 0, fItemHeight, 0 );
m_bLoop = bLoop;
m_fSecondsPerItem = fSecondsPerItem;
m_fSecondsPauseBetweenItems = fSecondsPauseBetweenItems;
m_fCurrentItem = m_bLoop ? 0 : (float)-m_fNumItemsToDraw;
m_fDestinationItem = (float)(m_SubActors.size()+1);
m_fPauseCountdownSeconds = 0;
RectF rectBarSize(
-m_fMaskWidth/2,
-m_fMaskHeight/2,
m_fMaskWidth/2,
m_fMaskHeight/2 );
m_quadMask.StretchTo( rectBarSize );
m_quadMask.SetZ( 1 );
m_quadMask.SetHidden( false );
m_bLoaded = true;
}
float ActorScroller::GetSecondsForCompleteScrollThrough()
{
float fTotalItems = m_fNumItemsToDraw + m_SubActors.size();
return fTotalItems * (m_fSecondsPerItem + m_fSecondsPauseBetweenItems );
}
void ActorScroller::LoadFromNode( const CString &sDir, const XNode *pNode )
{
ActorFrame::LoadFromNode( sDir, pNode );
@@ -115,10 +170,55 @@ void ActorScroller::Update( float fDeltaTime )
if( m_fHibernateSecondsLeft > 0 )
return; // early abort
/* If we have no children, the code below will busy loop. */
if( !m_SubActors.size() )
return;
// handle pause
if( fDeltaTime > m_fPauseCountdownSeconds )
{
fDeltaTime -= m_fPauseCountdownSeconds;
m_fPauseCountdownSeconds = 0;
}
else
{
m_fPauseCountdownSeconds -= fDeltaTime;
fDeltaTime = 0;
return;
}
if( m_fCurrentItem == m_fDestinationItem )
return; // done scrolling
float fOldItemAtTop = m_fCurrentItem;
if( m_fSecondsPerItem > 0 )
fapproach( m_fCurrentItem, m_fDestinationItem, fDeltaTime/m_fSecondsPerItem );
// if items changed, then pause
if( (int)fOldItemAtTop != (int)m_fCurrentItem )
m_fPauseCountdownSeconds = m_fSecondsPauseBetweenItems;
if( m_bLoop )
m_fCurrentItem = fmodf( m_fCurrentItem, m_fNumItemsToDraw+1 );
}
#define PUSH_AND_TRANSFORM_FOR_ITEM( fPosition ) { \
DISPLAY->PushMatrix(); \
if( m_vRotationDegrees.x ) DISPLAY->RotateX( m_vRotationDegrees.x*fPosition ); \
if( m_vRotationDegrees.y ) DISPLAY->RotateY( m_vRotationDegrees.y*fPosition ); \
if( m_vRotationDegrees.z ) DISPLAY->RotateZ( m_vRotationDegrees.z*fPosition ); \
RageVector3 vTranslation = \
m_vTranslateTerm0 + /* m_vTranslateTerm0*fPosition^0 */ \
m_vTranslateTerm1 * fPosition + /* m_vTranslateTerm1*fPosition^1 */ \
m_vTranslateTerm2 * fPosition*fPosition; /* m_vTranslateTerm2*fPosition^2 */ \
DISPLAY->Translate( \
vTranslation.x, \
vTranslation.y, \
vTranslation.z ); \
}
void ActorScroller::DrawPrimitives()
{
// Optimization: If we weren't loaded, then fall back to the ActorFrame logic
@@ -128,34 +228,37 @@ void ActorScroller::DrawPrimitives()
}
else
{
for( unsigned i=0; i<m_SubActors.size(); i++ )
{
float fItemOffset = i - m_fCurrentItem;
if( m_SubActors.empty() )
return;
if( fabsf(fItemOffset) > m_fNumItemsToDraw / 2 )
// write to z buffer so that top and bottom are clipped
float fPositionFullyOnScreenTop = -(m_fNumItemsToDraw-1)/2.f;
float fPositionFullyOnScreenBottom = (m_fNumItemsToDraw-1)/2.f;
float fPositionCompletelyOffScreenTop = fPositionFullyOnScreenTop - 1;
float fPositionCompletelyOffScreenBottom = fPositionFullyOnScreenBottom + 1;
PUSH_AND_TRANSFORM_FOR_ITEM( fPositionCompletelyOffScreenTop )
m_quadMask.Draw();
DISPLAY->PopMatrix();
PUSH_AND_TRANSFORM_FOR_ITEM( fPositionCompletelyOffScreenBottom )
m_quadMask.Draw();
DISPLAY->PopMatrix();
float fFirstItemToDraw = fPositionCompletelyOffScreenTop + m_fCurrentItem;
float fLastItemToDraw = fPositionCompletelyOffScreenBottom + m_fCurrentItem;
for( int iItem=(int)truncf(ceilf(fFirstItemToDraw)); iItem<=fLastItemToDraw; iItem++ )
{
float fPosition = iItem - m_fCurrentItem;
int iIndex = iItem;
if( m_bLoop )
wrap( iIndex, m_SubActors.size()-1 );
else if( iIndex < 0 || iIndex >= (int)m_SubActors.size() )
continue;
DISPLAY->PushMatrix();
if( m_vRotationDegrees.x )
DISPLAY->RotateX( m_vRotationDegrees.x*fItemOffset );
if( m_vRotationDegrees.y )
DISPLAY->RotateY( m_vRotationDegrees.y*fItemOffset );
if( m_vRotationDegrees.z )
DISPLAY->RotateZ( m_vRotationDegrees.z*fItemOffset );
RageVector3 vTranslation =
m_vTranslateTerm0 + // m_vTranslateTerm0*itemOffset^0
m_vTranslateTerm1 * fItemOffset + // m_vTranslateTerm1*itemOffset^1
m_vTranslateTerm2 * fItemOffset*fItemOffset; // m_vTranslateTerm2*itemOffset^2
DISPLAY->Translate(
vTranslation.x,
vTranslation.y,
vTranslation.z
);
m_SubActors[i]->Draw();
PUSH_AND_TRANSFORM_FOR_ITEM( fPosition )
m_SubActors[iIndex]->Draw();
DISPLAY->PopMatrix();
}
}
+28 -7
View File
@@ -4,6 +4,7 @@
#define ActorScroller_H
#include "ActorFrame.h"
#include "Quad.h"
struct XNode;
template<class T>
@@ -34,12 +35,25 @@ public:
const RageVector3 &vTranslateTerm1,
const RageVector3 &vTranslateTerm2 );
void Load2(
float fNumItemsToDraw,
float fItemWidth,
float fItemHeight,
bool bLoop,
float fSecondsPerItem,
float fSecondsPauseBetweenItems );
virtual void Update( float fDelta );
virtual void DrawPrimitives(); // DOES draw
void LoadFromNode( const CString &sDir, const XNode *pNode );
void SetDestinationItem( float fItemIndex ) { m_fDestinationItem = fItemIndex; }
void SetCurrentAndDestinationItem( float fItemIndex ) { m_fCurrentItem = m_fDestinationItem = fItemIndex; }
void SetDestinationItem( float fItemIndex ) { m_fDestinationItem = fItemIndex; }
void SetCurrentAndDestinationItem( float fItemIndex ) { m_fCurrentItem = m_fDestinationItem = fItemIndex; }
float GetDestinationItem() { return m_fDestinationItem; }
void SetPauseCountdownSeconds( float fSecs ) { m_fPauseCountdownSeconds = fSecs; }
float GetSecondsForCompleteScrollThrough();
//
// Commands
@@ -47,12 +61,19 @@ public:
void PushSelf( lua_State *L );
protected:
bool m_bLoaded;
float m_fCurrentItem; // usually between 0 and m_SubActors.size()
float m_fDestinationItem;
float m_fSecondsPerItem; // <= 0 means don't scroll
float m_fNumItemsToDraw;
bool m_bLoaded;
float m_fCurrentItem; // Item at top of list, usually between 0 and m_SubActors.size(), approaches destination
float m_fDestinationItem;
float m_fSecondsPerItem; // <= 0 means don't scroll
float m_fSecondsPauseBetweenItems;
float m_fNumItemsToDraw;
bool m_bLoop;
float m_fPauseCountdownSeconds;
float m_fMaskWidth;
float m_fMaskHeight;
Quad m_quadMask;
// Note: Rotation is applied before translation.
// rot = m_vRotationDegrees*itemOffset^1
+39 -77
View File
@@ -12,45 +12,37 @@
#include "GameState.h"
#include "Style.h"
#include "RageTexture.h"
#include "CourseEntryDisplay.h"
const int MAX_VISIBLE_ITEMS = 5;
const int MAX_ITEMS = MAX_VISIBLE_ITEMS+2;
CourseContentsList::CourseContentsList()
{
m_iNumContents = 0;
m_quad.SetDiffuse( RageColor(0,0,0,1) );
m_quad.SetBlendMode( BLEND_NO_EFFECT ); // invisible, since we want to write only to the Zbuffer
for( int i=0; i<MAX_ITEMS; i++ )
m_vpDisplay.push_back( new CourseEntryDisplay );
}
m_fTimeUntilScroll = 0;
m_fItemAtTopOfList = 0;
ContentsBarHeight = 1;
ContentsBarWidth = 1;
CourseContentsList::~CourseContentsList()
{
FOREACH( CourseEntryDisplay*, m_vpDisplay, d )
delete *d;
m_vpDisplay.clear();
}
void CourseContentsList::Load()
{
m_quad.SetUseZBuffer( true );
for( int i = 0; i < MAX_TOTAL_CONTENTS; ++i )
FOREACH( CourseEntryDisplay*, m_vpDisplay, d )
{
m_CourseContentDisplays[i].SetName( "CourseEntryDisplay" );
m_CourseContentDisplays[i].Load();
m_CourseContentDisplays[i].SetUseZBuffer( true );
(*d)->SetName( "CourseEntryDisplay" );
(*d)->Load();
(*d)->SetUseZBuffer( true );
}
/* These are all the same; grab the dimensions. */
ContentsBarHeight = m_CourseContentDisplays[0].GetUnzoomedHeight();
ContentsBarWidth = m_CourseContentDisplays[0].GetUnzoomedWidth();
}
void CourseContentsList::SetFromGameState()
{
Course* pCourse = GAMESTATE->m_pCurCourse;
if( pCourse == NULL )
{
m_iNumContents = 0;
return;
}
RemoveAllChildren();
// FIXME: Is there a better way to handle when players don't have
// the same number of TrailEntries?
@@ -59,13 +51,13 @@ void CourseContentsList::SetFromGameState()
Trail* pMasterTrail = GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber];
if( pMasterTrail == NULL )
return;
int iNumEntriesToShow = min((int)pMasterTrail->m_vEntries.size(), MAX_TOTAL_CONTENTS);
unsigned uNumEntriesToShow = min( pMasterTrail->m_vEntries.size(), m_vpDisplay.size() );
m_iNumContents = 0;
for( int i=0; i<iNumEntriesToShow; i++ )
for( int i=0; i<(int)uNumEntriesToShow; i++ )
{
CourseEntryDisplay& display = m_CourseContentDisplays[m_iNumContents];
CourseEntryDisplay &d = *m_vpDisplay[i];
this->AddChild( &d );
const TrailEntry* pte[NUM_PLAYERS];
ZERO( pte );
@@ -78,73 +70,43 @@ void CourseContentsList::SetFromGameState()
if( unsigned(i) < pTrail->m_vEntries.size() )
pte[pn] = &pTrail->m_vEntries[i];
}
display.LoadFromTrailEntry( m_iNumContents+1, pte );
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));
d.LoadFromTrailEntry( (int)(truncf(m_fItemAtPosition0InList))+i+1, pte );
}
for( int i=0; i<m_iNumContents; i++ )
m_CourseContentDisplays[i].Update( fDeltaTime );
}
bool bLoop = pMasterTrail->m_vEntries.size() > uNumEntriesToShow;
void CourseContentsList::DrawPrimitives()
{
// write to z buffer so that top and bottom are clipped
m_quad.SetZ( 1 );
this->Load2(
(float)MAX_VISIBLE_ITEMS,
m_vpDisplay[0]->GetUnzoomedWidth(),
m_vpDisplay[0]->GetUnzoomedHeight(),
bLoop,
0.7f,
0.7f );
RectF 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++ )
this->SetCurrentAndDestinationItem( (MAX_VISIBLE_ITEMS-1)/2 );
if( bLoop )
{
if( m_fTimeUntilScroll <= 0 )
m_CourseContentDisplays[iItemToDraw].SetY( fY + i*ContentsBarHeight);
m_CourseContentDisplays[iItemToDraw].Draw();
iItemToDraw = (iItemToDraw+1) % m_iNumContents;
SetPauseCountdownSeconds( 1.5f );
this->SetDestinationItem( MAX_ITEMS+1 ); // loop forever
}
}
void CourseContentsList::TweenInAfterChangedCourse()
{
/*
m_fItemAtTopOfList = 0;
m_fTimeUntilScroll = 3;
for( int i=0; i<m_iNumContents; i++ )
for( int i=0; i<m_fItemAtPosition0InList; i++ )
{
CourseEntryDisplay& display = m_CourseContentDisplays[i];
display.StopTweening();
display.SetXY( 0, -((MAX_VISIBLE_CONTENTS-1)/2) * float(ContentsBarHeight) );
display.SetXY( 0, -((MAX_VISIBLE_CONTENTS-1)/2) * float(CONTENTS_BAR_HEIGHT) );
display.BeginTweening( i*0.1f );
display.SetY( (-(MAX_VISIBLE_CONTENTS-1)/2 + i) * float(ContentsBarHeight) );
display.SetY( (-(MAX_VISIBLE_CONTENTS-1)/2 + i) * float(CONTENTS_BAR_HEIGHT) );
}
*/
}
/*
+6 -22
View File
@@ -3,31 +3,17 @@
#ifndef COURSE_CONTENTS_LIST_H
#define COURSE_CONTENTS_LIST_H
#include "BitmapText.h"
#include "ActorFrame.h"
#include "Sprite.h"
#include "Quad.h"
#include "CourseEntryDisplay.h"
class Course;
class Song;
class Steps;
#include "ActorScroller.h"
class CourseEntryDisplay;
const int MAX_VISIBLE_CONTENTS = 5;
const int MAX_TOTAL_CONTENTS = 56;
class CourseContentsList : public ActorFrame
class CourseContentsList : public ActorScroller
{
public:
CourseContentsList();
~CourseContentsList();
void Load();
virtual void Update( float fDeltaTime );
virtual void DrawPrimitives();
void SetFromGameState();
void TweenInAfterChangedCourse();
@@ -35,12 +21,10 @@ protected:
Quad m_quad;
int m_iNumContents;
CourseEntryDisplay m_CourseContentDisplays[MAX_TOTAL_CONTENTS];
float ContentsBarHeight, ContentsBarWidth;
vector<CourseEntryDisplay*> m_vpDisplay;
float m_fTimeUntilScroll;
float m_fItemAtTopOfList; // between 0 and m_iNumContents
float m_fItemAtPosition0InList; // 0 <= val < m_vpDisplay.size()
};
#endif
-174
View File
@@ -1,174 +0,0 @@
#include "global.h"
#include "ListDisplay.h"
#include "RageUtil.h"
#include "GameConstantsAndTypes.h"
#include "PrefsManager.h"
#include "RageLog.h"
#include "PrefsManager.h"
#include "Course.h"
#include "SongManager.h"
#include "ThemeManager.h"
#include "Steps.h"
#include "GameState.h"
#include "Style.h"
#include "RageTexture.h"
//
// TODO: Merge this with ActorScroller
//
ListDisplay::ListDisplay()
{
m_iNumItemsToShow = 0;
m_fItemWidth = 0;
m_fItemHeight = 0;
m_fCurrentItemAtTopOfList = 0;
m_fDestinationItemAtTopOfList = 0;
m_quadMask.SetBlendMode( BLEND_NO_EFFECT ); // don't change color values
m_quadMask.SetUseZBuffer( true ); // we want to write to the Zbuffer
}
void ListDisplay::Load(
const vector<Actor*> &m_vpItems,
int iNumItemsToShow,
float fItemWidth,
float fItemHeight,
bool bLoop,
float fSecondsPerItem,
float fSecondsPauseBetweenItems,
bool bSlide )
{
CLAMP( iNumItemsToShow, 1, 10000 );
CLAMP( fItemWidth, 1, 10000 );
CLAMP( fItemHeight, 1, 10000 );
CLAMP( fSecondsPerItem, 0.01f, 10000 );
CLAMP( fSecondsPauseBetweenItems, 0, 10000 );
m_SubActors = m_vpItems;
m_iNumItemsToShow = iNumItemsToShow;
m_fItemWidth = fItemWidth;
m_fItemHeight = fItemHeight;
m_bLoop = bLoop;
m_fSecondsPerItem = fSecondsPerItem;
m_fSecondsPauseBetweenItems = fSecondsPauseBetweenItems;
m_bSlide = bSlide;
m_fCurrentItemAtTopOfList = m_bLoop ? 0 : (float)-m_iNumItemsToShow;
m_fDestinationItemAtTopOfList = (float)(m_vpItems.size()+1);
m_fSecondsPauseCountdown = 0;
RectF rectBarSize(-m_fItemWidth/2, -m_fItemHeight/2,
m_fItemWidth/2, m_fItemHeight/2);
m_quadMask.StretchTo( rectBarSize );
m_quadMask.SetZ( 1 );
}
float ListDisplay::GetSecondsForCompleteScrollThrough()
{
int fTotalItems = m_iNumItemsToShow + m_SubActors.size();
return fTotalItems * (m_fSecondsPerItem + m_fSecondsPauseBetweenItems );
}
void ListDisplay::Update( float fDeltaTime )
{
ActorFrame::Update( fDeltaTime );
/* If we have no children, the code below will busy loop. */
if( !m_SubActors.size() )
return;
// handle pause
if( fDeltaTime > m_fSecondsPauseCountdown )
{
fDeltaTime -= m_fSecondsPauseCountdown;
m_fSecondsPauseCountdown = 0;
}
else
{
m_fSecondsPauseCountdown -= fDeltaTime;
fDeltaTime = 0;
return;
}
if( m_fCurrentItemAtTopOfList == m_fDestinationItemAtTopOfList )
return; // done scrolling
float fOldItemAtTop = m_fCurrentItemAtTopOfList;
fapproach( m_fCurrentItemAtTopOfList, m_fDestinationItemAtTopOfList, fDeltaTime/m_fSecondsPerItem );
// if items changed, then pause
if( (int)fOldItemAtTop != (int)m_fCurrentItemAtTopOfList )
m_fSecondsPauseCountdown = m_fSecondsPauseBetweenItems;
if( m_bLoop )
wrap( m_fCurrentItemAtTopOfList, (float) m_SubActors.size() );
}
void ListDisplay::DrawPrimitives()
{
if( m_SubActors.empty() )
return;
// write to z buffer so that top and bottom are clipped
float fIndexFullyOnScreenTop = -(m_iNumItemsToShow-1)/2.f;
float fIndexFullyOnScreenBottom = (m_iNumItemsToShow-1)/2.f;
float fIndexCompletelyOffScreenTop = fIndexFullyOnScreenTop - 1;
float fIndexCompletelyOffScreenBottom = fIndexFullyOnScreenBottom + 1;
m_quadMask.SetY( fIndexCompletelyOffScreenTop * m_fItemHeight );
m_quadMask.Draw();
m_quadMask.SetY( fIndexCompletelyOffScreenBottom * m_fItemHeight );
m_quadMask.Draw();
int iItemToDraw = (int)m_fCurrentItemAtTopOfList;
float fRemainder = m_fCurrentItemAtTopOfList - (int)m_fCurrentItemAtTopOfList;
float fIndex = fIndexFullyOnScreenTop - fRemainder;
float fY = (fIndex)*m_fItemHeight;
for( int i=0; i<m_iNumItemsToShow+1; i++ )
{
if( iItemToDraw >= 0 && iItemToDraw < (int) m_SubActors.size() )
{
float fX = 0;
if( m_bSlide && fIndex>fIndexFullyOnScreenBottom-1 )
fX = SCALE( fIndex, fIndexFullyOnScreenBottom, fIndexFullyOnScreenBottom-1.f, 640.f, 0.f );
m_SubActors[iItemToDraw]->SetXY( roundf(fX), roundf(fY) );
m_SubActors[iItemToDraw]->Draw();
}
iItemToDraw++;
if( m_bLoop )
wrap( iItemToDraw, m_SubActors.size() );
fY += m_fItemHeight;
fIndex += 1;
}
}
/*
* (c) 2003 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.
*/
-70
View File
@@ -1,70 +0,0 @@
#ifndef LIST_DISPLAY_H
#define LIST_DISPLAY_H
#include "ActorFrame.h"
#include "Quad.h"
class ListDisplay : public ActorFrame
{
public:
ListDisplay();
virtual void Update( float fDeltaTime );
virtual void DrawPrimitives();
void Load(
const vector<Actor*> &m_vpItems,
int iNumItemsToShow,
float fItemWidth,
float fItemHeight,
bool bLoop,
float fSecondsPerItem,
float fSecondsPauseBetweenItems,
bool bSlide );
float GetSecondsForCompleteScrollThrough();
void SetCurrentItem( float fItem ) { m_fCurrentItemAtTopOfList = fItem; }
void SetDestinationItem( float fItem ) { m_fDestinationItemAtTopOfList = fItem; }
float GetDestinationItem() { return m_fDestinationItemAtTopOfList; }
protected:
int m_iNumItemsToShow;
float m_fItemWidth;
float m_fItemHeight;
bool m_bLoop;
float m_fSecondsPerItem;
float m_fSecondsPauseBetweenItems;
bool m_bSlide;
float m_fCurrentItemAtTopOfList; // approaches destination
float m_fDestinationItemAtTopOfList;
float m_fSecondsPauseCountdown;
Quad m_quadMask;
};
#endif
/*
* (c) 2003 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.
*/
-20
View File
@@ -829,26 +829,6 @@ void MusicWheel::SetItemPosition( Actor &item, float fPosOffsetsFromMiddle )
item.SetRotationX( fRotationX );
}
template<class T>
void CircularShift( vector<T> &v, int dist )
{
for( int i = abs( dist ); i>0; i-- )
{
if( dist > 0 )
{
T t = v[0];
v.erase( v.begin() );
v.push_back( t );
}
else
{
T t = v.back();
v.erase( v.end()-1 );
v.insert( v.begin(), t );
}
}
}
void MusicWheel::RebuildAllMusicWheelItems()
{
RebuildMusicWheelItems( INT_MAX );
+20
View File
@@ -73,6 +73,26 @@ inline void wrap(float &x, float n)
x = fmodf(x,n);
}
template<class T>
void CircularShift( vector<T> &v, int dist )
{
for( int i = abs(dist); i>0; i-- )
{
if( dist > 0 )
{
T t = v[0];
v.erase( v.begin() );
v.push_back( t );
}
else
{
T t = v.back();
v.erase( v.end()-1 );
v.insert( v.begin(), t );
}
}
}
/*
* We only have unsigned swaps; byte swapping a signed value doesn't make sense.
*
+7 -10
View File
@@ -390,7 +390,7 @@ void ScreenRanking::Scroll( int iDir )
float fDest = m_ListScoreRowItems.GetDestinationItem();
float fOldDest = fDest;
fDest += iDir;
CLAMP( fDest, 0.0f, (float)m_vScoreRowItem.size()-SONG_SCORE_ROWS_TO_SHOW );
CLAMP( fDest, (SONG_SCORE_ROWS_TO_SHOW-1)/2.0f, m_vScoreRowItem.size()-(SONG_SCORE_ROWS_TO_SHOW-1)/2.0f-1 );
if( fOldDest != fDest )
{
// TODO: play sound
@@ -627,15 +627,13 @@ float ScreenRanking::SetPage( PageToShow pts )
m_ListScoreRowItems.Reset();
SET_XY_AND_ON_COMMAND( m_ListScoreRowItems );
vector<Actor*> vpActors;
for( unsigned i=0; i<m_vScoreRowItem.size(); i++ )
vpActors.push_back( &m_vScoreRowItem[i] );
m_ListScoreRowItems.Load( vpActors, SONG_SCORE_ROWS_TO_SHOW, SCREEN_WIDTH, ROW_SPACING_Y, false, SONG_SCORE_SECONDS_PER_ROW, 0, false );
m_ListScoreRowItems.AddChild( &m_vScoreRowItem[i] );
m_ListScoreRowItems.Load2( (float)SONG_SCORE_ROWS_TO_SHOW, SCREEN_WIDTH, ROW_SPACING_Y, false, SONG_SCORE_SECONDS_PER_ROW, 0 );
if( (bool)MANUAL_SCROLLING )
{
m_ListScoreRowItems.SetCurrentItem( 0 );
m_ListScoreRowItems.SetDestinationItem( 0 );
m_ListScoreRowItems.SetCurrentAndDestinationItem( (SONG_SCORE_ROWS_TO_SHOW-1)/2.0f );
}
for( unsigned s=0; s<m_vScoreRowItem.size(); s++ )
@@ -680,13 +678,12 @@ float ScreenRanking::SetPage( PageToShow pts )
vector<Actor*> vpActors;
for( unsigned i=0; i<m_vScoreRowItem.size(); i++ )
vpActors.push_back( &m_vScoreRowItem[i] );
m_ListScoreRowItems.Load( vpActors, SONG_SCORE_ROWS_TO_SHOW, SCREEN_WIDTH, ROW_SPACING_Y, false, SONG_SCORE_SECONDS_PER_ROW, 0, false );
m_ListScoreRowItems.AddChild( &m_vScoreRowItem[i] );
m_ListScoreRowItems.Load2( (float)SONG_SCORE_ROWS_TO_SHOW, SCREEN_WIDTH, ROW_SPACING_Y, false, SONG_SCORE_SECONDS_PER_ROW, 0 );
if( (bool)MANUAL_SCROLLING )
{
m_ListScoreRowItems.SetCurrentItem( 0 );
m_ListScoreRowItems.SetDestinationItem( 0 );
m_ListScoreRowItems.SetCurrentAndDestinationItem( (SONG_SCORE_ROWS_TO_SHOW-1)/2.0f );
}
for( unsigned s=0; s<m_vScoreRowItem.size(); s++ )
+2 -2
View File
@@ -6,7 +6,7 @@
#include "Sprite.h"
#include "BitmapText.h"
#include "Banner.h"
#include "ListDisplay.h"
#include "ActorScroller.h"
#include "ActorUtil.h"
#include "Difficulty.h"
#include "ThemeMetric.h"
@@ -95,7 +95,7 @@ protected:
BitmapText m_textScore[NUM_DIFFICULTIES];
};
vector<ScoreRowItem> m_vScoreRowItem; // for all_steps
ListDisplay m_ListScoreRowItems;
ActorScroller m_ListScoreRowItems;
vector<PageToShow> m_vPagesToShow;
+2 -10
View File
@@ -62,7 +62,7 @@ IntDir=.\../Debug6
TargetDir=\stepmania\stepmania\Program
TargetName=StepMania-debug
SOURCE="$(InputPath)"
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -99,7 +99,7 @@ IntDir=.\../Release6
TargetDir=\stepmania\stepmania\Program
TargetName=StepMania
SOURCE="$(InputPath)"
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -2286,14 +2286,6 @@ SOURCE=.\HelpDisplay.h
# End Source File
# Begin Source File
SOURCE=.\ListDisplay.cpp
# End Source File
# Begin Source File
SOURCE=.\ListDisplay.h
# End Source File
# Begin Source File
SOURCE=.\MemoryCardDisplay.cpp
# End Source File
# Begin Source File
-6
View File
@@ -1590,12 +1590,6 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File
RelativePath="HelpDisplay.h">
</File>
<File
RelativePath="ListDisplay.cpp">
</File>
<File
RelativePath="ListDisplay.h">
</File>
<File
RelativePath="MemoryCardDisplay.cpp">
</File>