From ad877b6dcb4c06cba28e7df9724606e707fbd4ab Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Thu, 5 Feb 2015 00:37:08 -0700 Subject: [PATCH] Changed BackgroundEffects files to apply the playback rate to videos. Added GetUpdateRate to ActorFrame and Get/SetDecodeMovie to Sprite. Hope nobody is caught off guard by checkerboard no longer playing videos back at 4x rate. --- BackgroundEffects/Centered.lua | 8 +++++- BackgroundEffects/Checkerboard1File2x2.lua | 24 ++++++++++++++--- BackgroundEffects/Checkerboard2File2x2.lua | 27 ++++++++++++++++--- BackgroundEffects/Checkerboard2x2.lua | 16 ++++++++--- BackgroundEffects/File2Flash.lua | 16 +++++++++-- BackgroundEffects/File2Normal.lua | 16 +++++++++-- BackgroundEffects/Kaleidoscope2x2.lua | 23 +++++++++++++--- BackgroundEffects/SongBgWithMovieViz.lua | 12 ++++++++- BackgroundEffects/StretchNoLoop.lua | 9 ++++++- BackgroundEffects/StretchNormal.lua | 4 +++ BackgroundEffects/StretchNormalAlignLeft.lua | 8 +++++- BackgroundEffects/StretchNormalBlue.lua | 8 +++++- BackgroundEffects/StretchNormalGreen.lua | 8 +++++- BackgroundEffects/StretchNormalRed.lua | 8 +++++- BackgroundEffects/StretchPaused.lua | 8 +++++- BackgroundEffects/StretchRewind.lua | 4 +++ BackgroundEffects/UpperLeft.lua | 8 +++++- BackgroundEffects/Visualization2File.lua | 16 +++++++++-- BackgroundEffects/Visualization2FileFlash.lua | 20 +++++++++++--- Docs/Changelog_sm5.txt | 11 +++++++- Docs/Luadoc/Lua.xml | 4 +++ Docs/Luadoc/LuaDocumentation.xml | 12 +++++++++ src/Actor.h | 1 + src/ActorFrame.cpp | 2 ++ src/ActorFrame.h | 1 + src/ActorMultiVertex.cpp | 2 ++ src/Background.cpp | 14 +++++++--- src/Sprite.cpp | 12 ++++++++- src/Sprite.h | 2 ++ 29 files changed, 263 insertions(+), 41 deletions(-) diff --git a/BackgroundEffects/Centered.lua b/BackgroundEffects/Centered.lua index 5ee918a626..2e8c7d3d1d 100644 --- a/BackgroundEffects/Centered.lua +++ b/BackgroundEffects/Centered.lua @@ -2,7 +2,13 @@ local Color1 = color(Var "Color1"); local t = Def.ActorFrame { LoadActor(Var "File1") .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;diffuse,Color1;effectclock,"music"); + OnCommand= function(self) + self:xy(_screen.cx, _screen.cy):diffuse(Color1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/BackgroundEffects/Checkerboard1File2x2.lua b/BackgroundEffects/Checkerboard1File2x2.lua index 6ecca9e692..0352305d10 100644 --- a/BackgroundEffects/Checkerboard1File2x2.lua +++ b/BackgroundEffects/Checkerboard1File2x2.lua @@ -1,16 +1,32 @@ local Color1 = color(Var "Color1"); local a = LoadActor(Var "File1") .. { - OnCommand=cmd(cropto,SCREEN_WIDTH/2,SCREEN_HEIGHT/2;diffuse,Color1;effectclock,"music"); + OnCommand= function(self) + self:cropto(_screen.w/2, _screen.h/2):diffuse(Color1) + :effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; local t = Def.ActorFrame { a .. { OnCommand=cmd(x,scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; - a .. { OnCommand=cmd(x,scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; - a .. { OnCommand=cmd(x,scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; - a .. { OnCommand=cmd(x,scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; + a .. { OnCommand=function(self) + self:x(scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT)):y(scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM)) + if self.SetDecodeMovie then self:SetDecodeMovie(false) end + end }; + a .. { OnCommand=function(self) + self:x(scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT)):y(scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)) + if self.SetDecodeMovie then self:SetDecodeMovie(false) end + end }; + a .. { OnCommand=function(self) + self:x(scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT)):y(scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)) + if self.SetDecodeMovie then self:SetDecodeMovie(false) end + end }; }; return t; diff --git a/BackgroundEffects/Checkerboard2File2x2.lua b/BackgroundEffects/Checkerboard2File2x2.lua index 515341cc49..eadb73f18b 100644 --- a/BackgroundEffects/Checkerboard2File2x2.lua +++ b/BackgroundEffects/Checkerboard2File2x2.lua @@ -2,12 +2,25 @@ local Color1 = color(Var "Color1"); local Color2 = color(Var "Color2"); local a1 = LoadActor(Var "File1") .. { - OnCommand=cmd(cropto,SCREEN_WIDTH/2,SCREEN_HEIGHT/2;diffuse,Color1;effectclock,"music"); + OnCommand= function(self) + self:cropto(SCREEN_WIDTH/2,SCREEN_HEIGHT/2):diffuse(Color1) + :effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; local a2 = LoadActor(Var "File2") .. { - OnCommand=cmd(cropto,SCREEN_WIDTH/2,SCREEN_HEIGHT/2;diffuse,Color2;effectclock,"music"); + OnCommand= function(self) + self:cropto(SCREEN_WIDTH/2,SCREEN_HEIGHT/2):diffuse(Color2):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; @@ -15,8 +28,14 @@ local a2 = LoadActor(Var "File2") .. { local t = Def.ActorFrame { a1 .. { OnCommand=cmd(x,scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; a2 .. { OnCommand=cmd(x,scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; - a2 .. { OnCommand=cmd(x,scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; - a1 .. { OnCommand=cmd(x,scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; + a2 .. { OnCommand=function(self) + self:x(scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT)):y(scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)) + if self.SetDecodeMovie then self:SetDecodeMovie(false) end + end }; + a1 .. { OnCommand=function(self) + self:x(scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT)):y(scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)) + if self.SetDecodeMovie then self:SetDecodeMovie(false) end + end }; }; return t; diff --git a/BackgroundEffects/Checkerboard2x2.lua b/BackgroundEffects/Checkerboard2x2.lua index 4183d12762..399ea05548 100644 --- a/BackgroundEffects/Checkerboard2x2.lua +++ b/BackgroundEffects/Checkerboard2x2.lua @@ -3,10 +3,18 @@ local Color2 = color(Var "Color2"); -- Alternating files being played back at once local t = Def.ActorFrame { - LoadActor(Var "File1") .. { OnCommand=cmd(x,scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM);cropto,SCREEN_WIDTH/2,SCREEN_HEIGHT/2;diffuse,Color1;rate,0.25) }; - LoadActor(Var "File2") .. { OnCommand=cmd(x,scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM);cropto,SCREEN_WIDTH/2,SCREEN_HEIGHT/2;diffuse,Color2;rate,0.25) }; - LoadActor(Var "File2") .. { OnCommand=cmd(x,scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM);cropto,SCREEN_WIDTH/2,SCREEN_HEIGHT/2;diffuse,Color1;rate,0.25) }; - LoadActor(Var "File1") .. { OnCommand=cmd(x,scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM);cropto,SCREEN_WIDTH/2,SCREEN_HEIGHT/2;diffuse,Color2;rate,0.25) }; + LoadActor(Var "File1") .. { OnCommand=cmd(x,scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM);cropto,SCREEN_WIDTH/2,SCREEN_HEIGHT/2;diffuse,Color1) }; + LoadActor(Var "File2") .. { OnCommand=cmd(x,scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM);cropto,SCREEN_WIDTH/2,SCREEN_HEIGHT/2;diffuse,Color2) }; + LoadActor(Var "File2") .. { + OnCommand=function(self) + self:x(scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT)):y(scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)):cropto(SCREEN_WIDTH/2,SCREEN_HEIGHT/2):diffuse(Color1) + if self.SetDecodeMovie then self:SetDecodeMovie(false) end + end }; + LoadActor(Var "File1") .. { + OnCommand=function(self) + self:x(scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT)):y(scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)):cropto(SCREEN_WIDTH/2,SCREEN_HEIGHT/2):diffuse(Color2) + if self.SetDecodeMovie then self:SetDecodeMovie(false) end + end }; }; return t diff --git a/BackgroundEffects/File2Flash.lua b/BackgroundEffects/File2Flash.lua index dd98d708ff..e2b649fc20 100644 --- a/BackgroundEffects/File2Flash.lua +++ b/BackgroundEffects/File2Flash.lua @@ -4,14 +4,26 @@ local Color2 = color(Var "Color2"); local t = Def.ActorFrame {}; t[#t+1] = LoadActor(Var "File1") .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;effectclock,"music"); + OnCommand=function(self) + self:x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; if Var("File2") ~= nil then t[#t+1] = LoadActor(Var("File2")) .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color2;effectclock,"music";linear,1;diffusealpha,0); + OnCommand=function(self) + self:x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color2):effectclock("music"):linear(1):diffusealpha(0) + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/BackgroundEffects/File2Normal.lua b/BackgroundEffects/File2Normal.lua index 85fd768f48..5125fda9c0 100644 --- a/BackgroundEffects/File2Normal.lua +++ b/BackgroundEffects/File2Normal.lua @@ -4,14 +4,26 @@ local Color2 = color(Var "Color2"); local t = Def.ActorFrame {}; t[#t+1] = LoadActor(Var "File1") .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;effectclock,"music"); + OnCommand=function(self) +self:x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; if Var("File2") ~= nil then t[#t+1] = LoadActor(Var("File2")) .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;effectclock,"music"); + OnCommand=function(self) + self:x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/BackgroundEffects/Kaleidoscope2x2.lua b/BackgroundEffects/Kaleidoscope2x2.lua index 834dd4f7a4..a2994bfe52 100644 --- a/BackgroundEffects/Kaleidoscope2x2.lua +++ b/BackgroundEffects/Kaleidoscope2x2.lua @@ -1,16 +1,31 @@ local Color1 = color(Var "Color1"); local a = LoadActor(Var "File1") .. { - OnCommand=cmd(cropto,SCREEN_WIDTH/2,SCREEN_HEIGHT/2;diffuse,Color1;zoomx,self:GetZoomX()*-1;zoomy,self:GetZoomY()*-1;effectclock,"music"); + OnCommand= function(self) + self:cropto(SCREEN_WIDTH/2,SCREEN_HEIGHT/2):diffuse(Color1):zoomx(self:GetZoomX()*-1):zoomy(self:GetZoomY()*-1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; local t = Def.ActorFrame { a .. { OnCommand=cmd(x,scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; - a .. { OnCommand=cmd(x,scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; - a .. { OnCommand=cmd(x,scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; - a .. { OnCommand=cmd(x,scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT);y,scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)); }; + a .. { OnCommand=function(self) + self:x(scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT)):y(scale(1,0,4,SCREEN_TOP,SCREEN_BOTTOM)) + if self.SetDecodeMovie then self:SetDecodeMovie(false) end + end }; + a .. { OnCommand=function(self) + self:x(scale(1,0,4,SCREEN_LEFT,SCREEN_RIGHT)):y(scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)) + if self.SetDecodeMovie then self:SetDecodeMovie(false) end + end }; + a .. { OnCommand=function(self) + self:x(scale(3,0,4,SCREEN_LEFT,SCREEN_RIGHT)):y(scale(3,0,4,SCREEN_TOP,SCREEN_BOTTOM)) + if self.SetDecodeMovie then self:SetDecodeMovie(false) end + end }; }; return t; diff --git a/BackgroundEffects/SongBgWithMovieViz.lua b/BackgroundEffects/SongBgWithMovieViz.lua index 7ae5d6d02f..800f5c8460 100644 --- a/BackgroundEffects/SongBgWithMovieViz.lua +++ b/BackgroundEffects/SongBgWithMovieViz.lua @@ -9,11 +9,21 @@ local t = Def.ActorFrame { self:scale_or_crop_background(); self:diffuse(Color1) self:effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end end; }; LoadActor(Var "File1") .. { - OnCommand=cmd(blend,"BlendMode_Add";x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color2;effectclock,"music"); + OnCommand=function(self) + self:blend("BlendMode_Add"):x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color2):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end; GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/BackgroundEffects/StretchNoLoop.lua b/BackgroundEffects/StretchNoLoop.lua index 0051588fea..84e630326d 100644 --- a/BackgroundEffects/StretchNoLoop.lua +++ b/BackgroundEffects/StretchNoLoop.lua @@ -6,7 +6,14 @@ local t = Def.ActorFrame { self:xy(SCREEN_CENTER_X,SCREEN_CENTER_Y) self:scale_or_crop_background() self:diffuse(Color1) - if self.loop ~= nil then + -- The playback rate in the simfile is used to set the update rate + -- on the ActorFrame, but effectclock("music") causes the sprite to + -- ignore the passed in delta time and use the music time instead. + -- So this passes the update rate in to the texture. -Kyz + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + if self.loop then self:loop(false) -- make videos start at beginning to prevent sticking on last frame self:position(0) diff --git a/BackgroundEffects/StretchNormal.lua b/BackgroundEffects/StretchNormal.lua index c814a02284..4fc137bb90 100644 --- a/BackgroundEffects/StretchNormal.lua +++ b/BackgroundEffects/StretchNormal.lua @@ -7,6 +7,10 @@ local t = Def.ActorFrame { self:scale_or_crop_background(); self:diffuse(Color1) self:effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end end; GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); diff --git a/BackgroundEffects/StretchNormalAlignLeft.lua b/BackgroundEffects/StretchNormalAlignLeft.lua index b145ef69d2..3ea7362832 100644 --- a/BackgroundEffects/StretchNormalAlignLeft.lua +++ b/BackgroundEffects/StretchNormalAlignLeft.lua @@ -3,7 +3,13 @@ local Color1 = color(Var "Color1"); local t = Def.ActorFrame { LoadActor(Var "File1") .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;effectclock,"music"); + OnCommand=function(self) + self:x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/BackgroundEffects/StretchNormalBlue.lua b/BackgroundEffects/StretchNormalBlue.lua index b5b7c629fb..2deae2baff 100644 --- a/BackgroundEffects/StretchNormalBlue.lua +++ b/BackgroundEffects/StretchNormalBlue.lua @@ -3,7 +3,13 @@ local Color1 = color("0,0,1,1"); local t = Def.ActorFrame { LoadActor(Var "File1") .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;effectclock,"music"); + OnCommand=function(self) + self:x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/BackgroundEffects/StretchNormalGreen.lua b/BackgroundEffects/StretchNormalGreen.lua index f90436b90f..225f6ac936 100644 --- a/BackgroundEffects/StretchNormalGreen.lua +++ b/BackgroundEffects/StretchNormalGreen.lua @@ -3,7 +3,13 @@ local Color1 = color("0,1,0,1"); local t = Def.ActorFrame { LoadActor(Var "File1") .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;effectclock,"music"); + OnCommand=function(self) + self:x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/BackgroundEffects/StretchNormalRed.lua b/BackgroundEffects/StretchNormalRed.lua index caa8ccbfa9..56b7de63f5 100644 --- a/BackgroundEffects/StretchNormalRed.lua +++ b/BackgroundEffects/StretchNormalRed.lua @@ -3,7 +3,13 @@ local Color1 = color("1,0,0,1"); local t = Def.ActorFrame { LoadActor(Var "File1") .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;effectclock,"music"); + OnCommand=function(self) + self:x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/BackgroundEffects/StretchPaused.lua b/BackgroundEffects/StretchPaused.lua index 41c81bdd52..46a534f398 100644 --- a/BackgroundEffects/StretchPaused.lua +++ b/BackgroundEffects/StretchPaused.lua @@ -2,7 +2,13 @@ local Color1 = color(Var "Color1"); local t = Def.ActorFrame { LoadActor(Var "File1") .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;pause;effectclock,"music"); + OnCommand=function(self) + self:x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color1):pause():effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/BackgroundEffects/StretchRewind.lua b/BackgroundEffects/StretchRewind.lua index 9d649131f2..4f3ccf23d2 100644 --- a/BackgroundEffects/StretchRewind.lua +++ b/BackgroundEffects/StretchRewind.lua @@ -10,6 +10,10 @@ local t = Def.ActorFrame { self:position(0) end self:effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end end; GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); diff --git a/BackgroundEffects/UpperLeft.lua b/BackgroundEffects/UpperLeft.lua index 0987f8f1c4..7e04b9992e 100644 --- a/BackgroundEffects/UpperLeft.lua +++ b/BackgroundEffects/UpperLeft.lua @@ -3,7 +3,13 @@ local Color1 = color(Var "Color1"); local t = Def.ActorFrame { LoadActor(Var "File1") .. { - OnCommand=cmd(diffuse,Color1;effectclock,"music"); + OnCommand=function(self) + self:diffuse(Color1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/BackgroundEffects/Visualization2File.lua b/BackgroundEffects/Visualization2File.lua index c729ed7b9d..5212c256b1 100644 --- a/BackgroundEffects/Visualization2File.lua +++ b/BackgroundEffects/Visualization2File.lua @@ -3,13 +3,25 @@ local Color2 = color(Var "Color2"); local t = Def.ActorFrame { LoadActor(Var "File1") .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;effectclock,"music"); + OnCommand=function(self) + self:x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; LoadActor(Var "File2") .. { - OnCommand=cmd(blend,"BlendMode_Add";x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scaletoclipped,SCREEN_WIDTH,SCREEN_HEIGHT;diffuse,Color2;effectclock,"music"); + OnCommand=function(self) + self:blend("BlendMode_Add"):x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scaletoclipped(SCREEN_WIDTH,SCREEN_HEIGHT):diffuse(Color2):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/BackgroundEffects/Visualization2FileFlash.lua b/BackgroundEffects/Visualization2FileFlash.lua index 9bc9f3e13f..d01a22a4d6 100644 --- a/BackgroundEffects/Visualization2FileFlash.lua +++ b/BackgroundEffects/Visualization2FileFlash.lua @@ -4,14 +4,26 @@ local Color2 = color(Var "Color2"); local t = Def.ActorFrame {}; t[#t+1] = LoadActor(Var "File1") .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;effectclock,"music"); - GainFocusCommand=cmd(play); - LoseFocusCommand=cmd(pause); + OnCommand=function(self) + self:x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color1):effectclock("music") + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, + GainFocusCommand=cmd(play); + LoseFocusCommand=cmd(pause); }; if Var("File2") ~= nil then t[#t+1] = LoadActor(Var("File2")) .. { - OnCommand=cmd(blend,"BlendMode_Add";x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color2;effectclock,"music";linear,1;diffusealpha,0); + OnCommand=function(self) + self:blend("BlendMode_Add"):x(SCREEN_CENTER_X):y(SCREEN_CENTER_Y):scale_or_crop_background():diffuse(Color2):effectclock("music"):linear(1):diffusealpha(0) + -- Explanation in StretchNoLoop.lua. + if self.GetTexture then + self:GetTexture():rate(self:GetParent():GetUpdateRate()) + end + end, GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index a0725f1321..c4105c1886 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -4,9 +4,18 @@ The StepMania 5 Changelog covers all post-sm-ssc changes. For a list of changes from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt. ________________________________________________________________________________ +2015/02/04 +---------- +* [ActorFrame] GetUpdateRate added. [kyzentun] +* [Background] Using the wrong transition name no longer crashes. + Playback rate is applied to videos. + Checkerboard and other BackgroundEffects that use the same file twice no + longer play videos back at multiplied speed. [kyzentun] +* [Sprite] Get/SetDecodeMovie added. [kyzentun] + 2015/02/02 ---------- -* [ActorMultiVertex] ForceStateUpdate and SetDecodeMovie added. [kyzentun] +* [ActorMultiVertex] ForceStateUpdate and Get/SetDecodeMovie added. [kyzentun] * [RageTexture] GetWidth and Height functions added. ( means Source, Texture, or Image) [kyzentun] * [Scripts] find_missing_strings_in_theme_translations function added to diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index 8379721827..4e15aac781 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -454,6 +454,7 @@ + @@ -499,6 +500,7 @@ + @@ -592,6 +594,7 @@ + @@ -604,6 +607,7 @@ + diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index 0024206366..8b171b3261 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -1429,6 +1429,9 @@ save yourself some time, copy this for undocumented things: Returns the number of children in the ActorFrame. + + Gets the update function's rate. + Plays the sCommandName command on the ActorFrame's children. @@ -1561,6 +1564,9 @@ save yourself some time, copy this for undocumented things: Returns the id of the current state. + + Gets whether the AMV should call the decode function for its texture during updates. + Sets whether the AMV should call the decode function for its texture during updates. @@ -4753,6 +4759,9 @@ save yourself some time, copy this for undocumented things: Returns the length of the animation in seconds. + + Gets whether the Sprite should call the decode function for its texture during updates. + Return the number of states this Sprite has. @@ -4793,6 +4802,9 @@ save yourself some time, copy this for undocumented things: Turns off the custom pos coords for the sprite. + + Sets whether the Sprite should call the decode function for its texture during updates. + Set the to mode. diff --git a/src/Actor.h b/src/Actor.h index 0acd10d96a..ccce22d864 100644 --- a/src/Actor.h +++ b/src/Actor.h @@ -609,6 +609,7 @@ public: virtual float GetAnimationLengthSeconds() const { return 0; } virtual void SetSecondsIntoAnimation( float ) {} virtual void SetUpdateRate( float ) {} + virtual float GetUpdateRate() { return 1.0f; } HiddenPtr m_pLuaInstance; diff --git a/src/ActorFrame.cpp b/src/ActorFrame.cpp index 174fe1ba64..26591e1eb3 100644 --- a/src/ActorFrame.cpp +++ b/src/ActorFrame.cpp @@ -625,6 +625,7 @@ public: static int propagate( T* p, lua_State *L ) { p->SetPropagateCommands( BIArg(1) ); COMMON_RETURN_SELF; } static int fov( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); COMMON_RETURN_SELF; } static int SetUpdateRate( T* p, lua_State *L ) { p->SetUpdateRate( FArg(1) ); COMMON_RETURN_SELF; } + DEFINE_METHOD(GetUpdateRate, GetUpdateRate()); static int SetFOV( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); COMMON_RETURN_SELF; } static int vanishpoint( T* p, lua_State *L ) { p->SetVanishPoint( FArg(1), FArg(2) ); COMMON_RETURN_SELF; } static int GetChild( T* p, lua_State *L ) @@ -738,6 +739,7 @@ public: ADD_METHOD( propagate ); // deprecated ADD_METHOD( fov ); ADD_METHOD( SetUpdateRate ); + ADD_METHOD( GetUpdateRate ); ADD_METHOD( SetFOV ); ADD_METHOD( vanishpoint ); ADD_METHOD( GetChild ); diff --git a/src/ActorFrame.h b/src/ActorFrame.h index 978b9760ac..274da11ba4 100644 --- a/src/ActorFrame.h +++ b/src/ActorFrame.h @@ -76,6 +76,7 @@ public: virtual void HurryTweening( float factor ); void SetUpdateRate( float fUpdateRate ) { m_fUpdateRate = fUpdateRate; } + float GetUpdateRate() { return m_fUpdateRate; } void SetFOV( float fFOV ) { m_fFOV = fFOV; } void SetVanishPoint( float fX, float fY) { m_fVanishX = fX; m_fVanishY = fY; } diff --git a/src/ActorMultiVertex.cpp b/src/ActorMultiVertex.cpp index 4420007683..d59b20ad33 100644 --- a/src/ActorMultiVertex.cpp +++ b/src/ActorMultiVertex.cpp @@ -1114,6 +1114,7 @@ public: p->UpdateAnimationState(true); COMMON_RETURN_SELF; } + DEFINE_METHOD(GetDecodeMovie, _decode_movie); static int SetDecodeMovie(T* p, lua_State *L) { p->_decode_movie= BArg(1); @@ -1182,6 +1183,7 @@ public: ADD_METHOD(GetQuadState); ADD_METHOD(SetQuadState); ADD_METHOD(ForceStateUpdate); + ADD_METHOD(GetDecodeMovie); ADD_METHOD(SetDecodeMovie); // Copy from RageTexture diff --git a/src/Background.cpp b/src/Background.cpp index e70e86e6e9..d75abfbd49 100644 --- a/src/Background.cpp +++ b/src/Background.cpp @@ -765,10 +765,16 @@ void BackgroundImpl::Layer::UpdateCurBGChange( const Song *pSong, float fLastMus if( !change.m_sTransition.empty() ) { map::const_iterator lIter = mapNameToTransition.find( change.m_sTransition ); - ASSERT( lIter != mapNameToTransition.end() ); - const BackgroundTransition &bt = lIter->second; - m_pFadingBGA->RunCommandsOnLeaves( *bt.cmdLeaves ); - m_pFadingBGA->RunCommands( *bt.cmdRoot ); + if(lIter == mapNameToTransition.end()) + { + LuaHelpers::ReportScriptErrorFmt("'%s' is not the name of a BackgroundTransition file.", change.m_sTransition.c_str()); + } + else + { + const BackgroundTransition &bt = lIter->second; + m_pFadingBGA->RunCommandsOnLeaves( *bt.cmdLeaves ); + m_pFadingBGA->RunCommands( *bt.cmdRoot ); + } } } } diff --git a/src/Sprite.cpp b/src/Sprite.cpp index 51d1b238da..da98194523 100644 --- a/src/Sprite.cpp +++ b/src/Sprite.cpp @@ -26,6 +26,7 @@ Sprite::Sprite() m_bUsingCustomTexCoords = false; m_bUsingCustomPosCoords = false; m_bSkipNextUpdate = true; + m_DecodeMovie= true; m_EffectMode = EffectMode_Normal; m_fRememberedClipWidth = -1; @@ -62,6 +63,7 @@ Sprite::Sprite( const Sprite &cpy ): CPY( m_bUsingCustomTexCoords ); CPY( m_bUsingCustomPosCoords ); CPY( m_bSkipNextUpdate ); + CPY( m_DecodeMovie ); CPY( m_EffectMode ); memcpy( m_CustomTexCoords, cpy.m_CustomTexCoords, sizeof(m_CustomTexCoords) ); memcpy( m_CustomPosCoords, cpy.m_CustomPosCoords, sizeof(m_CustomPosCoords) ); @@ -408,7 +410,7 @@ void Sprite::Update( float fDelta ) UpdateAnimationState(); // If the texture is a movie, decode frames. - if( !bSkipThisMovieUpdate ) + if(!bSkipThisMovieUpdate && m_DecodeMovie) m_pTexture->DecodeSeconds( max(0, fTimePassed) ); // update scrolling @@ -1210,6 +1212,12 @@ public: p->SetAllStateDelays(FArg(-1)); COMMON_RETURN_SELF; } + DEFINE_METHOD(GetDecodeMovie, m_DecodeMovie); + static int SetDecodeMovie(T* p, lua_State *L) + { + p->m_DecodeMovie= BArg(1); + COMMON_RETURN_SELF; + } LunaSprite() { @@ -1235,6 +1243,8 @@ public: ADD_METHOD( SetEffectMode ); ADD_METHOD( GetNumStates ); ADD_METHOD( SetAllStateDelays ); + ADD_METHOD(GetDecodeMovie); + ADD_METHOD(SetDecodeMovie); } }; diff --git a/src/Sprite.h b/src/Sprite.h index 9c136b91f5..30da184a7c 100644 --- a/src/Sprite.h +++ b/src/Sprite.h @@ -90,6 +90,8 @@ public: void SetAllStateDelays(float fDelay); + bool m_DecodeMovie; + protected: void LoadFromTexture( RageTextureID ID );