2003-02-17 02:45:30 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "CourseEntryDisplay.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-16 21:44:42 +00:00
|
|
|
#include "ActorUtil.h"
|
2005-08-31 02:14:59 +00:00
|
|
|
#include "LuaBinding.h"
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2005-07-30 19:32:55 +00:00
|
|
|
REGISTER_ACTOR_CLASS( CourseEntryDisplay )
|
|
|
|
|
|
|
|
|
|
CourseEntryDisplay::CourseEntryDisplay()
|
|
|
|
|
{
|
|
|
|
|
m_sName = "CourseEntryDisplay";
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 21:44:42 +00:00
|
|
|
void CourseEntryDisplay::Load()
|
2003-02-17 02:45:30 +00:00
|
|
|
{
|
2005-07-29 22:59:11 +00:00
|
|
|
SEPARATE_COURSE_METERS .Load( "CourseEntryDisplay", "SeparateCourseMeters" );
|
|
|
|
|
TEXT_BANNER_TYPE .Load( "CourseEntryDisplay", "TextBannerType" );
|
|
|
|
|
|
2003-11-16 21:44:42 +00:00
|
|
|
m_sprFrame.SetName( "Bar" );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_sprFrame.Load( THEME->GetPathG("CourseEntryDisplay","bar") );
|
2003-11-16 21:44:42 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( &m_sprFrame );
|
2003-02-17 02:45:30 +00:00
|
|
|
this->AddChild( &m_sprFrame );
|
|
|
|
|
|
2003-11-16 21:44:42 +00:00
|
|
|
this->m_size.x = (float) m_sprFrame.GetTexture()->GetSourceFrameWidth();
|
|
|
|
|
this->m_size.y = (float) m_sprFrame.GetTexture()->GetSourceFrameHeight();
|
|
|
|
|
|
|
|
|
|
m_textNumber.SetName( "Number" );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_textNumber.LoadFromFont( THEME->GetPathF("CourseEntryDisplay","number") );
|
2003-11-16 21:44:42 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( &m_textNumber );
|
2003-02-17 02:45:30 +00:00
|
|
|
this->AddChild( &m_textNumber );
|
|
|
|
|
|
2005-03-18 01:55:33 +00:00
|
|
|
m_TextBanner.SetName( "TextBanner" );
|
|
|
|
|
m_TextBanner.Load( TEXT_BANNER_TYPE );
|
2003-11-16 21:44:42 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( &m_TextBanner );
|
2004-02-24 23:07:03 +00:00
|
|
|
/* Load the m_TextBanner now, so any actor commands sent to us will propagate correctly. */
|
|
|
|
|
m_TextBanner.LoadFromString( "", "", "", "", "", "" );
|
2003-02-17 02:45:30 +00:00
|
|
|
this->AddChild( &m_TextBanner );
|
|
|
|
|
|
2004-06-06 20:57:13 +00:00
|
|
|
FOREACH_HumanPlayer( pn )
|
2004-01-21 08:38:06 +00:00
|
|
|
{
|
|
|
|
|
if( !SEPARATE_COURSE_METERS && pn != GAMESTATE->m_MasterPlayerNumber )
|
|
|
|
|
continue; // skip
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
m_textFoot[pn].SetName( SEPARATE_COURSE_METERS? ssprintf("FootP%i", pn+1):RString("Foot") );
|
2005-09-03 04:12:16 +00:00
|
|
|
m_textFoot[pn].LoadFromTextureAndChars( THEME->GetPathF("CourseEntryDisplay","difficulty"),"10" );
|
2004-01-21 08:38:06 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( &m_textFoot[pn] );
|
|
|
|
|
this->AddChild( &m_textFoot[pn] );
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
m_textDifficultyNumber[pn].SetName( SEPARATE_COURSE_METERS? ssprintf("DifficultyP%i", pn+1):RString("Difficulty") );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_textDifficultyNumber[pn].LoadFromFont( THEME->GetPathF("Common","normal") );
|
2004-01-21 08:38:06 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( &m_textDifficultyNumber[pn] );
|
|
|
|
|
this->AddChild( &m_textDifficultyNumber[pn] );
|
|
|
|
|
}
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2003-11-16 21:44:42 +00:00
|
|
|
m_textModifiers.SetName( "Modifiers" );
|
2005-02-06 03:32:53 +00:00
|
|
|
m_textModifiers.LoadFromFont( THEME->GetPathF("Common","normal") );
|
2003-11-16 21:44:42 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( &m_textModifiers );
|
2003-02-17 02:45:30 +00:00
|
|
|
this->AddChild( &m_textModifiers );
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
void CourseEntryDisplay::LoadFromNode( const RString& sDir, const XNode* pNode )
|
2005-07-30 19:32:55 +00:00
|
|
|
{
|
|
|
|
|
ActorFrame::LoadFromNode( sDir, pNode );
|
|
|
|
|
|
|
|
|
|
Load();
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
void CourseEntryDisplay::SetDifficulty( PlayerNumber pn, const RString &text, Difficulty dc )
|
2003-02-17 02:45:30 +00:00
|
|
|
{
|
2004-01-21 08:38:06 +00:00
|
|
|
if( !GAMESTATE->IsHumanPlayer(pn) )
|
|
|
|
|
return; // skip
|
|
|
|
|
if( !SEPARATE_COURSE_METERS && pn != GAMESTATE->m_MasterPlayerNumber )
|
|
|
|
|
return;
|
2004-01-21 06:58:01 +00:00
|
|
|
|
2005-08-31 02:14:59 +00:00
|
|
|
Lua *L = LUA->Get();
|
|
|
|
|
LuaHelpers::Push( dc, L );
|
|
|
|
|
m_textDifficultyNumber[pn].m_pLuaInstance->Set( L, "Difficulty" );
|
|
|
|
|
LuaHelpers::Push( dc, L );
|
|
|
|
|
m_textFoot[pn].m_pLuaInstance->Set( L, "Difficulty" );
|
|
|
|
|
LUA->Release(L);
|
|
|
|
|
|
2004-01-21 08:38:06 +00:00
|
|
|
m_textDifficultyNumber[pn].SetText( text );
|
2005-08-31 02:14:59 +00:00
|
|
|
m_textDifficultyNumber[pn].PlayCommand( "DifficultyChanged" );
|
2004-01-21 06:58:01 +00:00
|
|
|
|
2004-01-21 08:38:06 +00:00
|
|
|
m_textFoot[pn].SetText( "1" );
|
2005-08-31 02:14:59 +00:00
|
|
|
m_textFoot[pn].PlayCommand( "DifficultyChanged" );
|
2004-01-21 08:38:06 +00:00
|
|
|
}
|
|
|
|
|
|
2005-08-01 05:16:52 +00:00
|
|
|
void CourseEntryDisplay::SetFromGameState( int iCourseEntryIndex )
|
2004-01-21 08:38:06 +00:00
|
|
|
{
|
2005-08-01 05:16:52 +00:00
|
|
|
Course *pCourse = GAMESTATE->m_pCurCourse;
|
|
|
|
|
|
|
|
|
|
const TrailEntry *tes[NUM_PLAYERS];
|
|
|
|
|
const CourseEntry *ces[NUM_PLAYERS];
|
|
|
|
|
FOREACH_PlayerNumber( p )
|
|
|
|
|
{
|
|
|
|
|
Trail *pTrail = GAMESTATE->m_pCurTrail[p];
|
2005-08-12 04:05:19 +00:00
|
|
|
if( pTrail && iCourseEntryIndex < (int) pTrail->m_vEntries.size() )
|
2005-08-01 05:16:52 +00:00
|
|
|
{
|
|
|
|
|
tes[p] = &pTrail->m_vEntries[iCourseEntryIndex];
|
|
|
|
|
ces[p] = &pCourse->m_vEntries[iCourseEntryIndex];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tes[p] = NULL;
|
|
|
|
|
ces[p] = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-06-03 20:49:10 +00:00
|
|
|
const TrailEntry *te = tes[GAMESTATE->m_MasterPlayerNumber];
|
2004-06-06 20:18:50 +00:00
|
|
|
if( te == NULL )
|
|
|
|
|
return;
|
2004-09-08 00:03:06 +00:00
|
|
|
|
2005-03-10 22:54:55 +00:00
|
|
|
if( te->bSecret )
|
2004-01-21 08:38:06 +00:00
|
|
|
{
|
2004-05-23 00:53:20 +00:00
|
|
|
FOREACH_EnabledPlayer(pn)
|
2004-01-21 06:58:01 +00:00
|
|
|
{
|
2004-06-03 20:49:10 +00:00
|
|
|
const TrailEntry *te = tes[pn];
|
2005-08-01 05:16:52 +00:00
|
|
|
const CourseEntry *ce = ces[pn];
|
|
|
|
|
if( te == NULL || ce == NULL )
|
2004-09-08 00:03:06 +00:00
|
|
|
continue;
|
|
|
|
|
|
2005-08-03 03:13:28 +00:00
|
|
|
int iLow = ce->iLowMeter;
|
|
|
|
|
int iHigh = ce->iHighMeter;
|
|
|
|
|
|
2006-01-09 21:57:15 +00:00
|
|
|
bool bLowIsSet = iLow != -1;
|
|
|
|
|
bool bHighIsSet = iHigh != -1;
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString s;
|
2006-01-09 21:57:15 +00:00
|
|
|
if( !bLowIsSet && !bHighIsSet )
|
|
|
|
|
{
|
2005-08-03 03:13:28 +00:00
|
|
|
s = "?";
|
2006-01-09 21:57:15 +00:00
|
|
|
}
|
|
|
|
|
if( !bLowIsSet && bHighIsSet )
|
|
|
|
|
{
|
|
|
|
|
s = ssprintf( ">=%d", iHigh );
|
|
|
|
|
}
|
|
|
|
|
else if( bLowIsSet && !bHighIsSet )
|
|
|
|
|
{
|
|
|
|
|
s = ssprintf( "<=%d", iLow );
|
|
|
|
|
}
|
|
|
|
|
else if( bLowIsSet && bHighIsSet )
|
|
|
|
|
{
|
|
|
|
|
if( iLow == iHigh )
|
|
|
|
|
s = ssprintf( "%d", iLow );
|
|
|
|
|
else
|
|
|
|
|
s = ssprintf( "%d-%d", iLow, iHigh );
|
|
|
|
|
}
|
2005-08-03 03:13:28 +00:00
|
|
|
|
2004-05-25 20:33:17 +00:00
|
|
|
Difficulty dc = te->dc;
|
2004-01-21 08:38:06 +00:00
|
|
|
if( dc == DIFFICULTY_INVALID )
|
2005-08-03 03:13:28 +00:00
|
|
|
dc = DIFFICULTY_EDIT;
|
|
|
|
|
|
2005-08-31 01:42:22 +00:00
|
|
|
SetDifficulty( pn, s, dc );
|
2004-01-21 06:58:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_TextBanner.LoadFromString( "??????????", "??????????", "", "", "", "" );
|
|
|
|
|
m_TextBanner.SetDiffuse( RageColor(1,1,1,1) ); // TODO: What should this be?
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-05-23 00:53:20 +00:00
|
|
|
FOREACH_EnabledPlayer(pn)
|
2004-01-21 08:38:06 +00:00
|
|
|
{
|
2004-06-03 20:49:10 +00:00
|
|
|
const TrailEntry *te = tes[pn];
|
2004-06-06 20:18:50 +00:00
|
|
|
if( te == NULL )
|
|
|
|
|
continue;
|
2005-08-31 01:42:22 +00:00
|
|
|
SetDifficulty( pn, ssprintf("%d", te->pSteps->GetMeter()), te->pSteps->GetDifficulty() );
|
2004-01-21 08:38:06 +00:00
|
|
|
}
|
2004-01-21 06:58:01 +00:00
|
|
|
|
2004-05-23 00:53:20 +00:00
|
|
|
m_TextBanner.LoadFromSong( te->pSong );
|
|
|
|
|
m_TextBanner.SetDiffuse( SONGMAN->GetSongColor( te->pSong ) );
|
2004-01-21 06:58:01 +00:00
|
|
|
}
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2005-08-01 05:16:52 +00:00
|
|
|
m_textNumber.SetText( ssprintf("%d", iCourseEntryIndex+1) );
|
2003-02-17 02:45:30 +00:00
|
|
|
|
2004-05-23 00:53:20 +00:00
|
|
|
m_textModifiers.SetText( te->Modifiers );
|
2003-02-17 02:45:30 +00:00
|
|
|
}
|
2004-06-07 21:14:03 +00:00
|
|
|
|
2005-07-30 19:32:55 +00:00
|
|
|
|
|
|
|
|
// lua start
|
|
|
|
|
#include "LuaBinding.h"
|
|
|
|
|
|
|
|
|
|
class LunaCourseEntryDisplay: public Luna<CourseEntryDisplay>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
LunaCourseEntryDisplay() { LUA->Register( Register ); }
|
|
|
|
|
|
|
|
|
|
static int SetFromGameState( T* p, lua_State *L ) { p->SetFromGameState(IArg(1)); return 0; }
|
|
|
|
|
|
|
|
|
|
static void Register(lua_State *L)
|
|
|
|
|
{
|
2005-09-10 02:47:04 +00:00
|
|
|
ADD_METHOD( SetFromGameState );
|
|
|
|
|
|
2005-07-30 19:32:55 +00:00
|
|
|
Luna<T>::Register( L );
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
LUA_REGISTER_DERIVED_CLASS( CourseEntryDisplay, ActorFrame )
|
|
|
|
|
// 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.
|
|
|
|
|
*/
|