2003-09-28 02:59:02 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
|
|
#include "ScreenOptionsMaster.h"
|
|
|
|
|
#include "RageException.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "SongManager.h"
|
2003-09-28 05:04:55 +00:00
|
|
|
#include "PrefsManager.h"
|
2003-09-28 07:14:07 +00:00
|
|
|
#include "StepMania.h"
|
2003-10-12 20:34:46 +00:00
|
|
|
#include "RageSoundManager.h"
|
2005-01-29 21:56:24 +00:00
|
|
|
#include "Foreach.h"
|
2005-02-24 04:56:36 +00:00
|
|
|
#include "OptionRowHandler.h"
|
|
|
|
|
#include "ScreenOptionsMasterPrefs.h"
|
2005-05-24 23:32:39 +00:00
|
|
|
#include "CommonMetrics.h"
|
2003-09-28 02:59:02 +00:00
|
|
|
|
2005-02-20 10:12:50 +00:00
|
|
|
#define LINE_NAMES THEME->GetMetric (m_sName,"LineNames")
|
|
|
|
|
#define LINE(sLineName) THEME->GetMetric (m_sName,ssprintf("Line%s",sLineName.c_str()))
|
2006-01-15 22:35:25 +00:00
|
|
|
#define FORCE_ALL_PLAYERS THEME->GetMetricB(m_sName,"ForceAllPlayers")
|
2006-01-16 02:37:19 +00:00
|
|
|
#define INPUT_MODE THEME->GetMetric (m_sName,"InputMode")
|
2006-01-16 03:25:30 +00:00
|
|
|
#define NAVIGATION_MODE THEME->GetMetric (m_sName,"NavigationMode")
|
2003-09-28 02:59:02 +00:00
|
|
|
|
2005-01-29 21:56:24 +00:00
|
|
|
|
2006-01-15 20:46:15 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenOptionsMaster );
|
2005-02-23 06:29:05 +00:00
|
|
|
|
|
|
|
|
void ScreenOptionsMaster::Init()
|
|
|
|
|
{
|
2005-12-09 21:36:22 +00:00
|
|
|
vector<CString> asLineNames;
|
2004-02-13 05:27:18 +00:00
|
|
|
split( LINE_NAMES, ",", asLineNames );
|
|
|
|
|
if( asLineNames.empty() )
|
|
|
|
|
RageException::Throw( "%s::LineNames is empty.", m_sName.c_str() );
|
|
|
|
|
|
2006-01-15 22:35:25 +00:00
|
|
|
if( FORCE_ALL_PLAYERS )
|
|
|
|
|
{
|
|
|
|
|
FOREACH_PlayerNumber( pn )
|
|
|
|
|
GAMESTATE->m_bSideIsJoined[pn] = true;
|
|
|
|
|
GAMESTATE->m_MasterPlayerNumber = PLAYER_1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-16 03:25:30 +00:00
|
|
|
if( NAVIGATION_MODE == "toggle" )
|
|
|
|
|
SetNavigation( PREFSMAN->m_bArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY );
|
|
|
|
|
else if( NAVIGATION_MODE == "menu" )
|
|
|
|
|
SetNavigation( NAV_THREE_KEY_MENU );
|
2003-09-28 04:07:53 +00:00
|
|
|
|
2006-01-16 02:37:19 +00:00
|
|
|
SetInputMode( StringToInputMode(INPUT_MODE) );
|
2005-07-15 03:28:09 +00:00
|
|
|
|
2005-07-15 02:27:37 +00:00
|
|
|
// Call this after enabling players, if any.
|
|
|
|
|
ScreenOptions::Init();
|
|
|
|
|
|
2005-02-26 21:35:27 +00:00
|
|
|
vector<OptionRowDefinition> OptionRowDefs;
|
|
|
|
|
OptionRowDefs.resize( asLineNames.size() );
|
2004-09-21 07:53:39 +00:00
|
|
|
for( unsigned i = 0; i < asLineNames.size(); ++i )
|
2003-09-28 02:59:02 +00:00
|
|
|
{
|
2004-02-13 05:27:18 +00:00
|
|
|
CString sLineName = asLineNames[i];
|
|
|
|
|
CString sRowCommands = LINE(sLineName);
|
2004-01-10 20:43:32 +00:00
|
|
|
|
2005-12-06 04:25:52 +00:00
|
|
|
Commands cmds;
|
|
|
|
|
ParseCommands( sRowCommands, cmds );
|
2003-09-28 02:59:02 +00:00
|
|
|
|
2006-01-16 03:52:45 +00:00
|
|
|
OptionRowDefinition &def = OptionRowDefs[i];
|
|
|
|
|
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds, def );
|
2005-02-24 06:10:11 +00:00
|
|
|
if( pHand == NULL )
|
2006-01-16 03:49:21 +00:00
|
|
|
RageException::Throw( "Invalid OptionRowHandler '%s' in %s::Line%i", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), i );
|
2006-01-16 03:52:45 +00:00
|
|
|
m_OptionRowHandlers.push_back( pHand );
|
2003-09-28 02:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-16 05:24:41 +00:00
|
|
|
ASSERT( m_OptionRowHandlers.size() == asLineNames.size() );
|
2003-09-28 02:59:02 +00:00
|
|
|
|
2005-07-16 05:24:41 +00:00
|
|
|
|
|
|
|
|
InitMenu( OptionRowDefs, m_OptionRowHandlers );
|
2003-09-28 02:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScreenOptionsMaster::~ScreenOptionsMaster()
|
|
|
|
|
{
|
2005-06-23 08:05:09 +00:00
|
|
|
FOREACH( OptionRow*, m_pRows, r )
|
2005-02-25 05:45:16 +00:00
|
|
|
(*r)->DetachHandler();
|
2005-07-16 05:24:41 +00:00
|
|
|
FOREACH( OptionRowHandler*, m_OptionRowHandlers, h )
|
2005-02-24 04:56:36 +00:00
|
|
|
SAFE_DELETE( *h );
|
2005-07-16 05:24:41 +00:00
|
|
|
m_OptionRowHandlers.clear();
|
2003-09-28 02:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
2005-04-03 06:21:02 +00:00
|
|
|
void ScreenOptionsMaster::ImportOptions( int r, const vector<PlayerNumber> &vpns )
|
2003-09-28 02:59:02 +00:00
|
|
|
{
|
2005-04-03 06:21:02 +00:00
|
|
|
FOREACH_CONST( PlayerNumber, vpns, pn )
|
|
|
|
|
ASSERT( GAMESTATE->IsHumanPlayer(*pn) );
|
2005-06-23 08:05:09 +00:00
|
|
|
OptionRow &row = *m_pRows[r];
|
2005-04-03 06:21:02 +00:00
|
|
|
row.ImportOptions( vpns );
|
2003-09-28 02:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
2005-04-03 06:21:02 +00:00
|
|
|
void ScreenOptionsMaster::ExportOptions( int r, const vector<PlayerNumber> &vpns )
|
2005-02-12 09:07:59 +00:00
|
|
|
{
|
2005-06-23 08:05:09 +00:00
|
|
|
OptionRow &row = *m_pRows[r];
|
2005-04-03 06:21:02 +00:00
|
|
|
bool bRowHasFocus[NUM_PLAYERS];
|
|
|
|
|
ZERO( bRowHasFocus );
|
2005-04-21 19:53:37 +00:00
|
|
|
FOREACH_CONST( PlayerNumber, vpns, p )
|
|
|
|
|
{
|
|
|
|
|
int iCurRow = m_iCurrentRow[*p];
|
|
|
|
|
bRowHasFocus[*p] = iCurRow == r;
|
|
|
|
|
}
|
2005-04-03 06:21:02 +00:00
|
|
|
m_iChangeMask |= row.ExportOptions( vpns, bRowHasFocus );
|
2003-09-28 02:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-24 01:17:39 +00:00
|
|
|
void ScreenOptionsMaster::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
2005-07-12 06:10:01 +00:00
|
|
|
if( SM == SM_ExportOptions )
|
2005-02-24 01:17:39 +00:00
|
|
|
{
|
2005-07-12 06:03:12 +00:00
|
|
|
//
|
|
|
|
|
// Override ScreenOptions's calling of ExportOptions
|
|
|
|
|
//
|
|
|
|
|
m_iChangeMask = 0;
|
|
|
|
|
|
|
|
|
|
CHECKPOINT;
|
|
|
|
|
|
2006-01-15 08:41:17 +00:00
|
|
|
vector<PlayerNumber> vpns;
|
|
|
|
|
FOREACH_OptionsPlayer( p )
|
|
|
|
|
vpns.push_back( p );
|
2005-07-16 05:24:41 +00:00
|
|
|
for( unsigned r = 0; r < m_OptionRowHandlers.size(); ++r )
|
2005-02-24 01:17:39 +00:00
|
|
|
{
|
2005-07-16 05:24:41 +00:00
|
|
|
CHECKPOINT_M( ssprintf("%i/%i", r, int(m_OptionRowHandlers.size())) );
|
2005-07-12 06:03:12 +00:00
|
|
|
ExportOptions( r, vpns );
|
2005-02-24 01:17:39 +00:00
|
|
|
}
|
2005-07-12 06:03:12 +00:00
|
|
|
|
|
|
|
|
if( m_iChangeMask & OPT_APPLY_ASPECT_RATIO )
|
|
|
|
|
{
|
|
|
|
|
THEME->UpdateLuaGlobals(); // This needs to be done before resetting the projection matrix below
|
|
|
|
|
SCREENMAN->ThemeChanged(); // recreate ScreenSystemLayer and SharedBGA
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-16 03:57:12 +00:00
|
|
|
/* If the theme changes, we need to reset RageDisplay to apply the new window
|
|
|
|
|
* title and icon. If the aspect ratio changes, we need to reset RageDisplay
|
|
|
|
|
* so that the projection matrix is re-created using the new screen dimensions. */
|
2005-07-12 06:03:12 +00:00
|
|
|
if( (m_iChangeMask & OPT_APPLY_THEME) ||
|
|
|
|
|
(m_iChangeMask & OPT_APPLY_GRAPHICS) ||
|
|
|
|
|
(m_iChangeMask & OPT_APPLY_ASPECT_RATIO) )
|
2005-12-02 01:16:28 +00:00
|
|
|
StepMania::ApplyGraphicOptions();
|
2005-07-12 06:03:12 +00:00
|
|
|
|
|
|
|
|
if( m_iChangeMask & OPT_SAVE_PREFERENCES )
|
|
|
|
|
{
|
|
|
|
|
/* Save preferences. */
|
|
|
|
|
LOG->Trace("ROW_CONFIG used; saving ...");
|
2005-10-27 04:54:45 +00:00
|
|
|
PREFSMAN->SavePrefsToDisk();
|
2005-07-12 06:03:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( m_iChangeMask & OPT_RESET_GAME )
|
|
|
|
|
{
|
2005-12-02 01:16:28 +00:00
|
|
|
StepMania::ResetGame();
|
2006-01-15 08:04:40 +00:00
|
|
|
m_sNextScreen = CommonMetrics::INITIAL_SCREEN;
|
2005-07-12 06:03:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( m_iChangeMask & OPT_APPLY_SOUND )
|
|
|
|
|
{
|
2005-10-04 06:51:06 +00:00
|
|
|
SOUNDMAN->SetMixVolume( PREFSMAN->GetSoundVolume() );
|
2005-07-12 06:03:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( m_iChangeMask & OPT_APPLY_SONG )
|
|
|
|
|
SONGMAN->SetPreferences();
|
|
|
|
|
|
|
|
|
|
CHECKPOINT;
|
2006-01-15 08:04:40 +00:00
|
|
|
this->HandleScreenMessage( SM_GoToNextScreen );
|
2005-07-12 06:33:00 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2005-07-12 06:03:12 +00:00
|
|
|
else
|
|
|
|
|
ScreenOptions::HandleScreenMessage( SM );
|
2005-02-24 01:17:39 +00:00
|
|
|
}
|
2005-02-20 10:12:50 +00:00
|
|
|
|
2004-06-08 05:22:33 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 2003-2004 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.
|
|
|
|
|
*/
|