2003-02-17 02:45:30 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "CourseContentsList.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "Course.h"
|
|
|
|
|
#include "SongManager.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"
|
2004-06-28 07:26:00 +00:00
|
|
|
#include "Style.h"
|
2003-11-07 20:46:04 +00:00
|
|
|
#include "RageTexture.h"
|
2005-04-10 23:42:47 +00:00
|
|
|
#include "CourseEntryDisplay.h"
|
2005-07-29 22:59:11 +00:00
|
|
|
#include "ActorUtil.h"
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2005-04-10 23:42:47 +00:00
|
|
|
const int MAX_VISIBLE_ITEMS = 5;
|
|
|
|
|
const int MAX_ITEMS = MAX_VISIBLE_ITEMS+2;
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2005-07-29 22:59:11 +00:00
|
|
|
REGISTER_ACTOR_CLASS( CourseContentsList )
|
|
|
|
|
|
2003-02-17 02:45:30 +00:00
|
|
|
CourseContentsList::CourseContentsList()
|
|
|
|
|
{
|
2005-04-10 23:42:47 +00:00
|
|
|
for( int i=0; i<MAX_ITEMS; i++ )
|
|
|
|
|
m_vpDisplay.push_back( new CourseEntryDisplay );
|
2006-08-16 22:54:51 +00:00
|
|
|
this->SetNumItemsToDraw( (float)MAX_VISIBLE_ITEMS );
|
2005-04-10 23:42:47 +00:00
|
|
|
}
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2005-04-10 23:42:47 +00:00
|
|
|
CourseContentsList::~CourseContentsList()
|
|
|
|
|
{
|
|
|
|
|
FOREACH( CourseEntryDisplay*, m_vpDisplay, d )
|
|
|
|
|
delete *d;
|
|
|
|
|
m_vpDisplay.clear();
|
2005-03-30 17:42:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CourseContentsList::Load()
|
|
|
|
|
{
|
2005-04-10 23:42:47 +00:00
|
|
|
FOREACH( CourseEntryDisplay*, m_vpDisplay, d )
|
2003-11-16 21:44:42 +00:00
|
|
|
{
|
2005-04-10 23:42:47 +00:00
|
|
|
(*d)->SetName( "CourseEntryDisplay" );
|
|
|
|
|
(*d)->Load();
|
|
|
|
|
(*d)->SetUseZBuffer( true );
|
2003-11-16 21:44:42 +00:00
|
|
|
}
|
2003-02-17 02:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
void CourseContentsList::LoadFromNode( const RString& sDir, const XNode* pNode )
|
2005-07-29 22:59:11 +00:00
|
|
|
{
|
|
|
|
|
ActorScroller::LoadFromNode( sDir, pNode );
|
|
|
|
|
|
|
|
|
|
Load();
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-03 08:22:02 +00:00
|
|
|
void CourseContentsList::SetFromGameState()
|
2003-02-17 02:45:30 +00:00
|
|
|
{
|
2005-04-10 23:42:47 +00:00
|
|
|
RemoveAllChildren();
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2004-05-23 00:53:20 +00:00
|
|
|
// FIXME: Is there a better way to handle when players don't have
|
|
|
|
|
// the same number of TrailEntries?
|
2004-05-25 20:47:49 +00:00
|
|
|
// They have to have the same number, and of the same songs, or gameplay
|
|
|
|
|
// isn't going to line up.
|
2004-06-06 19:43:31 +00:00
|
|
|
Trail* pMasterTrail = GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber];
|
|
|
|
|
if( pMasterTrail == NULL )
|
|
|
|
|
return;
|
2005-04-10 23:42:47 +00:00
|
|
|
unsigned uNumEntriesToShow = min( pMasterTrail->m_vEntries.size(), m_vpDisplay.size() );
|
2004-06-03 08:22:02 +00:00
|
|
|
|
2005-04-10 23:42:47 +00:00
|
|
|
for( int i=0; i<(int)uNumEntriesToShow; i++ )
|
2003-02-17 02:45:30 +00:00
|
|
|
{
|
2005-04-10 23:42:47 +00:00
|
|
|
CourseEntryDisplay &d = *m_vpDisplay[i];
|
|
|
|
|
|
|
|
|
|
this->AddChild( &d );
|
2004-06-06 19:43:31 +00:00
|
|
|
|
2006-08-16 18:07:25 +00:00
|
|
|
d.SetFromGameState( i );
|
2003-02-17 02:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
2005-04-10 23:42:47 +00:00
|
|
|
bool bLoop = pMasterTrail->m_vEntries.size() > uNumEntriesToShow;
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2006-08-16 18:19:38 +00:00
|
|
|
this->SetLoop( bLoop );
|
2006-08-16 18:31:00 +00:00
|
|
|
this->Load2();
|
2005-12-07 05:43:49 +00:00
|
|
|
this->SetTransformFromHeight( m_vpDisplay[0]->GetUnzoomedHeight() );
|
2005-12-07 03:50:11 +00:00
|
|
|
this->SetSecondsPerItem( 0.7f );
|
2005-12-06 03:05:57 +00:00
|
|
|
this->EnableMask( m_vpDisplay[0]->GetUnzoomedWidth(), m_vpDisplay[0]->GetUnzoomedHeight() );
|
|
|
|
|
this->SetSecondsPauseBetweenItems( 0.7f );
|
|
|
|
|
this->ScrollThroughAllItems();
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2005-04-10 23:42:47 +00:00
|
|
|
this->SetCurrentAndDestinationItem( (MAX_VISIBLE_ITEMS-1)/2 );
|
|
|
|
|
if( bLoop )
|
2003-02-17 02:45:30 +00:00
|
|
|
{
|
2005-04-10 23:42:47 +00:00
|
|
|
SetPauseCountdownSeconds( 1.5f );
|
|
|
|
|
this->SetDestinationItem( MAX_ITEMS+1 ); // loop forever
|
2003-02-17 02:45:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-29 22:59:11 +00:00
|
|
|
// lua start
|
|
|
|
|
#include "LuaBinding.h"
|
|
|
|
|
|
|
|
|
|
class LunaCourseContentsList: public Luna<CourseContentsList>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
static int SetFromGameState( T* p, lua_State *L ) { p->SetFromGameState(); return 0; }
|
|
|
|
|
|
2006-09-27 20:03:31 +00:00
|
|
|
LunaCourseContentsList()
|
2005-07-29 22:59:11 +00:00
|
|
|
{
|
2006-09-27 20:03:31 +00:00
|
|
|
ADD_METHOD( SetFromGameState );
|
2005-07-29 22:59:11 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
LUA_REGISTER_DERIVED_CLASS( CourseContentsList, ActorScroller )
|
|
|
|
|
// lua end
|
|
|
|
|
|
2004-06-07 21:14:03 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|