On first run, run a gameplay benchmark and adjusts graphic options automatically for 60 fps.

This commit is contained in:
Chris Danford
2003-05-26 09:34:54 +00:00
parent c54214c1d2
commit b9b07f994c
2 changed files with 187 additions and 0 deletions
+152
View File
@@ -0,0 +1,152 @@
#include "global.h"
/*
-----------------------------------------------------------------------------
Class: ScreenAutoGraphicDetail
Desc: See header.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "ScreenAutoGraphicDetail.h"
#include "ThemeManager.h"
#include "GameState.h"
#include "GameDef.h"
#include "RageLog.h"
#include "SongManager.h"
#include "NoteFieldPositioning.h"
#include "GameManager.h"
#include "PrefsManager.h"
#include "StepMania.h"
#include "ScreenManager.h"
#include "RageTimer.h"
#include "RageDisplay.h"
#define SONG_BPM THEME->GetMetricF("ScreenAutoGraphicDetail","SongBPM")
#define SECONDS_TO_SHOW THEME->GetMetricF("ScreenAutoGraphicDetail","SecondsToShow")
enum Detail { low, medium, high, NUM_DETAIL_SETTINGS };
struct DetailSettings
{
int width, height, displaybpp, texturebpp;
};
const DetailSettings g_DetailSettings[NUM_DETAIL_SETTINGS] = {
{ 320, 240, 16, 16 },
{ 640, 480, 16, 16 },
{ 640, 480, 32, 32 },
};
void ApplyDetailSetting( Detail detail )
{
PREFSMAN->m_bVsync = false; // TODO: preserve vsync pref
PREFSMAN->m_iDisplayWidth = g_DetailSettings[detail].width;
PREFSMAN->m_iDisplayHeight = g_DetailSettings[detail].height;
PREFSMAN->m_iDisplayColorDepth = g_DetailSettings[detail].displaybpp;
PREFSMAN->m_iTextureColorDepth = g_DetailSettings[detail].texturebpp;
ApplyGraphicOptions();
}
ScreenAutoGraphicDetail::ScreenAutoGraphicDetail() : Screen("ScreenAutoGraphicDetail")
{
ApplyDetailSetting( medium );
m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenAutoGraphicDetail background") );
this->AddChild( &m_Background );
GAMESTATE->m_CurStyle = STYLE_DANCE_VERSUS;
NotesType nt = GAMESTATE->GetCurrentStyleDef()->m_NotesType;
int iNumOfTracks = GAMEMAN->NotesTypeToNumTracks( nt );
ASSERT(iNumOfTracks > 0); // crazy to have less than 1 track....
NoteData* pND = new NoteData;
pND->SetNumTracks( iNumOfTracks );
float fSongBPM = SONG_BPM;
float fSongBPS = fSongBPM / 60.f;
int iBeatsToPlay = fSongBPS * SECONDS_TO_SHOW;
for( int i=0; i<iBeatsToPlay; i++ )
{
float fBeat = i+2;
int iTrack = i % iNumOfTracks;
bool bIsHold = ((i / iNumOfTracks) % 2) == 1;
if( bIsHold )
pND->AddHoldNote( HoldNote(iTrack, fBeat, fBeat+1) );
else
{
pND->SetTapNote( iTrack, BeatToNoteRow(fBeat), TAP_TAP );
pND->SetTapNote( iTrack, BeatToNoteRow(fBeat+0.5f), TAP_TAP );
}
}
m_pSong = new Song;
m_pSong->AddBPMSegment( BPMSegment(0,fSongBPM) );
GAMESTATE->m_pCurSong = m_pSong;
GAMESTATE->m_bPastHereWeGo = true;
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsPlayerEnabled(p) )
continue; // skip
GAMESTATE->m_PlayerController[p] = PC_AUTOPLAY;
m_Player[p].Load( (PlayerNumber)p, pND, NULL, NULL, NULL, NULL );
m_Player[p].SetX( GAMESTATE->GetCurrentStyleDef()->m_iCenterX[p] );
this->AddChild( &m_Player[p] );
}
delete pND;
m_Overlay.LoadFromAniDir( THEME->GetPathToB("ScreenAutoGraphicDetail overlay") );
this->AddChild( &m_Overlay );
m_textMessage.LoadFromFont( THEME->GetPathToF("Common normal") );
m_textMessage.SetXY( CENTER_X, CENTER_Y );
this->AddChild( &m_textMessage );
m_fFakeSecondsIntoSong = 0;
this->ClearMessageQueue();
this->PostScreenMessage( SM_BeginFadingOut, SECONDS_TO_SHOW );
}
ScreenAutoGraphicDetail::~ScreenAutoGraphicDetail()
{
delete m_pSong;
}
void ScreenAutoGraphicDetail::Update( float fDelta )
{
m_fFakeSecondsIntoSong += fDelta;
GAMESTATE->UpdateSongPosition( m_fFakeSecondsIntoSong );
int iThisSecond = (int)RageTimer::GetTimeSinceStart();
int iLastSecond = (int)(RageTimer::GetTimeSinceStart()-fDelta);
if( iThisSecond != iLastSecond )
m_textMessage.SetText( ssprintf("Analyzing peformance... (FPS: %d)", DISPLAY->GetCumFPS()) );
Screen::Update( fDelta );
}
void ScreenAutoGraphicDetail::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
{
case SM_BeginFadingOut:
int cumFPS = DISPLAY->GetCumFPS();
if( cumFPS > 120 )
ApplyDetailSetting( high );
else if( cumFPS < 60 )
ApplyDetailSetting( low );
else
ApplyDetailSetting( medium );
GAMESTATE->m_pCurSong = NULL;
SCREENMAN->SetNewScreen( THEME->GetMetric("Common","InitialScreen") );
break;
}
}
+35
View File
@@ -0,0 +1,35 @@
/*
-----------------------------------------------------------------------------
Class: ScreenAutoGraphicDetail
Desc: Base class for all attraction screens.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "Screen.h"
#include "Player.h"
class ScreenAutoGraphicDetail : public Screen
{
public:
ScreenAutoGraphicDetail();
~ScreenAutoGraphicDetail();
virtual void Update( float fDelta );
virtual void HandleScreenMessage( const ScreenMessage SM );
protected:
BGAnimation m_Background;
Player m_Player[NUM_PLAYERS];
BGAnimation m_Overlay;
BitmapText m_textMessage;
Song* m_pSong;
float m_fFakeSecondsIntoSong;
};