change BGALayer to use Actor's map of commands
add "applydefaultoptions" command clean up CoinMode and Premium enums
This commit is contained in:
@@ -494,14 +494,15 @@ void BGAnimationLayer::LoadFromIni( const CString& sAniDir_, const IniKey& layer
|
||||
if( KeyName.Right(7) != "command" )
|
||||
continue; /* not a command */
|
||||
|
||||
const CString &Data = i->second;
|
||||
CString CmdName;
|
||||
const CString &sData = i->second;
|
||||
Commands cmds = ParseCommands( sData );
|
||||
CString sCmdName;
|
||||
/* Special case: "Command=foo" -> "OnCommand=foo" */
|
||||
if( KeyName.size() == 7 )
|
||||
CmdName="on";
|
||||
sCmdName="on";
|
||||
else
|
||||
CmdName = KeyName.Left( KeyName.size()-7 );
|
||||
m_asCommands[CmdName] = Data;
|
||||
sCmdName = KeyName.Left( KeyName.size()-7 );
|
||||
m_mapNameToCommands[sCmdName] = cmds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1005,18 +1006,21 @@ void BGAnimationLayer::LoseFocus()
|
||||
|
||||
void BGAnimationLayer::PlayCommand( const CString &sCommandName )
|
||||
{
|
||||
// Don't call base version.
|
||||
//Actor::PlayCommand( sCommandName );
|
||||
|
||||
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
||||
m_SubActors[i]->RunCommands( ParseCommands("playcommand,"+sCommandName) );
|
||||
|
||||
CString sKey = sCommandName;
|
||||
sKey.MakeLower();
|
||||
map<CString, CString>::const_iterator it = m_asCommands.find( sKey );
|
||||
map<CString, Commands>::const_iterator it = m_mapNameToCommands.find( sKey );
|
||||
|
||||
if( it == m_asCommands.end() )
|
||||
if( it == m_mapNameToCommands.end() )
|
||||
return;
|
||||
|
||||
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
||||
m_SubActors[i]->RunCommands( ParseCommands(it->second) );
|
||||
m_SubActors[i]->RunCommands( it->second );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -32,7 +32,6 @@ public:
|
||||
void LoseFocus();
|
||||
|
||||
void PlayCommand( const CString &sCommandName );
|
||||
void PlayOffCommand() { PlayCommand( "Off" ); }
|
||||
|
||||
protected:
|
||||
vector<RageVector3> m_vParticleVelocity;
|
||||
@@ -83,7 +82,6 @@ protected:
|
||||
|
||||
// common stuff
|
||||
bool m_bGeneric;
|
||||
map<CString, CString> m_asCommands;
|
||||
float m_fRepeatCommandEverySeconds; // -1 = no repeat
|
||||
float m_fSecondsUntilNextCommand;
|
||||
float m_fUpdateRate; // set by GainFocus
|
||||
|
||||
@@ -56,6 +56,7 @@ void GameCommand::Init()
|
||||
m_bInsertCredit = false;
|
||||
m_bResetToFactoryDefaults = false;
|
||||
m_bStopMusic = false;
|
||||
m_bApplyDefaultOptions = false;
|
||||
}
|
||||
|
||||
bool CompareSongOptions( const SongOptions &so1, const SongOptions &so2 );
|
||||
@@ -289,6 +290,10 @@ void GameCommand::Load( int iIndex, const Commands& cmds )
|
||||
{
|
||||
m_bStopMusic = true;
|
||||
}
|
||||
else if( sName == "applydefaultoptions" )
|
||||
{
|
||||
m_bApplyDefaultOptions = true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
@@ -323,7 +328,7 @@ int GetNumCreditsPaid()
|
||||
int iNumCreditsPaid = GAMESTATE->GetNumSidesJoined();
|
||||
|
||||
// players other than the first joined for free
|
||||
if( PREFSMAN->GetPremium() == PrefsManager::JOINT_PREMIUM )
|
||||
if( PREFSMAN->GetPremium() == PREMIUM_JOINT )
|
||||
iNumCreditsPaid = min( iNumCreditsPaid, 1 );
|
||||
|
||||
return iNumCreditsPaid;
|
||||
@@ -332,7 +337,7 @@ int GetNumCreditsPaid()
|
||||
|
||||
int GetCreditsRequiredToPlayStyle( const Style *style )
|
||||
{
|
||||
if( PREFSMAN->GetPremium() == PrefsManager::JOINT_PREMIUM )
|
||||
if( PREFSMAN->GetPremium() == PREMIUM_JOINT )
|
||||
return 1;
|
||||
|
||||
switch( style->m_StyleType )
|
||||
@@ -342,7 +347,7 @@ int GetCreditsRequiredToPlayStyle( const Style *style )
|
||||
case TWO_PLAYERS_TWO_SIDES:
|
||||
return 2;
|
||||
case ONE_PLAYER_TWO_SIDES:
|
||||
return (PREFSMAN->GetPremium() == PrefsManager::DOUBLES_PREMIUM) ? 1 : 2;
|
||||
return (PREFSMAN->GetPremium() == PREMIUM_DOUBLES) ? 1 : 2;
|
||||
default:
|
||||
ASSERT(0);
|
||||
return 1;
|
||||
@@ -509,7 +514,7 @@ void GameCommand::Apply( PlayerNumber pn ) const
|
||||
// players joined. If enough players aren't joined, then
|
||||
// we need to subtract credits for the sides that will be
|
||||
// joined as a result of applying this option.
|
||||
if( PREFSMAN->m_iCoinMode == COIN_PAY )
|
||||
if( PREFSMAN->m_CoinMode == COIN_PAY )
|
||||
{
|
||||
int iNumCreditsRequired = GetCreditsRequiredToPlayStyle(m_pStyle);
|
||||
int iNumCreditsPaid = GetNumCreditsPaid();
|
||||
@@ -571,8 +576,6 @@ void GameCommand::Apply( PlayerNumber pn ) const
|
||||
UNLOCKMAN->UnlockCode( m_iUnlockIndex );
|
||||
if( m_sSoundPath != "" )
|
||||
SOUND->PlayOnce( THEME->GetPathToS( m_sSoundPath ) );
|
||||
if( m_bStopMusic )
|
||||
SOUND->StopMusic();
|
||||
FOREACH_CONST( CString, m_vsScreensToPrepare, s )
|
||||
SCREENMAN->PrepareScreen( *s );
|
||||
if( m_bDeletePreparedScreens )
|
||||
@@ -673,6 +676,16 @@ void GameCommand::Apply( PlayerNumber pn ) const
|
||||
PREFSMAN->ResetToFactoryDefaults();
|
||||
SCREENMAN->SystemMessage( "All options reset to factory defaults." );
|
||||
}
|
||||
if( m_bStopMusic )
|
||||
{
|
||||
SOUND->StopMusic();
|
||||
}
|
||||
if( m_bApplyDefaultOptions )
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
GAMESTATE->m_SongOptions.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
}
|
||||
|
||||
// HACK: Set life type to BATTERY just once here so it happens once and
|
||||
// we don't override the user's changes if they back out.
|
||||
|
||||
@@ -61,6 +61,7 @@ struct GameCommand // used in SelectMode
|
||||
bool m_bInsertCredit;
|
||||
bool m_bResetToFactoryDefaults;
|
||||
bool m_bStopMusic;
|
||||
bool m_bApplyDefaultOptions;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -63,6 +63,14 @@ static const CString CoinModeNames[NUM_COIN_MODES] = {
|
||||
XToString( CoinMode );
|
||||
|
||||
|
||||
static const CString PremiumNames[NUM_PREMIUMS] = {
|
||||
"none",
|
||||
"doubles",
|
||||
"joint",
|
||||
};
|
||||
XToString( Premium );
|
||||
|
||||
|
||||
static const CString SortOrderNames[NUM_SORT_ORDERS] = {
|
||||
"Preferred",
|
||||
"Group",
|
||||
|
||||
@@ -267,6 +267,14 @@ enum CoinMode { COIN_HOME, COIN_PAY, COIN_FREE, NUM_COIN_MODES };
|
||||
const CString& CoinModeToString( CoinMode cm );
|
||||
|
||||
|
||||
//
|
||||
// Premium
|
||||
//
|
||||
enum Premium { PREMIUM_NONE, PREMIUM_DOUBLES, PREMIUM_JOINT, NUM_PREMIUMS };
|
||||
|
||||
const CString& PremiumToString( Premium p );
|
||||
|
||||
|
||||
//
|
||||
// Award stuff
|
||||
//
|
||||
|
||||
@@ -211,9 +211,9 @@ void PrefsManager::Init()
|
||||
m_iMusicWheelSwitchSpeed = 10;
|
||||
m_bEasterEggs = true;
|
||||
m_iMarvelousTiming = 2;
|
||||
m_iCoinMode = COIN_HOME;
|
||||
m_CoinMode = COIN_HOME;
|
||||
m_iCoinsPerCredit = 1;
|
||||
m_Premium = NO_PREMIUM;
|
||||
m_Premium = PREMIUM_NONE;
|
||||
m_bDelayedCreditsReconcile = false;
|
||||
m_iBoostAppPriority = -1;
|
||||
m_bSmoothLines = false;
|
||||
@@ -461,7 +461,7 @@ void PrefsManager::ReadPrefsFromFile( CString sIni )
|
||||
ini.GetValue( "Options", "SoundVolume", m_fSoundVolume );
|
||||
ini.GetValue( "Options", "LightsDriver", m_sLightsDriver );
|
||||
ini.GetValue( "Options", "SoundResampleQuality", m_iSoundResampleQuality );
|
||||
ini.GetValue( "Options", "CoinMode", m_iCoinMode );
|
||||
ini.GetValue( "Options", "CoinMode", (int&)m_CoinMode );
|
||||
ini.GetValue( "Options", "CoinsPerCredit", m_iCoinsPerCredit );
|
||||
m_iCoinsPerCredit = max(m_iCoinsPerCredit, 1);
|
||||
ini.GetValue( "Options", "Premium", (int&)m_Premium );
|
||||
@@ -695,7 +695,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
|
||||
ini.SetValue( "Options", "EasterEggs", m_bEasterEggs );
|
||||
ini.SetValue( "Options", "MarvelousTiming", m_iMarvelousTiming );
|
||||
ini.SetValue( "Options", "SoundResampleQuality", m_iSoundResampleQuality );
|
||||
ini.SetValue( "Options", "CoinMode", m_iCoinMode );
|
||||
ini.SetValue( "Options", "CoinMode", m_CoinMode );
|
||||
ini.SetValue( "Options", "CoinsPerCredit", m_iCoinsPerCredit );
|
||||
ini.SetValue( "Options", "Premium", m_Premium );
|
||||
ini.SetValue( "Options", "DelayedCreditsReconcile", m_bDelayedCreditsReconcile );
|
||||
@@ -831,22 +831,28 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
|
||||
ini.WriteFile( STEPMANIA_INI_PATH );
|
||||
}
|
||||
|
||||
int PrefsManager::GetCoinMode()
|
||||
CoinMode PrefsManager::GetCoinMode()
|
||||
{
|
||||
if( m_bEventMode && m_iCoinMode == COIN_PAY )
|
||||
if( m_bEventMode && m_CoinMode == COIN_PAY )
|
||||
return COIN_FREE;
|
||||
else
|
||||
return m_iCoinMode;
|
||||
return m_CoinMode;
|
||||
}
|
||||
|
||||
PrefsManager::Premium PrefsManager::GetPremium()
|
||||
Premium PrefsManager::GetPremium()
|
||||
{
|
||||
if(m_bEventMode)
|
||||
return NO_PREMIUM;
|
||||
return PREMIUM_NONE;
|
||||
else
|
||||
return m_Premium;
|
||||
}
|
||||
|
||||
|
||||
#include "LuaFunctions.h"
|
||||
LuaFunction_NoArgs( CoinMode, PREFSMAN->m_CoinMode )
|
||||
LuaFunction_NoArgs( Premium, PREFSMAN->m_Premium )
|
||||
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford, Chris Gomez
|
||||
* All rights reserved.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define PREFSMANAGER_H
|
||||
|
||||
#include "PlayerNumber.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "Grade.h" // for NUM_GRADE_TIERS
|
||||
#include "Preference.h"
|
||||
class IniFile;
|
||||
@@ -145,11 +146,10 @@ public:
|
||||
|
||||
// These options have weird interactions depending on m_bEventMode,
|
||||
// so wrap them.
|
||||
enum Premium { NO_PREMIUM, DOUBLES_PREMIUM, JOINT_PREMIUM };
|
||||
int m_iCoinMode;
|
||||
CoinMode m_CoinMode;
|
||||
Premium m_Premium;
|
||||
int GetCoinMode();
|
||||
Premium GetPremium();
|
||||
CoinMode GetCoinMode();
|
||||
Premium GetPremium();
|
||||
|
||||
bool m_bDelayedCreditsReconcile;
|
||||
bool m_bPickExtraStage;
|
||||
|
||||
@@ -168,12 +168,12 @@ bool Screen::ChangeCoinModeInput( const DeviceInput& DeviceI, const InputEventTy
|
||||
return false;
|
||||
if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == KEY_F3 )
|
||||
{
|
||||
PREFSMAN->m_iCoinMode++;
|
||||
wrap( PREFSMAN->m_iCoinMode, NUM_COIN_MODES );
|
||||
((int&)PREFSMAN->m_CoinMode)++;
|
||||
wrap( (int&)PREFSMAN->m_CoinMode, NUM_COIN_MODES );
|
||||
|
||||
/* Show the real coin mode, not GetCoinMode(), or F3 will go "home, free, free"
|
||||
* in event mode. XXX: move GetCoinMode to GameState to keep PrefsManager dumb? */
|
||||
CString sMessage = CoinModeToString( (CoinMode)PREFSMAN->m_iCoinMode );
|
||||
CString sMessage = CoinModeToString( PREFSMAN->m_CoinMode );
|
||||
sMessage.MakeUpper();
|
||||
sMessage = "Coin Mode: " + sMessage;
|
||||
SCREENMAN->RefreshCreditsMessages();
|
||||
@@ -200,7 +200,7 @@ bool Screen::JoinInput( const DeviceInput& DeviceI, const InputEventType type, c
|
||||
iCoinsToCharge = PREFSMAN->m_iCoinsPerCredit;
|
||||
|
||||
// If joint premium don't take away a credit for the 2nd join.
|
||||
if( PREFSMAN->GetPremium() == PrefsManager::JOINT_PREMIUM &&
|
||||
if( PREFSMAN->GetPremium() == PREMIUM_JOINT &&
|
||||
GAMESTATE->GetNumSidesJoined() == 1 )
|
||||
iCoinsToCharge = 0;
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "StepMania.h"
|
||||
#include "Game.h"
|
||||
#include "Foreach.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
|
||||
static void GetDefaultModifiers( PlayerOptions &po, SongOptions &so )
|
||||
{
|
||||
@@ -281,13 +282,16 @@ MOVE( AllowExtraStage, PREFSMAN->m_bAllowExtraStage );
|
||||
MOVE( PickExtraStage, PREFSMAN->m_bPickExtraStage );
|
||||
MOVE( UnlockSystem, PREFSMAN->m_bUseUnlockSystem );
|
||||
|
||||
/* Coin options */
|
||||
MOVE( CoinMode, PREFSMAN->m_iCoinMode );
|
||||
static void CoinModeM( int &sel, bool ToSel, const ConfOption *pConfOption )
|
||||
{
|
||||
const CoinMode mapping[] = { COIN_HOME, COIN_PAY, COIN_FREE };
|
||||
MoveMap( sel, PREFSMAN->m_CoinMode, ToSel, mapping, ARRAYSIZE(mapping) );
|
||||
}
|
||||
|
||||
static void CoinModeNoHome( int &sel, bool ToSel, const ConfOption *pConfOption )
|
||||
{
|
||||
const int mapping[] = { 1,2 };
|
||||
MoveMap( sel, PREFSMAN->m_iCoinMode, ToSel, mapping, ARRAYSIZE(mapping) );
|
||||
const CoinMode mapping[] = { COIN_PAY, COIN_FREE };
|
||||
MoveMap( sel, PREFSMAN->m_CoinMode, ToSel, mapping, ARRAYSIZE(mapping) );
|
||||
}
|
||||
|
||||
static void CoinsPerCredit( int &sel, bool ToSel, const ConfOption *pConfOption )
|
||||
@@ -296,9 +300,9 @@ static void CoinsPerCredit( int &sel, bool ToSel, const ConfOption *pConfOption
|
||||
MoveMap( sel, PREFSMAN->m_iCoinsPerCredit, ToSel, mapping, ARRAYSIZE(mapping) );
|
||||
}
|
||||
|
||||
static void Premium( int &sel, bool ToSel, const ConfOption *pConfOption )
|
||||
static void PremiumM( int &sel, bool ToSel, const ConfOption *pConfOption )
|
||||
{
|
||||
const PrefsManager::Premium mapping[] = { PrefsManager::NO_PREMIUM,PrefsManager::DOUBLES_PREMIUM,PrefsManager::JOINT_PREMIUM };
|
||||
const Premium mapping[] = { PREMIUM_NONE, PREMIUM_DOUBLES, PREMIUM_JOINT };
|
||||
MoveMap( sel, PREFSMAN->m_Premium, ToSel, mapping, ARRAYSIZE(mapping) );
|
||||
}
|
||||
|
||||
@@ -520,7 +524,7 @@ static void InitializeConfOptions()
|
||||
|
||||
/* Machine options */
|
||||
ADD( ConfOption( "MenuTimer", MovePref, "OFF","ON" ) );
|
||||
ADD( ConfOption( "CoinMode", CoinMode, "HOME","PAY","FREE PLAY" ) );
|
||||
ADD( ConfOption( "CoinMode", CoinModeM, "HOME","PAY","FREE PLAY" ) );
|
||||
ADD( ConfOption( "CoinModeNoHome", CoinModeNoHome, "PAY","FREE PLAY" ) );
|
||||
ADD( ConfOption( "Songs Per\nPlay", SongsPerPlay, "1","2","3","4","5","6","7" ) );
|
||||
ADD( ConfOption( "Event\nMode", EventMode, "OFF","ON" ) );
|
||||
@@ -533,7 +537,7 @@ static void InitializeConfOptions()
|
||||
ADD( ConfOption( "Default\nFail Type", DefaultFailType, "IMMEDIATE","COMBO OF 30 MISSES","END OF SONG","OFF" ) );
|
||||
ADD( ConfOption( "DefaultFailTypeNoOff", DefaultFailType, "IMMEDIATE","COMBO OF 30 MISSES","END OF SONG" ) );
|
||||
ADD( ConfOption( "Coins Per\nCredit", CoinsPerCredit, "1","2","3","4","5","6","7","8" ) );
|
||||
ADD( ConfOption( "Premium", Premium, "OFF","DOUBLE FOR 1 CREDIT","JOINT PREMIUM" ) );
|
||||
ADD( ConfOption( "Premium", PremiumM, "OFF","DOUBLE FOR 1 CREDIT","JOINT PREMIUM" ) );
|
||||
ADD( ConfOption( "Show Song\nOptions", ShowSongOptions, "HIDE","SHOW","ASK" ) );
|
||||
ADD( ConfOption( "Show Name\nEntry", ShowNameEntry, "OFF", "ON", "RANKING SONGS" ) );
|
||||
|
||||
|
||||
@@ -478,14 +478,11 @@ bool ScreenSelectMaster::ChangeSelection( PlayerNumber pn, int iNewChoice )
|
||||
{
|
||||
const int iOldChoice = m_iChoice[p];
|
||||
|
||||
if( !bMoveAll && p!=pn )
|
||||
continue; // skip
|
||||
|
||||
/* Set the new m_iChoice even for disabled players, since a player might
|
||||
* join on a SHARED_PREVIEW_AND_CURSOR after the cursor has been moved. */
|
||||
m_iChoice[p] = iNewChoice;
|
||||
|
||||
if( !GAMESTATE->IsHumanPlayer(p) )
|
||||
if( p!=pn )
|
||||
continue; // skip
|
||||
|
||||
if( SHARED_PREVIEW_AND_CURSOR )
|
||||
|
||||
@@ -198,9 +198,9 @@ void ScreenSelectMode::UpdateSelectableChoices()
|
||||
(mc.m_pStyle == NULL) ?
|
||||
1 :
|
||||
1;
|
||||
if( PREFSMAN->GetPremium()!=PrefsManager::JOINT_PREMIUM ||
|
||||
if( PREFSMAN->GetPremium()!=PREMIUM_JOINT ||
|
||||
(
|
||||
(PREFSMAN->GetPremium()==PrefsManager::JOINT_PREMIUM) &&
|
||||
(PREFSMAN->GetPremium()==PREMIUM_JOINT) &&
|
||||
(
|
||||
(INCLUDE_DOUBLE_IN_JP == 1 && (GAMESTATE->GetNumSidesJoined() == SidesJoinedToPlay)) ||
|
||||
(
|
||||
|
||||
@@ -104,11 +104,11 @@ ScreenSelectStyle::ScreenSelectStyle( CString sClassName ) : ScreenSelect( sClas
|
||||
|
||||
switch( PREFSMAN->GetPremium() )
|
||||
{
|
||||
case PrefsManager::DOUBLES_PREMIUM:
|
||||
case PREMIUM_DOUBLES:
|
||||
m_sprPremium.Load( THEME->GetPathToG(m_sName + " doubles premium") );
|
||||
this->AddChild( &m_sprPremium );
|
||||
break;
|
||||
case PrefsManager::JOINT_PREMIUM:
|
||||
case PREMIUM_JOINT:
|
||||
m_sprPremium.Load( THEME->GetPathToG(m_sName + " joint premium") );
|
||||
this->AddChild( &m_sprPremium );
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user