clean up premium coin logic

This commit is contained in:
Chris Danford
2003-11-09 01:09:35 +00:00
parent c279fd03a4
commit 02679ea68b
13 changed files with 39 additions and 86 deletions
+2 -3
View File
@@ -2079,12 +2079,11 @@ TimerSeconds=0
PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster
NextScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster
OptionMenuFlags=rows,5;together;explanations OptionMenuFlags=rows,4;together;explanations
Line1=conf,CoinMode Line1=conf,CoinMode
Line2=conf,SongsPerPlay Line2=conf,SongsPerPlay
Line3=conf,CoinsPerCredit Line3=conf,CoinsPerCredit
Line4=conf,VersusPremium Line4=conf,Premium
Line5=conf,DoublePremium
[ScreenMachineOptions] [ScreenMachineOptions]
StyleIcon=0 StyleIcon=0
-7
View File
@@ -1012,10 +1012,3 @@ void GameState::StoreRankingName( PlayerNumber pn, CString name )
*aFeats[i].pStringToFill = name; *aFeats[i].pStringToFill = name;
} }
} }
bool GameState::UsingPremiumAndPaying()
{
return
(PREFSMAN->m_bVersusForOneCredit || PREFSMAN->m_bDoubleForOneCredit) &&
PREFSMAN->m_iCoinMode == COIN_PAY;
}
-1
View File
@@ -66,7 +66,6 @@ public:
iNumSidesJoined++; // left side, and right side iNumSidesJoined++; // left side, and right side
return iNumSidesJoined; return iNumSidesJoined;
}; };
bool UsingPremiumAndPaying();
GameDef* GetCurrentGameDef(); GameDef* GetCurrentGameDef();
const StyleDef* GetCurrentStyleDef(); const StyleDef* GetCurrentStyleDef();
+4 -38
View File
@@ -161,22 +161,6 @@ void ModeChoice::Load( int iIndex, CString sChoice )
} }
} }
int GetCreditsRequiredToPlayStyle( Style style )
{
switch( GAMEMAN->GetStyleDefForStyle(style)->m_StyleType )
{
case StyleDef::ONE_PLAYER_ONE_CREDIT:
return 1;
case StyleDef::TWO_PLAYERS_TWO_CREDITS:
return PREFSMAN->m_bVersusForOneCredit ? 1 : 2;
case StyleDef::ONE_PLAYER_TWO_CREDITS:
return PREFSMAN->m_bDoubleForOneCredit ? 1 : 2;
default:
ASSERT(0);
return 1;
}
}
int GetSidesRequiredToPlayStyle( Style style ) int GetSidesRequiredToPlayStyle( Style style )
{ {
switch( GAMEMAN->GetStyleDefForStyle(style)->m_StyleType ) switch( GAMEMAN->GetStyleDefForStyle(style)->m_StyleType )
@@ -184,8 +168,9 @@ int GetSidesRequiredToPlayStyle( Style style )
case StyleDef::ONE_PLAYER_ONE_CREDIT: case StyleDef::ONE_PLAYER_ONE_CREDIT:
return 1; return 1;
case StyleDef::TWO_PLAYERS_TWO_CREDITS: case StyleDef::TWO_PLAYERS_TWO_CREDITS:
case StyleDef::ONE_PLAYER_TWO_CREDITS:
return 2; return 2;
case StyleDef::ONE_PLAYER_TWO_CREDITS:
return (PREFSMAN->m_Premium == PrefsManager::DOUBLE_FOR_1CREDIT) ? 1 : 2;
default: default:
ASSERT(0); ASSERT(0);
return 1; return 1;
@@ -199,21 +184,11 @@ bool ModeChoice::IsPlayable( CString *why ) const
if ( m_style != STYLE_INVALID ) if ( m_style != STYLE_INVALID )
{ {
int iNumCreditsInserted = GAMESTATE->m_iCoins/PREFSMAN->m_iCoinsPerCredit;
int iNumCreditsRequired = GetCreditsRequiredToPlayStyle(m_style);
int iNumSidesJoined = GAMESTATE->GetNumSidesJoined(); int iNumSidesJoined = GAMESTATE->GetNumSidesJoined();
int iNumSidesRequired = GetSidesRequiredToPlayStyle(m_style); int iNumSidesRequired = GetSidesRequiredToPlayStyle(m_style);
if( GAMESTATE->UsingPremiumAndPaying() ) if( iNumSidesRequired != iNumSidesJoined )
{ return false;
if( iNumCreditsInserted < iNumCreditsRequired )
return false;
}
else
{
if( iNumSidesRequired != iNumSidesJoined )
return false;
}
} }
/* Don't allow a PlayMode that's incompatible with our current Style (if set), /* Don't allow a PlayMode that's incompatible with our current Style (if set),
@@ -297,15 +272,6 @@ void ModeChoice::Apply( PlayerNumber pn ) const
default: default:
ASSERT(0); ASSERT(0);
} }
// If using a premium setting, subtract coins only after choosing a style.
int iNumCoinsInserted = GAMESTATE->m_iCoins;
int iNumCoinsRequired = PREFSMAN->m_iCoinsPerCredit*GetCreditsRequiredToPlayStyle(m_style);
if( GAMESTATE->UsingPremiumAndPaying() )
{
ASSERT( iNumCoinsInserted >= iNumCoinsRequired );
GAMESTATE->m_iCoins -= iNumCoinsRequired;
}
} }
if( m_dc != DIFFICULTY_INVALID && pn != PLAYER_INVALID ) if( m_dc != DIFFICULTY_INVALID && pn != PLAYER_INVALID )
GAMESTATE->m_PreferredDifficulty[pn] = m_dc; GAMESTATE->m_PreferredDifficulty[pn] = m_dc;
+3 -6
View File
@@ -87,8 +87,7 @@ PrefsManager::PrefsManager()
m_iMarvelousTiming = 2; m_iMarvelousTiming = 2;
m_iCoinMode = COIN_HOME; m_iCoinMode = COIN_HOME;
m_iCoinsPerCredit = 1; m_iCoinsPerCredit = 1;
m_bVersusForOneCredit = false; m_Premium = NO_PREMIUM;
m_bDoubleForOneCredit = false;
m_iBoostAppPriority = -1; m_iBoostAppPriority = -1;
m_bAntiAliasing = false; m_bAntiAliasing = false;
m_ShowSongOptions = YES; m_ShowSongOptions = YES;
@@ -260,8 +259,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk()
ini.GetValue( "Options", "SoundResampleQuality", m_iSoundResampleQuality ); ini.GetValue( "Options", "SoundResampleQuality", m_iSoundResampleQuality );
ini.GetValue( "Options", "CoinMode", m_iCoinMode ); ini.GetValue( "Options", "CoinMode", m_iCoinMode );
ini.GetValue( "Options", "CoinsPerCredit", m_iCoinsPerCredit ); ini.GetValue( "Options", "CoinsPerCredit", m_iCoinsPerCredit );
ini.GetValue( "Options", "VersusForOneCredit", m_bVersusForOneCredit ); ini.GetValue( "Options", "Premium", (int&)m_Premium );
ini.GetValue( "Options", "DoubleForOneCredit", m_bDoubleForOneCredit );
ini.GetValue( "Options", "BoostAppPriority", m_iBoostAppPriority ); ini.GetValue( "Options", "BoostAppPriority", m_iBoostAppPriority );
ini.GetValue( "Options", "PickExtraStage", m_bPickExtraStage ); ini.GetValue( "Options", "PickExtraStage", m_bPickExtraStage );
ini.GetValue( "Options", "ComboContinuesBetweenSongs", m_bComboContinuesBetweenSongs ); ini.GetValue( "Options", "ComboContinuesBetweenSongs", m_bComboContinuesBetweenSongs );
@@ -400,8 +398,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
ini.SetValue( "Options", "SoundResampleQuality", m_iSoundResampleQuality ); ini.SetValue( "Options", "SoundResampleQuality", m_iSoundResampleQuality );
ini.SetValue( "Options", "CoinMode", m_iCoinMode ); ini.SetValue( "Options", "CoinMode", m_iCoinMode );
ini.SetValue( "Options", "CoinsPerCredit", m_iCoinsPerCredit ); ini.SetValue( "Options", "CoinsPerCredit", m_iCoinsPerCredit );
ini.SetValue( "Options", "VersusForOneCredit", m_bVersusForOneCredit ); ini.SetValue( "Options", "Premium", m_Premium );
ini.SetValue( "Options", "DoubleForOneCredit", m_bDoubleForOneCredit );
ini.SetValue( "Options", "BoostAppPriority", m_iBoostAppPriority ); ini.SetValue( "Options", "BoostAppPriority", m_iBoostAppPriority );
ini.SetValue( "Options", "PickExtraStage", m_bPickExtraStage ); ini.SetValue( "Options", "PickExtraStage", m_bPickExtraStage );
ini.SetValue( "Options", "ComboContinuesBetweenSongs", m_bComboContinuesBetweenSongs ); ini.SetValue( "Options", "ComboContinuesBetweenSongs", m_bComboContinuesBetweenSongs );
+2 -2
View File
@@ -72,8 +72,8 @@ public:
int m_iMarvelousTiming; int m_iMarvelousTiming;
int m_iCoinMode; int m_iCoinMode;
int m_iCoinsPerCredit; int m_iCoinsPerCredit;
bool m_bVersusForOneCredit; enum Premium { NO_PREMIUM, DOUBLE_FOR_1CREDIT, JOINT_PREMIUM };
bool m_bDoubleForOneCredit; Premium m_Premium;
bool m_bPickExtraStage; bool m_bPickExtraStage;
bool m_bComboContinuesBetweenSongs; bool m_bComboContinuesBetweenSongs;
float m_fLongVerSongSeconds; float m_fLongVerSongSeconds;
+3 -4
View File
@@ -189,10 +189,9 @@ bool Screen::JoinInput( const DeviceInput& DeviceI, const InputEventType type, c
if( PREFSMAN->m_iCoinMode == COIN_PAY ) if( PREFSMAN->m_iCoinMode == COIN_PAY )
iCoinsToCharge = PREFSMAN->m_iCoinsPerCredit; iCoinsToCharge = PREFSMAN->m_iCoinsPerCredit;
// If using premium, subtract credits only after choosing a style, // If joint premium don't take away a credit for the 2nd join.
// not when the players join. if( PREFSMAN->m_Premium == PrefsManager::JOINT_PREMIUM &&
bool bUsingPremium = PREFSMAN->m_bVersusForOneCredit || PREFSMAN->m_bDoubleForOneCredit; GAMESTATE->GetNumSidesJoined() == 1 )
if( bUsingPremium )
iCoinsToCharge = 0; iCoinsToCharge = 0;
if( GAMESTATE->m_iCoins < iCoinsToCharge ) if( GAMESTATE->m_iCoins < iCoinsToCharge )
+11 -6
View File
@@ -199,16 +199,21 @@ void ScreenSystemLayer::RefreshCreditsMessages()
Profile* pProfile = PROFILEMAN->GetProfile( (PlayerNumber)p ); Profile* pProfile = PROFILEMAN->GetProfile( (PlayerNumber)p );
if( pProfile ) if( pProfile )
sPlayerInfo = pProfile->m_sName; sPlayerInfo = pProfile->m_sName;
else if( GAMESTATE->m_bPlayersCanJoin ) else if( GAMESTATE->m_bIsOnSystemMenu ) // no mem card
sPlayerInfo = PLAYER_INFO_INSERT_CARD;
else if( GAMESTATE->m_bIsOnSystemMenu )
sPlayerInfo = ""; sPlayerInfo = "";
else else if( PREFSMAN->m_sMemoryCardDir[p]!="" )
sPlayerInfo = PLAYER_INFO_NO_CARD; {
if( GAMESTATE->m_bPlayersCanJoin )
sPlayerInfo = PLAYER_INFO_INSERT_CARD;
else
sPlayerInfo = PLAYER_INFO_NO_CARD;
}
} }
else if( GAMESTATE->m_bPlayersCanJoin ) else if( GAMESTATE->m_bPlayersCanJoin )
{ {
if( PREFSMAN->m_iCoinMode==COIN_PAY && GAMESTATE->m_iCoins<PREFSMAN->m_iCoinsPerCredit ) if( PREFSMAN->m_iCoinMode==COIN_PAY &&
PREFSMAN->m_Premium!=PrefsManager::JOINT_PREMIUM &&
GAMESTATE->m_iCoins<PREFSMAN->m_iCoinsPerCredit )
sPlayerInfo = PLAYER_INFO_INSERT_MORE; sPlayerInfo = PLAYER_INFO_INSERT_MORE;
else else
sPlayerInfo = PLAYER_INFO_PRESS_START; sPlayerInfo = PLAYER_INFO_PRESS_START;
+6 -4
View File
@@ -263,8 +263,11 @@ static void CoinsPerCredit( int &sel, bool ToSel, const CStringArray &choices )
MoveMap( sel, PREFSMAN->m_iCoinsPerCredit, ToSel, mapping, ARRAYSIZE(mapping) ); MoveMap( sel, PREFSMAN->m_iCoinsPerCredit, ToSel, mapping, ARRAYSIZE(mapping) );
} }
MOVE( VersusPremium, PREFSMAN->m_bVersusForOneCredit ); static void Premium( int &sel, bool ToSel, const CStringArray &choices )
MOVE( DoublePremium, PREFSMAN->m_bDoubleForOneCredit ); {
const PrefsManager::Premium mapping[] = { PrefsManager::NO_PREMIUM,PrefsManager::DOUBLE_FOR_1CREDIT,PrefsManager::JOINT_PREMIUM };
MoveMap( sel, PREFSMAN->m_Premium, ToSel, mapping, ARRAYSIZE(mapping) );
}
static void SongsPerPlay( int &sel, bool ToSel, const CStringArray &choices ) static void SongsPerPlay( int &sel, bool ToSel, const CStringArray &choices )
{ {
@@ -454,8 +457,7 @@ static const ConfOption g_ConfOptions[] =
ConfOption( "Progressive\nNonstop Lifebar",ProgressiveNonstopLifebar,"OFF","1","2","3","4","5","6","7","8","INSANITY"), ConfOption( "Progressive\nNonstop Lifebar",ProgressiveNonstopLifebar,"OFF","1","2","3","4","5","6","7","8","INSANITY"),
ConfOption( "Default\nFail Type", DefaultFailType, "ARCADE","END OF SONG","OFF" ), ConfOption( "Default\nFail Type", DefaultFailType, "ARCADE","END OF SONG","OFF" ),
ConfOption( "Coins Per\nCredit", CoinsPerCredit, "1","2","3","4","5","6","7","8" ), ConfOption( "Coins Per\nCredit", CoinsPerCredit, "1","2","3","4","5","6","7","8" ),
ConfOption( "Versus\nPremium", VersusPremium, "OFF (2 credits)","ON (1 credit)" ), ConfOption( "Premium", Premium, "OFF","DOUBLE FOR 1 CREDIT","JOINT PREMIUM" ),
ConfOption( "Double\nPremium", DoublePremium, "OFF (2 credits)","ON (1 credit)" ),
ConfOption( "Show Song\nOptions", ShowSongOptions, "HIDE","SHOW","ASK" ), ConfOption( "Show Song\nOptions", ShowSongOptions, "HIDE","SHOW","ASK" ),
ConfOption( "Show Name\nEntry", ShowNameEntry, "OFF", "ON", "RANKING SONGS" ), ConfOption( "Show Name\nEntry", ShowNameEntry, "OFF", "ON", "RANKING SONGS" ),
+3 -11
View File
@@ -93,18 +93,10 @@ void ScreenSelect::Input( const DeviceInput& DeviceI, const InputEventType type,
{ {
// LOG->Trace( "ScreenSelect::Input()" ); // LOG->Trace( "ScreenSelect::Input()" );
if( GAMESTATE->UsingPremiumAndPaying() ) if( Screen::JoinInput(DeviceI, type, GameI, MenuI, StyleI) )
{ {
if( MenuI.IsValid() && MenuI.button==MENU_BUTTON_COIN && GAMESTATE->m_iCoins==PREFSMAN->m_iCoinsPerCredit*2 ) this->UpdateSelectableChoices();
this->UpdateSelectableChoices(); return; // don't let the screen handle the MENU_START press
}
else
{
if( Screen::JoinInput(DeviceI, type, GameI, MenuI, StyleI) )
{
this->UpdateSelectableChoices();
return; // don't let the screen handle the MENU_START press
}
} }
if( m_Menu.IsTransitioning() ) if( m_Menu.IsTransitioning() )
+2 -2
View File
@@ -168,9 +168,9 @@ void ScreenSelectMode::UpdateSelectableChoices()
(mc.m_style == STYLE_INVALID) ? (mc.m_style == STYLE_INVALID) ?
1 : 1 :
1; 1;
if( !(PREFSMAN->m_bVersusForOneCredit||PREFSMAN->m_bDoubleForOneCredit ) || if( PREFSMAN->m_Premium!=PrefsManager::JOINT_PREMIUM ||
( (
(PREFSMAN->m_bVersusForOneCredit||PREFSMAN->m_bDoubleForOneCredit) && (PREFSMAN->m_Premium==PrefsManager::JOINT_PREMIUM) &&
( (
(INCLUDE_DOUBLE_IN_JP == 1 && (GAMESTATE->GetNumSidesJoined() == SidesJoinedToPlay)) || (INCLUDE_DOUBLE_IN_JP == 1 && (GAMESTATE->GetNumSidesJoined() == SidesJoinedToPlay)) ||
( (
+1 -1
View File
@@ -108,7 +108,7 @@ ScreenSelectStyle::ScreenSelectStyle( CString sClassName ) : ScreenSelect( sClas
m_sprJointPremium.SetName( "JointPremium" ); m_sprJointPremium.SetName( "JointPremium" );
if( GAMESTATE->UsingPremiumAndPaying() ) if( PREFSMAN->m_Premium==PrefsManager::JOINT_PREMIUM )
{ {
m_sprJointPremium.Load( THEME->GetPathToG(m_sName + " joint premium") ); m_sprJointPremium.Load( THEME->GetPathToG(m_sName + " joint premium") );
this->AddChild( &m_sprJointPremium ); this->AddChild( &m_sprJointPremium );
+2 -1
View File
@@ -62,6 +62,7 @@ ScreenTitleMenu::ScreenTitleMenu( CString sClassName ) : ScreenSelect( sClassNam
{ {
LOG->Trace( "ScreenTitleMenu::ScreenTitleMenu()" ); LOG->Trace( "ScreenTitleMenu::ScreenTitleMenu()" );
/* XXX We really need two common calls: 1, something run when exiting from gameplay /* XXX We really need two common calls: 1, something run when exiting from gameplay
* (to do this reset), and 2, something run when entering gameplay, to apply default * (to do this reset), and 2, something run when entering gameplay, to apply default
* options. Having special cases in attract screens and the title menu to reset * options. Having special cases in attract screens and the title menu to reset
@@ -71,7 +72,7 @@ ScreenTitleMenu::ScreenTitleMenu( CString sClassName ) : ScreenSelect( sClassNam
CodeDetector::RefreshCacheItems(); CodeDetector::RefreshCacheItems();
if( GAMESTATE->UsingPremiumAndPaying() ) if( PREFSMAN->m_Premium==PrefsManager::JOINT_PREMIUM )
{ {
m_JointPremium.LoadFromAniDir( THEME->GetPathToB("ScreenTitleMenu joint premium") ); m_JointPremium.LoadFromAniDir( THEME->GetPathToB("ScreenTitleMenu joint premium") );
this->AddChild( &m_JointPremium ); this->AddChild( &m_JointPremium );