2003-07-09 03:10:01 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: ScreenUnlock
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2003 by the person(s) listed below. All rights reserved.
|
2003-07-10 07:22:31 +00:00
|
|
|
Andrew Wong
|
2003-07-09 03:10:01 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "ScreenUnlock.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "UnlockSystem.h"
|
2003-07-09 04:46:24 +00:00
|
|
|
#include "SongManager.h"
|
2003-07-12 20:35:48 +00:00
|
|
|
#include "ActorUtil.h"
|
2003-07-16 20:11:03 +00:00
|
|
|
#include "song.h"
|
2003-07-09 03:10:01 +00:00
|
|
|
|
|
|
|
|
ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock")
|
|
|
|
|
{
|
|
|
|
|
LOG->Trace("ScreenUnlock::ScreenUnlock()");
|
|
|
|
|
PointsUntilNextUnlock.LoadFromFont( THEME->GetPathToF("Common normal") );
|
|
|
|
|
PointsUntilNextUnlock.SetHorizAlign( Actor::align_left );
|
|
|
|
|
|
2003-07-13 14:18:26 +00:00
|
|
|
// get unlock data first
|
|
|
|
|
|
2003-07-09 06:05:43 +00:00
|
|
|
CString sDP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->DancePointsUntilNextUnlock() );
|
|
|
|
|
CString sAP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->ArcadePointsUntilNextUnlock() );
|
|
|
|
|
CString sSP = ssprintf( "%d", (int)GAMESTATE->m_pUnlockingSys->SongPointsUntilNextUnlock() );
|
|
|
|
|
|
|
|
|
|
CString PointDisplay = THEME->GetMetric("ScreenUnlock", "TypeOfPointsToDisplay");
|
2003-07-10 07:22:31 +00:00
|
|
|
|
2003-07-11 09:35:28 +00:00
|
|
|
CString IconCommand = THEME->GetMetric("ScreenUnlock", "UnlockIconCommand");
|
2003-07-09 03:10:01 +00:00
|
|
|
|
|
|
|
|
for(int i=1; i <= THEME->GetMetricI("ScreenUnlock", "NumUnlocks"); i++)
|
|
|
|
|
{
|
2003-07-16 14:03:40 +00:00
|
|
|
Sprite* entry = new Sprite;
|
|
|
|
|
|
2003-07-09 03:10:01 +00:00
|
|
|
// new unlock graphic
|
2003-07-16 14:03:40 +00:00
|
|
|
entry->Load( THEME->GetPathToG(ssprintf("ScreenUnlock %d icon", i)) );
|
2003-07-09 03:10:01 +00:00
|
|
|
|
2003-07-10 14:44:13 +00:00
|
|
|
// set graphic location
|
2003-07-16 14:03:40 +00:00
|
|
|
entry->SetName( ssprintf("Unlock%d",i) );
|
|
|
|
|
SET_XY( *entry );
|
2003-07-09 03:10:01 +00:00
|
|
|
|
2003-07-10 14:44:13 +00:00
|
|
|
// get pertaining songentry
|
|
|
|
|
SongEntry *pSong = GAMESTATE->m_pUnlockingSys->FindSong(
|
|
|
|
|
THEME->GetMetric("ScreenUnlock",
|
|
|
|
|
ssprintf("Unlock%dSong", i)) );
|
|
|
|
|
|
|
|
|
|
LOG->Trace("UnlockScreen: Searching for %s", THEME->GetMetric("ScreenUnlock",
|
|
|
|
|
ssprintf("Unlock%dSong", i)).c_str() );
|
|
|
|
|
|
|
|
|
|
if( pSong == NULL)
|
2003-07-17 12:14:19 +00:00
|
|
|
{
|
|
|
|
|
LOG->Trace("Can't find song");
|
2003-07-09 04:46:24 +00:00
|
|
|
continue;
|
2003-07-17 12:14:19 +00:00
|
|
|
}
|
2003-07-09 04:46:24 +00:00
|
|
|
|
2003-07-16 14:03:40 +00:00
|
|
|
entry->Command(IconCommand);
|
|
|
|
|
|
|
|
|
|
Unlocks.push_back(entry);
|
2003-07-10 07:22:31 +00:00
|
|
|
|
2003-07-10 14:44:13 +00:00
|
|
|
if ( !pSong->isLocked )
|
2003-07-17 12:14:19 +00:00
|
|
|
this->AddChild(Unlocks[Unlocks.size() - 1]);
|
2003-07-09 03:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
2003-07-16 13:13:26 +00:00
|
|
|
// scrolling text
|
|
|
|
|
if (THEME->GetMetricI("ScreenUnlock", "UnlockTextScroll") != 0)
|
|
|
|
|
{
|
2003-07-17 22:56:28 +00:00
|
|
|
int NumberUnlocks = THEME->GetMetricI("ScreenUnlock", "NumUnlocks");
|
2003-07-16 13:13:26 +00:00
|
|
|
float ScrollingTextX = THEME->GetMetricF("ScreenUnlock", "UnlockTextScrollX");
|
|
|
|
|
float ScrollingTextStartY = THEME->GetMetricF("ScreenUnlock", "UnlockTextScrollStartY");
|
|
|
|
|
float ScrollingTextEndY = THEME->GetMetricF("ScreenUnlock", "UnlockTextScrollEndY");
|
|
|
|
|
float ScrollingTextZoom = THEME->GetMetricF("ScreenUnlock", "UnlockTextScrollZoom");
|
|
|
|
|
float ScrollingTextRows = THEME->GetMetricF("ScreenUnlock", "UnlockTextScrollRows");
|
|
|
|
|
float MaxWidth = THEME->GetMetricF("ScreenUnlock", "UnlockTextScrollMaxWidth");
|
|
|
|
|
|
|
|
|
|
float SecondsToScroll = THEME->GetMetricF("ScreenUnlock", "TimeToDisplay");
|
|
|
|
|
if (SecondsToScroll > 2) SecondsToScroll--;
|
|
|
|
|
|
|
|
|
|
const float SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows + NumberUnlocks);
|
|
|
|
|
|
|
|
|
|
for(int i = 1; i <= NumberUnlocks; i++)
|
|
|
|
|
{
|
2003-07-16 14:03:40 +00:00
|
|
|
BitmapText* text = new BitmapText;
|
2003-07-16 13:13:26 +00:00
|
|
|
|
2003-07-16 14:03:40 +00:00
|
|
|
text->LoadFromFont( THEME->GetPathToF("_shared2") );
|
|
|
|
|
text->SetHorizAlign( Actor::align_left );
|
2003-07-16 13:13:26 +00:00
|
|
|
|
2003-07-16 14:03:40 +00:00
|
|
|
CString SongText = THEME->GetMetric("ScreenUnlock", ssprintf("Unlock%dSong", i));
|
2003-07-16 13:13:26 +00:00
|
|
|
SongText.MakeUpper();
|
|
|
|
|
SongEntry *pSong = GAMESTATE->m_pUnlockingSys->FindSong(SongText);
|
|
|
|
|
|
|
|
|
|
if (pSong != NULL && pSong->ActualSong != NULL)
|
|
|
|
|
SongText = pSong->ActualSong->GetFullDisplayTitle();
|
2003-07-16 14:03:40 +00:00
|
|
|
else // song is missing
|
2003-07-17 12:14:19 +00:00
|
|
|
{
|
|
|
|
|
if (SONGMAN->FindCourse(SongText) != NULL)
|
|
|
|
|
text->Command("Diffuse,0,1,0,1");
|
|
|
|
|
else
|
|
|
|
|
text->Command("Diffuse,0.5,0,0,1");
|
|
|
|
|
}
|
2003-07-16 13:13:26 +00:00
|
|
|
|
|
|
|
|
BreakLine(SongText);
|
2003-07-16 14:03:40 +00:00
|
|
|
text->SetZoom(ScrollingTextZoom);
|
|
|
|
|
text->SetTextMaxWidth(MaxWidth, SongText );
|
|
|
|
|
|
2003-07-17 12:14:19 +00:00
|
|
|
if (pSong != NULL && pSong->isLocked) {
|
|
|
|
|
text->SetText("???");
|
|
|
|
|
// text->SetZoom(ScrollingTextZoom * 1.99);
|
|
|
|
|
} else if (pSong != NULL) {
|
|
|
|
|
RageColor color = SONGMAN->GetGroupColor(pSong->ActualSong->m_sGroupName);
|
|
|
|
|
text->SetGlobalDiffuseColor(color);
|
|
|
|
|
}
|
2003-07-16 13:13:26 +00:00
|
|
|
|
2003-07-16 14:03:40 +00:00
|
|
|
text->SetXY(ScrollingTextX, ScrollingTextStartY);
|
|
|
|
|
text->Command( ssprintf("diffusealpha,0;sleep,%f;linear,0.5;diffusealpha,1;linear,%f;y,%f;linear,0.5;diffusealpha,0", SECS_PER_CYCLE * (i - 1), SECS_PER_CYCLE * (ScrollingTextRows), ScrollingTextEndY) );
|
2003-07-16 13:13:26 +00:00
|
|
|
|
2003-07-16 14:03:40 +00:00
|
|
|
item.push_back(text);
|
|
|
|
|
this->AddChild(item[i-1]);
|
|
|
|
|
|
|
|
|
|
if (THEME->GetMetricI("ScreenUnlock", "UnlockTextScroll") == 2)
|
2003-07-16 13:13:26 +00:00
|
|
|
{
|
2003-07-16 14:03:40 +00:00
|
|
|
Sprite* IconCount = new Sprite;
|
|
|
|
|
|
|
|
|
|
// new unlock graphic
|
|
|
|
|
IconCount->Load( THEME->GetPathToG(ssprintf("ScreenUnlock %d icon", i)) );
|
2003-07-16 13:13:26 +00:00
|
|
|
|
2003-07-16 14:03:40 +00:00
|
|
|
// set graphic location
|
|
|
|
|
IconCount->SetXY( THEME->GetMetricF("ScreenUnlock", "UnlockTextScrollIconX"),
|
|
|
|
|
ScrollingTextStartY);
|
2003-07-16 13:13:26 +00:00
|
|
|
|
2003-07-16 14:03:40 +00:00
|
|
|
float IconSize = THEME->GetMetricF("ScreenUnlock", "UnlockTextScrollIconSize");
|
2003-07-16 13:13:26 +00:00
|
|
|
|
2003-07-16 14:03:40 +00:00
|
|
|
IconCount->SetHeight(IconSize);
|
|
|
|
|
IconCount->SetWidth(IconSize);
|
2003-07-16 13:13:26 +00:00
|
|
|
|
2003-07-16 14:03:40 +00:00
|
|
|
IconCount->Command( ssprintf("diffusealpha,0;sleep,%f;linear,0.5;diffusealpha,1;linear,%f;y,%f;linear,0.5;diffusealpha,0", SECS_PER_CYCLE * (i - 1), SECS_PER_CYCLE * (ScrollingTextRows), ScrollingTextEndY) );
|
2003-07-16 13:13:26 +00:00
|
|
|
|
2003-07-16 14:03:40 +00:00
|
|
|
ItemIcons.push_back(IconCount);
|
|
|
|
|
|
|
|
|
|
this->AddChild(ItemIcons[i-1]);
|
2003-07-17 12:14:19 +00:00
|
|
|
LOG->Trace("Added unlock text %d", i);
|
2003-07-16 14:03:40 +00:00
|
|
|
|
|
|
|
|
}
|
2003-07-16 13:13:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-09 06:05:43 +00:00
|
|
|
PointsUntilNextUnlock.SetName( "PointsDisplay" );
|
|
|
|
|
|
|
|
|
|
if (PointDisplay == "DP" || PointDisplay == "Dance")
|
|
|
|
|
PointsUntilNextUnlock.SetText( sDP );
|
|
|
|
|
|
|
|
|
|
if (PointDisplay == "AP" || PointDisplay == "Arcade")
|
|
|
|
|
PointsUntilNextUnlock.SetText( sAP );
|
|
|
|
|
|
|
|
|
|
if (PointDisplay == "SP" || PointDisplay == "Song")
|
|
|
|
|
PointsUntilNextUnlock.SetText( sSP );
|
|
|
|
|
|
|
|
|
|
PointsUntilNextUnlock.SetZoom( THEME->GetMetricF("ScreenUnlock","PointsZoom") );
|
2003-07-09 03:10:01 +00:00
|
|
|
SET_XY( PointsUntilNextUnlock );
|
|
|
|
|
this->AddChild( &PointsUntilNextUnlock );
|
2003-07-10 07:22:31 +00:00
|
|
|
|
|
|
|
|
this->ClearMessageQueue( SM_BeginFadingOut ); // ignore ScreenAttract's SecsToShow
|
|
|
|
|
|
|
|
|
|
this->PostScreenMessage( SM_BeginFadingOut,
|
2003-07-12 20:33:19 +00:00
|
|
|
THEME->GetMetricF("ScreenUnlock", "TimeToDisplay") );
|
2003-07-09 03:10:01 +00:00
|
|
|
}
|
2003-07-16 13:13:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void ScreenUnlock::BreakLine(CString& line)
|
|
|
|
|
{
|
2003-07-17 22:56:28 +00:00
|
|
|
for(unsigned i = 1; i < line.size(); i++)
|
|
|
|
|
{
|
2003-07-16 13:13:26 +00:00
|
|
|
if (line[i] == '~' || line[i] == '(')
|
2003-07-17 22:56:28 +00:00
|
|
|
{
|
2003-07-16 13:13:26 +00:00
|
|
|
if (line[i-1] == ' ')
|
|
|
|
|
{
|
|
|
|
|
line[i-1] = '\n';
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-07-17 22:56:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-07-16 20:11:03 +00:00
|
|
|
}
|