do tween in lua
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -2837,9 +2837,8 @@ BannerWidth=512
|
||||
BannerHeight=160
|
||||
|
||||
[LyricDisplay]
|
||||
LyricInCommand=shadowlength,0;diffusealpha,0;linear,0.2;diffusealpha,0.75
|
||||
LyricOutCommand=linear,0.2;diffusealpha,0
|
||||
WipeDimFactor=0.5,0.5,0.5,0.5
|
||||
LyricFrontChangedCommand=LyricCommand,"Front"
|
||||
LyricBackChangedCommand=LyricCommand,"Back"
|
||||
InLength=
|
||||
OutLength=
|
||||
|
||||
|
||||
@@ -8,18 +8,18 @@
|
||||
|
||||
static ThemeMetric<float> IN_LENGTH ("LyricDisplay","InLength");
|
||||
static ThemeMetric<float> OUT_LENGTH ("LyricDisplay","OutLength");
|
||||
static ThemeMetric<RageColor> WIPE_DIM_FACTOR ("LyricDisplay","WipeDimFactor");
|
||||
|
||||
LyricDisplay::LyricDisplay()
|
||||
{
|
||||
for( int i=0; i<2; i++ )
|
||||
{
|
||||
m_textLyrics[i].SetName( "Lyric" );
|
||||
ActorUtil::LoadAllCommands( m_textLyrics[i], "LyricDisplay" );
|
||||
m_textLyrics[i].LoadFromFont( THEME->GetPathF("LyricDisplay","text") );
|
||||
m_textLyrics[i].SetDiffuse( RageColor(1,1,1,1) );
|
||||
this->AddChild( &m_textLyrics[i] );
|
||||
}
|
||||
m_textLyrics[0].SetName( "LyricBack" );
|
||||
ActorUtil::LoadAllCommands( m_textLyrics[0], "LyricDisplay" );
|
||||
m_textLyrics[0].LoadFromFont( THEME->GetPathF("LyricDisplay","text") );
|
||||
this->AddChild( &m_textLyrics[0] );
|
||||
|
||||
m_textLyrics[1].SetName( "LyricFront" );
|
||||
ActorUtil::LoadAllCommands( m_textLyrics[1], "LyricDisplay" );
|
||||
m_textLyrics[1].LoadFromFont( THEME->GetPathF("LyricDisplay","text") );
|
||||
this->AddChild( &m_textLyrics[1] );
|
||||
|
||||
Init();
|
||||
}
|
||||
@@ -72,44 +72,30 @@ void LyricDisplay::Update( float fDeltaTime )
|
||||
// Make lyrics show faster for faster song rates.
|
||||
fShowLength /= GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
|
||||
|
||||
Lua *L = LUA->Get();
|
||||
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];
|
||||
|
||||
/*
|
||||
* 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"
|
||||
*/
|
||||
m_textLyrics[i].PushContext(L);
|
||||
|
||||
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();
|
||||
m_textLyrics[i].SetZoomX( fZoom );
|
||||
lua_pushstring( L, "LyricDuration" );
|
||||
lua_pushnumber( L, fShowLength );
|
||||
lua_settable( L, -3 );
|
||||
|
||||
RageColor color = GAMESTATE->m_pCurSong->m_LyricSegments[m_iCurLyricNumber].m_Color;
|
||||
|
||||
if( i==0 )
|
||||
color *= WIPE_DIM_FACTOR;
|
||||
lua_pushstring( L, "LyricColor" );
|
||||
seg.m_Color.PushTable( L );
|
||||
lua_settable( L, -3 );
|
||||
|
||||
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_pop( L, 1 );
|
||||
}
|
||||
LUA->Release( L );
|
||||
|
||||
PlayCommand( "Changed" );
|
||||
|
||||
m_iCurLyricNumber++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user