Files
itgmania212121/stepmania/src/ScreenDebugOverlay.cpp
T

1184 lines
39 KiB
C++
Raw Normal View History

2005-05-16 10:10:08 +00:00
#include "global.h"
#include "ScreenDebugOverlay.h"
#include "ScreenDimensions.h"
2005-07-20 09:48:19 +00:00
#include "ScreenManager.h"
2005-05-16 10:10:08 +00:00
#include "PrefsManager.h"
#include "GamePreferences.h"
2005-05-16 10:10:08 +00:00
#include "RageLog.h"
#include "GameState.h"
#include "PlayerState.h"
#include "StepMania.h"
#include "GameCommand.h"
#include "ScreenGameplay.h"
#include "RageSoundManager.h"
2005-05-19 23:29:39 +00:00
#include "GameSoundManager.h"
#include "RageTextureManager.h"
2005-06-15 23:54:59 +00:00
#include "MemoryCardManager.h"
2005-05-19 23:29:39 +00:00
#include "NoteSkinManager.h"
#include "Bookkeeper.h"
#include "ProfileManager.h"
#include "CodeDetector.h"
#include "RageInput.h"
2005-08-17 23:53:02 +00:00
#include "RageDisplay.h"
#include "InputEventPlus.h"
2005-12-22 03:10:04 +00:00
#include "LocalizedString.h"
2006-01-18 10:09:34 +00:00
#include "Profile.h"
#include "SongManager.h"
2006-01-24 04:10:21 +00:00
#include "GameLoop.h"
#include "Song.h"
2005-05-16 10:10:08 +00:00
static bool g_bIsDisplayed = false;
static bool g_bIsSlow = false;
static bool g_bIsHalt = false;
static RageTimer g_HaltTimer(RageZeroTimer);
2005-08-17 23:53:02 +00:00
static float g_fImageScaleCurrent = 1;
static float g_fImageScaleDestination = 1;
2005-08-16 23:23:49 +00:00
//
// self-registering debug lines
// We don't use SubscriptionManager, because we want to keep the line order.
2005-08-16 23:23:49 +00:00
//
2006-08-12 23:20:43 +00:00
static LocalizedString ON ( "ScreenDebugOverlay", "on" );
static LocalizedString OFF ( "ScreenDebugOverlay", "off" );
2005-08-16 23:23:49 +00:00
class IDebugLine;
static vector<IDebugLine*> *g_pvpSubscribers = NULL;
2005-08-16 23:23:49 +00:00
class IDebugLine
{
public:
IDebugLine()
{
if( g_pvpSubscribers == NULL )
g_pvpSubscribers = new vector<IDebugLine*>;
g_pvpSubscribers->push_back( this );
2005-08-16 23:23:49 +00:00
}
virtual ~IDebugLine() { }
enum Type { all_screens, gameplay_only };
virtual Type GetType() const { return all_screens; }
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() = 0;
virtual RString GetDisplayValue() { return IsEnabled() ? ON.GetValue():OFF.GetValue(); }
2007-05-06 04:49:21 +00:00
virtual RString GetPageName() const { return "Main"; }
virtual bool ForceOffAfterUse() const { return false; }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() = 0;
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-17 10:16:06 +00:00
{
2007-01-25 11:19:11 +00:00
RString s1 = GetDisplayTitle();
RString s2 = GetDisplayValue();
2005-08-17 10:16:06 +00:00
if( !s2.empty() )
s1 += " - ";
sMessageOut = s1 + s2;
};
DeviceInput m_Button;
2005-08-16 23:23:49 +00:00
};
2005-05-19 23:29:39 +00:00
static bool IsGameplay()
{
return SCREENMAN && SCREENMAN->GetTopScreen() && SCREENMAN->GetTopScreen()->GetScreenType() == gameplay;
}
2005-08-16 23:23:49 +00:00
2006-01-15 20:46:15 +00:00
REGISTER_SCREEN_CLASS( ScreenDebugOverlay );
2005-05-16 10:10:08 +00:00
ScreenDebugOverlay::~ScreenDebugOverlay()
{
2005-08-16 23:23:49 +00:00
this->RemoveAllChildren();
FOREACH( BitmapText*, m_vptextButton, p )
SAFE_DELETE( *p );
m_vptextButton.clear();
FOREACH( BitmapText*, m_vptextFunction, p )
SAFE_DELETE( *p );
m_vptextFunction.clear();
2005-05-16 10:10:08 +00:00
}
2005-08-16 23:23:49 +00:00
const int MAX_DEBUG_LINES = 30;
2005-05-16 10:10:08 +00:00
struct MapDebugToDI
{
DeviceInput holdForDebug1;
DeviceInput holdForDebug2;
2006-01-24 06:18:09 +00:00
DeviceInput holdForSlow;
DeviceInput holdForFast;
2005-08-16 23:23:49 +00:00
DeviceInput debugButton[MAX_DEBUG_LINES];
DeviceInput gameplayButton[MAX_DEBUG_LINES];
2007-05-06 04:49:21 +00:00
map<DeviceInput, int> pageButton;
2005-05-16 10:10:08 +00:00
void Clear()
{
holdForDebug1.MakeInvalid();
holdForDebug2.MakeInvalid();
2006-01-24 06:18:09 +00:00
holdForSlow.MakeInvalid();
holdForFast.MakeInvalid();
2005-08-16 23:23:49 +00:00
for( int i=0; i<MAX_DEBUG_LINES; i++ )
2005-05-19 23:29:39 +00:00
{
debugButton[i].MakeInvalid();
gameplayButton[i].MakeInvalid();
}
2005-05-16 10:10:08 +00:00
}
};
static MapDebugToDI g_Mappings;
2006-01-08 18:40:20 +00:00
static LocalizedString IN_GAMEPLAY( "ScreenDebugOverlay", "%s in gameplay" );
static LocalizedString OR( "ScreenDebugOverlay", "or" );
static RString GetDebugButtonName( const IDebugLine *pLine )
2005-05-16 10:10:08 +00:00
{
RString s = INPUTMAN->GetDeviceSpecificInputString(pLine->m_Button);
switch( pLine->GetType() )
{
case IDebugLine::all_screens:
return s;
case IDebugLine::gameplay_only:
return ssprintf( IN_GAMEPLAY.GetValue(), s.c_str() );
default:
ASSERT(0);
}
2005-05-16 10:10:08 +00:00
}
2006-03-09 22:59:29 +00:00
static LocalizedString DEBUG_MENU( "ScreenDebugOverlay", "Debug Menu" );
2005-05-16 10:10:08 +00:00
void ScreenDebugOverlay::Init()
{
Screen::Init();
// Init debug mappings
// TODO: Arch-specific?
{
g_Mappings.Clear();
g_Mappings.holdForDebug1 = DeviceInput(DEVICE_KEYBOARD, KEY_F3);
g_Mappings.holdForDebug2.MakeInvalid();
2006-06-28 18:44:28 +00:00
g_Mappings.holdForSlow = DeviceInput(DEVICE_KEYBOARD, KEY_ACCENT);
g_Mappings.holdForFast = DeviceInput(DEVICE_KEYBOARD, KEY_TAB);
2006-01-24 06:18:09 +00:00
2005-05-19 23:29:39 +00:00
2005-11-07 03:59:05 +00:00
int i=0;
g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F8);
g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F7);
g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F6);
i=0;
2005-11-07 03:59:05 +00:00
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C1);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C2);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C3);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C4);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C5);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C6);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C7);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C8);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C9);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C0);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cq);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cw);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ce);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cr);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ct);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cy);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ci);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Co);
2006-08-12 23:16:15 +00:00
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cp);
2005-11-07 03:59:05 +00:00
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_UP);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_DOWN);
g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_BACK);
2007-05-06 04:49:21 +00:00
g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F5)] = 0;
g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F6)] = 1;
g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F7)] = 2;
g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F8)] = 3;
2005-05-16 10:10:08 +00:00
}
2007-05-06 05:28:10 +00:00
map<RString,int> iNextDebugButton;
int iNextGameplayButton = 0;
FOREACH( IDebugLine*, *g_pvpSubscribers, p )
{
2007-05-06 04:49:21 +00:00
RString sPageName = (*p)->GetPageName();
DeviceInput di;
switch( (*p)->GetType() )
{
case IDebugLine::all_screens:
2007-05-06 05:28:10 +00:00
di = g_Mappings.debugButton[iNextDebugButton[sPageName]++];
break;
case IDebugLine::gameplay_only:
2007-05-06 05:28:10 +00:00
di = g_Mappings.gameplayButton[iNextGameplayButton++];
break;
}
2007-05-06 04:49:21 +00:00
(*p)->m_Button = di;
if( find(m_asPages.begin(), m_asPages.end(), sPageName) == m_asPages.end() )
m_asPages.push_back( sPageName );
}
2007-05-06 04:49:21 +00:00
m_iCurrentPage = 0;
m_bForcedHidden = false;
2007-05-06 04:49:21 +00:00
2005-05-16 10:10:08 +00:00
m_Quad.StretchTo( RectF( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) );
m_Quad.SetDiffuse( RageColor(0, 0, 0, 0.5f) );
this->AddChild( &m_Quad );
2005-09-03 02:08:27 +00:00
m_textHeader.LoadFromFont( THEME->GetPathF("Common", "normal") );
2006-09-26 19:48:46 +00:00
m_textHeader.SetHorizAlign( align_left );
2005-05-19 23:29:39 +00:00
m_textHeader.SetX( SCREEN_LEFT+20 );
m_textHeader.SetY( SCREEN_TOP+20 );
2006-03-09 22:59:29 +00:00
m_textHeader.SetText( DEBUG_MENU );
2005-05-19 23:29:39 +00:00
this->AddChild( &m_textHeader );
2005-05-16 10:10:08 +00:00
FOREACH_CONST( IDebugLine*, *g_pvpSubscribers, p )
2005-05-16 10:10:08 +00:00
{
2005-08-17 09:40:35 +00:00
{
BitmapText *pT1 = new BitmapText;
2005-09-03 02:08:27 +00:00
pT1->LoadFromFont( THEME->GetPathF("Common", "normal") );
2006-09-26 19:48:46 +00:00
pT1->SetHorizAlign( align_right );
2005-08-17 09:40:35 +00:00
pT1->SetText( "blah" );
pT1->SetShadowLength( 2 );
m_vptextButton.push_back( pT1 );
this->AddChild( pT1 );
}
{
BitmapText *pT2 = new BitmapText;
2005-09-03 02:08:27 +00:00
pT2->LoadFromFont( THEME->GetPathF("Common", "normal") );
2006-09-26 19:48:46 +00:00
pT2->SetHorizAlign( align_left );
2005-08-17 09:40:35 +00:00
pT2->SetText( "blah" );
pT2->SetShadowLength( 2 );
m_vptextFunction.push_back( pT2 );
this->AddChild( pT2 );
}
2005-05-16 10:10:08 +00:00
}
2007-05-10 02:48:19 +00:00
this->SetVisible( false );
2005-05-16 10:10:08 +00:00
}
void ScreenDebugOverlay::Update( float fDeltaTime )
{
2006-01-24 04:10:21 +00:00
{
float fRate = 1;
2006-01-24 06:18:09 +00:00
if( INPUTFILTER->IsBeingPressed(g_Mappings.holdForFast) )
2006-01-24 04:10:21 +00:00
{
2006-01-24 06:18:09 +00:00
if( INPUTFILTER->IsBeingPressed(g_Mappings.holdForSlow) )
2006-01-24 04:10:21 +00:00
fRate = 0; /* both; stop time */
else
fRate *= 4;
}
2006-01-24 06:18:09 +00:00
else if( INPUTFILTER->IsBeingPressed(g_Mappings.holdForSlow) )
2006-01-24 04:10:21 +00:00
{
fRate /= 4;
}
if( g_bIsHalt )
fRate = 0;
else if( g_bIsSlow )
fRate /= 4;
2006-01-24 04:10:21 +00:00
GameLoop::SetUpdateRate( fRate );
}
2005-08-17 23:53:02 +00:00
bool bCenteringNeedsUpdate = g_fImageScaleCurrent != g_fImageScaleDestination;
fapproach( g_fImageScaleCurrent, g_fImageScaleDestination, fDeltaTime );
if( bCenteringNeedsUpdate )
{
DISPLAY->ChangeCentering(
PREFSMAN->m_iCenterImageTranslateX,
PREFSMAN->m_iCenterImageTranslateY,
2005-08-18 00:07:34 +00:00
PREFSMAN->m_fCenterImageAddWidth - (int)SCREEN_WIDTH + (int)(g_fImageScaleCurrent*SCREEN_WIDTH),
PREFSMAN->m_fCenterImageAddHeight - (int)SCREEN_HEIGHT + (int)(g_fImageScaleCurrent*SCREEN_HEIGHT) );
2005-08-17 23:53:02 +00:00
}
2005-05-16 10:10:08 +00:00
Screen::Update(fDeltaTime);
this->SetVisible( g_bIsDisplayed && !m_bForcedHidden );
2005-05-16 10:10:08 +00:00
if( !g_bIsDisplayed )
return;
2005-05-18 07:15:56 +00:00
UpdateText();
}
void ScreenDebugOverlay::UpdateText()
{
2007-05-06 04:49:21 +00:00
m_textHeader.SetText( ssprintf("%s: %s", DEBUG_MENU.GetValue().c_str(), GetCurrentPageName().c_str()) );
2005-05-16 10:10:08 +00:00
/* Highlight options that aren't the default. */
const RageColor off(0.6f, 0.6f, 0.6f, 1.0f);
const RageColor on(1, 1, 1, 1);
2007-05-06 04:49:21 +00:00
int iOffset = 0;
FOREACH_CONST( IDebugLine*, *g_pvpSubscribers, p )
2005-05-16 10:10:08 +00:00
{
2007-05-06 04:49:21 +00:00
RString sPageName = (*p)->GetPageName();
int i = p-g_pvpSubscribers->begin();
2007-05-06 04:49:21 +00:00
float fY = SCREEN_TOP+50 + iOffset * 16;
2005-08-16 23:23:49 +00:00
BitmapText &txt1 = *m_vptextButton[i];
2007-05-06 04:49:21 +00:00
BitmapText &txt2 = *m_vptextFunction[i];
if( sPageName != GetCurrentPageName() )
{
txt1.SetVisible( false );
txt2.SetVisible( false );
continue;
}
txt1.SetVisible( true );
txt2.SetVisible( true );
++iOffset;
2005-05-19 23:29:39 +00:00
txt1.SetX( SCREEN_CENTER_X-50 );
txt1.SetY( fY );
2005-05-19 23:29:39 +00:00
txt2.SetX( SCREEN_CENTER_X-30 );
txt2.SetY( fY );
2005-05-16 10:10:08 +00:00
2007-01-25 11:19:11 +00:00
RString s1 = (*p)->GetDisplayTitle();
RString s2 = (*p)->GetDisplayValue();
2005-05-16 10:10:08 +00:00
2005-08-16 23:23:49 +00:00
bool bOn = (*p)->IsEnabled();
2005-05-19 23:29:39 +00:00
txt1.SetDiffuse( bOn ? on:off );
txt2.SetDiffuse( bOn ? on:off );
RString sButton = GetDebugButtonName( *p );
if( !sButton.empty() )
sButton += ": ";
2005-05-19 23:29:39 +00:00
txt1.SetText( sButton );
if( !s2.empty() )
s1 += " - ";
2005-05-19 23:29:39 +00:00
txt2.SetText( s1 + s2 );
2005-05-16 10:10:08 +00:00
}
2006-01-24 04:41:47 +00:00
if( g_bIsHalt )
{
2005-05-16 10:10:08 +00:00
/* More than once I've paused the game accidentally and wasted time
* figuring out why, so warn. */
if( g_HaltTimer.Ago() >= 5.0f )
{
g_HaltTimer.Touch();
LOG->Warn( "Game halted" );
}
2006-01-24 04:41:47 +00:00
}
2005-05-16 10:10:08 +00:00
}
2007-05-06 04:49:21 +00:00
template<typename U, typename V>
static bool GetValueFromMap( const map<U, V> &m, const U &key, V &val )
2007-05-06 04:49:21 +00:00
{
typename map<U, V>::const_iterator it = m.find(key);
2007-05-06 04:49:21 +00:00
if( it == m.end() )
return false;
val = it->second;
return true;
}
bool ScreenDebugOverlay::OverlayInput( const InputEventPlus &input )
2005-05-16 10:10:08 +00:00
{
if( input.DeviceI == g_Mappings.holdForDebug1 ||
input.DeviceI == g_Mappings.holdForDebug2 )
2005-05-16 10:10:08 +00:00
{
bool bHoldingNeither =
(!g_Mappings.holdForDebug1.IsValid() || !INPUTFILTER->IsBeingPressed(g_Mappings.holdForDebug1)) &&
(!g_Mappings.holdForDebug2.IsValid() || !INPUTFILTER->IsBeingPressed(g_Mappings.holdForDebug2));
bool bHoldingBoth =
(!g_Mappings.holdForDebug1.IsValid() || INPUTFILTER->IsBeingPressed(g_Mappings.holdForDebug1)) &&
(!g_Mappings.holdForDebug2.IsValid() || INPUTFILTER->IsBeingPressed(g_Mappings.holdForDebug2));
if( bHoldingNeither )
m_bForcedHidden = false;
if( bHoldingBoth )
2005-05-16 10:10:08 +00:00
g_bIsDisplayed = true;
else
2005-05-16 10:10:08 +00:00
g_bIsDisplayed = false;
}
int iPage = 0;
2007-05-06 04:49:21 +00:00
if( g_bIsDisplayed && GetValueFromMap(g_Mappings.pageButton, input.DeviceI, iPage) )
{
if( input.type != IET_FIRST_PRESS )
return true; /* eat the input but do nothing */
m_iCurrentPage = iPage;
CLAMP( m_iCurrentPage, 0, (int) m_asPages.size()-1 );
return true;
}
FOREACH_CONST( IDebugLine*, *g_pvpSubscribers, p )
2005-05-16 10:10:08 +00:00
{
2007-05-06 04:49:21 +00:00
RString sPageName = (*p)->GetPageName();
int i = p-g_pvpSubscribers->begin();
// Gameplay buttons are available only in gameplay. Non-gameplay buttons are
// only available when the screen is displayed.
switch( (*p)->GetType() )
{
case IDebugLine::all_screens:
if( !g_bIsDisplayed )
continue;
2007-05-09 17:29:55 +00:00
if( sPageName != GetCurrentPageName() )
continue;
break;
case IDebugLine::gameplay_only:
if( !IsGameplay() )
continue;
break;
default:
ASSERT(0);
}
if( input.DeviceI == (*p)->m_Button )
2005-05-16 10:10:08 +00:00
{
if( input.type != IET_FIRST_PRESS )
2005-05-20 00:41:22 +00:00
return true; /* eat the input but do nothing */
2005-08-16 23:23:49 +00:00
BitmapText &txt1 = *m_vptextButton[i];
2005-05-19 23:29:39 +00:00
txt1.FinishTweening();
float fZoom = txt1.GetZoom();
txt1.SetZoom( fZoom * 1.2f );
2006-01-23 04:42:12 +00:00
txt1.BeginTweening( 0.2f, TWEEN_LINEAR );
2005-05-19 23:29:39 +00:00
txt1.SetZoom( fZoom );
2005-05-16 10:10:08 +00:00
2006-01-22 01:00:06 +00:00
RString sMessage;
2007-01-25 11:19:11 +00:00
(*p)->DoAndMakeSystemMessage( sMessage );
2005-08-30 01:17:38 +00:00
if( !sMessage.empty() )
SCREENMAN->SystemMessage( sMessage );
if( (*p)->ForceOffAfterUse() )
m_bForcedHidden = true;
2005-08-16 23:23:49 +00:00
2005-05-18 07:15:56 +00:00
UpdateText();
2005-05-19 23:29:39 +00:00
return true;
2005-05-16 10:10:08 +00:00
}
}
2005-05-19 23:29:39 +00:00
return false;
2005-05-16 10:10:08 +00:00
}
2005-08-16 23:23:49 +00:00
//
// DebugLine helpers
//
static void SetSpeed()
{
2006-01-24 04:41:47 +00:00
// PauseMusic( g_bIsHalt );
2005-08-16 23:23:49 +00:00
}
void ChangeVolume( float fDelta )
{
2007-05-24 21:35:03 +00:00
Preference<float> *pRet = Preference<float>::GetPreferenceByName("SoundVolume");
float fVol = pRet->Get();
2005-08-16 23:23:49 +00:00
fVol += fDelta;
CLAMP( fVol, 0.0f, 1.0f );
2007-05-24 21:35:03 +00:00
pRet->Set( fVol );
SOUNDMAN->SetMixVolume();
2005-08-16 23:23:49 +00:00
}
2007-06-18 20:59:51 +00:00
void ChangeVisualDelay( float fDelta )
{
Preference<float> *pRet = Preference<float>::GetPreferenceByName("VisualDelaySeconds");
float fSecs = pRet->Get();
fSecs += fDelta;
CLAMP( fSecs, -1.0f, 1.0f );
pRet->Set( fSecs );
}
2005-08-16 23:23:49 +00:00
//
// DebugLines
//
2005-12-20 08:35:47 +00:00
static LocalizedString AUTO_PLAY ( "ScreenDebugOverlay", "AutoPlay" );
2007-01-25 11:03:41 +00:00
static LocalizedString ASSIST ( "ScreenDebugOverlay", "Assist" );
2005-12-20 08:35:47 +00:00
static LocalizedString AUTOSYNC ( "ScreenDebugOverlay", "Autosync" );
static LocalizedString COIN_MODE ( "ScreenDebugOverlay", "CoinMode" );
2006-01-24 06:09:25 +00:00
static LocalizedString HALT ( "ScreenDebugOverlay", "Halt" );
2005-12-20 08:35:47 +00:00
static LocalizedString LIGHTS_DEBUG ( "ScreenDebugOverlay", "Lights Debug" );
static LocalizedString MONKEY_INPUT ( "ScreenDebugOverlay", "Monkey Input" );
2006-01-24 06:09:25 +00:00
static LocalizedString RENDERING_STATS ( "ScreenDebugOverlay", "Rendering Stats" );
2005-12-20 08:35:47 +00:00
static LocalizedString VSYNC ( "ScreenDebugOverlay", "Vsync" );
static LocalizedString MULTITEXTURE ( "ScreenDebugOverlay", "Multitexture" );
2006-01-24 06:09:25 +00:00
static LocalizedString SCREEN_TEST_MODE ( "ScreenDebugOverlay", "Screen Test Mode" );
2007-05-23 21:07:28 +00:00
static LocalizedString SCREEN_SHOW_MASKS ( "ScreenDebugOverlay", "Show Masks" );
2007-05-06 05:21:31 +00:00
static LocalizedString PROFILE ( "ScreenDebugOverlay", "Profile" );
static LocalizedString CLEAR_PROFILE_STATS ( "ScreenDebugOverlay", "Clear Profile Stats" );
static LocalizedString FILL_PROFILE_STATS ( "ScreenDebugOverlay", "Fill Profile Stats" );
2005-12-20 08:35:47 +00:00
static LocalizedString SEND_NOTES_ENDED ( "ScreenDebugOverlay", "Send Notes Ended" );
2006-01-24 06:09:25 +00:00
static LocalizedString RELOAD ( "ScreenDebugOverlay", "Reload" );
2006-08-10 17:49:40 +00:00
static LocalizedString RESTART ( "ScreenDebugOverlay", "Restart" );
2007-04-29 03:52:57 +00:00
static LocalizedString SCREEN_ON ( "ScreenDebugOverlay", "Send On To Screen" );
static LocalizedString SCREEN_OFF ( "ScreenDebugOverlay", "Send Off To Screen" );
2006-01-24 06:09:25 +00:00
static LocalizedString RELOAD_THEME_AND_TEXTURES( "ScreenDebugOverlay", "Reload Theme and Textures" );
2005-12-20 08:35:47 +00:00
static LocalizedString WRITE_PROFILES ( "ScreenDebugOverlay", "Write Profiles" );
static LocalizedString WRITE_PREFERENCES ( "ScreenDebugOverlay", "Write Preferences" );
2006-01-24 06:09:25 +00:00
static LocalizedString MENU_TIMER ( "ScreenDebugOverlay", "Menu Timer" );
static LocalizedString FLUSH_LOG ( "ScreenDebugOverlay", "Flush Log" );
2005-12-20 08:35:47 +00:00
static LocalizedString PULL_BACK_CAMERA ( "ScreenDebugOverlay", "Pull Back Camera" );
2007-06-18 20:59:51 +00:00
static LocalizedString VISUAL_DELAY_UP ( "ScreenDebugOverlay", "Visual Delay Up" );
static LocalizedString VISUAL_DELAY_DOWN ( "ScreenDebugOverlay", "Visual Delay Down" );
2006-01-24 06:09:25 +00:00
static LocalizedString VOLUME_UP ( "ScreenDebugOverlay", "Volume Up" );
static LocalizedString VOLUME_DOWN ( "ScreenDebugOverlay", "Volume Down" );
static LocalizedString UPTIME ( "ScreenDebugOverlay", "Uptime" );
static LocalizedString FORCE_CRASH ( "ScreenDebugOverlay", "Force Crash" );
2006-01-24 06:09:25 +00:00
static LocalizedString SLOW ( "ScreenDebugOverlay", "Slow" );
static LocalizedString CPU ( "ScreenDebugOverlay", "CPU" );
static LocalizedString SONG ( "ScreenDebugOverlay", "Song" );
static LocalizedString MACHINE ( "ScreenDebugOverlay", "Machine" );
static LocalizedString SYNC_TEMPO ( "ScreenDebugOverlay", "Tempo" );
2005-12-20 08:35:47 +00:00
2005-08-16 23:23:49 +00:00
class DebugLineAutoplay : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return AUTO_PLAY.GetValue(); }
virtual RString GetDisplayValue()
2005-08-16 23:23:49 +00:00
{
2006-11-22 05:51:10 +00:00
switch( GamePreferences::m_AutoPlay.Get() )
2005-08-16 23:23:49 +00:00
{
case PC_HUMAN: return OFF.GetValue(); break;
case PC_AUTOPLAY: return ON.GetValue(); break;
case PC_CPU: return CPU.GetValue(); break;
2006-01-22 01:00:06 +00:00
default: ASSERT(0); return RString();
2005-08-16 23:23:49 +00:00
}
}
virtual Type GetType() const { return IDebugLine::gameplay_only; }
2006-11-21 05:02:55 +00:00
virtual bool IsEnabled() { return GamePreferences::m_AutoPlay.Get() != PC_HUMAN; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
ASSERT( GAMESTATE->m_MasterPlayerNumber != PLAYER_INVALID );
PlayerController pc = GAMESTATE->m_pPlayerState[GAMESTATE->m_MasterPlayerNumber]->m_PlayerController;
bool bHoldingShift = INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_LSHIFT) );
if( bHoldingShift )
pc = (pc==PC_CPU) ? PC_HUMAN : PC_CPU;
else
pc = (pc==PC_AUTOPLAY) ? PC_HUMAN : PC_AUTOPLAY;
2006-11-21 05:02:55 +00:00
GamePreferences::m_AutoPlay.Set( pc );
2005-08-23 21:07:07 +00:00
FOREACH_HumanPlayer(p)
2006-11-21 05:02:55 +00:00
GAMESTATE->m_pPlayerState[p]->m_PlayerController = GamePreferences::m_AutoPlay;
2005-08-23 21:07:07 +00:00
FOREACH_MultiPlayer(p)
2006-11-21 05:02:55 +00:00
GAMESTATE->m_pMultiPlayerState[p]->m_PlayerController = GamePreferences::m_AutoPlay;
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
2007-01-25 11:03:41 +00:00
class DebugLineAssist : public IDebugLine
2005-08-16 23:23:49 +00:00
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return ASSIST.GetValue(); }
virtual Type GetType() const { return gameplay_only; }
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayValue() {
2007-01-25 11:03:41 +00:00
SongOptions so;
so.m_bAssistClap = GAMESTATE->m_SongOptions.GetSong().m_bAssistClap;
so.m_bAssistMetronome = GAMESTATE->m_SongOptions.GetSong().m_bAssistMetronome;
if( so.m_bAssistClap || so.m_bAssistMetronome )
return so.GetLocalizedString();
else
return OFF.GetValue();
}
virtual bool IsEnabled() { return GAMESTATE->m_SongOptions.GetSong().m_bAssistClap || GAMESTATE->m_SongOptions.GetSong().m_bAssistMetronome; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
2007-01-25 11:03:41 +00:00
ASSERT( GAMESTATE->m_MasterPlayerNumber != PLAYER_INVALID );
bool bHoldingShift = INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_LSHIFT) );
bool b;
if( bHoldingShift )
b = !GAMESTATE->m_SongOptions.GetSong().m_bAssistMetronome;
else
b = !GAMESTATE->m_SongOptions.GetSong().m_bAssistClap;
if( bHoldingShift )
SO_GROUP_ASSIGN( GAMESTATE->m_SongOptions, ModsLevel_Preferred, m_bAssistMetronome, b );
2007-01-25 11:03:41 +00:00
else
SO_GROUP_ASSIGN( GAMESTATE->m_SongOptions, ModsLevel_Preferred, m_bAssistClap, b );
2007-01-25 11:03:41 +00:00
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineAutosync : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return AUTOSYNC.GetValue(); }
virtual RString GetDisplayValue()
2005-08-16 23:23:49 +00:00
{
switch( GAMESTATE->m_SongOptions.GetSong().m_AutosyncType )
2005-08-16 23:23:49 +00:00
{
case SongOptions::AUTOSYNC_OFF: return OFF.GetValue(); break;
case SongOptions::AUTOSYNC_SONG: return SONG.GetValue(); break;
case SongOptions::AUTOSYNC_MACHINE: return MACHINE.GetValue(); break;
case SongOptions::AUTOSYNC_TEMPO: return SYNC_TEMPO.GetValue(); break;
2005-08-16 23:23:49 +00:00
default: ASSERT(0);
}
}
virtual Type GetType() const { return IDebugLine::gameplay_only; }
virtual bool IsEnabled() { return GAMESTATE->m_SongOptions.GetSong().m_AutosyncType!=SongOptions::AUTOSYNC_OFF; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
int as = GAMESTATE->m_SongOptions.GetSong().m_AutosyncType + 1;
2006-08-18 04:47:11 +00:00
bool bAllowSongAutosync = !GAMESTATE->IsCourseMode();
if( !bAllowSongAutosync &&
( as == SongOptions::AUTOSYNC_SONG || as == SongOptions::AUTOSYNC_TEMPO ) )
2006-08-18 04:47:11 +00:00
as = SongOptions::AUTOSYNC_MACHINE;
wrap( as, SongOptions::NUM_AUTOSYNC_TYPES );
SO_GROUP_ASSIGN( GAMESTATE->m_SongOptions, ModsLevel_Song, m_AutosyncType, SongOptions::AutosyncType(as) );
2005-08-17 10:16:06 +00:00
MESSAGEMAN->Broadcast( Message_AutosyncChanged );
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineCoinMode : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return COIN_MODE.GetValue(); }
virtual RString GetDisplayValue() { return CoinModeToString(GamePreferences::m_CoinMode); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return true; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
int cm = GamePreferences::m_CoinMode+1;
wrap( cm, NUM_CoinMode );
GamePreferences::m_CoinMode.Set( CoinMode(cm) );
2005-08-16 23:23:49 +00:00
SCREENMAN->RefreshCreditsMessages();
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineSlow : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return SLOW.GetValue(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return g_bIsSlow; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
g_bIsSlow = !g_bIsSlow;
SetSpeed();
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineHalt : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return HALT.GetValue(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return g_bIsHalt; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
g_bIsHalt = !g_bIsHalt;
g_HaltTimer.Touch();
SetSpeed();
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineLightsDebug : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return LIGHTS_DEBUG.GetValue(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return PREFSMAN->m_bDebugLights.Get(); }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
PREFSMAN->m_bDebugLights.Set( !PREFSMAN->m_bDebugLights );
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineMonkeyInput : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return MONKEY_INPUT.GetValue(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return PREFSMAN->m_bMonkeyInput.Get(); }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
PREFSMAN->m_bMonkeyInput.Set( !PREFSMAN->m_bMonkeyInput );
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineStats : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return RENDERING_STATS.GetValue(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return PREFSMAN->m_bShowStats.Get(); }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
PREFSMAN->m_bShowStats.Set( !PREFSMAN->m_bShowStats );
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineVsync : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return VSYNC.GetValue(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return PREFSMAN->m_bVsync.Get(); }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
PREFSMAN->m_bVsync.Set( !PREFSMAN->m_bVsync );
2005-12-02 01:16:28 +00:00
StepMania::ApplyGraphicOptions();
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
2005-11-07 03:59:05 +00:00
class DebugLineAllowMultitexture : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return MULTITEXTURE.GetValue(); }
2005-11-07 03:59:05 +00:00
virtual bool IsEnabled() { return PREFSMAN->m_bAllowMultitexture.Get(); }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-11-07 03:59:05 +00:00
{
PREFSMAN->m_bAllowMultitexture.Set( !PREFSMAN->m_bAllowMultitexture );
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-11-07 03:59:05 +00:00
}
};
2005-08-16 23:23:49 +00:00
2007-05-23 21:07:28 +00:00
class DebugLineShowMasks : public IDebugLine
{
virtual RString GetDisplayTitle() { return SCREEN_SHOW_MASKS.GetValue(); }
virtual bool IsEnabled() { return GetPref()->Get(); }
virtual RString GetPageName() const { return "Theme"; }
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
{
GetPref()->Set( !GetPref()->Get() );
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
}
Preference<bool> *GetPref()
{
2007-05-24 21:35:03 +00:00
return Preference<bool>::GetPreferenceByName("ShowMasks");
2007-05-23 21:07:28 +00:00
}
};
2007-05-06 05:21:31 +00:00
static ProfileSlot g_ProfileSlot = ProfileSlot_Machine;
static bool IsSelectProfilePersistent()
2005-08-16 23:23:49 +00:00
{
2007-05-06 05:21:31 +00:00
if( g_ProfileSlot == ProfileSlot_Machine )
return true;
return PROFILEMAN->IsPersistentProfile( (PlayerNumber) g_ProfileSlot );
}
class DebugLineProfileSlot : public IDebugLine
{
virtual RString GetDisplayTitle() { return PROFILE.GetValue(); }
virtual RString GetDisplayValue()
{
switch( g_ProfileSlot )
{
case ProfileSlot_Machine: return "Machine";
case ProfileSlot_Player1: return "Player 1";
case ProfileSlot_Player2: return "Player 2";
}
return RString();
}
virtual bool IsEnabled() { return IsSelectProfilePersistent(); }
virtual RString GetPageName() const { return "Profiles"; }
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
{
enum_add( g_ProfileSlot, +1 );
if( g_ProfileSlot == NUM_ProfileSlot )
g_ProfileSlot = ProfileSlot_Player1;
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
}
};
class DebugLineClearProfileStats : public IDebugLine
{
virtual RString GetDisplayTitle() { return CLEAR_PROFILE_STATS.GetValue(); }
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayValue() { return RString(); }
2007-05-06 05:21:31 +00:00
virtual bool IsEnabled() { return IsSelectProfilePersistent(); }
2007-05-06 04:49:21 +00:00
virtual RString GetPageName() const { return "Profiles"; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
2007-05-06 05:22:50 +00:00
Profile *pProfile = PROFILEMAN->GetProfile( g_ProfileSlot );
2007-05-06 05:13:58 +00:00
pProfile->ClearStats();
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
2006-01-18 10:09:34 +00:00
static HighScore MakeRandomHighScore( float fPercentDP )
{
HighScore hs;
hs.SetName( "FAKE" );
2007-06-15 15:00:14 +00:00
Grade g = (Grade)SCALE( RandomInt(6), 0, 4, Grade_Tier01, Grade_Tier06 );
if( g == Grade_Tier06 )
g = Grade_Failed;
hs.SetGrade( g );
hs.SetScore( RandomInt(100*1000) );
2006-01-18 10:09:34 +00:00
hs.SetPercentDP( fPercentDP );
2007-10-27 01:51:58 +00:00
hs.SetAliveSeconds( randomf(30.0f, 100.0f) );
2006-01-18 10:09:34 +00:00
PlayerOptions po;
po.ChooseRandomModifiers();
hs.SetModifiers( po.GetString() );
hs.SetDateTime( DateTime::GetNowDateTime() );
hs.SetPlayerGuid( Profile::MakeGuid() );
hs.SetMachineGuid( Profile::MakeGuid() );
hs.SetProductID( RandomInt(10) );
FOREACH_ENUM( TapNoteScore, tns )
hs.SetTapNoteScore( tns, RandomInt(100) );
FOREACH_ENUM( HoldNoteScore, hns )
hs.SetHoldNoteScore( hns, RandomInt(100) );
2006-01-18 10:09:34 +00:00
RadarValues rv;
FOREACH_ENUM( RadarCategory, rc )
2006-01-18 10:09:34 +00:00
rv.m_Values.f[rc] = randomf( 0, 1 );
hs.SetRadarValues( rv );
return hs;
}
2006-03-18 11:59:41 +00:00
static void FillProfileStats( Profile *pProfile )
2006-01-18 10:09:34 +00:00
{
2006-03-21 03:57:56 +00:00
pProfile->InitSongScores();
pProfile->InitCourseScores();
static int s_iCount = 0;
2006-01-18 10:09:34 +00:00
// Choose a percent for all scores. This is useful for testing unlocks
// where some elements are unlocked at a certain percent complete
2006-03-21 03:57:56 +00:00
float fPercentDP = s_iCount ? randomf( 0.6f, 1.0f ) : 1.0f;
s_iCount = (s_iCount+1)%2;
2006-01-18 10:09:34 +00:00
int iCount = pProfile->IsMachine()?
PREFSMAN->m_iMaxHighScoresPerListForMachine.Get():
PREFSMAN->m_iMaxHighScoresPerListForPlayer.Get();
2009-03-22 08:42:27 +00:00
vector<Song*> vpAllSongs = SONGMAN->GetAllSongs();
2006-01-18 10:09:34 +00:00
FOREACH( Song*, vpAllSongs, pSong )
{
vector<Steps*> vpAllSteps = (*pSong)->GetAllSteps();
FOREACH( Steps*, vpAllSteps, pSteps )
{
2007-06-15 15:00:14 +00:00
if( rand() % 5 )
pProfile->IncrementStepsPlayCount( *pSong, *pSteps );
2006-01-18 10:09:34 +00:00
for( int i=0; i<iCount; i++ )
{
int iIndex = 0;
pProfile->AddStepsHighScore( *pSong, *pSteps, MakeRandomHighScore(fPercentDP), iIndex );
}
}
}
vector<Course*> vpAllCourses;
SONGMAN->GetAllCourses( vpAllCourses, true );
FOREACH( Course*, vpAllCourses, pCourse )
{
vector<Trail*> vpAllTrails;
(*pCourse)->GetAllTrails( vpAllTrails );
FOREACH( Trail*, vpAllTrails, pTrail )
{
2007-06-15 15:00:14 +00:00
if( rand() % 5 )
pProfile->IncrementCoursePlayCount( *pCourse, *pTrail );
2006-01-18 10:09:34 +00:00
for( int i=0; i<iCount; i++ )
{
int iIndex = 0;
pProfile->AddCourseHighScore( *pCourse, *pTrail, MakeRandomHighScore(fPercentDP), iIndex );
}
}
}
}
2007-05-06 05:21:31 +00:00
class DebugLineFillProfileStats : public IDebugLine
2005-08-16 23:23:49 +00:00
{
2007-05-06 05:21:31 +00:00
virtual RString GetDisplayTitle() { return FILL_PROFILE_STATS.GetValue(); }
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayValue() { return RString(); }
2007-05-06 05:21:31 +00:00
virtual bool IsEnabled() { return IsSelectProfilePersistent(); }
2007-05-06 04:49:21 +00:00
virtual RString GetPageName() const { return "Profiles"; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
2007-05-06 05:21:31 +00:00
Profile* pProfile = PROFILEMAN->GetProfile( g_ProfileSlot );
2006-03-18 11:59:41 +00:00
FillProfileStats( pProfile );
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineSendNotesEnded : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return SEND_NOTES_ENDED.GetValue(); }
virtual RString GetDisplayValue() { return RString(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return true; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
SCREENMAN->PostMessageToTopScreen( SM_NotesEnded, 0 );
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineReloadCurrentScreen : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return RELOAD.GetValue(); }
virtual RString GetDisplayValue() { return SCREENMAN && SCREENMAN->GetTopScreen()? SCREENMAN->GetTopScreen()->GetName() : RString(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return true; }
2007-05-06 04:49:21 +00:00
virtual RString GetPageName() const { return "Theme"; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
2006-08-31 20:49:39 +00:00
RString sScreenName = SCREENMAN->GetScreen(0)->GetName();
SCREENMAN->PopAllScreens();
2005-08-16 23:23:49 +00:00
SOUND->StopMusic();
2005-12-02 01:16:28 +00:00
StepMania::ResetGame();
2006-08-09 03:29:24 +00:00
SCREENMAN->SetNewScreen( sScreenName );
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-30 01:17:38 +00:00
sMessageOut = "";
2005-08-16 23:23:49 +00:00
}
};
2006-08-10 17:49:40 +00:00
class DebugLineRestartCurrentScreen : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return RESTART.GetValue(); }
virtual RString GetDisplayValue() { return SCREENMAN && SCREENMAN->GetTopScreen()? SCREENMAN->GetTopScreen()->GetName() : RString(); }
2006-08-10 17:49:40 +00:00
virtual bool IsEnabled() { return true; }
virtual bool ForceOffAfterUse() const { return true; }
2007-05-06 04:49:21 +00:00
virtual RString GetPageName() const { return "Theme"; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2006-08-10 17:49:40 +00:00
{
SCREENMAN->GetTopScreen()->BeginScreen();
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2006-08-10 17:49:40 +00:00
sMessageOut = "";
}
};
2007-04-29 03:52:57 +00:00
class DebugLineCurrentScreenOn : public IDebugLine
{
virtual RString GetDisplayTitle() { return SCREEN_ON.GetValue(); }
virtual RString GetDisplayValue() { return SCREENMAN && SCREENMAN->GetTopScreen()? SCREENMAN->GetTopScreen()->GetName() : RString(); }
virtual bool IsEnabled() { return true; }
virtual bool ForceOffAfterUse() const { return true; }
2007-05-06 04:49:21 +00:00
virtual RString GetPageName() const { return "Theme"; }
2007-04-29 03:52:57 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
{
SCREENMAN->GetTopScreen()->PlayCommand("On");
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
sMessageOut = "";
}
};
class DebugLineCurrentScreenOff : public IDebugLine
{
virtual RString GetDisplayTitle() { return SCREEN_OFF.GetValue(); }
virtual RString GetDisplayValue() { return SCREENMAN && SCREENMAN->GetTopScreen()? SCREENMAN->GetTopScreen()->GetName() : RString(); }
virtual bool IsEnabled() { return true; }
virtual bool ForceOffAfterUse() const { return true; }
2007-05-06 04:49:21 +00:00
virtual RString GetPageName() const { return "Theme"; }
2007-04-29 03:52:57 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
{
SCREENMAN->GetTopScreen()->PlayCommand("Off");
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
sMessageOut = "";
}
};
2005-08-16 23:23:49 +00:00
class DebugLineReloadTheme : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return RELOAD_THEME_AND_TEXTURES.GetValue(); }
virtual RString GetDisplayValue() { return RString(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return true; }
2007-05-06 04:49:21 +00:00
virtual RString GetPageName() const { return "Theme"; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
THEME->ReloadMetrics();
TEXTUREMAN->ReloadAll();
NOTESKIN->RefreshNoteSkinData( GAMESTATE->m_pCurGame );
CodeDetector::RefreshCacheItems();
2006-01-24 06:09:25 +00:00
// HACK: Don't update text below. Return immediately because this screen
// was just destroyed as part of the theme reload.
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineWriteProfiles : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return WRITE_PROFILES.GetValue(); }
virtual RString GetDisplayValue() { return RString(); }
2007-05-06 05:21:31 +00:00
virtual bool IsEnabled() { return IsSelectProfilePersistent(); }
2007-05-06 04:49:21 +00:00
virtual RString GetPageName() const { return "Profiles"; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
// Also save bookkeeping and profile info for debugging
// so we don't have to play through a whole song to get new output.
2007-05-06 05:21:31 +00:00
if( g_ProfileSlot == ProfileSlot_Machine )
GAMESTATE->SaveLocalData();
else
2007-06-15 15:53:13 +00:00
{
PlayerNumber pn = (PlayerNumber) g_ProfileSlot;
GAMESTATE->SaveCurrentSettingsToProfile(pn);
GAMESTATE->SaveProfile( pn );
}
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineWritePreferences : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return WRITE_PREFERENCES.GetValue(); }
virtual RString GetDisplayValue() { return RString(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return true; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
2005-10-27 04:54:45 +00:00
PREFSMAN->SavePrefsToDisk();
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineMenuTimer : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return MENU_TIMER.GetValue(); }
virtual RString GetDisplayValue() { return RString(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return PREFSMAN->m_bMenuTimer.Get(); }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
PREFSMAN->m_bMenuTimer.Set( !PREFSMAN->m_bMenuTimer );
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
class DebugLineFlushLog : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return FLUSH_LOG.GetValue(); }
virtual RString GetDisplayValue() { return RString(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return true; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
LOG->Flush();
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
};
2005-08-17 23:53:02 +00:00
class DebugLinePullBackCamera : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return PULL_BACK_CAMERA.GetValue(); }
virtual RString GetDisplayValue() { return RString(); }
2005-08-17 23:53:02 +00:00
virtual bool IsEnabled() { return g_fImageScaleDestination != 1; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-17 23:53:02 +00:00
{
if( g_fImageScaleDestination == 1 )
g_fImageScaleDestination = 0.5f;
else
g_fImageScaleDestination = 1;
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-17 23:53:02 +00:00
}
};
2005-08-16 23:23:49 +00:00
class DebugLineVolumeUp : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return VOLUME_UP.GetValue(); }
2007-05-24 21:35:03 +00:00
virtual RString GetDisplayValue() { return ssprintf("%.0f%%", GetPref()->Get()*100); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return true; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
ChangeVolume( +0.1f );
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2005-08-16 23:23:49 +00:00
}
2007-05-24 21:35:03 +00:00
Preference<float> *GetPref()
{
return Preference<float>::GetPreferenceByName("SoundVolume");
}
2005-08-16 23:23:49 +00:00
};
class DebugLineVolumeDown : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return VOLUME_DOWN.GetValue(); }
virtual RString GetDisplayValue() { return RString(); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return true; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
2005-08-16 23:23:49 +00:00
{
ChangeVolume( -0.1f );
2007-01-25 11:19:11 +00:00
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
2007-05-24 21:35:03 +00:00
sMessageOut += " - " + ssprintf("%.0f%%",GetPref()->Get()*100);
}
Preference<float> *GetPref()
{
return Preference<float>::GetPreferenceByName("SoundVolume");
2005-08-16 23:23:49 +00:00
}
};
2007-06-18 20:59:51 +00:00
class DebugLineVisualDelayUp : public IDebugLine
{
virtual RString GetDisplayTitle() { return VISUAL_DELAY_UP.GetValue(); }
virtual RString GetDisplayValue() { return ssprintf("%.03f",GetPref()->Get()); }
virtual bool IsEnabled() { return true; }
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
{
ChangeVisualDelay( +0.001f );
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
}
Preference<float> *GetPref()
{
return Preference<float>::GetPreferenceByName("VisualDelaySeconds");
}
};
class DebugLineVisualDelayDown : public IDebugLine
{
virtual RString GetDisplayTitle() { return VISUAL_DELAY_DOWN.GetValue(); }
virtual RString GetDisplayValue() { return RString(); }
virtual bool IsEnabled() { return true; }
virtual void DoAndMakeSystemMessage( RString &sMessageOut )
{
ChangeVisualDelay( -0.001f );
IDebugLine::DoAndMakeSystemMessage( sMessageOut );
sMessageOut += " - " + ssprintf("%.03f",GetPref()->Get());
}
Preference<float> *GetPref()
{
return Preference<float>::GetPreferenceByName("VisualDelaySeconds");
}
};
class DebugLineForceCrash : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return FORCE_CRASH.GetValue(); }
virtual RString GetDisplayValue() { return RString(); }
virtual bool IsEnabled() { return false; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut ) { FAIL_M("DebugLineCrash"); }
};
2005-08-16 23:23:49 +00:00
class DebugLineUptime : public IDebugLine
{
2007-01-25 11:19:11 +00:00
virtual RString GetDisplayTitle() { return UPTIME.GetValue(); }
virtual RString GetDisplayValue() { return SecondsToMMSSMsMsMs(RageTimer::GetTimeSinceStart()); }
2005-08-16 23:23:49 +00:00
virtual bool IsEnabled() { return false; }
2007-01-25 11:19:11 +00:00
virtual void DoAndMakeSystemMessage( RString &sMessageOut ) {}
2005-08-16 23:23:49 +00:00
};
2005-12-09 01:46:19 +00:00
/* #ifdef out the lines below if you don't want them to appear on certain
* platforms. This is easier than #ifdefing the whole DebugLine definitions
* that can span pages.
*/
#define DECLARE_ONE( x ) static x g_##x
2005-12-09 01:46:19 +00:00
DECLARE_ONE( DebugLineAutoplay );
2007-01-25 11:03:41 +00:00
DECLARE_ONE( DebugLineAssist );
2005-12-09 01:46:19 +00:00
DECLARE_ONE( DebugLineAutosync );
DECLARE_ONE( DebugLineCoinMode );
DECLARE_ONE( DebugLineSlow );
DECLARE_ONE( DebugLineHalt );
DECLARE_ONE( DebugLineLightsDebug );
DECLARE_ONE( DebugLineMonkeyInput );
DECLARE_ONE( DebugLineStats );
DECLARE_ONE( DebugLineVsync );
DECLARE_ONE( DebugLineAllowMultitexture );
2007-05-23 21:07:28 +00:00
DECLARE_ONE( DebugLineShowMasks );
2007-05-06 05:21:31 +00:00
DECLARE_ONE( DebugLineProfileSlot );
DECLARE_ONE( DebugLineClearProfileStats );
DECLARE_ONE( DebugLineFillProfileStats );
2005-12-09 01:46:19 +00:00
DECLARE_ONE( DebugLineSendNotesEnded );
DECLARE_ONE( DebugLineReloadCurrentScreen );
2006-08-10 17:49:40 +00:00
DECLARE_ONE( DebugLineRestartCurrentScreen );
2007-04-29 03:52:57 +00:00
DECLARE_ONE( DebugLineCurrentScreenOn );
DECLARE_ONE( DebugLineCurrentScreenOff );
2005-12-09 01:46:19 +00:00
DECLARE_ONE( DebugLineReloadTheme );
DECLARE_ONE( DebugLineWriteProfiles );
DECLARE_ONE( DebugLineWritePreferences );
DECLARE_ONE( DebugLineMenuTimer );
DECLARE_ONE( DebugLineFlushLog );
DECLARE_ONE( DebugLinePullBackCamera );
DECLARE_ONE( DebugLineVolumeUp );
DECLARE_ONE( DebugLineVolumeDown );
2007-06-18 20:59:51 +00:00
DECLARE_ONE( DebugLineVisualDelayUp );
DECLARE_ONE( DebugLineVisualDelayDown );
DECLARE_ONE( DebugLineForceCrash );
2005-11-07 03:59:05 +00:00
DECLARE_ONE( DebugLineUptime );
2005-08-16 23:23:49 +00:00
2005-05-16 10:10:08 +00:00
/*
* (c) 2001-2005 Chris Danford, Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/