From 916e08b55c08d14b532285758b40e4a8e1a960c9 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 26 Jul 2003 09:53:15 +0000 Subject: [PATCH] fix selection glow in GroupList --- stepmania/src/GroupList.cpp | 102 ++++++++++++++++++++++-------------- stepmania/src/GroupList.h | 5 +- 2 files changed, 65 insertions(+), 42 deletions(-) diff --git a/stepmania/src/GroupList.cpp b/stepmania/src/GroupList.cpp index bea712c6eb..7d7a1d0fd2 100644 --- a/stepmania/src/GroupList.cpp +++ b/stepmania/src/GroupList.cpp @@ -26,11 +26,10 @@ GroupList::GroupList() GroupList::~GroupList() { - for( unsigned i = 0; i < m_Frames.size(); ++i ) + for( unsigned i = 0; i < m_sprButtons.size(); ++i ) { - delete m_Frames[i]; delete m_sprButtons[i]; - delete m_screenLabels[i]; + delete m_textLabels[i]; } } @@ -49,28 +48,31 @@ void GroupList::Load( const CStringArray& asGroupNames ) for( unsigned i=0; i < m_asLabels.size(); i++ ) { - ActorFrame *frame = new ActorFrame; - frame->SetXY( START_X + i*SPACING_X, START_Y + i*SPACING_Y ); - m_Frames.push_back(frame); - m_Frame.AddChild( frame ); + Sprite *button = new Sprite; + BitmapText *label = new BitmapText; - Sprite *spr = new Sprite; - m_sprButtons.push_back(spr); - spr->Load( THEME->GetPathToG("GroupList bar") ); - frame->AddChild( spr ); + m_sprButtons.push_back( button ); + m_textLabels.push_back( label ); - BitmapText *text = new BitmapText; - m_screenLabels.push_back(text); - text->LoadFromFont( THEME->GetPathToF("GroupList label") ); - text->SetShadowLength( 2 ); - text->SetText( SONGMAN->ShortenGroupName( asGroupNames[i] ) ); - frame->AddChild( text ); + button->Load( THEME->GetPathToG("GroupList bar") ); + label->LoadFromFont( THEME->GetPathToF("GroupList label") ); + label->SetShadowLength( 2 ); + label->SetText( SONGMAN->ShortenGroupName( asGroupNames[i] ) ); + + m_Frame.AddChild( button ); + m_Frame.AddChild( label ); + + button->SetXY( START_X + i*SPACING_X, START_Y + i*SPACING_Y ); + label->SetXY( START_X + i*SPACING_X, START_Y + i*SPACING_Y ); if( i == 0 ) - text->TurnRainbowOn(); - else { - text->TurnRainbowOff(); - text->SetDiffuse( SONGMAN->GetGroupColor(asGroupNames[i]) ); + { + label->TurnRainbowOn(); + } + else + { + label->TurnRainbowOff(); + label->SetDiffuse( SONGMAN->GetGroupColor(asGroupNames[i]) ); } m_bHidden.push_back( ItemIsOnScreen(i) ); @@ -83,20 +85,21 @@ void GroupList::Load( const CStringArray& asGroupNames ) void GroupList::ResetTextSize( int i ) { - BitmapText *text = m_screenLabels[i]; - const float fTextWidth = (float)text->GetWidestLineWidthInSourcePixels(); + BitmapText *label = m_textLabels[i]; + const float fTextWidth = (float)label->GetWidestLineWidthInSourcePixels(); const float fButtonWidth = m_sprButtons[i]->GetZoomedWidth(); float fZoom = fButtonWidth/fTextWidth; fZoom = min( fZoom, 0.8f ); - text->SetZoomX( fZoom ); - text->SetZoomY( 0.8f ); + label->SetZoomX( fZoom ); + label->SetZoomY( 0.8f ); } void GroupList::BeforeChange() { - m_Frames[m_iSelection]->Command( LOSE_FOCUS_COMMAND ); + m_sprButtons[m_iSelection]->Command( LOSE_FOCUS_COMMAND ); + m_textLabels[m_iSelection]->Command( LOSE_FOCUS_COMMAND ); } @@ -106,7 +109,9 @@ void GroupList::AfterChange() m_Frame.Command( SCROLL_TWEEN_COMMAND ); m_Frame.SetY( -m_iTop*SPACING_Y ); - m_Frames[m_iSelection]->Command( GAIN_FOCUS_COMMAND ); + m_sprButtons[m_iSelection]->Command( GAIN_FOCUS_COMMAND ); + m_textLabels[m_iSelection]->Command( GAIN_FOCUS_COMMAND ); + for( int i=0; i < (int) m_asLabels.size(); i++ ) { const bool IsHidden = !ItemIsOnScreen(i); @@ -115,12 +120,12 @@ void GroupList::AfterChange() if( IsHidden && !WasHidden ) { m_sprButtons[i]->Command( HIDE_ITEM_COMMAND ); - m_screenLabels[i]->Command( HIDE_ITEM_COMMAND ); + m_textLabels[i]->Command( HIDE_ITEM_COMMAND ); } else if( !IsHidden && WasHidden ) { m_sprButtons[i]->Command( SHOW_ITEM_COMMAND ); - m_screenLabels[i]->Command( SHOW_ITEM_COMMAND ); + m_textLabels[i]->Command( SHOW_ITEM_COMMAND ); ResetTextSize( i ); } @@ -186,18 +191,27 @@ void GroupList::TweenOnScreen() for( int i=0; i < (int) m_asLabels.size(); i++ ) { const int offset = max(0, i-m_iTop); - m_Frames[i]->SetX( 400 ); - m_Frames[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_END ); - m_Frames[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_END ); - m_Frames[i]->SetX( 0 ); + + m_sprButtons[i]->SetX( 400 ); + m_textLabels[i]->SetX( 400 ); + + m_sprButtons[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_END ); + m_textLabels[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_END ); + + m_sprButtons[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_END ); + m_textLabels[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_END ); + + m_sprButtons[i]->SetX( 0 ); + m_textLabels[i]->SetX( 0 ); /* If this item isn't visible, hide it and skip tweens. */ if( !ItemIsOnScreen(i) ) { m_sprButtons[i]->Command( HIDE_ITEM_COMMAND ); - m_screenLabels[i]->Command( HIDE_ITEM_COMMAND ); + m_textLabels[i]->Command( HIDE_ITEM_COMMAND ); + m_sprButtons[i]->FinishTweening(); - m_screenLabels[i]->FinishTweening(); + m_textLabels[i]->FinishTweening(); } } } @@ -208,11 +222,21 @@ void GroupList::TweenOffScreen() { const int offset = max(0, i-m_iTop); if( i == m_iSelection ) - m_Frames[i]->BeginTweening( 1.0f, TWEEN_BOUNCE_BEGIN ); + { + m_sprButtons[i]->BeginTweening( 1.0f, TWEEN_BOUNCE_BEGIN ); + m_textLabels[i]->BeginTweening( 1.0f, TWEEN_BOUNCE_BEGIN ); + } else - m_Frames[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_BEGIN ); - m_Frames[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_BEGIN ); - m_Frames[i]->SetX( 400 ); + { + m_sprButtons[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_BEGIN ); + m_textLabels[i]->BeginTweening( 0.1f*offset, TWEEN_BOUNCE_BEGIN ); + } + + m_sprButtons[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_BEGIN ); + m_textLabels[i]->BeginTweening( 0.2f, TWEEN_BOUNCE_BEGIN ); + + m_sprButtons[i]->SetX( 400 ); + m_textLabels[i]->SetX( 400 ); } } diff --git a/stepmania/src/GroupList.h b/stepmania/src/GroupList.h index f00df2331b..dbe983749a 100644 --- a/stepmania/src/GroupList.h +++ b/stepmania/src/GroupList.h @@ -7,10 +7,9 @@ class GroupList: public ActorFrame { ActorFrame m_Frame; - vector m_Frames; vector m_sprButtons; - vector m_screenLabels; - vector m_asLabels; + vector m_textLabels; + vector m_asLabels; vector m_bHidden;