From 9b2c59de46a914f8b440630643985b98ef57da3e Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Sat, 16 Aug 2014 03:37:24 -0600 Subject: [PATCH] Added BackgroundFitMode preference and setting screen for controlling how backgrounds are fitted to the screen. --- BackgroundEffects/File2Normal.lua | 1 - BackgroundEffects/SongBgWithMovieViz.lua | 5 +- BackgroundEffects/StretchNormal.lua | 5 +- .../BGAnimations/ScreenSetBGFit overlay.lua | 147 ++++++++++++++++++ .../Graphics/ScreenSetBGFit 16_10_example.png | Bin 0 -> 160 bytes .../Graphics/ScreenSetBGFit 16_12_example.png | Bin 0 -> 160 bytes .../Graphics/ScreenSetBGFit 16_9_example.png | Bin 0 -> 160 bytes Themes/_fallback/Languages/en.ini | 17 ++ Themes/_fallback/Scripts/02 Actor.lua | 34 +++- Themes/_fallback/Scripts/04 LogDisplay.lua | 16 ++ .../_fallback/Scripts/04 SetBGFitHelpers.lua | 126 +++++++++++++++ Themes/_fallback/metrics.ini | 13 +- .../default.lua | 6 +- Themes/default/metrics.ini | 2 +- src/PrefsManager.cpp | 12 ++ src/PrefsManager.h | 11 ++ src/ScreenOptionsMasterPrefs.cpp | 3 +- 17 files changed, 378 insertions(+), 20 deletions(-) create mode 100644 Themes/_fallback/BGAnimations/ScreenSetBGFit overlay.lua create mode 100644 Themes/_fallback/Graphics/ScreenSetBGFit 16_10_example.png create mode 100644 Themes/_fallback/Graphics/ScreenSetBGFit 16_12_example.png create mode 100644 Themes/_fallback/Graphics/ScreenSetBGFit 16_9_example.png create mode 100644 Themes/_fallback/Scripts/04 SetBGFitHelpers.lua diff --git a/BackgroundEffects/File2Normal.lua b/BackgroundEffects/File2Normal.lua index 318a36bee1..69278eadaf 100644 --- a/BackgroundEffects/File2Normal.lua +++ b/BackgroundEffects/File2Normal.lua @@ -1,6 +1,5 @@ local Color1 = color(Var "Color1"); local Color2 = color(Var "Color2"); -local stretchBG = PREFSMAN:GetPreference("StretchBackgrounds") local t = Def.ActorFrame {}; diff --git a/BackgroundEffects/SongBgWithMovieViz.lua b/BackgroundEffects/SongBgWithMovieViz.lua index a9597aa256..7ae5d6d02f 100644 --- a/BackgroundEffects/SongBgWithMovieViz.lua +++ b/BackgroundEffects/SongBgWithMovieViz.lua @@ -1,15 +1,12 @@ local Color1 = color(Var "Color1"); local Color2 = color(Var "Color2"); -local stretchBG = PREFSMAN:GetPreference("StretchBackgrounds") local t = Def.ActorFrame { Def.Sprite { OnCommand=function(self) self:LoadFromCurrentSongBackground() self:xy(SCREEN_CENTER_X,SCREEN_CENTER_Y) - if stretchBG then self:SetSize(SCREEN_WIDTH,SCREEN_HEIGHT) - else self:scale_or_crop_background(); - end + self:scale_or_crop_background(); self:diffuse(Color1) self:effectclock("music") end; diff --git a/BackgroundEffects/StretchNormal.lua b/BackgroundEffects/StretchNormal.lua index 0edf91f0f1..c814a02284 100644 --- a/BackgroundEffects/StretchNormal.lua +++ b/BackgroundEffects/StretchNormal.lua @@ -1,13 +1,10 @@ local Color1 = color(Var "Color1"); -local stretchBG = PREFSMAN:GetPreference("StretchBackgrounds") local t = Def.ActorFrame { LoadActor(Var "File1") .. { OnCommand=function(self) self:xy(SCREEN_CENTER_X,SCREEN_CENTER_Y) - if stretchBG then self:SetSize(SCREEN_WIDTH,SCREEN_HEIGHT) - else self:scale_or_crop_background(); - end + self:scale_or_crop_background(); self:diffuse(Color1) self:effectclock("music") end; diff --git a/Themes/_fallback/BGAnimations/ScreenSetBGFit overlay.lua b/Themes/_fallback/BGAnimations/ScreenSetBGFit overlay.lua new file mode 100644 index 0000000000..5f0a91adcd --- /dev/null +++ b/Themes/_fallback/BGAnimations/ScreenSetBGFit overlay.lua @@ -0,0 +1,147 @@ +-- General layout: There is one choice for each possible background fitting +-- mode. Each choice will have three examples showing how backgrounds of +-- common aspect ratios will be stretched or clipped by that fitting mode. + +-- fit_choices will be used later to tell the actor that controls input what +-- actors to use for each choice. +local fit_choices= {} +-- actors will contain all the actors on the screen. +local actors= {} +-- width_per_choice is how much of the screen width will be used to separate +-- each choice +local width_per_choice= _screen.w / #BackgroundFitMode +-- xstart is the x position of the first choice. It starts at +-- width_per_choice / 2 because that's the x coordinate of the center of the +-- first choice. +local xstart= width_per_choice / 2 +-- mini_screen_w and mini_screen_h are the size of the miniature screen used +-- in the examples. +local mini_screen_w= _screen.w * .1 +local mini_screen_h= _screen.h * .1 + +-- This function returns a BitmapText that will be used to label each example +-- in each choice. +-- w and h are the width and height of the aspect ratio, passed in so they +-- can be displayed to be read. +function BGFitNormalExampleText(w, h) + return Def.BitmapText{ + -- To use a different font for the text, change the Font field. + Name= "example_label", Font= "Common Normal", + -- The "BG" part of the text is fetched with THEME:GetString so that it + -- can be translated. + Text= w .. ":" .. h .. " " .. THEME:GetString("ScreenSetBGFit", "BG"), + InitCommand= function(self) + -- This positions the text underneath its corresponding example. + self:y(mini_screen_h * .5 + 9) + self:zoom(.375) + end + } +end + +-- This loop goes through all the array elements of the BackgroundFitMode +-- table and creates a choice actor for each one. The BackgroundFitMode +-- table contains an entry for each background fitting mode. +for i, mode in ipairs(BackgroundFitMode) do + actors[#actors+1]= Def.ActorFrame{ + Name= mode, InitCommand= function(self) + -- This adds the actor to fit_choices so it can be used by the input + -- controller. + fit_choices[i]= self + -- This positions the choice on the screen. Choices are placed in a + -- row across the center of the screen, evenly spaced. + self:xy(xstart + ((i-1) * width_per_choice), _screen.cy) + end, + Def.BitmapText{ + -- This actor is a label for the choice, so the player knows the name + -- of their choice. + Name= "mode_label", Font= "Common Normal", + Text= THEME:GetString("ScreenSetBGFit", ToEnumShortString(mode)), + InitCommand= function(self) + -- Position the label above the topmost example. + self:y(mini_screen_h * -2.5) + self:zoom(.75) + end + }, + -- BGFitChoiceExample is a function that creates an example to show how + -- a bg with a given aspect ratio is affected by the fitting mode for + -- this choice. It takes a number of parameters that control how the + -- example is created. + -- The simplest way to modify it to suit your theme is to just change + -- the png files and the two colors. + BGFitChoiceExample{ + -- exname is the name of the image in Graphics that will be used as an + -- example bg to show distortion/cropping. "16_12_example.png" means + -- that "Graphics/ScreenSetBGFit 16_12_example.png" will be loaded. + exname= "16_12_example.png", + -- x and y are the position this example will be placed at. + -- x is 0 because the x positioning was handled above, when the choice + -- this example is part of was positioned. + -- This is the first example of 3, so y is set to position it above + -- the other two. + x= 0, y= mini_screen_h * -1.5, + -- mini_screen_w and mini_screen_h are the size of the miniature screen + -- the example will draw. + mini_screen_w= mini_screen_w, mini_screen_h= mini_screen_h, + -- example_function is the background fitting function for the mode + -- that will be set by this choice. bg_fit_functions is a table + -- that contains a function for each mode, so we set example_function + -- to the element of bg_fit_functions that has the same name as the + -- mode this choice is for. + example_function= bg_fit_functions[mode], + -- example_label is an actor that will be used to label this example, + -- so the player knows what size of bg is shown in this example. + example_label= BGFitNormalExampleText(16, 12), + -- sbg_color is the color of the quad representing the screen in the + -- example. sbg_color is the color of the outline representing the + -- screen in the example. + -- The quad is visible behind the example bg, so it's seen around the + -- edges when the example doesn't fill the miniature screen. + -- The outline is drawn over everything else so the player can see what + -- part of the example bg will be cut off. + sbg_color= color("0,0,0,1"), soutline_color= color("#39b54a")}, + -- The parameters passed to the other examples have the same meaning as + -- above. + BGFitChoiceExample{ + exname= "16_10_example.png", x= 0, y= 0, + mini_screen_w= mini_screen_w, mini_screen_h= mini_screen_h, + example_function= bg_fit_functions[mode], + example_label= BGFitNormalExampleText(16, 10), + sbg_color= color("0,0,0,1"), soutline_color= color("#39b54a")}, + BGFitChoiceExample{ + exname= "16_9_example.png", x= 0, y= mini_screen_h * 1.5, + mini_screen_w= mini_screen_w, mini_screen_h= mini_screen_h, + example_function= bg_fit_functions[mode], + example_label= BGFitNormalExampleText(16, 9), + sbg_color= color("0,0,0,1"), soutline_color= color("#39b54a")}, + } +end + +-- LoseFocus and GainFocus will be used on each choice to show which one +-- is currently selected. +local function LoseFocus(self) + -- We use stoptweening so that the player can't overflow the tween buffer + -- through repeated rapid input. Using stoptweening means that the actor + -- will stop at its current state and start tweening towards the new state + -- we are about to add to the tween stack. + -- If finishtweening was used, there would be jerking from the actor + -- suddenly reaching the end tween state. + self:stoptweening() + -- .25 seconds is a fine time for changing zoom size. + self:linear(.25) + -- Unfocused choices are normal size. + self:zoom(1) +end + +local function GainFocus(self) + self:stoptweening() + self:linear(.25) + -- The choice with focus is 1.5 size. + self:zoom(1.5) +end + +-- BGFitInputActor returns the actor that will handle input from the player +-- and apply their choice to the preference. We pass it fit_choices so that +-- it has the choice actors so it can show the player which once they have +-- selected. +actors[#actors+1]= BGFitInputActor(fit_choices, LoseFocus, GainFocus) +return Def.ActorFrame(actors) diff --git a/Themes/_fallback/Graphics/ScreenSetBGFit 16_10_example.png b/Themes/_fallback/Graphics/ScreenSetBGFit 16_10_example.png new file mode 100644 index 0000000000000000000000000000000000000000..69e8f9f2a0a36b1e67b73bdd113dc461adf06189 GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~g!2~3Y?s%RCQk(@Ik;M!Q+`=Ht$S`Y;1W=H@ z#M9T6{T_z^Gq?N;{hMUvg3;sD9ArDl=;OXk;vd$@?2>|o^ BD`5Zt literal 0 HcmV?d00001 diff --git a/Themes/_fallback/Graphics/ScreenSetBGFit 16_12_example.png b/Themes/_fallback/Graphics/ScreenSetBGFit 16_12_example.png new file mode 100644 index 0000000000000000000000000000000000000000..f77cb7a6c8858ae4d6c3cf0a7fe4deac941c8683 GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~e!2~3qw63}aq&N#aB8wRqxP?KOkzv*x37{Z* ziKnkC`#lZ;W^RFso;~3}A;}Wgh!W@g+}zZ>5(ej@)Wnk16ovB4k_-iRPv3y>Mm}+% zA}LQ7#}JM4$q5MwKmPx>=TymDrI>J~ZDIm5L)T@w4>kLFvw*4?JYD@<);T3K0RSNA BD&+tG literal 0 HcmV?d00001 diff --git a/Themes/_fallback/Graphics/ScreenSetBGFit 16_9_example.png b/Themes/_fallback/Graphics/ScreenSetBGFit 16_9_example.png new file mode 100644 index 0000000000000000000000000000000000000000..d33b7863797cb0bcd0402764e060b2851109c4d1 GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~k!2~3?cvz=`I0YV&#S9GG!XV7ZFl&wkP>{XE z)7O>#9)|!kx30pI4{ksq$r9Iy66gHf+|;}h2Ir#G#FEq$h4Rdj33=Expand 2->3 Expand 2x=Expand 2x Expand 3->4=Expand 3->4 Fast=Fast +FitInside=Fit Inside +FitInsideAvoidLetter=Avoid Letter +FitInsideAvoidPillar=Avoid Pillar Five Key Menu=Five Key Flat=Flat Flip=Flip @@ -850,6 +857,7 @@ AutogenGroupCourses=Autogen Group Courses AutogenSteps=Autogen Steps BGBrightness=Brightness Background=Background +BackgroundFitMode=BG Fit Mode BarDrain=Bar Drain BatLives=Bat Lives Base Difficulty=Base Difficulty @@ -1074,6 +1082,7 @@ Secret=Secret Secs Remaining=Seconds Remaining Server=Server Servers=Servers +Set BG Fit Mode=Set BG Fit Mode Set P1=Set P1 Set P2=Set P2 Set modifiers=Set modifiers @@ -1608,6 +1617,14 @@ size ???=size ??? HeaderText=Options HeaderSubText=You can configure the game here +[ScreenSetBGFit] +CoverDistort=Distort +CoverPreserve=Preserve +FitInside=Fit +FitInsideAvoidLetter=Avoid Letter +FitInsideAvoidPillar=Avoid Pillar +BG=BG + [ScreenPackages] DL @ %d KB/s=DL @ %d KB/s Download cancelled.=Download cancelled. diff --git a/Themes/_fallback/Scripts/02 Actor.lua b/Themes/_fallback/Scripts/02 Actor.lua index abcdfc3d8b..c886ae369d 100644 --- a/Themes/_fallback/Scripts/02 Actor.lua +++ b/Themes/_fallback/Scripts/02 Actor.lua @@ -151,8 +151,40 @@ function Actor:FullScreen() self:stretchto( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ) end +bg_fit_functions= { + BackgroundFitMode_CoverDistort= function(self, width, height) + local xscale= width / self:GetWidth() + local yscale= height / self:GetHeight() + self:zoomx(xscale) + self:zoomy(yscale) + end, + BackgroundFitMode_CoverPreserve= function(self, width, height) + local xscale= width / self:GetWidth() + local yscale= height / self:GetHeight() + self:zoom(math.max(xscale, yscale)) + end, + BackgroundFitMode_FitInside= function(self, width, height) + local xscale= width / self:GetWidth() + local yscale= height / self:GetHeight() + self:zoom(math.min(xscale, yscale)) + end, + BackgroundFitMode_FitInsideAvoidLetter= function(self, width, height) + local yscale= height / self:GetHeight() + self:zoom(yscale) + end, + BackgroundFitMode_FitInsideAvoidPillar= function(self, width, height) + local xscale= width / self:GetWidth() + self:zoom(xscale) + end +} + function Actor:scale_or_crop_background() - self:scaletocover(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) + local fit_mode= PREFSMAN:GetPreference("BackgroundFitMode") + if bg_fit_functions[fit_mode] then + bg_fit_functions[fit_mode](self, SCREEN_WIDTH, SCREEN_HEIGHT) + else + self:scaletocover(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) + end end function Actor:CenterX() self:x(SCREEN_CENTER_X) end diff --git a/Themes/_fallback/Scripts/04 LogDisplay.lua b/Themes/_fallback/Scripts/04 LogDisplay.lua index 537022be86..457807c165 100644 --- a/Themes/_fallback/Scripts/04 LogDisplay.lua +++ b/Themes/_fallback/Scripts/04 LogDisplay.lua @@ -319,3 +319,19 @@ function Def.LogDisplay(params) _G[params.Name .. "LogDisplay"]= new_log_display return new_log_display:create_actors(params) end + +--[[ +Copyright © 2014 Eric Reese / Kyzentun +All rights reserved. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +]] diff --git a/Themes/_fallback/Scripts/04 SetBGFitHelpers.lua b/Themes/_fallback/Scripts/04 SetBGFitHelpers.lua new file mode 100644 index 0000000000..bdd0bee819 --- /dev/null +++ b/Themes/_fallback/Scripts/04 SetBGFitHelpers.lua @@ -0,0 +1,126 @@ +function BGFitChoiceExample(params) + -- verify all the parameters, emitting an error for omitted ones. + local default_params= { + exname= "16_12_example.png", x= 0, y= 0, + mini_screen_w= 0, mini_screen_h= 0, + example_function= bg_fit_functions.BackgroundFitMode_CoverDistort, + sbg_color= Color.Black, soutline_color= Color.Green + } + for name, value in pairs(default_params) do + if not params[name] then + lua.ReportScriptError("BGFitChoiceExample not passed a '" .. name .. + "' param.") + params[name]= value + end + end + return Def.ActorFrame{ + Name= params.exname, InitCommand= function(self) + self:xy(params.x, params.y) + end, + -- Quad representing the screen, to show behind the example quad. + Def.Quad{ + Name="mini_scr", InitCommand= function(self) + self:setsize(params.mini_screen_w, params.mini_screen_h) + self:diffuse(params.sbg_color) + end + }, + -- Sprite representing the example bg. + Def.Sprite{ + Name="mini_ex", InitCommand= function(self) + self:LoadBackground(THEME:GetPathG("ScreenSetBGFit", params.exname)) + self:SetTextureFiltering(false) + params.example_function(self, params.mini_screen_w, params.mini_screen_h) + end + }, + -- AMV for the outline of the screen, to show where the screen is so + -- cropping is visible. + Def.ActorMultiVertex{ + Name="mini_outline", InitCommand= function(self) + local hw= params.mini_screen_w / 2 + local hh= params.mini_screen_h / 2 + local verts= { + {{-hw, -hh, 0}, params.soutline_color}, + {{hw, -hh, 0}, params.soutline_color}, + {{hw, hh, 0}, params.soutline_color}, + {{-hw, hh, 0}, params.soutline_color}, + {{-hw, -hh, 0}, params.soutline_color}, + } + self:SetVertices(verts) + self:SetLineWidth(1) + self:SetDrawState{Mode= "DrawMode_LineStrip"} + end + }, + params.example_label, + } +end + +function BGFitInputActor(choices, lose_focus, gain_focus) + local curr_choice= BackgroundFitMode:Reverse()[PREFSMAN:GetPreference("BackgroundFitMode")] + 1 -- reverse is 0-indexed + local left_buttons= {MenuLeft= true, MenuUp= true} + local right_buttons= {MenuRight= true, MenuDown= true} + local saw_press= false + if not lose_focus then + lua.ReportScriptError("BGFitInputActor not given a lose_focus function.") + lose_focus= function() end + end + if not gain_focus then + lua.ReportScriptError("BGFitInputActor not given a gain_focus function.") + gain_focus= function() end + end + local function check_choice_and_change_focus(focus_func) + if choices[curr_choice] then + focus_func(choices[curr_choice]) + else + lua.ReportScriptError("BGFitInputActor not given a choice actor for the " .. BackgroundFitMode[curr_choice] .. " mode.") + end + end + local function input(event) + if event.type == "InputEventType_Release" then return false end + if event.type == "InputEventType_Repeat" and not saw_press then + return false + end + if not event.GameButton then return false end + saw_press= true + if left_buttons[event.GameButton] or right_buttons[event.GameButton] then + check_choice_and_change_focus(lose_focus) + if left_buttons[event.GameButton] then + curr_choice= math.max(curr_choice - 1, 1) + else + curr_choice= math.min(curr_choice + 1, #choices) + end + check_choice_and_change_focus(gain_focus) + PREFSMAN:SetPreference("BackgroundFitMode", BackgroundFitMode[curr_choice]) + SOUND:PlayOnce(THEME:GetPathS("ScreenSelectMaster", "change")) + elseif event.GameButton == "Start" or event.GameButton == "Back" then + SOUND:PlayOnce(THEME:GetPathS("ScreenSelectMaster", "start")) + SCREENMAN:GetTopScreen():StartTransitioningScreen("SM_GoToNextScreen") + end + return false + end + return Def.ActorFrame{ + Name= "input_init", + OnCommand= function(self) + local screen= SCREENMAN:GetTopScreen() + screen:AddInputCallback(input) + choices[curr_choice]:stoptweening() + choices[curr_choice]:linear(.25) + choices[curr_choice]:zoom(1.5) + end + } +end + +--[[ +Copyright © 2014 Eric Reese / Kyzentun +All rights reserved. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +]] diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index b99685446d..8f0cf7ed36 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -1644,6 +1644,13 @@ TimerY= TimerOnCommand= TimerOffCommand= +[ScreenSetBGFit] +Class="ScreenWithMenuElements" +Fallback="ScreenWithMenuElements" +NextScreen="ScreenOptionsService" +RepeatRate=10 +RepeatDelay=.25 + [ScreenWithMenuElementsBlank] Fallback="ScreenWithMenuElements" UpdateOnMessage="" @@ -2689,7 +2696,7 @@ Fallback="ScreenOptionsSimpleService" NextScreen=Branch.AfterInit() PrevScreen=Branch.AfterInit() -LineNames="Sync,GameType,KeyConfig,TestInput,Input,Reload,Arcade,Appearance,GraphicSound,Profiles,Network,UI,Advanced,Credits" +LineNames="Sync,GameType,KeyConfig,TestInput,Input,Reload,Arcade,Appearance,BGFit,GraphicSound,Profiles,Network,UI,Advanced,Credits" LineSync="gamecommand;screen,ScreenGameplaySyncMachine;name,Calibrate Machine Sync" LineGameType="gamecommand;screen,ScreenSelectGame;name,Select Game" LineKeyConfig="gamecommand;screen,ScreenMapControllers;name,Key Joy Mappings" @@ -2698,7 +2705,7 @@ LineInput="gamecommand;screen,ScreenOptionsInput;name,Input Options" LineReload="gamecommand;screen,ScreenReloadSongs;name,Reload Songs" LineArcade="gamecommand;screen,ScreenOptionsArcade;name,Arcade Options" LineAppearance="gamecommand;screen,ScreenAppearanceOptions;name,Appearance Options" - +LineBGFit="gamecommand;screen,ScreenSetBGFit;name,Set BG Fit Mode" LineGraphicSound="gamecommand;screen,ScreenOptionsGraphicsSound;name,Graphics/Sound Options" LineProfiles="gamecommand;screen,ScreenOptionsManageProfiles;name,Profiles" LineNetwork="gamecommand;screen,ScreenNetworkOptions;name,Network Options" @@ -2970,7 +2977,7 @@ Line4="conf,DefaultNoteSkin" Line5="conf,PercentageScoring" Line14="conf,RandomBackgroundMode" Line15="conf,BGBrightness" -LineSB="conf,StretchBackgrounds" +LineSB="conf,BackgroundFitMode" Line17="conf,ShowDancingCharacters" Line18="conf,ShowBeginnerHelper" Line19="conf,NumBackgrounds" diff --git a/Themes/default/BGAnimations/ScreenStageInformation underlay/default.lua b/Themes/default/BGAnimations/ScreenStageInformation underlay/default.lua index cac3d01897..cffe860349 100644 --- a/Themes/default/BGAnimations/ScreenStageInformation underlay/default.lua +++ b/Themes/default/BGAnimations/ScreenStageInformation underlay/default.lua @@ -38,11 +38,7 @@ else InitCommand=cmd(Center;diffusealpha,0); BeginCommand=cmd(LoadFromCurrentSongBackground); OnCommand=function(self) - if PREFSMAN:GetPreference("StretchBackgrounds") then - self:SetSize(SCREEN_WIDTH,SCREEN_HEIGHT) - else - self:scale_or_crop_background() - end + self:scale_or_crop_background() self:sleep(0.5) self:linear(0.50) self:diffusealpha(1) diff --git a/Themes/default/metrics.ini b/Themes/default/metrics.ini index 3759e277ea..c54e13ae65 100644 --- a/Themes/default/metrics.ini +++ b/Themes/default/metrics.ini @@ -1262,7 +1262,7 @@ ExplanationTogetherOffCommand=stoptweening [ScreenOptionsService] ShowHeader=true -LineNames="Sync,GameType,KeyConfig,TestInput,Input,Reload,Arcade,Appearance,Theme,GraphicSound,Profiles,Network,UI,Advanced,Credits" +LineNames="Sync,GameType,KeyConfig,TestInput,Input,Reload,Arcade,Appearance,Theme,BGFit,GraphicSound,Profiles,Network,UI,Advanced,Credits" LineTheme="gamecommand;screen,ScreenOptionsTheme;name,Theme Options" # ScreenOptionsSystemDirection" diff --git a/src/PrefsManager.cpp b/src/PrefsManager.cpp index 27522d3628..64d742babc 100644 --- a/src/PrefsManager.cpp +++ b/src/PrefsManager.cpp @@ -125,6 +125,17 @@ XToString( CourseSortOrders ); StringToX( CourseSortOrders ); LuaXType( CourseSortOrders ); +static const char *BackgroundFitModeNames[] = { + "CoverDistort", + "CoverPreserve", + "FitInside", + "FitInsideAvoidLetter", + "FitInsideAvoidPillar", +}; +XToString( BackgroundFitMode ); +StringToX( BackgroundFitMode ); +LuaXType( BackgroundFitMode ); + bool g_bAutoRestart = false; #ifdef DEBUG # define TRUE_IF_DEBUG true @@ -162,6 +173,7 @@ PrefsManager::PrefsManager() : m_iTextureColorDepth ( "TextureColorDepth", 16 ), m_iMovieColorDepth ( "MovieColorDepth", 16 ), m_bStretchBackgrounds ( "StretchBackgrounds", false ), + m_BGFitMode("BackgroundFitMode", BFM_CoverPreserve), m_HighResolutionTextures ( "HighResolutionTextures", HighResolutionTextures_Auto ), m_iMaxTextureResolution ( "MaxTextureResolution", 2048 ), m_iRefreshRate ( "RefreshRate", REFRESH_DEFAULT ), diff --git a/src/PrefsManager.h b/src/PrefsManager.h index 509acf8d8d..4c34be5429 100644 --- a/src/PrefsManager.h +++ b/src/PrefsManager.h @@ -111,6 +111,16 @@ enum CourseSortOrders NUM_CourseSortOrders, CourseSortOrders_Invalid }; +enum BackgroundFitMode +{ + BFM_CoverDistort, + BFM_CoverPreserve, + BFM_FitInside, + BFM_FitInsideAvoidLetter, + BFM_FitInsideAvoidPillar, + NUM_BackgroundFitMode, + BackgroundFitMode_Invalid +}; /** @brief Holds user-chosen preferences that are saved between sessions. */ class PrefsManager @@ -154,6 +164,7 @@ public: Preference m_iTextureColorDepth; Preference m_iMovieColorDepth; Preference m_bStretchBackgrounds; + Preference m_BGFitMode; Preference m_HighResolutionTextures; Preference m_iMaxTextureResolution; Preference m_iRefreshRate; diff --git a/src/ScreenOptionsMasterPrefs.cpp b/src/ScreenOptionsMasterPrefs.cpp index 75ea161ea1..0a64a4727f 100644 --- a/src/ScreenOptionsMasterPrefs.cpp +++ b/src/ScreenOptionsMasterPrefs.cpp @@ -692,7 +692,8 @@ static void InitializeConfOptions() g_ConfOptions.back().m_sPrefName = "BGBrightness"; ADD( ConfOption( "BGBrightnessOrStatic", BGBrightnessOrStatic, "Disabled","25% Bright","50% Bright","75% Bright" ) ); g_ConfOptions.back().m_sPrefName = "BGBrightness"; - ADD( ConfOption( "StretchBackgrounds", MovePref, "Off","On" ) ); + ADD( ConfOption( "StretchBackgrounds", MovePref, "Off","On" ) ); // Deprecated, unused by default/_fallback. -Kyz + ADD( ConfOption( "BackgroundFitMode", MovePref, "CoverDistort", "CoverPreserve", "FitInside", "FitInsideAvoidLetter", "FitInsideAvoidPillar") ); ADD( ConfOption( "ShowDanger", MovePref, "Hide","Show" ) ); ADD( ConfOption( "ShowDancingCharacters", MovePref, "Default to Off","Default to Random","Select" ) );