From 1ef5607405979cfaec0329c5e089897da3674e32 Mon Sep 17 00:00:00 2001 From: Andrew Wong Date: Wed, 16 Jul 2003 13:13:26 +0000 Subject: [PATCH] basic support for scrolling song list in screenunlock (oops, forgot the important files) --- stepmania/src/ScreenUnlock.cpp | 76 ++++++++++++++++++++++++++++++++++ stepmania/src/ScreenUnlock.h | 3 ++ 2 files changed, 79 insertions(+) diff --git a/stepmania/src/ScreenUnlock.cpp b/stepmania/src/ScreenUnlock.cpp index 813509b755..8fa53a4ee2 100644 --- a/stepmania/src/ScreenUnlock.cpp +++ b/stepmania/src/ScreenUnlock.cpp @@ -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; + } + +} \ No newline at end of file diff --git a/stepmania/src/ScreenUnlock.h b/stepmania/src/ScreenUnlock.h index f215d8413a..51f70fa1d5 100644 --- a/stepmania/src/ScreenUnlock.h +++ b/stepmania/src/ScreenUnlock.h @@ -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 };