From 02a4b35d51422663204eba9958bf97633cede931 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 26 Sep 2006 20:00:27 +0000 Subject: [PATCH] bound alignment constants --- stepmania/src/Actor.cpp | 34 ++++++++++++++++------------------ stepmania/src/Actor.h | 7 ++++--- stepmania/src/ActorUtil.cpp | 2 -- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index b1e355eac5..c607439893 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -32,6 +32,20 @@ Actor *Actor::Copy() const { return new Actor(*this); } static float g_fCabinetLights[NUM_CABINET_LIGHTS]; +static const char *HorizAlignNames[] = { + "Left", + "Center", + "Right" +}; +LuaXType( HorizAlign ); + +static const char *VertAlignNames[] = { + "Top", + "Middle", + "Bottom" +}; +LuaXType( VertAlign ); + void Actor::SetBGMTime( float fTime, float fBeat ) { g_fCurrentBGMTime = fTime; @@ -829,22 +843,6 @@ void Actor::ScaleTo( const RectF &rect, StretchType st ) SetZoom( fNewZoom ); } -void Actor::SetHorizAlignString( const RString &s ) -{ - if (s.EqualsNoCase("left")) this->SetHorizAlign( HorizAlign_Left ); /* call derived */ - else if(s.EqualsNoCase("center")) this->SetHorizAlign( HorizAlign_Center ); - else if(s.EqualsNoCase("right")) this->SetHorizAlign( HorizAlign_Right ); - else ASSERT(0); -} - -void Actor::SetVertAlignString( const RString &s ) -{ - if (s.EqualsNoCase("top")) this->SetVertAlign( VertAlign_Top ); /* call derived */ - else if(s.EqualsNoCase("middle")) this->SetVertAlign( VertAlign_Middle ); - else if(s.EqualsNoCase("bottom")) this->SetVertAlign( VertAlign_Bottom ); - else ASSERT(0); -} - void Actor::SetEffectClockString( const RString &s ) { if (s.EqualsNoCase("timer")) this->SetEffectClock( CLOCK_TIMER ); @@ -1388,8 +1386,8 @@ public: static int pitch( T* p, lua_State *L ) { p->AddRotationP(FArg(1)); return 0; } static int roll( T* p, lua_State *L ) { p->AddRotationR(FArg(1)); return 0; } static int shadowlength( T* p, lua_State *L ) { p->SetShadowLength(FArg(1)); return 0; } - static int horizalign( T* p, lua_State *L ) { p->SetHorizAlignString(SArg(1)); return 0; } - static int vertalign( T* p, lua_State *L ) { p->SetVertAlignString(SArg(1)); return 0; } + static int horizalign( T* p, lua_State *L ) { p->SetHorizAlign(Enum::Check(L, 1)); return 0; } + static int vertalign( T* p, lua_State *L ) { p->SetVertAlign(Enum::Check(L, 1)); return 0; } static int luaeffect( T* p, lua_State *L ) { p->SetEffectLua(SArg(1)); return 0; } static int diffuseblink( T* p, lua_State *L ) { p->SetEffectDiffuseBlink(); return 0; } static int diffuseshift( T* p, lua_State *L ) { p->SetEffectDiffuseShift(); return 0; } diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 00d6a85af5..a761e646fa 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -6,6 +6,7 @@ #include "RageTypes.h" #include "RageUtil_AutoPtr.h" #include "LuaReference.h" +#include "EnumHelper.h" #include class XNode; struct lua_State; @@ -30,6 +31,7 @@ enum HorizAlign NUM_HorizAlign, HorizAlign_Invalid }; +LuaDeclareType( HorizAlign ); enum VertAlign { @@ -39,6 +41,8 @@ enum VertAlign NUM_VertAlign, VertAlign_Invalid }; +LuaDeclareType( VertAlign ); + #define align_left HorizAlign_Left #define align_center HorizAlign_Center #define align_right HorizAlign_Right @@ -251,10 +255,7 @@ public: // Alignment settings. These need to be virtual for BitmapText // virtual void SetHorizAlign( HorizAlign ha ) { m_HorizAlign = ha; } - void SetHorizAlignString( const RString &s ); // convenience - virtual void SetVertAlign( VertAlign va ) { m_VertAlign = va; } - void SetVertAlignString( const RString &s ); // convenience // diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index b527dd17a9..b5bfe6a481 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -430,8 +430,6 @@ void ActorUtil::ParseActorCommands( Lua *L, const RString &sCommands ) s << "\tself:" << sName << "("; bool bFirstParamIsString = - sName == "horizalign" || - sName == "vertalign" || sName == "effectclock" || sName == "playcommand" || sName == "queuecommand" ||