basic support for scrolling song list in screenunlock (oops, forgot the important files)

This commit is contained in:
Andrew Wong
2003-07-16 13:13:26 +00:00
parent 734813bede
commit 1ef5607405
2 changed files with 79 additions and 0 deletions
+76
View File
@@ -18,6 +18,7 @@
#include "UnlockSystem.h"
#include "SongManager.h"
#include "ActorUtil.h"
#include "Song.h"
ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock")
{
@@ -62,6 +63,68 @@ ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock")
this->AddChild(&Unlocks[i]);
}
// scrolling text
if (THEME->GetMetricI("ScreenUnlock", "UnlockTextScroll") != 0)
{
int NumberUnlocks = THEME->GetMetricF("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++)
{
item[i].LoadFromFont( THEME->GetPathToF("_shared2") );
item[i].SetHorizAlign( Actor::align_left );
CString SongText = THEME->GetMetric("ScreenUnlock",
ssprintf("Unlock%dSong", i));
SongText.MakeUpper();
SongEntry *pSong = GAMESTATE->m_pUnlockingSys->FindSong(SongText);
if (pSong != NULL && pSong->ActualSong != NULL)
{
LOG->Trace("Entry %d, pointer=%d", i, (int)pSong);
SongText = pSong->ActualSong->GetFullDisplayTitle();
}
else if (pSong == NULL) // song is not in library
item[i].Command("Diffuse,0,1,0,1");
else // song is mistyped
item[i].Command("Diffuse,1,0,0,1");
BreakLine(SongText);
item[i].SetZoom(ScrollingTextZoom);
item[i].SetTextMaxWidth(MaxWidth, SongText );
if (pSong->isLocked)
{
item[i].SetText("????????");
item[i].SetZoom(ScrollingTextZoom * 1.99);
}
item[i].SetXY(ScrollingTextX, ScrollingTextStartY);
CString commands;
commands = 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);
LOG->Trace("Updated text %d: %s", i, SongText.c_str() );
item[i].Command(commands);
this->AddChild(&item[i]);
}
}
PointsUntilNextUnlock.SetName( "PointsDisplay" );
if (PointDisplay == "DP" || PointDisplay == "Dance")
@@ -82,3 +145,16 @@ ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock")
this->PostScreenMessage( SM_BeginFadingOut,
THEME->GetMetricF("ScreenUnlock", "TimeToDisplay") );
}
void ScreenUnlock::BreakLine(CString& line)
{
for(unsigned i = 1; i < line.GetLength(); i++)
if (line[i] == '~' || line[i] == '(')
if (line[i-1] == ' ')
{
line[i-1] = '\n';
return;
}
}
+3
View File
@@ -25,4 +25,7 @@ public:
protected:
BitmapText PointsUntilNextUnlock;
Sprite Unlocks[NUM_UNLOCKS]; // support 30 unlocks right now
BitmapText item[NUM_UNLOCKS]; // for scrolling text
void BreakLine(CString& line); // used in scrollingtext
};