From 406a557c0460a8208c5e9b3a3a635ec005ced53c Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Thu, 16 Feb 2012 01:36:22 -0600 Subject: [PATCH] changed scale_or_crop_background function (technically it just scales now...) and replaced various scaletoclipped references with it. Hopefully this fixes the problems people have been having with song backgrounds. --- BackgroundEffects/SongBgWithMovieViz.lua | 2 +- BackgroundEffects/StretchNormal.lua | 2 +- Themes/_fallback/Scripts/02 Actor.lua | 29 ++----------------- .../ScreenEvaluation background/default.lua | 2 +- .../ScreenGameplay in/default.lua | 2 +- .../default.lua | 2 +- .../ScreenPlayerOptions background.lua | 2 +- .../CourseDisplay.lua | 4 +-- .../default.lua | 2 +- 9 files changed, 11 insertions(+), 36 deletions(-) diff --git a/BackgroundEffects/SongBgWithMovieViz.lua b/BackgroundEffects/SongBgWithMovieViz.lua index d15151a1cf..d69c30b20c 100644 --- a/BackgroundEffects/SongBgWithMovieViz.lua +++ b/BackgroundEffects/SongBgWithMovieViz.lua @@ -3,7 +3,7 @@ local Color2 = color(Var "Color2"); local t = Def.ActorFrame { Def.Sprite { - OnCommand=cmd(LoadFromCurrentSongBackground;x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scaletoclipped,SCREEN_WIDTH,SCREEN_HEIGHT;diffuse,Color1;effectclock,"music"); + OnCommand=cmd(LoadFromCurrentSongBackground;x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;effectclock,"music"); }; LoadActor(Var "File1") .. { diff --git a/BackgroundEffects/StretchNormal.lua b/BackgroundEffects/StretchNormal.lua index 24cae70734..6d23359a47 100644 --- a/BackgroundEffects/StretchNormal.lua +++ b/BackgroundEffects/StretchNormal.lua @@ -2,7 +2,7 @@ local Color1 = color(Var "Color1"); local t = Def.ActorFrame { LoadActor(Var "File1") .. { - OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scaletoclipped,SCREEN_WIDTH,SCREEN_HEIGHT;diffuse,Color1;effectclock,"music"); + OnCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scale_or_crop_background;diffuse,Color1;effectclock,"music"); GainFocusCommand=cmd(play); LoseFocusCommand=cmd(pause); }; diff --git a/Themes/_fallback/Scripts/02 Actor.lua b/Themes/_fallback/Scripts/02 Actor.lua index 587dab08e3..1a1813421b 100644 --- a/Themes/_fallback/Scripts/02 Actor.lua +++ b/Themes/_fallback/Scripts/02 Actor.lua @@ -151,34 +151,9 @@ function Actor:FullScreen() self:stretchto( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ) end ---[[ Typical background sizes: -320x240 - [4:3] -640x480 - [4:3] (most simfiles in distribution today use this res.) -768x480 - [16:10] -854x480 - [16:9] -]] function Actor:scale_or_crop_background() - local gw = self:GetWidth() - local gh = self:GetHeight() - - local graphicAspect = gw/gh - local displayAspect = DISPLAY:GetDisplayWidth()/DISPLAY:GetDisplayHeight() - - if graphicAspect == displayAspect then - -- bga matches the current aspect, we can stretch it. - self:stretchto( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ) - else - -- temp - self:scaletocover( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ) - --[[ - -- bga doesn't match the aspect. - if displayAspect > graphicAspect then - -- the graphic is smaller than the display aspect ratio - else - -- the graphic is bigger than the display aspect ratio; crop me - end - --]] - end + local graphicAspect = self:GetWidth()/self:GetHeight() + self:zoomto(SCREEN_HEIGHT*graphicAspect,SCREEN_HEIGHT) end -- xy(actorX,actorY) diff --git a/Themes/default/BGAnimations/ScreenEvaluation background/default.lua b/Themes/default/BGAnimations/ScreenEvaluation background/default.lua index 5cd05e9772..d8fbc56435 100644 --- a/Themes/default/BGAnimations/ScreenEvaluation background/default.lua +++ b/Themes/default/BGAnimations/ScreenEvaluation background/default.lua @@ -9,7 +9,7 @@ t[#t+1] = Def.ActorFrame { if song:HasBackground() then self:LoadBackground(song:GetBackgroundPath()); end; - self:scaletoclipped( SCREEN_WIDTH+1,SCREEN_HEIGHT ); + self:scale_or_crop_background() (cmd(fadebottom,0.25;fadetop,0.25;croptop,48/480;cropbottom,48/480))(self); else self:visible(false); diff --git a/Themes/default/BGAnimations/ScreenGameplay in/default.lua b/Themes/default/BGAnimations/ScreenGameplay in/default.lua index c89a4026e4..29d0efd3ea 100644 --- a/Themes/default/BGAnimations/ScreenGameplay in/default.lua +++ b/Themes/default/BGAnimations/ScreenGameplay in/default.lua @@ -2,6 +2,6 @@ local t = Def.ActorFrame {}; t[#t+1] = Def.Sprite { InitCommand=cmd(Center); BeginCommand=cmd(LoadFromCurrentSongBackground); - OnCommand=cmd(diffusealpha,1;scaletoclipped,SCREEN_WIDTH,SCREEN_HEIGHT;linear,1;diffusealpha,0;); + OnCommand=cmd(diffusealpha,1;scale_or_crop_background;linear,1;diffusealpha,0;); }; return t; \ No newline at end of file diff --git a/Themes/default/BGAnimations/ScreenGameplay next course song/default.lua b/Themes/default/BGAnimations/ScreenGameplay next course song/default.lua index 732b6a912d..6cdb2900c2 100644 --- a/Themes/default/BGAnimations/ScreenGameplay next course song/default.lua +++ b/Themes/default/BGAnimations/ScreenGameplay next course song/default.lua @@ -5,7 +5,7 @@ if not GAMESTATE:IsCourseMode() then return t; end; t[#t+1] = Def.Sprite { InitCommand=cmd(Center); BeforeLoadingNextCourseSongMessageCommand=function(self) self:LoadFromSongBackground( SCREENMAN:GetTopScreen():GetNextCourseSong() ) end; - ChangeCourseSongInMessageCommand=cmd(scaletoclipped,SCREEN_WIDTH,SCREEN_HEIGHT); + ChangeCourseSongInMessageCommand=cmd(scale_or_crop_background); StartCommand=cmd(diffusealpha,0;decelerate,0.5;diffusealpha,1;); FinishCommand=cmd(linear,0.1;glow,Color.Alpha(Color("White"),0.5);decelerate,0.4;glow,Color("Invisible");diffusealpha,0); }; diff --git a/Themes/default/BGAnimations/ScreenPlayerOptions background.lua b/Themes/default/BGAnimations/ScreenPlayerOptions background.lua index f06580a070..083901796c 100644 --- a/Themes/default/BGAnimations/ScreenPlayerOptions background.lua +++ b/Themes/default/BGAnimations/ScreenPlayerOptions background.lua @@ -10,7 +10,7 @@ t[#t+1] = Def.ActorFrame { if song:HasBackground() then self:LoadBackground(song:GetBackgroundPath()); end; - self:scaletoclipped( SCREEN_WIDTH+1,SCREEN_HEIGHT ); + self:scale_or_crop_background(); (cmd(fadebottom,0.25;fadetop,0.25;croptop,48/480;cropbottom,48/480))(self); else self:visible(false); diff --git a/Themes/default/BGAnimations/ScreenStageInformation underlay/CourseDisplay.lua b/Themes/default/BGAnimations/ScreenStageInformation underlay/CourseDisplay.lua index c3794cf418..e6d2d39cee 100644 --- a/Themes/default/BGAnimations/ScreenStageInformation underlay/CourseDisplay.lua +++ b/Themes/default/BGAnimations/ScreenStageInformation underlay/CourseDisplay.lua @@ -13,12 +13,12 @@ local t = Def.ActorFrame{ self:LoadFromCurrentSongBackground() end end; - OnCommand=cmd(diffusealpha,0;scaletoclipped,SCREEN_WIDTH,SCREEN_HEIGHT;sleep,0.5;linear,0.50;diffusealpha,1;sleep,3); + OnCommand=cmd(diffusealpha,0;scale_or_crop_background;sleep,0.5;linear,0.50;diffusealpha,1;sleep,3); }; -- alternate background Def.Sprite{ InitCommand=cmd(Center;); - BeginCommand=cmd(LoadFromCurrentSongBackground;scaletoclipped,SCREEN_WIDTH,SCREEN_HEIGHT;diffusealpha,0); + BeginCommand=cmd(LoadFromCurrentSongBackground;scale_or_crop_background;diffusealpha,0); OnCommand=cmd(sleep,4;playcommand,"Show"); ShowCommand=function(self) if course:HasBackground() then diff --git a/Themes/default/BGAnimations/ScreenStageInformation underlay/default.lua b/Themes/default/BGAnimations/ScreenStageInformation underlay/default.lua index 9a37087def..249debdbdf 100644 --- a/Themes/default/BGAnimations/ScreenStageInformation underlay/default.lua +++ b/Themes/default/BGAnimations/ScreenStageInformation underlay/default.lua @@ -28,7 +28,7 @@ else t[#t+1] = Def.Sprite { InitCommand=cmd(Center); BeginCommand=cmd(LoadFromCurrentSongBackground); - OnCommand=cmd(diffusealpha,0;scaletoclipped,SCREEN_WIDTH,SCREEN_HEIGHT;sleep,0.5;linear,0.50;diffusealpha,1;sleep,3); + OnCommand=cmd(diffusealpha,0;scale_or_crop_background;sleep,0.5;linear,0.50;diffusealpha,1;sleep,3); }; end