add TemporaryEventMode flag to GameState

This commit is contained in:
Chris Danford
2005-02-21 17:29:49 +00:00
parent d7bcadccc7
commit a2915c038b
21 changed files with 85 additions and 64 deletions
+4 -4
View File
@@ -392,7 +392,7 @@ int GetNumCreditsPaid()
int iNumCreditsPaid = GAMESTATE->GetNumSidesJoined();
// players other than the first joined for free
if( PREFSMAN->GetPremium() == PREMIUM_JOINT )
if( GAMESTATE->GetPremium() == PREMIUM_JOINT )
iNumCreditsPaid = min( iNumCreditsPaid, 1 );
return iNumCreditsPaid;
@@ -401,7 +401,7 @@ int GetNumCreditsPaid()
int GetCreditsRequiredToPlayStyle( const Style *style )
{
if( PREFSMAN->GetPremium() == PREMIUM_JOINT )
if( GAMESTATE->GetPremium() == PREMIUM_JOINT )
return 1;
switch( style->m_StyleType )
@@ -411,7 +411,7 @@ int GetCreditsRequiredToPlayStyle( const Style *style )
case TWO_PLAYERS_TWO_SIDES:
return 2;
case ONE_PLAYER_TWO_SIDES:
return (PREFSMAN->GetPremium() == PREMIUM_DOUBLES) ? 1 : 2;
return (GAMESTATE->GetPremium() == PREMIUM_DOUBLES) ? 1 : 2;
default:
ASSERT(0);
return 1;
@@ -457,7 +457,7 @@ bool GameCommand::IsPlayable( CString *why ) const
const int iNumCreditsPaid = GetNumCreditsPaid();
const int iNumCreditsRequired = GetCreditsRequiredToPlayStyle(m_pStyle);
switch( PREFSMAN->GetCoinMode() )
switch( GAMESTATE->GetCoinMode() )
{
case COIN_HOME:
case COIN_FREE:
+44 -15
View File
@@ -204,6 +204,8 @@ void GameState::Reset()
m_iStopCourseAtSeconds = -1;
m_bTemporaryEventMode = false;
LIGHTSMAN->SetLightsMode( LIGHTSMODE_ATTRACT );
ApplyCmdline();
@@ -700,7 +702,7 @@ void GameState::FinishStage()
if( PREFSMAN->m_bEventMode )
if( GAMESTATE->GetEventMode() )
{
const int iSaveProfileEvery = 3;
if( iOldStageIndex/iSaveProfileEvery < m_iCurrentStageIndex/iSaveProfileEvery )
@@ -720,14 +722,14 @@ int GameState::GetNumStagesLeft() const
{
if( IsExtraStage() || IsExtraStage2() )
return 1;
if( PREFSMAN->m_bEventMode )
if( GAMESTATE->GetEventMode() )
return 999;
return PREFSMAN->m_iNumArcadeStages - m_iCurrentStageIndex;
}
bool GameState::IsFinalStage() const
{
if( PREFSMAN->m_bEventMode )
if( GAMESTATE->GetEventMode() )
return false;
if( this->IsCourseMode() )
@@ -742,14 +744,14 @@ bool GameState::IsFinalStage() const
bool GameState::IsExtraStage() const
{
if( PREFSMAN->m_bEventMode )
if( GAMESTATE->GetEventMode() )
return false;
return m_iCurrentStageIndex == PREFSMAN->m_iNumArcadeStages;
}
bool GameState::IsExtraStage2() const
{
if( PREFSMAN->m_bEventMode )
if( GAMESTATE->GetEventMode() )
return false;
return m_iCurrentStageIndex == PREFSMAN->m_iNumArcadeStages+1;
}
@@ -760,7 +762,7 @@ CString GameState::GetStageText() const
else if( m_PlayMode == PLAY_MODE_ONI ) return "oni";
else if( m_PlayMode == PLAY_MODE_NONSTOP ) return "nonstop";
else if( m_PlayMode == PLAY_MODE_ENDLESS ) return "endless";
else if( PREFSMAN->m_bEventMode ) return "event";
else if( GAMESTATE->GetEventMode() ) return "event";
else if( IsFinalStage() ) return "final";
else if( IsExtraStage() ) return "extra1";
else if( IsExtraStage2() ) return "extra2";
@@ -815,7 +817,7 @@ bool GameState::PlayersCanJoin() const
bool GameState::EnoughCreditsToJoin() const
{
switch( PREFSMAN->GetCoinMode() )
switch( GAMESTATE->GetCoinMode() )
{
case COIN_PAY:
return GAMESTATE->m_iCoins >= PREFSMAN->m_iCoinsPerCredit;
@@ -962,7 +964,7 @@ bool GameState::IsBattleMode() const
bool GameState::HasEarnedExtraStage() const
{
if( PREFSMAN->m_bEventMode )
if( GAMESTATE->GetEventMode() )
return false;
if( !PREFSMAN->m_bAllowExtraStage )
@@ -1302,7 +1304,7 @@ void GameState::AdjustFailType()
/* If beginner's steps were chosen, and this is the first stage,
* turn off failure completely--always give a second try. */
if(dc == DIFFICULTY_BEGINNER &&
!PREFSMAN->m_bEventMode && /* stage index is meaningless in event mode */
GAMESTATE->GetEventMode() && /* stage index is meaningless in event mode */
this->m_iCurrentStageIndex == 0)
setmax(this->m_SongOptions.m_FailType, SongOptions::FAIL_OFF);
}
@@ -1826,14 +1828,25 @@ Difficulty GameState::GetEasiestNotesDifficulty() const
return dc;
}
bool PlayerIsUsingModifier( PlayerNumber pn, const CString sModifier )
bool GameState::GetEventMode()
{
PlayerOptions po = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions;
SongOptions so = GAMESTATE->m_SongOptions;
po.FromString( sModifier );
so.FromString( sModifier );
return m_bTemporaryEventMode || PREFSMAN->m_bEventMode;
}
return po == GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions && so == GAMESTATE->m_SongOptions;
CoinMode GameState::GetCoinMode()
{
if( GetEventMode() && PREFSMAN->m_CoinMode == COIN_PAY )
return COIN_FREE;
else
return PREFSMAN->m_CoinMode;
}
Premium GameState::GetPremium()
{
if( GetEventMode() )
return PREMIUM_NONE;
else
return PREFSMAN->m_Premium;
}
@@ -1860,6 +1873,9 @@ public:
p->ApplyGameCommand(SArg(1),pn);
return 0;
}
static int GetCurrentCourse( T* p, lua_State *L ) { if(p->m_pCurCourse) p->m_pCurCourse->PushSelf(L); else lua_pushnil(L); return 1; }
static int SetCurrentCourse( T* p, lua_State *L ) { Course *pC = Luna<Course>::check(L,1); p->m_pCurCourse = pC; return 0; }
static int SetTemporaryEventMode( T* p, lua_State *L ) { p->m_bTemporaryEventMode = BArg(1); return 0; }
static void Register(lua_State *L)
{
@@ -1868,6 +1884,9 @@ public:
ADD_METHOD( GetPlayerDisplayName )
ADD_METHOD( GetMasterPlayerNumber )
ADD_METHOD( ApplyGameCommand )
ADD_METHOD( GetCurrentCourse )
ADD_METHOD( SetCurrentCourse )
ADD_METHOD( SetTemporaryEventMode )
Luna<T>::Register( L );
// add global singleton
@@ -1912,6 +1931,16 @@ LuaFunction_StrStr( SetEnv, GAMESTATE->m_mapEnv[str1] = str2 )
LuaFunction_NoArgs( CurSong, GAMESTATE->m_pCurSong )
LuaFunction_PlayerNumber( CurSteps, GAMESTATE->m_pCurSteps[pn] )
bool PlayerIsUsingModifier( PlayerNumber pn, const CString sModifier )
{
PlayerOptions po = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions;
SongOptions so = GAMESTATE->m_SongOptions;
po.FromString( sModifier );
so.FromString( sModifier );
return po == GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions && so == GAMESTATE->m_SongOptions;
}
int LuaFunc_UsingModifier( lua_State *L )
{
REQ_ARGS( "UsingModifier", 2 );
+11
View File
@@ -271,6 +271,17 @@ public:
//
int m_iStopCourseAtSeconds; // -1 == don't stop early
//
// Preference wrappers
//
// These options have weird interactions depending on m_bEventMode,
// so wrap them
bool m_bTemporaryEventMode;
bool GetEventMode();
CoinMode GetCoinMode();
Premium GetPremium();
// Lua
void PushSelf( lua_State *L );
};
+1 -1
View File
@@ -540,7 +540,7 @@ void LifeMeterBar::UpdateNonstopLifebar(const int cleared,
// it isn't, do so here
/* No, wait: if we're playing nonstop, event mode just means that we can play another
* nonstop course later, so it shouldn't affect life difficulty. */
/* if (PREFSMAN->m_bEventMode)
/* if (GAMESTATE->GetEventMode())
{
m_fLifeDifficulty = m_fBaseLifeDifficulty;
return;
+1 -1
View File
@@ -66,7 +66,7 @@ public:
lua_settable(L, metatable);
// fill method table with methods from class T
for (unsigned i=0; i<s_pvMethods->size(); i++ )
for (unsigned i=0; s_pvMethods && i<s_pvMethods->size(); i++ )
{
const MyRegType *l = &(*s_pvMethods)[i];
lua_pushstring(L, l->name);
+2 -2
View File
@@ -232,7 +232,7 @@ void MusicWheel::Load()
// but someone mentioned it does it sometimes.
if( GAMESTATE->m_pCurSong != NULL &&
SongManager::GetNumStagesForSong( GAMESTATE->m_pCurSong ) + GAMESTATE->m_iCurrentStageIndex > PREFSMAN->m_iNumArcadeStages
&& !PREFSMAN->m_bEventMode
&& !GAMESTATE->GetEventMode()
&& !GAMESTATE->IsExtraStage() && !GAMESTATE->IsExtraStage2() )
{
GAMESTATE->m_pCurSong = NULL;
@@ -477,7 +477,7 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
case SORT_ONI_COURSES:
case SORT_ENDLESS_COURSES:
/* Don't display course modes after the first stage. */
if( !PREFSMAN->m_bEventMode && GAMESTATE->m_iCurrentStageIndex )
if( !GAMESTATE->GetEventMode() && GAMESTATE->m_iCurrentStageIndex )
continue;
}
+2 -21
View File
@@ -837,13 +837,11 @@ class LunaPrefsManager : public Luna<T>
public:
LunaPrefsManager() { LUA->Register( Register ); }
static int GetEventMode( T* p, lua_State *L ) { lua_pushboolean(L, p->m_bEventMode ); return 1; }
static int SetEventMode( T* p, lua_State *L ) { p->m_bEventMode = BArg(1); return 0; }
// static int GetEventMode( T* p, lua_State *L ) { lua_pushboolean(L, p->m_bEventMode ); return 1; }
static void Register(lua_State *L)
{
ADD_METHOD( GetEventMode )
ADD_METHOD( SetEventMode )
// ADD_METHOD( GetEventMode )
Luna<T>::Register( L );
// Add global singleton if constructed already. If it's not constructed yet,
@@ -862,23 +860,6 @@ LUA_REGISTER_CLASS( PrefsManager )
// lua end
CoinMode PrefsManager::GetCoinMode()
{
if( m_bEventMode && m_CoinMode == COIN_PAY )
return COIN_FREE;
else
return m_CoinMode;
}
Premium PrefsManager::GetPremium()
{
if(m_bEventMode)
return PREMIUM_NONE;
else
return m_Premium;
}
#include "RageLog.h"
#include "LuaFunctions.h"
-2
View File
@@ -149,8 +149,6 @@ public:
// so wrap them.
CoinMode m_CoinMode;
Premium m_Premium;
CoinMode GetCoinMode();
Premium GetPremium();
bool m_bDelayedCreditsReconcile;
bool m_bPickExtraStage;
+2 -2
View File
@@ -384,7 +384,7 @@ void ProfileManager::AddStepsScore( const Song* pSong, const Steps* pSteps, Play
// In event mode, set the score's name immediately to the Profile's last
// used name. If no profile last used name exists, use "EVNT".
if( PREFSMAN->m_bEventMode )
if( GAMESTATE->GetEventMode() )
{
Profile* pProfile = PROFILEMAN->GetProfile(pn);
if( pProfile && !pProfile->m_sLastUsedHighScoreName.empty() )
@@ -453,7 +453,7 @@ void ProfileManager::AddCourseScore( const Course* pCourse, const Trail* pTrail,
// In event mode, set the score's name immediately to the Profile's last
// used name. If no profile last used name exists, use "EVNT".
if( PREFSMAN->m_bEventMode )
if( GAMESTATE->GetEventMode() )
{
Profile* pProfile = PROFILEMAN->GetProfile(pn);
if( pProfile && !pProfile->m_sLastUsedHighScoreName.empty() )
+2 -2
View File
@@ -193,11 +193,11 @@ bool Screen::JoinInput( const MenuInput &MenuI )
/* subtract coins */
int iCoinsToCharge = 0;
if( PREFSMAN->GetCoinMode() == COIN_PAY )
if( GAMESTATE->GetCoinMode() == COIN_PAY )
iCoinsToCharge = PREFSMAN->m_iCoinsPerCredit;
// If joint premium don't take away a credit for the 2nd join.
if( PREFSMAN->GetPremium() == PREMIUM_JOINT &&
if( GAMESTATE->GetPremium() == PREMIUM_JOINT &&
GAMESTATE->GetNumSidesJoined() == 1 )
iCoinsToCharge = 0;
+1 -1
View File
@@ -75,7 +75,7 @@ void ScreenAttract::AttractInput( const DeviceInput& DeviceI, const InputEventTy
case MENU_BUTTON_START:
case MENU_BUTTON_BACK:
case MENU_BUTTON_COIN:
switch( PREFSMAN->GetCoinMode() )
switch( GAMESTATE->GetCoinMode() )
{
case COIN_PAY:
LOG->Trace("ScreenAttract::AttractInput: COIN_PAY (%i/%i)", GAMESTATE->m_iCoins, PREFSMAN->m_iCoinsPerCredit );
+4 -2
View File
@@ -1375,8 +1375,10 @@ void ScreenEvaluation::HandleScreenMessage( const ScreenMessage SM )
break;
case SM_GoToNextScreen:
{
if( PREFSMAN->m_bEventMode )
if( GAMESTATE->GetEventMode() )
{
SCREENMAN->SetNewScreen( NEXT_SCREEN );
}
else
{
/* Go to FAILED_SCREEN if we failed a non-extra stage. */
@@ -1457,7 +1459,7 @@ void ScreenEvaluation::EndScreen()
FOREACH_PlayerNumber( p )
m_Grades[p].SettleImmediately();
if( !PREFSMAN->m_bEventMode )
if( !GAMESTATE->GetEventMode() )
{
switch( m_Type )
{
+1 -1
View File
@@ -951,7 +951,7 @@ void ScreenGameplay::LoadNextSong()
if( GAMESTATE->m_SongOptions.m_LifeType==SongOptions::LIFE_BATTERY && STATSMAN->m_CurStageStats.m_player[p].bFailed ) // already failed
ShowOniGameOver(p);
if( GAMESTATE->m_SongOptions.m_LifeType==SongOptions::LIFE_BAR && GAMESTATE->m_PlayMode == PLAY_MODE_REGULAR && !PREFSMAN->m_bEventMode && !GAMESTATE->m_bDemonstrationOrJukebox)
if( GAMESTATE->m_SongOptions.m_LifeType==SongOptions::LIFE_BAR && GAMESTATE->m_PlayMode == PLAY_MODE_REGULAR && !GAMESTATE->GetEventMode() && !GAMESTATE->m_bDemonstrationOrJukebox)
{
m_pLifeMeter[p]->UpdateNonstopLifebar(
GAMESTATE->GetStageIndex(),
+1 -1
View File
@@ -386,7 +386,7 @@ void ScreenNameEntry::HandleScreenMessage( const ScreenMessage SM )
// There shouldn't be NameEntry in event mode. -Chris
// /* Hack: go back to the select course screen in event mode. */
// if( PREFSMAN->m_bEventMode && GAMESTATE->IsCourseMode() )
// if( GAMESTATE->GetEventMode() && GAMESTATE->IsCourseMode() )
// {
// SCREENMAN->SetNewScreen( "ScreenSelectCourse" );
// break;
+1 -1
View File
@@ -110,7 +110,7 @@ void ScreenSelect::Update( float fDelta )
}
// don't time out on this screen is coin mode is pay.
// If we're here, then there's a credit in the machine.
if( PREFSMAN->GetCoinMode() != COIN_PAY )
if( GAMESTATE->GetCoinMode() != COIN_PAY )
{
if( IDLE_TIMEOUT_SECONDS > 0 && m_timerIdleTimeout.PeekDeltaTime() >= IDLE_TIMEOUT_SECONDS )
{
+2 -2
View File
@@ -197,9 +197,9 @@ void ScreenSelectMode::UpdateSelectableChoices()
(mc.m_pStyle == NULL) ?
1 :
1;
if( PREFSMAN->GetPremium()!=PREMIUM_JOINT ||
if( GAMESTATE->GetPremium()!=PREMIUM_JOINT ||
(
(PREFSMAN->GetPremium()==PREMIUM_JOINT) &&
(GAMESTATE->GetPremium()==PREMIUM_JOINT) &&
(
(INCLUDE_DOUBLE_IN_JP == 1 && (GAMESTATE->GetNumSidesJoined() == SidesJoinedToPlay)) ||
(
+1 -1
View File
@@ -1098,7 +1098,7 @@ void ScreenSelectMusic::MenuStart( PlayerNumber pn )
/* See if this song is a repeat. If we're in event mode, only check the last five songs. */
bool bIsRepeat = false;
int i = 0;
if( PREFSMAN->m_bEventMode )
if( GAMESTATE->GetEventMode() )
i = max( 0, int(STATSMAN->m_vPlayedStageStats.size())-5 );
for( ; i < (int)STATSMAN->m_vPlayedStageStats.size(); ++i )
if( STATSMAN->m_vPlayedStageStats[i].vpSongs.back() == m_MusicWheel.GetSelectedSong() )
+1 -1
View File
@@ -100,7 +100,7 @@ ScreenSelectStyle::ScreenSelectStyle( CString sClassName ) : ScreenSelect( sClas
m_sprPremium.SetName( "Premium" );
switch( PREFSMAN->GetPremium() )
switch( GAMESTATE->GetPremium() )
{
case PREMIUM_DOUBLES:
m_sprPremium.Load( THEME->GetPathG(m_sName,"doubles premium") );
+1 -1
View File
@@ -183,7 +183,7 @@ void ScreenSystemLayer::RefreshCreditsMessages()
}
else // bShowCreditsMessage
{
switch( PREFSMAN->GetCoinMode() )
switch( GAMESTATE->GetCoinMode() )
{
case COIN_HOME:
if( GAMESTATE->PlayersCanJoin() )
+2 -2
View File
@@ -37,7 +37,7 @@ ScreenTitleMenu::ScreenTitleMenu( CString sScreenName ) :
// Don't show screen title menu (says "Press Start")
// if there are 0 credits and inserted and CoinMode is pay.
if( PREFSMAN->GetCoinMode() == COIN_PAY &&
if( GAMESTATE->GetCoinMode() == COIN_PAY &&
GAMESTATE->m_iCoins < PREFSMAN->m_iCoinsPerCredit )
{
SCREENMAN->SetNewScreen( INITIAL_SCREEN );
@@ -78,7 +78,7 @@ ScreenTitleMenu::ScreenTitleMenu( CString sScreenName ) :
m_textMaxStages.LoadFromFont( THEME->GetPathF(m_sName,"MaxStages") );
m_textMaxStages.SetName( "MaxStages" );
CString sText =
PREFSMAN->m_bEventMode ?
GAMESTATE->GetEventMode() ?
CString("event mode") :
ssprintf( "%d %s%s max", PREFSMAN->m_iNumArcadeStages, MAX_STAGES_TEXT.c_str(), (PREFSMAN->m_iNumArcadeStages>1)?"s":"" );
m_textMaxStages.SetText( sText );
+1 -1
View File
@@ -1436,7 +1436,7 @@ static void HandleInputEvents(float fDeltaTime)
continue; // skip
// check back in event mode
if( PREFSMAN->m_bEventMode &&
if( GAMESTATE->GetEventMode() &&
CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_BACK_IN_EVENT_MODE) )
{
MenuI.player = PLAYER_1;