add Lua/Xml bindings
This commit is contained in:
@@ -4,10 +4,13 @@
|
|||||||
#include "GameConstantsAndTypes.h"
|
#include "GameConstantsAndTypes.h"
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
#include "ThemeMetric.h"
|
#include "ThemeMetric.h"
|
||||||
|
#include "ActorUtil.h"
|
||||||
|
#include "StatsManager.h"
|
||||||
|
|
||||||
static ThemeMetric<apActorCommands> HELD_COMMAND ("HoldJudgment","HeldCommand");
|
static ThemeMetric<apActorCommands> HELD_COMMAND ("HoldJudgment","HeldCommand");
|
||||||
static ThemeMetric<apActorCommands> LET_GO_COMMAND ("HoldJudgment","LetGoCommand");
|
static ThemeMetric<apActorCommands> LET_GO_COMMAND ("HoldJudgment","LetGoCommand");
|
||||||
|
|
||||||
|
REGISTER_ACTOR_CLASS( HoldJudgment )
|
||||||
|
|
||||||
HoldJudgment::HoldJudgment()
|
HoldJudgment::HoldJudgment()
|
||||||
{
|
{
|
||||||
@@ -15,6 +18,8 @@ HoldJudgment::HoldJudgment()
|
|||||||
m_sprJudgment->StopAnimating();
|
m_sprJudgment->StopAnimating();
|
||||||
ResetAnimation();
|
ResetAnimation();
|
||||||
this->AddChild( m_sprJudgment );
|
this->AddChild( m_sprJudgment );
|
||||||
|
|
||||||
|
m_mpToTrack = MultiPlayer_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HoldJudgment::ResetAnimation()
|
void HoldJudgment::ResetAnimation()
|
||||||
@@ -48,6 +53,43 @@ void HoldJudgment::SetHoldJudgment( HoldNoteScore hns )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HoldJudgment::LoadFromMultiPlayer( MultiPlayer mp )
|
||||||
|
{
|
||||||
|
ASSERT( m_mpToTrack == MultiPlayer_INVALID ); // assert only load once
|
||||||
|
m_mpToTrack = mp;
|
||||||
|
this->SubscribeToMessage( enum_add2(Message_ShowHoldJudgmentMuliPlayerP1,m_mpToTrack) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void HoldJudgment::HandleMessage( const RString &sMessage )
|
||||||
|
{
|
||||||
|
ASSERT( m_mpToTrack != MultiPlayer_INVALID );
|
||||||
|
if( sMessage == MessageToString( enum_add2(Message_ShowHoldJudgmentMuliPlayerP1,m_mpToTrack) ) )
|
||||||
|
SetHoldJudgment( STATSMAN->m_CurStageStats.m_multiPlayer[m_mpToTrack].hnsLast );
|
||||||
|
|
||||||
|
ActorFrame::HandleMessage( sMessage );
|
||||||
|
}
|
||||||
|
|
||||||
|
// lua start
|
||||||
|
#include "LuaBinding.h"
|
||||||
|
|
||||||
|
class LunaHoldJudgment: public Luna<HoldJudgment>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LunaHoldJudgment() { LUA->Register( Register ); }
|
||||||
|
|
||||||
|
static int LoadFromMultiPlayer( T* p, lua_State *L ) { p->LoadFromMultiPlayer( (MultiPlayer)IArg(1) ); return 0; }
|
||||||
|
|
||||||
|
static void Register(lua_State *L)
|
||||||
|
{
|
||||||
|
ADD_METHOD( LoadFromMultiPlayer );
|
||||||
|
|
||||||
|
Luna<T>::Register( L );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LUA_REGISTER_DERIVED_CLASS( HoldJudgment, ActorFrame )
|
||||||
|
// lua end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2001-2004 Chris Danford
|
* (c) 2001-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -10,12 +10,21 @@ class HoldJudgment : public ActorFrame
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HoldJudgment();
|
HoldJudgment();
|
||||||
|
virtual Actor *Copy() const;
|
||||||
|
|
||||||
void SetHoldJudgment( HoldNoteScore hns );
|
void SetHoldJudgment( HoldNoteScore hns );
|
||||||
|
void LoadFromMultiPlayer( MultiPlayer mp );
|
||||||
|
void HandleMessage( const RString &sMessage );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lua
|
||||||
|
//
|
||||||
|
virtual void PushSelf( lua_State *L );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ResetAnimation();
|
void ResetAnimation();
|
||||||
AutoActor m_sprJudgment;
|
AutoActor m_sprJudgment;
|
||||||
|
MultiPlayer m_mpToTrack;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include "GameState.h"
|
#include "GameState.h"
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
#include "ThemeMetric.h"
|
#include "ThemeMetric.h"
|
||||||
|
#include "ActorUtil.h"
|
||||||
|
#include "StatsManager.h"
|
||||||
|
|
||||||
static ThemeMetric<apActorCommands> W1_COMMAND ("Judgment","W1Command");
|
static ThemeMetric<apActorCommands> W1_COMMAND ("Judgment","W1Command");
|
||||||
static ThemeMetric<apActorCommands> W2_COMMAND ("Judgment","W2Command");
|
static ThemeMetric<apActorCommands> W2_COMMAND ("Judgment","W2Command");
|
||||||
@@ -13,11 +15,14 @@ static ThemeMetric<apActorCommands> W4_COMMAND ("Judgment","W4Command");
|
|||||||
static ThemeMetric<apActorCommands> W5_COMMAND ("Judgment","W5Command");
|
static ThemeMetric<apActorCommands> W5_COMMAND ("Judgment","W5Command");
|
||||||
static ThemeMetric<apActorCommands> MISS_COMMAND ("Judgment","MissCommand");
|
static ThemeMetric<apActorCommands> MISS_COMMAND ("Judgment","MissCommand");
|
||||||
|
|
||||||
|
REGISTER_ACTOR_CLASS( Judgment )
|
||||||
|
|
||||||
Judgment::Judgment()
|
Judgment::Judgment()
|
||||||
{
|
{
|
||||||
|
m_mpToTrack = MultiPlayer_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Judgment::Load( bool bBeginner )
|
void Judgment::LoadNormal( bool bBeginner )
|
||||||
{
|
{
|
||||||
m_sprJudgment.Load( THEME->GetPathG("Judgment",bBeginner?"BeginnerLabel":"label") );
|
m_sprJudgment.Load( THEME->GetPathG("Judgment",bBeginner?"BeginnerLabel":"label") );
|
||||||
ASSERT( m_sprJudgment.GetNumStates() == 6 || m_sprJudgment.GetNumStates() == 12 );
|
ASSERT( m_sprJudgment.GetNumStates() == 6 || m_sprJudgment.GetNumStates() == 12 );
|
||||||
@@ -26,7 +31,6 @@ void Judgment::Load( bool bBeginner )
|
|||||||
this->AddChild( &m_sprJudgment );
|
this->AddChild( &m_sprJudgment );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Judgment::Reset()
|
void Judgment::Reset()
|
||||||
{
|
{
|
||||||
m_sprJudgment.FinishTweening();
|
m_sprJudgment.FinishTweening();
|
||||||
@@ -77,6 +81,50 @@ void Judgment::SetJudgment( TapNoteScore score, bool bEarly )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Judgment::LoadFromMultiPlayer( MultiPlayer mp )
|
||||||
|
{
|
||||||
|
LoadNormal( false );
|
||||||
|
ASSERT( m_mpToTrack == MultiPlayer_INVALID ); // assert only load once
|
||||||
|
m_mpToTrack = mp;
|
||||||
|
this->SubscribeToMessage( enum_add2(Message_ShowJudgmentMuliPlayerP1,m_mpToTrack) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Judgment::HandleMessage( const RString &sMessage )
|
||||||
|
{
|
||||||
|
ASSERT( m_mpToTrack != MultiPlayer_INVALID );
|
||||||
|
if( sMessage == MessageToString( enum_add2(Message_ShowJudgmentMuliPlayerP1,m_mpToTrack) ) )
|
||||||
|
SetJudgment( STATSMAN->m_CurStageStats.m_multiPlayer[m_mpToTrack].tnsLast, false ); // FIXME: save and pass early bool?
|
||||||
|
|
||||||
|
ActorFrame::HandleMessage( sMessage );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Judgment::DrawPrimitives()
|
||||||
|
{
|
||||||
|
ActorFrame::DrawPrimitives();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// lua start
|
||||||
|
#include "LuaBinding.h"
|
||||||
|
|
||||||
|
class LunaJudgment: public Luna<Judgment>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LunaJudgment() { LUA->Register( Register ); }
|
||||||
|
|
||||||
|
static int LoadFromMultiPlayer( T* p, lua_State *L ) { p->LoadFromMultiPlayer( (MultiPlayer)IArg(1) ); return 0; }
|
||||||
|
|
||||||
|
static void Register(lua_State *L)
|
||||||
|
{
|
||||||
|
ADD_METHOD( LoadFromMultiPlayer );
|
||||||
|
|
||||||
|
Luna<T>::Register( L );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LUA_REGISTER_DERIVED_CLASS( Judgment, ActorFrame )
|
||||||
|
// lua end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2001-2004 Chris Danford
|
* (c) 2001-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -12,12 +12,22 @@ class Judgment : public ActorFrame
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Judgment();
|
Judgment();
|
||||||
void Load( bool bAlternateLabel );
|
virtual Actor *Copy() const;
|
||||||
|
void LoadNormal( bool bAlternateLabel );
|
||||||
|
void LoadFromMultiPlayer( MultiPlayer mp );
|
||||||
void Reset();
|
void Reset();
|
||||||
void SetJudgment( TapNoteScore score, bool bEarly );
|
void SetJudgment( TapNoteScore score, bool bEarly );
|
||||||
|
void HandleMessage( const RString &sMessage );
|
||||||
|
virtual void DrawPrimitives();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lua
|
||||||
|
//
|
||||||
|
virtual void PushSelf( lua_State *L );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Sprite m_sprJudgment;
|
Sprite m_sprJudgment;
|
||||||
|
MultiPlayer m_mpToTrack;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user