Files
itgmania212121/stepmania/src/ScreenUnlock.cpp
T

191 lines
5.9 KiB
C++
Raw Normal View History

/*
-----------------------------------------------------------------------------
Class: ScreenUnlock
Desc: See header.
Copyright (c) 2003 by the person(s) listed below. All rights reserved.
Andrew Wong
-----------------------------------------------------------------------------
*/
#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"
ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock")
{
LOG->Trace("ScreenUnlock::ScreenUnlock()");
PointsUntilNextUnlock.LoadFromFont( THEME->GetPathToF("Common normal") );
PointsUntilNextUnlock.SetHorizAlign( Actor::align_left );
// get unlock data first
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");
CString IconCommand = THEME->GetMetric("ScreenUnlock", "UnlockIconCommand");
for(int i=1; i <= THEME->GetMetricI("ScreenUnlock", "NumUnlocks"); i++)
{
2003-07-16 14:03:40 +00:00
Sprite* entry = new Sprite;
// new unlock graphic
2003-07-16 14:03:40 +00:00
entry->Load( THEME->GetPathToG(ssprintf("ScreenUnlock %d icon", i)) );
// set graphic location
2003-07-16 14:03:40 +00:00
entry->SetName( ssprintf("Unlock%d",i) );
SET_XY( *entry );
// 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)
{
LOG->Trace("Can't find song");
2003-07-09 04:46:24 +00:00
continue;
}
2003-07-09 04:46:24 +00:00
2003-07-16 14:03:40 +00:00
entry->Command(IconCommand);
Unlocks.push_back(entry);
if ( !pSong->isLocked )
this->AddChild(Unlocks[Unlocks.size() - 1]);
}
// scrolling text
if (THEME->GetMetricI("ScreenUnlock", "UnlockTextScroll") != 0)
{
2003-07-17 22:56:28 +00:00
int NumberUnlocks = THEME->GetMetricI("ScreenUnlock", "NumUnlocks");
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 14:03:40 +00:00
text->LoadFromFont( THEME->GetPathToF("_shared2") );
text->SetHorizAlign( Actor::align_left );
2003-07-16 14:03:40 +00:00
CString SongText = THEME->GetMetric("ScreenUnlock", ssprintf("Unlock%dSong", i));
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
{
if (SONGMAN->FindCourse(SongText) != NULL)
text->Command("Diffuse,0,1,0,1");
else
text->Command("Diffuse,0.5,0,0,1");
}
BreakLine(SongText);
2003-07-16 14:03:40 +00:00
text->SetZoom(ScrollingTextZoom);
text->SetTextMaxWidth(MaxWidth, SongText );
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 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 14:03:40 +00:00
item.push_back(text);
this->AddChild(item[i-1]);
if (THEME->GetMetricI("ScreenUnlock", "UnlockTextScroll") == 2)
{
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 14:03:40 +00:00
// set graphic location
IconCount->SetXY( THEME->GetMetricF("ScreenUnlock", "UnlockTextScrollIconX"),
ScrollingTextStartY);
2003-07-16 14:03:40 +00:00
float IconSize = THEME->GetMetricF("ScreenUnlock", "UnlockTextScrollIconSize");
2003-07-16 14:03:40 +00:00
IconCount->SetHeight(IconSize);
IconCount->SetWidth(IconSize);
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 14:03:40 +00:00
ItemIcons.push_back(IconCount);
this->AddChild(ItemIcons[i-1]);
LOG->Trace("Added unlock text %d", i);
2003-07-16 14:03:40 +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") );
SET_XY( PointsUntilNextUnlock );
this->AddChild( &PointsUntilNextUnlock );
this->ClearMessageQueue( SM_BeginFadingOut ); // ignore ScreenAttract's SecsToShow
this->PostScreenMessage( SM_BeginFadingOut,
2003-07-12 20:33:19 +00:00
THEME->GetMetricF("ScreenUnlock", "TimeToDisplay") );
}
void ScreenUnlock::BreakLine(CString& line)
{
2003-07-17 22:56:28 +00:00
for(unsigned i = 1; i < line.size(); i++)
{
if (line[i] == '~' || line[i] == '(')
2003-07-17 22:56:28 +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
}