#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" 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 = OptionRow; 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; lGetPathToF("ScreenOptions explanation") ); m_textExplanation.SetXY( EXPLANATION_X, EXPLANATION_Y ); m_textExplanation.SetZoom( EXPLANATION_ZOOM ); m_textExplanation.SetShadowLength( 0 ); m_framePage.AddChild( &m_textExplanation ); InitOptionsText(); PositionItems(); PositionUnderlines(); PositionIcons(); RefreshIcons(); PositionCursors(); UpdateEnabledDisabled(); OnChange(); /* 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; rTrace( "ScreenOptions::~ScreenOptions()" ); } void ScreenOptions::GetWidthXY( PlayerNumber pn, int iRow, int &iWidthOut, int &iXOut, int &iYOut ) { bool bExitRow = iRow == m_iNumOptionRows; bool bLotsOfOptions = m_bRowIsLong[iRow]; int iOptionInRow = bExitRow ? 0 : bLotsOfOptions ? pn : m_iSelectedOption[pn][iRow]; BitmapText &text = m_textItems[iRow][iOptionInRow]; iWidthOut = int(roundf( text.GetWidestLineWidthInSourcePixels() * text.GetZoomX() )); iXOut = int(roundf( text.GetDestX() )); /* We update m_fRowY, change colors and tween items, and then tween rows to * their final positions. (This is so we don't tween colors, too.) m_fRowY * is the actual destination position, even though we may not have set up the * tween yet. */ iYOut = int(roundf( m_fRowY[iRow] )); } void ScreenOptions::InitOptionsText() { // init m_textItems from optionLines int i; for( 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 ); // init all text in this line and count the width of the line float fX = ITEMS_START_X; // indent 70 pixels for( unsigned j=0; jGetPathToF("ScreenOptions item") ); option.SetText( optline.choices[j] ); option.SetZoom( ITEMS_ZOOM ); option.EnableShadow( false ); // set the XY position of each item in the line float fItemWidth = option.GetWidestLineWidthInSourcePixels() * option.GetZoomX(); fX += fItemWidth/2; option.SetXY( fX, fY ); fX += fItemWidth/2 + ITEMS_GAP_X; } m_bRowIsLong[i] = fX > SCREEN_RIGHT-40; // goes off edge of screen if( m_bRowIsLong[i] ) { // re-init with "long row" style for( unsigned j=0; jIsHumanPlayer(p) ) continue; BitmapText &option = m_textItems[i][p]; const int iChoiceInRow = m_iSelectedOption[p][i]; option.LoadFromFont( THEME->GetPathToF("ScreenOptions item") ); option.SetText( m_OptionRow[i].choices[iChoiceInRow] ); option.SetZoom( ITEMS_ZOOM ); option.EnableShadow( false ); option.SetY( fY ); /* if choices are locked together, center the item. */ if( optline.bOneChoiceForAllPlayers ) option.SetX( (ITEM_X[0]+ITEM_X[1])/2 ); else option.SetX( ITEM_X[p] ); UpdateText( (PlayerNumber)p, j ); } } } BitmapText &option = m_textItems[i][0]; option.LoadFromFont( THEME->GetPathToF("ScreenOptions item") ); option.SetText( "EXIT" ); option.SetZoom( ITEMS_ZOOM ); option.SetShadowLength( 0 ); float fY = ITEMS_START_Y + ITEMS_SPACING_Y*i; option.SetXY( CENTER_X, fY ); } void ScreenOptions::PositionUnderlines() { // Set the position of the underscores showing the current choice for each option line. for( int p=0; p