Remove the old files. (also I am very sorry for nuking the line by line history, this has been pissing me off for ages)

This commit is contained in:
Colby Klein
2011-09-23 15:44:01 -07:00
parent 6fed94a210
commit 69431604e3
14 changed files with 0 additions and 4624 deletions
-1746
View File
File diff suppressed because it is too large Load Diff
-755
View File
@@ -1,755 +0,0 @@
#ifndef ACTOR_H
#define ACTOR_H
#include "PlayerNumber.h"
#include "RageTypes.h"
#include "RageUtil_AutoPtr.h"
#include "LuaReference.h"
#include "EnumHelper.h"
#include <map>
class XNode;
struct lua_State;
class LuaClass;
#include "MessageManager.h"
#include "Tween.h"
typedef AutoPtrCopyOnWrite<LuaReference> apActorCommands;
/** @brief The background layer. */
#define DRAW_ORDER_BEFORE_EVERYTHING -200
/** @brief The underlay layer. */
#define DRAW_ORDER_UNDERLAY -100
/** @brief The decorations layer. */
#define DRAW_ORDER_DECORATIONS 0
/** @brief The overlay layer.
*
* Normal screen elements go here. */
#define DRAW_ORDER_OVERLAY +100
/** @brief The transitions layer. */
#define DRAW_ORDER_TRANSITIONS +200
/** @brief The over everything layer. */
#define DRAW_ORDER_AFTER_EVERYTHING +300
/** @brief The different horizontal alignments. */
enum HorizAlign
{
HorizAlign_Left, /**< Align to the left. */
HorizAlign_Center, /**< Align to the center. */
HorizAlign_Right, /**< Align to the right. */
NUM_HorizAlign, /**< The number of horizontal alignments. */
HorizAlign_Invalid
};
LuaDeclareType( HorizAlign );
/** @brief The different vertical alignments. */
enum VertAlign
{
VertAlign_Top, /**< Align to the top. */
VertAlign_Middle, /**< Align to the middle. */
VertAlign_Bottom, /**< Align to the bottom. */
NUM_VertAlign, /**< The number of vertical alignments. */
VertAlign_Invalid
};
LuaDeclareType( VertAlign );
/** @brief The left horizontal alignment constant. */
#define align_left 0.0f
/** @brief The center horizontal alignment constant. */
#define align_center 0.5f
/** @brief The right horizontal alignment constant. */
#define align_right 1.0f
/** @brief The top vertical alignment constant. */
#define align_top 0.0f
/** @brief The middle vertical alignment constant. */
#define align_middle 0.5f
/** @brief The bottom vertical alignment constant. */
#define align_bottom 1.0f
// ssc futures:
/*
enum EffectAction
{
EffectAction_None, // no_effect
// [Diffuse]
EffectAction_DiffuseBlink, // diffuse_blink
EffectAction_DiffuseShift, // diffuse_shift
EffectAction_DiffuseRamp, // diffuse_ramp
EffectAction_Rainbow, // rainbow
// [Glow]
EffectAction_GlowBlink, // glow_blink
EffectAction_GlowShift, // glow_shift
EffectAction_GlowRamp, // glow_ramp
// [Translate]
EffectAction_Bob,
EffectAction_Bounce,
EffectAction_Vibrate,
// [Rotate]
EffectAction_Spin,
EffectAction_Wag,
// [Zoom]
EffectAction_Pulse,
NUM_EffectAction,
EffectAction_Invalid
};
LuaDeclareType( EffectAction );
*/
/** @brief Base class for all objects that appear on the screen. */
class Actor : public MessageSubscriber
{
public:
/** @brief Set up the Actor with its initial settings. */
Actor();
/**
* @brief Copy a new Actor to the old one.
* @param cpy the new Actor to use in place of this one. */
Actor( const Actor &cpy );
virtual ~Actor();
virtual Actor *Copy() const;
virtual void InitState();
virtual void LoadFromNode( const XNode* pNode );
static void SetBGMTime( float fTime, float fBeat, float fTimeNoOffset, float fBeatNoOffset );
static void SetPlayerBGMBeat( PlayerNumber pn, float fBeat, float fBeatNoOffset );
static void SetBGMLight( int iLightNumber, float fCabinetLights );
/**
* @brief The list of the different effects.
*
* todo: split out into diffuse effects and translation effects, or
* create an effect stack instead. -aj */
enum Effect { no_effect,
diffuse_blink, diffuse_shift, diffuse_ramp,
glow_blink, glow_shift, glow_ramp, rainbow,
wag, bounce, bob, pulse, spin, vibrate
};
/** @brief Various values an Actor's effect can be tied to. */
enum EffectClock
{
CLOCK_TIMER,
CLOCK_TIMER_GLOBAL,
CLOCK_BGM_TIME,
CLOCK_BGM_BEAT,
CLOCK_BGM_TIME_NO_OFFSET,
CLOCK_BGM_BEAT_NO_OFFSET,
CLOCK_BGM_BEAT_PLAYER1,
CLOCK_BGM_BEAT_PLAYER2,
CLOCK_LIGHT_1 = 1000,
CLOCK_LIGHT_LAST = 1100,
NUM_CLOCKS
};
/*
* @brief What type of Effect this is.
*
* This is an internal enum for checking if an effect can be run;
* You can't have more than one of most EffectTypes in the Effect list. (You
* might be able to have mutliple EffectType_Translates; not sure yet.) -aj */
/*
enum EffectType {
EffectType_Diffuse,
EffectType_Glow,
EffectType_Translate,
EffectType_Rotate,
EffectType_Zoom,
NUM_EffectType,
EffectType_Invalid
};
*/
// todo: use this instead of the Effect enum -aj
/*
// This is similar to Attributes in BitmapText as far as implementation.
struct Effect
{
Effect() : m_Action(EffectAction_None), m_Type(EffectType_Invalid), m_fSecsIntoEffect(0),
m_fEffectDelta(0), m_fEffectRampUp(0.5f), m_fEffectHoldAtHalf(0),
m_fEffectRampDown(0.5f), m_fEffectHoldAtZero(0), m_fEffectOffset(0),
m_EffectClock(CLOCK_TIMER), m_vEffectMagnitude(RageVector3(0,0,10)),
m_effectColor1(RageColor(1,1,1,1)), m_effectColor2(RageColor(1,1,1,1))
{ }
RString m_sName; // friendly name
EffectAction m_Action; // replaces the old Effect enum
EffectType m_Type; // determined by EffectAction
float m_fSecsIntoEffect;
float m_fEffectDelta;
RageColor m_EffectColor1;
RageColor m_EffectColor2;
RageVector3 m_vEffectMagnitude;
EffectClock m_EffectClock;
// units depend on m_EffectClock
float m_fEffectRampUp;
float m_fEffectHoldAtHalf;
float m_fEffectRampDown;
float m_fEffectHoldAtZero;
float m_fEffectOffset;
};
*/
/**
* @brief The present state for the Tween.
*/
struct TweenState
{
void Init();
static void MakeWeightedAverage( TweenState& average_out, const TweenState& ts1, const TweenState& ts2, float fPercentBetween );
bool operator==( const TweenState &other ) const;
bool operator!=( const TweenState &other ) const { return !operator==(other); }
// start and end position for tweening
RageVector3 pos;
RageVector3 rotation;
RageVector4 quat;
RageVector3 scale;
float fSkewX, fSkewY;
/**
* @brief The amount of cropping involved.
*
* If 0, there is no cropping. If 1, it's fully cropped. */
RectF crop;
/**
* @brief The amount of fading involved.
*
* If 0, there is no fade. If 1, it's fully faded. */
RectF fade;
/**
* @brief Four values making up the diffuse in this TweenState.
*
* 0 = UpperLeft, 1 = UpperRight, 2 = LowerLeft, 3 = LowerRight */
RageColor diffuse[4];
/** @brief The glow color for this TweenState. */
RageColor glow;
/** @brief A magical value that nobody really knows the use for. ;) */
float aux;
};
/**
* @brief Calls multiple functions for drawing the Actors.
*
* It calls the following in order:
* -# EarlyAbortDraw
* -# BeginDraw
* -# DrawPrimitives
* -# EndDraw
*/
void Draw();
/**
* @brief Allow the Actor to be aborted early.
*
* Subclasses may wish to overwrite this to allow for
* aborted actors.
* @return false, as by default Actors shouldn't be aborted on drawing. */
virtual bool EarlyAbortDraw() const { return false; }
/** @brief Start the drawing and push the transform on the world matrix stack. */
virtual void BeginDraw();
/**
* @brief Set the global rendering states of this Actor.
*
* This should be called at the beginning of an Actor's DrawPrimitives() call. */
virtual void SetGlobalRenderStates();
/**
* @brief Set the texture rendering states of this Actor.
*
* This should be called after setting a texture for the Actor. */
virtual void SetTextureRenderStates();
/**
* @brief Draw the primitives of the Actor.
*
* Derivative classes should override this function. */
virtual void DrawPrimitives() {};
/** @brief Pop the transform from the world matrix stack. */
virtual void EndDraw();
// TODO: make Update non virtual and change all classes to override UpdateInternal
// instead.
bool IsFirstUpdate() const;
virtual void Update( float fDeltaTime ); // this can short circuit UpdateInternal
virtual void UpdateInternal( float fDeltaTime ); // override this
void UpdateTweening( float fDeltaTime );
/**
* @brief Retrieve the Actor's name.
* @return the Actor's name. */
const RString &GetName() const { return m_sName; }
/**
* @brief Set the Actor's name to a new one.
* @param sName the new name for the Actor. */
virtual void SetName( const RString &sName ) { m_sName = sName; }
/**
* @brief Give this Actor a new parent.
* @param pParent the new parent Actor. */
void SetParent( Actor *pParent );
/**
* @brief Retrieve the Actor's parent.
* @return the Actor's parent. */
Actor *GetParent() { return m_pParent; }
/**
* @brief Retrieve the Actor's lineage.
* @return the Actor's lineage. */
RString GetLineage() const;
/**
* @brief Retrieve the Actor's x position.
* @return the Actor's x position. */
float GetX() const { return m_current.pos.x; };
/**
* @brief Retrieve the Actor's y position.
* @return the Actor's y position. */
float GetY() const { return m_current.pos.y; };
/**
* @brief Retrieve the Actor's z position.
* @return the Actor's z position. */
float GetZ() const { return m_current.pos.z; };
float GetDestX() const { return DestTweenState().pos.x; };
float GetDestY() const { return DestTweenState().pos.y; };
float GetDestZ() const { return DestTweenState().pos.z; };
void SetX( float x ) { DestTweenState().pos.x = x; };
void SetY( float y ) { DestTweenState().pos.y = y; };
void SetZ( float z ) { DestTweenState().pos.z = z; };
void SetXY( float x, float y ) { DestTweenState().pos.x = x; DestTweenState().pos.y = y; };
/**
* @brief Add to the x position of this Actor.
* @param x the amount to add to the Actor's x position. */
void AddX( float x ) { SetX( GetDestX()+x ); }
/**
* @brief Add to the y position of this Actor.
* @param y the amount to add to the Actor's y position. */
void AddY( float y ) { SetY( GetDestY()+y ); }
/**
* @brief Add to the z position of this Actor.
* @param z the amount to add to the Actor's z position. */
void AddZ( float z ) { SetZ( GetDestZ()+z ); }
// height and width vary depending on zoom
float GetUnzoomedWidth() const { return m_size.x; }
float GetUnzoomedHeight() const { return m_size.y; }
float GetZoomedWidth() const { return m_size.x * m_baseScale.x * DestTweenState().scale.x; }
float GetZoomedHeight() const { return m_size.y * m_baseScale.y * DestTweenState().scale.y; }
void SetWidth( float width ) { m_size.x = width; }
void SetHeight( float height ) { m_size.y = height; }
// Base values
float GetBaseZoomX() const { return m_baseScale.x; }
void SetBaseZoomX( float zoom ) { m_baseScale.x = zoom; }
float GetBaseZoomY() const { return m_baseScale.y; }
void SetBaseZoomY( float zoom ) { m_baseScale.y = zoom; }
float GetBaseZoomZ() const { return m_baseScale.z; }
void SetBaseZoomZ( float zoom ) { m_baseScale.z = zoom; }
void SetBaseZoom( float zoom ) { m_baseScale = RageVector3(zoom,zoom,zoom); }
void SetBaseRotationX( float rot ) { m_baseRotation.x = rot; }
void SetBaseRotationY( float rot ) { m_baseRotation.y = rot; }
void SetBaseRotationZ( float rot ) { m_baseRotation.z = rot; }
void SetBaseRotation( const RageVector3 &rot ) { m_baseRotation = rot; }
virtual void SetBaseAlpha( float fAlpha ) { m_fBaseAlpha = fAlpha; }
/**
* @brief Retrieve the general zoom factor, using the x coordinate of the Actor.
*
* Note that this is not accurate in some cases.
* @return the zoom factor for the x coordinate of the Actor. */
float GetZoom() const { return DestTweenState().scale.x; }
/**
* @brief Retrieve the zoom factor for the x coordinate of the Actor.
* @return the zoom factor for the x coordinate of the Actor. */
float GetZoomX() const { return DestTweenState().scale.x; }
/**
* @brief Retrieve the zoom factor for the y coordinate of the Actor.
* @return the zoom factor for the y coordinate of the Actor. */
float GetZoomY() const { return DestTweenState().scale.y; }
/**
* @brief Retrieve the zoom factor for the z coordinate of the Actor.
* @return the zoom factor for the z coordinate of the Actor. */
float GetZoomZ() const { return DestTweenState().scale.z; }
/**
* @brief Set the zoom factor for all dimensions of the Actor.
* @param zoom the zoom factor for all dimensions. */
void SetZoom( float zoom )
{
DestTweenState().scale.x = zoom;
DestTweenState().scale.y = zoom;
DestTweenState().scale.z = zoom;
}
/**
* @brief Set the zoom factor for the x dimension of the Actor.
* @param zoom the zoom factor for the x dimension. */
void SetZoomX( float zoom ) { DestTweenState().scale.x = zoom; }
/**
* @brief Set the zoom factor for the y dimension of the Actor.
* @param zoom the zoom factor for the y dimension. */
void SetZoomY( float zoom ) { DestTweenState().scale.y = zoom; }
/**
* @brief Set the zoom factor for the z dimension of the Actor.
* @param zoom the zoom factor for the z dimension. */
void SetZoomZ( float zoom ) { DestTweenState().scale.z = zoom; }
void ZoomTo( float fX, float fY ) { ZoomToWidth(fX); ZoomToHeight(fY); }
void ZoomToWidth( float zoom ) { SetZoomX( zoom / GetUnzoomedWidth() ); }
void ZoomToHeight( float zoom ) { SetZoomY( zoom / GetUnzoomedHeight() ); }
float GetRotationX() const { return DestTweenState().rotation.x; }
float GetRotationY() const { return DestTweenState().rotation.y; }
float GetRotationZ() const { return DestTweenState().rotation.z; }
void SetRotationX( float rot ) { DestTweenState().rotation.x = rot; }
void SetRotationY( float rot ) { DestTweenState().rotation.y = rot; }
void SetRotationZ( float rot ) { DestTweenState().rotation.z = rot; }
// added in StepNXA, now available in sm-ssc:
void AddRotationX( float rot ) { DestTweenState().rotation.x += rot; };
void AddRotationY( float rot ) { DestTweenState().rotation.y += rot; };
void AddRotationZ( float rot ) { DestTweenState().rotation.z += rot; };
// and these were normally in SM:
void AddRotationH( float rot );
void AddRotationP( float rot );
void AddRotationR( float rot );
void SetSkewX( float fAmount ) { DestTweenState().fSkewX = fAmount; }
float GetSkewX( float fAmount ) const { return DestTweenState().fSkewX; }
void SetSkewY( float fAmount ) { DestTweenState().fSkewY = fAmount; }
float GetSkewY( float fAmount ) const { return DestTweenState().fSkewY; }
float GetCropLeft() const { return DestTweenState().crop.left; }
float GetCropTop() const { return DestTweenState().crop.top; }
float GetCropRight() const { return DestTweenState().crop.right; }
float GetCropBottom() const { return DestTweenState().crop.bottom; }
void SetCropLeft( float percent ) { DestTweenState().crop.left = percent; }
void SetCropTop( float percent ) { DestTweenState().crop.top = percent; }
void SetCropRight( float percent ) { DestTweenState().crop.right = percent; }
void SetCropBottom( float percent ) { DestTweenState().crop.bottom = percent; }
void SetFadeLeft( float percent ) { DestTweenState().fade.left = percent; }
void SetFadeTop( float percent ) { DestTweenState().fade.top = percent; }
void SetFadeRight( float percent ) { DestTweenState().fade.right = percent; }
void SetFadeBottom( float percent ) { DestTweenState().fade.bottom = percent; }
void SetGlobalDiffuseColor( RageColor c );
virtual void SetDiffuse( RageColor c ) { for(int i=0; i<4; i++) DestTweenState().diffuse[i] = c; };
virtual void SetDiffuseAlpha( float f ) { for(int i = 0; i < 4; ++i) { RageColor c = GetDiffuses( i ); c.a = f; SetDiffuses( i, c ); } }
float GetCurrentDiffuseAlpha() const { return m_current.diffuse[0].a; }
void SetDiffuseColor( RageColor c );
void SetDiffuses( int i, RageColor c ) { DestTweenState().diffuse[i] = c; };
void SetDiffuseUpperLeft( RageColor c ) { DestTweenState().diffuse[0] = c; };
void SetDiffuseUpperRight( RageColor c ) { DestTweenState().diffuse[1] = c; };
void SetDiffuseLowerLeft( RageColor c ) { DestTweenState().diffuse[2] = c; };
void SetDiffuseLowerRight( RageColor c ) { DestTweenState().diffuse[3] = c; };
void SetDiffuseTopEdge( RageColor c ) { DestTweenState().diffuse[0] = DestTweenState().diffuse[1] = c; };
void SetDiffuseRightEdge( RageColor c ) { DestTweenState().diffuse[1] = DestTweenState().diffuse[3] = c; };
void SetDiffuseBottomEdge( RageColor c ) { DestTweenState().diffuse[2] = DestTweenState().diffuse[3] = c; };
void SetDiffuseLeftEdge( RageColor c ) { DestTweenState().diffuse[0] = DestTweenState().diffuse[2] = c; };
RageColor GetDiffuse() const { return DestTweenState().diffuse[0]; };
RageColor GetDiffuses( int i ) const { return DestTweenState().diffuse[i]; };
float GetDiffuseAlpha() const { return DestTweenState().diffuse[0].a; };
void SetGlow( RageColor c ) { DestTweenState().glow = c; };
RageColor GetGlow() const { return DestTweenState().glow; };
void SetAux( float f ) { DestTweenState().aux = f; }
float GetAux() const { return m_current.aux; }
void BeginTweening( float time, ITween *pInterp );
void BeginTweening( float time, TweenType tt = TWEEN_LINEAR );
void StopTweening();
void Sleep( float time );
void QueueCommand( const RString& sCommandName );
void QueueMessage( const RString& sMessageName );
virtual void FinishTweening();
virtual void HurryTweening( float factor );
// Let ActorFrame and BGAnimation override
virtual float GetTweenTimeLeft() const; // Amount of time until all tweens have stopped
TweenState& DestTweenState() // where Actor will end when its tween finish
{
if( m_Tweens.empty() ) // not tweening
return m_current;
else
return m_Tweens.back()->state;
}
const TweenState& DestTweenState() const { return const_cast<Actor*>(this)->DestTweenState(); }
/** @brief How do we handle stretching the Actor? */
enum StretchType
{
fit_inside, /**< Have the Actor fit inside its parent, using the smaller zoom. */
cover /**< Have the Actor cover its parent, using the larger zoom. */
};
void ScaleToCover( const RectF &rect ) { ScaleTo( rect, cover ); }
void ScaleToFitInside( const RectF &rect ) { ScaleTo( rect, fit_inside); };
void ScaleTo( const RectF &rect, StretchType st );
void StretchTo( const RectF &rect );
// Alignment settings. These need to be virtual for BitmapText
virtual void SetHorizAlign( float f ) { m_fHorizAlign = f; }
virtual void SetVertAlign( float f ) { m_fVertAlign = f; }
void SetHorizAlign( HorizAlign ha ) { SetHorizAlign( (ha == HorizAlign_Left)? 0.0f: (ha == HorizAlign_Center)? 0.5f: +1.0f ); }
void SetVertAlign( VertAlign va ) { SetVertAlign( (va == VertAlign_Top)? 0.0f: (va == VertAlign_Middle)? 0.5f: +1.0f ); }
virtual float GetHorizAlign() { return m_fHorizAlign; }
virtual float GetVertAlign() { return m_fVertAlign; }
// effects
#if defined(SSC_FUTURES)
void StopEffects();
Effect GetEffect( int i ) const { return m_Effects[i]; }
#else
void StopEffect() { m_Effect = no_effect; }
Effect GetEffect() const { return m_Effect; }
#endif
float GetSecsIntoEffect() const { return m_fSecsIntoEffect; }
float GetEffectDelta() const { return m_fEffectDelta; }
// todo: account for SSC_FUTURES by adding an effect as an arg to each one -aj
void SetEffectColor1( RageColor c ) { m_effectColor1 = c; }
void SetEffectColor2( RageColor c ) { m_effectColor2 = c; }
void SetEffectPeriod( float fTime );
float GetEffectPeriod() const;
void SetEffectTiming( float fRampUp, float fAtHalf, float fRampDown, float fAtZero );
void SetEffectOffset( float fTime ) { m_fEffectOffset = fTime; }
void SetEffectClock( EffectClock c ) { m_EffectClock = c; }
void SetEffectClockString( const RString &s ); // convenience
void SetEffectMagnitude( RageVector3 vec ) { m_vEffectMagnitude = vec; }
RageVector3 GetEffectMagnitude() const { return m_vEffectMagnitude; }
void SetEffectDiffuseBlink(
float fEffectPeriodSeconds = 1.0f,
RageColor c1 = RageColor(0.5f,0.5f,0.5f,1),
RageColor c2 = RageColor(1,1,1,1) );
void SetEffectDiffuseShift( float fEffectPeriodSeconds = 1.f,
RageColor c1 = RageColor(0,0,0,1),
RageColor c2 = RageColor(1,1,1,1) );
void SetEffectDiffuseRamp( float fEffectPeriodSeconds = 1.f,
RageColor c1 = RageColor(0,0,0,1),
RageColor c2 = RageColor(1,1,1,1) );
void SetEffectGlowBlink( float fEffectPeriodSeconds = 1.f,
RageColor c1 = RageColor(1,1,1,0.2f),
RageColor c2 = RageColor(1,1,1,0.8f) );
void SetEffectGlowShift(
float fEffectPeriodSeconds = 1.0f,
RageColor c1 = RageColor(1,1,1,0.2f),
RageColor c2 = RageColor(1,1,1,0.8f) );
void SetEffectGlowRamp(
float fEffectPeriodSeconds = 1.0f,
RageColor c1 = RageColor(1,1,1,0.2f),
RageColor c2 = RageColor(1,1,1,0.8f) );
void SetEffectRainbow(
float fEffectPeriodSeconds = 2.0f );
void SetEffectWag(
float fPeriod = 2.f,
RageVector3 vect = RageVector3(0,0,20) );
void SetEffectBounce(
float fPeriod = 2.f,
RageVector3 vect = RageVector3(0,20,0) );
void SetEffectBob(
float fPeriod = 2.f,
RageVector3 vect = RageVector3(0,20,0) );
void SetEffectPulse(
float fPeriod = 2.f,
float fMinZoom = 0.5f,
float fMaxZoom = 1.f );
void SetEffectSpin( RageVector3 vect = RageVector3(0,0,180) );
void SetEffectVibrate( RageVector3 vect = RageVector3(10,10,10) );
// other properties
/**
* @brief Determine if the Actor is visible at this time.
* @return true if it's visible, false otherwise. */
bool GetVisible() const { return m_bVisible; }
void SetVisible( bool b ) { m_bVisible = b; }
void SetShadowLength( float fLength ) { m_fShadowLengthX = fLength; m_fShadowLengthY = fLength; }
void SetShadowLengthX( float fLengthX ) { m_fShadowLengthX = fLengthX; }
void SetShadowLengthY( float fLengthY ) { m_fShadowLengthY = fLengthY; }
void SetShadowColor( RageColor c ) { m_ShadowColor = c; }
// TODO: Implement hibernate as a tween type?
void SetHibernate( float fSecs ) { m_fHibernateSecondsLeft = fSecs; }
void SetDrawOrder( int iOrder ) { m_iDrawOrder = iOrder; }
int GetDrawOrder() const { return m_iDrawOrder; }
virtual void EnableAnimation( bool b ) { m_bIsAnimating = b; } // Sprite needs to overload this
void StartAnimating() { this->EnableAnimation(true); }
void StopAnimating() { this->EnableAnimation(false); }
// render states
void SetBlendMode( BlendMode mode ) { m_BlendMode = mode; }
void SetTextureWrapping( bool b ) { m_bTextureWrapping = b; }
void SetTextureFiltering( bool b ) { m_bTextureFiltering = 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 SetZWrite( bool b ) { m_bZWrite = b; }
void SetZBias( float f ) { m_fZBias = f; }
virtual void SetCullMode( CullMode mode ) { m_CullMode = mode; }
// Lua
virtual void PushSelf( lua_State *L );
virtual void PushContext( lua_State *L );
// Named commands
void AddCommand( const RString &sCmdName, apActorCommands apac );
bool HasCommand( const RString &sCmdName ) const;
const apActorCommands *GetCommand( const RString &sCommandName ) const;
void PlayCommand( const RString &sCommandName ) { HandleMessage( Message(sCommandName) ); } // convenience
void PlayCommandNoRecurse( const Message &msg );
// Commands by reference
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = NULL );
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommands( *cmds, pParamTable ); } // convenience
virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = NULL ) { RunCommands(cmds, pParamTable); }
// If we're a leaf, then execute this command.
virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = NULL ) { RunCommands(cmds, pParamTable); }
// Messages
virtual void HandleMessage( const Message &msg );
// Animation
virtual int GetNumStates() const { return 1; }
virtual void SetState( int iNewState ) {}
virtual float GetAnimationLengthSeconds() const { return 0; }
virtual void SetSecondsIntoAnimation( float fSeconds ) {}
virtual void SetUpdateRate( float fRate ) {}
HiddenPtr<LuaClass> m_pLuaInstance;
protected:
/** @brief the name of the Actor. */
RString m_sName;
/** @brief the current parent of this Actor if it exists. */
Actor *m_pParent;
/** @brief Some general information about the Tween. */
struct TweenInfo
{
// counters for tweening
TweenInfo();
~TweenInfo();
TweenInfo( const TweenInfo &cpy );
TweenInfo &operator=( const TweenInfo &rhs );
ITween *m_pTween;
/** @brief How far into the tween are we? */
float m_fTimeLeftInTween;
/** @brief The number of seconds between Start and End positions/zooms. */
float m_fTweenTime;
/** @brief The command to execute when this TweenState goes into effect. */
RString m_sCommandName;
};
RageVector3 m_baseRotation;
RageVector3 m_baseScale;
float m_fBaseAlpha;
RageVector2 m_size;
TweenState m_current;
TweenState m_start;
struct TweenStateAndInfo
{
TweenState state;
TweenInfo info;
};
vector<TweenStateAndInfo *> m_Tweens;
/** @brief Temporary variables that are filled just before drawing */
TweenState *m_pTempState;
bool m_bFirstUpdate;
// Stuff for alignment
/** @brief The particular horizontal alignment.
*
* Use the defined constant values for best effect. */
float m_fHorizAlign;
/** @brief The particular vertical alignment.
*
* Use the defined constant values for best effect. */
float m_fVertAlign;
// Stuff for effects
#if defined(SSC_FUTURES) // be able to stack effects
vector<Effect> m_Effects;
#else // compatibility
Effect m_Effect;
#endif
float m_fSecsIntoEffect;
float m_fEffectDelta;
// units depend on m_EffectClock
float m_fEffectRampUp;
float m_fEffectHoldAtHalf;
float m_fEffectRampDown;
float m_fEffectHoldAtZero;
float m_fEffectOffset;
EffectClock m_EffectClock;
/* This can be used in lieu of the fDeltaTime parameter to Update() to
* follow the effect clock. Actor::Update must be called first. */
float GetEffectDeltaTime() const { return m_fEffectDelta; }
// todo: account for SSC_FUTURES by having these be vectors too -aj
RageColor m_effectColor1;
RageColor m_effectColor2;
RageVector3 m_vEffectMagnitude;
// other properties
bool m_bVisible;
bool m_bIsAnimating;
float m_fHibernateSecondsLeft;
float m_fShadowLengthX;
float m_fShadowLengthY;
RageColor m_ShadowColor;
/** @brief The draw order priority.
*
* The lower this number is, the sooner it is drawn. */
int m_iDrawOrder;
// render states
BlendMode m_BlendMode;
ZTestMode m_ZTestMode;
CullMode m_CullMode;
bool m_bTextureWrapping;
bool m_bTextureFiltering;
bool m_bClearZBuffer;
bool m_bZWrite;
/**
* @brief The amount of bias.
*
* If 0, there is no bias. If 1, there is a full bias. */
float m_fZBias;
// global state
static float g_fCurrentBGMTime, g_fCurrentBGMBeat;
static float g_fCurrentBGMTimeNoOffset, g_fCurrentBGMBeatNoOffset;
static vector<float> g_vfCurrentBGMBeatPlayer;
static vector<float> g_vfCurrentBGMBeatPlayerNoOffset;
private:
// commands
map<RString, apActorCommands> m_mapNameToCommands;
};
#endif
/**
* @file
* @author Chris Danford (c) 2001-2004
* @section LICENSE
* 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.
*/
-633
View File
@@ -1,633 +0,0 @@
#include "global.h"
#include "ActorFrame.h"
#include "arch/Dialog/Dialog.h"
#include "RageUtil.h"
#include "RageLog.h"
#include "XmlFile.h"
#include "ActorUtil.h"
#include "LuaBinding.h"
#include "ActorUtil.h"
#include "RageDisplay.h"
#include "ScreenDimensions.h"
#include "Foreach.h"
/* Tricky: We need ActorFrames created in Lua to auto delete their children.
* We don't want classes that derive from ActorFrame to auto delete their
* children. The name "ActorFrame" is widely used in Lua, so we'll have
* that string instead create an ActorFrameAutoDeleteChildren object.
*/
//REGISTER_ACTOR_CLASS( ActorFrame );
REGISTER_ACTOR_CLASS_WITH_NAME( ActorFrameAutoDeleteChildren, ActorFrame );
ActorFrame *ActorFrame::Copy() const { return new ActorFrame(*this); }
ActorFrame::ActorFrame()
{
m_bPropagateCommands = false;
m_bDeleteChildren = false;
m_bDrawByZPosition = false;
m_DrawFunction.SetFromNil();
m_UpdateFunction.SetFromNil();
m_fUpdateRate = 1;
m_fFOV = -1;
m_fVanishX = SCREEN_CENTER_X;
m_fVanishY = SCREEN_CENTER_Y;
m_bOverrideLighting = false;
m_bLighting = false;
m_ambientColor = RageColor(1,1,1,1);
m_diffuseColor = RageColor(1,1,1,1);
m_specularColor = RageColor(1,1,1,1);
m_lightDirection = RageVector3(0,0,1);
}
ActorFrame::~ActorFrame()
{
if( m_bDeleteChildren )
DeleteAllChildren();
}
ActorFrame::ActorFrame( const ActorFrame &cpy ):
Actor( cpy )
{
#define CPY(x) this->x = cpy.x;
CPY( m_bPropagateCommands );
CPY( m_bDeleteChildren );
CPY( m_bDrawByZPosition );
CPY( m_DrawFunction );
CPY( m_UpdateFunction );
CPY( m_fUpdateRate );
CPY( m_fFOV );
CPY( m_fVanishX );
CPY( m_fVanishY );
CPY( m_bOverrideLighting );
CPY( m_bLighting );
CPY( m_ambientColor );
CPY( m_diffuseColor );
CPY( m_specularColor );
CPY( m_lightDirection );
#undef CPY
/* If m_bDeleteChildren, we own our children and it's up to us to copy
* them. If not, the derived class owns the children. This must preserve
* the current order of m_SubActors. */
if( m_bDeleteChildren )
{
for( unsigned i = 0; i < cpy.m_SubActors.size(); ++i )
{
Actor *pActor = cpy.m_SubActors[i]->Copy();
this->AddChild( pActor );
}
}
}
void ActorFrame::InitState()
{
FOREACH( Actor*, m_SubActors, a )
(*a)->InitState();
Actor::InitState();
}
void ActorFrame::LoadFromNode( const XNode* pNode )
{
if( AutoLoadChildren() )
LoadChildrenFromNode( pNode );
Actor::LoadFromNode( pNode );
pNode->GetAttrValue( "UpdateRate", m_fUpdateRate );
pNode->GetAttrValue( "FOV", m_fFOV );
pNode->GetAttrValue( "VanishX", m_fVanishX );
pNode->GetAttrValue( "VanishY", m_fVanishY );
m_bOverrideLighting = pNode->GetAttrValue( "Lighting", m_bLighting );
// new lighting values (only ambient color seems to work?) -aj
RString sTemp1,sTemp2,sTemp3;
pNode->GetAttrValue( "AmbientColor", sTemp1 );
m_ambientColor.FromString(sTemp1);
pNode->GetAttrValue( "DiffuseColor", sTemp2 );
m_diffuseColor.FromString(sTemp2);
pNode->GetAttrValue( "SpecularColor", sTemp3 );
m_specularColor.FromString(sTemp3);
// Values need to be converted into a RageVector3, so more work needs to be done...
//pNode->GetAttrValue( "LightDirection", m_lightDirection );
}
void ActorFrame::LoadChildrenFromNode( const XNode* pNode )
{
// Shouldn't be calling this unless we're going to delete our children.
ASSERT( m_bDeleteChildren );
// Load children
const XNode* pChildren = pNode->GetChild("children");
bool bArrayOnly = false;
if( pChildren == NULL )
{
bArrayOnly = true;
pChildren = pNode;
}
FOREACH_CONST_Child( pChildren, pChild )
{
if( bArrayOnly && !IsAnInt(pChild->GetName()) )
continue;
Actor* pChildActor = ActorUtil::LoadFromNode( pChild, this );
if( pChildActor )
AddChild( pChildActor );
}
SortByDrawOrder();
}
void ActorFrame::AddChild( Actor *pActor )
{
#ifdef DEBUG
// check that this Actor isn't already added.
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
if( iter != m_SubActors.end() )
Dialog::OK( ssprintf("Actor \"%s\" adds child \"%s\" more than once", GetLineage().c_str(), pActor->GetName().c_str()) );
#endif
ASSERT( pActor );
ASSERT( (void*)pActor != (void*)0xC0000005 );
m_SubActors.push_back( pActor );
pActor->SetParent( this );
}
void ActorFrame::RemoveChild( Actor *pActor )
{
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
if( iter != m_SubActors.end() )
m_SubActors.erase( iter );
}
void ActorFrame::TransferChildren( ActorFrame *pTo )
{
FOREACH( Actor*, m_SubActors, i )
pTo->AddChild( *i );
RemoveAllChildren();
}
Actor* ActorFrame::GetChild( const RString &sName )
{
FOREACH( Actor*, m_SubActors, a )
{
if( (*a)->GetName() == sName )
return *a;
}
return NULL;
}
void ActorFrame::RemoveAllChildren()
{
m_SubActors.clear();
}
void ActorFrame::MoveToTail( Actor* pActor )
{
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
if( iter == m_SubActors.end() ) // didn't find
{
ASSERT(0); // called with a pActor that doesn't exist
return;
}
m_SubActors.erase( iter );
m_SubActors.push_back( pActor );
}
void ActorFrame::MoveToHead( Actor* pActor )
{
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
if( iter == m_SubActors.end() ) // didn't find
{
ASSERT(0); // called with a pActor that doesn't exist
return;
}
m_SubActors.erase( iter );
m_SubActors.insert( m_SubActors.begin(), pActor );
}
void ActorFrame::BeginDraw()
{
Actor::BeginDraw();
if( m_fFOV != -1 )
{
DISPLAY->CameraPushMatrix();
DISPLAY->LoadMenuPerspective( m_fFOV, SCREEN_WIDTH, SCREEN_HEIGHT, m_fVanishX, m_fVanishY );
}
if( m_bOverrideLighting )
{
DISPLAY->SetLighting( m_bLighting );
if( m_bLighting )
DISPLAY->SetLightDirectional( 0,m_ambientColor,m_diffuseColor,m_specularColor,m_lightDirection );
}
}
void ActorFrame::DrawPrimitives()
{
ASSERT_M( !m_bClearZBuffer, "ClearZBuffer not supported on ActorFrames" );
// Don't set Actor-defined render states because we won't be drawing
// any geometry that belongs to this object.
// Actor::DrawPrimitives();
if( unlikely(!m_DrawFunction.IsNil()) )
{
Lua *L = LUA->Get();
m_DrawFunction.PushSelf( L );
ASSERT( !lua_isnil(L, -1) );
this->PushSelf( L );
RString sError;
if( !LuaHelpers::RunScriptOnStack(L, sError, 1, 0) ) // 1 arg, 0 results
LOG->Warn( "Error running DrawFunction: %s", sError.c_str() );
LUA->Release(L);
return;
}
// draw all sub-ActorFrames while we're in the ActorFrame's local coordinate space
if( m_bDrawByZPosition )
{
vector<Actor*> subs = m_SubActors;
ActorUtil::SortByZPosition( subs );
for( unsigned i=0; i<subs.size(); i++ )
subs[i]->Draw();
}
else
{
for( unsigned i=0; i<m_SubActors.size(); i++ )
m_SubActors[i]->Draw();
}
}
void ActorFrame::EndDraw()
{
if( m_bOverrideLighting )
{
// TODO: pop state instead of turning lighting off
DISPLAY->SetLightOff( 0 );
DISPLAY->SetLighting( false );
}
if( m_fFOV != -1 )
{
DISPLAY->CameraPopMatrix();
}
Actor::EndDraw();
}
void ActorFrame::PushChildrenTable( lua_State *L )
{
lua_newtable( L );
FOREACH( Actor*, m_SubActors, a )
{
LuaHelpers::Push( L, (*a)->GetName() );
(*a)->PushSelf( L );
lua_rawset( L, -3 );
}
}
void ActorFrame::PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable )
{
const apActorCommands *pCmd = GetCommand( sCommandName );
if( pCmd != NULL )
RunCommandsOnChildren( *pCmd, pParamTable );
}
void ActorFrame::PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable )
{
const apActorCommands *pCmd = GetCommand( sCommandName );
if( pCmd != NULL )
RunCommandsOnLeaves( **pCmd, pParamTable );
}
void ActorFrame::RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable )
{
for( unsigned i=0; i<m_SubActors.size(); i++ )
m_SubActors[i]->RunCommandsRecursively( cmds, pParamTable );
Actor::RunCommandsRecursively( cmds, pParamTable );
}
void ActorFrame::RunCommandsOnChildren( const LuaReference& cmds, const LuaReference *pParamTable )
{
for( unsigned i=0; i<m_SubActors.size(); i++ )
m_SubActors[i]->RunCommands( cmds, pParamTable );
}
void ActorFrame::RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable )
{
for( unsigned i=0; i<m_SubActors.size(); i++ )
m_SubActors[i]->RunCommandsOnLeaves( cmds, pParamTable );
}
void ActorFrame::UpdateInternal( float fDeltaTime )
{
// LOG->Trace( "ActorFrame::Update( %f )", fDeltaTime );
fDeltaTime *= m_fUpdateRate;
Actor::UpdateInternal( fDeltaTime );
// update all sub-Actors
for( vector<Actor*>::iterator it=m_SubActors.begin(); it!=m_SubActors.end(); it++ )
{
Actor *pActor = *it;
pActor->Update(fDeltaTime);
}
if( unlikely(!m_UpdateFunction.IsNil()) )
{
Lua *L = LUA->Get();
m_UpdateFunction.PushSelf( L );
ASSERT( !lua_isnil(L, -1) );
this->PushSelf( L );
lua_pushnumber( L, fDeltaTime );
RString sError;
if( !LuaHelpers::RunScriptOnStack(L, sError, 2, 0) ) // 1 args, 0 results
LOG->Warn( "Error running m_UpdateFunction: %s", sError.c_str() );
LUA->Release(L);
}
}
#define PropagateActorFrameCommand( cmd ) \
void ActorFrame::cmd() \
{ \
Actor::cmd(); \
\
/* set all sub-Actors */ \
for( unsigned i=0; i<m_SubActors.size(); i++ ) \
m_SubActors[i]->cmd(); \
}
#define PropagateActorFrameCommand1Param( cmd, type ) \
void ActorFrame::cmd( type f ) \
{ \
Actor::cmd( f ); \
\
/* set all sub-Actors */ \
for( unsigned i=0; i<m_SubActors.size(); i++ ) \
m_SubActors[i]->cmd( f ); \
}
PropagateActorFrameCommand( FinishTweening )
PropagateActorFrameCommand1Param( SetDiffuse, RageColor )
PropagateActorFrameCommand1Param( SetZTestMode, ZTestMode )
PropagateActorFrameCommand1Param( SetZWrite, bool )
PropagateActorFrameCommand1Param( HurryTweening, float )
PropagateActorFrameCommand1Param( SetDiffuseAlpha, float )
PropagateActorFrameCommand1Param( SetBaseAlpha, float )
float ActorFrame::GetTweenTimeLeft() const
{
float m = Actor::GetTweenTimeLeft();
for( unsigned i=0; i<m_SubActors.size(); i++ )
{
const Actor* pActor = m_SubActors[i];
m = max(m, m_fHibernateSecondsLeft + pActor->GetTweenTimeLeft());
}
return m;
}
static bool CompareActorsByDrawOrder(const Actor *p1, const Actor *p2)
{
return p1->GetDrawOrder() < p2->GetDrawOrder();
}
void ActorFrame::SortByDrawOrder()
{
// Preserve ordering of Actors with equal DrawOrders.
stable_sort( m_SubActors.begin(), m_SubActors.end(), CompareActorsByDrawOrder );
}
void ActorFrame::DeleteAllChildren()
{
for( unsigned i=0; i<m_SubActors.size(); i++ )
delete m_SubActors[i];
m_SubActors.clear();
}
void ActorFrame::RunCommands( const LuaReference& cmds, const LuaReference *pParamTable )
{
if( m_bPropagateCommands )
RunCommandsOnChildren( cmds, pParamTable );
else
Actor::RunCommands( cmds, pParamTable );
}
void ActorFrame::SetPropagateCommands( bool b )
{
m_bPropagateCommands = b;
}
void ActorFrame::HandleMessage( const Message &msg )
{
Actor::HandleMessage( msg );
/* Don't propagate broadcasts. They'll receive it directly if they're subscribed. */
if( msg.IsBroadcast() )
return;
for( unsigned i=0; i<m_SubActors.size(); i++ )
{
Actor* pActor = m_SubActors[i];
pActor->HandleMessage( msg );
}
}
void ActorFrame::SetDrawByZPosition( bool b )
{
m_bDrawByZPosition = b;
}
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the ActorFrame. */
class LunaActorFrame : public Luna<ActorFrame>
{
public:
static int playcommandonchildren( T* p, lua_State *L ) { p->PlayCommandOnChildren(SArg(1)); return 0; }
static int playcommandonleaves( T* p, lua_State *L ) { p->PlayCommandOnLeaves(SArg(1)); return 0; }
static int runcommandsonleaves( T* p, lua_State *L )
{
luaL_checktype( L, 1, LUA_TFUNCTION );
LuaReference cmds;
cmds.SetFromStack( L );
p->RunCommandsOnLeaves( cmds );
return 0;
}
static int RunCommandsOnChildren( T* p, lua_State *L )
{
luaL_checktype( L, 1, LUA_TFUNCTION );
lua_pushvalue( L, 2 );
LuaReference ParamTable;
ParamTable.SetFromStack( L );
lua_pushvalue( L, 1 );
LuaReference cmds;
cmds.SetFromStack( L );
p->RunCommandsOnChildren( cmds, &ParamTable );
return 0;
}
static int propagate( T* p, lua_State *L ) { p->SetPropagateCommands( BIArg(1) ); return 0; }
static int fov( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); return 0; }
static int SetUpdateRate( T* p, lua_State *L ) { p->SetUpdateRate( FArg(1) ); return 0; }
static int SetFOV( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); return 0; }
static int vanishpoint( T* p, lua_State *L ) { p->SetVanishPoint( FArg(1), FArg(2) ); return 0; }
static int GetChild( T* p, lua_State *L )
{
Actor *pChild = p->GetChild( SArg(1) );
if( pChild )
pChild->PushSelf( L );
else
lua_pushnil( L );
return 1;
}
static int GetChildren( T* p, lua_State *L )
{
p->PushChildrenTable( L );
return 1;
}
static int GetNumChildren( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumChildren() ); return 1; }
static int SetDrawByZPosition( T* p, lua_State *L ) { p->SetDrawByZPosition( BArg(1) ); return 1; }
static int SetDrawFunction( T* p, lua_State *L )
{
luaL_checktype( L, 1, LUA_TFUNCTION );
LuaReference ref;
lua_pushvalue( L, 1 );
ref.SetFromStack( L );
p->SetDrawFunction( ref );
return 0;
}
static int GetDrawFunction( T* p, lua_State *L )
{
p->GetDrawFunction().PushSelf(L);
return 1;
}
static int SetUpdateFunction( T* p, lua_State *L )
{
luaL_checktype( L, 1, LUA_TFUNCTION );
LuaReference ref;
lua_pushvalue( L, 1 );
ref.SetFromStack( L );
p->SetUpdateFunction( ref );
return 0;
}
static int SortByDrawOrder( T* p, lua_State *L ) { p->SortByDrawOrder(); return 0; }
//static int CustomLighting( T* p, lua_State *L ) { p->SetCustomLighting(BArg(1)); return 0; }
static int SetAmbientLightColor( T* p, lua_State *L ) { RageColor c; c.FromStackCompat( L, 1 ); p->SetAmbientLightColor( c ); return 0; }
static int SetDiffuseLightColor( T* p, lua_State *L ) { RageColor c; c.FromStackCompat( L, 1 ); p->SetDiffuseLightColor( c ); return 0; }
static int SetSpecularLightColor( T* p, lua_State *L ) { RageColor c; c.FromStackCompat( L, 1 ); p->SetSpecularLightColor( c ); return 0; }
static int SetLightDirection( T* p, lua_State *L )
{
luaL_checktype( L, 1, LUA_TTABLE );
lua_pushvalue( L, 1 );
vector<float> coords;
LuaHelpers::ReadArrayFromTable( coords, L );
lua_pop( L, 1 );
if( coords.size() !=3 )
{
//error
}
RageVector3 vTmp = RageVector3( coords[0], coords[1], coords[2] );
p->SetLightDirection( vTmp );
return 0;
}
static int AddChildFromPath( T* p, lua_State *L )
{
// this one is tricky, we need to get an Actor from Lua.
Actor *pActor = ActorUtil::MakeActor( SArg(1) );
if ( pActor == NULL )
{
lua_pushboolean( L, 0 );
return 1;
}
p->AddChild( pActor );
lua_pushboolean( L, 1 );
return 1;
}
static int RemoveChild( T* p, lua_State *L )
{
Actor *pChild = p->GetChild( SArg(1) );
if( pChild )
p->RemoveChild( pChild );
else
lua_pushnil( L );
return 1;
}
static int RemoveAllChildren( T* p, lua_State *L ) { p->RemoveAllChildren( ); return 0; }
LunaActorFrame()
{
ADD_METHOD( playcommandonchildren );
ADD_METHOD( playcommandonleaves );
ADD_METHOD( runcommandsonleaves );
ADD_METHOD( RunCommandsOnChildren );
ADD_METHOD( propagate ); // deprecated
ADD_METHOD( fov );
ADD_METHOD( SetUpdateRate );
ADD_METHOD( SetFOV );
ADD_METHOD( vanishpoint );
ADD_METHOD( GetChild );
ADD_METHOD( GetChildren );
ADD_METHOD( GetNumChildren );
ADD_METHOD( SetDrawByZPosition );
ADD_METHOD( SetDrawFunction );
ADD_METHOD( GetDrawFunction );
ADD_METHOD( SetUpdateFunction );
ADD_METHOD( SortByDrawOrder );
//ADD_METHOD( CustomLighting );
ADD_METHOD( SetAmbientLightColor );
ADD_METHOD( SetDiffuseLightColor );
ADD_METHOD( SetSpecularLightColor );
ADD_METHOD( SetLightDirection );
ADD_METHOD( AddChildFromPath );
ADD_METHOD( RemoveChild );
ADD_METHOD( RemoveAllChildren );
}
};
LUA_REGISTER_DERIVED_CLASS( ActorFrame, Actor )
// lua end
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-164
View File
@@ -1,164 +0,0 @@
#ifndef ACTORFRAME_H
#define ACTORFRAME_H
#include "Actor.h"
/** @brief A container for other Actors. */
class ActorFrame : public Actor
{
public:
ActorFrame();
ActorFrame( const ActorFrame &cpy );
virtual ~ActorFrame();
/** @brief Set up the initial state. */
virtual void InitState();
void LoadFromNode( const XNode* pNode );
virtual ActorFrame *Copy() const;
/**
* @brief Add a new child to the ActorFrame.
* @param pActor the new Actor to add. */
virtual void AddChild( Actor *pActor );
/**
* @brief Remove the specified child from the ActorFrame.
* @param pActor the Actor to remove. */
virtual void RemoveChild( Actor *pActor );
void TransferChildren( ActorFrame *pTo );
Actor* GetChild( const RString &sName );
vector<Actor*> GetChildren() { return m_SubActors; }
int GetNumChildren() const { return m_SubActors.size(); }
/** @brief Remove all of the children from the frame. */
void RemoveAllChildren();
/**
* @brief Move a particular actor to the tail.
* @param pActor the actor to go to the tail.
*/
void MoveToTail( Actor* pActor );
/**
* @brief Move a particular actor to the head.
* @param pActor the actor to go to the head.
*/
void MoveToHead( Actor* pActor );
void SortByDrawOrder();
void SetDrawByZPosition( bool b );
void SetDrawFunction( const LuaReference &DrawFunction ) { m_DrawFunction = DrawFunction; }
void SetUpdateFunction( const LuaReference &UpdateFunction ) { m_UpdateFunction = UpdateFunction; }
LuaReference GetDrawFunction() const { return m_DrawFunction; }
virtual bool AutoLoadChildren() const { return false; } // derived classes override to automatically LoadChildrenFromNode
void DeleteChildrenWhenDone( bool bDelete=true ) { m_bDeleteChildren = bDelete; }
void DeleteAllChildren();
// Commands
virtual void PushSelf( lua_State *L );
void PushChildrenTable( lua_State *L );
void PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable = NULL );
void PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable = NULL );
virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = NULL );
virtual void RunCommandsOnChildren( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); /* but not on self */
void RunCommandsOnChildren( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommandsOnChildren( *cmds, pParamTable ); } // convenience
virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); /* but not on self */
virtual void UpdateInternal( float fDeltaTime );
virtual void BeginDraw();
virtual void DrawPrimitives();
virtual void EndDraw();
// propagated commands
virtual void SetDiffuse( RageColor c );
virtual void SetDiffuseAlpha( float f );
virtual void SetBaseAlpha( float f );
virtual void SetZTestMode( ZTestMode mode );
virtual void SetZWrite( bool b );
virtual void FinishTweening();
virtual void HurryTweening( float factor );
void SetUpdateRate( float fUpdateRate ) { m_fUpdateRate = fUpdateRate; }
void SetFOV( float fFOV ) { m_fFOV = fFOV; }
void SetVanishPoint( float fX, float fY) { m_fVanishX = fX; m_fVanishY = fY; }
void SetCustomLighting( bool bCustomLighting ) { m_bOverrideLighting = bCustomLighting; }
void SetAmbientLightColor( RageColor c ) { m_ambientColor = c; }
void SetDiffuseLightColor( RageColor c ) { m_diffuseColor = c; }
void SetSpecularLightColor( RageColor c ) { m_specularColor = c; }
void SetLightDirection( RageVector3 vec ) { m_lightDirection = vec; }
virtual void SetPropagateCommands( bool b );
/** @brief Amount of time until all tweens (and all children's tweens) have stopped: */
virtual float GetTweenTimeLeft() const;
virtual void HandleMessage( const Message &msg );
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = NULL );
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommands( *cmds, pParamTable ); } // convenience
protected:
void LoadChildrenFromNode( const XNode* pNode );
/** @brief The children Actors used by the ActorFrame. */
vector<Actor*> m_SubActors;
bool m_bPropagateCommands;
bool m_bDeleteChildren;
bool m_bDrawByZPosition;
LuaReference m_UpdateFunction;
LuaReference m_DrawFunction;
// state effects
float m_fUpdateRate;
float m_fFOV; // -1 = no change
float m_fVanishX;
float m_fVanishY;
/**
* @brief A flad to see if an override for the lighting is needed.
*
* If true, set lightning to m_bLightning. */
bool m_bOverrideLighting;
bool m_bLighting;
// lighting variables
RageColor m_ambientColor;
RageColor m_diffuseColor;
RageColor m_specularColor;
RageVector3 m_lightDirection;
};
/** @brief an ActorFrame that handles deleting children Actors automatically. */
class ActorFrameAutoDeleteChildren : public ActorFrame
{
public:
ActorFrameAutoDeleteChildren() { DeleteChildrenWhenDone(true); }
virtual bool AutoLoadChildren() const { return true; }
virtual ActorFrameAutoDeleteChildren *Copy() const;
};
#endif
/**
* @file
* @author Chris Danford (c) 2001-2004
* @section LICENSE
* 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.
*/
-127
View File
@@ -1,127 +0,0 @@
#include "global.h"
#include "ActorFrameTexture.h"
#include "RageTextureRenderTarget.h"
#include "RageTextureManager.h"
#include "ActorUtil.h"
REGISTER_ACTOR_CLASS_WITH_NAME( ActorFrameTextureAutoDeleteChildren, ActorFrameTexture );
ActorFrameTexture *ActorFrameTexture::Copy() const { return new ActorFrameTexture(*this); }
ActorFrameTexture::ActorFrameTexture()
{
m_bDepthBuffer = false;
m_bAlphaBuffer = false;
m_bFloat = false;
m_bPreserveTexture = false;
static uint64_t i = 0;
++i;
m_sTextureName = ssprintf( ConvertI64FormatString("ActorFrameTexture %lli"), i );
m_pRenderTarget = NULL;
}
ActorFrameTexture::ActorFrameTexture( const ActorFrameTexture &cpy ):
ActorFrame(cpy)
{
FAIL_M( "ActorFrameTexture copy not implemented" );
}
ActorFrameTexture::~ActorFrameTexture()
{
/* Release our reference to the texture. */
TEXTUREMAN->UnloadTexture( m_pRenderTarget );
}
void ActorFrameTexture::Create()
{
ASSERT( m_pRenderTarget == NULL );
RageTextureID id( m_sTextureName );
id.Policy = RageTextureID::TEX_VOLATILE;
RenderTargetParam param;
param.bWithDepthBuffer = m_bDepthBuffer;
param.bWithAlpha = m_bAlphaBuffer;
param.bFloat = m_bFloat;
param.iWidth = (int) m_size.x;
param.iHeight = (int) m_size.y;
m_pRenderTarget = new RageTextureRenderTarget( id, param );
m_pRenderTarget->m_bWasUsed = true;
/* This passes ownership of m_pRenderTarget to TEXTUREMAN, but we retain
* our reference to it until we call TEXTUREMAN->UnloadTexture. */
TEXTUREMAN->RegisterTexture( id, m_pRenderTarget );
}
void ActorFrameTexture::DrawPrimitives()
{
if( m_pRenderTarget == NULL )
return;
m_pRenderTarget->BeginRenderingTo( m_bPreserveTexture );
ActorFrame::DrawPrimitives();
m_pRenderTarget->FinishRenderingTo();
}
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the ActorFrameTexture. */
class LunaActorFrameTexture : public Luna<ActorFrameTexture>
{
public:
static int Create( T* p, lua_State *L ) { p->Create(); return 0; }
static int EnableDepthBuffer( T* p, lua_State *L ) { p->EnableDepthBuffer(BArg(1)); return 0; }
static int EnableAlphaBuffer( T* p, lua_State *L ) { p->EnableAlphaBuffer(BArg(1)); return 0; }
static int EnableFloat( T* p, lua_State *L ) { p->EnableFloat(BArg(1)); return 0; }
static int EnablePreserveTexture( T* p, lua_State *L ) { p->EnablePreserveTexture(BArg(1)); return 0; }
static int SetTextureName( T* p, lua_State *L ) { p->SetTextureName(SArg(1)); return 0; }
static int GetTexture( T* p, lua_State *L )
{
RageTexture *pTexture = p->GetTexture();
if( pTexture == NULL )
return 0;
pTexture->PushSelf(L);
return 1;
}
LunaActorFrameTexture()
{
ADD_METHOD( Create );
ADD_METHOD( EnableDepthBuffer );
ADD_METHOD( EnableAlphaBuffer );
ADD_METHOD( EnableFloat );
ADD_METHOD( EnablePreserveTexture );
ADD_METHOD( SetTextureName );
ADD_METHOD( GetTexture );
}
};
LUA_REGISTER_DERIVED_CLASS( ActorFrameTexture, ActorFrame )
// lua end
/*
* (c) 2006 Glenn Maynard
* 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.
*/
-88
View File
@@ -1,88 +0,0 @@
#ifndef ACTOR_FRAME_TEXTURE_H
#define ACTOR_FRAME_TEXTURE_H
#include "ActorFrame.h"
class RageTextureRenderTarget;
class ActorFrameTexture: public ActorFrame
{
public:
ActorFrameTexture();
ActorFrameTexture( const ActorFrameTexture &cpy );
virtual ~ActorFrameTexture();
virtual ActorFrameTexture *Copy() const;
/**
* @brief Set the texture name.
*
* This can be used with RageTextureManager (and users, eg. Sprite)
* to load the texture. If no name is supplied, a unique one will
* be generated. In that case, the only way to access the texture
* is via GetTextureName.
* @param sName the new name. */
void SetTextureName( const RString &sName ) { m_sTextureName = sName; }
/**
* @brief Retrieve the texture name.
* @return the texture name. */
RString GetTextureName() const { return m_sTextureName; }
RageTextureRenderTarget *GetTexture() { return m_pRenderTarget; }
void EnableDepthBuffer( bool b ) { m_bDepthBuffer = b; }
void EnableAlphaBuffer( bool b ) { m_bAlphaBuffer = b; }
void EnableFloat( bool b ) { m_bFloat = b; }
void EnablePreserveTexture( bool b ) { m_bPreserveTexture = b; }
void Create();
virtual void DrawPrimitives();
// Commands
virtual void PushSelf( lua_State *L );
private:
RageTextureRenderTarget *m_pRenderTarget;
bool m_bDepthBuffer;
bool m_bAlphaBuffer;
bool m_bFloat;
bool m_bPreserveTexture;
/** @brief the name of this ActorFrameTexture. */
RString m_sTextureName;
};
class ActorFrameTextureAutoDeleteChildren : public ActorFrameTexture
{
public:
ActorFrameTextureAutoDeleteChildren() { DeleteChildrenWhenDone(true); }
virtual bool AutoLoadChildren() const { return true; }
virtual ActorFrameTextureAutoDeleteChildren *Copy() const;
};
#endif
/**
* @file
* @author Glenn Maynard (c) 2006
* @section LICENSE
* 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.
*/
-215
View File
@@ -1,215 +0,0 @@
#include "global.h"
#include <cassert>
#include "ActorMultiTexture.h"
#include "RageTextureManager.h"
#include "XmlFile.h"
#include "RageLog.h"
#include "RageDisplay.h"
#include "RageTexture.h"
#include "RageUtil.h"
#include "ActorUtil.h"
#include "Foreach.h"
#include "LuaBinding.h"
#include "LuaManager.h"
REGISTER_ACTOR_CLASS( ActorMultiTexture );
ActorMultiTexture::ActorMultiTexture()
{
m_EffectMode = EffectMode_Normal;
}
ActorMultiTexture::~ActorMultiTexture()
{
ClearTextures();
}
ActorMultiTexture::ActorMultiTexture( const ActorMultiTexture &cpy ):
Actor( cpy )
{
#define CPY(a) a = cpy.a
CPY( m_Rect );
CPY( m_aTextureUnits );
#undef CPY
FOREACH( TextureUnitState, m_aTextureUnits, tex )
tex->m_pTexture = TEXTUREMAN->CopyTexture( tex->m_pTexture );
}
void ActorMultiTexture::SetTextureCoords( const RectF &r )
{
m_Rect = r;
}
void ActorMultiTexture::LoadFromNode( const XNode* pNode )
{
m_Rect = RectF( 0, 0, 1, 1 );
Actor::LoadFromNode( pNode );
}
void ActorMultiTexture::SetSizeFromTexture( RageTexture *pTexture )
{
ActorMultiTexture::m_size.x = pTexture->GetSourceWidth();
ActorMultiTexture::m_size.y = pTexture->GetSourceHeight();
}
void ActorMultiTexture::ClearTextures()
{
FOREACH( TextureUnitState, m_aTextureUnits, tex )
TEXTUREMAN->UnloadTexture( tex->m_pTexture );
m_aTextureUnits.clear();
}
int ActorMultiTexture::AddTexture( RageTexture *pTexture )
{
ASSERT( pTexture != NULL );
LOG->Trace( "ActorMultiTexture::AddTexture( %s )", pTexture->GetID().filename.c_str() );
m_aTextureUnits.push_back( TextureUnitState() );
m_aTextureUnits.back().m_pTexture = TEXTUREMAN->CopyTexture( pTexture );
return m_aTextureUnits.size() - 1;
}
void ActorMultiTexture::SetTextureMode( int iIndex, TextureMode tm )
{
ASSERT( iIndex < (int) m_aTextureUnits.size() );
m_aTextureUnits[iIndex].m_TextureMode = tm;
}
void ActorMultiTexture::DrawPrimitives()
{
Actor::SetGlobalRenderStates(); // set Actor-specified render states
RectF quadVerticies;
quadVerticies.left = -m_size.x/2.0f;
quadVerticies.right = +m_size.x/2.0f;
quadVerticies.top = -m_size.y/2.0f;
quadVerticies.bottom = +m_size.y/2.0f;
DISPLAY->ClearAllTextures();
for( size_t i = 0; i < m_aTextureUnits.size(); ++i )
{
TextureUnit tu = enum_add2(TextureUnit_1, i);
DISPLAY->SetTexture( tu, m_aTextureUnits[i].m_pTexture->GetTexHandle() );
DISPLAY->SetTextureWrapping( tu, m_bTextureWrapping );
DISPLAY->SetTextureMode( tu, m_aTextureUnits[i].m_TextureMode );
}
DISPLAY->SetEffectMode( m_EffectMode );
static RageSpriteVertex v[4];
v[0].p = RageVector3( quadVerticies.left, quadVerticies.top, 0 ); // top left
v[1].p = RageVector3( quadVerticies.left, quadVerticies.bottom, 0 ); // bottom left
v[2].p = RageVector3( quadVerticies.right, quadVerticies.bottom, 0 ); // bottom right
v[3].p = RageVector3( quadVerticies.right, quadVerticies.top, 0 ); // top right
const RectF *pTexCoordRect = &m_Rect;
v[0].t = RageVector2( pTexCoordRect->left, pTexCoordRect->top ); // top left
v[1].t = RageVector2( pTexCoordRect->left, pTexCoordRect->bottom ); // bottom left
v[2].t = RageVector2( pTexCoordRect->right, pTexCoordRect->bottom ); // bottom right
v[3].t = RageVector2( pTexCoordRect->right, pTexCoordRect->top ); // top right
v[0].c = m_pTempState->diffuse[0]; // top left
v[1].c = m_pTempState->diffuse[2]; // bottom left
v[2].c = m_pTempState->diffuse[3]; // bottom right
v[3].c = m_pTempState->diffuse[1]; // top right
DISPLAY->DrawQuad( v );
for( size_t i = 0; i < m_aTextureUnits.size(); ++i )
DISPLAY->SetTexture( enum_add2(TextureUnit_1, i), 0 );
DISPLAY->SetEffectMode( EffectMode_Normal );
}
bool ActorMultiTexture::EarlyAbortDraw() const
{
return m_aTextureUnits.empty();
}
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the ActorMultiTexture. */
class LunaActorMultiTexture: public Luna<ActorMultiTexture>
{
public:
static int ClearTextures( T* p, lua_State *L )
{
p->ClearTextures();
return 0;
}
static int AddTexture( T* p, lua_State *L )
{
RageTexture *pTexture = Luna<RageTexture>::check(L, 1);
int iRet = p->AddTexture( pTexture );
lua_pushinteger( L, iRet );
return 1;
}
static int SetTextureMode( T* p, lua_State *L )
{
int iIndex = IArg(1);
TextureMode tm = Enum::Check<TextureMode>(L, 2);
p->SetTextureMode( iIndex, tm );
return 0;
}
static int SetTextureCoords( T* p, lua_State *L )
{
p->SetTextureCoords( RectF(FArg(1), FArg(2), FArg(3), FArg(4)) );
return 0;
}
static int SetSizeFromTexture( T* p, lua_State *L )
{
RageTexture *pTexture = Luna<RageTexture>::check(L, 1);
p->SetSizeFromTexture( pTexture );
return 0;
}
static int SetEffectMode( T* p, lua_State *L )
{
EffectMode em = Enum::Check<EffectMode>(L, 1);
p->SetEffectMode( em );
return 0;
}
LunaActorMultiTexture()
{
ADD_METHOD( ClearTextures );
ADD_METHOD( AddTexture );
ADD_METHOD( SetTextureMode );
ADD_METHOD( SetTextureCoords );
ADD_METHOD( SetSizeFromTexture );
ADD_METHOD( SetEffectMode );
}
};
LUA_REGISTER_DERIVED_CLASS( ActorMultiTexture, Actor )
// lua end
/*
* (c) 2001-2007 Glenn Maynard, 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.
*/
-73
View File
@@ -1,73 +0,0 @@
/** @brief ActorMultiTexture - A texture created from multiple textures. */
#ifndef ACTOR_MULTI_TEXTURE_H
#define ACTOR_MULTI_TEXTURE_H
#include "Actor.h"
#include "RageDisplay.h"
class RageTexture;
class ActorMultiTexture: public Actor
{
public:
ActorMultiTexture();
ActorMultiTexture( const ActorMultiTexture &cpy );
virtual ~ActorMultiTexture();
void LoadFromNode( const XNode* pNode );
virtual ActorMultiTexture *Copy() const;
virtual bool EarlyAbortDraw() const;
virtual void DrawPrimitives();
void ClearTextures();
int AddTexture( RageTexture *pTexture );
void SetTextureMode( int iIndex, TextureMode tm );
void SetSizeFromTexture( RageTexture *pTexture );
void SetTextureCoords( const RectF &r );
void SetEffectMode( EffectMode em ) { m_EffectMode = em; }
virtual void PushSelf( lua_State *L );
private:
EffectMode m_EffectMode;
struct TextureUnitState
{
TextureUnitState(): m_pTexture(NULL), m_TextureMode(TextureMode_Modulate) {}
RageTexture *m_pTexture;
TextureMode m_TextureMode;
};
vector<TextureUnitState> m_aTextureUnits;
RectF m_Rect;
};
#endif
/**
* @file
* @author Chris Danford (c) 2001-2004
* @section LICENSE
* 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.
*/
-90
View File
@@ -1,90 +0,0 @@
#include "global.h"
#include "ActorProxy.h"
#include "ActorUtil.h"
REGISTER_ACTOR_CLASS( ActorProxy );
ActorProxy::ActorProxy()
{
m_pActorTarget = NULL;
}
bool ActorProxy::EarlyAbortDraw() const
{
return m_pActorTarget == NULL || Actor::EarlyAbortDraw();
}
void ActorProxy::DrawPrimitives()
{
if( m_pActorTarget != NULL )
{
bool bVisible = m_pActorTarget->GetVisible();
m_pActorTarget->SetVisible( true );
m_pActorTarget->Draw();
m_pActorTarget->SetVisible( bVisible );
}
}
void ActorProxy::LoadFromNode( const XNode* pNode )
{
Actor::LoadFromNode( pNode );
}
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the ActorProxy. */
class LunaActorProxy: public Luna<ActorProxy>
{
public:
static int SetTarget( T* p, lua_State *L )
{
Actor *pTarget = Luna<Actor>::check( L, 1 );
p->SetTarget( pTarget );
return 0;
}
static int GetTarget( T* p, lua_State *L )
{
Actor *pTarget = p->GetTarget();
if( pTarget != NULL )
pTarget->PushSelf( L );
else
lua_pushnil( L );
return 1;
}
LunaActorProxy()
{
ADD_METHOD( SetTarget );
ADD_METHOD( GetTarget );
}
};
LUA_REGISTER_DERIVED_CLASS( ActorProxy, Actor )
// lua end
/*
* (c) 2006 Glenn Maynard
* 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.
*/
-54
View File
@@ -1,54 +0,0 @@
#ifndef ACTOR_PROXY_H
#define ACTOR_PROXY_H
#include "Actor.h"
struct lua_State;
/** @brief Renders another actor. */
class ActorProxy: public Actor
{
public:
ActorProxy();
virtual bool EarlyAbortDraw() const;
virtual void DrawPrimitives();
void LoadFromNode( const XNode* pNode );
virtual ActorProxy *Copy() const;
Actor *GetTarget() { return m_pActorTarget; }
void SetTarget( Actor *pTarget ) { m_pActorTarget = pTarget; }
// Lua
virtual void PushSelf( lua_State *L );
private:
Actor *m_pActorTarget;
};
#endif
/*
* (c) 2006 Glenn Maynard
* 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.
*/
-397
View File
@@ -1,397 +0,0 @@
#include "global.h"
#include "ActorScroller.h"
#include "Foreach.h"
#include "RageUtil.h"
#include "XmlFile.h"
#include "arch/Dialog/Dialog.h"
#include "RageLog.h"
#include "ActorUtil.h"
#include "LuaBinding.h"
/* Tricky: We need ActorFrames created in Lua to auto delete their children.
* We don't want classes that derive from ActorFrame to auto delete their
* children. The name "ActorFrame" is widely used in Lua, so we'll have
* that string instead create an ActorFrameAutoDeleteChildren object. */
//REGISTER_ACTOR_CLASS( ActorScroller );
REGISTER_ACTOR_CLASS_WITH_NAME( ActorScrollerAutoDeleteChildren, ActorScroller );
ActorScroller *ActorScroller::Copy() const { return new ActorScroller(*this); }
ActorScroller::ActorScroller()
{
m_iNumItems = 0;
m_fCurrentItem = 0;
m_fDestinationItem = 0;
m_fSecondsPerItem = 1;
m_fSecondsPauseBetweenItems = 0;
m_fNumItemsToDraw = 7;
m_iFirstSubActorIndex = 0;
m_bLoop = false;
m_bFastCatchup = false;
m_bFunctionDependsOnPositionOffset = true;
m_bFunctionDependsOnItemIndex = true;
m_fPauseCountdownSeconds = 0;
m_fQuantizePixels = 0;
m_quadMask.SetBlendMode( BLEND_NO_EFFECT ); // don't change color values
m_quadMask.SetUseZBuffer( true ); // we want to write to the Zbuffer
m_fMaskWidth = 0;
m_fMaskHeight = 0;
DisableMask();
}
void ActorScroller::Load2()
{
m_iNumItems = m_SubActors.size();
Lua *L = LUA->Get();
for( unsigned i = 0; i < m_SubActors.size(); ++i )
{
lua_pushnumber( L, i );
this->m_SubActors[i]->m_pLuaInstance->Set( L, "ItemIndex" );
}
LUA->Release( L );
}
void ActorScroller::SetTransformFromReference( const LuaReference &ref )
{
m_exprTransformFunction.SetFromReference( ref );
// Probe to find which of the parameters are used.
#define GP(a,b) m_exprTransformFunction.GetTransformCached( a, b, 2 )
m_bFunctionDependsOnPositionOffset = (GP(0,0) != GP(1,0)) && (GP(0,1) != GP(1,1));
m_bFunctionDependsOnItemIndex = (GP(0,0) != GP(0,1)) && (GP(1,0) != GP(1,1));
m_exprTransformFunction.ClearCache();
}
void ActorScroller::SetTransformFromExpression( const RString &sTransformFunction )
{
LuaReference ref;
ref.SetFromExpression( sTransformFunction );
SetTransformFromReference( ref );
}
void ActorScroller::SetTransformFromWidth( float fItemWidth )
{
SetTransformFromExpression( ssprintf("function(self,offset,itemIndex,numItems) self:x(%f*offset) end",fItemWidth) );
}
void ActorScroller::SetTransformFromHeight( float fItemHeight )
{
SetTransformFromExpression( ssprintf("function(self,offset,itemIndex,numItems) self:y(%f*offset) end",fItemHeight) );
}
void ActorScroller::EnableMask( float fWidth, float fHeight )
{
m_quadMask.SetVisible( fWidth != 0 && fHeight != 0 );
m_quadMask.SetWidth( fWidth );
m_fMaskWidth = fWidth;
m_quadMask.SetHeight( fHeight );
m_fMaskHeight = fHeight;
}
void ActorScroller::DisableMask()
{
m_quadMask.SetVisible( false );
}
void ActorScroller::ScrollThroughAllItems()
{
m_fCurrentItem = m_bLoop ? +m_fNumItemsToDraw/2.0f : -(m_fNumItemsToDraw/2.0f)-1;
m_fDestinationItem = (float)(m_iNumItems+m_fNumItemsToDraw/2.0f+1);
}
void ActorScroller::ScrollWithPadding( float fItemPaddingStart, float fItemPaddingEnd )
{
m_fCurrentItem = -fItemPaddingStart;
m_fDestinationItem = m_iNumItems-1+fItemPaddingEnd;
}
float ActorScroller::GetSecondsForCompleteScrollThrough() const
{
float fTotalItems = m_fNumItemsToDraw + m_iNumItems;
return fTotalItems * (m_fSecondsPerItem + m_fSecondsPauseBetweenItems );
}
float ActorScroller::GetSecondsToDestination() const
{
float fTotalItemsToMove = fabsf(m_fCurrentItem - m_fDestinationItem);
return fTotalItemsToMove * m_fSecondsPerItem;
}
void ActorScroller::LoadFromNode( const XNode *pNode )
{
ActorFrame::LoadFromNode( pNode );
Load2();
float fNumItemsToDraw = 0;
if( pNode->GetAttrValue("NumItemsToDraw", fNumItemsToDraw) )
SetNumItemsToDraw( fNumItemsToDraw );
float fSecondsPerItem = 0;
if( pNode->GetAttrValue("SecondsPerItem", fSecondsPerItem) )
ActorScroller::SetSecondsPerItem( fSecondsPerItem );
Lua *L = LUA->Get();
pNode->PushAttrValue( L, "TransformFunction" );
{
LuaReference ref;
ref.SetFromStack( L );
if( !ref.IsNil() )
SetTransformFromReference( ref );
}
LUA->Release( L );
int iSubdivisions = 1;
if( pNode->GetAttrValue("Subdivisions", iSubdivisions) )
ActorScroller::SetNumSubdivisions( iSubdivisions );
bool bUseMask = false;
pNode->GetAttrValue( "UseMask", bUseMask );
if( bUseMask )
{
pNode->GetAttrValue( "MaskWidth", m_fMaskWidth );
pNode->GetAttrValue( "MaskHeight", m_fMaskHeight );
EnableMask( m_fMaskWidth, m_fMaskHeight );
}
pNode->GetAttrValue( "QuantizePixels", m_fQuantizePixels );
}
void ActorScroller::UpdateInternal( float fDeltaTime )
{
ActorFrame::UpdateInternal( fDeltaTime );
// If we have no children, the code below will busy loop.
if( !m_SubActors.size() )
return;
// handle pause
if( fDeltaTime > m_fPauseCountdownSeconds )
{
fDeltaTime -= m_fPauseCountdownSeconds;
m_fPauseCountdownSeconds = 0;
}
else
{
m_fPauseCountdownSeconds -= fDeltaTime;
fDeltaTime = 0;
return;
}
if( m_fCurrentItem == m_fDestinationItem )
return; // done scrolling
float fOldItemAtTop = m_fCurrentItem;
if( m_fSecondsPerItem > 0 )
{
float fApproachSpeed = fDeltaTime/m_fSecondsPerItem;
if( m_bFastCatchup )
{
float fDistanceToMove = fabsf(m_fCurrentItem - m_fDestinationItem);
if( fDistanceToMove > 1 )
fApproachSpeed *= fDistanceToMove*fDistanceToMove;
}
fapproach( m_fCurrentItem, m_fDestinationItem, fApproachSpeed );
}
// if items changed, then pause
if( (int)fOldItemAtTop != (int)m_fCurrentItem )
m_fPauseCountdownSeconds = m_fSecondsPauseBetweenItems;
if( m_bLoop )
m_fCurrentItem = fmodf( m_fCurrentItem, (float) m_iNumItems );
}
void ActorScroller::DrawPrimitives()
{
PositionItemsAndDrawPrimitives( true );
}
void ActorScroller::PositionItems()
{
PositionItemsAndDrawPrimitives( false );
}
/* Shift m_SubActors forward by iDist. This will place item m_iFirstSubActorIndex
* in m_SubActors[0]. */
void ActorScroller::ShiftSubActors( int iDist )
{
if( iDist != INT_MAX )
CircularShift( m_SubActors, iDist );
}
void ActorScroller::PositionItemsAndDrawPrimitives( bool bDrawPrimitives )
{
if( m_SubActors.empty() )
return;
float fNumItemsToDraw = m_fNumItemsToDraw;
if( m_quadMask.GetVisible() )
{
// write to z buffer so that top and bottom are clipped
// Draw an extra item; this is the one that will be masked.
fNumItemsToDraw++;
float fPositionFullyOffScreenTop = -(fNumItemsToDraw)/2.f;
float fPositionFullyOffScreenBottom = (fNumItemsToDraw)/2.f;
m_exprTransformFunction.TransformItemCached( m_quadMask, fPositionFullyOffScreenTop, -1, m_iNumItems );
if( bDrawPrimitives ) m_quadMask.Draw();
m_exprTransformFunction.TransformItemCached( m_quadMask, fPositionFullyOffScreenBottom, m_iNumItems, m_iNumItems );
if( bDrawPrimitives ) m_quadMask.Draw();
}
float fFirstItemToDraw = m_fCurrentItem - fNumItemsToDraw/2.f;
float fLastItemToDraw = m_fCurrentItem + fNumItemsToDraw/2.f;
int iFirstItemToDraw = (int) ceilf( fFirstItemToDraw );
int iLastItemToDraw = (int) ceilf( fLastItemToDraw );
if( !m_bLoop )
{
iFirstItemToDraw = clamp( iFirstItemToDraw, 0, m_iNumItems );
iLastItemToDraw = clamp( iLastItemToDraw, 0, m_iNumItems );
}
bool bDelayedDraw = m_bDrawByZPosition && !m_bLoop;
vector<Actor*> subs;
{
// Shift m_SubActors so iFirstItemToDraw is at the beginning.
int iNewFirstIndex = iFirstItemToDraw;
int iDist = iNewFirstIndex - m_iFirstSubActorIndex;
m_iFirstSubActorIndex = iNewFirstIndex;
ShiftSubActors( iDist );
}
int iNumToDraw = iLastItemToDraw - iFirstItemToDraw;
for( int i = 0; i < iNumToDraw; ++i )
{
int iItem = i + iFirstItemToDraw;
float fPosition = iItem - m_fCurrentItem;
int iIndex = i; // index into m_SubActors
if( m_bLoop )
wrap( iIndex, m_SubActors.size() );
else if( iIndex < 0 || iIndex >= (int)m_SubActors.size() )
continue;
// Optimization: Zero out unused parameters so that they don't create new,
// unnecessary entries in the position cache. On scrollers with lots of
// items, especially with Subdivisions > 1, m_exprTransformFunction uses
// too much memory.
if( !m_bFunctionDependsOnPositionOffset )
fPosition = 0;
if( !m_bFunctionDependsOnItemIndex )
iItem = 0;
m_exprTransformFunction.TransformItemCached( *m_SubActors[iIndex], fPosition, iItem, m_iNumItems );
if( bDrawPrimitives )
{
if( bDelayedDraw )
subs.push_back( m_SubActors[iIndex] );
else
m_SubActors[iIndex]->Draw();
}
}
if( bDelayedDraw )
{
ActorUtil::SortByZPosition( subs );
FOREACH( Actor*, subs, a )
(*a)->Draw();
}
}
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the ActorScroller. */
class LunaActorScroller: public Luna<ActorScroller>
{
public:
static int PositionItems( T* p, lua_State *L ) { p->PositionItems(); return 0; }
static int SetTransformFromFunction( T* p, lua_State *L )
{
LuaReference ref;
LuaHelpers::FromStack( L, ref, 1 );
p->SetTransformFromReference( ref );
return 0;
}
static int SetTransformFromHeight( T* p, lua_State *L ) { p->SetTransformFromHeight(FArg(1)); return 0; }
static int SetTransformFromWidth( T* p, lua_State *L ) { p->SetTransformFromWidth(FArg(1)); return 0; }
static int SetCurrentAndDestinationItem( T* p, lua_State *L ) { p->SetCurrentAndDestinationItem( FArg(1) ); return 0; }
static int SetDestinationItem( T* p, lua_State *L ) { p->SetDestinationItem( FArg(1) ); return 0; }
static int GetSecondsToDestination( T* p, lua_State *L ) { lua_pushnumber( L, p->GetSecondsToDestination() ); return 1; }
static int SetSecondsPerItem( T* p, lua_State *L ) { p->SetSecondsPerItem(FArg(1)); return 0; }
static int SetSecondsPauseBetweenItems( T* p, lua_State *L ) { p->SetSecondsPauseBetweenItems(FArg(1)); return 0; }
static int SetPauseCountdownSeconds( T* p, lua_State *L ) { p->SetPauseCountdownSeconds(FArg(1)); return 0; }
static int SetNumSubdivisions( T* p, lua_State *L ) { p->SetNumSubdivisions(IArg(1)); return 0; }
static int ScrollThroughAllItems( T* p, lua_State *L ) { p->ScrollThroughAllItems(); return 0; }
static int ScrollWithPadding( T* p, lua_State *L ) { p->ScrollWithPadding(FArg(1),FArg(2)); return 0; }
static int SetFastCatchup( T* p, lua_State *L ) { p->SetFastCatchup(BArg(1)); return 0; }
static int SetLoop( T* p, lua_State *L ) { p->SetLoop(BArg(1)); return 0; }
static int SetMask( T* p, lua_State *L ) { p->EnableMask(FArg(1), FArg(2)); return 0; }
static int SetNumItemsToDraw( T* p, lua_State *L ) { p->SetNumItemsToDraw(FArg(1)); return 0; }
static int GetFullScrollLengthSeconds( T* p, lua_State *L ) { lua_pushnumber( L, p->GetSecondsForCompleteScrollThrough() ); return 1; }
static int GetCurrentItem( T* p, lua_State *L ) { lua_pushnumber( L, p->GetCurrentItem() ); return 1; }
static int GetDestinationItem( T* p, lua_State *L ) { lua_pushnumber( L, p->GetDestinationItem() ); return 1; }
static int GetNumItems( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumItems() ); return 1; }
LunaActorScroller()
{
ADD_METHOD( PositionItems );
ADD_METHOD( SetTransformFromFunction );
ADD_METHOD( SetTransformFromHeight );
ADD_METHOD( SetTransformFromWidth );
ADD_METHOD( SetCurrentAndDestinationItem );
ADD_METHOD( SetDestinationItem );
ADD_METHOD( GetSecondsToDestination );
ADD_METHOD( SetSecondsPerItem );
ADD_METHOD( SetSecondsPauseBetweenItems );
ADD_METHOD( SetPauseCountdownSeconds );
ADD_METHOD( SetNumSubdivisions );
ADD_METHOD( ScrollThroughAllItems );
ADD_METHOD( ScrollWithPadding );
ADD_METHOD( SetFastCatchup );
ADD_METHOD( SetLoop );
ADD_METHOD( SetMask );
ADD_METHOD( SetNumItemsToDraw );
ADD_METHOD( GetFullScrollLengthSeconds );
ADD_METHOD( GetCurrentItem );
ADD_METHOD( GetDestinationItem );
ADD_METHOD( GetNumItems );
}
};
LUA_REGISTER_DERIVED_CLASS( ActorScroller, ActorFrame )
// lua end
/*
* (c) 2003-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.
*/
-123
View File
@@ -1,123 +0,0 @@
#ifndef ActorScroller_H
#define ActorScroller_H
#include "ActorFrame.h"
#include "Quad.h"
class XNode;
#include "LuaExpressionTransform.h"
/** @brief ActorFrame that moves its children. */
class ActorScroller : public ActorFrame
{
public:
ActorScroller();
void SetTransformFromReference( const LuaReference &ref );
void SetTransformFromExpression( const RString &sTransformFunction );
void SetTransformFromWidth( float fItemWidth );
void SetTransformFromHeight( float fItemHeight );
void Load2();
void EnableMask( float fWidth, float fHeight );
void DisableMask();
virtual void UpdateInternal( float fDelta );
virtual void DrawPrimitives(); // handles drawing and doesn't call ActorFrame::DrawPrimitives
void PositionItems();
void LoadFromNode( const XNode *pNode );
virtual ActorScroller *Copy() const;
void SetLoop( bool bLoop ) { m_bLoop = bLoop; }
void SetNumItemsToDraw( float fNumItemsToDraw ) { m_fNumItemsToDraw = fNumItemsToDraw; }
void SetDestinationItem( float fItemIndex ) { m_fDestinationItem = fItemIndex; }
void SetCurrentAndDestinationItem( float fItemIndex ) { m_fCurrentItem = m_fDestinationItem = fItemIndex; }
float GetCurrentItem() const { return m_fCurrentItem; }
float GetDestinationItem() const { return m_fDestinationItem; }
void ScrollThroughAllItems();
void ScrollWithPadding( float fItemPaddingStart, float fItemPaddingEnd );
void SetPauseCountdownSeconds( float fSecs ) { m_fPauseCountdownSeconds = fSecs; }
void SetFastCatchup( bool bOn ) { m_bFastCatchup = bOn; }
void SetSecondsPerItem( float fSeconds ) { m_fSecondsPerItem = fSeconds; }
void SetSecondsPauseBetweenItems( float fSeconds ) { m_fSecondsPauseBetweenItems = fSeconds; }
void SetNumSubdivisions( int iNumSubdivisions ) { m_exprTransformFunction.SetNumSubdivisions( iNumSubdivisions ); }
float GetSecondsForCompleteScrollThrough() const;
float GetSecondsToDestination() const;
int GetNumItems() const { return m_iNumItems; }
// Commands
void PushSelf( lua_State *L );
protected:
void PositionItemsAndDrawPrimitives( bool bDrawPrimitives );
virtual void ShiftSubActors( int iDist );
int m_iNumItems;
/**
* @brief the current item we are focused on.
*
* An item at the center of the list, usually between 0 and m_SubActors.size(),
* will approach its destination.
*
* The above comment was paraphrased from what was here previously. It could use
* some clearing up. -Wolfman2000 */
float m_fCurrentItem;
float m_fDestinationItem;
/**
* @brief How many seconds are there per item?
*
* If this is less than zero, then we are not scrolling. */
float m_fSecondsPerItem;
float m_fSecondsPauseBetweenItems;
float m_fNumItemsToDraw;
int m_iFirstSubActorIndex;
bool m_bLoop;
bool m_bFastCatchup;
bool m_bFunctionDependsOnPositionOffset;
bool m_bFunctionDependsOnItemIndex;
float m_fPauseCountdownSeconds;
float m_fQuantizePixels;
Quad m_quadMask;
float m_fMaskWidth, m_fMaskHeight;
LuaExpressionTransform m_exprTransformFunction; // params: self,offset,itemIndex,numItems
};
class ActorScrollerAutoDeleteChildren : public ActorScroller
{
public:
ActorScrollerAutoDeleteChildren() { DeleteChildrenWhenDone(true); }
virtual bool AutoLoadChildren() const { return true; }
virtual ActorScrollerAutoDeleteChildren *Copy() const;
};
#endif
/**
* @file
* @author Chris Danford (c) 2003-2004
* @section LICENSE
* 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.
*/
-103
View File
@@ -1,103 +0,0 @@
#include "global.h"
#include "ActorSound.h"
#include "ActorUtil.h"
#include "LuaManager.h"
#include "XmlFile.h"
#include "RageUtil.h"
REGISTER_ACTOR_CLASS_WITH_NAME( ActorSound, Sound );
void ActorSound::Load( const RString &sPath )
{
m_Sound.Load( sPath, true );
}
void ActorSound::Play()
{
// This fix makes it possible to stop and pause ActorSounds. (Also,
// sometimes stacking sounds is annoying.) -DaisuMaster
if( m_Sound.IsPlaying() )
{
m_Sound.PlayCopy();
return;
}
m_Sound.StartPlaying();
}
void ActorSound::Pause( bool bPause )
{
m_Sound.Pause(bPause);
}
void ActorSound::Stop()
{
m_Sound.Stop();
}
void ActorSound::LoadFromNode( const XNode* pNode )
{
RageSoundLoadParams params;
pNode->GetAttrValue("SupportPan", params.m_bSupportPan);
pNode->GetAttrValue("SupportRateChanging", params.m_bSupportRateChanging);
bool bPrecache = true;
pNode->GetAttrValue( "Precache", bPrecache );
Actor::LoadFromNode( pNode );
RString sFile;
if( ActorUtil::GetAttrPath(pNode, "File", sFile) )
m_Sound.Load( sFile, bPrecache, &params );
}
// lua start
#include "LuaBinding.h"
/** @brief Allow Lua to have access to the ActorSound. */
class LunaActorSound: public Luna<ActorSound>
{
public:
static int load( T* p, lua_State *L ) { p->Load(SArg(1)); return 0; }
static int play( T* p, lua_State *L ) { p->Play(); return 0; }
static int pause( T* p, lua_State *L ) { p->Pause(BArg(1)); return 0; }
static int stop( T* p, lua_State *L ) { p->Stop(); return 0; }
static int get( T* p, lua_State *L ) { p->PushSound( L ); return 1; }
LunaActorSound()
{
ADD_METHOD( load );
ADD_METHOD( play );
ADD_METHOD( pause );
ADD_METHOD( stop );
ADD_METHOD( get );
}
};
LUA_REGISTER_DERIVED_CLASS( ActorSound, Actor )
// lua end
/*
* (c) 2005 Glenn Maynard
* 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.
*/
-56
View File
@@ -1,56 +0,0 @@
#ifndef ACTOR_SOUND_H
#define ACTOR_SOUND_H
#include "Actor.h"
#include "RageSound.h"
/** @brief RageSound Actor interface. */
class ActorSound: public Actor
{
public:
virtual ~ActorSound() { }
virtual ActorSound *Copy() const;
void Load( const RString &sPath );
void Play();
void Pause( bool bPause );
void Stop();
void LoadFromNode( const XNode* pNode );
void PushSound( lua_State *L ) { m_Sound.PushSelf( L ); }
//
// Lua
//
virtual void PushSelf( lua_State *L );
private:
RageSound m_Sound;
};
#endif
/**
* @file
* @author Glenn Maynard (c) 2005
* @section LICENSE
* 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.
*/