void LinkedOptionsMenu::SetChoices( const CStringArray &asChoices ) { ClearChoices(); for( unsigned i = 0; i < asChoices.size(); i++ ) { CString ch = asChoices[i]; BitmapText *bt = new BitmapText; m_Rows.push_back( bt ); bt->LoadFromFont( THEME->GetPathF( m_sName, "menutext" ) ); bt->SetName( "Row" ); bt->SetXY( ROW_OFFSET_X, ROW_OFFSET_Y + (ROW_SPACING_Y * (float)(i % ROWS_PER_PAGE)) ); bt->SetText( ch ); m_Frame.AddChild( bt ); ON_COMMAND( *bt ); } // show first page of choices for( unsigned i = 0; i < asChoices.size() && i < (unsigned)ROWS_PER_PAGE; i++ ) { m_Rows[i]->PlayCommand("TweenOn"); } m_iCurPage = 0; if ( asChoices.size() > (unsigned)ROWS_PER_PAGE ) { m_sprIndicatorDown.PlayCommand("TweenOn"); m_bIndTweenedOn[1] = true; } if ( m_Rows.size() > 0 ) { if ( m_bFocus ) m_Cursor.PlayCommand( "TweenOn" ); m_Cursor.SetXY( CURSOR_OFFSET_X + m_Rows[0]->GetX(), m_Rows[0]->GetY() ); m_Cursor.SetBarWidth( floor(m_Rows[0]->GetZoomedWidth()) ); m_iCurrentSelection = 0; } else { m_iCurrentSelection = -1; m_Cursor.PlayCommand( "TweenOff" ); if ( m_bFocus ) SCREENMAN->PostMessageToTopScreen( m_smChangeMenu, 0.0f ); } }
void ScreenDebugOverlay::Init() { Screen::Init(); // Init debug mappings // TODO: Arch-specific? { g_Mappings.Clear(); g_Mappings.holdForDebug1 = DeviceInput(DEVICE_KEYBOARD, KEY_F3); g_Mappings.holdForDebug2.MakeInvalid(); g_Mappings.holdForSlow = DeviceInput(DEVICE_KEYBOARD, KEY_ACCENT); g_Mappings.holdForFast = DeviceInput(DEVICE_KEYBOARD, KEY_TAB); g_Mappings.toggleMute = DeviceInput(DEVICE_KEYBOARD, KEY_PAUSE); /* TODO: Find a better way of indicating which option is which here. * Maybe we should take a page from ScreenEdit's menus and make * RowDefs()? */ int i=0; g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F8); g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F7); g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F6); i=0; g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C1); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C2); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C3); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C4); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C5); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C6); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C7); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C8); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C9); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C0); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cq); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cw); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ce); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cr); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ct); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cy); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ci); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Co); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cp); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ca); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cs); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cd); g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F5)] = 0; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F6)] = 1; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F7)] = 2; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F8)] = 3; } std::map<std::string,int> iNextDebugButton; int iNextGameplayButton = 0; for (auto *p: *g_pvpSubscribers) { std::string sPageName = p->GetPageName(); DeviceInput di; switch( p->GetType() ) { case IDebugLine::all_screens: di = g_Mappings.debugButton[iNextDebugButton[sPageName]++]; break; case IDebugLine::gameplay_only: di = g_Mappings.gameplayButton[iNextGameplayButton++]; break; } p->m_Button = di; if( find(m_asPages.begin(), m_asPages.end(), sPageName) == m_asPages.end() ) m_asPages.push_back( sPageName ); } m_iCurrentPage = 0; m_bForcedHidden = false; m_Quad.StretchTo( Rage::RectF( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); m_Quad.SetDiffuse( BACKGROUND_COLOR ); this->AddChild( &m_Quad ); // if you're going to add user commands, make sure to have the overrides // set after parsing the metrics. -aj m_textHeader.SetName( "HeaderText" ); m_textHeader.LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "header") ); LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_textHeader ); m_textHeader.SetText( DEBUG_MENU.GetValue() ); this->AddChild( &m_textHeader ); for (auto s = m_asPages.begin(); s != m_asPages.end(); ++s) { int iPage = s - m_asPages.begin(); DeviceInput di; bool b = GetKeyFromMap( g_Mappings.pageButton, iPage, di ); ASSERT( b ); std::string sButton = INPUTMAN->GetDeviceSpecificInputString( di ); BitmapText *p = new BitmapText; p->SetName( "PageText" ); p->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "page") ); LOAD_ALL_COMMANDS_AND_ON_COMMAND( p ); // todo: Y value is still hardcoded. -aj p->SetXY( PAGE_START_X+iPage*PAGE_SPACING_X, SCREEN_TOP+20 ); p->SetText( *s + " (" + sButton + ")" ); m_vptextPages.push_back( p ); this->AddChild( p ); } auto onEachLine = [this](IDebugLine *) { { BitmapText *bt = new BitmapText; bt->SetName( "ButtonText" ); bt->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "line") ); bt->SetHorizAlign( align_right ); bt->SetText( "blah" ); LOAD_ALL_COMMANDS_AND_ON_COMMAND( *bt ); m_vptextButton.push_back( bt ); this->AddChild( bt ); } { BitmapText *bt = new BitmapText; bt->SetName( "FunctionText" ); bt->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "line") ); bt->SetHorizAlign( align_left ); bt->SetText( "blah" ); LOAD_ALL_COMMANDS_AND_ON_COMMAND( *bt ); m_vptextFunction.push_back( bt ); this->AddChild( bt ); } }; std::for_each(g_pvpSubscribers->begin(), g_pvpSubscribers->end(), onEachLine); this->SetVisible( false ); }
void ScreenDebugOverlay::Init() { Screen::Init(); // Init debug mappings // TODO: Arch-specific? { g_Mappings.Clear(); g_Mappings.holdForDebug1 = DeviceInput(DEVICE_KEYBOARD, KEY_F3); g_Mappings.holdForDebug2.MakeInvalid(); g_Mappings.holdForSlow = DeviceInput(DEVICE_KEYBOARD, KEY_ACCENT); g_Mappings.holdForFast = DeviceInput(DEVICE_KEYBOARD, KEY_TAB); /* TODO: Find a better way of indicating which option is which here. * Maybe we should take a page from ScreenEdit's menus and make * RowDefs()? */ int i=0; g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F8); g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F7); g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F6); i=0; g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C1); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C2); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C3); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C4); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C5); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C6); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C7); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C8); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C9); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C0); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cq); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cw); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ce); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cr); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ct); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cy); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ci); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Co); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cp); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_UP); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_DOWN); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_BACK); g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F5)] = 0; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F6)] = 1; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F7)] = 2; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F8)] = 3; } map<RString,int> iNextDebugButton; int iNextGameplayButton = 0; FOREACH( IDebugLine*, *g_pvpSubscribers, p ) { RString sPageName = (*p)->GetPageName(); DeviceInput di; switch( (*p)->GetType() ) { case IDebugLine::all_screens: di = g_Mappings.debugButton[iNextDebugButton[sPageName]++]; break; case IDebugLine::gameplay_only: di = g_Mappings.gameplayButton[iNextGameplayButton++]; break; } (*p)->m_Button = di; if( find(m_asPages.begin(), m_asPages.end(), sPageName) == m_asPages.end() ) m_asPages.push_back( sPageName ); } m_iCurrentPage = 0; m_bForcedHidden = false; m_Quad.StretchTo( RectF( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); m_Quad.SetDiffuse( BACKGROUND_COLOR ); this->AddChild( &m_Quad ); // if you're going to add user commands, make sure to have the overrides // set after parsing the metrics. -aj m_textHeader.SetName( "HeaderText" ); m_textHeader.LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "header") ); LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_textHeader ); m_textHeader.SetText( DEBUG_MENU ); this->AddChild( &m_textHeader ); FOREACH_CONST( RString, m_asPages, s ) { int iPage = s - m_asPages.begin(); DeviceInput di; bool b = GetKeyFromMap( g_Mappings.pageButton, iPage, di ); ASSERT( b ); RString sButton = INPUTMAN->GetDeviceSpecificInputString( di ); BitmapText *p = new BitmapText; p->SetName( "PageText" ); p->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "page") ); LOAD_ALL_COMMANDS_AND_ON_COMMAND( p ); // todo: Y value is still hardcoded. -aj p->SetXY( PAGE_START_X+iPage*PAGE_SPACING_X, SCREEN_TOP+20 ); p->SetText( *s + " (" + sButton + ")" ); m_vptextPages.push_back( p ); this->AddChild( p ); }
void ScreenUnlockStatus::Init() { ScreenAttract::Init(); unsigned iNumUnlocks = UNLOCKMAN->m_UnlockEntries.size(); if( !PREFSMAN->m_bUseUnlockSystem || iNumUnlocks == 0 ) { this->PostScreenMessage( SM_GoToNextScreen, 0 ); return; } unsigned NumUnlocks = UNLOCKMAN->m_UnlockEntries.size(); PointsUntilNextUnlock.LoadFromFont( THEME->GetPathF("Common","normal") ); PointsUntilNextUnlock.SetHorizAlign( align_left ); apActorCommands IconCommand = ICON_COMMAND; for( unsigned i=1; i <= NumUnlocks; i++ ) { // get pertaining UnlockEntry const UnlockEntry &entry = UNLOCKMAN->m_UnlockEntries[i-1]; const Song *pSong = entry.m_Song.ToSong(); if( pSong == NULL) continue; Sprite* pSpr = new Sprite; // new unlock graphic pSpr->Load( THEME->GetPathG("ScreenUnlockStatus",ssprintf("%04d icon", i)) ); // set graphic location pSpr->SetName( ssprintf("Unlock%04d",i) ); LOAD_ALL_COMMANDS_AND_SET_XY( pSpr ); pSpr->RunCommands(IconCommand); Unlocks.push_back(pSpr); if ( !entry.IsLocked() ) this->AddChild(Unlocks[Unlocks.size() - 1]); } // scrolling text if (UNLOCK_TEXT_SCROLL != 0) { float ScrollingTextX = UNLOCK_TEXT_SCROLL_X; float ScrollingTextStartY = UNLOCK_TEXT_SCROLL_START_Y; float ScrollingTextEndY = UNLOCK_TEXT_SCROLL_END_Y; float ScrollingTextZoom = UNLOCK_TEXT_SCROLL_ZOOM; float ScrollingTextRows = UNLOCK_TEXT_SCROLL_ROWS; float MaxWidth = UNLOCK_TEXT_SCROLL_MAX_WIDTH; float SecondsToScroll = TIME_TO_DISPLAY; if (SecondsToScroll > 2) SecondsToScroll--; float SECS_PER_CYCLE = 0; if (UNLOCK_TEXT_SCROLL != 3) SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows + NumUnlocks); else SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows * 3 + NumUnlocks + 4); for(unsigned i = 1; i <= NumUnlocks; i++) { const UnlockEntry &entry = UNLOCKMAN->m_UnlockEntries[i-1]; BitmapText* text = new BitmapText; text->LoadFromFont( THEME->GetPathF("ScreenUnlockStatus","text") ); text->SetHorizAlign( align_left ); text->SetZoom(ScrollingTextZoom); switch( entry.m_Type ) { case UnlockRewardType_Song: { const Song *pSong = entry.m_Song.ToSong(); ASSERT( pSong != NULL ); RString title = pSong->GetDisplayMainTitle(); RString subtitle = pSong->GetDisplaySubTitle(); if( subtitle != "" ) title = title + "\n" + subtitle; text->SetMaxWidth( MaxWidth ); text->SetText( title ); } break; case UnlockRewardType_Course: { const Course *pCourse = entry.m_Course.ToCourse(); ASSERT( pCourse != NULL ); text->SetMaxWidth( MaxWidth ); text->SetText( pCourse->GetDisplayFullTitle() ); text->SetDiffuse( RageColor(0,1,0,1) ); } break; default: text->SetText( "" ); text->SetDiffuse( RageColor(0.5f,0,0,1) ); break; } if( entry.IsLocked() ) { text->SetText("???"); text->SetZoomX(1); } else { // unlocked. change color const Song *pSong = entry.m_Song.ToSong(); RageColor color = RageColor(1,1,1,1); if( pSong ) color = SONGMAN->GetSongGroupColor(pSong->m_sGroupName); text->SetGlobalDiffuseColor(color); } text->SetXY( ScrollingTextX, ScrollingTextStartY ); if (UNLOCK_TEXT_SCROLL == 3 && UNLOCK_TEXT_SCROLL_ROWS + i > NumUnlocks) { // special command for last unlocks when scrolling is in effect float TargetRow = -0.5f + i + UNLOCK_TEXT_SCROLL_ROWS - NumUnlocks; float StopOffPoint = ScrollingTextEndY - TargetRow / UNLOCK_TEXT_SCROLL_ROWS * (ScrollingTextEndY - ScrollingTextStartY); float FirstCycleTime = (UNLOCK_TEXT_SCROLL_ROWS - TargetRow) * SECS_PER_CYCLE; float SecondCycleTime = (6 + TargetRow) * SECS_PER_CYCLE - FirstCycleTime; //LOG->Trace("Target Row: %f", TargetRow); //LOG->Trace("command for icon %d: %s", i, ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime * 2, ScrollingTextEndY).c_str() ); RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime, ScrollingTextEndY); text->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); } else { RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), SECS_PER_CYCLE * (ScrollingTextRows), ScrollingTextEndY); text->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); } item.push_back(text); if (UNLOCK_TEXT_SCROLL >= 2) { Sprite* IconCount = new Sprite; // new unlock graphic IconCount->Load( THEME->GetPathG("ScreenUnlockStatus",ssprintf("%04d icon", i)) ); // set graphic location IconCount->SetXY( UNLOCK_TEXT_SCROLL_ICON_X, ScrollingTextStartY); IconCount->SetHeight(UNLOCK_TEXT_SCROLL_ICON_SIZE); IconCount->SetWidth(UNLOCK_TEXT_SCROLL_ICON_SIZE); if (UNLOCK_TEXT_SCROLL == 3 && UNLOCK_TEXT_SCROLL_ROWS + i > NumUnlocks) { float TargetRow = -0.5f + i + UNLOCK_TEXT_SCROLL_ROWS - NumUnlocks; float StopOffPoint = ScrollingTextEndY - TargetRow / UNLOCK_TEXT_SCROLL_ROWS * (ScrollingTextEndY - ScrollingTextStartY); float FirstCycleTime = (UNLOCK_TEXT_SCROLL_ROWS - TargetRow) * SECS_PER_CYCLE; float SecondCycleTime = (6 + TargetRow) * SECS_PER_CYCLE - FirstCycleTime; //LOG->Trace("Target Row: %f", TargetRow); //LOG->Trace("command for icon %d: %s", i, ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime * 2, ScrollingTextEndY).c_str() ); RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime, ScrollingTextEndY); IconCount->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); } else { RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), SECS_PER_CYCLE * (ScrollingTextRows), ScrollingTextEndY); IconCount->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); } ItemIcons.push_back(IconCount); //LOG->Trace("Added unlock text %d", i); if (UNLOCK_TEXT_SCROLL == 3) { if ( !entry.IsLocked() ) LastUnlocks.push_back(i); } } } } if (UNLOCK_TEXT_SCROLL == 3) { float ScrollingTextX = UNLOCK_TEXT_SCROLL_X; float ScrollingTextStartY = UNLOCK_TEXT_SCROLL_START_Y; float ScrollingTextEndY = UNLOCK_TEXT_SCROLL_END_Y; float ScrollingTextRows = UNLOCK_TEXT_SCROLL_ROWS; float MaxWidth = UNLOCK_TEXT_SCROLL_MAX_WIDTH; float SecondsToScroll = TIME_TO_DISPLAY - 1; float SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows * 3 + NumUnlocks + 4); for(unsigned i=1; i <= UNLOCK_TEXT_SCROLL_ROWS; i++) { if (i > LastUnlocks.size()) continue; unsigned NextIcon = LastUnlocks[LastUnlocks.size() - i]; const UnlockEntry &entry = UNLOCKMAN->m_UnlockEntries[NextIcon-1]; const Song *pSong = entry.m_Song.ToSong(); if( pSong == NULL ) continue; BitmapText* NewText = new BitmapText; NewText->LoadFromFont( THEME->GetPathF("ScreenUnlockStatus","text") ); NewText->SetHorizAlign( align_left ); RString title = pSong->GetDisplayMainTitle(); RString subtitle = pSong->GetDisplaySubTitle(); if( subtitle != "" ) title = title + "\n" + subtitle; NewText->SetZoom(UNLOCK_TEXT_SCROLL_ZOOM); NewText->SetMaxWidth( MaxWidth ); NewText->SetText( title ); RageColor color = SONGMAN->GetSongGroupColor(pSong->m_sGroupName); NewText->SetGlobalDiffuseColor(color); NewText->SetXY(ScrollingTextX, ScrollingTextStartY); { RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;", SECS_PER_CYCLE * (NumUnlocks + 2 * i - 2), SECS_PER_CYCLE * ((ScrollingTextRows - i) * 2 + 1 ), (ScrollingTextStartY + (ScrollingTextEndY - ScrollingTextStartY) * (ScrollingTextRows - i + 0.5) / ScrollingTextRows )); NewText->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); } // new unlock graphic Sprite* NewIcon = new Sprite; NewIcon->Load( THEME->GetPathG("ScreenUnlockStatus",ssprintf("%04d icon", NextIcon)) ); NewIcon->SetXY( UNLOCK_TEXT_SCROLL_ICON_X, ScrollingTextStartY); NewIcon->SetHeight(UNLOCK_TEXT_SCROLL_ICON_SIZE); NewIcon->SetWidth(UNLOCK_TEXT_SCROLL_ICON_SIZE); { RString sCommand = ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;", SECS_PER_CYCLE * (NumUnlocks + 2 * i - 2), SECS_PER_CYCLE * ((ScrollingTextRows - i) * 2 + 1 ), (ScrollingTextStartY + (ScrollingTextEndY - ScrollingTextStartY) * (ScrollingTextRows - i + 0.5) / ScrollingTextRows )); NewIcon->RunCommands( ActorUtil::ParseActorCommands(sCommand) ); } ItemIcons.push_back(NewIcon); item.push_back(NewText); } } // NOTE: the following two loops require the iterator to // be ints because if you decrement an unsigned when it // equals zero, you get the maximum value of an unsigned, // which is still greater than 0. By typecasting it as // an integer, you can achieve -1, which exits the loop. for(int i = item.size() - 1; (int)i >= 0; i--) this->AddChild(item[i]); for(int i = ItemIcons.size() - 1; (int)i >= 0; i--) this->AddChild(ItemIcons[i]); PointsUntilNextUnlock.SetName( "PointsDisplay" ); RString PointDisplay = TYPE_TO_DISPLAY; if (PointDisplay == "DP" || PointDisplay == "Dance") { RString sDP = ssprintf( "%d", (int)UNLOCKMAN->PointsUntilNextUnlock(UnlockRequirement_DancePoints) ); PointsUntilNextUnlock.SetText( sDP ); } else if (PointDisplay == "AP" || PointDisplay == "Arcade") { RString sAP = ssprintf( "%d", (int)UNLOCKMAN->PointsUntilNextUnlock(UnlockRequirement_ArcadePoints) ); PointsUntilNextUnlock.SetText( sAP ); } else if (PointDisplay == "SP" || PointDisplay == "Song") { RString sSP = ssprintf( "%d", (int)UNLOCKMAN->PointsUntilNextUnlock(UnlockRequirement_SongPoints) ); PointsUntilNextUnlock.SetText( sSP ); } PointsUntilNextUnlock.SetZoom( POINTS_ZOOM ); LOAD_ALL_COMMANDS_AND_SET_XY( PointsUntilNextUnlock ); this->AddChild( &PointsUntilNextUnlock ); this->ClearMessageQueue( SM_BeginFadingOut ); // ignore ScreenAttract's SecsToShow this->PostScreenMessage( SM_BeginFadingOut, TIME_TO_DISPLAY ); }
ScreenUnlock::ScreenUnlock( CString sClassName ) : ScreenAttract( sClassName ) { LOG->Trace("ScreenUnlock::ScreenUnlock()"); unsigned NumUnlocks = NUM_UNLOCKS; if (UNLOCKMAN->m_SongEntries.size() < NumUnlocks) NumUnlocks = UNLOCKMAN->m_SongEntries.size(); if (!PREFSMAN->m_bUseUnlockSystem || NumUnlocks == 0) { this->HandleScreenMessage( SM_GoToNextScreen ); return; } PointsUntilNextUnlock.LoadFromFont( THEME->GetPathToF("Common normal") ); PointsUntilNextUnlock.SetHorizAlign( Actor::align_left ); unsigned i; CString IconCommand = ICON_COMMAND; for(i=1; i <= NumUnlocks; i++) { // get pertaining UnlockEntry CString SongTitle = DISPLAYED_SONG(i); if (USE_UNLOCKS_DAT == 1) if ((unsigned)i <= UNLOCKMAN->m_SongEntries.size() ) SongTitle = UNLOCKMAN->m_SongEntries[i-1].m_sSongName; LOG->Trace("UnlockScreen: Searching for %s", SongTitle.c_str()); const UnlockEntry *pSong = UNLOCKMAN->FindLockEntry( SongTitle ); if( pSong == NULL) { LOG->Trace("Can't find song %s", SongTitle.c_str()); continue; } Sprite* entry = new Sprite; // new unlock graphic entry->Load( THEME->GetPathToG(ssprintf("ScreenUnlock %d icon", i)) ); // set graphic location entry->SetName( ssprintf("Unlock%d",i) ); SET_XY( *entry ); entry->Command(IconCommand); Unlocks.push_back(entry); if ( !pSong->IsLocked() ) this->AddChild(Unlocks[Unlocks.size() - 1]); } // scrolling text if (UNLOCK_TEXT_SCROLL != 0) { float ScrollingTextX = UNLOCK_TEXT_SCROLL_X; float ScrollingTextStartY = UNLOCK_TEXT_SCROLL_START_Y; float ScrollingTextEndY = UNLOCK_TEXT_SCROLL_END_Y; float ScrollingTextZoom = UNLOCK_TEXT_SCROLL_ZOOM; float ScrollingTextRows = UNLOCK_TEXT_SCROLL_ROWS; float MaxWidth = UNLOCK_TEXT_SCROLL_MAX_WIDTH; float SecondsToScroll = TIME_TO_DISPLAY; if (SecondsToScroll > 2) SecondsToScroll--; float SECS_PER_CYCLE = 0; if (UNLOCK_TEXT_SCROLL != 3) SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows + NumUnlocks); else SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows * 3 + NumUnlocks + 4); for(i = 1; i <= NumUnlocks; i++) { CString DisplayedSong = DISPLAYED_SONG(i); if (USE_UNLOCKS_DAT == 1) if ((unsigned)i <= UNLOCKMAN->m_SongEntries.size() ) DisplayedSong = UNLOCKMAN->m_SongEntries[i-1].m_sSongName; DisplayedSong.MakeUpper(); const UnlockEntry *pSong = UNLOCKMAN->FindLockEntry(DisplayedSong); if ( pSong == NULL ) // no such song continue; BitmapText* text = new BitmapText; text->LoadFromFont( THEME->GetPathToF("ScreenUnlock text") ); text->SetHorizAlign( Actor::align_left ); text->SetZoom(ScrollingTextZoom); if (pSong && pSong->m_pSong != NULL) { CString title = pSong->m_pSong->GetDisplayMainTitle(); CString subtitle = pSong->m_pSong->GetDisplaySubTitle(); if( subtitle != "" ) title = title + "\n" + subtitle; text->SetMaxWidth( MaxWidth ); text->SetText( title ); } else // song is missing, might be a course { Course *crs = SONGMAN->FindCourse( DisplayedSong ); if (crs != NULL) { text->SetMaxWidth( MaxWidth ); text->SetText( crs->GetFullDisplayTitle() ); text->Command("Diffuse,0,1,0,1"); } else // entry isn't a song or course { text->SetText( "" ); text->Command("Diffuse,0.5,0,0,1"); } } if (pSong != NULL && pSong->m_pSong != NULL) { if( pSong->IsLocked() ) // song is locked { text->SetText("???"); text->SetZoomX(1); } else { // song is unlocked, change color RageColor color = SONGMAN->GetGroupColor(pSong->m_pSong->m_sGroupName); text->SetGlobalDiffuseColor(color); } } text->SetXY(ScrollingTextX, ScrollingTextStartY); if (UNLOCK_TEXT_SCROLL == 3 && UNLOCK_TEXT_SCROLL_ROWS + i > NumUnlocks) { // special command for last unlocks when extreme-style scrolling is in effect float TargetRow = -0.5f + i + UNLOCK_TEXT_SCROLL_ROWS - NumUnlocks; float StopOffPoint = ScrollingTextEndY - TargetRow / UNLOCK_TEXT_SCROLL_ROWS * (ScrollingTextEndY - ScrollingTextStartY); float FirstCycleTime = (UNLOCK_TEXT_SCROLL_ROWS - TargetRow) * SECS_PER_CYCLE; float SecondCycleTime = (6 + TargetRow) * SECS_PER_CYCLE - FirstCycleTime; LOG->Trace("Target Row: %f", TargetRow); LOG->Trace("command for icon %d: %s", i, ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime * 2, ScrollingTextEndY).c_str() ); text->Command( ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime, ScrollingTextEndY) ); } else text->Command( ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), SECS_PER_CYCLE * (ScrollingTextRows), ScrollingTextEndY) ); item.push_back(text); if (UNLOCK_TEXT_SCROLL >= 2) { Sprite* IconCount = new Sprite; // new unlock graphic IconCount->Load( THEME->GetPathToG(ssprintf("ScreenUnlock %d icon", i)) ); // set graphic location IconCount->SetXY( UNLOCK_TEXT_SCROLL_ICON_X, ScrollingTextStartY); IconCount->SetHeight(UNLOCK_TEXT_SCROLL_ICON_SIZE); IconCount->SetWidth(UNLOCK_TEXT_SCROLL_ICON_SIZE); if (UNLOCK_TEXT_SCROLL == 3 && UNLOCK_TEXT_SCROLL_ROWS + i > NumUnlocks) { float TargetRow = -0.5f + i + UNLOCK_TEXT_SCROLL_ROWS - NumUnlocks; float StopOffPoint = ScrollingTextEndY - TargetRow / UNLOCK_TEXT_SCROLL_ROWS * (ScrollingTextEndY - ScrollingTextStartY); float FirstCycleTime = (UNLOCK_TEXT_SCROLL_ROWS - TargetRow) * SECS_PER_CYCLE; float SecondCycleTime = (6 + TargetRow) * SECS_PER_CYCLE - FirstCycleTime; LOG->Trace("Target Row: %f", TargetRow); LOG->Trace("command for icon %d: %s", i, ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime * 2, ScrollingTextEndY).c_str() ); IconCount->Command( ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), FirstCycleTime, StopOffPoint, SecondCycleTime, ScrollingTextEndY) ); } else IconCount->Command( ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;linear,0.1;diffusealpha,0", SECS_PER_CYCLE * (i - 1), SECS_PER_CYCLE * (ScrollingTextRows), ScrollingTextEndY) ); ItemIcons.push_back(IconCount); LOG->Trace("Added unlock text %d", i); if (UNLOCK_TEXT_SCROLL == 3) { if ( !pSong->IsLocked() ) LastUnlocks.push_back(i); } } } } if (UNLOCK_TEXT_SCROLL == 3) { float ScrollingTextX = UNLOCK_TEXT_SCROLL_X; float ScrollingTextStartY = UNLOCK_TEXT_SCROLL_START_Y; float ScrollingTextEndY = UNLOCK_TEXT_SCROLL_END_Y; float ScrollingTextRows = UNLOCK_TEXT_SCROLL_ROWS; float MaxWidth = UNLOCK_TEXT_SCROLL_MAX_WIDTH; float SecondsToScroll = TIME_TO_DISPLAY - 1; float SECS_PER_CYCLE = (float)SecondsToScroll/(ScrollingTextRows * 3 + NumUnlocks + 4); for(i=1; i <= UNLOCK_TEXT_SCROLL_ROWS; i++) { if (i > LastUnlocks.size()) continue; unsigned NextIcon = LastUnlocks[LastUnlocks.size() - i]; CString DisplayedSong = DISPLAYED_SONG(NextIcon); if (USE_UNLOCKS_DAT == 1) { if (NextIcon <= UNLOCKMAN->m_SongEntries.size() ) DisplayedSong = UNLOCKMAN->m_SongEntries[NextIcon-1].m_sSongName; } DisplayedSong.MakeUpper(); const UnlockEntry *pSong = UNLOCKMAN->FindLockEntry(DisplayedSong); if (pSong->m_pSong == NULL) continue; BitmapText* NewText = new BitmapText; NewText->LoadFromFont( THEME->GetPathToF("ScreenUnlock text") ); NewText->SetHorizAlign( Actor::align_left ); CString title = pSong->m_pSong->GetDisplayMainTitle(); CString subtitle = pSong->m_pSong->GetDisplaySubTitle(); if( subtitle != "" ) title = title + "\n" + subtitle; NewText->SetZoom(UNLOCK_TEXT_SCROLL_ZOOM); NewText->SetMaxWidth( MaxWidth ); NewText->SetText( title ); RageColor color = SONGMAN->GetGroupColor(pSong->m_pSong->m_sGroupName); NewText->SetGlobalDiffuseColor(color); NewText->SetXY(ScrollingTextX, ScrollingTextStartY); NewText->Command( ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;", SECS_PER_CYCLE * (NumUnlocks + 2 * i - 2), SECS_PER_CYCLE * ((ScrollingTextRows - i) * 2 + 1 ), (ScrollingTextStartY + (ScrollingTextEndY - ScrollingTextStartY) * (ScrollingTextRows - i + 0.5) / ScrollingTextRows )) ); // new unlock graphic Sprite* NewIcon = new Sprite; NewIcon->Load( THEME->GetPathToG(ssprintf("ScreenUnlock %d icon", NextIcon)) ); // set graphic location NewIcon->SetXY( UNLOCK_TEXT_SCROLL_ICON_X, ScrollingTextStartY); NewIcon->SetHeight(UNLOCK_TEXT_SCROLL_ICON_SIZE); NewIcon->SetWidth(UNLOCK_TEXT_SCROLL_ICON_SIZE); NewIcon->Command( ssprintf("diffusealpha,0;sleep,%f;diffusealpha,1;linear,%f;y,%f;", SECS_PER_CYCLE * (NumUnlocks + 2 * i - 2), SECS_PER_CYCLE * ((ScrollingTextRows - i) * 2 + 1 ), (ScrollingTextStartY + (ScrollingTextEndY - ScrollingTextStartY) * (ScrollingTextRows - i + 0.5) / ScrollingTextRows )) ); ItemIcons.push_back(NewIcon); item.push_back(NewText); } } // NOTE: the following two loops require the iterator to // be ints because if you decrement an unsigned when it // equals zero, you get the maximum value of an unsigned, // which is still greater than 0. By typecasting it as // an integer, you can achieve -1, which exits the loop. for(i = item.size() - 1; (int)i >= 0; i--) this->AddChild(item[i]); for(i = ItemIcons.size() - 1; (int)i >= 0; i--) this->AddChild(ItemIcons[i]); PointsUntilNextUnlock.SetName( "PointsDisplay" ); CString PointDisplay = TYPE_TO_DISPLAY; if (PointDisplay == "DP" || PointDisplay == "Dance") { CString sDP = ssprintf( "%d", (int)UNLOCKMAN->DancePointsUntilNextUnlock() ); PointsUntilNextUnlock.SetText( sDP ); } else if (PointDisplay == "AP" || PointDisplay == "Arcade") { CString sAP = ssprintf( "%d", (int)UNLOCKMAN->ArcadePointsUntilNextUnlock() ); PointsUntilNextUnlock.SetText( sAP ); } else if (PointDisplay == "SP" || PointDisplay == "Song") { CString sSP = ssprintf( "%d", (int)UNLOCKMAN->SongPointsUntilNextUnlock() ); PointsUntilNextUnlock.SetText( sSP ); } PointsUntilNextUnlock.SetZoom( POINTS_ZOOM ); SET_XY( PointsUntilNextUnlock ); this->AddChild( &PointsUntilNextUnlock ); this->ClearMessageQueue( SM_BeginFadingOut ); // ignore ScreenAttract's SecsToShow this->PostScreenMessage( SM_BeginFadingOut, TIME_TO_DISPLAY ); this->SortByDrawOrder(); }