avoid global ThemeMetric<apActorCommands>

This commit is contained in:
Glenn Maynard
2006-08-21 21:26:02 +00:00
parent 2b879ed23a
commit c819c74ce6
3 changed files with 34 additions and 31 deletions
+12 -7
View File
@@ -420,15 +420,20 @@ StartX=0
StartY=-136
SpacingX=0
SpacingY=28
GainFocusGroupCommand=stoptweening;linear,0.2;x,-40
LoseFocusGroupCommand=stoptweening;linear,0.2;x,0
GainFocusItemCommand=glowshift;effectperiod,0.5
LoseFocusItemCommand=stopeffect
HideItemCommand=linear,0.2;diffusealpha,0
ShowItemCommand=stoptweening;linear,0.2;diffusealpha,1;zoom,1.0;
ButtonFrameGainFocusCommand=stoptweening;linear,0.2;x,-40
ButtonFrameLoseFocusCommand=stoptweening;linear,0.2;x,0
ButtonGainFocusCommand=glowshift;effectperiod,0.5
ButtonLoseFocusCommand=stopeffect
LabelGainFocusCommand=glowshift;effectperiod,0.5
LabelLoseFocusCommand=stopeffect
ButtonHideItemCommand=linear,0.2;diffusealpha,0
ButtonShowItemCommand=stoptweening;linear,0.2;diffusealpha,1;zoom,1.0;
LabelHideItemCommand=linear,0.2;diffusealpha,0
LabelShowItemCommand=stoptweening;linear,0.2;diffusealpha,1;zoom,1.0;
# This just selects the type of tweening used for scrolling the list; it shouldn't actually
# queue any commands.
ScrollTweenCommand=stoptweening;linear,0.2;
FrameScrollTweenCommand=stoptweening;linear,0.2;
[MusicList]
NumColumns=4
+17 -20
View File
@@ -4,6 +4,7 @@
#include "SongManager.h"
#include "RageLog.h"
#include "ThemeMetric.h"
#include "ActorUtil.h"
/* If this actor is used anywhere other than SelectGroup, we
* can add a setting that changes which metric group we pull
@@ -12,13 +13,6 @@ static const ThemeMetric<float> START_X ("GroupList","StartX");
static const ThemeMetric<float> START_Y ("GroupList","StartY");
static const ThemeMetric<float> SPACING_X ("GroupList","SpacingX");
static const ThemeMetric<float> SPACING_Y ("GroupList","SpacingY");
static const ThemeMetric<apActorCommands> SCROLL_TWEEN_COMMAND ("GroupList","ScrollTweenCommand");
static const ThemeMetric<apActorCommands> GAIN_FOCUS_ITEM_COMMAND ("GroupList","GainFocusItemCommand");
static const ThemeMetric<apActorCommands> LOSE_FOCUS_ITEM_COMMAND ("GroupList","LoseFocusItemCommand");
static const ThemeMetric<apActorCommands> GAIN_FOCUS_GROUP_COMMAND ("GroupList","GainFocusGroupCommand");
static const ThemeMetric<apActorCommands> LOSE_FOCUS_GROUP_COMMAND ("GroupList","LoseFocusGroupCommand");
static const ThemeMetric<apActorCommands> HIDE_ITEM_COMMAND ("GroupList","HideItemCommand");
static const ThemeMetric<apActorCommands> SHOW_ITEM_COMMAND ("GroupList","ShowItemCommand");
const int MAX_GROUPS_ONSCREEN = 7;
@@ -48,13 +42,23 @@ void GroupList::Load( const vector<RString>& asGroupNames )
{
m_asLabels = asGroupNames;
m_Frame.SetName( "Frame" );
this->AddChild( &m_Frame );
ActorUtil::LoadAllCommands( m_Frame, "GroupList" );
for( unsigned i=0; i < m_asLabels.size(); i++ )
{
Sprite *button = new Sprite;
button->SetName( "Button" );
ActorUtil::LoadAllCommands( *button, "GroupList" );
BitmapText *label = new BitmapText;
label->SetName( "Label" );
ActorUtil::LoadAllCommands( *label, "GroupList" );
ActorFrame *frame = new ActorFrame;
frame->SetName( "ButtonFrame" );
ActorUtil::LoadAllCommands( *frame, "GroupList" );
m_sprButtons.push_back( button );
m_textLabels.push_back( label );
@@ -105,16 +109,14 @@ void GroupList::ResetTextSize( int i )
void GroupList::BeforeChange()
{
m_sprButtons[m_iSelection]->RunCommands( LOSE_FOCUS_ITEM_COMMAND );
m_textLabels[m_iSelection]->RunCommands( LOSE_FOCUS_ITEM_COMMAND );
m_ButtonFrames[m_iSelection]->RunCommands( LOSE_FOCUS_GROUP_COMMAND );
m_ButtonFrames[m_iSelection]->PlayCommand( "LoseFocus" );
}
void GroupList::AfterChange()
{
m_Frame.StopTweening();
m_Frame.RunCommands( SCROLL_TWEEN_COMMAND );
m_Frame.PlayCommand( "ScrollTween" );
m_Frame.SetY( -m_iTop*SPACING_Y );
for( int i=0; i < (int) m_asLabels.size(); i++ )
@@ -124,22 +126,18 @@ void GroupList::AfterChange()
if( IsHidden && !WasHidden )
{
m_sprButtons[i]->RunCommands( HIDE_ITEM_COMMAND );
m_textLabels[i]->RunCommands( HIDE_ITEM_COMMAND );
m_ButtonFrames[i]->PlayCommand( "HideItem" );
}
else if( !IsHidden && WasHidden )
{
m_sprButtons[i]->RunCommands( SHOW_ITEM_COMMAND );
m_textLabels[i]->RunCommands( SHOW_ITEM_COMMAND );
m_ButtonFrames[i]->PlayCommand( "ShowItem" );
ResetTextSize( i );
}
m_bHidden[i] = IsHidden;
}
m_sprButtons[m_iSelection]->RunCommands( GAIN_FOCUS_ITEM_COMMAND );
m_textLabels[m_iSelection]->RunCommands( GAIN_FOCUS_ITEM_COMMAND );
m_ButtonFrames[m_iSelection]->RunCommands( GAIN_FOCUS_GROUP_COMMAND );
m_ButtonFrames[m_iSelection]->PlayCommand( "GainFocus" );
}
void GroupList::Up()
@@ -206,8 +204,7 @@ void GroupList::TweenOnScreen()
/* If this item isn't visible, hide it and skip tweens. */
if( !ItemIsOnScreen(i) )
{
m_sprButtons[i]->RunCommands( HIDE_ITEM_COMMAND );
m_textLabels[i]->RunCommands( HIDE_ITEM_COMMAND );
m_ButtonFrames[i]->PlayCommand( "HideItem" );
m_sprButtons[i]->FinishTweening();
m_textLabels[i]->FinishTweening();
+5 -4
View File
@@ -4,9 +4,8 @@
#include "GameState.h"
#include "ThemeMetric.h"
#include "song.h"
#include "ActorUtil.h"
static ThemeMetric<apActorCommands> IN_COMMAND ("LyricDisplay","InCommand");
static ThemeMetric<apActorCommands> OUT_COMMAND ("LyricDisplay","OutCommand");
static ThemeMetric<float> IN_LENGTH ("LyricDisplay","InLength");
static ThemeMetric<float> OUT_LENGTH ("LyricDisplay","OutLength");
static ThemeMetric<RageColor> WIPE_DIM_FACTOR ("LyricDisplay","WipeDimFactor");
@@ -15,6 +14,8 @@ LyricDisplay::LyricDisplay()
{
for( int i=0; i<2; i++ )
{
m_textLyrics[i].SetName( "Lyric" );
ActorUtil::LoadAllCommands( m_textLyrics[i], "LyricDisplay" );
m_textLyrics[i].LoadFromFont( THEME->GetPathF("LyricDisplay","text") );
m_textLyrics[i].SetDiffuse( RageColor(1,1,1,1) );
this->AddChild( &m_textLyrics[i] );
@@ -100,14 +101,14 @@ void LyricDisplay::Update( float fDeltaTime )
m_textLyrics[i].SetCropLeft(0);
if( i==1 )
m_textLyrics[i].SetCropRight(1);
m_textLyrics[i].RunCommands( IN_COMMAND );
m_textLyrics[i].PlayCommand( "In" );
m_textLyrics[i].BeginTweening( fShowLength * 0.75f ); /* sleep */
if( i==0 )
m_textLyrics[i].SetCropLeft(1);
if( i==1 )
m_textLyrics[i].SetCropRight(0);
m_textLyrics[i].BeginTweening( fShowLength * 0.25f ); /* sleep */
m_textLyrics[i].RunCommands( OUT_COMMAND );
m_textLyrics[i].PlayCommand( "Out" );
}
m_iCurLyricNumber++;