2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2003-01-21 05:14:59 +00:00
|
|
|
#include "ScreenNameEntry.h"
|
|
|
|
|
#include "SongManager.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "GameManager.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "GameState.h"
|
2004-07-08 00:10:34 +00:00
|
|
|
#include "GameSoundManager.h"
|
2003-01-21 05:14:59 +00:00
|
|
|
#include "ThemeManager.h"
|
2003-07-17 20:10:07 +00:00
|
|
|
#include "Course.h"
|
2003-11-01 07:25:22 +00:00
|
|
|
#include "AnnouncerManager.h"
|
2003-11-09 10:14:52 +00:00
|
|
|
#include "ProfileManager.h"
|
2005-07-01 05:07:22 +00:00
|
|
|
#include "Profile.h"
|
2003-12-23 00:26:00 +00:00
|
|
|
#include "StageStats.h"
|
2004-07-25 17:07:32 +00:00
|
|
|
#include "Game.h"
|
2004-09-21 06:07:12 +00:00
|
|
|
#include "ScreenDimensions.h"
|
2004-12-20 06:25:59 +00:00
|
|
|
#include "PlayerState.h"
|
2005-01-15 02:01:26 +00:00
|
|
|
#include "Style.h"
|
2005-04-18 01:19:56 +00:00
|
|
|
#include "NoteSkinManager.h"
|
2005-09-05 02:26:50 +00:00
|
|
|
#include "InputEventPlus.h"
|
2006-10-20 04:32:46 +00:00
|
|
|
#include "RageSoundManager.h"
|
|
|
|
|
#include "RageDisplay.h"
|
|
|
|
|
|
2003-01-21 05:14:59 +00:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Defines specific to ScreenNameEntry
|
|
|
|
|
//
|
2006-10-16 07:18:03 +00:00
|
|
|
#define TIMER_X THEME->GetMetricF("ScreenNameEntry","TimerX")
|
|
|
|
|
#define TIMER_Y THEME->GetMetricF("ScreenNameEntry","TimerY")
|
|
|
|
|
#define CATEGORY_Y THEME->GetMetricF("ScreenNameEntry","CategoryY")
|
|
|
|
|
#define CATEGORY_ZOOM THEME->GetMetricF("ScreenNameEntry","CategoryZoom")
|
|
|
|
|
#define CHARS_ZOOM_SMALL THEME->GetMetricF("ScreenNameEntry","CharsZoomSmall")
|
|
|
|
|
#define CHARS_ZOOM_LARGE THEME->GetMetricF("ScreenNameEntry","CharsZoomLarge")
|
|
|
|
|
#define CHARS_SPACING_Y THEME->GetMetricF("ScreenNameEntry","CharsSpacingY")
|
2005-08-26 21:12:48 +00:00
|
|
|
#define SCROLLING_CHARS_COMMAND THEME->GetMetricA("ScreenNameEntry","ScrollingCharsCommand")
|
|
|
|
|
#define SELECTED_CHARS_COMMAND THEME->GetMetricA("ScreenNameEntry","SelectedCharsCommand")
|
2006-10-16 07:18:03 +00:00
|
|
|
#define GRAY_ARROWS_Y THEME->GetMetricF("ScreenNameEntry","ReceptorArrowsY")
|
2003-01-26 02:21:47 +00:00
|
|
|
#define NUM_CHARS_TO_DRAW_BEHIND THEME->GetMetricI("ScreenNameEntry","NumCharsToDrawBehind")
|
|
|
|
|
#define NUM_CHARS_TO_DRAW_TOTAL THEME->GetMetricI("ScreenNameEntry","NumCharsToDrawTotal")
|
2006-10-16 07:18:03 +00:00
|
|
|
#define FAKE_BEATS_PER_SEC THEME->GetMetricF("ScreenNameEntry","FakeBeatsPerSec")
|
|
|
|
|
#define TIMER_SECONDS THEME->GetMetricF("ScreenNameEntry","TimerSeconds")
|
2003-10-14 21:43:30 +00:00
|
|
|
#define MAX_RANKING_NAME_LENGTH THEME->GetMetricI(m_sName,"MaxRankingNameLength")
|
2004-11-07 05:49:06 +00:00
|
|
|
#define PLAYER_X( p, styleType ) THEME->GetMetricF(m_sName,ssprintf("PlayerP%d%sX",p+1,StyleTypeToString(styleType).c_str()))
|
2003-01-26 02:21:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// cache for frequently used metrics
|
2006-10-16 09:01:39 +00:00
|
|
|
static float g_fCharsZoomSmall;
|
|
|
|
|
static float g_fCharsZoomLarge;
|
|
|
|
|
static float g_fCharsSpacingY;
|
|
|
|
|
static float g_fReceptorArrowsY;
|
|
|
|
|
static int g_iNumCharsToDrawBehind;
|
|
|
|
|
static int g_iNumCharsToDrawTotal;
|
|
|
|
|
static float g_fFakeBeatsPerSec;
|
2003-01-26 02:21:47 +00:00
|
|
|
|
|
|
|
|
|
2006-10-16 09:01:39 +00:00
|
|
|
static const char NAME_CHARS[] =
|
2003-01-26 02:21:47 +00:00
|
|
|
{
|
|
|
|
|
' ',' ',' ',' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
|
|
|
|
|
};
|
2006-09-13 03:11:38 +00:00
|
|
|
#define NUM_NAME_CHARS (ARRAYLEN(NAME_CHARS))
|
2006-10-16 07:18:03 +00:00
|
|
|
#define HEIGHT_OF_ALL_CHARS (NUM_NAME_CHARS * g_fCharsSpacingY)
|
2003-01-21 05:14:59 +00:00
|
|
|
|
|
|
|
|
|
2006-10-16 07:30:25 +00:00
|
|
|
static int GetClosestCharIndex( float fFakeBeat )
|
2003-01-26 02:21:47 +00:00
|
|
|
{
|
2003-02-11 02:44:26 +00:00
|
|
|
int iCharIndex = (int)roundf(fFakeBeat) % NUM_NAME_CHARS;
|
|
|
|
|
ASSERT( iCharIndex >= 0 );
|
|
|
|
|
return iCharIndex;
|
|
|
|
|
}
|
2003-01-26 02:21:47 +00:00
|
|
|
|
|
|
|
|
// return value is relative to gray arrows
|
2006-10-16 07:30:25 +00:00
|
|
|
static float GetClosestCharYOffset( float fFakeBeat )
|
2003-01-26 02:21:47 +00:00
|
|
|
{
|
|
|
|
|
float f = fmodf(fFakeBeat, 1.0f);
|
|
|
|
|
if( f > 0.5f )
|
|
|
|
|
f -= 1;
|
2003-04-05 04:44:35 +00:00
|
|
|
ASSERT( f>-0.5f && f<=0.5f );
|
2003-01-26 02:21:47 +00:00
|
|
|
return -f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// return value is relative to gray arrows
|
2006-10-16 07:30:25 +00:00
|
|
|
static float GetClosestCharYPos( float fFakeBeat )
|
2003-01-26 02:21:47 +00:00
|
|
|
{
|
2003-04-16 06:13:47 +00:00
|
|
|
return GetClosestCharYOffset(fFakeBeat)*g_fCharsSpacingY;
|
2003-01-26 02:21:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-01-15 20:46:15 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenNameEntry );
|
2006-01-15 18:37:57 +00:00
|
|
|
ScreenNameEntry::ScreenNameEntry()
|
2003-01-21 05:14:59 +00:00
|
|
|
{
|
2006-10-20 04:32:46 +00:00
|
|
|
#if 0
|
2003-01-27 02:00:38 +00:00
|
|
|
// DEBUGGING STUFF
|
2006-10-20 04:32:46 +00:00
|
|
|
GAMESTATE->m_pCurGame.Set( GAMEMAN->GetDefaultGame() );
|
|
|
|
|
GAMESTATE->m_pCurStyle.Set( GAMEMAN->GetHowToPlayStyleForGame(GAMESTATE->m_pCurGame) );
|
|
|
|
|
GAMESTATE->m_PlayMode.Set( PLAY_MODE_REGULAR );
|
|
|
|
|
GAMESTATE->m_bSideIsJoined[PLAYER_1] = true;
|
|
|
|
|
GAMESTATE->m_MasterPlayerNumber = PLAYER_1;
|
|
|
|
|
#endif
|
2006-01-15 18:30:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenNameEntry::Init()
|
|
|
|
|
{
|
|
|
|
|
Screen::Init();
|
2003-01-26 02:21:47 +00:00
|
|
|
|
2006-01-15 18:30:35 +00:00
|
|
|
// update cache
|
|
|
|
|
g_fCharsZoomSmall = CHARS_ZOOM_SMALL;
|
|
|
|
|
g_fCharsZoomLarge = CHARS_ZOOM_LARGE;
|
|
|
|
|
g_fCharsSpacingY = CHARS_SPACING_Y;
|
|
|
|
|
g_fReceptorArrowsY = GRAY_ARROWS_Y;
|
|
|
|
|
g_iNumCharsToDrawBehind = NUM_CHARS_TO_DRAW_BEHIND;
|
|
|
|
|
g_iNumCharsToDrawTotal = NUM_CHARS_TO_DRAW_TOTAL;
|
|
|
|
|
g_fFakeBeatsPerSec = FAKE_BEATS_PER_SEC;
|
2003-01-26 02:21:47 +00:00
|
|
|
|
2003-02-07 00:39:54 +00:00
|
|
|
// reset Player and Song Options
|
2003-02-10 05:30:12 +00:00
|
|
|
{
|
2004-05-24 06:10:11 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2006-08-05 08:02:49 +00:00
|
|
|
PO_GROUP_CALL( GAMESTATE->m_pPlayerState[p]->m_PlayerOptions, ModsLevel_Stage, Init );
|
|
|
|
|
SO_GROUP_CALL( GAMESTATE->m_SongOptions, ModsLevel_Stage, Init );
|
2003-02-10 05:30:12 +00:00
|
|
|
}
|
2003-01-27 02:00:38 +00:00
|
|
|
|
2004-03-08 02:21:22 +00:00
|
|
|
vector<GameState::RankingFeat> aFeats[NUM_PLAYERS];
|
2003-10-14 17:06:30 +00:00
|
|
|
|
2003-10-05 21:42:56 +00:00
|
|
|
// Find out if players deserve to enter their name
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-10-14 17:06:30 +00:00
|
|
|
{
|
2005-01-31 03:18:46 +00:00
|
|
|
GAMESTATE->GetRankingFeats( p, aFeats[p] );
|
2005-08-26 21:12:48 +00:00
|
|
|
GAMESTATE->JoinPlayer( p );
|
2005-09-23 00:44:52 +00:00
|
|
|
m_bStillEnteringName[p] = aFeats[p].size()>0;
|
2006-10-20 04:32:46 +00:00
|
|
|
#if 0 // Debugging.
|
|
|
|
|
m_bStillEnteringName[p] = p == PLAYER_1;
|
|
|
|
|
#endif
|
2003-10-14 17:06:30 +00:00
|
|
|
}
|
2003-10-05 21:42:56 +00:00
|
|
|
|
|
|
|
|
if( !AnyStillEntering() )
|
|
|
|
|
{
|
|
|
|
|
/* Nobody made a high score. */
|
2005-08-26 21:12:48 +00:00
|
|
|
PostScreenMessage( SM_GoToNextScreen, 0 );
|
2003-10-05 21:42:56 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2003-01-27 02:00:38 +00:00
|
|
|
|
2003-11-03 10:14:13 +00:00
|
|
|
bool IsOnRanking = ( (GAMESTATE->m_PlayMode == PLAY_MODE_NONSTOP || GAMESTATE->m_PlayMode == PLAY_MODE_ONI)
|
|
|
|
|
&& !(GAMESTATE->m_pCurCourse->IsRanking()) );
|
|
|
|
|
|
2006-10-07 05:52:45 +00:00
|
|
|
if( PREFSMAN->m_GetRankingName == RANKING_OFF ||
|
|
|
|
|
(PREFSMAN->m_GetRankingName == RANKING_LIST && !IsOnRanking) )
|
2003-11-03 10:14:13 +00:00
|
|
|
{
|
|
|
|
|
// don't collect score due to ranking setting
|
2006-01-15 18:29:50 +00:00
|
|
|
PostScreenMessage( SM_GoToNextScreen, 0 );
|
2003-11-03 10:14:13 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-10-10 04:36:04 +00:00
|
|
|
GAMESTATE->m_bGameplayLeadIn.Set( false ); // enable the gray arrows
|
2003-01-26 02:21:47 +00:00
|
|
|
|
2004-05-24 08:16:17 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-01-21 05:14:59 +00:00
|
|
|
{
|
2003-11-09 10:14:52 +00:00
|
|
|
// load last used ranking name if any
|
2005-01-31 03:18:46 +00:00
|
|
|
Profile* pProfile = PROFILEMAN->GetProfile(p);
|
2003-11-09 10:14:52 +00:00
|
|
|
if( pProfile && !pProfile->m_sLastUsedHighScoreName.empty() )
|
|
|
|
|
m_sSelectedName[p] = pProfile->m_sLastUsedHighScoreName;
|
2003-01-26 02:21:47 +00:00
|
|
|
|
2003-11-09 10:14:52 +00:00
|
|
|
// resize string to MAX_RANKING_NAME_LENGTH
|
|
|
|
|
m_sSelectedName[p] = ssprintf( "%*.*s", MAX_RANKING_NAME_LENGTH, MAX_RANKING_NAME_LENGTH, m_sSelectedName[p].c_str() );
|
2003-11-12 01:28:47 +00:00
|
|
|
ASSERT( (int) m_sSelectedName[p].length() == MAX_RANKING_NAME_LENGTH );
|
2003-11-09 10:14:52 +00:00
|
|
|
|
|
|
|
|
// don't load player if they aren't going to enter their name
|
2003-10-05 21:42:56 +00:00
|
|
|
if( !m_bStillEnteringName[p] )
|
2003-01-21 05:14:59 +00:00
|
|
|
continue; // skip
|
|
|
|
|
|
2003-02-06 09:19:48 +00:00
|
|
|
// remove modifiers that may have been on the last song
|
2006-08-05 02:38:05 +00:00
|
|
|
PlayerOptions po;
|
|
|
|
|
GAMESTATE->GetDefaultPlayerOptions( po );
|
2006-08-05 04:47:01 +00:00
|
|
|
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.Assign( ModsLevel_Stage, po );
|
2003-02-06 09:19:48 +00:00
|
|
|
|
2003-04-10 05:46:31 +00:00
|
|
|
ASSERT( GAMESTATE->IsHumanPlayer(p) ); // they better be enabled if they made a high score!
|
2003-01-21 05:14:59 +00:00
|
|
|
|
2006-10-20 04:32:46 +00:00
|
|
|
float fPlayerX = PLAYER_X(p,GAMESTATE->GetCurrentStyle()->m_StyleType);
|
2004-11-07 05:49:06 +00:00
|
|
|
|
2005-04-18 01:19:56 +00:00
|
|
|
{
|
2006-08-05 02:38:05 +00:00
|
|
|
LockNoteSkin l( GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.GetCurrent().m_sNoteSkin );
|
2005-04-18 01:19:56 +00:00
|
|
|
|
|
|
|
|
m_ReceptorArrowRow[p].Load( GAMESTATE->m_pPlayerState[p], 0 );
|
|
|
|
|
m_ReceptorArrowRow[p].SetX( fPlayerX );
|
2006-10-16 08:42:54 +00:00
|
|
|
m_ReceptorArrowRow[p].SetY( GRAY_ARROWS_Y );
|
2005-04-18 01:19:56 +00:00
|
|
|
this->AddChild( &m_ReceptorArrowRow[p] );
|
|
|
|
|
}
|
2003-01-21 05:14:59 +00:00
|
|
|
|
|
|
|
|
|
2004-06-28 07:26:00 +00:00
|
|
|
const Style* pStyle = GAMESTATE->GetCurrentStyle();
|
2003-02-16 23:20:52 +00:00
|
|
|
|
2004-06-28 07:26:00 +00:00
|
|
|
m_ColToStringIndex[p].insert(m_ColToStringIndex[p].begin(), pStyle->m_iColsPerPlayer, -1);
|
2003-02-16 23:20:52 +00:00
|
|
|
int CurrentStringIndex = 0;
|
|
|
|
|
|
2006-09-13 09:24:56 +00:00
|
|
|
for( int iCol=0; iCol<pStyle->m_iColsPerPlayer; iCol++ )
|
2003-01-26 02:21:47 +00:00
|
|
|
{
|
2006-10-16 07:18:03 +00:00
|
|
|
if( CurrentStringIndex == MAX_RANKING_NAME_LENGTH )
|
2006-10-16 08:27:49 +00:00
|
|
|
break; /* We have enough columns. */
|
2003-02-16 23:20:52 +00:00
|
|
|
|
|
|
|
|
/* Find out if this column is associated with the START menu button. */
|
2006-09-13 09:24:56 +00:00
|
|
|
GameInput gi = GAMESTATE->GetCurrentStyle()->StyleInputToGameInput( iCol, p );
|
2006-09-30 08:22:36 +00:00
|
|
|
MenuButton mb = INPUTMAPPER->GameToMenu( gi );
|
2006-09-14 04:11:29 +00:00
|
|
|
if( mb == MENU_BUTTON_START )
|
2003-02-16 23:20:52 +00:00
|
|
|
continue;
|
2006-09-13 09:24:56 +00:00
|
|
|
m_ColToStringIndex[p][iCol] = CurrentStringIndex++;
|
|
|
|
|
|
|
|
|
|
float ColX = fPlayerX + pStyle->m_ColumnInfo[p][iCol].fXOffset;
|
|
|
|
|
|
|
|
|
|
m_textSelectedChars[p][iCol].LoadFromFont( THEME->GetPathF("ScreenNameEntry","letters") );
|
|
|
|
|
m_textSelectedChars[p][iCol].SetX( ColX );
|
|
|
|
|
m_textSelectedChars[p][iCol].SetY( GRAY_ARROWS_Y );
|
|
|
|
|
m_textSelectedChars[p][iCol].RunCommands( SELECTED_CHARS_COMMAND );
|
|
|
|
|
m_textSelectedChars[p][iCol].SetZoom( CHARS_ZOOM_LARGE );
|
|
|
|
|
if( iCol < (int)m_sSelectedName[p].length() )
|
|
|
|
|
m_textSelectedChars[p][iCol].SetText( m_sSelectedName[p].substr(iCol,1) );
|
|
|
|
|
this->AddChild( &m_textSelectedChars[p][iCol] ); // draw these manually
|
2003-01-26 02:21:47 +00:00
|
|
|
|
2006-09-13 09:24:56 +00:00
|
|
|
m_textScrollingChars[p][iCol].LoadFromFont( THEME->GetPathF("ScreenNameEntry","letters") );
|
|
|
|
|
m_textScrollingChars[p][iCol].SetX( ColX );
|
|
|
|
|
m_textScrollingChars[p][iCol].SetY( GRAY_ARROWS_Y );
|
|
|
|
|
m_textScrollingChars[p][iCol].RunCommands( SCROLLING_CHARS_COMMAND );
|
2006-10-20 04:32:46 +00:00
|
|
|
//this->AddChild( &m_textScrollingChars[p][iCol] ); // draw these manually
|
2003-01-26 02:21:47 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-06 03:32:53 +00:00
|
|
|
m_textCategory[p].LoadFromFont( THEME->GetPathF("ScreenNameEntry","category") );
|
2004-11-07 05:49:06 +00:00
|
|
|
m_textCategory[p].SetX( fPlayerX );
|
2003-01-26 02:21:47 +00:00
|
|
|
m_textCategory[p].SetY( CATEGORY_Y );
|
2003-10-19 21:38:11 +00:00
|
|
|
m_textCategory[p].SetZoom( CATEGORY_ZOOM );
|
2006-01-22 01:00:06 +00:00
|
|
|
RString joined;
|
2003-10-15 01:09:29 +00:00
|
|
|
for( unsigned j = 0; j < aFeats[p].size(); ++j )
|
|
|
|
|
{
|
|
|
|
|
if( j )
|
|
|
|
|
joined += "\n";
|
|
|
|
|
joined += aFeats[p][j].Feat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_textCategory[p].SetText( joined );
|
2003-01-26 02:21:47 +00:00
|
|
|
this->AddChild( &m_textCategory[p] );
|
2003-01-21 05:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-27 02:00:38 +00:00
|
|
|
|
2005-07-18 02:08:15 +00:00
|
|
|
m_Timer.Load();
|
2003-02-10 22:13:31 +00:00
|
|
|
if( !PREFSMAN->m_bMenuTimer )
|
2003-03-11 21:33:11 +00:00
|
|
|
m_Timer.Disable();
|
2003-02-10 22:13:31 +00:00
|
|
|
else
|
2003-03-11 21:33:11 +00:00
|
|
|
m_Timer.SetSeconds(TIMER_SECONDS);
|
2003-01-26 02:21:47 +00:00
|
|
|
m_Timer.SetXY( TIMER_X, TIMER_Y );
|
|
|
|
|
this->AddChild( &m_Timer );
|
|
|
|
|
|
2005-02-06 03:32:53 +00:00
|
|
|
m_In.Load( THEME->GetPathB("ScreenNameEntry","in") );
|
2003-04-12 19:40:56 +00:00
|
|
|
m_In.StartTransitioning();
|
2005-07-11 22:25:29 +00:00
|
|
|
m_In.SetDrawOrder( DRAW_ORDER_TRANSITIONS );
|
|
|
|
|
this->AddChild( &m_In );
|
2003-04-12 19:40:56 +00:00
|
|
|
|
2005-02-06 03:32:53 +00:00
|
|
|
m_Out.Load( THEME->GetPathB("ScreenNameEntry","out") );
|
2005-07-11 22:25:29 +00:00
|
|
|
m_Out.SetDrawOrder( DRAW_ORDER_TRANSITIONS );
|
|
|
|
|
this->AddChild( &m_Out );
|
|
|
|
|
|
|
|
|
|
this->SortByDrawOrder();
|
2003-01-26 02:21:47 +00:00
|
|
|
|
2005-02-06 03:32:53 +00:00
|
|
|
m_soundStep.Load( THEME->GetPathS("ScreenNameEntry","step") );
|
2006-10-16 09:31:28 +00:00
|
|
|
m_sPathToMusic = THEME->GetPathS( m_sName, "music" );
|
2003-01-26 02:21:47 +00:00
|
|
|
m_fFakeBeat = 0;
|
2003-01-21 05:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
2006-10-16 09:31:28 +00:00
|
|
|
void ScreenNameEntry::BeginScreen()
|
|
|
|
|
{
|
2006-10-20 04:32:46 +00:00
|
|
|
Screen::BeginScreen();
|
2006-10-16 09:31:28 +00:00
|
|
|
SOUND->PlayMusic( m_sPathToMusic );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenNameEntry::EndScreen()
|
|
|
|
|
{
|
|
|
|
|
SOUND->StopMusic();
|
2006-10-20 04:32:46 +00:00
|
|
|
Screen::EndScreen();
|
2006-10-16 09:31:28 +00:00
|
|
|
}
|
|
|
|
|
|
2003-10-05 21:42:56 +00:00
|
|
|
bool ScreenNameEntry::AnyStillEntering() const
|
|
|
|
|
{
|
2004-05-24 06:10:11 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-10-05 21:42:56 +00:00
|
|
|
if( m_bStillEnteringName[p] )
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-01-21 05:14:59 +00:00
|
|
|
|
|
|
|
|
ScreenNameEntry::~ScreenNameEntry()
|
|
|
|
|
{
|
|
|
|
|
LOG->Trace( "ScreenNameEntry::~ScreenNameEntry()" );
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-26 02:21:47 +00:00
|
|
|
void ScreenNameEntry::Update( float fDelta )
|
|
|
|
|
{
|
2003-11-01 07:25:22 +00:00
|
|
|
if( m_bFirstUpdate )
|
|
|
|
|
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo("name entry") );
|
|
|
|
|
|
2003-01-26 02:21:47 +00:00
|
|
|
m_fFakeBeat += fDelta * FAKE_BEATS_PER_SEC;
|
|
|
|
|
GAMESTATE->m_fSongBeat = m_fFakeBeat;
|
|
|
|
|
|
2005-07-11 22:25:29 +00:00
|
|
|
Screen::Update(fDelta);
|
2003-01-26 02:21:47 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-21 05:14:59 +00:00
|
|
|
void ScreenNameEntry::DrawPrimitives()
|
|
|
|
|
{
|
|
|
|
|
Screen::DrawPrimitives();
|
2006-10-20 04:32:46 +00:00
|
|
|
DISPLAY->CameraPushMatrix();
|
|
|
|
|
DISPLAY->LoadMenuPerspective( m_fFOV, SCREEN_WIDTH, SCREEN_HEIGHT, m_fVanishX, m_fVanishY );
|
|
|
|
|
|
2003-01-26 02:21:47 +00:00
|
|
|
int iClosestIndex = GetClosestCharIndex( m_fFakeBeat );
|
|
|
|
|
int iStartDrawingIndex = iClosestIndex - NUM_CHARS_TO_DRAW_BEHIND;
|
|
|
|
|
iStartDrawingIndex += NUM_NAME_CHARS; // make positive
|
|
|
|
|
|
2004-06-28 07:26:00 +00:00
|
|
|
const Style* pStyle = GAMESTATE->GetCurrentStyle();
|
2003-01-26 02:21:47 +00:00
|
|
|
|
2004-05-24 06:10:11 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2003-01-26 02:21:47 +00:00
|
|
|
{
|
2003-01-27 02:00:38 +00:00
|
|
|
if( !m_bStillEnteringName[p] )
|
|
|
|
|
continue; // don't draw scrolling arrows
|
2003-01-26 02:21:47 +00:00
|
|
|
|
|
|
|
|
float fY = GRAY_ARROWS_Y + GetClosestCharYPos(m_fFakeBeat) - g_iNumCharsToDrawBehind*g_fCharsSpacingY;
|
|
|
|
|
int iCharIndex = iStartDrawingIndex % NUM_NAME_CHARS;
|
2003-02-16 23:20:52 +00:00
|
|
|
|
2003-01-26 02:21:47 +00:00
|
|
|
for( int i=0; i<NUM_CHARS_TO_DRAW_TOTAL; i++ )
|
|
|
|
|
{
|
2006-10-20 04:32:46 +00:00
|
|
|
const RString c( 1, NAME_CHARS[iCharIndex] );
|
2004-06-28 07:26:00 +00:00
|
|
|
for( int t=0; t<pStyle->m_iColsPerPlayer; t++ )
|
2003-01-26 02:21:47 +00:00
|
|
|
{
|
2006-10-16 07:18:03 +00:00
|
|
|
if( m_ColToStringIndex[p][t] == -1 )
|
2003-02-16 23:20:52 +00:00
|
|
|
continue;
|
|
|
|
|
|
2006-10-20 04:32:46 +00:00
|
|
|
m_textScrollingChars[p][t].SetText( c );
|
2003-01-26 02:21:47 +00:00
|
|
|
m_textScrollingChars[p][t].SetY( fY );
|
|
|
|
|
float fZoom = g_fCharsZoomSmall;
|
|
|
|
|
if( iCharIndex==iClosestIndex )
|
|
|
|
|
fZoom = SCALE(fabsf(GetClosestCharYOffset(m_fFakeBeat)),0,0.5f,g_fCharsZoomLarge,g_fCharsZoomSmall);
|
|
|
|
|
m_textScrollingChars[p][t].SetZoom(fZoom);
|
2006-01-15 18:28:16 +00:00
|
|
|
float fAlpha = 1;
|
2003-01-26 02:21:47 +00:00
|
|
|
if( i==0 )
|
2005-08-26 21:12:48 +00:00
|
|
|
fAlpha *= SCALE(GetClosestCharYOffset(m_fFakeBeat),-0.5f,0.f,0.f,1.f);
|
2003-01-26 02:21:47 +00:00
|
|
|
if( i==g_iNumCharsToDrawTotal-1 )
|
2005-08-26 21:12:48 +00:00
|
|
|
fAlpha *= SCALE(GetClosestCharYOffset(m_fFakeBeat),0.f,0.5f,1.f,0.f);
|
|
|
|
|
m_textScrollingChars[p][t].SetDiffuseAlpha( fAlpha );
|
2006-10-20 04:32:46 +00:00
|
|
|
m_textScrollingChars[p][t].Draw();
|
2003-01-26 02:21:47 +00:00
|
|
|
}
|
|
|
|
|
fY += g_fCharsSpacingY;
|
|
|
|
|
iCharIndex = (iCharIndex+1) % NUM_NAME_CHARS;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-10-20 04:32:46 +00:00
|
|
|
DISPLAY->CameraPopMatrix();
|
2003-01-21 05:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
2005-09-05 02:26:50 +00:00
|
|
|
void ScreenNameEntry::Input( const InputEventPlus &input )
|
2003-01-21 05:14:59 +00:00
|
|
|
{
|
|
|
|
|
LOG->Trace( "ScreenNameEntry::Input()" );
|
|
|
|
|
|
2003-04-12 19:40:56 +00:00
|
|
|
if( m_In.IsTransitioning() || m_Out.IsTransitioning() )
|
|
|
|
|
return;
|
|
|
|
|
|
2006-10-16 10:16:47 +00:00
|
|
|
if( input.type != IET_FIRST_PRESS || !input.GameI.IsValid() )
|
2003-01-26 02:21:47 +00:00
|
|
|
return; // ignore
|
|
|
|
|
|
2006-09-30 22:13:20 +00:00
|
|
|
const int iCol = GAMESTATE->GetCurrentStyle()->GameInputToColumn( input.GameI );
|
2006-10-07 04:25:28 +00:00
|
|
|
if( iCol != Column_Invalid && m_bStillEnteringName[input.pn] )
|
2003-01-26 02:21:47 +00:00
|
|
|
{
|
2006-09-13 10:11:36 +00:00
|
|
|
int iStringIndex = m_ColToStringIndex[input.pn][iCol];
|
2005-09-05 02:26:50 +00:00
|
|
|
if( iStringIndex != -1 )
|
2003-01-26 02:21:47 +00:00
|
|
|
{
|
2006-09-13 10:11:36 +00:00
|
|
|
m_ReceptorArrowRow[input.pn].Step( iCol, TNS_W1 );
|
2003-01-26 02:21:47 +00:00
|
|
|
m_soundStep.Play();
|
2003-01-27 02:00:38 +00:00
|
|
|
char c = NAME_CHARS[GetClosestCharIndex(m_fFakeBeat)];
|
2006-09-13 10:11:36 +00:00
|
|
|
m_textSelectedChars[input.pn][iCol].SetText( ssprintf("%c",c) );
|
|
|
|
|
m_sSelectedName[input.pn][iStringIndex] = c;
|
2003-01-26 02:21:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-05 02:26:50 +00:00
|
|
|
Screen::Input( input );
|
2003-01-21 05:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenNameEntry::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
2006-02-24 00:20:41 +00:00
|
|
|
if( SM == SM_MenuTimer )
|
2003-01-21 05:14:59 +00:00
|
|
|
{
|
2003-04-12 19:40:56 +00:00
|
|
|
if( !m_Out.IsTransitioning() )
|
2003-01-27 02:00:38 +00:00
|
|
|
{
|
2006-09-15 01:47:24 +00:00
|
|
|
InputEventPlus iep;
|
2004-05-24 06:10:11 +00:00
|
|
|
FOREACH_PlayerNumber( p )
|
2006-09-15 01:47:24 +00:00
|
|
|
{
|
|
|
|
|
iep.pn = p;
|
|
|
|
|
this->MenuStart( iep );
|
|
|
|
|
}
|
2003-01-27 02:00:38 +00:00
|
|
|
}
|
2006-02-24 00:20:41 +00:00
|
|
|
}
|
2005-07-12 05:38:13 +00:00
|
|
|
|
|
|
|
|
Screen::HandleScreenMessage( SM );
|
2003-01-21 05:14:59 +00:00
|
|
|
}
|
2003-01-27 02:00:38 +00:00
|
|
|
|
|
|
|
|
|
2006-09-15 01:47:24 +00:00
|
|
|
void ScreenNameEntry::MenuStart( const InputEventPlus &input )
|
2003-01-27 02:00:38 +00:00
|
|
|
{
|
2006-09-15 01:47:24 +00:00
|
|
|
PlayerNumber pn = input.pn;
|
|
|
|
|
|
2003-02-16 23:20:52 +00:00
|
|
|
if( !m_bStillEnteringName[pn] )
|
|
|
|
|
return;
|
|
|
|
|
m_bStillEnteringName[pn] = false;
|
2003-01-27 02:00:38 +00:00
|
|
|
|
2003-02-16 23:20:52 +00:00
|
|
|
m_soundStep.Play();
|
2003-01-27 02:00:38 +00:00
|
|
|
|
2003-11-09 10:14:52 +00:00
|
|
|
// save last used ranking name
|
|
|
|
|
Profile* pProfile = PROFILEMAN->GetProfile(pn);
|
2005-05-01 06:42:30 +00:00
|
|
|
pProfile->m_sLastUsedHighScoreName = m_sSelectedName[pn];
|
2003-11-09 10:14:52 +00:00
|
|
|
|
2004-05-24 09:26:44 +00:00
|
|
|
TrimRight( m_sSelectedName[pn], " " );
|
|
|
|
|
TrimLeft( m_sSelectedName[pn], " " );
|
|
|
|
|
|
|
|
|
|
GAMESTATE->StoreRankingName( pn, m_sSelectedName[pn] );
|
|
|
|
|
|
2003-10-05 21:42:56 +00:00
|
|
|
if( !AnyStillEntering() && !m_Out.IsTransitioning() )
|
2003-04-12 19:40:56 +00:00
|
|
|
m_Out.StartTransitioning( SM_GoToNextScreen );
|
2003-01-27 02:00:38 +00:00
|
|
|
}
|
2004-06-08 05:22:33 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 Chris Danford
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|