diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index d827fc6f25..52f8c2f3f1 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -2976,7 +2976,7 @@ Line6=conf,RandomBackgrounds [ScreenAppearanceOptions] Fallback=ScreenOptionsSubmenu -LineNames=1,2,3,4,5,6,7,8,9,10,11,12,13 +LineNames=1,2,3,4,5,6,7,8,9,10,11,12,13,14 OptionMenuFlags=together;explanations Line1=conf,Language Line2=conf,Announcer @@ -2991,6 +2991,7 @@ Line10=conf,CourseSort Line11=conf,RandomAtEnd Line12=conf,Translations Line13=conf,Lyrics +Line14=conf,AspectRatio [ScreenOtherOptions] Fallback=ScreenOptionsSubmenu diff --git a/stepmania/src/LuaHelpers.cpp b/stepmania/src/LuaHelpers.cpp index 6537c197ea..1f154fafaa 100644 --- a/stepmania/src/LuaHelpers.cpp +++ b/stepmania/src/LuaHelpers.cpp @@ -153,8 +153,8 @@ void Lua::UpdateGlobals() ASSERT( L ); /* Important: explicitly refresh cached metrics that we use. */ - SCREEN_WIDTH.Read(); - SCREEN_HEIGHT.Read(); + THEME_SCREEN_WIDTH.Read(); + THEME_SCREEN_HEIGHT.Read(); lua_pushnumber( L, SCREEN_WIDTH ); lua_setglobal( L, "SCREEN_WIDTH" ); diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index 44bb93aa86..c96a3a355d 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -75,6 +75,7 @@ PrefsManager::PrefsManager() : m_iMovieColorDepth ( Options, "MovieColorDepth", 16 ), m_iMaxTextureResolution ( Options, "MaxTextureResolution", 2048 ), m_iRefreshRate ( Options, "RefreshRate", REFRESH_DEFAULT ), + m_fAspectRatio ( Options, "AspectRatio", 4/3.0f ), m_bShowStats ( Options, "ShowStats", #ifdef DEBUG true diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index ec1ee70690..949a5df46a 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -26,6 +26,7 @@ public: Preference m_iMovieColorDepth; Preference m_iMaxTextureResolution; Preference m_iRefreshRate; + Preference m_fAspectRatio; Preference m_bShowStats; Preference m_bShowBanners; diff --git a/stepmania/src/ScreenDimensions.cpp b/stepmania/src/ScreenDimensions.cpp index c127b698ba..789e3afb05 100644 --- a/stepmania/src/ScreenDimensions.cpp +++ b/stepmania/src/ScreenDimensions.cpp @@ -1,8 +1,37 @@ #include "global.h" #include "ScreenDimensions.h" +#include "PrefsManager.h" + + +ThemeMetric THEME_SCREEN_WIDTH("Common","ScreenWidth"); +ThemeMetric THEME_SCREEN_HEIGHT("Common","ScreenHeight"); + +// +// The theme's logical resolution specifies the minimum screen width +// and the minimum screen height with a 4:3 aspect ratio. Scale just one +// of the dimensions up to meet the requested aspect ratio. +// + +#define ASPECT_4_TO_3 (4/3.0f) + +float ScreenWidth() +{ + float fScale = 1; + if( PREFSMAN->m_fAspectRatio > ASPECT_4_TO_3 ) + fScale = PREFSMAN->m_fAspectRatio / ASPECT_4_TO_3; + ASSERT( fScale >= 1 ); + return THEME_SCREEN_WIDTH * fScale; +} + +float ScreenHeight() +{ + float fScale = 1; + if( PREFSMAN->m_fAspectRatio < ASPECT_4_TO_3 ) + fScale = ASPECT_4_TO_3 / PREFSMAN->m_fAspectRatio; + ASSERT( fScale >= 1 ); + return THEME_SCREEN_HEIGHT * fScale; +} -ThemeMetric SCREEN_WIDTH("Common","ScreenWidth"); -ThemeMetric SCREEN_HEIGHT("Common","ScreenHeight"); /* * (c) 2001-2002 Chris Danford diff --git a/stepmania/src/ScreenDimensions.h b/stepmania/src/ScreenDimensions.h index 39c48a41d0..4ce35be350 100644 --- a/stepmania/src/ScreenDimensions.h +++ b/stepmania/src/ScreenDimensions.h @@ -6,8 +6,13 @@ #include "ThemeManager.h" #include "ThemeMetric.h" -extern ThemeMetric SCREEN_WIDTH; -extern ThemeMetric SCREEN_HEIGHT; +#define SCREEN_WIDTH ScreenWidth() +#define SCREEN_HEIGHT ScreenHeight() +float ScreenWidth(); +float ScreenHeight(); + +extern ThemeMetric THEME_SCREEN_WIDTH; +extern ThemeMetric THEME_SCREEN_HEIGHT; #define SCREEN_LEFT (0) #define SCREEN_RIGHT (SCREEN_WIDTH) diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index cd2b686779..8a717c8a78 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -95,6 +95,9 @@ void ScreenManager::ThemeChanged() SAFE_DELETE( m_SystemLayer ); m_SystemLayer = new ScreenSystemLayer; m_SystemLayer->RefreshCreditsMessages(); + + // reload shared BGA + m_pSharedBGA->LoadFromAniDir( m_sLastLoadedBackgroundPath ); } void ScreenManager::EmptyDeleteQueue() @@ -361,9 +364,9 @@ retry: if( sNewBGA.empty() ) { m_pSharedBGA->Unload(); - m_sLastLoadedBackground = ""; + m_sLastLoadedBackgroundPath = ""; } - else if( m_sLastLoadedBackground != sNewBGA ) + else if( m_sLastLoadedBackgroundPath != sNewBGA ) { // Create the new background before deleting the previous so that we keep // any common textures loaded. @@ -372,7 +375,7 @@ retry: SAFE_DELETE( m_pSharedBGA ); m_pSharedBGA = pNewBGA; - m_sLastLoadedBackground = sNewBGA; + m_sLastLoadedBackgroundPath = sNewBGA; } bool bWasOnSystemMenu = GAMESTATE->m_bIsOnSystemMenu; diff --git a/stepmania/src/ScreenManager.h b/stepmania/src/ScreenManager.h index d7000092f3..458e58a429 100644 --- a/stepmania/src/ScreenManager.h +++ b/stepmania/src/ScreenManager.h @@ -66,7 +66,7 @@ private: vector m_ScreenStack; // bottommost to topmost ScreenSystemLayer *m_SystemLayer; - CString m_sLastLoadedBackground; + CString m_sLastLoadedBackgroundPath; CString m_sDelayedScreen; ScreenMessage m_MessageSendOnPop; vector m_vPreparedScreens; diff --git a/stepmania/src/ScreenOptionsMaster.cpp b/stepmania/src/ScreenOptionsMaster.cpp index 0ac15db561..2a2d4afdd1 100644 --- a/stepmania/src/ScreenOptionsMaster.cpp +++ b/stepmania/src/ScreenOptionsMaster.cpp @@ -21,6 +21,7 @@ #include "RageSoundManager.h" #include "ProfileManager.h" #include "StepsUtil.h" +#include "LuaHelpers.h" #define LINE_NAMES THEME->GetMetric (m_sName,"LineNames") #define OPTION_MENU_FLAGS THEME->GetMetric (m_sName,"OptionMenuFlags") @@ -535,9 +536,19 @@ void ScreenOptionsMaster::ExportOptions() if( m_sNextScreen == "" ) m_sNextScreen = NEXT_SCREEN; - /* Did the theme change? */ + if( ChangeMask & OPT_APPLY_ASPECT_RATIO ) + { + Lua::UpdateGlobals(); // This needs to be done before resetting the projection matrix below + SCREENMAN->ThemeChanged(); // recreate ScreenSystemLayer and SharedBGA + } + + /* If the theme changes, we need to reset RageDisplay to apply new theme + * window title and icon. */ + /* If the aspect ratio changes, we need to reset RageDisplay so that the + * projection matrix is re-created using the new screen dimensions. */ if( (ChangeMask & OPT_APPLY_THEME) || - (ChangeMask & OPT_APPLY_GRAPHICS) ) // reset graphics to apply new window title and icon + (ChangeMask & OPT_APPLY_GRAPHICS) || + (ChangeMask & OPT_APPLY_ASPECT_RATIO) ) ApplyGraphicOptions(); if( ChangeMask & OPT_SAVE_PREFERENCES ) diff --git a/stepmania/src/ScreenOptionsMasterPrefs.cpp b/stepmania/src/ScreenOptionsMasterPrefs.cpp index b70654df22..255fc646f7 100644 --- a/stepmania/src/ScreenOptionsMasterPrefs.cpp +++ b/stepmania/src/ScreenOptionsMasterPrefs.cpp @@ -440,6 +440,12 @@ static void RefreshRate( int &sel, bool ToSel, const ConfOption *pConfOption ) MoveMap( sel, PREFSMAN->m_iRefreshRate.Value(), ToSel, mapping, ARRAYSIZE(mapping) ); } +static void AspectRatio( int &sel, bool ToSel, const ConfOption *pConfOption ) +{ + const float mapping[] = { 3/4.f,1,4/3.0f,16/10.0f,16/9.f, 8/3.f }; + MoveMap( sel, PREFSMAN->m_fAspectRatio.Value(), ToSel, mapping, ARRAYSIZE(mapping) ); +} + /* Sound options */ MOVE( ResamplingQuality, PREFSMAN->m_iSoundResampleQuality ); MOVE( AttractSoundFrequency,PREFSMAN->m_iAttractSoundFrequency ); @@ -546,11 +552,13 @@ static void InitializeConfOptions() ADD( ConfOption( "DelayedTextureDelete", MovePref, "OFF","ON" ) ); g_ConfOptions.back().m_iEffects = OPT_APPLY_GRAPHICS; ADD( ConfOption( "CelShade\nModels", CelShadeModels, "OFF","ON" ) ); - ADD( ConfOption( "SmoothLines", SmoothLines, "OFF","ON" ) ); + ADD( ConfOption( "Smooth\nLines", SmoothLines, "OFF","ON" ) ); g_ConfOptions.back().m_iEffects = OPT_APPLY_GRAPHICS; ADD( ConfOption( "Refresh\nRate", RefreshRate, "DEFAULT","60","70","72","75","80","85","90","100","120","150" ) ); g_ConfOptions.back().m_iEffects = OPT_APPLY_GRAPHICS; - ADD( ConfOption( "Vsync", MovePref, "NO", "YES" ) ); + ADD( ConfOption( "Aspect\nRatio", AspectRatio, "3:4","1:1","4:3","16:10","16:9","8:3" ) ); + g_ConfOptions.back().m_iEffects = OPT_APPLY_ASPECT_RATIO; + ADD( ConfOption( "Vsync", MovePref, "NO", "YES" ) ); g_ConfOptions.back().m_iEffects = OPT_APPLY_GRAPHICS; ADD( ConfOption( "ShowStats", MovePref, "OFF","ON" ) ); ADD( ConfOption( "ShowBanners", MovePref, "OFF","ON" ) ); diff --git a/stepmania/src/ScreenOptionsMasterPrefs.h b/stepmania/src/ScreenOptionsMasterPrefs.h index 4a84d802c8..a7cec78294 100644 --- a/stepmania/src/ScreenOptionsMasterPrefs.h +++ b/stepmania/src/ScreenOptionsMasterPrefs.h @@ -8,6 +8,7 @@ static const int MAX_OPTIONS=16; #define OPT_RESET_GAME (1<<3) #define OPT_APPLY_SOUND (1<<4) #define OPT_APPLY_SONG (1<<5) +#define OPT_APPLY_ASPECT_RATIO (1<<6) struct ConfOption {