From 580ff0716aa43c3e412044ae03dbcd1b031f5c2b Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 29 Dec 2005 08:12:51 +0000 Subject: [PATCH] Centering is a user preference, to adjust the screen, not a theme setting. It's usually tied to the screen resolution (will usually need readjustment anyway if the resolution changes). Treat the values as pixels, as if we were using glViewport to do this. (Reduces dependencies on ScreenDimensions.h, and we don't need to worry about calling ChangeCentering when the theme changes.) --- stepmania/src/RageDisplay.cpp | 24 +++++++++++++++++++----- stepmania/src/RageDisplay.h | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 53346957e0..3e3d09c73e 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -29,6 +29,8 @@ static int g_iFramesRenderedSinceLastCheck, g_iNumChecksSinceLastReset; static RageTimer g_LastFrameEndedAt( RageZeroTimer ); +static int g_iTranslateX = 0, g_iTranslateY = 0, g_iAddWidth = 0, g_iAddHeight = 0; + RageDisplay* DISPLAY = NULL; Preference LOG_FPS( "LogFPS", true ); @@ -602,13 +604,25 @@ RageMatrix RageDisplay::GetFrustumMatrix( float l, float r, float b, float t, fl return m; } -void RageDisplay::ChangeCentering( int trans_x, int trans_y, int add_width, int add_height ) +void RageDisplay::ChangeCentering( int iTranslateX, int iTranslateY, int iAddWidth, int iAddHeight ) +{ + g_iTranslateX = iTranslateX; + g_iTranslateY = iTranslateY; + g_iAddWidth = iAddWidth; + g_iAddHeight = iAddHeight; + + UpdateCentering(); +} + +void RageDisplay::UpdateCentering() { // in screen space, left edge = -1, right edge = 1, bottom edge = -1. top edge = 1 - float fPercentShiftX = SCALE( trans_x, 0, SCREEN_WIDTH, 0, +2.0f ); - float fPercentShiftY = SCALE( trans_y, 0, SCREEN_HEIGHT, 0, -2.0f ); - float fPercentScaleX = SCALE( add_width, 0, SCREEN_WIDTH, 1.0f, 2.0f ); - float fPercentScaleY = SCALE( add_height, 0, SCREEN_HEIGHT, 1.0f, 2.0f ); + float fWidth = (float) GetActualVideoModeParams().width; + float fHeight = (float) GetActualVideoModeParams().height; + float fPercentShiftX = SCALE( g_iTranslateX, 0, fWidth, 0, +2.0f ); + float fPercentShiftY = SCALE( g_iTranslateY, 0, fHeight, 0, -2.0f ); + float fPercentScaleX = SCALE( g_iAddWidth, 0, fWidth, 1.0f, 2.0f ); + float fPercentScaleY = SCALE( g_iAddHeight, 0, fHeight, 1.0f, 2.0f ); RageMatrix m1; RageMatrix m2; diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index a561b99549..c46dd2a810 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -313,6 +313,7 @@ protected: // Matrix that adjusts position and scale of image on the screen // RageMatrix m_Centering; + void UpdateCentering(); // Called by the RageDisplay derivitives const RageMatrix* GetCentering() { return &m_Centering; }