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 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; }