do tween in lua

This commit is contained in:
Glenn Maynard
2006-09-21 22:13:18 +00:00
parent 52ae78a40e
commit 5a7b061639
3 changed files with 91 additions and 42 deletions
@@ -0,0 +1,64 @@
function Actor:lyriccommand(side)
self:settext( self.ctx.LyricText );
self:stoptweening();
self:shadowlength(0);
local Zoom = SCREEN_WIDTH/(self:GetZoomedWidth()+1);
if( Zoom > 1 ) then Zoom = 1 end
self:zoomx( Zoom );
local Color = self.ctx.LyricColor
local Factor = 1
if side == "Back" then
Factor = 0.5
end
self:diffuse( {
Color[1] * Factor,
Color[2] * Factor,
Color[3] * Factor,
Color[4] * Factor } )
if side == "Front" then
self:cropright(1);
else
self:cropleft(0);
end
self:diffusealpha(0);
self:linear(0.2);
self:diffusealpha(0.75);
self:linear(self.ctx.LyricDuration * 0.75);
if side == "Front" then
self:cropright(0);
else
self:cropleft(1);
end
self:sleep(self.ctx.LyricDuration * 0.25);
self:linear(0.2);
self:diffusealpha(0);
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.
+2 -3
View File
@@ -2837,9 +2837,8 @@ BannerWidth=512
BannerHeight=160 BannerHeight=160
[LyricDisplay] [LyricDisplay]
LyricInCommand=shadowlength,0;diffusealpha,0;linear,0.2;diffusealpha,0.75 LyricFrontChangedCommand=LyricCommand,"Front"
LyricOutCommand=linear,0.2;diffusealpha,0 LyricBackChangedCommand=LyricCommand,"Back"
WipeDimFactor=0.5,0.5,0.5,0.5
InLength= InLength=
OutLength= OutLength=
+25 -39
View File
@@ -8,18 +8,18 @@
static ThemeMetric<float> IN_LENGTH ("LyricDisplay","InLength"); static ThemeMetric<float> IN_LENGTH ("LyricDisplay","InLength");
static ThemeMetric<float> OUT_LENGTH ("LyricDisplay","OutLength"); static ThemeMetric<float> OUT_LENGTH ("LyricDisplay","OutLength");
static ThemeMetric<RageColor> WIPE_DIM_FACTOR ("LyricDisplay","WipeDimFactor");
LyricDisplay::LyricDisplay() LyricDisplay::LyricDisplay()
{ {
for( int i=0; i<2; i++ ) m_textLyrics[0].SetName( "LyricBack" );
{ ActorUtil::LoadAllCommands( m_textLyrics[0], "LyricDisplay" );
m_textLyrics[i].SetName( "Lyric" ); m_textLyrics[0].LoadFromFont( THEME->GetPathF("LyricDisplay","text") );
ActorUtil::LoadAllCommands( m_textLyrics[i], "LyricDisplay" ); this->AddChild( &m_textLyrics[0] );
m_textLyrics[i].LoadFromFont( THEME->GetPathF("LyricDisplay","text") );
m_textLyrics[i].SetDiffuse( RageColor(1,1,1,1) ); m_textLyrics[1].SetName( "LyricFront" );
this->AddChild( &m_textLyrics[i] ); ActorUtil::LoadAllCommands( m_textLyrics[1], "LyricDisplay" );
} m_textLyrics[1].LoadFromFont( THEME->GetPathF("LyricDisplay","text") );
this->AddChild( &m_textLyrics[1] );
Init(); Init();
} }
@@ -72,44 +72,30 @@ void LyricDisplay::Update( float fDeltaTime )
// Make lyrics show faster for faster song rates. // Make lyrics show faster for faster song rates.
fShowLength /= GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate; fShowLength /= GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
Lua *L = LUA->Get();
for( int i=0; i<2; i++ ) for( int i=0; i<2; i++ )
{ {
m_textLyrics[i].SetText( GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_sLyric ); const LyricSegment &seg = GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber];
/* m_textLyrics[i].PushContext(L);
* This really needs a way to define a custom theme command here, so themes
* can do things like:
*
* "Diffuse=1,1,1,0;linear,.2;Diffuse=1,1,1,1;linear,.2;LyricDiffuse"
*/
const float fZoom = min( 1.0f, float(SCREEN_WIDTH)/(m_textLyrics[i].GetZoomedWidth()+1) ); lua_pushstring( L, "LyricText" );
lua_pushstring( L, seg.m_sLyric );
lua_settable( L, -3 );
m_textLyrics[i].StopTweening(); lua_pushstring( L, "LyricDuration" );
m_textLyrics[i].SetZoomX( fZoom ); lua_pushnumber( L, fShowLength );
lua_settable( L, -3 );
RageColor color = GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_Color; lua_pushstring( L, "LyricColor" );
seg.m_Color.PushTable( L );
lua_settable( L, -3 );
if( i==0 ) lua_pop( L, 1 );
color *= WIPE_DIM_FACTOR;
m_textLyrics[i].SetDiffuse( color );
/* Crop the bottom layer of text away as we crop the top layer on. That
* prevents overdraw, which reduces AA quality. */
if( i==0 )
m_textLyrics[i].SetCropLeft(0);
if( i==1 )
m_textLyrics[i].SetCropRight(1);
m_textLyrics[i].PlayCommand( "In" );
m_textLyrics[i].BeginTweening( fShowLength * 0.75f ); /* sleep */
if( i==0 )
m_textLyrics[i].SetCropLeft(1);
if( i==1 )
m_textLyrics[i].SetCropRight(0);
m_textLyrics[i].BeginTweening( fShowLength * 0.25f ); /* sleep */
m_textLyrics[i].PlayCommand( "Out" );
} }
LUA->Release( L );
PlayCommand( "Changed" );
m_iCurLyricNumber++; m_iCurLyricNumber++;
} }