void OptionRow::LoadExit() { m_RowType = OptionRow::ROW_EXIT; m_RowDef.name = EXIT_NAME; m_RowDef.choices.push_back( "" ); BitmapText *bt = new BitmapText; m_textItems.push_back( bt ); bt->LoadFromFont( THEME->GetPathF(m_sType,"item") ); CString sText = "Exit"; PrepareItemText( sText ); bt->SetText( sText ); bt->RunCommands( ITEMS_ON_COMMAND ); bt->SetShadowLength( 0 ); bt->SetX( ITEMS_LONG_ROW_SHARED_X ); m_Frame.AddChild( bt ); FOREACH_PlayerNumber( p ) m_OptionIcons[p].SetHidden( true ); m_sprBullet.SetHidden( true ); m_textTitle.SetHidden( true ); }
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 ); }
void OptionRow::AfterImportOptions() { // Make all selections the same if bOneChoiceForAllPlayers // Hack: we only import active players, so if only player 2 is imported, // we need to copy p2 to p1, not p1 to p2. if( m_RowDef.bOneChoiceForAllPlayers ) { PlayerNumber pnCopyFrom = GAMESTATE->m_MasterPlayerNumber; if( GAMESTATE->m_MasterPlayerNumber == PLAYER_INVALID ) pnCopyFrom = PLAYER_1; FOREACH_PlayerNumber( p ) m_vbSelected[p] = m_vbSelected[pnCopyFrom]; } FOREACH_PlayerNumber( p ) { switch( m_RowDef.selectType ) { case SELECT_ONE: { /* Make sure the row actually has a selection. */ bool bHasASelection = false; for( unsigned i=0; i<m_vbSelected[p].size(); i++ ) { if( m_vbSelected[p][i] ) bHasASelection = true; } if( !bHasASelection && !m_vbSelected[p].empty() ) m_vbSelected[p][0] = true; m_iChoiceInRowWithFocus[p] = GetOneSelection(p, true); // focus on the selection we just set } break; case SELECT_MULTIPLE: case SELECT_NONE: m_iChoiceInRowWithFocus[p] = 0; break; default: ASSERT(0); } } // init row icons FOREACH_HumanPlayer( p ) { LoadOptionIcon( p, "" ); } // If the items will go off the edge of the screen, then re-init with the "long row" style. { BitmapText bt; bt.LoadFromFont( THEME->GetPathF(m_sType,"item") ); bt.RunCommands( ITEMS_ON_COMMAND ); float fX = ITEMS_START_X; for( unsigned c=0; c<m_RowDef.choices.size(); c++ ) { CString sText = m_RowDef.choices[c]; PrepareItemText( sText ); bt.SetText( sText ); fX += bt.GetZoomedWidth(); if( c != m_RowDef.choices.size()-1 ) fX += ITEMS_GAP_X; if( fX > ITEMS_END_X ) { m_RowDef.layoutType = LAYOUT_SHOW_ONE_IN_ROW; break; } } } // // load m_textItems // switch( m_RowDef.layoutType ) { case LAYOUT_SHOW_ONE_IN_ROW: // init text FOREACH_HumanPlayer( p ) { BitmapText *bt = new BitmapText; m_textItems.push_back( bt ); const int iChoiceInRowWithFocus = m_iChoiceInRowWithFocus[p]; bt->LoadFromFont( THEME->GetPathF(m_sType,"item") ); CString sText = (iChoiceInRowWithFocus==-1) ? "" : m_RowDef.choices[iChoiceInRowWithFocus]; // ugly hack for Speed mods --infamouspat PrepareItemText( sText ); bt->SetText( sText ); bt->RunCommands( ITEMS_ON_COMMAND ); bt->SetShadowLength( 0 ); if( m_RowDef.bOneChoiceForAllPlayers ) { bt->SetX( ITEMS_LONG_ROW_SHARED_X ); break; // only initialize one item since it's shared } else { bt->SetX( ITEMS_LONG_ROW_X.GetValue(p) ); } } // init underlines FOREACH_HumanPlayer( p ) { OptionsCursor *ul = new OptionsCursor; m_Underline[p].push_back( ul ); ul->Load( m_sType, OptionsCursor::underline ); ul->Set( p ); int iWidth, iX, iY; GetWidthXY( p, 0, iWidth, iX, iY ); ul->SetX( float(iX) ); ul->SetWidth( float(iWidth) ); } break; case LAYOUT_SHOW_ALL_IN_ROW: { float fX = ITEMS_START_X; for( unsigned c=0; c<m_RowDef.choices.size(); c++ ) { // init text BitmapText *bt = new BitmapText; m_textItems.push_back( bt ); bt->LoadFromFont( THEME->GetPathF(m_sType,"item") ); CString sText = m_RowDef.choices[c]; PrepareItemText( sText ); bt->SetText( sText ); bt->RunCommands( ITEMS_ON_COMMAND ); bt->SetShadowLength( 0 ); // set the X position of each item in the line float fItemWidth = bt->GetZoomedWidth(); fX += fItemWidth/2; bt->SetX( fX ); // init underlines FOREACH_HumanPlayer( p ) { OptionsCursor *ul = new OptionsCursor; m_Underline[p].push_back( ul ); ul->Load( m_sType, OptionsCursor::underline ); ul->Set( p ); ul->SetX( fX ); ul->SetWidth( truncf(fItemWidth) ); } fX += fItemWidth/2 + ITEMS_GAP_X; } } break; default: ASSERT(0); } for( unsigned c=0; c<m_textItems.size(); c++ ) m_Frame.AddChild( m_textItems[c] ); FOREACH_PlayerNumber( p ) for( unsigned c=0; c<m_Underline[p].size(); c++ ) m_Frame.AddChild( m_Underline[p][c] ); m_textTitle.LoadFromFont( THEME->GetPathF(m_sType,"title") ); CString sTitle = GetRowTitle(); m_textTitle.SetText( sTitle ); m_textTitle.SetX( LABELS_X ); m_textTitle.RunCommands( LABELS_ON_COMMAND ); m_sprBullet.Load( THEME->GetPathG(m_sType,"bullet") ); m_sprBullet.SetX( ARROWS_X ); // // HACK: Set focus to one item in the row, which is "go down" // if( m_bFirstItemGoesDown && m_RowDef.name != "Speed" ) FOREACH_PlayerNumber( p ) m_iChoiceInRowWithFocus[p] = 0; }