2004-11-25 19:16:46 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "ScreenSystemLayer.h"
|
2005-07-20 09:48:19 +00:00
|
|
|
#include "ScreenManager.h"
|
2004-11-25 19:16:46 +00:00
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "ActorUtil.h"
|
|
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "MemoryCardManager.h"
|
|
|
|
|
#include "Profile.h"
|
|
|
|
|
#include "ProfileManager.h"
|
|
|
|
|
#include "RageDisplay.h"
|
|
|
|
|
#include "RageLog.h"
|
2005-01-26 11:21:43 +00:00
|
|
|
#include "Command.h"
|
2005-08-18 02:28:54 +00:00
|
|
|
#include "ScreenDimensions.h"
|
2004-11-25 19:16:46 +00:00
|
|
|
|
|
|
|
|
|
2006-01-15 20:46:15 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenSystemLayer );
|
2006-01-15 20:34:52 +00:00
|
|
|
void ScreenSystemLayer::Init()
|
2004-11-25 19:16:46 +00:00
|
|
|
{
|
2005-06-15 10:30:58 +00:00
|
|
|
SubscribeToMessage( "RefreshCreditText" );
|
|
|
|
|
SubscribeToMessage( "SystemMessage" );
|
|
|
|
|
SubscribeToMessage( "SystemMessageNoAnimate" );
|
|
|
|
|
SubscribeToMessage( "HideSystemMessage" );
|
2006-01-15 19:48:11 +00:00
|
|
|
|
2005-06-04 03:04:29 +00:00
|
|
|
CREDITS_PRESS_START .Load(m_sName,"CreditsPressStart");
|
|
|
|
|
CREDITS_INSERT_CARD .Load(m_sName,"CreditsInsertCard");
|
2006-01-15 19:48:11 +00:00
|
|
|
CREDITS_CARD_TOO_LATE .Load(m_sName,"CreditsCardTooLate");
|
|
|
|
|
CREDITS_CARD_NO_NAME .Load(m_sName,"CreditsCardNoName");
|
2005-06-04 03:04:29 +00:00
|
|
|
CREDITS_CARD_READY .Load(m_sName,"CreditsCardReady");
|
2006-01-15 19:48:11 +00:00
|
|
|
CREDITS_CARD_CHECKING .Load(m_sName,"CreditsCardChecking");
|
|
|
|
|
CREDITS_CARD_REMOVED .Load(m_sName,"CreditsCardRemoved");
|
2005-06-04 03:04:29 +00:00
|
|
|
CREDITS_FREE_PLAY .Load(m_sName,"CreditsFreePlay");
|
|
|
|
|
CREDITS_CREDITS .Load(m_sName,"CreditsCredits");
|
|
|
|
|
CREDITS_NOT_PRESENT .Load(m_sName,"CreditsNotPresent");
|
|
|
|
|
CREDITS_LOAD_FAILED .Load(m_sName,"CreditsLoadFailed");
|
|
|
|
|
CREDITS_LOADED_FROM_LAST_GOOD_APPEND.Load(m_sName,"CreditsLoadedFromLastGoodAppend");
|
|
|
|
|
CREDITS_JOIN_ONLY .Load( m_sName, "CreditsJoinOnly" );
|
2005-02-28 05:01:50 +00:00
|
|
|
|
2005-02-23 06:29:05 +00:00
|
|
|
Screen::Init();
|
|
|
|
|
|
2004-11-25 19:16:46 +00:00
|
|
|
this->AddChild(&m_textMessage);
|
|
|
|
|
FOREACH_PlayerNumber( p )
|
|
|
|
|
this->AddChild(&m_textCredits[p]);
|
|
|
|
|
|
|
|
|
|
ReloadCreditsText();
|
|
|
|
|
/* This will be done when we set up the first screen, after GAMESTATE->Reset has
|
|
|
|
|
* been called. */
|
|
|
|
|
// RefreshCreditsMessages();
|
2006-03-22 23:00:58 +00:00
|
|
|
|
|
|
|
|
m_sprOverlay.Load( THEME->GetPathB("ScreenSystemLayer", "overlay") );
|
|
|
|
|
this->AddChild( m_sprOverlay );
|
2004-11-25 19:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSystemLayer::ReloadCreditsText()
|
|
|
|
|
{
|
2005-06-04 03:04:29 +00:00
|
|
|
if( m_sprMessageFrame.IsLoaded() )
|
|
|
|
|
this->RemoveChild( m_sprMessageFrame );
|
|
|
|
|
m_sprMessageFrame.Load( THEME->GetPathG(m_sName,"MessageFrame") );
|
|
|
|
|
this->AddChild( m_sprMessageFrame );
|
|
|
|
|
m_sprMessageFrame->SetName( "MessageFrame" );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_sprMessageFrame );
|
|
|
|
|
m_sprMessageFrame->SetHidden( true );
|
|
|
|
|
|
|
|
|
|
m_textMessage.LoadFromFont( THEME->GetPathF(m_sName,"message") );
|
2004-11-25 19:16:46 +00:00
|
|
|
m_textMessage.SetName( "Message" );
|
2005-05-09 09:49:13 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( m_textMessage );
|
|
|
|
|
m_textMessage.SetHidden( true );
|
2004-11-25 19:16:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
FOREACH_PlayerNumber( p )
|
|
|
|
|
{
|
2005-02-06 03:32:53 +00:00
|
|
|
m_textCredits[p].LoadFromFont( THEME->GetPathF("ScreenManager","credits") );
|
2004-11-25 19:16:46 +00:00
|
|
|
m_textCredits[p].SetName( ssprintf("CreditsP%d",p+1) );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( &m_textCredits[p] );
|
|
|
|
|
}
|
2005-06-04 03:04:29 +00:00
|
|
|
|
|
|
|
|
this->SortByDrawOrder();
|
2004-11-25 19:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString ScreenSystemLayer::GetCreditsMessage( PlayerNumber pn ) const
|
2004-11-25 19:16:46 +00:00
|
|
|
{
|
2005-03-01 18:45:04 +00:00
|
|
|
if( (bool)CREDITS_JOIN_ONLY && !GAMESTATE->PlayersCanJoin() )
|
2006-01-22 01:00:06 +00:00
|
|
|
return RString();
|
2005-02-26 07:20:38 +00:00
|
|
|
|
|
|
|
|
bool bShowCreditsMessage;
|
2005-05-19 23:29:39 +00:00
|
|
|
if( SCREENMAN && SCREENMAN->GetTopScreen() && SCREENMAN->GetTopScreen()->GetScreenType() == system_menu )
|
2005-02-26 07:20:38 +00:00
|
|
|
bShowCreditsMessage = true;
|
|
|
|
|
else if( MEMCARDMAN->GetCardsLocked() )
|
|
|
|
|
bShowCreditsMessage = !GAMESTATE->IsPlayerEnabled( pn );
|
|
|
|
|
else
|
|
|
|
|
bShowCreditsMessage = !GAMESTATE->m_bSideIsJoined[pn];
|
2004-11-25 19:16:46 +00:00
|
|
|
|
2005-02-26 07:20:38 +00:00
|
|
|
if( !bShowCreditsMessage )
|
|
|
|
|
{
|
|
|
|
|
MemoryCardState mcs = MEMCARDMAN->GetCardState( pn );
|
|
|
|
|
const Profile* pProfile = PROFILEMAN->GetProfile( pn );
|
|
|
|
|
switch( mcs )
|
2004-11-25 19:16:46 +00:00
|
|
|
{
|
2005-12-01 03:20:25 +00:00
|
|
|
case MemoryCardState_NoCard:
|
2005-02-26 07:20:38 +00:00
|
|
|
// this is a local machine profile
|
2005-05-01 06:42:30 +00:00
|
|
|
if( PROFILEMAN->LastLoadWasFromLastGood(pn) )
|
2005-07-13 18:49:49 +00:00
|
|
|
return pProfile->GetDisplayNameOrHighScoreName() + CREDITS_LOADED_FROM_LAST_GOOD_APPEND.GetValue();
|
2005-02-26 07:20:38 +00:00
|
|
|
else if( PROFILEMAN->LastLoadWasTamperedOrCorrupt(pn) )
|
2005-03-01 15:18:25 +00:00
|
|
|
return CREDITS_LOAD_FAILED.GetValue();
|
2005-02-26 07:20:38 +00:00
|
|
|
// Prefer the name of the profile over the name of the card.
|
2005-05-09 08:44:01 +00:00
|
|
|
else if( PROFILEMAN->IsPersistentProfile(pn) )
|
2005-07-13 18:49:49 +00:00
|
|
|
return pProfile->GetDisplayNameOrHighScoreName();
|
2005-02-26 07:20:38 +00:00
|
|
|
else if( GAMESTATE->PlayersCanJoin() )
|
2005-03-01 15:18:25 +00:00
|
|
|
return CREDITS_INSERT_CARD.GetValue();
|
2005-02-26 07:20:38 +00:00
|
|
|
else
|
2006-01-22 01:00:06 +00:00
|
|
|
return RString();
|
2005-02-26 07:20:38 +00:00
|
|
|
|
2005-12-01 03:20:25 +00:00
|
|
|
case MemoryCardState_Error: return THEME->GetMetric( m_sName, "CreditsCard" + MEMCARDMAN->GetCardError(pn) );
|
|
|
|
|
case MemoryCardState_TooLate: return CREDITS_CARD_TOO_LATE.GetValue();
|
|
|
|
|
case MemoryCardState_Checking: return CREDITS_CARD_CHECKING.GetValue();
|
|
|
|
|
case MemoryCardState_Removed: return CREDITS_CARD_REMOVED.GetValue();
|
|
|
|
|
case MemoryCardState_Ready:
|
2005-03-26 22:18:28 +00:00
|
|
|
{
|
|
|
|
|
// If the profile failed to load and there was no usable backup...
|
|
|
|
|
if( PROFILEMAN->LastLoadWasTamperedOrCorrupt(pn) && !PROFILEMAN->LastLoadWasFromLastGood(pn) )
|
|
|
|
|
return CREDITS_LOAD_FAILED.GetValue();
|
|
|
|
|
|
|
|
|
|
// If there is a local profile loaded, prefer it over the name of the memory card.
|
2005-05-09 08:44:01 +00:00
|
|
|
if( PROFILEMAN->IsPersistentProfile(pn) )
|
2005-03-26 22:18:28 +00:00
|
|
|
{
|
2006-01-22 01:00:06 +00:00
|
|
|
RString s = pProfile->GetDisplayNameOrHighScoreName();
|
2005-03-26 22:18:28 +00:00
|
|
|
if( s.empty() )
|
|
|
|
|
s = CREDITS_CARD_NO_NAME.GetValue();
|
|
|
|
|
if( PROFILEMAN->LastLoadWasFromLastGood(pn) )
|
|
|
|
|
s += CREDITS_LOADED_FROM_LAST_GOOD_APPEND.GetValue();
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
else if( !MEMCARDMAN->IsNameAvailable(pn) )
|
|
|
|
|
return CREDITS_CARD_READY.GetValue();
|
|
|
|
|
else if( !MEMCARDMAN->GetName(pn).empty() )
|
|
|
|
|
return MEMCARDMAN->GetName(pn);
|
|
|
|
|
else
|
|
|
|
|
return CREDITS_CARD_NO_NAME.GetValue();
|
|
|
|
|
}
|
2005-02-26 07:20:38 +00:00
|
|
|
default:
|
|
|
|
|
FAIL_M( ssprintf("%i",mcs) );
|
2004-11-25 19:16:46 +00:00
|
|
|
}
|
2005-02-26 07:20:38 +00:00
|
|
|
}
|
|
|
|
|
else // bShowCreditsMessage
|
|
|
|
|
{
|
|
|
|
|
switch( GAMESTATE->GetCoinMode() )
|
2004-11-25 19:16:46 +00:00
|
|
|
{
|
2005-05-20 17:45:44 +00:00
|
|
|
case COIN_MODE_HOME:
|
2005-02-26 07:20:38 +00:00
|
|
|
if( GAMESTATE->PlayersCanJoin() )
|
2005-03-01 15:18:25 +00:00
|
|
|
return CREDITS_PRESS_START.GetValue();
|
2005-02-26 07:20:38 +00:00
|
|
|
else
|
2005-03-01 15:18:25 +00:00
|
|
|
return CREDITS_NOT_PRESENT.GetValue();
|
2004-11-25 19:16:46 +00:00
|
|
|
|
2005-05-20 17:45:44 +00:00
|
|
|
case COIN_MODE_PAY:
|
2005-02-26 07:20:38 +00:00
|
|
|
{
|
|
|
|
|
int Credits = GAMESTATE->m_iCoins / PREFSMAN->m_iCoinsPerCredit;
|
|
|
|
|
int Coins = GAMESTATE->m_iCoins % PREFSMAN->m_iCoinsPerCredit;
|
2006-01-22 01:00:06 +00:00
|
|
|
RString sCredits = CREDITS_CREDITS;
|
2005-02-26 07:20:38 +00:00
|
|
|
if( Credits > 0 || PREFSMAN->m_iCoinsPerCredit == 1 )
|
|
|
|
|
sCredits += ssprintf(" %d", Credits);
|
|
|
|
|
if( PREFSMAN->m_iCoinsPerCredit > 1 )
|
2005-05-06 20:41:05 +00:00
|
|
|
sCredits += ssprintf(" %d/%d", Coins, PREFSMAN->m_iCoinsPerCredit.Get() );
|
2005-02-26 07:20:38 +00:00
|
|
|
return sCredits;
|
|
|
|
|
}
|
2005-05-20 17:45:44 +00:00
|
|
|
case COIN_MODE_FREE:
|
2005-02-26 07:20:38 +00:00
|
|
|
if( GAMESTATE->PlayersCanJoin() )
|
2005-03-01 15:18:25 +00:00
|
|
|
return CREDITS_FREE_PLAY.GetValue();
|
2005-02-26 07:20:38 +00:00
|
|
|
else
|
2005-03-01 15:18:25 +00:00
|
|
|
return CREDITS_NOT_PRESENT.GetValue();
|
2005-02-26 07:20:38 +00:00
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
ASSERT(0);
|
|
|
|
|
}
|
2004-11-25 19:16:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
void ScreenSystemLayer::HandleMessage( const RString &sMessage )
|
2005-02-26 07:20:38 +00:00
|
|
|
{
|
2005-02-28 05:01:50 +00:00
|
|
|
if( sMessage == "RefreshCreditText" )
|
|
|
|
|
{
|
|
|
|
|
// update joined
|
|
|
|
|
FOREACH_PlayerNumber( pn )
|
|
|
|
|
m_textCredits[pn].SetText( GetCreditsMessage(pn) );
|
|
|
|
|
}
|
2005-02-28 05:10:08 +00:00
|
|
|
else if( sMessage == "SystemMessage" )
|
|
|
|
|
{
|
2005-06-04 03:04:29 +00:00
|
|
|
m_sprMessageFrame->SetHidden( false );
|
|
|
|
|
m_sprMessageFrame->PlayCommand( "On" );
|
|
|
|
|
m_sprMessageFrame->PlayCommand( "Off" );
|
|
|
|
|
|
2005-05-09 09:49:13 +00:00
|
|
|
m_textMessage.SetHidden( false );
|
2005-02-28 05:10:08 +00:00
|
|
|
m_textMessage.SetText( SCREENMAN->GetCurrentSystemMessage() );
|
2005-05-09 09:49:13 +00:00
|
|
|
m_textMessage.PlayCommand( "On" );
|
2005-05-12 21:55:48 +00:00
|
|
|
m_textMessage.PlayCommand( "Off" );
|
2005-02-28 05:10:08 +00:00
|
|
|
}
|
|
|
|
|
else if( sMessage == "SystemMessageNoAnimate" )
|
|
|
|
|
{
|
2005-06-04 03:04:29 +00:00
|
|
|
m_sprMessageFrame->SetHidden( false );
|
|
|
|
|
m_sprMessageFrame->PlayCommand( "On" );
|
|
|
|
|
m_sprMessageFrame->FinishTweening();
|
|
|
|
|
m_sprMessageFrame->PlayCommand( "Off" );
|
|
|
|
|
|
2005-05-09 09:49:13 +00:00
|
|
|
m_textMessage.SetHidden( false );
|
2005-02-28 05:10:08 +00:00
|
|
|
m_textMessage.SetText( SCREENMAN->GetCurrentSystemMessage() );
|
2005-05-09 09:49:13 +00:00
|
|
|
m_textMessage.PlayCommand( "On" );
|
|
|
|
|
m_textMessage.FinishTweening();
|
2005-05-12 21:55:48 +00:00
|
|
|
m_textMessage.PlayCommand( "Off" );
|
2005-02-28 05:10:08 +00:00
|
|
|
}
|
2005-06-15 10:01:08 +00:00
|
|
|
else if( sMessage == "HideSystemMessage" )
|
|
|
|
|
{
|
|
|
|
|
m_sprMessageFrame->SetHidden( true );
|
|
|
|
|
|
|
|
|
|
m_textMessage.SetHidden( true );
|
|
|
|
|
}
|
2005-02-28 05:01:50 +00:00
|
|
|
Screen::HandleMessage( sMessage );
|
2005-02-26 07:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
2004-11-25 19:16:46 +00:00
|
|
|
void ScreenSystemLayer::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
Screen::Update(fDeltaTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2005-03-01 15:18:25 +00:00
|
|
|
* (c) 2001-2005 Chris Danford, Glenn Maynard
|
2004-11-25 19:16:46 +00:00
|
|
|
* 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.
|
|
|
|
|
*/
|