Time to reopen this big 'ol bag of worms.

This commit is contained in:
Ben "root" Anderson
2014-02-02 12:53:26 -06:00
parent 5a761f8613
commit d654bd0142
7 changed files with 103 additions and 45 deletions
+1 -1
View File
@@ -3016,7 +3016,7 @@ Fallback="ScreenOptionsServiceChild"
NextScreen="ScreenOptionsService" NextScreen="ScreenOptionsService"
PrevScreen="ScreenOptionsService" PrevScreen="ScreenOptionsService"
# stuff tied to arcade features # stuff tied to arcade features
LineNames="1,2,3,6" LineNames="1,2,3,4,5,6"
Line1="conf,GetRankingName" Line1="conf,GetRankingName"
Line2="conf,CoinMode" Line2="conf,CoinMode"
Line3="conf,SongsPerPlay" Line3="conf,SongsPerPlay"
+19 -1
View File
@@ -493,7 +493,12 @@ bool GameCommand::IsPlayable( RString *why ) const
if ( m_pStyle ) if ( m_pStyle )
{ {
int iCredits = NUM_PLAYERS; int iCredits;
if( GAMESTATE->GetCoinMode() == CoinMode_Pay )
iCredits = GAMESTATE->m_iCoins / PREFSMAN->m_iCoinsPerCredit;
else
iCredits = NUM_PLAYERS;
const int iNumCreditsPaid = GetNumCreditsPaid(); const int iNumCreditsPaid = GetNumCreditsPaid();
const int iNumCreditsRequired = GetCreditsRequiredToPlayStyle(m_pStyle); const int iNumCreditsRequired = GetCreditsRequiredToPlayStyle(m_pStyle);
@@ -637,6 +642,19 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
{ {
GAMESTATE->SetCurrentStyle( m_pStyle ); GAMESTATE->SetCurrentStyle( m_pStyle );
// It's possible to choose a style that didn't have enough 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( GAMESTATE->GetCoinMode() == CoinMode_Pay )
{
int iNumCreditsRequired = GetCreditsRequiredToPlayStyle(m_pStyle);
int iNumCreditsPaid = GetNumCreditsPaid();
int iNumCreditsOwed = iNumCreditsRequired - iNumCreditsPaid;
GAMESTATE->m_iCoins.Set( GAMESTATE->m_iCoins - iNumCreditsOwed * PREFSMAN->m_iCoinsPerCredit );
LOG->Trace( "Deducted %i coins, %i remaining",
iNumCreditsOwed * PREFSMAN->m_iCoinsPerCredit, GAMESTATE->m_iCoins.Get() );
}
// If only one side is joined and we picked a style that requires both // If only one side is joined and we picked a style that requires both
// sides, join the other side. // sides, join the other side.
switch( m_pStyle->m_StyleType ) switch( m_pStyle->m_StyleType )
+21 -3
View File
@@ -361,6 +361,12 @@ void GameState::Reset()
void GameState::JoinPlayer( PlayerNumber pn ) void GameState::JoinPlayer( PlayerNumber pn )
{ {
/* If joint premium and we're not taking away a credit for the 2nd join,
* give the new player the same number of stage tokens that the old player
* has. */
if( GetCoinMode() == CoinMode_Pay && GetPremium() == Premium_2PlayersFor1Credit && GetNumSidesJoined() == 1 )
m_iPlayerStageTokens[pn] = m_iPlayerStageTokens[this->GetMasterPlayerNumber()];
else
m_iPlayerStageTokens[pn] = PREFSMAN->m_iSongsPerPlay; m_iPlayerStageTokens[pn] = PREFSMAN->m_iSongsPerPlay;
m_bSideIsJoined[pn] = true; m_bSideIsJoined[pn] = true;
@@ -483,7 +489,17 @@ bool GameState::JoinPlayers()
int GameState::GetCoinsNeededToJoin() const int GameState::GetCoinsNeededToJoin() const
{ {
return 0; int iCoinsToCharge = 0;
if( GetCoinMode() == CoinMode_Pay )
iCoinsToCharge = PREFSMAN->m_iCoinsPerCredit;
// If joint premium, don't take away a credit for the second join.
if( GetPremium() == Premium_2PlayersFor1Credit &&
GetNumSidesJoined() == 1 )
iCoinsToCharge = 0;
return iCoinsToCharge;
} }
/* Game flow: /* Game flow:
@@ -2039,9 +2055,11 @@ bool GameState::IsEventMode() const
CoinMode GameState::GetCoinMode() const CoinMode GameState::GetCoinMode() const
{ {
if( GamePreferences::m_CoinMode == CoinMode_Home ) // XXX: Event mode shouldn't be valid if CoinMode_Pay
return CoinMode_Home; if( IsEventMode() && GamePreferences::m_CoinMode == CoinMode_Pay )
return CoinMode_Free; return CoinMode_Free;
else
return GamePreferences::m_CoinMode;
} }
ThemeMetric<bool> DISABLE_PREMIUM_IN_EVENT_MODE("GameState","DisablePremiumInEventMode"); ThemeMetric<bool> DISABLE_PREMIUM_IN_EVENT_MODE("GameState","DisablePremiumInEventMode");
+6
View File
@@ -83,6 +83,12 @@ bool ScreenAttract::AttractInput( const InputEventPlus &input, ScreenWithMenuEle
// fall through // fall through
case GAME_BUTTON_START: case GAME_BUTTON_START:
case GAME_BUTTON_COIN: case GAME_BUTTON_COIN:
// If we're not in a game and there aren't enough credits to start,
// eat the input and do nothing.
if( GAMESTATE->GetCoinMode() == CoinMode_Pay &&
GAMESTATE->m_iCoins < PREFSMAN->m_iCoinsPerCredit &&
GAMESTATE->GetNumSidesJoined() == 0 )
return true;
if( pScreen->IsTransitioning() ) if( pScreen->IsTransitioning() )
return false; return false;
+19 -27
View File
@@ -383,43 +383,34 @@ static void MusicWheelSwitchSpeed( int &sel, bool ToSel, const ConfOption *pConf
MoveMap( sel, pConfOption, ToSel, mapping, ARRAYLEN(mapping) ); MoveMap( sel, pConfOption, ToSel, mapping, ARRAYLEN(mapping) );
} }
// Gameplay options static void CoinModeNoHome( int &sel, bool ToSel, const ConfOption *pConfOption )
static void CoinModeWithHome( int &sel, bool ToSel, const ConfOption *pConfOption )
{ {
// 0 = Pay, 1 = Free
// But MovePref<CoinMode> thinks 0 = Home, 1 = Pay, 2 = Free
if( ToSel ) if( ToSel )
{ {
// Two options: Home and Free
MovePref<CoinMode>( sel, ToSel, pConfOption ); MovePref<CoinMode>( sel, ToSel, pConfOption );
if( sel != 0 ) sel--;
sel = 1;
} }
else else
{ {
int tmp = static_cast<int>(CoinMode_Home); int tmp = sel + 1;
if( sel != 0 ) MovePref<CoinMode>( sel, ToSel, pConfOption );
{
sel = 1;
tmp = static_cast<int>(CoinMode_Free);
}
MovePref<CoinMode>( tmp , ToSel, pConfOption );
}
}
static void CoinModeNoHome( int &sel, bool ToSel, const ConfOption *pConfOption )
{
// We only have one play mode that isn't Home
sel = 0;
if( !ToSel )
{
int tmp = static_cast<int>(CoinMode_Free);
MovePref<CoinMode>( tmp, ToSel, pConfOption );
} }
} }
static void CoinsPerCredit( int &sel, bool ToSel, const ConfOption *pConfOption ) static void CoinsPerCredit( int &sel, bool ToSel, const ConfOption *pConfOption )
{ {
const int mapping[] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }; if( ToSel )
MoveMap( sel, pConfOption, ToSel, mapping, ARRAYLEN(mapping) ); {
MovePref<int>( sel, ToSel, pConfOption );
sel--;
}
else
{
int tmp = sel + 1;
MovePref<int>( tmp, ToSel, pConfOption );
}
} }
static void JointPremium( int &sel, bool ToSel, const ConfOption *pConfOption ) static void JointPremium( int &sel, bool ToSel, const ConfOption *pConfOption )
@@ -729,9 +720,10 @@ static void InitializeConfOptions()
// Machine options // Machine options
ADD( ConfOption( "MenuTimer", MovePref<bool>, "Off","On" ) ); ADD( ConfOption( "MenuTimer", MovePref<bool>, "Off","On" ) );
ADD( ConfOption( "CoinMode", CoinModeWithHome, "Home","Free Play" ) ); ADD( ConfOption( "CoinMode", MovePref<CoinMode>, "Home","Pay","Free Play" ) );
ADD( ConfOption( "CoinModeNoHome", CoinModeNoHome, "Free Play" ) ); ADD( ConfOption( "CoinModeNoHome", CoinModeNoHome, "Pay","Free Play" ) );
g_ConfOptions.back().m_sPrefName = "CoinMode"; g_ConfOptions.back().m_sPrefName = "CoinMode";
ADD( ConfOption( "CoinsPerCredit", CoinsPerCredit, "|1","|2","|3","|4","|5","|6","|7","|8","|9","|10","|11","|12","|13","|14","|15","|16" ) );
ADD( ConfOption( "SongsPerPlay", SongsPerPlay, "|1","|2","|3","|4","|5" ) ); ADD( ConfOption( "SongsPerPlay", SongsPerPlay, "|1","|2","|3","|4","|5" ) );
ADD( ConfOption( "SongsPerPlayOrEvent", SongsPerPlayOrEventMode,"|1","|2","|3","|4","|5","Event" ) ); ADD( ConfOption( "SongsPerPlayOrEvent", SongsPerPlayOrEventMode,"|1","|2","|3","|4","|5","Event" ) );
+21 -5
View File
@@ -97,15 +97,31 @@ namespace
} }
else // bShowCreditsMessage else // bShowCreditsMessage
{ {
if( GAMESTATE->PlayersCanJoin() ) switch( GAMESTATE->GetCoinMode() )
return CREDITS_NOT_PRESENT.GetValue(); {
case CoinMode_Home:
CoinMode mode = GAMESTATE->GetCoinMode();
if( mode == CoinMode_Home )
return CREDITS_PRESS_START.GetValue(); return CREDITS_PRESS_START.GetValue();
case CoinMode_Pay:
// GCC is picky and needs this to be bracketed
{
int iCredits = GAMESTATE->m_iCoins / PREFSMAN->m_iCoinsPerCredit;
int iCoins = GAMESTATE->m_iCoins % PREFSMAN->m_iCoinsPerCredit;
RString sCredits = CREDITS_CREDITS;
// todo: allow themers to change these strings -aj
if( iCredits > 0 || PREFSMAN->m_iCoinsPerCredit == 1 )
sCredits += ssprintf(" %d", iCredits);
if( PREFSMAN->m_iCoinsPerCredit > 1 )
sCredits += ssprintf(" %d/%d", iCoins, PREFSMAN->m_iCoinsPerCredit.Get() );
if( iCredits >= MAX_NUM_CREDITS )
sCredits += " " + CREDITS_MAX.GetValue();
return sCredits;
}
default: // CoinMode_Free
if( GAMESTATE->PlayersCanJoin() )
return CREDITS_FREE_PLAY.GetValue(); return CREDITS_FREE_PLAY.GetValue();
} }
} }
}
}; };
+8
View File
@@ -134,6 +134,14 @@ void ScreenWithMenuElements::BeginScreen()
/* Evaluate FirstUpdateCommand. */ /* Evaluate FirstUpdateCommand. */
this->PlayCommand( "FirstUpdate" ); this->PlayCommand( "FirstUpdate" );
/* If AutoJoin and a player is already joined, then try to join a player. (If no players
* are joined, they'll join on the first JoinInput.) */
if( GAMESTATE->GetCoinMode() == CoinMode_Pay && GAMESTATE->m_bAutoJoin.Get() )
{
if( GAMESTATE->GetNumSidesJoined() > 0 && GAMESTATE->JoinPlayers() )
SCREENMAN->PlayStartSound();
}
} }
void ScreenWithMenuElements::HandleScreenMessage( const ScreenMessage SM ) void ScreenWithMenuElements::HandleScreenMessage( const ScreenMessage SM )