diff --git a/stepmania/src/DifficultyList.cpp b/stepmania/src/DifficultyList.cpp index 87024b1156..b01021278c 100644 --- a/stepmania/src/DifficultyList.cpp +++ b/stepmania/src/DifficultyList.cpp @@ -30,7 +30,6 @@ void DifficultyList::SetName( const CString &sName, const CString &sID ) ActorFrame::SetName( sName, sID ); ITEMS_SPACING_Y.Load( m_sName, "ItemsSpacingY" ); - DESCRIPTION_MAX_WIDTH.Load( m_sName, "DescriptionMaxWidth" ); NUM_SHOWN_ITEMS.Load( m_sName, "NumShownItems" ); CAPITALIZE_DIFFICULTY_NAMES.Load( m_sName, "CapitalizeDifficultyNames" ); MOVE_COMMAND.Load( m_sName, "MoveCommand" ); @@ -61,27 +60,15 @@ void DifficultyList::Load() for( unsigned m = 0; m < m_Lines.size(); ++m ) { m_Lines[m].m_Meter.SetName( "Row" ); - m_Lines[m].m_Meter.Load( "DifficultySummaryRow" ); + m_Lines[m].m_Meter.Load( "DifficultyListRow" ); this->AddChild( &m_Lines[m].m_Meter ); - - m_Lines[m].m_Description.SetName( "Description" ); - m_Lines[m].m_Description.LoadFromFont( THEME->GetPathF(m_sName,"description") ); - this->AddChild( &m_Lines[m].m_Description ); - - m_Lines[m].m_Number.SetName( "Number" ); - m_Lines[m].m_Number.LoadFromFont( THEME->GetPathF(m_sName,"number") ); - this->AddChild( &m_Lines[m].m_Number ); } FOREACH_HumanPlayer( pn ) ON_COMMAND( m_Cursors[pn] ); for( int m = 0; m < MAX_METERS; ++m ) - { ON_COMMAND( m_Lines[m].m_Meter ); - ON_COMMAND( m_Lines[m].m_Description ); - ON_COMMAND( m_Lines[m].m_Number ); - } UpdatePositions(); PositionItems(); @@ -207,9 +194,7 @@ void DifficultyList::PositionItems() for( int i = 0; i < MAX_METERS; ++i ) { bool bUnused = ( i >= (int)m_Rows.size() ); - m_Lines[i].m_Description.SetHidden( bUnused ); m_Lines[i].m_Meter.SetHidden( bUnused ); - m_Lines[i].m_Number.SetHidden( bUnused ); } for( int m = 0; m < (int)m_Rows.size(); ++m ) @@ -220,18 +205,14 @@ void DifficultyList::PositionItems() bHidden = true; const float fDiffuseAlpha = bHidden? 0.0f:1.0f; - if( m_Lines[m].m_Number.GetDestY() != row.m_fY || - m_Lines[m].m_Number.DestTweenState().diffuse[0][3] != fDiffuseAlpha ) + if( m_Lines[m].m_Meter.GetDestY() != row.m_fY || + m_Lines[m].m_Meter.DestTweenState().diffuse[0][3] != fDiffuseAlpha ) { - m_Lines[m].m_Description.RunCommands( MOVE_COMMAND ); m_Lines[m].m_Meter.RunCommands( MOVE_COMMAND ); m_Lines[m].m_Meter.RunCommandsOnChildren( MOVE_COMMAND ); - m_Lines[m].m_Number.RunCommands( MOVE_COMMAND ); } - m_Lines[m].m_Description.SetY( row.m_fY ); m_Lines[m].m_Meter.SetY( row.m_fY ); - m_Lines[m].m_Number.SetY( row.m_fY ); } for( int m=0; m < MAX_METERS; ++m ) @@ -242,9 +223,7 @@ void DifficultyList::PositionItems() float fDiffuseAlpha = bHidden?0.0f:1.0f; - m_Lines[m].m_Description.SetDiffuseAlpha( fDiffuseAlpha ); m_Lines[m].m_Meter.SetDiffuseAlpha( fDiffuseAlpha ); - m_Lines[m].m_Number.SetDiffuseAlpha( fDiffuseAlpha ); } @@ -275,8 +254,6 @@ void DifficultyList::SetFromGameState() for( int m = 0; m < MAX_METERS; ++m ) { m_Lines[m].m_Meter.Unset(); - m_Lines[m].m_Number.SetText( "" ); - m_Lines[m].m_Description.SetText( "" ); } m_Rows.clear(); @@ -297,12 +274,6 @@ void DifficultyList::SetFromGameState() m_Lines[i].m_Meter.SetFromMeterAndDifficulty( 0, *d ); - m_Lines[i].m_Description.SetText( GetDifficultyString(*d) ); - m_Lines[i].m_Description.SetDiffuseColor( SONGMAN->GetDifficultyColor(*d) ); - - m_Lines[i].m_Number.SetDiffuseColor( SONGMAN->GetDifficultyColor(*d) ); - m_Lines[i].m_Number.SetText( "?" ); - i++; } } @@ -324,19 +295,6 @@ void DifficultyList::SetFromGameState() m_Lines[i].m_Meter.SetFromSteps( m_Rows[i].m_Steps ); row.m_dc = row.m_Steps->GetDifficulty(); - - CString s; - if( row.m_Steps->GetDifficulty() == DIFFICULTY_EDIT ) - s = row.m_Steps->GetDescription(); - else - s = GetDifficultyString(row.m_dc); - m_Lines[i].m_Description.SetMaxWidth( DESCRIPTION_MAX_WIDTH ); - m_Lines[i].m_Description.SetText( s ); - /* Don't mess with alpha; it might be fading on. */ - m_Lines[i].m_Description.SetDiffuseColor( SONGMAN->GetDifficultyColor(row.m_dc) ); - - m_Lines[i].m_Number.SetDiffuseColor( SONGMAN->GetDifficultyColor(row.m_dc) ); - m_Lines[i].m_Number.SetText( ssprintf("%d",row.m_Steps->GetMeter()) ); } } } @@ -347,11 +305,7 @@ void DifficultyList::SetFromGameState() if( bSongChanged ) { for( int m = 0; m < MAX_METERS; ++m ) - { m_Lines[m].m_Meter.FinishTweening(); - m_Lines[m].m_Description.FinishTweening(); - m_Lines[m].m_Number.FinishTweening(); - } } } @@ -361,13 +315,8 @@ void DifficultyList::HideRows() { Line &l = m_Lines[m]; - l.m_Description.FinishTweening(); l.m_Meter.FinishTweening(); - l.m_Number.FinishTweening(); - - l.m_Description.SetDiffuseAlpha(0); l.m_Meter.SetDiffuseAlpha(0); - l.m_Number.SetDiffuseAlpha(0); } } @@ -379,20 +328,14 @@ void DifficultyList::TweenOnScreen() { Line &l = m_Lines[m]; - l.m_Description.FinishTweening(); l.m_Meter.FinishTweening(); - l.m_Number.FinishTweening(); } -// PositionItems(); HideRows(); - PositionItems(); FOREACH_HumanPlayer( pn ) - { COMMAND( m_Cursors[pn], "TweenOn" ); - } } void DifficultyList::TweenOffScreen() @@ -410,9 +353,7 @@ void DifficultyList::Show() PositionItems(); FOREACH_HumanPlayer( pn ) - { COMMAND( m_Cursors[pn], "Show" ); - } } void DifficultyList::Hide() @@ -421,17 +362,7 @@ void DifficultyList::Hide() PositionItems(); FOREACH_HumanPlayer( pn ) - { COMMAND( m_Cursors[pn], "Hide" ); - } -} - -CString DifficultyList::GetDifficultyString( Difficulty d ) const -{ - CString s = DifficultyToThemedString( d ); - if( CAPITALIZE_DIFFICULTY_NAMES ) - s.MakeUpper(); - return s; } /* diff --git a/stepmania/src/DifficultyList.h b/stepmania/src/DifficultyList.h index ba0d09dd2f..39004ddddb 100644 --- a/stepmania/src/DifficultyList.h +++ b/stepmania/src/DifficultyList.h @@ -30,10 +30,8 @@ private: void PositionItems(); int GetCurrentRowIndex( PlayerNumber pn ) const; void HideRows(); - CString GetDifficultyString( Difficulty d ) const; ThemeMetric ITEMS_SPACING_Y; - ThemeMetric DESCRIPTION_MAX_WIDTH; ThemeMetric NUM_SHOWN_ITEMS; ThemeMetric CAPITALIZE_DIFFICULTY_NAMES; ThemeMetric MOVE_COMMAND; @@ -44,8 +42,6 @@ private: struct Line { DifficultyMeter m_Meter; - BitmapText m_Description; - BitmapText m_Number; }; vector m_Lines; diff --git a/stepmania/src/DifficultyMeter.cpp b/stepmania/src/DifficultyMeter.cpp index d2199266ad..0aab1704d2 100644 --- a/stepmania/src/DifficultyMeter.cpp +++ b/stepmania/src/DifficultyMeter.cpp @@ -10,6 +10,7 @@ #include "SongManager.h" #include "ActorUtil.h" #include "Style.h" +#include "XmlFile.h" // lua start LUA_REGISTER_CLASS( DifficultyMeter ) @@ -23,7 +24,7 @@ DifficultyMeter::DifficultyMeter() static CString GetDifficultyCommandName( Difficulty d ) { return "Set"+DifficultyToString(d); } static CString GetCourseDifficultyCommandName( CourseDifficulty d ) { return "Set"+CourseDifficultyToString(d)+"Course"; } -static const CString DIFFICULTY_COMMAND_NAME_NONE = "None"; +static const CString DIFFICULTY_COMMAND_NAME_NONE = "SetNone"; /* sID experiment: * @@ -51,16 +52,14 @@ void DifficultyMeter::Load( const CString &sType ) { /* We can't use global ThemeMetrics, because we can have multiple * DifficultyMeters on screen at once, with different names. */ - m_iNumFeetInMeter = THEME->GetMetricI(sType,"NumFeetInMeter"); - m_iMaxFeetInMeter = THEME->GetMetricI(sType,"MaxFeetInMeter"); - m_iGlowIfMeterGreaterThan = THEME->GetMetricI(sType,"GlowIfMeterGreaterThan"); - m_bShowFeet = THEME->GetMetricB(sType,"ShowFeet"); - /* "easy", "hard" */ - m_bShowDifficulty = THEME->GetMetricB(sType,"ShowDifficulty"); - /* 3, 9 */ - m_bShowMeter = THEME->GetMetricB(sType,"ShowMeter"); - m_bFeetIsDifficultyColor = THEME->GetMetricB(sType,"FeetIsDifficultyColor"); - m_bFeetPerDifficulty = THEME->GetMetricB(sType,"FeetPerDifficulty"); + m_iNumFeetInMeter.Load(sType,"NumFeetInMeter"); + m_iMaxFeetInMeter.Load(sType,"MaxFeetInMeter"); + m_iGlowIfMeterGreaterThan.Load(sType,"GlowIfMeterGreaterThan"); + m_bShowFeet.Load(sType,"ShowFeet"); + m_bShowDifficulty.Load(sType,"ShowDifficulty"); + m_bShowMeter.Load(sType,"ShowMeter"); + m_bShowEditDescription.Load(sType,"ShowEditDescription"); + m_bFeetPerDifficulty.Load(sType,"FeetPerDifficulty"); if( m_bShowFeet ) { @@ -106,10 +105,28 @@ void DifficultyMeter::Load( const CString &sType ) ActorUtil::LoadCommand( m_textMeter, sType, GetCourseDifficultyCommandName(d) ); ActorUtil::LoadCommand( m_textMeter, sType, DIFFICULTY_COMMAND_NAME_NONE ); } + + if( m_bShowEditDescription ) + { + m_textEditDescription.SetName( "EditDescription" ); + m_textEditDescription.LoadFromFont( THEME->GetPathF(sType,"EditDescription") ); + ActorUtil::SetXYAndOnCommand( m_textEditDescription, sType ); + this->AddChild( &m_textEditDescription ); + } Unset(); } +void DifficultyMeter::LoadFromNode( const CString& sDir, const XNode* pNode ) +{ + ActorFrame::LoadFromNode( sDir, pNode ); + + CString s; + pNode->GetAttrValue( "Type", s ); + ASSERT( s.size() ); + Load( s ); +} + void DifficultyMeter::SetFromGameState( PlayerNumber pn ) { if( GAMESTATE->IsCourseMode() ) @@ -138,8 +155,21 @@ void DifficultyMeter::SetFromSteps( const Steps* pSteps ) return; } - SetFromMeterAndDifficulty( pSteps->GetMeter(), pSteps->GetDifficulty() ); - PlayDifficultyCommand( GetDifficultyCommandName( pSteps->GetDifficulty() ) ); + Difficulty dc = pSteps->GetDifficulty(); + SetFromMeterAndDifficulty( pSteps->GetMeter(), dc ); + PlayDifficultyCommand( GetDifficultyCommandName( dc ) ); + if( m_bShowEditDescription ) + { + if( dc == DIFFICULTY_EDIT ) + { + m_textEditDescription.SetVisible( true ); + m_textEditDescription.SetText( pSteps->GetDescription() ); + } + else + { + m_textEditDescription.SetVisible( false ); + } + } } void DifficultyMeter::SetFromTrail( const Trail* pTrail ) @@ -150,14 +180,19 @@ void DifficultyMeter::SetFromTrail( const Trail* pTrail ) return; } - SetFromMeterAndDifficulty( pTrail->GetMeter(), pTrail->m_CourseDifficulty ); - PlayDifficultyCommand( GetCourseDifficultyCommandName( pTrail->m_CourseDifficulty ) ); + CourseDifficulty cd = pTrail->m_CourseDifficulty; + SetFromMeterAndDifficulty( pTrail->GetMeter(), cd ); + PlayDifficultyCommand( GetCourseDifficultyCommandName( cd ) ); + if( m_bShowEditDescription ) + m_textEditDescription.SetVisible( false ); } void DifficultyMeter::Unset() { SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER ); PlayDifficultyCommand( DIFFICULTY_COMMAND_NAME_NONE ); + if( m_bShowEditDescription ) + m_textEditDescription.SetText(""); } void DifficultyMeter::SetFromDifficulty( Difficulty dc ) @@ -182,7 +217,7 @@ void DifficultyMeter::SetFromMeterAndDifficulty( int iMeter, Difficulty dc ) on = char(dc + '0'); CString sNewText; - int iNumOn = min( m_iMaxFeetInMeter, iMeter ); + int iNumOn = min( (int)m_iMaxFeetInMeter, iMeter ); sNewText.insert( sNewText.end(), iNumOn, on ); int iNumOff = max( 0, m_iNumFeetInMeter-iNumOn ); sNewText.insert( sNewText.end(), iNumOff, off ); @@ -193,9 +228,6 @@ void DifficultyMeter::SetFromMeterAndDifficulty( int iMeter, Difficulty dc ) m_textFeet.SetEffectGlowShift(); else m_textFeet.SetEffectNone(); - - if( m_bFeetIsDifficultyColor ) - m_textFeet.SetDiffuse( SONGMAN->GetDifficultyColor( dc ) ); } if( m_bShowMeter ) diff --git a/stepmania/src/DifficultyMeter.h b/stepmania/src/DifficultyMeter.h index ec27aa7d28..fdc609248c 100644 --- a/stepmania/src/DifficultyMeter.h +++ b/stepmania/src/DifficultyMeter.h @@ -10,6 +10,7 @@ #include "ActorUtil.h" #include "Difficulty.h" #include "ActorFrame.h" +#include "ThemeMetric.h" class Steps; class Trail; @@ -51,6 +52,9 @@ public: DifficultyMeter(); void Load( const CString &sType ); + + void LoadFromNode( const CString& sDir, const XNode* pNode ); + void SetFromGameState( PlayerNumber pn ); void SetFromMeterAndDifficulty( int iMeter, Difficulty dc ); void SetFromSteps( const Steps* pSteps ); @@ -66,15 +70,20 @@ private: void PlayDifficultyCommand( CString diff ); - BitmapText m_textFeet; - + BitmapText m_textFeet; // bar CString m_sCurDifficultyCommand; - AutoActor m_Difficulty; + AutoActor m_Difficulty; /* "easy", "hard" */ + BitmapText m_textMeter; /* 3, 9 */ + BitmapText m_textEditDescription; - BitmapText m_textMeter; - - int m_iNumFeetInMeter, m_iMaxFeetInMeter, m_iGlowIfMeterGreaterThan; - bool m_bShowFeet, m_bShowDifficulty, m_bShowMeter, m_bFeetIsDifficultyColor, m_bFeetPerDifficulty; + ThemeMetric m_iNumFeetInMeter; + ThemeMetric m_iMaxFeetInMeter; + ThemeMetric m_iGlowIfMeterGreaterThan; + ThemeMetric m_bShowFeet; + ThemeMetric m_bShowDifficulty; + ThemeMetric m_bShowMeter; + ThemeMetric m_bShowEditDescription; + ThemeMetric m_bFeetPerDifficulty; }; #endif