From 70446551a979e194ae6410d245067177c8131b66 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 11 Oct 2003 01:51:36 +0000 Subject: [PATCH] add half-finished screen centering code (necessary for arcade and Xbox) --- .../BGAnimations/ScreenCenterImage in.redir | 1 + .../BGAnimations/ScreenCenterImage out.redir | 1 + .../Graphics/ScreenCenterImage footer.redir | 1 + .../Graphics/ScreenCenterImage header.redir | 1 + stepmania/Themes/default/metrics.ini | 30 ++++++++++++------- stepmania/src/RageDisplay.cpp | 20 +++++++++++++ stepmania/src/RageDisplay.h | 12 ++++++++ stepmania/src/RageDisplay_D3D.cpp | 7 +++-- stepmania/src/RageDisplay_OGL.cpp | 3 +- stepmania/src/RageMath.cpp | 5 ++++ stepmania/src/Screen.cpp | 2 ++ stepmania/src/ScreenMapControllers.cpp | 1 + 12 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 stepmania/Themes/default/BGAnimations/ScreenCenterImage in.redir create mode 100644 stepmania/Themes/default/BGAnimations/ScreenCenterImage out.redir create mode 100644 stepmania/Themes/default/Graphics/ScreenCenterImage footer.redir create mode 100644 stepmania/Themes/default/Graphics/ScreenCenterImage header.redir diff --git a/stepmania/Themes/default/BGAnimations/ScreenCenterImage in.redir b/stepmania/Themes/default/BGAnimations/ScreenCenterImage in.redir new file mode 100644 index 0000000000..0f6547301b --- /dev/null +++ b/stepmania/Themes/default/BGAnimations/ScreenCenterImage in.redir @@ -0,0 +1 @@ +_options to options \ No newline at end of file diff --git a/stepmania/Themes/default/BGAnimations/ScreenCenterImage out.redir b/stepmania/Themes/default/BGAnimations/ScreenCenterImage out.redir new file mode 100644 index 0000000000..0f6547301b --- /dev/null +++ b/stepmania/Themes/default/BGAnimations/ScreenCenterImage out.redir @@ -0,0 +1 @@ +_options to options \ No newline at end of file diff --git a/stepmania/Themes/default/Graphics/ScreenCenterImage footer.redir b/stepmania/Themes/default/Graphics/ScreenCenterImage footer.redir new file mode 100644 index 0000000000..a8c38e48f6 --- /dev/null +++ b/stepmania/Themes/default/Graphics/ScreenCenterImage footer.redir @@ -0,0 +1 @@ +_shared footer diff --git a/stepmania/Themes/default/Graphics/ScreenCenterImage header.redir b/stepmania/Themes/default/Graphics/ScreenCenterImage header.redir new file mode 100644 index 0000000000..05fbd67250 --- /dev/null +++ b/stepmania/Themes/default/Graphics/ScreenCenterImage header.redir @@ -0,0 +1 @@ +_shared menu header diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index dca1b40fb5..59baf32da8 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -1747,6 +1747,11 @@ OddLineOut=stoptweening;accelerate,0.3;addx,640; StyleIcon=0 TimerSeconds=0 +[ScreenCenterImage] +HelpText=Use arrow keys to navigate, ENTER to assign, SPACE to clear, ESCAPE when done. +StyleIcon=0 +TimerSeconds=0 + [HoldGhostArrow] WarmUpSeconds=0.25 @@ -2558,19 +2563,20 @@ OptionMenuFlags=together;forceallplayers;rows,11;smnavigation # This NextScreen is only used for the "exit" choice. NextScreen=ScreenTitleMenu PrevScreen=ScreenTitleMenu -NumRows=12 +NumRows=13 Line1=list,Appearance Options;title,; Line2=list,Autogen Options;title,; Line3=list,Background Options;title,; -Line4=list,Coin Options;title,; -Line5=list,Config Key/Joy Mappings;title,; -Line6=list,Input Options;title,; -Line7=list,Gameplay Options;title,; -Line8=list,Graphic Options;title,; -Line9=list,Machine Options;title,; -Line10=list,Sound Options;title,; -Line11=list,Profile Options;title,; -Line12=list,Reload Songs/Courses;title,; +Line4=list,Center Image;title,; +Line5=list,Coin Options;title,; +Line6=list,Config Key/Joy Mappings;title,; +Line7=list,Input Options;title,; +Line8=list,Gameplay Options;title,; +Line9=list,Graphic Options;title,; +Line10=list,Machine Options;title,; +Line11=list,Sound Options;title,; +Line12=list,Profile Options;title,; +Line13=list,Reload Songs/Courses;title,; [TextBanner] Width=180 @@ -3059,6 +3065,10 @@ Background Options=1,together Background OptionsDefault= Background Options,1=screen,ScreenBackgroundOptions@ScreenOptionsMaster Background OptionsName,1=Background Options +Center Image=1,together +Center ImageDefault= +Center Image,1=screen,ScreenCenterImage +Center ImageName,1=Center Image Coin Options=1,together Coin OptionsDefault= Coin Options,1=screen,ScreenCoinOptions@ScreenOptionsMaster diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index c80044fd8b..a7ba2c3a37 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -206,6 +206,7 @@ void RageDisplay::SetDefaultRenderStates() SetBlendMode( BLEND_NORMAL ); SetTextureFiltering( true ); LoadMenuPerspective(0, CENTER_X, CENTER_Y); // 0 FOV = ortho + ResetCentering(); } @@ -619,3 +620,22 @@ RageMatrix RageDisplay::GetFrustumMatrix( float l, float r, float b, float t, fl 0, 0, D, 0 ); return m; } + +void RageDisplay::ResetCentering() +{ + RageMatrixIdentity( &m_Centering ); +} + +void RageDisplay::CenteringTranslate( float x, float y, float z ) +{ + RageMatrix m; + RageMatrixTranslation( &m, x, y, z ); + RageMatrixMultiply( &m_Centering, &m, &m_Centering ); +} + +void RageDisplay::CenteringScale( float x, float y, float z ) +{ + RageMatrix m; + RageMatrixScaling( &m, x, y, z ); + RageMatrixMultiply( &m_Centering, &m, &m_Centering ); +} diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index e33cf9b1f9..b1d2dfbdd3 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -247,6 +247,12 @@ public: void LoadMenuPerspective( float fovDegrees, float fVanishPointX, float fVanishPointY ); void LoadLookAt( float fov, const RageVector3 &Eye, const RageVector3 &At, const RageVector3 &Up ); + /* Centering matrix */ + void CenteringTranslate( float x, float y, float z ); + void CenteringScale( float x, float y, float z ); + void ResetCentering(); + + SDL_Surface *CreateSurfaceFromPixfmt( PixelFormat pixfmt, void *pixels, int width, int height, int pitch ); PixelFormat FindPixelFormat( int bpp, int Rmask, int Gmask, int Bmask, int Amask ); @@ -257,7 +263,13 @@ protected: virtual RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf ) = 0; virtual RageMatrix GetFrustumMatrix( float l, float r, float b, float t, float zn, float zf ); + // + // Matrix that adjusts position and scale of image on the screen + // + RageMatrix m_Centering; + // Called by the RageDisplay derivitives + const RageMatrix* GetCentering() { return &m_Centering; } const RageMatrix* GetProjectionTop(); const RageMatrix* GetViewTop(); const RageMatrix* GetWorldTop(); diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index a0cc1e8849..63032f88f2 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -243,11 +243,12 @@ RageDisplay_D3D::RageDisplay_D3D( VideoModeParams p ) LOG->Trace( "Driver: %s\n" "Description: %s\n" - "Max texture size: %d\n", + "Max texture size: %d\n" + "Alpha in palette: %s\n", identifier.Driver, identifier.Description, - g_DeviceCaps.MaxTextureWidth - ); + g_DeviceCaps.MaxTextureWidth, + (g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) ? "yes" : "no" ); LOG->Trace( "This display adaptor supports the following modes:" ); D3DDISPLAYMODE mode; diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 03035d147d..be5e9acb6d 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -741,7 +741,8 @@ static void SetupVertices( const RageSpriteVertex v[], int iNumVerts ) glMatrixMode( GL_PROJECTION ); \ glLoadMatrixf( (const float*)GetProjectionTop() ); \ RageMatrix modelView; \ - RageMatrixMultiply( &modelView, GetViewTop(), GetWorldTop() ); \ + RageMatrixMultiply( &modelView, GetCentering(), GetViewTop() ); \ + RageMatrixMultiply( &modelView, &modelView, GetWorldTop() ); \ glMatrixMode( GL_MODELVIEW ); \ glLoadMatrixf( (const float*)&modelView ); \ diff --git a/stepmania/src/RageMath.cpp b/stepmania/src/RageMath.cpp index 7d960b4523..6ac197d83e 100644 --- a/stepmania/src/RageMath.cpp +++ b/stepmania/src/RageMath.cpp @@ -96,6 +96,10 @@ RageMatrix RageMatrix::GetTranspose() const void RageMatrixMultiply( RageMatrix* pOut, const RageMatrix* pA, const RageMatrix* pB ) { +//#if defined(_WINDOWS) || defined(_XBOX) +// // <30 cycles for theirs versus >100 for ours. +// D3DXMatrixMultiply( (D3DMATRIX*)pOut, (D3DMATRIX*)pA, (D3DMATRIX*)pB ); +//#else const RageMatrix &a = *pA; const RageMatrix &b = *pB; @@ -118,6 +122,7 @@ void RageMatrixMultiply( RageMatrix* pOut, const RageMatrix* pA, const RageMatri b.m30*a.m03+b.m31*a.m13+b.m32*a.m23+b.m33*a.m33 ); // phew! +//#endif } void RageMatrixTranslation( RageMatrix* pOut, float x, float y, float z ) diff --git a/stepmania/src/Screen.cpp b/stepmania/src/Screen.cpp index 43e8399226..60a9449d54 100644 --- a/stepmania/src/Screen.cpp +++ b/stepmania/src/Screen.cpp @@ -288,6 +288,7 @@ void Screen::ClearMessageQueue( const ScreenMessage SM ) #include "ScreenAttract.h" #include "ScreenReloadSongs.h" #include "ScreenOptionsMaster.h" +#include "ScreenCenterImage.h" Screen* Screen::Create( CString sClassName ) { @@ -385,6 +386,7 @@ Screen* Screen::Create( CString sClassName ) IF_RETURN( ScreenExit ); IF_RETURN( ScreenReloadSongs ); IF_RETURN( ScreenOptionsMaster ); + IF_RETURN( ScreenCenterImage ); RageException::Throw( "Invalid Screen class name '%s'", sClassName.c_str() ); } diff --git a/stepmania/src/ScreenMapControllers.cpp b/stepmania/src/ScreenMapControllers.cpp index d1772af8bc..c3635610e9 100644 --- a/stepmania/src/ScreenMapControllers.cpp +++ b/stepmania/src/ScreenMapControllers.cpp @@ -21,6 +21,7 @@ #include "GameState.h" #include "RageSounds.h" #include "ThemeManager.h" +#include "RageDisplay.h" #define EVEN_LINE_IN THEME->GetMetric("ScreenMapControllers","EvenLineIn")