#include "global.h" #include "GroupList.h" #include "ThemeManager.h" #include "SongManager.h" /* If this actor is used anywhere other than SelectGroup, we * can add a setting that changes which metric group we pull * settings out of, so it can be configured separately. */ #define BUTTON_X THEME->GetMetricF("ScreenSelectGroup","ButtonX") #define BUTTON_START_Y THEME->GetMetricF("ScreenSelectGroup","ButtonStartY") #define BUTTON_SPACING_Y THEME->GetMetricF("ScreenSelectGroup","ButtonSpacingY") #define BUTTON_SELECTED_X THEME->GetMetricF("ScreenSelectGroup","ButtonSelectedX") GroupList::GroupList() { m_iSelection = m_iTop = 0; } void GroupList::DoneAddingGroups() { unsigned i; for( i=0; iGetPathTo("Graphics","select group button") ); m_sprButton[i].SetXY( BUTTON_X, BUTTON_START_Y + i*BUTTON_SPACING_Y ); this->AddChild( &m_sprButton[i] ); this->AddChild( &m_screenLabels[i] ); } for( i=0; iGetPathTo("Fonts","select group button label") ); m_screenLabels[i].SetXY( BUTTON_X, BUTTON_START_Y + i*BUTTON_SPACING_Y ); m_screenLabels[i].SetShadowLength( 2 ); CString sGroupName = m_textLabels[i]; } SetLabels(); AfterChange(); } void GroupList::SetLabels() { for( unsigned i=0; iShortenGroupName( label ) ); float fTextWidth = (float)m_screenLabels[i].GetWidestLineWidthInSourcePixels(); float fButtonWidth = m_sprButton[i].GetZoomedWidth(); float fZoom = fButtonWidth/fTextWidth; fZoom = min( fZoom, 0.8f ); m_screenLabels[i].SetZoomX( fZoom ); m_screenLabels[i].SetZoomY( 0.8f ); if( m_iTop+i == 0 ) m_screenLabels[i].TurnRainbowOn(); else { m_screenLabels[i].TurnRainbowOff(); m_screenLabels[i].SetDiffuse( SONGMAN->GetGroupColor(label) ); } } } void GroupList::BeforeChange() { int iSel = m_iSelection-m_iTop; m_sprButton[iSel].BeginTweening( 0.2f ); m_sprButton[iSel].SetTweenX( BUTTON_X ); m_sprButton[iSel].SetEffectNone(); m_screenLabels[iSel].BeginTweening( 0.2f ); m_screenLabels[iSel].SetTweenX( BUTTON_X ); m_screenLabels[iSel].SetEffectNone(); } void GroupList::AfterChange() { int iSel = m_iSelection-m_iTop; m_sprButton[iSel].StopTweening(); m_sprButton[iSel].BeginTweening( 0.2f ); m_sprButton[iSel].SetTweenX( BUTTON_SELECTED_X ); m_sprButton[iSel].SetEffectGlowCamelion(); m_screenLabels[iSel].StopTweening(); m_screenLabels[iSel].BeginTweening( 0.2f ); m_screenLabels[iSel].SetTweenX( BUTTON_SELECTED_X ); m_screenLabels[iSel].SetEffectGlowCamelion(); } void GroupList::Up() { BeforeChange(); if( m_iSelection == 0 ) SetSelection(m_textLabels.size()-1); else SetSelection(m_iSelection-1); AfterChange(); } void GroupList::Down() { BeforeChange(); SetSelection((m_iSelection+1) % m_textLabels.size()); AfterChange(); } void GroupList::AddGroup(CString name) { m_textLabels.push_back(name); } void GroupList::SetSelection( unsigned sel ) { BeforeChange(); m_iSelection=sel; if( m_textLabels.size() <= MAX_GROUPS_ONSCREEN || sel <= MAX_GROUPS_ONSCREEN/2 ) m_iTop = 0; else if ( sel >= m_textLabels.size() - MAX_GROUPS_ONSCREEN/2 ) m_iTop = m_textLabels.size() - MAX_GROUPS_ONSCREEN; else m_iTop = sel - MAX_GROUPS_ONSCREEN/2; /* The current selection must always be visible. */ ASSERT( m_iTop <= m_iSelection ); ASSERT( m_iTop+MAX_GROUPS_ONSCREEN > m_iSelection ); SetLabels(); AfterChange(); } void GroupList::TweenOnScreen() { for( unsigned i=0; i