use Lua to execute commands
(needs cleanup)
This commit is contained in:
+59
-46
@@ -10,11 +10,12 @@
|
||||
#include "Foreach.h"
|
||||
#include "XmlFile.h"
|
||||
#include "LuaBinding.h"
|
||||
#include "LuaManager.h"
|
||||
#include "Command.h"
|
||||
#include "ActorCommands.h"
|
||||
|
||||
|
||||
// lua start
|
||||
//LUA_REGISTER_CLASS( Actor, null )
|
||||
LUA_REGISTER_CLASS( Actor )
|
||||
// lua end
|
||||
|
||||
|
||||
@@ -99,13 +100,15 @@ void Actor::LoadFromNode( const CString& sDir, const XNode* pNode )
|
||||
|
||||
const CString &sCommands = a->m_sValue;
|
||||
Commands cmds = ParseCommands( sCommands );
|
||||
apActorCommands apac( new ActorCommands( cmds ) );
|
||||
|
||||
CString sCmdName;
|
||||
/* Special case: "Command=foo" -> "OnCommand=foo" */
|
||||
if( sKeyName.size() == 7 )
|
||||
sCmdName="on";
|
||||
else
|
||||
sCmdName = sKeyName.Left( sKeyName.size()-7 );
|
||||
m_mapNameToCommands[sCmdName] = cmds;
|
||||
m_mapNameToCommands[sCmdName] = apac;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,9 +310,10 @@ void Actor::UpdateTweening( float fDeltaTime )
|
||||
m_start = m_current; // set the start position
|
||||
|
||||
// Execute the command in this tween (if any).
|
||||
const Command &command = TS.command;
|
||||
if( command.m_vsArgs.size() )
|
||||
this->HandleCommand( command );
|
||||
if( TS.sCommandName.size() )
|
||||
{
|
||||
this->PlayCommand( TS.sCommandName );
|
||||
}
|
||||
}
|
||||
|
||||
float fSecsToSubtract = min( TI.m_fTimeLeftInTween, fDeltaTime );
|
||||
@@ -433,7 +437,7 @@ void Actor::BeginTweening( float time, TweenType tt )
|
||||
TS = m_Tweens[m_Tweens.size()-2].state;
|
||||
|
||||
// don't inherit the queued state's command
|
||||
TS.command.Clear();
|
||||
TS.sCommandName = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -499,28 +503,28 @@ void Actor::ScaleTo( const RectF &rect, StretchType st )
|
||||
SetZoom( fNewZoom );
|
||||
}
|
||||
|
||||
void Actor::SetHorizAlign( const CString &s )
|
||||
void Actor::SetHorizAlignString( const CString &s )
|
||||
{
|
||||
if (s.CompareNoCase("left")==0) SetHorizAlign( align_left ); /* call derived */
|
||||
else if(s.CompareNoCase("center")==0) SetHorizAlign( align_center );
|
||||
else if(s.CompareNoCase("right")==0) SetHorizAlign( align_right );
|
||||
if (s.CompareNoCase("left")==0) this->SetHorizAlign( align_left ); /* call derived */
|
||||
else if(s.CompareNoCase("center")==0) this->SetHorizAlign( align_center );
|
||||
else if(s.CompareNoCase("right")==0) this->SetHorizAlign( align_right );
|
||||
else ASSERT(0);
|
||||
}
|
||||
|
||||
void Actor::SetVertAlign( const CString &s )
|
||||
void Actor::SetVertAlignString( const CString &s )
|
||||
{
|
||||
if (s.CompareNoCase("top")==0) SetVertAlign( align_top ); /* call derived */
|
||||
else if(s.CompareNoCase("middle")==0) SetVertAlign( align_middle );
|
||||
else if(s.CompareNoCase("bottom")==0) SetVertAlign( align_bottom );
|
||||
if (s.CompareNoCase("top")==0) this->SetVertAlign( align_top ); /* call derived */
|
||||
else if(s.CompareNoCase("middle")==0) this->SetVertAlign( align_middle );
|
||||
else if(s.CompareNoCase("bottom")==0) this->SetVertAlign( align_bottom );
|
||||
else ASSERT(0);
|
||||
}
|
||||
|
||||
void Actor::SetEffectClock( const CString &s )
|
||||
void Actor::SetEffectClockString( const CString &s )
|
||||
{
|
||||
if (s.CompareNoCase("timer")==0) SetEffectClock( CLOCK_TIMER );
|
||||
else if(s.CompareNoCase("beat")==0) SetEffectClock( CLOCK_BGM_BEAT );
|
||||
else if(s.CompareNoCase("music")==0) SetEffectClock( CLOCK_BGM_TIME );
|
||||
else if(s.CompareNoCase("bgm")==0) SetEffectClock( CLOCK_BGM_BEAT ); // compat, deprecated
|
||||
if (s.CompareNoCase("timer")==0) this->SetEffectClock( CLOCK_TIMER );
|
||||
else if(s.CompareNoCase("beat")==0) this->SetEffectClock( CLOCK_BGM_BEAT );
|
||||
else if(s.CompareNoCase("music")==0) this->SetEffectClock( CLOCK_BGM_TIME );
|
||||
else if(s.CompareNoCase("bgm")==0) this->SetEffectClock( CLOCK_BGM_BEAT ); // compat, deprecated
|
||||
else ASSERT(0);
|
||||
}
|
||||
|
||||
@@ -671,12 +675,15 @@ void Actor::AddRotationR( float rot )
|
||||
RageQuatMultiply( &DestTweenState().quat, DestTweenState().quat, RageQuatFromR(rot) );
|
||||
}
|
||||
|
||||
void Actor::RunCommands( const Commands &cmds )
|
||||
void Actor::RunCommands( const ActorCommands& cmds )
|
||||
{
|
||||
FOREACH_CONST( Command, cmds.v, c )
|
||||
this->HandleCommand( *c );
|
||||
lua_pushstring(LUA->L, cmds.GetFunctionName()); // function name
|
||||
lua_gettable(LUA->L, LUA_GLOBALSINDEX); // function to be called
|
||||
this->PushSelf( LUA->L ); // 1st parameter
|
||||
lua_call(LUA->L, 1, 0); // call function with 1 argument and 0 results
|
||||
}
|
||||
|
||||
/*
|
||||
void Actor::HandleCommand( const Command &command )
|
||||
{
|
||||
BeginHandleArgs;
|
||||
@@ -730,7 +737,7 @@ void Actor::HandleCommand( const Command &command )
|
||||
else if( sName=="diffuserightedge" ) SetDiffuseRightEdge( cArg(1) );
|
||||
else if( sName=="diffusetopedge" ) SetDiffuseTopEdge( cArg(1) );
|
||||
else if( sName=="diffusebottomedge" ) SetDiffuseBottomEdge( cArg(1) );
|
||||
/* Add left/right/top/bottom for alpha if needed. */
|
||||
// Add left/right/top/bottom for alpha if needed.
|
||||
else if( sName=="diffusealpha" ) SetDiffuseAlpha( fArg(1) );
|
||||
else if( sName=="diffusecolor" ) SetDiffuseColor( cArg(1) );
|
||||
else if( sName=="glow" ) SetGlow( cArg(1) );
|
||||
@@ -791,10 +798,10 @@ void Actor::HandleCommand( const Command &command )
|
||||
return; // don't do argument count checking
|
||||
}
|
||||
|
||||
/* These are commands intended for a Sprite commands, but they will get
|
||||
* sent to all sub-actors (which aren't necessarily Sprites) on
|
||||
* GainFocus and LoseFocus. So, don't run EndHandleArgs
|
||||
* on these commands. */
|
||||
// These are commands intended for a Sprite commands, but they will get
|
||||
// sent to all sub-actors (which aren't necessarily Sprites) on
|
||||
// GainFocus and LoseFocus. So, don't run EndHandleArgs
|
||||
// on these commands.
|
||||
else if(
|
||||
sName=="customtexturerect" ||
|
||||
sName=="texcoordvelocity" ||
|
||||
@@ -816,8 +823,9 @@ void Actor::HandleCommand( const Command &command )
|
||||
|
||||
EndHandleArgs;
|
||||
}
|
||||
*/
|
||||
|
||||
float Actor::GetCommandsLengthSeconds( const Commands &cmds )
|
||||
float Actor::GetCommandsLengthSeconds( const ActorCommands& cmds )
|
||||
{
|
||||
Actor temp;
|
||||
temp.RunCommands(cmds);
|
||||
@@ -916,28 +924,28 @@ void Actor::TweenState::MakeWeightedAverage( TweenState& average_out, const Twee
|
||||
average_out.glow = ts1.glow + (ts2.glow - ts1.glow )*fPercentBetween;
|
||||
}
|
||||
|
||||
void Actor::SetBlendMode( const CString &s )
|
||||
void Actor::SetBlendModeString( const CString &s )
|
||||
{
|
||||
if (s.CompareNoCase("normal")==0) SetBlendMode( BLEND_NORMAL );
|
||||
else if(s.CompareNoCase("add")==0) SetBlendMode( BLEND_ADD );
|
||||
else if(s.CompareNoCase("noeffect")==0) SetBlendMode( BLEND_NO_EFFECT );
|
||||
if (s.CompareNoCase("normal")==0) this->SetBlendMode( BLEND_NORMAL );
|
||||
else if(s.CompareNoCase("add")==0) this->SetBlendMode( BLEND_ADD );
|
||||
else if(s.CompareNoCase("noeffect")==0) this->SetBlendMode( BLEND_NO_EFFECT );
|
||||
else ASSERT(0);
|
||||
}
|
||||
|
||||
void Actor::SetCullMode( const CString &s )
|
||||
void Actor::SetCullModeString( const CString &s )
|
||||
{
|
||||
if (s.CompareNoCase("back")==0) SetCullMode( CULL_BACK );
|
||||
else if(s.CompareNoCase("front")==0) SetCullMode( CULL_FRONT );
|
||||
else if(s.CompareNoCase("none")==0) SetCullMode( CULL_NONE );
|
||||
if (s.CompareNoCase("back")==0) this->SetCullMode( CULL_BACK );
|
||||
else if(s.CompareNoCase("front")==0) this->SetCullMode( CULL_FRONT );
|
||||
else if(s.CompareNoCase("none")==0) this->SetCullMode( CULL_NONE );
|
||||
else ASSERT(0);
|
||||
}
|
||||
|
||||
void Actor::SetZTestMode( const CString &s )
|
||||
void Actor::SetZTestModeString( const CString &s )
|
||||
{
|
||||
// for metrics backward compatibility
|
||||
if(s.CompareNoCase("off")==0) SetZTestMode( ZTEST_OFF );
|
||||
else if(s.CompareNoCase("writeonpass")==0) SetZTestMode( ZTEST_WRITE_ON_PASS );
|
||||
else if(s.CompareNoCase("writeonfail")==0) SetZTestMode( ZTEST_WRITE_ON_FAIL );
|
||||
if(s.CompareNoCase("off")==0) this->SetZTestMode( ZTEST_OFF );
|
||||
else if(s.CompareNoCase("writeonpass")==0) this->SetZTestMode( ZTEST_WRITE_ON_PASS );
|
||||
else if(s.CompareNoCase("writeonfail")==0) this->SetZTestMode( ZTEST_WRITE_ON_FAIL );
|
||||
else ASSERT(0);
|
||||
}
|
||||
|
||||
@@ -954,22 +962,27 @@ void Actor::Sleep( float time )
|
||||
BeginTweening( 0, TWEEN_LINEAR );
|
||||
}
|
||||
|
||||
void Actor::QueueCommand( const Command& command )
|
||||
void Actor::QueueCommand( const CString& sCommandName )
|
||||
{
|
||||
BeginTweening( 0, TWEEN_LINEAR );
|
||||
DestTweenState().command = command;
|
||||
BeginTweening( 0, TWEEN_LINEAR );
|
||||
DestTweenState().sCommandName = sCommandName;
|
||||
}
|
||||
|
||||
void Actor::PlayCommand( const CString &sCommandName )
|
||||
{
|
||||
CString sKey = sCommandName;
|
||||
sKey.MakeLower();
|
||||
map<CString, Commands>::const_iterator it = m_mapNameToCommands.find( sKey );
|
||||
map<CString, apActorCommands>::const_iterator it = m_mapNameToCommands.find( sKey );
|
||||
|
||||
if( it == m_mapNameToCommands.end() )
|
||||
return;
|
||||
|
||||
RunCommands( it->second );
|
||||
RunCommands( *it->second );
|
||||
}
|
||||
|
||||
void Actor::PushSelf( lua_State *L )
|
||||
{
|
||||
Luna<Actor,LuaActor>::Push( L, this );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+195
-19
@@ -4,24 +4,197 @@
|
||||
#define ACTOR_H
|
||||
|
||||
#include "RageTypes.h"
|
||||
#include "Command.h"
|
||||
#include "ActorCommands.h"
|
||||
#include <deque>
|
||||
#include <map>
|
||||
struct XNode;
|
||||
struct lua_State;
|
||||
|
||||
#define DRAW_ORDER_BEFORE_EVERYTHING -100
|
||||
#define DRAW_ORDER_TRANSITIONS 100
|
||||
#define DRAW_ORDER_AFTER_EVERYTHING 200
|
||||
|
||||
/*
|
||||
|
||||
#define LUA_Actor_METHODS( T ) \
|
||||
static int GetX( T* p, lua_State *L ) { lua_pushnumber(L, p->GetX()); return 1; } \
|
||||
static int SetX( T* p, lua_State *L ) { p->SetX(luaL_checknumber(L, 1)); return 0; } \
|
||||
static int sleep( T* p, lua_State *L ) { p->Sleep(FArg(1)); return 0; } \
|
||||
static int linear( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_LINEAR); return 0; } \
|
||||
static int accelerate( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_ACCELERATE); return 0; } \
|
||||
static int decelerate( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_DECELERATE); return 0; } \
|
||||
static int bouncebegin( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_BOUNCE_BEGIN); return 0; } \
|
||||
static int bounceend( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_BOUNCE_END); return 0; } \
|
||||
static int spring( T* p, lua_State *L ) { p->BeginTweening(FArg(1),Actor::TWEEN_SPRING); return 0; } \
|
||||
static int stoptweening( T* p, lua_State *L ) { p->StopTweening(); p->BeginTweening( 0.0001f, Actor::TWEEN_LINEAR ); return 0; } \
|
||||
static int finishtweening( T* p, lua_State *L ) { p->FinishTweening(); return 0; } \
|
||||
static int hurrytweening( T* p, lua_State *L ) { p->HurryTweening(FArg(1)); return 0; } \
|
||||
static int x( T* p, lua_State *L ) { p->SetX(FArg(1)); return 0; } \
|
||||
static int y( T* p, lua_State *L ) { p->SetY(FArg(1)); return 0; } \
|
||||
static int z( T* p, lua_State *L ) { p->SetZ(FArg(1)); return 0; } \
|
||||
static int addx( T* p, lua_State *L ) { p->AddX(FArg(1)); return 0; } \
|
||||
static int addy( T* p, lua_State *L ) { p->AddY(FArg(1)); return 0; } \
|
||||
static int addz( T* p, lua_State *L ) { p->AddZ(FArg(1)); return 0; } \
|
||||
static int zoom( T* p, lua_State *L ) { p->SetZoom(FArg(1)); return 0; } \
|
||||
static int zoomx( T* p, lua_State *L ) { p->SetZoomX(FArg(1)); return 0; } \
|
||||
static int zoomy( T* p, lua_State *L ) { p->SetZoomY(FArg(1)); return 0; } \
|
||||
static int zoomz( T* p, lua_State *L ) { p->SetZoomZ(FArg(1)); return 0; } \
|
||||
static int zoomtowidth( T* p, lua_State *L ) { p->ZoomToWidth(FArg(1)); return 0; } \
|
||||
static int zoomtoheight( T* p, lua_State *L ) { p->ZoomToHeight(FArg(1)); return 0; } \
|
||||
static int stretchto( T* p, lua_State *L ) { p->StretchTo( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
|
||||
static int cropleft( T* p, lua_State *L ) { p->SetCropLeft(FArg(1)); return 0; } \
|
||||
static int croptop( T* p, lua_State *L ) { p->SetCropTop(FArg(1)); return 0; } \
|
||||
static int cropright( T* p, lua_State *L ) { p->SetCropRight(FArg(1)); return 0; } \
|
||||
static int cropbottom( T* p, lua_State *L ) { p->SetCropBottom(FArg(1)); return 0; } \
|
||||
static int fadeleft( T* p, lua_State *L ) { p->SetFadeLeft(FArg(1)); return 0; } \
|
||||
static int fadetop( T* p, lua_State *L ) { p->SetFadeTop(FArg(1)); return 0; } \
|
||||
static int faderight( T* p, lua_State *L ) { p->SetFadeRight(FArg(1)); return 0; } \
|
||||
static int fadebottom( T* p, lua_State *L ) { p->SetFadeBottom(FArg(1)); return 0; } \
|
||||
static int diffuse( T* p, lua_State *L ) { p->SetDiffuse( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
|
||||
static int diffuseleftedge( T* p, lua_State *L ) { p->SetDiffuseLeftEdge( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
|
||||
static int diffuserightedge( T* p, lua_State *L ) { p->SetDiffuseRightEdge( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
|
||||
static int diffusetopedge( T* p, lua_State *L ) { p->SetDiffuseTopEdge( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
|
||||
static int diffusebottomedge( T* p, lua_State *L ) { p->SetDiffuseBottomEdge( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
|
||||
static int diffusealpha( T* p, lua_State *L ) { p->SetDiffuseAlpha(FArg(1)); return 0; } \
|
||||
static int diffusecolor( T* p, lua_State *L ) { p->SetDiffuseColor( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
|
||||
static int glow( T* p, lua_State *L ) { p->SetGlow( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
|
||||
static int rotationx( T* p, lua_State *L ) { p->SetRotationX(FArg(1)); return 0; } \
|
||||
static int rotationy( T* p, lua_State *L ) { p->SetRotationY(FArg(1)); return 0; } \
|
||||
static int rotationz( T* p, lua_State *L ) { p->SetRotationZ(FArg(1)); return 0; } \
|
||||
static int heading( T* p, lua_State *L ) { p->AddRotationH(FArg(1)); return 0; } \
|
||||
static int pitch( T* p, lua_State *L ) { p->AddRotationP(FArg(1)); return 0; } \
|
||||
static int roll( T* p, lua_State *L ) { p->AddRotationR(FArg(1)); return 0; } \
|
||||
static int shadowlength( T* p, lua_State *L ) { p->SetShadowLength(FArg(1)); return 0; } \
|
||||
static int horizalign( T* p, lua_State *L ) { p->SetHorizAlignString(SArg(1)); return 0; } \
|
||||
static int vertalign( T* p, lua_State *L ) { p->SetVertAlignString(SArg(1)); return 0; } \
|
||||
static int diffuseblink( T* p, lua_State *L ) { p->SetEffectDiffuseBlink(); return 0; } \
|
||||
static int diffuseshift( T* p, lua_State *L ) { p->SetEffectDiffuseShift(); return 0; } \
|
||||
static int glowblink( T* p, lua_State *L ) { p->SetEffectGlowBlink(); return 0; } \
|
||||
static int glowshift( T* p, lua_State *L ) { p->SetEffectGlowShift(); return 0; } \
|
||||
static int rainbow( T* p, lua_State *L ) { p->SetEffectRainbow(); return 0; } \
|
||||
static int wag( T* p, lua_State *L ) { p->SetEffectWag(); return 0; } \
|
||||
static int bounce( T* p, lua_State *L ) { p->SetEffectBounce(); return 0; } \
|
||||
static int bob( T* p, lua_State *L ) { p->SetEffectBob(); return 0; } \
|
||||
static int pulse( T* p, lua_State *L ) { p->SetEffectPulse(); return 0; } \
|
||||
static int spin( T* p, lua_State *L ) { p->SetEffectSpin(); return 0; } \
|
||||
static int vibrate( T* p, lua_State *L ) { p->SetEffectVibrate(); return 0; } \
|
||||
static int stopeffect( T* p, lua_State *L ) { p->SetEffectNone(); return 0; } \
|
||||
static int effectcolor1( T* p, lua_State *L ) { p->SetEffectColor1( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
|
||||
static int effectcolor2( T* p, lua_State *L ) { p->SetEffectColor2( RageColor(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
|
||||
static int effectperiod( T* p, lua_State *L ) { p->SetEffectPeriod(FArg(1)); return 0; } \
|
||||
static int effectoffset( T* p, lua_State *L ) { p->SetEffectOffset(FArg(1)); return 0; } \
|
||||
static int effectdelay( T* p, lua_State *L ) { p->SetEffectDelay(FArg(1)); return 0; } \
|
||||
static int effectclock( T* p, lua_State *L ) { p->SetEffectClockString(SArg(1)); return 0; } \
|
||||
static int effectmagnitude( T* p, lua_State *L ) { p->SetEffectMagnitude( RageVector3(FArg(1),FArg(2),FArg(3)) ); return 0; } \
|
||||
static int scaletocover( T* p, lua_State *L ) { p->ScaleToCover( RectF(FArg(1), FArg(2), FArg(3), FArg(4)) ); return 0; } \
|
||||
static int scaletofit( T* p, lua_State *L ) { p->ScaleToFitInside( RectF(FArg(1), FArg(2), FArg(3), FArg(4)) ); return 0; } \
|
||||
static int animate( T* p, lua_State *L ) { p->EnableAnimation(BArg(1)); return 0; } \
|
||||
static int play( T* p, lua_State *L ) { p->EnableAnimation(true); return 0; } \
|
||||
static int pause( T* p, lua_State *L ) { p->EnableAnimation(false); return 0; } \
|
||||
static int setstate( T* p, lua_State *L ) { p->SetState(IArg(1)); return 0; } \
|
||||
static int texturewrapping( T* p, lua_State *L ) { p->SetTextureWrapping(BArg(1)); return 0; } \
|
||||
static int additiveblend( T* p, lua_State *L ) { p->SetBlendMode(BArg(1) ? BLEND_ADD : BLEND_NORMAL); return 0; } \
|
||||
static int blend( T* p, lua_State *L ) { p->SetBlendModeString(SArg(1)); return 0; } \
|
||||
static int zbuffer( T* p, lua_State *L ) { p->SetUseZBuffer(BArg(1)); return 0; } \
|
||||
static int ztest( T* p, lua_State *L ) { p->SetZTestMode(BArg(1)?ZTEST_WRITE_ON_PASS:ZTEST_OFF); return 0; } \
|
||||
static int ztestmode( T* p, lua_State *L ) { p->SetZTestModeString(SArg(1)); return 0; } \
|
||||
static int zwrite( T* p, lua_State *L ) { p->SetZWrite(BArg(1)); return 0; } \
|
||||
static int clearzbuffer( T* p, lua_State *L ) { p->SetClearZBuffer(BArg(1)); return 0; } \
|
||||
static int backfacecull( T* p, lua_State *L ) { p->SetCullMode(BArg(1) ? CULL_BACK : CULL_NONE); return 0; } \
|
||||
static int cullmode( T* p, lua_State *L ) { p->SetCullModeString(SArg(1)); return 0; } \
|
||||
static int hidden( T* p, lua_State *L ) { p->SetHidden(BArg(1)); return 0; } \
|
||||
static int hibernate( T* p, lua_State *L ) { p->SetHibernate(FArg(1)); return 0; } \
|
||||
static int draworder( T* p, lua_State *L ) { p->SetDrawOrder(IArg(1)); return 0; } \
|
||||
static int playcommand( T* p, lua_State *L ) { p->PlayCommand(SArg(1)); return 0; } \
|
||||
static int queuecommand( T* p, lua_State *L ) { p->QueueCommand(SArg(1)); return 0; } \
|
||||
|
||||
#define LUA_Actor_METHODS_MAP( T ) \
|
||||
LUA_METHOD_MAP( T, GetX ) \
|
||||
LUA_METHOD_MAP( T, SetX ) \
|
||||
*/
|
||||
LUA_METHOD_MAP( T, sleep ) \
|
||||
LUA_METHOD_MAP( T, linear ) \
|
||||
LUA_METHOD_MAP( T, accelerate ) \
|
||||
LUA_METHOD_MAP( T, decelerate ) \
|
||||
LUA_METHOD_MAP( T, bouncebegin ) \
|
||||
LUA_METHOD_MAP( T, bounceend ) \
|
||||
LUA_METHOD_MAP( T, spring ) \
|
||||
LUA_METHOD_MAP( T, stoptweening ) \
|
||||
LUA_METHOD_MAP( T, finishtweening ) \
|
||||
LUA_METHOD_MAP( T, hurrytweening ) \
|
||||
LUA_METHOD_MAP( T, x ) \
|
||||
LUA_METHOD_MAP( T, y ) \
|
||||
LUA_METHOD_MAP( T, z ) \
|
||||
LUA_METHOD_MAP( T, addx ) \
|
||||
LUA_METHOD_MAP( T, addy ) \
|
||||
LUA_METHOD_MAP( T, addz ) \
|
||||
LUA_METHOD_MAP( T, zoom ) \
|
||||
LUA_METHOD_MAP( T, zoomx ) \
|
||||
LUA_METHOD_MAP( T, zoomy ) \
|
||||
LUA_METHOD_MAP( T, zoomz ) \
|
||||
LUA_METHOD_MAP( T, zoomtowidth ) \
|
||||
LUA_METHOD_MAP( T, zoomtoheight ) \
|
||||
LUA_METHOD_MAP( T, stretchto ) \
|
||||
LUA_METHOD_MAP( T, cropleft ) \
|
||||
LUA_METHOD_MAP( T, croptop ) \
|
||||
LUA_METHOD_MAP( T, cropright ) \
|
||||
LUA_METHOD_MAP( T, cropbottom ) \
|
||||
LUA_METHOD_MAP( T, fadeleft ) \
|
||||
LUA_METHOD_MAP( T, fadetop ) \
|
||||
LUA_METHOD_MAP( T, faderight ) \
|
||||
LUA_METHOD_MAP( T, fadebottom ) \
|
||||
LUA_METHOD_MAP( T, diffuse ) \
|
||||
LUA_METHOD_MAP( T, diffuseleftedge ) \
|
||||
LUA_METHOD_MAP( T, diffuserightedge ) \
|
||||
LUA_METHOD_MAP( T, diffusetopedge ) \
|
||||
LUA_METHOD_MAP( T, diffusebottomedge ) \
|
||||
LUA_METHOD_MAP( T, diffusealpha ) \
|
||||
LUA_METHOD_MAP( T, diffusecolor ) \
|
||||
LUA_METHOD_MAP( T, glow ) \
|
||||
LUA_METHOD_MAP( T, rotationx ) \
|
||||
LUA_METHOD_MAP( T, rotationy ) \
|
||||
LUA_METHOD_MAP( T, rotationz ) \
|
||||
LUA_METHOD_MAP( T, heading ) \
|
||||
LUA_METHOD_MAP( T, pitch ) \
|
||||
LUA_METHOD_MAP( T, roll ) \
|
||||
LUA_METHOD_MAP( T, shadowlength ) \
|
||||
LUA_METHOD_MAP( T, horizalign ) \
|
||||
LUA_METHOD_MAP( T, vertalign ) \
|
||||
LUA_METHOD_MAP( T, diffuseblink ) \
|
||||
LUA_METHOD_MAP( T, diffuseshift ) \
|
||||
LUA_METHOD_MAP( T, glowblink ) \
|
||||
LUA_METHOD_MAP( T, glowshift ) \
|
||||
LUA_METHOD_MAP( T, rainbow ) \
|
||||
LUA_METHOD_MAP( T, wag ) \
|
||||
LUA_METHOD_MAP( T, bounce ) \
|
||||
LUA_METHOD_MAP( T, bob ) \
|
||||
LUA_METHOD_MAP( T, pulse ) \
|
||||
LUA_METHOD_MAP( T, spin ) \
|
||||
LUA_METHOD_MAP( T, vibrate ) \
|
||||
LUA_METHOD_MAP( T, stopeffect ) \
|
||||
LUA_METHOD_MAP( T, effectcolor1 ) \
|
||||
LUA_METHOD_MAP( T, effectcolor2 ) \
|
||||
LUA_METHOD_MAP( T, effectperiod ) \
|
||||
LUA_METHOD_MAP( T, effectoffset ) \
|
||||
LUA_METHOD_MAP( T, effectdelay ) \
|
||||
LUA_METHOD_MAP( T, effectclock ) \
|
||||
LUA_METHOD_MAP( T, effectmagnitude ) \
|
||||
LUA_METHOD_MAP( T, scaletocover ) \
|
||||
LUA_METHOD_MAP( T, scaletofit ) \
|
||||
LUA_METHOD_MAP( T, animate ) \
|
||||
LUA_METHOD_MAP( T, play ) \
|
||||
LUA_METHOD_MAP( T, pause ) \
|
||||
LUA_METHOD_MAP( T, setstate ) \
|
||||
LUA_METHOD_MAP( T, texturewrapping ) \
|
||||
LUA_METHOD_MAP( T, additiveblend ) \
|
||||
LUA_METHOD_MAP( T, blend ) \
|
||||
LUA_METHOD_MAP( T, zbuffer ) \
|
||||
LUA_METHOD_MAP( T, ztest ) \
|
||||
LUA_METHOD_MAP( T, ztestmode ) \
|
||||
LUA_METHOD_MAP( T, zwrite ) \
|
||||
LUA_METHOD_MAP( T, clearzbuffer ) \
|
||||
LUA_METHOD_MAP( T, backfacecull ) \
|
||||
LUA_METHOD_MAP( T, cullmode ) \
|
||||
LUA_METHOD_MAP( T, hidden ) \
|
||||
LUA_METHOD_MAP( T, hibernate ) \
|
||||
LUA_METHOD_MAP( T, draworder ) \
|
||||
LUA_METHOD_MAP( T, playcommand ) \
|
||||
LUA_METHOD_MAP( T, queuecommand ) \
|
||||
|
||||
|
||||
class Actor
|
||||
{
|
||||
@@ -60,7 +233,7 @@ public:
|
||||
RectF fade; // 0 = no fade
|
||||
RageColor diffuse[4];
|
||||
RageColor glow;
|
||||
Command command; // command to execute when this
|
||||
CString sCommandName; // command to execute when this TweenState goes into effect
|
||||
|
||||
void Init();
|
||||
static void MakeWeightedAverage( TweenState& average_out, const TweenState& ts1, const TweenState& ts2, float fPercentBetween );
|
||||
@@ -194,7 +367,7 @@ public:
|
||||
void BeginTweening( float time, TweenType tt = TWEEN_LINEAR );
|
||||
void StopTweening();
|
||||
void Sleep( float time );
|
||||
void QueueCommand( const Command& command );
|
||||
void QueueCommand( const CString& sCommandName );
|
||||
virtual void FinishTweening();
|
||||
virtual void HurryTweening( float factor );
|
||||
// Let ActorFrame and BGAnimation override
|
||||
@@ -223,11 +396,11 @@ public:
|
||||
//
|
||||
enum HorizAlign { align_left, align_center, align_right };
|
||||
virtual void SetHorizAlign( HorizAlign ha ) { m_HorizAlign = ha; }
|
||||
virtual void SetHorizAlign( const CString &s );
|
||||
virtual void SetHorizAlignString( const CString &s ); // convenience
|
||||
|
||||
enum VertAlign { align_top, align_middle, align_bottom };
|
||||
virtual void SetVertAlign( VertAlign va ) { m_VertAlign = va; }
|
||||
virtual void SetVertAlign( const CString &s );
|
||||
virtual void SetVertAlignString( const CString &s ); // convenience
|
||||
|
||||
|
||||
//
|
||||
@@ -241,7 +414,7 @@ public:
|
||||
void SetEffectDelay( float fTime ) { m_fEffectDelay = fTime; }
|
||||
void SetEffectOffset( float fPercent ) { m_fEffectOffset = fPercent; }
|
||||
void SetEffectClock( EffectClock c ) { m_EffectClock = c; }
|
||||
void SetEffectClock( const CString &s );
|
||||
void SetEffectClockString( const CString &s ); // convenience
|
||||
|
||||
void SetEffectMagnitude( RageVector3 vec ) { m_vEffectMagnitude = vec; }
|
||||
|
||||
@@ -300,23 +473,26 @@ public:
|
||||
// render states
|
||||
//
|
||||
void SetBlendMode( BlendMode mode ) { m_BlendMode = mode; }
|
||||
void SetBlendMode( const CString &s );
|
||||
void SetBlendModeString( const CString &s ); // convenience
|
||||
void SetTextureWrapping( bool b ) { m_bTextureWrapping = b; }
|
||||
void SetClearZBuffer( bool b ) { m_bClearZBuffer = b; }
|
||||
void SetUseZBuffer( bool b ) { SetZTestMode(b?ZTEST_WRITE_ON_PASS:ZTEST_OFF); SetZWrite(b); }
|
||||
virtual void SetZTestMode( ZTestMode mode ) { m_ZTestMode = mode; }
|
||||
virtual void SetZTestMode( const CString &s );
|
||||
void SetZTestModeString( const CString &s ); // convenience
|
||||
virtual void SetZWrite( bool b ) { m_bZWrite = b; }
|
||||
virtual void SetCullMode( CullMode mode ) { m_CullMode = mode; }
|
||||
virtual void SetCullMode( const CString &s );
|
||||
void SetCullModeString( const CString &s ); // convenience
|
||||
|
||||
//
|
||||
// Commands
|
||||
//
|
||||
virtual void PushSelf( lua_State *L );
|
||||
virtual void PlayCommand( const CString &sCommandName );
|
||||
void RunCommands( const Commands &cmds );
|
||||
virtual void HandleCommand( const Command &command ); // derivable
|
||||
static float GetCommandsLengthSeconds( const Commands &cmds );
|
||||
virtual void RunCommands( const ActorCommands& cmds );
|
||||
void RunCommands( const apActorCommands& cmds ) { this->RunCommands( *cmds ); } // convenience
|
||||
|
||||
static float GetCommandsLengthSeconds( const ActorCommands& cmds );
|
||||
static float GetCommandsLengthSeconds( const apActorCommands& cmds ) { return GetCommandsLengthSeconds( *cmds ); } // convenience
|
||||
|
||||
//
|
||||
// Animation
|
||||
@@ -420,7 +596,7 @@ protected:
|
||||
//
|
||||
// commands
|
||||
//
|
||||
map<CString, Commands> m_mapNameToCommands;
|
||||
map<CString, apActorCommands> m_mapNameToCommands;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
#include "global.h"
|
||||
#include "ActorCommands.h"
|
||||
#include "Command.h"
|
||||
#include "Foreach.h"
|
||||
#include "RageUtil.h"
|
||||
#include <sstream>
|
||||
#include "LuaManager.h"
|
||||
#include "LuaBinding.h"
|
||||
|
||||
#define MAX_SIMULTANEOUS_LUA_FUNCTIONS 10000
|
||||
|
||||
static CString GetNextFunctionName()
|
||||
{
|
||||
static int id = 0;
|
||||
id = (id+1) % MAX_SIMULTANEOUS_LUA_FUNCTIONS;
|
||||
return ssprintf("F%d",id);
|
||||
}
|
||||
|
||||
ActorCommands::ActorCommands( const Commands& cmds )
|
||||
{
|
||||
Register( cmds );
|
||||
}
|
||||
|
||||
ActorCommands::~ActorCommands()
|
||||
{
|
||||
if( m_sLuaFunctionName.size() )
|
||||
Unregister();
|
||||
}
|
||||
|
||||
CString ActorCommands::GetFunctionName() const
|
||||
{
|
||||
return m_sLuaFunctionName;
|
||||
}
|
||||
|
||||
void ActorCommands::Register( const Commands& cmds )
|
||||
{
|
||||
// TODO: calculate a better function name, or figure out how
|
||||
// to keep a pointer directly to the Lua function so no global
|
||||
// table lookup is necessary.
|
||||
m_sLuaFunctionName = GetNextFunctionName();
|
||||
|
||||
//
|
||||
// Convert cmds to a Lua function
|
||||
//
|
||||
ostringstream s;
|
||||
|
||||
s << m_sLuaFunctionName << " = function(self)\n";
|
||||
|
||||
FOREACH_CONST( Command, cmds.v, c )
|
||||
{
|
||||
const Command& cmd = (*c);
|
||||
CString sName = cmd.GetName();
|
||||
s << "\tself:" << sName << "(";
|
||||
|
||||
bool bFirstParamIsString =
|
||||
sName == "horizalign" ||
|
||||
sName == "vertalign" ||
|
||||
sName == "effectclock" ||
|
||||
sName == "blend" ||
|
||||
sName == "ztestmode" ||
|
||||
sName == "cullmode" ||
|
||||
sName == "playcommand" ||
|
||||
sName == "queuecommand";
|
||||
|
||||
for( unsigned i=1; i<cmd.m_vsArgs.size(); i++ )
|
||||
{
|
||||
CString sArg = cmd.m_vsArgs[i];
|
||||
|
||||
// "+200" -> "200"
|
||||
if( sArg[0] == '+' )
|
||||
sArg.erase( sArg.begin() );
|
||||
|
||||
if( i==1 && bFirstParamIsString ) // string literal
|
||||
{
|
||||
s << "'" << sArg << "'";
|
||||
}
|
||||
else if( sArg[0] == '#' ) // HTML color
|
||||
{
|
||||
RageColor c; // in case FromString fails
|
||||
c.FromString( sArg );
|
||||
// c is still valid if FromString fails
|
||||
s << c.r << "," << c.g << "," << c.b << "," << c.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
s << sArg;
|
||||
}
|
||||
|
||||
if( i != cmd.m_vsArgs.size()-1 )
|
||||
s << ",";
|
||||
}
|
||||
s << ")\n";
|
||||
}
|
||||
|
||||
s << "end\n";
|
||||
|
||||
|
||||
CString s2 = s.str();
|
||||
LUA->RunScript( s2 );
|
||||
}
|
||||
|
||||
void ActorCommands::Unregister()
|
||||
{
|
||||
if( LUA == NULL )
|
||||
return; // nothing to do
|
||||
|
||||
ASSERT( m_sLuaFunctionName.size() );
|
||||
|
||||
lua_pushstring( LUA->L, m_sLuaFunctionName );
|
||||
lua_pushnil( LUA->L );
|
||||
lua_settable( LUA->L, LUA_GLOBALSINDEX );
|
||||
|
||||
m_sLuaFunctionName = "";
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 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.
|
||||
*/
|
||||
@@ -0,0 +1,52 @@
|
||||
/* Commands - Actor command parsing and reading helpers. */
|
||||
|
||||
#ifndef ActorCommands_H
|
||||
#define ActorCommands_H
|
||||
|
||||
#include <memory> // auto_ptr
|
||||
class Commands;
|
||||
|
||||
class ActorCommands
|
||||
{
|
||||
public:
|
||||
ActorCommands( const Commands& cmds );
|
||||
~ActorCommands();
|
||||
|
||||
|
||||
CString GetFunctionName() const;
|
||||
|
||||
private:
|
||||
void Register( const Commands& cmds );
|
||||
void Unregister();
|
||||
|
||||
CString m_sLuaFunctionName;
|
||||
};
|
||||
|
||||
typedef auto_ptr<ActorCommands> apActorCommands;
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 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.
|
||||
*/
|
||||
@@ -4,6 +4,12 @@
|
||||
#include "RageUtil.h"
|
||||
#include "XmlFile.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "LuaBinding.h"
|
||||
#include "ActorCommands.h"
|
||||
|
||||
// lua start
|
||||
LUA_REGISTER_CLASS( ActorFrame )
|
||||
// lua end
|
||||
|
||||
ActorFrame::ActorFrame()
|
||||
{
|
||||
@@ -95,16 +101,10 @@ void ActorFrame::DrawPrimitives()
|
||||
m_SubActors[i]->Draw();
|
||||
}
|
||||
|
||||
void ActorFrame::RunCommandOnChildren( const Commands &cmd )
|
||||
void ActorFrame::RunCommandsOnChildren( const ActorCommands& cmds )
|
||||
{
|
||||
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
||||
m_SubActors[i]->RunCommands( cmd );
|
||||
}
|
||||
|
||||
void ActorFrame::RunCommandOnChildren( const Command &cmd )
|
||||
{
|
||||
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
||||
m_SubActors[i]->HandleCommand( cmd );
|
||||
m_SubActors[i]->RunCommands( cmds );
|
||||
}
|
||||
|
||||
void ActorFrame::Update( float fDeltaTime )
|
||||
@@ -144,7 +144,6 @@ void ActorFrame::SetDiffuseAlpha( float f )
|
||||
m_SubActors[i]->SetDiffuseAlpha( f );
|
||||
}
|
||||
|
||||
|
||||
void ActorFrame::FinishTweening()
|
||||
{
|
||||
Actor::FinishTweening();
|
||||
@@ -186,6 +185,20 @@ void ActorFrame::DeleteAllChildren()
|
||||
m_SubActors.clear();
|
||||
}
|
||||
|
||||
void ActorFrame::RunCommands( const ActorCommands& cmds )
|
||||
{
|
||||
if( m_bPropagateCommands )
|
||||
RunCommandsOnChildren( cmds );
|
||||
else
|
||||
Actor::RunCommands( cmds );
|
||||
}
|
||||
|
||||
void ActorFrame::SetPropagateCommands( bool b )
|
||||
{
|
||||
m_bPropagateCommands = b;
|
||||
}
|
||||
|
||||
/*
|
||||
void ActorFrame::HandleCommand( const Command &command )
|
||||
{
|
||||
BeginHandleArgs;
|
||||
@@ -206,12 +219,13 @@ void ActorFrame::HandleCommand( const Command &command )
|
||||
EndHandleArgs;
|
||||
} while(0);
|
||||
|
||||
/* By default, don't propograte most commands to children; it makes no sense
|
||||
* to run "x,50" recursively. If m_bPropagateCommands is set, propagate all
|
||||
* commands. */
|
||||
// By default, don't propograte most commands to children; it makes no sense
|
||||
// to run "x,50" recursively. If m_bPropagateCommands is set, propagate all
|
||||
// commands.
|
||||
if( m_bPropagateCommands && sName!="propagate" )
|
||||
RunCommandOnChildren( command );
|
||||
}
|
||||
*/
|
||||
|
||||
void ActorFrame::GainFocus( float fRate, bool bRewindMovie, bool bLoop )
|
||||
{
|
||||
@@ -240,6 +254,11 @@ void ActorFrame::PlayCommand( const CString &sCommandName )
|
||||
}
|
||||
}
|
||||
|
||||
void ActorFrame::PushSelf( lua_State *L )
|
||||
{
|
||||
Luna<ActorFrame,LuaActorFrame>::Push( L, this );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
|
||||
@@ -5,6 +5,14 @@
|
||||
|
||||
#include "Actor.h"
|
||||
|
||||
#define LUA_ActorFrame_METHODS( T ) \
|
||||
LUA_Actor_METHODS( T ) \
|
||||
static int propagate( T* p, lua_State *L ) { p->SetPropagateCommands( BArg(1) ); return 0; } \
|
||||
|
||||
#define LUA_ActorFrame_METHODS_MAP( T ) \
|
||||
LUA_Actor_METHODS_MAP( T ) \
|
||||
LUA_METHOD_MAP( T, propagate ) \
|
||||
|
||||
class ActorFrame : public Actor
|
||||
{
|
||||
public:
|
||||
@@ -15,16 +23,19 @@ public:
|
||||
|
||||
virtual void AddChild( Actor* pActor );
|
||||
virtual void RemoveChild( Actor* pActor );
|
||||
virtual void MoveToTail( Actor* pActor );
|
||||
virtual void MoveToHead( Actor* pActor );
|
||||
virtual void SortByDrawOrder();
|
||||
void MoveToTail( Actor* pActor );
|
||||
void MoveToHead( Actor* pActor );
|
||||
void SortByDrawOrder();
|
||||
|
||||
void DeleteChildrenWhenDone( bool bDelete=true ) { m_bDeleteChildren = bDelete; }
|
||||
void DeleteAllChildren();
|
||||
|
||||
virtual void RunCommandOnChildren( const Commands &cmds ); /* but not on self */
|
||||
virtual void RunCommandOnChildren( const Command &cmd ); /* but not on self */
|
||||
virtual void HandleCommand( const Command &command ); // derivable
|
||||
//
|
||||
// Commands
|
||||
//
|
||||
void PushSelf( lua_State *L );
|
||||
void RunCommandsOnChildren( const ActorCommands& cmds ); /* but not on self */
|
||||
void RunCommandsOnChildren( const apActorCommands& cmds ) { RunCommandsOnChildren( *cmds ); } // convenience
|
||||
|
||||
virtual void Update( float fDeltaTime );
|
||||
virtual void DrawPrimitives();
|
||||
@@ -37,12 +48,16 @@ public:
|
||||
virtual void FinishTweening();
|
||||
virtual void HurryTweening( float factor );
|
||||
|
||||
void SetPropagateCommands( bool b );
|
||||
|
||||
/* Amount of time until all tweens (and all children's tweens) have stopped: */
|
||||
virtual float GetTweenTimeLeft() const;
|
||||
|
||||
virtual void GainFocus( float fRate, bool bRewindMovie, bool bLoop );
|
||||
virtual void LoseFocus();
|
||||
virtual void PlayCommand( const CString &sCommandName );
|
||||
virtual void RunCommands( const ActorCommands& cmds );
|
||||
void RunCommands( const apActorCommands& cmds ) { ActorFrame::RunCommands( *cmds ); } // convenience
|
||||
|
||||
protected:
|
||||
vector<Actor*> m_SubActors;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <set>
|
||||
#include "PlayerState.h"
|
||||
|
||||
|
||||
CString GetAttackPath( const CString &sAttack )
|
||||
{
|
||||
CString ret = ssprintf( "AttackDisplay attack %s", sAttack.c_str() );
|
||||
@@ -110,7 +111,7 @@ void AttackDisplay::SetAttack( const CString &sText )
|
||||
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
|
||||
|
||||
const CString sName = ssprintf( "%sP%i", sText.c_str(), pn+1 );
|
||||
m_sprAttack.RunCommands( THEME->GetMetricA("AttackDisplay", sName + "OnCommand" ) );
|
||||
m_sprAttack.RunCommands( THEME->GetMetricA("AttackDisplay", sName + "OnCommand") );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
#include "BGAnimationLayer.h"
|
||||
#include "RageUtil.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "LuaManager.h"
|
||||
#include "Foreach.h"
|
||||
#include "Command.h"
|
||||
#include "LuaManager.h"
|
||||
|
||||
|
||||
BGAnimation::BGAnimation()
|
||||
@@ -184,14 +185,12 @@ void BGAnimation::LoadFromNode( const CString& sDir, const XNode* pNode )
|
||||
/* There's an InitCommand. Run it now. This can be used to eg. change Z to
|
||||
* modify draw order between BGAs in a Foreground. Most things should be done
|
||||
* in metrics.ini commands, not here. */
|
||||
this->RunCommands( ParseCommands(sInitCommand) );
|
||||
this->RunCommands( ActorCommands(ParseCommands(sInitCommand)) );
|
||||
}
|
||||
|
||||
ActorScroller::LoadFromNode( sDir, pNode );
|
||||
|
||||
Command cmd;
|
||||
cmd.Load( "PlayCommand,Init" );
|
||||
this->RunCommandOnChildren( cmd );
|
||||
this->RunCommandsOnChildren( ActorCommands(ParseCommands("PlayCommand,Init")) );
|
||||
|
||||
|
||||
/* Backwards-compatibility: if a "LengthSeconds" value is present, create a dummy
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "ScreenDimensions.h"
|
||||
#include "ThemeMetric.h"
|
||||
#include "PlayerState.h"
|
||||
#include "Command.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
@@ -29,7 +30,7 @@ ThemeMetric<float> BOTTOM_EDGE ("Background","BottomEdge");
|
||||
#define RECT_BACKGROUND RectF (LEFT_EDGE,TOP_EDGE,RIGHT_EDGE,BOTTOM_EDGE)
|
||||
ThemeMetric<bool> BLINK_DANGER_ALL ("Background","BlinkDangerAll");
|
||||
ThemeMetric<bool> DANGER_ALL_IS_OPAQUE ("Background","DangerAllIsOpaque");
|
||||
ThemeMetric<Commands> BRIGHTNESS_FADE_COMMAND ("Background","BrightnessFadeCommand");
|
||||
ThemeMetric<apActorCommands> BRIGHTNESS_FADE_COMMAND ("Background","BrightnessFadeCommand");
|
||||
|
||||
static float g_fBackgroundCenterWidth = 40;
|
||||
const CString STATIC_BACKGROUND = "static background";
|
||||
@@ -468,9 +469,8 @@ void Background::LoadFromSong( const Song* pSong )
|
||||
* may look something like "BGAnimation, BGAnimationLayer, Sprite" or it
|
||||
* may be deeper, like "BGAnimation, BGAnimationLayer, BGAnimation,
|
||||
* BGAnimationLayer, Sprite". */
|
||||
pBGA->RunCommands( ParseCommands("propagate,1") );
|
||||
pBGA->RunCommands( ParseCommands("effectclock,music") );
|
||||
pBGA->RunCommands( ParseCommands("propagate,0") );
|
||||
ActorCommands acmds( ParseCommands("effectclock,music") );
|
||||
pBGA->RunCommands( acmds );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ void BrightnessOverlay::Set( float fBrightness )
|
||||
|
||||
void BrightnessOverlay::FadeToActualBrightness()
|
||||
{
|
||||
this->RunCommandOnChildren( BRIGHTNESS_FADE_COMMAND );
|
||||
this->RunCommandsOnChildren( BRIGHTNESS_FADE_COMMAND );
|
||||
SetActualBrightness();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "Font.h"
|
||||
#include "ActorUtil.h" // for BeginHandleArgs
|
||||
#include "LuaBinding.h"
|
||||
|
||||
// lua start
|
||||
LUA_REGISTER_CLASS( BitmapText )
|
||||
// lua end
|
||||
|
||||
/*
|
||||
* XXX: Changing a whole array of diffuse colors every frame (several times) is a waste,
|
||||
@@ -517,6 +522,7 @@ void BitmapText::SetVertAlign( VertAlign va )
|
||||
BuildChars();
|
||||
}
|
||||
|
||||
/*
|
||||
void BitmapText::HandleCommand( const Command &command )
|
||||
{
|
||||
BeginHandleArgs;
|
||||
@@ -535,6 +541,7 @@ void BitmapText::HandleCommand( const Command &command )
|
||||
|
||||
EndHandleArgs;
|
||||
}
|
||||
*/
|
||||
|
||||
void BitmapText::SetWrapWidthPixels( int iWrapWidthPixels )
|
||||
{
|
||||
@@ -544,6 +551,11 @@ void BitmapText::SetWrapWidthPixels( int iWrapWidthPixels )
|
||||
SetText( m_sText, "", iWrapWidthPixels );
|
||||
}
|
||||
|
||||
void BitmapText::PushSelf( lua_State *L )
|
||||
{
|
||||
Luna<BitmapText,LuaBitmapText>::Push( L, this );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
|
||||
@@ -3,7 +3,19 @@
|
||||
#ifndef BITMAPTEXT_H
|
||||
#define BITMAPTEXT_H
|
||||
|
||||
#include "Sprite.h"
|
||||
#include "Actor.h"
|
||||
class RageTexture;
|
||||
|
||||
#define LUA_BitmapText_METHODS( T ) \
|
||||
LUA_Actor_METHODS( T ) \
|
||||
static int wrapwidthpixels( T* p, lua_State *L ) { p->SetWrapWidthPixels( IArg(1) ); return 0; } \
|
||||
static int maxwidth( T* p, lua_State *L ) { p->SetMaxWidth( FArg(1) ); return 0; } \
|
||||
|
||||
#define LUA_BitmapText_METHODS_MAP( T ) \
|
||||
LUA_Actor_METHODS_MAP( T ) \
|
||||
LUA_METHOD_MAP( T, wrapwidthpixels ) \
|
||||
LUA_METHOD_MAP( T, maxwidth ) \
|
||||
|
||||
|
||||
class Font;
|
||||
|
||||
@@ -37,7 +49,10 @@ public:
|
||||
/* Return true if the string 's' will use an alternate string, if available. */
|
||||
bool StringWillUseAlternate(const CString& sText, const CString& sAlternateText) const;
|
||||
|
||||
virtual void HandleCommand( const Command &command );
|
||||
//
|
||||
// Commands
|
||||
//
|
||||
virtual void PushSelf( lua_State *L );
|
||||
|
||||
public:
|
||||
Font* m_pFont;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "GameState.h"
|
||||
#include "song.h"
|
||||
#include "ThemeMetric.h"
|
||||
#include "Command.h"
|
||||
|
||||
|
||||
ThemeMetric<float> LABEL_X ("Combo","LabelX");
|
||||
@@ -21,10 +22,10 @@ ThemeMetric<float> NUMBER_MAX_ZOOM ("Combo","NumberMaxZoom");
|
||||
ThemeMetric<float> NUMBER_MAX_ZOOM_AT ("Combo","NumberMaxZoomAt");
|
||||
ThemeMetric<float> PULSE_ZOOM ("Combo","PulseZoom");
|
||||
ThemeMetric<float> C_TWEEN_SECONDS ("Combo","TweenSeconds");
|
||||
ThemeMetric<Commands> FULL_COMBO_GREATS_COMMAND ("Combo","FullComboGreatsCommand");
|
||||
ThemeMetric<Commands> FULL_COMBO_PERFECTS_COMMAND ("Combo","FullComboPerfectsCommand");
|
||||
ThemeMetric<Commands> FULL_COMBO_MARVELOUSES_COMMAND ("Combo","FullComboMarvelousesCommand");
|
||||
ThemeMetric<Commands> FULL_COMBO_BROKEN_COMMAND ("Combo","FullComboBrokenCommand");
|
||||
ThemeMetric<apActorCommands> FULL_COMBO_GREATS_COMMAND ("Combo","FullComboGreatsCommand");
|
||||
ThemeMetric<apActorCommands> FULL_COMBO_PERFECTS_COMMAND ("Combo","FullComboPerfectsCommand");
|
||||
ThemeMetric<apActorCommands> FULL_COMBO_MARVELOUSES_COMMAND ("Combo","FullComboMarvelousesCommand");
|
||||
ThemeMetric<apActorCommands> FULL_COMBO_BROKEN_COMMAND ("Combo","FullComboBrokenCommand");
|
||||
ThemeMetric<bool> SHOW_MISS_COMBO ("Combo","ShowMissCombo");
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "StageStats.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "BitmapText.h"
|
||||
#include "Sprite.h"
|
||||
|
||||
const int MinComboSizeToShow = 5;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
DancingCharacters();
|
||||
virtual ~DancingCharacters();
|
||||
|
||||
virtual void LoadNextSong();
|
||||
void LoadNextSong();
|
||||
|
||||
virtual void Update( float fDelta );
|
||||
virtual void DrawPrimitives();
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
#include "DifficultyDisplay.h"
|
||||
#include "song.h"
|
||||
#include "ThemeMetric.h"
|
||||
#include "Command.h"
|
||||
|
||||
ThemeMetric<Commands> ICONONCOMMAND ("DifficultyDisplay","IconOnCommand");
|
||||
ThemeMetric<Commands> ICONOFFCOMMAND ("DifficultyDisplay","IconOffCommand");
|
||||
ThemeMetric<apActorCommands> ICONONCOMMAND ("DifficultyDisplay","IconOnCommand");
|
||||
ThemeMetric<apActorCommands> ICONOFFCOMMAND ("DifficultyDisplay","IconOffCommand");
|
||||
|
||||
DifficultyDisplay::DifficultyDisplay()
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "StepsUtil.h"
|
||||
#include "CommonMetrics.h"
|
||||
#include "Command.h"
|
||||
|
||||
#define ITEMS_SPACING_Y THEME->GetMetricF(m_sName,"ItemsSpacingY")
|
||||
#define DESCRIPTION_MAX_WIDTH THEME->GetMetricF(m_sName,"DescriptionMaxWidth")
|
||||
@@ -214,10 +215,11 @@ void DifficultyList::PositionItems()
|
||||
if( m_Lines[m].m_Number.GetDestY() != row.m_fY ||
|
||||
m_Lines[m].m_Number.DestTweenState().diffuse[0][3] != DiffuseAlpha )
|
||||
{
|
||||
m_Lines[m].m_Description.RunCommands( MOVE_COMMAND );
|
||||
m_Lines[m].m_Meter.RunCommands( MOVE_COMMAND );
|
||||
m_Lines[m].m_Meter.RunCommandOnChildren( MOVE_COMMAND );
|
||||
m_Lines[m].m_Number.RunCommands( MOVE_COMMAND );
|
||||
apActorCommands c(MOVE_COMMAND);
|
||||
m_Lines[m].m_Description.RunCommands( c );
|
||||
m_Lines[m].m_Meter.RunCommands( c );
|
||||
m_Lines[m].m_Meter.RunCommandsOnChildren( c );
|
||||
m_Lines[m].m_Number.RunCommands( c );
|
||||
}
|
||||
|
||||
m_Lines[m].m_Description.SetY( row.m_fY );
|
||||
@@ -231,10 +233,10 @@ void DifficultyList::PositionItems()
|
||||
if( m_bShown && m < (int)m_Rows.size() )
|
||||
bHidden = m_Rows[m].m_bHidden;
|
||||
|
||||
const Commands cmds = ParseCommands( ssprintf("diffusealpha,%f",bHidden?0.0f:1.0f) );
|
||||
m_Lines[m].m_Description.RunCommands( cmds );
|
||||
m_Lines[m].m_Meter.RunCommandOnChildren( cmds );
|
||||
m_Lines[m].m_Number.RunCommands( cmds );
|
||||
ActorCommands c = ActorCommands( ParseCommands( ssprintf("diffusealpha,%f",bHidden?0.0f:1.0f) ) );
|
||||
m_Lines[m].m_Description.RunCommands( c );
|
||||
m_Lines[m].m_Meter.RunCommandsOnChildren( c );
|
||||
m_Lines[m].m_Number.RunCommands( c );
|
||||
}
|
||||
|
||||
|
||||
@@ -352,10 +354,10 @@ void DifficultyList::HideRows()
|
||||
{
|
||||
for( unsigned m = 0; m < m_Rows.size(); ++m )
|
||||
{
|
||||
static const Commands cmds = ParseCommands( "finishtweening;diffusealpha,0" );
|
||||
m_Lines[m].m_Description.RunCommands( cmds );
|
||||
m_Lines[m].m_Meter.RunCommandOnChildren( cmds );
|
||||
m_Lines[m].m_Number.RunCommands( cmds );
|
||||
ActorCommands c = ActorCommands( ParseCommands( "finishtweening;diffusealpha,0" ) );
|
||||
m_Lines[m].m_Description.RunCommands( c );
|
||||
m_Lines[m].m_Meter.RunCommandsOnChildren( c );
|
||||
m_Lines[m].m_Number.RunCommands( c );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,10 +367,10 @@ void DifficultyList::TweenOnScreen()
|
||||
m_bShown = true;
|
||||
for( unsigned m = 0; m < m_Rows.size(); ++m )
|
||||
{
|
||||
static const Commands cmds = ParseCommands( "finishtweening" );
|
||||
m_Lines[m].m_Description.RunCommands( cmds );
|
||||
m_Lines[m].m_Meter.RunCommandOnChildren( cmds );
|
||||
m_Lines[m].m_Number.RunCommands( cmds );
|
||||
ActorCommands c = ActorCommands( ParseCommands( "finishtweening" ) );
|
||||
m_Lines[m].m_Description.RunCommands( c );
|
||||
m_Lines[m].m_Meter.RunCommandsOnChildren( c );
|
||||
m_Lines[m].m_Number.RunCommands( c );
|
||||
}
|
||||
|
||||
// PositionItems();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "Course.h"
|
||||
#include "ScreenMessage.h"
|
||||
#include "song.h"
|
||||
#include "Sprite.h"
|
||||
|
||||
|
||||
class EditCoursesSongMenu: public ActorFrame
|
||||
|
||||
@@ -31,7 +31,8 @@ void GhostArrow::Load( CString sNoteSkin, CString sButton, CString sElement )
|
||||
{
|
||||
CString sJudge = TapNoteScoreToString( i );
|
||||
CString sCommand = Capitalize(sJudge)+"Command";
|
||||
m_acScoreCommand[i] = NOTESKIN->GetMetricA( sNoteSkin, m_sName, sCommand );
|
||||
apActorCommands p( new ActorCommands(NOTESKIN->GetMetricA(sNoteSkin,m_sName,sCommand)) );
|
||||
m_acScoreCommand[i] = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "PlayerNumber.h"
|
||||
#include "ActorFrame.h"
|
||||
#include "ActorCommands.h"
|
||||
|
||||
class GhostArrow : public ActorFrame
|
||||
{
|
||||
@@ -21,7 +22,7 @@ public:
|
||||
protected:
|
||||
PlayerNumber m_PlayerNumber;
|
||||
Sprite m_spr[NUM_TAP_NOTE_SCORES];
|
||||
Commands m_acScoreCommand[NUM_TAP_NOTE_SCORES];
|
||||
apActorCommands m_acScoreCommand[NUM_TAP_NOTE_SCORES];
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
#define LABEL_OFFSET_X( i ) THEME->GetMetricF("GrooveRadar",ssprintf("Label%dOffsetX",i+1))
|
||||
#define LABEL_OFFSET_Y( i ) THEME->GetMetricF("GrooveRadar",ssprintf("Label%dOffsetY",i+1))
|
||||
static const ThemeMetric<Commands> LABEL_ON_COMMAND ("GrooveRadar","LabelOnCommand");
|
||||
static const ThemeMetric<apActorCommands> LABEL_ON_COMMAND ("GrooveRadar","LabelOnCommand");
|
||||
static const ThemeMetric<float> LABEL_ON_DELAY ("GrooveRadar","LabelOnDelay");
|
||||
static const ThemeMetric<Commands> LABEL_ON_COMMAND_POST_DELAY ("GrooveRadar","LabelOnCommandPostDelay");
|
||||
static const ThemeMetric<apActorCommands> LABEL_ON_COMMAND_POST_DELAY ("GrooveRadar","LabelOnCommandPostDelay");
|
||||
|
||||
float RADAR_VALUE_ROTATION( int iValueIndex ) { return PI/2 + PI*2 / 5.0f * iValueIndex; }
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ static const ThemeMetric<float> START_X ("GroupList","StartX");
|
||||
static const ThemeMetric<float> START_Y ("GroupList","StartY");
|
||||
static const ThemeMetric<float> SPACING_X ("GroupList","SpacingX");
|
||||
static const ThemeMetric<float> SPACING_Y ("GroupList","SpacingY");
|
||||
static const ThemeMetric<Commands> SCROLL_TWEEN_COMMAND ("GroupList","ScrollTweenCommand");
|
||||
static const ThemeMetric<Commands> GAIN_FOCUS_ITEM_COMMAND ("GroupList","GainFocusItemCommand");
|
||||
static const ThemeMetric<Commands> LOSE_FOCUS_ITEM_COMMAND ("GroupList","LoseFocusItemCommand");
|
||||
static const ThemeMetric<Commands> GAIN_FOCUS_GROUP_COMMAND ("GroupList","GainFocusGroupCommand");
|
||||
static const ThemeMetric<Commands> LOSE_FOCUS_GROUP_COMMAND ("GroupList","LoseFocusGroupCommand");
|
||||
static const ThemeMetric<Commands> HIDE_ITEM_COMMAND ("GroupList","HideItemCommand");
|
||||
static const ThemeMetric<Commands> SHOW_ITEM_COMMAND ("GroupList","ShowItemCommand");
|
||||
static const ThemeMetric<apActorCommands> SCROLL_TWEEN_COMMAND ("GroupList","ScrollTweenCommand");
|
||||
static const ThemeMetric<apActorCommands> GAIN_FOCUS_ITEM_COMMAND ("GroupList","GainFocusItemCommand");
|
||||
static const ThemeMetric<apActorCommands> LOSE_FOCUS_ITEM_COMMAND ("GroupList","LoseFocusItemCommand");
|
||||
static const ThemeMetric<apActorCommands> GAIN_FOCUS_GROUP_COMMAND ("GroupList","GainFocusGroupCommand");
|
||||
static const ThemeMetric<apActorCommands> LOSE_FOCUS_GROUP_COMMAND ("GroupList","LoseFocusGroupCommand");
|
||||
static const ThemeMetric<apActorCommands> HIDE_ITEM_COMMAND ("GroupList","HideItemCommand");
|
||||
static const ThemeMetric<apActorCommands> SHOW_ITEM_COMMAND ("GroupList","ShowItemCommand");
|
||||
|
||||
const int MAX_GROUPS_ONSCREEN = 7;
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "ThemeMetric.h"
|
||||
|
||||
ThemeMetric<Commands> OK_COMMAND ("HoldJudgment","OKCommand");
|
||||
ThemeMetric<Commands> NG_COMMAND ("HoldJudgment","NGCommand");
|
||||
ThemeMetric<Commands> OK_ODD_COMMAND ("HoldJudgment","OKOddCommand");
|
||||
ThemeMetric<Commands> NG_ODD_COMMAND ("HoldJudgment","NGOddCommand");
|
||||
ThemeMetric<Commands> OK_EVEN_COMMAND ("HoldJudgment","OKEvenCommand");
|
||||
ThemeMetric<Commands> NG_EVEN_COMMAND ("HoldJudgment","NGEvenCommand");
|
||||
ThemeMetric<apActorCommands> OK_COMMAND ("HoldJudgment","OKCommand");
|
||||
ThemeMetric<apActorCommands> NG_COMMAND ("HoldJudgment","NGCommand");
|
||||
ThemeMetric<apActorCommands> OK_ODD_COMMAND ("HoldJudgment","OKOddCommand");
|
||||
ThemeMetric<apActorCommands> NG_ODD_COMMAND ("HoldJudgment","NGOddCommand");
|
||||
ThemeMetric<apActorCommands> OK_EVEN_COMMAND ("HoldJudgment","OKEvenCommand");
|
||||
ThemeMetric<apActorCommands> NG_EVEN_COMMAND ("HoldJudgment","NGEvenCommand");
|
||||
|
||||
|
||||
HoldJudgment::HoldJudgment()
|
||||
|
||||
+18
-18
@@ -7,26 +7,26 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "ThemeMetric.h"
|
||||
|
||||
static ThemeMetric<Commands> MARVELOUS_COMMAND ("Judgment","MarvelousCommand");
|
||||
static ThemeMetric<Commands> PERFECT_COMMAND ("Judgment","PerfectCommand");
|
||||
static ThemeMetric<Commands> GREAT_COMMAND ("Judgment","GreatCommand");
|
||||
static ThemeMetric<Commands> GOOD_COMMAND ("Judgment","GoodCommand");
|
||||
static ThemeMetric<Commands> BOO_COMMAND ("Judgment","BooCommand");
|
||||
static ThemeMetric<Commands> MISS_COMMAND ("Judgment","MissCommand");
|
||||
static ThemeMetric<apActorCommands> MARVELOUS_COMMAND ("Judgment","MarvelousCommand");
|
||||
static ThemeMetric<apActorCommands> PERFECT_COMMAND ("Judgment","PerfectCommand");
|
||||
static ThemeMetric<apActorCommands> GREAT_COMMAND ("Judgment","GreatCommand");
|
||||
static ThemeMetric<apActorCommands> GOOD_COMMAND ("Judgment","GoodCommand");
|
||||
static ThemeMetric<apActorCommands> BOO_COMMAND ("Judgment","BooCommand");
|
||||
static ThemeMetric<apActorCommands> MISS_COMMAND ("Judgment","MissCommand");
|
||||
|
||||
static ThemeMetric<Commands> MARVELOUS_ODD_COMMAND ("Judgment","MarvelousOddCommand");
|
||||
static ThemeMetric<Commands> PERFECT_ODD_COMMAND ("Judgment","PerfectOddCommand");
|
||||
static ThemeMetric<Commands> GREAT_ODD_COMMAND ("Judgment","GreatOddCommand");
|
||||
static ThemeMetric<Commands> GOOD_ODD_COMMAND ("Judgment","GoodOddCommand");
|
||||
static ThemeMetric<Commands> BOO_ODD_COMMAND ("Judgment","BooOddCommand");
|
||||
static ThemeMetric<Commands> MISS_ODD_COMMAND ("Judgment","MissOddCommand");
|
||||
static ThemeMetric<apActorCommands> MARVELOUS_ODD_COMMAND ("Judgment","MarvelousOddCommand");
|
||||
static ThemeMetric<apActorCommands> PERFECT_ODD_COMMAND ("Judgment","PerfectOddCommand");
|
||||
static ThemeMetric<apActorCommands> GREAT_ODD_COMMAND ("Judgment","GreatOddCommand");
|
||||
static ThemeMetric<apActorCommands> GOOD_ODD_COMMAND ("Judgment","GoodOddCommand");
|
||||
static ThemeMetric<apActorCommands> BOO_ODD_COMMAND ("Judgment","BooOddCommand");
|
||||
static ThemeMetric<apActorCommands> MISS_ODD_COMMAND ("Judgment","MissOddCommand");
|
||||
|
||||
static ThemeMetric<Commands> MARVELOUS_EVEN_COMMAND ("Judgment","MarvelousEvenCommand");
|
||||
static ThemeMetric<Commands> PERFECT_EVEN_COMMAND ("Judgment","PerfectEvenCommand");
|
||||
static ThemeMetric<Commands> GREAT_EVEN_COMMAND ("Judgment","GreatEvenCommand");
|
||||
static ThemeMetric<Commands> GOOD_EVEN_COMMAND ("Judgment","GoodEvenCommand");
|
||||
static ThemeMetric<Commands> BOO_EVEN_COMMAND ("Judgment","BooEvenCommand");
|
||||
static ThemeMetric<Commands> MISS_EVEN_COMMAND ("Judgment","MissEvenCommand");
|
||||
static ThemeMetric<apActorCommands> MARVELOUS_EVEN_COMMAND ("Judgment","MarvelousEvenCommand");
|
||||
static ThemeMetric<apActorCommands> PERFECT_EVEN_COMMAND ("Judgment","PerfectEvenCommand");
|
||||
static ThemeMetric<apActorCommands> GREAT_EVEN_COMMAND ("Judgment","GreatEvenCommand");
|
||||
static ThemeMetric<apActorCommands> GOOD_EVEN_COMMAND ("Judgment","GoodEvenCommand");
|
||||
static ThemeMetric<apActorCommands> BOO_EVEN_COMMAND ("Judgment","BooEvenCommand");
|
||||
static ThemeMetric<apActorCommands> MISS_EVEN_COMMAND ("Judgment","MissEvenCommand");
|
||||
|
||||
|
||||
Judgment::Judgment()
|
||||
|
||||
+18
-35
@@ -2,12 +2,22 @@
|
||||
* Modified by Chris.
|
||||
*/
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
extern "C"
|
||||
{
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
}
|
||||
|
||||
#include "LuaManager.h"
|
||||
|
||||
|
||||
#define LUA_REGISTER_CLASS( T, base ) \
|
||||
#define SArg(n) (luaL_checkstring(L,n))
|
||||
#define IArg(n) (luaL_checkint(L,n))
|
||||
#define BArg(n) (!!IArg(n))
|
||||
#define FArg(n) (luaL_checknumber(L,n))
|
||||
|
||||
|
||||
#define LUA_REGISTER_CLASS( T ) \
|
||||
class Lua##T { \
|
||||
public: \
|
||||
Lua##T() { LUA->Register( Register ); } \
|
||||
@@ -15,11 +25,6 @@ public: \
|
||||
static Luna<T,Lua##T>::RegType methods[]; \
|
||||
static void Register( lua_State* L ) { \
|
||||
Luna<T,Lua##T>::Register(L); \
|
||||
if( stricmp(#base,"null") != 0 ) \
|
||||
LUA->RunScript( "getmetatable("#T").__index = "#base ); \
|
||||
} \
|
||||
static T* MakeNew( lua_State* L ) { \
|
||||
return new T; \
|
||||
} \
|
||||
LUA_##T##_METHODS( T ) \
|
||||
}; \
|
||||
@@ -63,20 +68,6 @@ public:
|
||||
lua_pushcfunction(L, tostring_T);
|
||||
lua_settable(L, metatable);
|
||||
|
||||
lua_pushliteral(L, "__gc");
|
||||
lua_pushcfunction(L, gc_T);
|
||||
lua_settable(L, metatable);
|
||||
|
||||
lua_newtable(L); // mt for method table
|
||||
int mt = lua_gettop(L);
|
||||
lua_pushliteral(L, "__call");
|
||||
lua_pushcfunction(L, new_T);
|
||||
lua_pushliteral(L, "new");
|
||||
lua_pushvalue(L, -2); // dup new_T function
|
||||
lua_settable(L, methods); // add new_T to method table
|
||||
lua_settable(L, mt); // mt.__call = new_T
|
||||
lua_setmetatable(L, methods);
|
||||
|
||||
// fill method table with methods from class T
|
||||
for (RegType *l = TInfo::methods; l->name; l++) {
|
||||
lua_pushstring(L, l->name);
|
||||
@@ -109,26 +100,18 @@ private:
|
||||
return (*(l->mfunc))(obj,L); // call member function
|
||||
}
|
||||
|
||||
public:
|
||||
// create a new T object and
|
||||
// push onto the Lua stack a userdata containing a pointer to T object
|
||||
static int new_T(lua_State *L) {
|
||||
lua_remove(L, 1); // use classname:new(), instead of classname.new()
|
||||
T *obj = TInfo::MakeNew(L); // call constructor for T objects
|
||||
userdataType *ud =
|
||||
static_cast<userdataType*>(lua_newuserdata(L, sizeof(userdataType)));
|
||||
ud->pT = obj; // store pointer to object in userdata
|
||||
static int Push(lua_State *L, T* p ) {
|
||||
userdataType *ud = static_cast<userdataType*>(lua_newuserdata(L, sizeof(userdataType)));
|
||||
ud->pT = p; // store pointer to object in userdata
|
||||
luaL_getmetatable(L, TInfo::className); // lookup metatable in Lua registry
|
||||
lua_setmetatable(L, -2);
|
||||
return 1; // userdata containing pointer to T object
|
||||
}
|
||||
|
||||
// garbage collection metamethod
|
||||
static int gc_T(lua_State *L) {
|
||||
userdataType *ud = static_cast<userdataType*>(lua_touserdata(L, 1));
|
||||
T *obj = ud->pT;
|
||||
delete obj; // call destructor for T objects
|
||||
return 0;
|
||||
}
|
||||
private:
|
||||
|
||||
static int tostring_T (lua_State *L) {
|
||||
char buff[32];
|
||||
|
||||
@@ -175,8 +175,11 @@ void LuaManager::ResetState()
|
||||
|
||||
if( g_vRegisterActors )
|
||||
{
|
||||
FOREACH( RegisterActorFn, *g_vRegisterActors, fn )
|
||||
(*fn)( L );
|
||||
for( unsigned i=0; i<g_vRegisterActors->size(); i++ )
|
||||
{
|
||||
RegisterActorFn fn = (*g_vRegisterActors)[i];
|
||||
fn( L );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ public:
|
||||
bool GetStack( int pos, int &out );
|
||||
void SetGlobal( const CString &sName );
|
||||
|
||||
private:
|
||||
/* Run an expression. The result is left on the Lua stack. */
|
||||
bool RunExpression( const CString &str );
|
||||
lua_State *L;
|
||||
private:
|
||||
};
|
||||
|
||||
extern LuaManager *LUA;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include "GameState.h"
|
||||
#include "ThemeMetric.h"
|
||||
|
||||
static ThemeMetric<Commands> IN_COMMAND ("LyricDisplay","InCommand");
|
||||
static ThemeMetric<Commands> OUT_COMMAND ("LyricDisplay","OutCommand");
|
||||
static ThemeMetric<apActorCommands> IN_COMMAND ("LyricDisplay","InCommand");
|
||||
static ThemeMetric<apActorCommands> OUT_COMMAND ("LyricDisplay","OutCommand");
|
||||
static ThemeMetric<RageColor> WIPE_DIM_FACTOR ("LyricDisplay","WipeDimFactor");
|
||||
|
||||
static float g_TweenInTime, g_TweenOutTime;
|
||||
@@ -112,14 +112,14 @@ void LyricDisplay::Update( float fDeltaTime )
|
||||
m_textLyrics[i].SetCropLeft(0);
|
||||
if( i==1 )
|
||||
m_textLyrics[i].SetCropRight(1);
|
||||
m_textLyrics[i].RunCommands(IN_COMMAND);
|
||||
m_textLyrics[i].RunCommands( IN_COMMAND );
|
||||
m_textLyrics[i].BeginTweening( fShowLength * 0.75f ); /* sleep */
|
||||
if( i==0 )
|
||||
m_textLyrics[i].SetCropLeft(1);
|
||||
if( i==1 )
|
||||
m_textLyrics[i].SetCropRight(0);
|
||||
m_textLyrics[i].BeginTweening( fShowLength * 0.25f ); /* sleep */
|
||||
m_textLyrics[i].RunCommands(OUT_COMMAND);
|
||||
m_textLyrics[i].RunCommands( OUT_COMMAND );
|
||||
}
|
||||
|
||||
m_iCurLyricNumber++;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
static const ThemeMetric<int> WARNING_START ("MenuTimer","WarningStart");
|
||||
static const ThemeMetric<int> WARNING_BEEP_START ("MenuTimer","WarningBeepStart");
|
||||
#define WARNING_COMMAND(i) THEME->GetMetricA ("MenuTimer", ssprintf("WarningCommand%i",i))
|
||||
static const ThemeMetric<Commands> ON_COMMAND ("MenuTimer","OnCommand");
|
||||
static const ThemeMetric<apActorCommands> ON_COMMAND ("MenuTimer","OnCommand");
|
||||
|
||||
static const int TIMER_SECONDS = 99;
|
||||
static const int MAX_STALL_SECONDS = 30;
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
#include <cerrno>
|
||||
#include "ModelManager.h"
|
||||
#include "Foreach.h"
|
||||
#include "LuaBinding.h"
|
||||
|
||||
// lua start
|
||||
LUA_REGISTER_CLASS( Model )
|
||||
// lua end
|
||||
|
||||
const float FRAMES_PER_SECOND = 30;
|
||||
const CString DEFAULT_ANIMATION_NAME = "default";
|
||||
@@ -750,6 +755,7 @@ void Model::SetSecondsIntoAnimation( float fSeconds )
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void Model::HandleCommand( const Command &command )
|
||||
{
|
||||
BeginHandleArgs;
|
||||
@@ -767,6 +773,7 @@ void Model::HandleCommand( const Command &command )
|
||||
|
||||
EndHandleArgs;
|
||||
}
|
||||
*/
|
||||
|
||||
bool Model::MaterialsNeedNormals() const
|
||||
{
|
||||
@@ -778,6 +785,11 @@ bool Model::MaterialsNeedNormals() const
|
||||
return false;
|
||||
}
|
||||
|
||||
void Model::PushSelf( lua_State *L )
|
||||
{
|
||||
Luna<Model,LuaModel>::Push( L, this );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
|
||||
+11
-1
@@ -10,6 +10,13 @@
|
||||
#include <map>
|
||||
#include "RageModelGeometry.h"
|
||||
|
||||
#define LUA_Model_METHODS( T ) \
|
||||
LUA_Actor_METHODS( T ) \
|
||||
static int playanimation( T* p, lua_State *L ) { p->PlayAnimation(SArg(1),FArg(2)); return 0; } \
|
||||
|
||||
#define LUA_Model_METHODS_MAP( T ) \
|
||||
LUA_Actor_METHODS_MAP( T ) \
|
||||
LUA_METHOD_MAP( T, playanimation ) \
|
||||
|
||||
class Model : public Actor
|
||||
{
|
||||
@@ -45,7 +52,10 @@ public:
|
||||
|
||||
bool MaterialsNeedNormals() const;
|
||||
|
||||
virtual void HandleCommand( const Command &command );
|
||||
//
|
||||
// Commands
|
||||
//
|
||||
virtual void PushSelf( lua_State *L );
|
||||
|
||||
private:
|
||||
RageModelGeometry *m_pGeometry;
|
||||
|
||||
@@ -12,7 +12,7 @@ static const ThemeMetric<float> START_X ("MusicList","StartX");
|
||||
static const ThemeMetric<float> START_Y ("MusicList","StartY");
|
||||
static const ThemeMetric<float> SPACING_X ("MusicList","SpacingX");
|
||||
static const ThemeMetric<float> CROP_WIDTH ("MusicList","CropWidth");
|
||||
static const ThemeMetric<Commands> INIT_COMMAND ("MusicList","InitCommand");
|
||||
static const ThemeMetric<apActorCommands> INIT_COMMAND ("MusicList","InitCommand");
|
||||
|
||||
MusicList::MusicList()
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ ThemeMetric<float> NUM_WHEEL_ITEMS_TO_DRAW ("MusicWheel","NumWheelItems");
|
||||
#define MOST_PLAYED_SONGS_TO_SHOW THEME->GetMetricI("MusicWheel","MostPlayedSongsToShow")
|
||||
#define SORT_MENU_CHOICE_NAMES THEME->GetMetric ("MusicWheel","SortMenuChoiceNames")
|
||||
#define MODE_MENU_CHOICE_NAMES THEME->GetMetric ("MusicWheel","ModeMenuChoiceNames")
|
||||
#define CHOICE( sChoiceName ) THEME->GetMetricA("MusicWheel",ssprintf("Choice%s",sChoiceName.c_str()))
|
||||
#define CHOICE( sChoiceName ) THEME->GetMetricM("MusicWheel",ssprintf("Choice%s",sChoiceName.c_str()))
|
||||
#define WHEEL_ITEM_ON_DELAY_CENTER THEME->GetMetricF("MusicWheel","WheelItemOnDelayCenter")
|
||||
#define WHEEL_ITEM_ON_DELAY_OFFSET THEME->GetMetricF("MusicWheel","WheelItemOnDelayOffset")
|
||||
#define WHEEL_ITEM_OFF_DELAY_CENTER THEME->GetMetricF("MusicWheel","WheelItemOffDelayCenter")
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "SongManager.h"
|
||||
#include "Course.h"
|
||||
#include "Style.h"
|
||||
#include "Command.h"
|
||||
|
||||
#define SHIFT_X(p) THEME->GetMetricF(m_sName, ssprintf("ShiftP%iX", p+1))
|
||||
#define SHIFT_Y(p) THEME->GetMetricF(m_sName, ssprintf("ShiftP%iY", p+1))
|
||||
@@ -322,7 +323,7 @@ done:
|
||||
continue;
|
||||
spec.erase( spec.begin(), spec.begin()+1 );
|
||||
|
||||
m_textContents[c].RunCommands( ParseCommands(join(";", spec)) );
|
||||
m_textContents[c].RunCommands( ActorCommands( ParseCommands(join(";", spec)) ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ bool ReceptorArrow::Load( CString NoteSkin, const PlayerState* pPlayerState, int
|
||||
{
|
||||
CString sJudge = TapNoteScoreToString( i );
|
||||
CString sCommand = Capitalize(sJudge)+"Command";
|
||||
m_sScoreCommand[i] = NOTESKIN->GetMetricA( NoteSkin, m_sName, sCommand );
|
||||
m_sScoreCommand[i] = apActorCommands( new ActorCommands(NOTESKIN->GetMetricA(NoteSkin,m_sName,sCommand)) );
|
||||
}
|
||||
|
||||
m_pPressBlock.Load( NOTESKIN->GetPathToFromNoteSkinAndButton(NoteSkin,sButton,"KeypressBlock") );
|
||||
@@ -71,8 +71,8 @@ void ReceptorArrow::Step( TapNoteScore score )
|
||||
{
|
||||
m_pReceptorGo->FinishTweening();
|
||||
m_pReceptorWaiting->FinishTweening();
|
||||
m_pReceptorGo->RunCommands( m_sScoreCommand[score] );
|
||||
m_pReceptorWaiting->RunCommands( m_sScoreCommand[score] );
|
||||
m_pReceptorGo->RunCommands( *m_sScoreCommand[score] );
|
||||
m_pReceptorWaiting->RunCommands( *m_sScoreCommand[score] );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -27,7 +27,7 @@ private:
|
||||
|
||||
AutoActor m_pReceptorWaiting;
|
||||
AutoActor m_pReceptorGo;
|
||||
Commands m_sScoreCommand[NUM_TAP_NOTE_SCORES];
|
||||
apActorCommands m_sScoreCommand[NUM_TAP_NOTE_SCORES];
|
||||
|
||||
AutoActor m_pPressBlock;
|
||||
bool m_bIsPressed;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include "PlayerState.h"
|
||||
#include "Command.h"
|
||||
|
||||
#define ITEM_X( i ) THEME->GetMetricF("ScoreDisplayBattle",ssprintf("Item%dX",i+1))
|
||||
#define ITEM_Y( i ) THEME->GetMetricF("ScoreDisplayBattle",ssprintf("Item%dY",i+1))
|
||||
@@ -52,14 +53,14 @@ void ScoreDisplayBattle::Update( float fDelta )
|
||||
|
||||
if( sNewModifier == "" )
|
||||
{
|
||||
m_ItemIcon[s].RunCommands( ParseCommands("linear,0.25;zoom,0") );
|
||||
m_ItemIcon[s].RunCommands( ActorCommands( ParseCommands("linear,0.25;zoom,0") ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Cache all of the icon graphics so we don't load them dynamically from disk.
|
||||
m_ItemIcon[s].Load( THEME->GetPathToG("ScoreDisplayBattle icon "+sNewModifier) );
|
||||
m_ItemIcon[s].StopTweening();
|
||||
m_ItemIcon[s].RunCommands( ParseCommands(
|
||||
ActorCommands acmds( ParseCommands(
|
||||
"diffuse,1,1,1,1;zoom,1;"
|
||||
"sleep,0.1;linear,0;diffusealpha,0;"
|
||||
"sleep,0.1;linear,0;diffusealpha,1;"
|
||||
@@ -67,6 +68,7 @@ void ScoreDisplayBattle::Update( float fDelta )
|
||||
"sleep,0.1;linear,0;diffusealpha,1;"
|
||||
"sleep,0.1;linear,0;diffusealpha,0;"
|
||||
"sleep,0.1;linear,0;diffusealpha,1;" ) );
|
||||
m_ItemIcon[s].RunCommands( acmds );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
|
||||
#include "ScoreDisplay.h"
|
||||
#include "BitmapText.h"
|
||||
|
||||
|
||||
#include "Sprite.h"
|
||||
|
||||
class ScoreDisplayNormal : public ScoreDisplay
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "ScoreDisplay.h"
|
||||
#include "BitmapText.h"
|
||||
|
||||
#include "Sprite.h"
|
||||
|
||||
class ScoreDisplayOni : public ScoreDisplay
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "ScoreDisplay.h"
|
||||
#include "PercentageDisplay.h"
|
||||
#include "Sprite.h"
|
||||
|
||||
class ScoreDisplayPercentage : public ScoreDisplay
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "LuaManager.h"
|
||||
#include "GameCommand.h"
|
||||
#include "RageUtil.h"
|
||||
#include "Command.h"
|
||||
|
||||
#define CHOICES THEME->GetMetric (m_sName,"Choices")
|
||||
#define CONDITION(choice) THEME->GetMetric (m_sName,"Condition"+choice)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "BitmapText.h"
|
||||
#include "ScreenAttract.h"
|
||||
#include "Sprite.h"
|
||||
|
||||
enum EndingStatsLine
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "Style.h"
|
||||
#include "MemoryCardManager.h"
|
||||
#include "PlayerState.h"
|
||||
#include "Command.h"
|
||||
|
||||
const int NUM_SCORE_DIGITS = 9;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "StepsUtil.h"
|
||||
#include "ScreenDimensions.h"
|
||||
#include "PlayerState.h"
|
||||
#include "Command.h"
|
||||
|
||||
#define SCROLLING_LIST_X THEME->GetMetricF("ScreenEz2SelectMusic","ScrollingListX")
|
||||
#define SCROLLING_LIST_Y THEME->GetMetricF("ScreenEz2SelectMusic","ScrollingListY")
|
||||
@@ -413,10 +414,10 @@ void ScreenEz2SelectMusic::MenuBack( PlayerNumber pn )
|
||||
|
||||
void ScreenEz2SelectMusic::TweenOffScreen()
|
||||
{
|
||||
static const Commands cmds = ParseCommands("linear,0.5;zoomy,0");
|
||||
ActorCommands cmds( ParseCommands("linear,0.5;zoomy,0") );
|
||||
m_MusicBannerWheel.RunCommands( cmds );
|
||||
|
||||
static const Commands cmds2 = ParseCommands("Linear,1;DiffuseAlpha,0");
|
||||
ActorCommands cmds2( ParseCommands("Linear,1;DiffuseAlpha,0") );
|
||||
m_PumpDifficultyCircle.RunCommands( cmds2 );
|
||||
m_Guide.RunCommands( cmds2 );
|
||||
m_PumpDifficultyRating.RunCommands( cmds2 );
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
#include "HelpDisplay.h"
|
||||
#include "ScreenDimensions.h"
|
||||
#include "ThemeMetric.h"
|
||||
#include "Command.h"
|
||||
|
||||
static const ThemeMetric<Commands> EVEN_LINE_IN ("ScreenMapControllers","EvenLineIn");
|
||||
static const ThemeMetric<Commands> EVEN_LINE_OUT ("ScreenMapControllers","EvenLineOut");
|
||||
static const ThemeMetric<Commands> ODD_LINE_IN ("ScreenMapControllers","OddLineIn");
|
||||
static const ThemeMetric<Commands> ODD_LINE_OUT ("ScreenMapControllers","OddLineOut");
|
||||
static const ThemeMetric<apActorCommands> EVEN_LINE_IN ("ScreenMapControllers","EvenLineIn");
|
||||
static const ThemeMetric<apActorCommands> EVEN_LINE_OUT ("ScreenMapControllers","EvenLineOut");
|
||||
static const ThemeMetric<apActorCommands> ODD_LINE_IN ("ScreenMapControllers","OddLineIn");
|
||||
static const ThemeMetric<apActorCommands> ODD_LINE_OUT ("ScreenMapControllers","OddLineOut");
|
||||
|
||||
const int FramesToWaitForInput = 2;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "Foreach.h"
|
||||
#include "Style.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
#include "Command.h"
|
||||
|
||||
//
|
||||
// Defines specific to ScreenNameEntryTraditional
|
||||
@@ -83,10 +83,10 @@ void HighScoreWheelItem::LoadBlank( int iRankIndex )
|
||||
|
||||
void HighScoreWheelItem::ShowFocus()
|
||||
{
|
||||
Commands cmds = ParseCommands("diffuseshift;EffectColor1,1,1,0,1;EffectColor2,0,1,1,1");
|
||||
m_textRank.RunCommands( cmds );
|
||||
m_textName.RunCommands( cmds );
|
||||
m_textScore.RunCommands( cmds );
|
||||
ActorCommands c( ParseCommands("diffuseshift;EffectColor1,1,1,0,1;EffectColor2,0,1,1,1") );
|
||||
m_textRank.RunCommands( c );
|
||||
m_textName.RunCommands( c );
|
||||
m_textScore.RunCommands( c );
|
||||
}
|
||||
|
||||
void HighScoreWheel::Load( const HighScoreList& hsl, int iIndexToFocus )
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "Course.h"
|
||||
#include "Style.h"
|
||||
#include "ScreenDimensions.h"
|
||||
#include "Command.h"
|
||||
|
||||
const float ITEM_X[NUM_PLAYERS] = { 260, 420 };
|
||||
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
#include "RageDisplay.h"
|
||||
#include "arch/ArchHooks/ArchHooks.h"
|
||||
#include "LightsManager.h"
|
||||
#include "Command.h"
|
||||
|
||||
|
||||
#define CHOICE_NAMES THEME->GetMetric (m_sName,"ChoiceNames")
|
||||
#define CHOICE( sChoiceName ) THEME->GetMetricA(m_sName,ssprintf("Choice%s",sChoiceName.c_str()))
|
||||
#define CHOICE( sChoiceName ) THEME->GetMetricM(m_sName,ssprintf("Choice%s",sChoiceName.c_str()))
|
||||
#define CODE_NAMES THEME->GetMetric (m_sName,"CodeNames")
|
||||
#define CODE( c ) THEME->GetMetric (m_sName,ssprintf("Code%d",c+1))
|
||||
#define CODE_ACTION( c ) THEME->GetMetricA(m_sName,ssprintf("Code%dAction",c+1))
|
||||
#define CODE_ACTION( c ) THEME->GetMetricM(m_sName,ssprintf("Code%dAction",c+1))
|
||||
#define NEXT_SCREEN( c ) THEME->GetMetric (m_sName,ssprintf("NextScreen%d",c+1))
|
||||
#define IDLE_TIMEOUT_SCREEN THEME->GetMetric (m_sName,"IdleTimeoutScreen")
|
||||
#define ALLOW_DISABLED_PLAYER_INPUT THEME->GetMetricB(m_sName,"AllowDisabledPlayerInput")
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "Character.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include "Command.h"
|
||||
|
||||
|
||||
#define TITLE_ON_COMMAND( p ) THEME->GetMetricA("ScreenSelectCharacter",ssprintf("TitleP%dOnCommand",p+1))
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "GameCommand.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "ScreenDimensions.h"
|
||||
#include "Command.h"
|
||||
|
||||
#define NUM_CHOICES_ON_PAGE_1 THEME->GetMetricI(m_sName,"NumChoicesOnPage1")
|
||||
#define LOCK_INPUT_SECONDS THEME->GetMetricF(m_sName,"LockInputSeconds")
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "Foreach.h"
|
||||
#include "Style.h"
|
||||
#include "PlayerState.h"
|
||||
|
||||
#include "Command.h"
|
||||
|
||||
const int NUM_SCORE_DIGITS = 9;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "ActorUtil.h"
|
||||
#include "LightsManager.h"
|
||||
#include "CommonMetrics.h"
|
||||
#include "Command.h"
|
||||
|
||||
|
||||
#define ICON_GAIN_FOCUS_COMMAND THEME->GetMetricA(m_sName,"IconGainFocusCommand")
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "ProfileManager.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "RageLog.h"
|
||||
#include "Command.h"
|
||||
|
||||
|
||||
#define CREDITS_PRESS_START THEME->GetMetric ("ScreenSystemLayer","CreditsPressStart")
|
||||
@@ -97,8 +98,8 @@ void ScreenSystemLayer::ReloadCreditsText()
|
||||
void ScreenSystemLayer::SystemMessage( const CString &sMessage )
|
||||
{
|
||||
m_textMessage.SetText( sMessage );
|
||||
static const Commands cmds = ParseCommands("finishtweening;diffusealpha,1;addx,-640;linear,0.5;addx,+640;sleep,5;linear,0.5;diffusealpha,0");
|
||||
m_textMessage.RunCommands( cmds );
|
||||
ActorCommands c = ActorCommands( ParseCommands("finishtweening;diffusealpha,1;addx,-640;linear,0.5;addx,+640;sleep,5;linear,0.5;diffusealpha,0") );
|
||||
m_textMessage.RunCommands( c );
|
||||
}
|
||||
|
||||
void ScreenSystemLayer::SystemMessageNoAnimate( const CString &sMessage )
|
||||
|
||||
@@ -45,7 +45,7 @@ ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName )
|
||||
PointsUntilNextUnlock.LoadFromFont( THEME->GetPathToF("Common normal") );
|
||||
PointsUntilNextUnlock.SetHorizAlign( Actor::align_left );
|
||||
|
||||
const Commands IconCommand = ICON_COMMAND;
|
||||
apActorCommands IconCommand = ICON_COMMAND;
|
||||
for( unsigned i=1; i <= NumUnlocks; i++ )
|
||||
{
|
||||
// get pertaining UnlockEntry
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
#include "LuaBinding.h"
|
||||
#include "LuaManager.h"
|
||||
|
||||
|
||||
// lua start
|
||||
//LUA_REGISTER_CLASS( Sprite, Actor )
|
||||
LUA_REGISTER_CLASS( Sprite )
|
||||
// lua end
|
||||
|
||||
|
||||
@@ -912,6 +913,11 @@ void Sprite::StretchTexCoords( float fX, float fY )
|
||||
SetCustomTextureCoords( fTexCoords );
|
||||
}
|
||||
|
||||
void Sprite::SetPosition( float f ) { GetTexture()->SetPosition(f); }
|
||||
void Sprite::SetLooping( bool b ) { GetTexture()->SetLooping(b); }
|
||||
void Sprite::SetPlaybackRate( float f ) { GetTexture()->SetPlaybackRate(f); }
|
||||
|
||||
/*
|
||||
void Sprite::HandleCommand( const Command &command )
|
||||
{
|
||||
BeginHandleArgs;
|
||||
@@ -925,10 +931,10 @@ void Sprite::HandleCommand( const Command &command )
|
||||
else if( sName=="scaletoclipped" ) ScaleToClipped( fArg(1),fArg(2) );
|
||||
else if( sName=="stretchtexcoords" ) StretchTexCoords( fArg(1),fArg(2) );
|
||||
|
||||
/* Texture commands; these could be moved to RageTexture* (even though that's
|
||||
* not an Actor) if these are needed for other things that use textures.
|
||||
* We'd need to break the command helpers into a separate function; RageTexture
|
||||
* shouldn't depend on Actor. */
|
||||
// Texture commands; these could be moved to RageTexture* (even though that's
|
||||
// not an Actor) if these are needed for other things that use textures.
|
||||
// We'd need to break the command helpers into a separate function; RageTexture
|
||||
// shouldn't depend on Actor.
|
||||
else if( sName=="position" ) GetTexture()->SetPosition( fArg(1) );
|
||||
else if( sName=="loop" ) GetTexture()->SetLooping( bArg(1) );
|
||||
else if( sName=="rate" ) GetTexture()->SetPlaybackRate( fArg(1) );
|
||||
@@ -940,6 +946,7 @@ void Sprite::HandleCommand( const Command &command )
|
||||
|
||||
EndHandleArgs;
|
||||
}
|
||||
*/
|
||||
|
||||
void Sprite::GainFocus( float fRate, bool bRewindMovie, bool bLoop )
|
||||
{
|
||||
@@ -969,6 +976,12 @@ void Sprite::LoseFocus()
|
||||
Actor::LoseFocus();
|
||||
}
|
||||
|
||||
void Sprite::PushSelf( lua_State *L )
|
||||
{
|
||||
Luna<Sprite,LuaSprite>::Push( L, this );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
|
||||
+30
-3
@@ -8,13 +8,33 @@
|
||||
|
||||
class RageTexture;
|
||||
|
||||
/*
|
||||
|
||||
#define LUA_Sprite_METHODS( T ) \
|
||||
LUA_Actor_METHODS( T ) \
|
||||
/* Commands that go in the tweening queue:
|
||||
* Commands that take effect immediately (ignoring the tweening queue): */ \
|
||||
static int customtexturerect( T* p, lua_State *L ) { p->SetCustomTextureRect( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } \
|
||||
static int texcoordvelocity( T* p, lua_State *L ) { p->SetTexCoordVelocity( FArg(1),FArg(2) ); return 0; } \
|
||||
static int scaletoclipped( T* p, lua_State *L ) { p->ScaleToClipped( FArg(1),FArg(2) ); return 0; } \
|
||||
static int stretchtexcoords( T* p, lua_State *L ) { p->StretchTexCoords( FArg(1),FArg(2) ); return 0; } \
|
||||
/* Texture commands; these could be moved to RageTexture* (even though that's
|
||||
* not an Actor) if these are needed for other things that use textures.
|
||||
* We'd need to break the command helpers into a separate function; RageTexture
|
||||
* shouldn't depend on Actor. */ \
|
||||
static int position( T* p, lua_State *L ) { p->SetPosition(FArg(1)); return 0; } \
|
||||
static int loop( T* p, lua_State *L ) { p->SetLooping(BArg(1)); return 0; } \
|
||||
static int rate( T* p, lua_State *L ) { p->SetPlaybackRate(FArg(1)); return 0; } \
|
||||
|
||||
#define LUA_Sprite_METHODS_MAP( T ) \
|
||||
LUA_Actor_METHODS_MAP( T ) \
|
||||
*/
|
||||
LUA_METHOD_MAP( T, customtexturerect ) \
|
||||
LUA_METHOD_MAP( T, texcoordvelocity ) \
|
||||
LUA_METHOD_MAP( T, scaletoclipped ) \
|
||||
LUA_METHOD_MAP( T, stretchtexcoords ) \
|
||||
LUA_METHOD_MAP( T, position ) \
|
||||
LUA_METHOD_MAP( T, loop ) \
|
||||
LUA_METHOD_MAP( T, rate ) \
|
||||
|
||||
|
||||
class Sprite: public Actor
|
||||
{
|
||||
@@ -63,6 +83,9 @@ public:
|
||||
void StopUsingCustomCoords();
|
||||
void GetActiveTextureCoords(float fTexCoordsOut[8]) const;
|
||||
void StretchTexCoords( float fX, float fY );
|
||||
void SetPosition( float f );
|
||||
void SetLooping( bool b );
|
||||
void SetPlaybackRate( float f );
|
||||
|
||||
|
||||
void SetTexCoordVelocity(float fVelX, float fVelY) { m_fTexCoordVelocityX = fVelX; m_fTexCoordVelocityY = fVelY; }
|
||||
@@ -71,7 +94,10 @@ public:
|
||||
void ScaleToClipped( float fWidth, float fHeight );
|
||||
static bool IsDiagonalBanner( int iWidth, int iHeight );
|
||||
|
||||
virtual void HandleCommand( const Command &command );
|
||||
//
|
||||
// Commands
|
||||
//
|
||||
virtual void PushSelf( lua_State *L );
|
||||
|
||||
protected:
|
||||
virtual bool LoadFromTexture( RageTextureID ID );
|
||||
@@ -104,6 +130,7 @@ protected:
|
||||
float m_fTexCoordVelocityY;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -32,6 +32,12 @@
|
||||
#include "CommonMetrics.h"
|
||||
#include "Game.h"
|
||||
|
||||
// temp
|
||||
#include "Command.h"
|
||||
#include "LuaBinding.h"
|
||||
#include "ActorCommands.h"
|
||||
#include "Sprite.h"
|
||||
|
||||
//
|
||||
// StepMania global classes
|
||||
//
|
||||
@@ -1085,6 +1091,41 @@ int main(int argc, char* argv[])
|
||||
CheckSettings();
|
||||
|
||||
LUA = new LuaManager;
|
||||
|
||||
|
||||
RageTimer t;
|
||||
float fDelta = 0;
|
||||
Sprite s;
|
||||
CString sCommands = "x,SCREEN_LEFT+100";
|
||||
Commands cmds = ParseCommands("horizalign,left;vertalign,top;zoom,0.8;shadowlength,2");
|
||||
ActorCommands* pacmds = new ActorCommands( cmds );
|
||||
|
||||
LUA->RunScript(
|
||||
"SCREEN_LEFT = 100\n"
|
||||
"left = 'left'\n"
|
||||
"center = 'center'\n"
|
||||
"right = 'right'\n"
|
||||
"top = 'top'\n"
|
||||
"middle = 'middle'\n"
|
||||
"bottom = 'bottom'\n"
|
||||
"F2 = function(self)"
|
||||
" self:vertalign(top)"
|
||||
" self:horizalign(left)"
|
||||
" self:zoom(0.8)"
|
||||
" self:shadowlength(2)"
|
||||
"end"
|
||||
);
|
||||
t.GetDeltaTime();
|
||||
for( int i=0; i<100000; i++ )
|
||||
{
|
||||
// s.RunCommands( *pacmds );
|
||||
}
|
||||
LOG->Trace( "Lua2 took %f", t.GetDeltaTime() );
|
||||
|
||||
|
||||
SAFE_DELETE( pacmds );
|
||||
|
||||
|
||||
GAMEMAN = new GameManager;
|
||||
THEME = new ThemeManager;
|
||||
ANNOUNCER = new AnnouncerManager;
|
||||
|
||||
@@ -632,6 +632,14 @@ SOURCE=.\RageUtil_FileDB.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ActorCommands.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ActorCommands.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Attack.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -8,14 +8,15 @@
|
||||
#include "RageTextureManager.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "ThemeMetric.h"
|
||||
#include "Command.h"
|
||||
|
||||
ThemeMetric<CString> ARTIST_PREPEND_STRING ("TextBanner","ArtistPrependString");
|
||||
ThemeMetric<Commands> TWO_LINES_TITLE_COMMAND ("TextBanner","TwoLinesTitleCommand");
|
||||
ThemeMetric<Commands> TWO_LINES_SUBTITLE_COMMAND ("TextBanner","TwoLinesSubtitleCommand");
|
||||
ThemeMetric<Commands> TWO_LINES_ARTIST_COMMAND ("TextBanner","TwoLinesArtistCommand");
|
||||
ThemeMetric<Commands> THREE_LINES_TITLE_COMMAND ("TextBanner","ThreeLinesTitleCommand");
|
||||
ThemeMetric<Commands> THREE_LINES_SUBTITLE_COMMAND ("TextBanner","ThreeLinesSubtitleCommand");
|
||||
ThemeMetric<Commands> THREE_LINES_ARTIST_COMMAND ("TextBanner","ThreeLinesArtistCommand");
|
||||
ThemeMetric<apActorCommands> TWO_LINES_TITLE_COMMAND ("TextBanner","TwoLinesTitleCommand");
|
||||
ThemeMetric<apActorCommands> TWO_LINES_SUBTITLE_COMMAND ("TextBanner","TwoLinesSubtitleCommand");
|
||||
ThemeMetric<apActorCommands> TWO_LINES_ARTIST_COMMAND ("TextBanner","TwoLinesArtistCommand");
|
||||
ThemeMetric<apActorCommands> THREE_LINES_TITLE_COMMAND ("TextBanner","ThreeLinesTitleCommand");
|
||||
ThemeMetric<apActorCommands> THREE_LINES_SUBTITLE_COMMAND ("TextBanner","ThreeLinesSubtitleCommand");
|
||||
ThemeMetric<apActorCommands> THREE_LINES_ARTIST_COMMAND ("TextBanner","ThreeLinesArtistCommand");
|
||||
|
||||
void TextBanner::Init()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "ThemeMetric.h"
|
||||
#include "LuaManager.h"
|
||||
#include "ScreenDimensions.h"
|
||||
#include "Command.h"
|
||||
|
||||
|
||||
ThemeManager* THEME = NULL; // global object accessable from anywhere in the program
|
||||
@@ -745,11 +746,16 @@ RageColor ThemeManager::GetMetricC( const CString &sClassName, const CString &sV
|
||||
return ret;
|
||||
}
|
||||
|
||||
Commands ThemeManager::GetMetricA( const CString &sClassName, const CString &sValueName )
|
||||
Commands ThemeManager::GetMetricM( const CString &sClassName, const CString &sValueName )
|
||||
{
|
||||
return ParseCommands( GetMetricRaw(sClassName,sValueName) );
|
||||
}
|
||||
|
||||
apActorCommands ThemeManager::GetMetricA( const CString &sClassName, const CString &sValueName )
|
||||
{
|
||||
return apActorCommands( new ActorCommands( ParseCommands( GetMetricRaw(sClassName,sValueName) ) ) );
|
||||
}
|
||||
|
||||
void ThemeManager::NextTheme()
|
||||
{
|
||||
CStringArray as;
|
||||
@@ -807,7 +813,7 @@ void ThemeManager::GetModifierNames( set<CString>& AddTo )
|
||||
}
|
||||
}
|
||||
|
||||
void ThemeManager::GetMetric( const CString &sClassName, const CString &sValueName, Commands &valueOut )
|
||||
void ThemeManager::GetMetric( const CString &sClassName, const CString &sValueName, apActorCommands &valueOut )
|
||||
{
|
||||
valueOut = GetMetricA( sClassName, sValueName );
|
||||
}
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
#include "RageTimer.h"
|
||||
#include <set>
|
||||
#include <deque>
|
||||
#include "Command.h"
|
||||
#include "ActorCommands.h"
|
||||
|
||||
class IThemeMetric;
|
||||
class IniFile;
|
||||
class Commands;
|
||||
|
||||
enum ElementCategory { BGAnimations, Fonts, Graphics, Numbers, Sounds, Other, NUM_ELEMENT_CATEGORIES };
|
||||
|
||||
@@ -62,14 +63,16 @@ public:
|
||||
float GetMetricF( const CString &sClassName, const CString &sValueName );
|
||||
bool GetMetricB( const CString &sClassName, const CString &sValueName );
|
||||
RageColor GetMetricC( const CString &sClassName, const CString &sValueName );
|
||||
Commands GetMetricA( const CString &sClassName, const CString &sValueName );
|
||||
Commands GetMetricM( const CString &sClassName, const CString &sValueName );
|
||||
apActorCommands GetMetricA( const CString &sClassName, const CString &sValueName );
|
||||
|
||||
void GetMetric( const CString &sClassName, const CString &sValueName, CString &valueOut ) { valueOut = GetMetric( sClassName, sValueName ); }
|
||||
void GetMetric( const CString &sClassName, const CString &sValueName, int &valueOut ) { valueOut = GetMetricI( sClassName, sValueName ); }
|
||||
void GetMetric( const CString &sClassName, const CString &sValueName, float &valueOut ) { valueOut = GetMetricF( sClassName, sValueName ); }
|
||||
void GetMetric( const CString &sClassName, const CString &sValueName, bool &valueOut ) { valueOut = GetMetricB( sClassName, sValueName ); }
|
||||
void GetMetric( const CString &sClassName, const CString &sValueName, RageColor &valueOut ) { valueOut = GetMetricC( sClassName, sValueName ); }
|
||||
void GetMetric( const CString &sClassName, const CString &sValueName, Commands &valueOut );
|
||||
void GetMetric( const CString &sClassName, const CString &sValueName, Command &valueOut );
|
||||
void GetMetric( const CString &sClassName, const CString &sValueName, apActorCommands &valueOut );
|
||||
|
||||
//
|
||||
// For self-registering metrics
|
||||
|
||||
Reference in New Issue
Block a user