Files
itgmania212121/src/HoldJudgment.cpp
T

136 lines
3.7 KiB
C++
Raw Normal View History

2003-02-17 12:19:42 +00:00
#include "global.h"
#include "HoldJudgment.h"
#include "RageUtil.h"
#include "GameConstantsAndTypes.h"
#include "ThemeManager.h"
#include "ThemeMetric.h"
2006-04-21 00:07:27 +00:00
#include "ActorUtil.h"
2006-07-11 17:19:21 +00:00
#include "XmlFile.h"
2003-02-17 12:19:42 +00:00
2006-04-21 00:07:27 +00:00
REGISTER_ACTOR_CLASS( HoldJudgment )
2003-02-17 12:19:42 +00:00
HoldJudgment::HoldJudgment()
{
2006-10-07 03:43:41 +00:00
m_mpToTrack = MultiPlayer_Invalid;
2006-07-11 17:19:21 +00:00
}
void HoldJudgment::Load( const RString &sPath )
{
m_sprJudgment.Load( sPath );
m_sprJudgment->StopAnimating();
2006-08-21 21:33:00 +00:00
m_sprJudgment->SetName( "HoldJudgment" );
ActorUtil::LoadAllCommands( *m_sprJudgment, "HoldJudgment" );
ResetAnimation();
this->AddChild( m_sprJudgment );
2006-07-11 17:19:21 +00:00
}
2006-04-21 00:07:27 +00:00
void HoldJudgment::LoadFromNode( const XNode* pNode )
2006-07-11 17:19:21 +00:00
{
RString sFile;
2006-10-09 06:55:28 +00:00
if( ActorUtil::GetAttrPath(pNode, "File", sFile) )
2006-10-09 08:08:59 +00:00
RageException::Throw( "%s: HoldJudgment: missing the attribute \"File\"", ActorUtil::GetWhere(pNode).c_str() );
2006-07-11 17:19:21 +00:00
CollapsePath( sFile );
Load( sFile );
ActorFrame::LoadFromNode( pNode );
2003-02-17 12:19:42 +00:00
}
void HoldJudgment::ResetAnimation()
2003-03-09 00:55:49 +00:00
{
2006-07-13 07:28:08 +00:00
ASSERT( m_sprJudgment.IsLoaded() );
m_sprJudgment->SetDiffuse( RageColor(1,1,1,0) );
m_sprJudgment->SetXY( 0, 0 );
m_sprJudgment->StopTweening();
m_sprJudgment->StopEffect();
2003-02-17 12:19:42 +00:00
}
void HoldJudgment::SetHoldJudgment( HoldNoteScore hns )
{
//LOG->Trace( "Judgment::SetJudgment()" );
ResetAnimation();
2003-02-17 12:19:42 +00:00
2003-03-09 00:55:49 +00:00
switch( hns )
2003-02-17 12:19:42 +00:00
{
case HNS_None:
2003-03-09 00:55:49 +00:00
ASSERT(0);
case HNS_Held:
m_sprJudgment->SetState( 0 );
2006-08-21 21:33:00 +00:00
m_sprJudgment->PlayCommand( "Held" );
2003-03-09 00:55:49 +00:00
break;
case HNS_LetGo:
m_sprJudgment->SetState( 1 );
2006-08-21 21:33:00 +00:00
m_sprJudgment->PlayCommand( "LetGo" );
2003-03-09 00:55:49 +00:00
break;
default:
ASSERT(0);
2003-02-17 12:19:42 +00:00
}
}
2004-06-08 00:08:04 +00:00
2006-04-21 00:07:27 +00:00
void HoldJudgment::LoadFromMultiPlayer( MultiPlayer mp )
{
2006-10-07 03:43:41 +00:00
ASSERT( m_mpToTrack == MultiPlayer_Invalid ); // assert only load once
2006-04-21 00:07:27 +00:00
m_mpToTrack = mp;
this->SubscribeToMessage( "Judgment" );
2006-04-21 00:07:27 +00:00
}
2006-11-13 23:11:25 +00:00
void HoldJudgment::HandleMessage( const Message &msg )
2006-04-21 00:07:27 +00:00
{
if( m_mpToTrack != MultiPlayer_Invalid && msg.GetName() == "Judgment" )
2007-02-03 06:02:46 +00:00
{
MultiPlayer mp;
if( msg.GetParam("MultiPlayer", mp) && mp == m_mpToTrack )
{
HoldNoteScore hns;
if( msg.GetParam("HoldNoteScore", hns) )
SetHoldJudgment( hns );
}
2007-02-03 06:02:46 +00:00
}
2006-04-21 00:07:27 +00:00
2006-11-13 23:11:25 +00:00
ActorFrame::HandleMessage( msg );
2006-04-21 00:07:27 +00:00
}
// lua start
#include "LuaBinding.h"
class LunaHoldJudgment: public Luna<HoldJudgment>
{
public:
2006-09-27 06:18:11 +00:00
static int LoadFromMultiPlayer( T* p, lua_State *L ) { p->LoadFromMultiPlayer( Enum::Check<MultiPlayer>(L, 1) ); return 0; }
2006-04-21 00:07:27 +00:00
2006-09-27 20:10:14 +00:00
LunaHoldJudgment()
2006-04-21 00:07:27 +00:00
{
2006-09-27 20:10:14 +00:00
ADD_METHOD( LoadFromMultiPlayer );
2006-04-21 00:07:27 +00:00
}
};
LUA_REGISTER_DERIVED_CLASS( HoldJudgment, ActorFrame )
// lua end
2004-06-08 00:08:04 +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.
*/