#include "global.h" /* ----------------------------------------------------------------------------- Class: ScreenOptions Desc: See header. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. Chris Danford Glenn Maynard ----------------------------------------------------------------------------- */ #include "ScreenOptions.h" #include "RageUtil.h" #include "ScreenManager.h" #include "PrefsManager.h" #include "GameConstantsAndTypes.h" #include "RageLog.h" #include "GameState.h" #include "ThemeManager.h" #include "InputMapper.h" const float ITEM_X[NUM_PLAYERS] = { 260, 420 }; #define ICONS_X( p ) THEME->GetMetricF("ScreenOptions",ssprintf("IconsP%dX",p+1)) #define ARROWS_X THEME->GetMetricF("ScreenOptions","ArrowsX") #define LABELS_X THEME->GetMetricF("ScreenOptions","LabelsX") #define LABELS_ZOOM THEME->GetMetricF("ScreenOptions","LabelsZoom") #define LABELS_H_ALIGN THEME->GetMetricI("ScreenOptions","LabelsHAlign") #define ITEMS_ZOOM THEME->GetMetricF("ScreenOptions","ItemsZoom") #define ITEMS_START_X THEME->GetMetricF("ScreenOptions","ItemsStartX") #define ITEMS_GAP_X THEME->GetMetricF("ScreenOptions","ItemsGapX") #define ITEMS_START_Y THEME->GetMetricF("ScreenOptions","ItemsStartY") #define ITEMS_SPACING_Y THEME->GetMetricF("ScreenOptions","ItemsSpacingY") #define EXPLANATION_X THEME->GetMetricF("ScreenOptions","ExplanationX") #define EXPLANATION_Y THEME->GetMetricF("ScreenOptions","ExplanationY") #define EXPLANATION_ZOOM THEME->GetMetricF("ScreenOptions","ExplanationZoom") #define COLOR_SELECTED THEME->GetMetricC("ScreenOptions","ColorSelected") #define COLOR_NOT_SELECTED THEME->GetMetricC("ScreenOptions","ColorNotSelected") #define NUM_SHOWN_ITEMS THEME->GetMetricI("ScreenOptions","NumShownItems") ScreenOptions::ScreenOptions( CString sClassName, bool bEnableTimer ) : Screen("ScreenOptions") { LOG->Trace( "ScreenOptions::ScreenOptions()" ); m_sName = sClassName; m_SoundChangeCol.Load( THEME->GetPathToS("ScreenOptions change") ); m_SoundNextRow.Load( THEME->GetPathToS("ScreenOptions next") ); m_SoundPrevRow.Load( THEME->GetPathToS("ScreenOptions prev") ); m_SoundStart.Load( THEME->GetPathToS("Common start") ); m_Menu.Load( sClassName, bEnableTimer, false ); // no style icon this->AddChild( &m_Menu ); // add everything to m_framePage so we can animate everything at once this->AddChild( &m_framePage ); m_sprPage.Load( THEME->GetPathToG(sClassName+" page") ); m_sprPage.SetXY( CENTER_X, CENTER_Y ); m_framePage.AddChild( &m_sprPage ); for( int p=0; pTrace( "ScreenOptions::Set()" ); m_InputMode = im; m_OptionRow = OptionRows; m_iNumOptionRows = iNumOptionLines; m_bLoadExplanations = bLoadExplanations; this->ImportOptions(); for( unsigned l=0; lIsHumanPlayer(p) ) continue; // skip m_Highlight[p].Load( (PlayerNumber)p, false ); m_framePage.AddChild( &m_Highlight[p] ); } // init underlines for( p=0; pIsHumanPlayer(p) ) continue; // skip for( int l=0; l & textItems = m_textItems[r]; const OptionRow &optline = m_OptionRow[r]; unsigned c; m_framePage.AddChild( &m_sprBullets[r] ); m_framePage.AddChild( &m_textTitles[r] ); float fX = ITEMS_START_X; // indent 70 pixels for( c=0; cLoadFromFont( THEME->GetPathToF("ScreenOptions item") ); bt->SetText( optline.choices[c] ); bt->SetZoom( ITEMS_ZOOM ); bt->EnableShadow( false ); // set the X position of each item in the line float fItemWidth = bt->GetWidestLineWidthInSourcePixels() * bt->GetZoomX(); fX += fItemWidth/2; bt->SetX( fX ); fX += fItemWidth/2 + ITEMS_GAP_X; } if( fX > SCREEN_RIGHT-40 ) { // It goes off the edge of the screen. Re-init with the "long row" style. m_bRowIsLong[r] = true; for( unsigned j=0; jIsHumanPlayer(p) ) continue; BitmapText *bt = new BitmapText; textItems.push_back( bt ); const int iChoiceInRow = m_iSelectedOption[p][r]; bt->LoadFromFont( THEME->GetPathToF("ScreenOptions item") ); bt->SetText( optline.choices[iChoiceInRow] ); bt->SetZoom( ITEMS_ZOOM ); bt->EnableShadow( false ); /* if choices are locked together, center the item. */ if( optline.bOneChoiceForAllPlayers ) bt->SetX( (ITEM_X[0]+ITEM_X[1])/2 ); else bt->SetX( ITEM_X[p] ); /* If bOneChoiceForAllPlayers, then only initialize one text item. */ if( optline.bOneChoiceForAllPlayers ) break; } } for( c=0; cLoadFromFont( THEME->GetPathToF("ScreenOptions item") ); bt->SetText( "EXIT" ); bt->SetZoom( ITEMS_ZOOM ); bt->SetShadowLength( 0 ); float fY = ITEMS_START_Y + ITEMS_SPACING_Y*m_iNumOptionRows; bt->SetXY( CENTER_X, fY ); m_framePage.AddChild( bt ); } // add explanation here so it appears on top m_textExplanation.LoadFromFont( THEME->GetPathToF("ScreenOptions explanation") ); m_textExplanation.SetXY( EXPLANATION_X, EXPLANATION_Y ); m_textExplanation.SetZoom( EXPLANATION_ZOOM ); m_textExplanation.SetShadowLength( 0 ); m_framePage.AddChild( &m_textExplanation ); PositionItems(); PositionUnderlines(); PositionIcons(); CHECKPOINT; RefreshIcons(); CHECKPOINT; PositionCursors(); CHECKPOINT; UpdateEnabledDisabled(); CHECKPOINT; OnChange(); CHECKPOINT; /* It's tweening into position, but on the initial tween-in we only want to * tween in the whole page at once. Since the tweens are nontrivial, it's * easiest to queue the tweens and then force them to finish. */ for( r=0; rFinishTweening(); } for( int p=0; pTrace( "ScreenOptions::~ScreenOptions()" ); for( int i=0; iGetPathToF("ScreenOptions title") ); CString sText = optline.name; title.SetText( sText ); title.SetXY( LABELS_X, fY ); title.SetZoom( LABELS_ZOOM ); title.SetHorizAlign( (Actor::HorizAlign)LABELS_H_ALIGN ); title.SetVertAlign( Actor::align_middle ); title.EnableShadow( false ); Sprite &bullet = m_sprBullets[i]; bullet.Load( THEME->GetPathToG("ScreenOptions bullet") ); bullet.SetXY( ARROWS_X, fY ); // set the Y position of each item in the line for( unsigned c=0; cSetY( fY ); } } void ScreenOptions::PositionUnderlines() { // Set the position of the underscores showing the current choice for each option line. for( int p=0; pIsHumanPlayer(p) ) continue; // skip for( int i=0; i