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.

This commit is contained in:
AJ Kelly
2012-02-16 01:36:22 -06:00
parent a20fca969d
commit 406a557c04
9 changed files with 11 additions and 36 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ local Color2 = color(Var "Color2");
local t = Def.ActorFrame { local t = Def.ActorFrame {
Def.Sprite { 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") .. { LoadActor(Var "File1") .. {
+1 -1
View File
@@ -2,7 +2,7 @@ local Color1 = color(Var "Color1");
local t = Def.ActorFrame { local t = Def.ActorFrame {
LoadActor(Var "File1") .. { 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); GainFocusCommand=cmd(play);
LoseFocusCommand=cmd(pause); LoseFocusCommand=cmd(pause);
}; };
+2 -27
View File
@@ -151,34 +151,9 @@ function Actor:FullScreen()
self:stretchto( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ) self:stretchto( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT )
end 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() function Actor:scale_or_crop_background()
local gw = self:GetWidth() local graphicAspect = self:GetWidth()/self:GetHeight()
local gh = self:GetHeight() self:zoomto(SCREEN_HEIGHT*graphicAspect,SCREEN_HEIGHT)
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
end end
-- xy(actorX,actorY) -- xy(actorX,actorY)
@@ -9,7 +9,7 @@ t[#t+1] = Def.ActorFrame {
if song:HasBackground() then if song:HasBackground() then
self:LoadBackground(song:GetBackgroundPath()); self:LoadBackground(song:GetBackgroundPath());
end; 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); (cmd(fadebottom,0.25;fadetop,0.25;croptop,48/480;cropbottom,48/480))(self);
else else
self:visible(false); self:visible(false);
@@ -2,6 +2,6 @@ local t = Def.ActorFrame {};
t[#t+1] = Def.Sprite { t[#t+1] = Def.Sprite {
InitCommand=cmd(Center); InitCommand=cmd(Center);
BeginCommand=cmd(LoadFromCurrentSongBackground); 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; return t;
@@ -5,7 +5,7 @@ if not GAMESTATE:IsCourseMode() then return t; end;
t[#t+1] = Def.Sprite { t[#t+1] = Def.Sprite {
InitCommand=cmd(Center); InitCommand=cmd(Center);
BeforeLoadingNextCourseSongMessageCommand=function(self) self:LoadFromSongBackground( SCREENMAN:GetTopScreen():GetNextCourseSong() ) end; 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;); 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); FinishCommand=cmd(linear,0.1;glow,Color.Alpha(Color("White"),0.5);decelerate,0.4;glow,Color("Invisible");diffusealpha,0);
}; };
@@ -10,7 +10,7 @@ t[#t+1] = Def.ActorFrame {
if song:HasBackground() then if song:HasBackground() then
self:LoadBackground(song:GetBackgroundPath()); self:LoadBackground(song:GetBackgroundPath());
end; 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); (cmd(fadebottom,0.25;fadetop,0.25;croptop,48/480;cropbottom,48/480))(self);
else else
self:visible(false); self:visible(false);
@@ -13,12 +13,12 @@ local t = Def.ActorFrame{
self:LoadFromCurrentSongBackground() self:LoadFromCurrentSongBackground()
end end
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 -- alternate background
Def.Sprite{ Def.Sprite{
InitCommand=cmd(Center;); 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"); OnCommand=cmd(sleep,4;playcommand,"Show");
ShowCommand=function(self) ShowCommand=function(self)
if course:HasBackground() then if course:HasBackground() then
@@ -28,7 +28,7 @@ else
t[#t+1] = Def.Sprite { t[#t+1] = Def.Sprite {
InitCommand=cmd(Center); InitCommand=cmd(Center);
BeginCommand=cmd(LoadFromCurrentSongBackground); 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 end