finish image centering code
add input test screen
This commit is contained in:
@@ -133,6 +133,11 @@ PrefsManager::PrefsManager()
|
||||
m_bVsync = true;
|
||||
m_sLanguage = ""; // ThemeManager will deal with this invalid language
|
||||
|
||||
m_iCenterImageTranslateX = 0;
|
||||
m_iCenterImageTranslateY = 0;
|
||||
m_fCenterImageScaleX = 1;
|
||||
m_fCenterImageScaleY = 1;
|
||||
|
||||
|
||||
/* XXX: Set these defaults for individual consoles using VideoCardDefaults.ini. */
|
||||
#ifdef _XBOX
|
||||
@@ -288,6 +293,10 @@ void PrefsManager::ReadGlobalPrefsFromDisk()
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
ini.GetValue( "Options", ssprintf("DefaultProfileP%d",p+1), m_sDefaultProfile[p] );
|
||||
|
||||
ini.GetValue( "Options", "CenterImageTranslateX", m_iCenterImageTranslateX );
|
||||
ini.GetValue( "Options", "CenterImageTranslateY", m_iCenterImageTranslateY );
|
||||
ini.GetValue( "Options", "CenterImageScaleX", m_fCenterImageScaleX );
|
||||
ini.GetValue( "Options", "CenterImageScaleY", m_fCenterImageScaleY );
|
||||
|
||||
CString sAdditionalSongFolders;
|
||||
if( ini.GetValue( "Options", "AdditionalSongFolders", sAdditionalSongFolders ) )
|
||||
@@ -405,6 +414,11 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
ini.SetValue ( "Options", ssprintf("DefaultProfileP%d",p+1), m_sDefaultProfile[p] );
|
||||
|
||||
ini.SetValue( "Options", "CenterImageTranslateX", m_iCenterImageTranslateX );
|
||||
ini.SetValue( "Options", "CenterImageTranslateY", m_iCenterImageTranslateY );
|
||||
ini.SetValue( "Options", "CenterImageScaleX", m_fCenterImageScaleX );
|
||||
ini.SetValue( "Options", "CenterImageScaleY", m_fCenterImageScaleY );
|
||||
|
||||
/* Only write these if they aren't the default. This ensures that we can change
|
||||
* the default and have it take effect for everyone (except people who
|
||||
* tweaked this value). */
|
||||
|
||||
@@ -99,7 +99,11 @@ public:
|
||||
int m_iEndlessNumStagesUntilBreak;
|
||||
int m_iEndlessBreakLength;
|
||||
CString m_sLanguage;
|
||||
CString m_sDefaultProfile[NUM_PLAYERS]; // directory name of profile on HD
|
||||
CString m_sDefaultProfile[NUM_PLAYERS]; // directory name of profile
|
||||
int m_iCenterImageTranslateX;
|
||||
int m_iCenterImageTranslateY;
|
||||
float m_fCenterImageScaleX;
|
||||
float m_fCenterImageScaleY;
|
||||
|
||||
// course ranking
|
||||
enum CourseSortOrders { COURSE_SORT_SONGS, COURSE_SORT_METER, COURSE_SORT_METER_SUM, COURSE_SORT_RANK } m_iCourseSortOrder;
|
||||
|
||||
@@ -206,7 +206,7 @@ void RageDisplay::SetDefaultRenderStates()
|
||||
SetBlendMode( BLEND_NORMAL );
|
||||
SetTextureFiltering( true );
|
||||
LoadMenuPerspective(0, CENTER_X, CENTER_Y); // 0 FOV = ortho
|
||||
ResetCentering();
|
||||
ChangeCentering(0,0,1,1);
|
||||
}
|
||||
|
||||
|
||||
@@ -621,21 +621,11 @@ RageMatrix RageDisplay::GetFrustumMatrix( float l, float r, float b, float t, fl
|
||||
return m;
|
||||
}
|
||||
|
||||
void RageDisplay::ResetCentering()
|
||||
void RageDisplay::ChangeCentering( int trans_x, int trans_y, float scale_x, float scale_y )
|
||||
{
|
||||
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 );
|
||||
RageMatrix m1;
|
||||
RageMatrix m2;
|
||||
RageMatrixTranslation( &m1, trans_x, trans_y, 0 );
|
||||
RageMatrixScaling( &m2, scale_x, scale_y, 1 );
|
||||
RageMatrixMultiply( &m_Centering, &m1, &m2 );
|
||||
}
|
||||
|
||||
@@ -248,10 +248,7 @@ public:
|
||||
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();
|
||||
|
||||
void ChangeCentering( int trans_x, int trans_y, float scale_x, float scale_y );
|
||||
|
||||
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 );
|
||||
|
||||
@@ -289,6 +289,7 @@ void Screen::ClearMessageQueue( const ScreenMessage SM )
|
||||
#include "ScreenReloadSongs.h"
|
||||
#include "ScreenOptionsMaster.h"
|
||||
#include "ScreenCenterImage.h"
|
||||
#include "ScreenTestInput.h"
|
||||
|
||||
Screen* Screen::Create( CString sClassName )
|
||||
{
|
||||
@@ -387,6 +388,7 @@ Screen* Screen::Create( CString sClassName )
|
||||
IF_RETURN( ScreenReloadSongs );
|
||||
IF_RETURN( ScreenOptionsMaster );
|
||||
IF_RETURN( ScreenCenterImage );
|
||||
IF_RETURN( ScreenTestInput );
|
||||
|
||||
RageException::Throw( "Invalid Screen class name '%s'", sClassName.c_str() );
|
||||
}
|
||||
|
||||
@@ -64,37 +64,73 @@ void ScreenCenterImage::Input( const DeviceInput& DeviceI, const InputEventType
|
||||
if( m_Menu.IsTransitioning() )
|
||||
return;
|
||||
|
||||
if( type != IET_RELEASE )
|
||||
if( type == IET_RELEASE )
|
||||
return;
|
||||
|
||||
|
||||
bool bHoldingShift =
|
||||
INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_RSHIFT)) ||
|
||||
INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT));
|
||||
|
||||
int iScale;
|
||||
switch( type )
|
||||
{
|
||||
case IET_SLOW_REPEAT: iScale = 4; break;
|
||||
case IET_FAST_REPEAT: iScale = 16; break;
|
||||
default: iScale = 1; break;
|
||||
}
|
||||
|
||||
switch( DeviceI.button )
|
||||
{
|
||||
case SDLK_SPACE:
|
||||
if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_RSHIFT)) ||
|
||||
INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT)) )
|
||||
{
|
||||
if( DeviceI.button == SDLK_LEFT )
|
||||
DISPLAY->CenteringScale( 0.999f, 1, 1 );
|
||||
if( DeviceI.button == SDLK_DOWN )
|
||||
DISPLAY->CenteringScale( 1.f, 1/0.999f, 1.f );
|
||||
if( DeviceI.button == SDLK_UP )
|
||||
DISPLAY->CenteringScale( 1.f, 0.999f, 1.f );
|
||||
if( DeviceI.button == SDLK_RIGHT )
|
||||
DISPLAY->CenteringScale( 1/0.999f, 1.f, 1.f );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( DeviceI.button == SDLK_LEFT )
|
||||
DISPLAY->CenteringTranslate( -1, 0, 0 );
|
||||
if( DeviceI.button == SDLK_DOWN )
|
||||
DISPLAY->CenteringTranslate( 0, +1, 0 );
|
||||
if( DeviceI.button == SDLK_UP )
|
||||
DISPLAY->CenteringTranslate( 0, -1, 0 );
|
||||
if( DeviceI.button == SDLK_RIGHT )
|
||||
DISPLAY->CenteringTranslate( +1, 0, 0 );
|
||||
}
|
||||
PREFSMAN->m_iCenterImageTranslateX = 0;
|
||||
PREFSMAN->m_iCenterImageTranslateY = 0;
|
||||
PREFSMAN->m_fCenterImageScaleX = 1;
|
||||
PREFSMAN->m_fCenterImageScaleY = 1;
|
||||
break;
|
||||
case SDLK_LEFT:
|
||||
if( bHoldingShift )
|
||||
PREFSMAN->m_fCenterImageScaleX -= 0.001f * iScale;
|
||||
else
|
||||
PREFSMAN->m_iCenterImageTranslateX -= 1 * iScale;
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
if( bHoldingShift )
|
||||
PREFSMAN->m_fCenterImageScaleX += 0.001f * iScale;
|
||||
else
|
||||
PREFSMAN->m_iCenterImageTranslateX += 1 * iScale;
|
||||
break;
|
||||
case SDLK_UP:
|
||||
if( bHoldingShift )
|
||||
PREFSMAN->m_fCenterImageScaleY -= 0.001f * iScale;
|
||||
else
|
||||
PREFSMAN->m_iCenterImageTranslateY -= 1 * iScale;
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
if( bHoldingShift )
|
||||
PREFSMAN->m_fCenterImageScaleY += 0.001f * iScale;
|
||||
else
|
||||
PREFSMAN->m_iCenterImageTranslateY += 1 * iScale;
|
||||
break;
|
||||
}
|
||||
|
||||
switch( DeviceI.button )
|
||||
{
|
||||
case SDLK_SPACE:
|
||||
case SDLK_LEFT:
|
||||
case SDLK_RIGHT:
|
||||
case SDLK_UP:
|
||||
case SDLK_DOWN:
|
||||
DISPLAY->ChangeCentering(
|
||||
PREFSMAN->m_iCenterImageTranslateX,
|
||||
PREFSMAN->m_iCenterImageTranslateY,
|
||||
PREFSMAN->m_fCenterImageScaleX,
|
||||
PREFSMAN->m_fCenterImageScaleY );
|
||||
break;
|
||||
}
|
||||
|
||||
switch( DeviceI.button )
|
||||
{
|
||||
case SDLK_ESCAPE:
|
||||
if(!m_Menu.IsTransitioning())
|
||||
{
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
#include "global.h"
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: ScreenTestInput
|
||||
|
||||
Desc: Where the player maps device input to pad input.
|
||||
|
||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "ScreenTestInput.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "InputMapper.h"
|
||||
#include "GameManager.h"
|
||||
#include "GameState.h"
|
||||
#include "RageSounds.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "RageDisplay.h"
|
||||
|
||||
|
||||
|
||||
ScreenTestInput::ScreenTestInput( CString sClassName ) : Screen( sClassName )
|
||||
{
|
||||
LOG->Trace( "ScreenTestInput::ScreenTestInput()" );
|
||||
|
||||
|
||||
m_textInputs.LoadFromFont( THEME->GetPathToF("Common normal") );
|
||||
m_textInputs.SetText( "" );
|
||||
m_textInputs.SetXY( CENTER_X, CENTER_Y );
|
||||
m_textInputs.SetDiffuse( RageColor(1,1,1,1) );
|
||||
m_textInputs.SetZoom( 0.8f );
|
||||
this->AddChild( &m_textInputs );
|
||||
|
||||
m_Menu.Load( "ScreenTestInput" );
|
||||
this->AddChild( &m_Menu );
|
||||
|
||||
SOUND->PlayMusic( THEME->GetPathToS("ScreenTestInput music") );
|
||||
}
|
||||
|
||||
|
||||
|
||||
ScreenTestInput::~ScreenTestInput()
|
||||
{
|
||||
LOG->Trace( "ScreenTestInput::~ScreenTestInput()" );
|
||||
}
|
||||
|
||||
|
||||
void ScreenTestInput::Update( float fDeltaTime )
|
||||
{
|
||||
Screen::Update( fDeltaTime );
|
||||
|
||||
CStringArray asInputs;
|
||||
|
||||
DeviceInput di;
|
||||
|
||||
for( int d=0; d<NUM_INPUT_DEVICES; d++ )
|
||||
{
|
||||
for( int b=0; b<NUM_DEVICE_BUTTONS[d]; b++ )
|
||||
{
|
||||
di.device = (InputDevice)d;
|
||||
di.button = b;
|
||||
|
||||
if( INPUTFILTER->IsBeingPressed(di) )
|
||||
{
|
||||
CString sTemp;
|
||||
sTemp += di.GetDescription();
|
||||
|
||||
GameInput gi;
|
||||
if( INPUTMAPPER->DeviceToGame(di,gi) )
|
||||
{
|
||||
CString sName = GAMESTATE->GetCurrentGameDef()->m_szButtonNames[b];
|
||||
CString sSecondary = GAMESTATE->GetCurrentGameDef()->m_szSecondaryFunction[b];
|
||||
|
||||
sTemp += "(" + sName + ", " + sSecondary + ")";
|
||||
}
|
||||
|
||||
asInputs.push_back( sTemp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_sDeviceInputs = join( "\n ", asInputs );
|
||||
}
|
||||
|
||||
|
||||
void ScreenTestInput::DrawPrimitives()
|
||||
{
|
||||
m_Menu.DrawBottomLayer();
|
||||
Screen::DrawPrimitives();
|
||||
m_Menu.DrawTopLayer();
|
||||
}
|
||||
|
||||
void ScreenTestInput::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
||||
{
|
||||
if( type != IET_FIRST_PRESS && type != IET_SLOW_REPEAT )
|
||||
return; // ignore
|
||||
|
||||
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default handler
|
||||
}
|
||||
|
||||
void ScreenTestInput::HandleScreenMessage( const ScreenMessage SM )
|
||||
{
|
||||
switch( SM )
|
||||
{
|
||||
case SM_GoToNextScreen:
|
||||
case SM_GoToPrevScreen:
|
||||
SCREENMAN->SetNewScreen( "ScreenOptionsMenu" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: ScreenTestInput
|
||||
|
||||
Desc: Where the player maps device input to instrument buttons.
|
||||
|
||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "Screen.h"
|
||||
#include "Sprite.h"
|
||||
#include "BitmapText.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "GrayArrow.h"
|
||||
#include "InputMapper.h"
|
||||
#include "MenuElements.h"
|
||||
#include "RageInputDevice.h"
|
||||
|
||||
|
||||
class ScreenTestInput : public Screen
|
||||
{
|
||||
public:
|
||||
ScreenTestInput( CString sName );
|
||||
virtual ~ScreenTestInput();
|
||||
|
||||
virtual void DrawPrimitives();
|
||||
virtual void Update( float fDelta );
|
||||
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
|
||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||
|
||||
private:
|
||||
CString m_sDeviceInputs;
|
||||
CString m_sGameInputs;
|
||||
BitmapText m_textInputs;
|
||||
|
||||
MenuElements m_Menu;
|
||||
};
|
||||
|
||||
@@ -165,6 +165,12 @@ void ApplyGraphicOptions()
|
||||
|
||||
bNeedReload |= DISPLAY->SetVideoMode( GetCurVideoModeParams() );
|
||||
|
||||
DISPLAY->ChangeCentering(
|
||||
PREFSMAN->m_iCenterImageTranslateX,
|
||||
PREFSMAN->m_iCenterImageTranslateY,
|
||||
PREFSMAN->m_fCenterImageScaleX,
|
||||
PREFSMAN->m_fCenterImageScaleY );
|
||||
|
||||
bNeedReload |= TEXTUREMAN->SetPrefs(
|
||||
PREFSMAN->m_iTextureColorDepth,
|
||||
PREFSMAN->m_iMovieColorDepth,
|
||||
@@ -802,6 +808,13 @@ int main(int argc, char* argv[])
|
||||
delete loading_window; // destroy this before init'ing Display
|
||||
|
||||
DISPLAY = CreateDisplay();
|
||||
|
||||
DISPLAY->ChangeCentering(
|
||||
PREFSMAN->m_iCenterImageTranslateX,
|
||||
PREFSMAN->m_iCenterImageTranslateY,
|
||||
PREFSMAN->m_fCenterImageScaleX,
|
||||
PREFSMAN->m_fCenterImageScaleY );
|
||||
|
||||
TEXTUREMAN = new RageTextureManager();
|
||||
TEXTUREMAN->SetPrefs(
|
||||
PREFSMAN->m_iTextureColorDepth,
|
||||
|
||||
Reference in New Issue
Block a user