don't use Name/ID to load DifficultyMeter. We only need the Name at load time, so pass it into Load and don't save it in the Actor.
This commit is contained in:
@@ -58,8 +58,8 @@ void DifficultyList::Load()
|
||||
|
||||
for( unsigned m = 0; m < m_Lines.size(); ++m )
|
||||
{
|
||||
m_Lines[m].m_Meter.SetName( "DifficultySummaryRow", "Row" );
|
||||
m_Lines[m].m_Meter.Load();
|
||||
m_Lines[m].m_Meter.SetName( "Row" );
|
||||
m_Lines[m].m_Meter.Load( "DifficultySummaryRow" );
|
||||
this->AddChild( &m_Lines[m].m_Meter );
|
||||
|
||||
m_Lines[m].m_Description.SetName( "Description" );
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
#include "ActorUtil.h"
|
||||
#include "Style.h"
|
||||
|
||||
// lua start
|
||||
LUA_REGISTER_CLASS( DifficultyMeter )
|
||||
// lua end
|
||||
REGISTER_ACTOR_CLASS( DifficultyMeter );
|
||||
|
||||
|
||||
DifficultyMeter::DifficultyMeter()
|
||||
{
|
||||
@@ -38,20 +43,20 @@ DifficultyMeter::DifficultyMeter()
|
||||
* so I'm trying it first in only this object.
|
||||
*/
|
||||
|
||||
void DifficultyMeter::Load()
|
||||
void DifficultyMeter::Load( const CString &sType )
|
||||
{
|
||||
/* We can't use global ThemeMetric<CString>s, because we can have multiple
|
||||
* DifficultyMeters on screen at once, with different names. */
|
||||
m_iNumFeetInMeter = THEME->GetMetricI(m_sName,"NumFeetInMeter");
|
||||
m_iMaxFeetInMeter = THEME->GetMetricI(m_sName,"MaxFeetInMeter");
|
||||
m_iGlowIfMeterGreaterThan = THEME->GetMetricI(m_sName,"GlowIfMeterGreaterThan");
|
||||
m_bShowFeet = THEME->GetMetricB(m_sName,"ShowFeet");
|
||||
/* "easy", "hard" */
|
||||
m_bShowDifficulty = THEME->GetMetricB(m_sName,"ShowDifficulty");
|
||||
/* 3, 9 */
|
||||
m_bShowMeter = THEME->GetMetricB(m_sName,"ShowMeter");
|
||||
m_bFeetIsDifficultyColor = THEME->GetMetricB(m_sName,"FeetIsDifficultyColor");
|
||||
m_bFeetPerDifficulty = THEME->GetMetricB(m_sName,"FeetPerDifficulty");
|
||||
/* We can't use global ThemeMetric<CString>s, 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");
|
||||
|
||||
if( m_bShowFeet )
|
||||
{
|
||||
@@ -65,14 +70,14 @@ void DifficultyMeter::Load()
|
||||
}
|
||||
else
|
||||
Feet = "0X";
|
||||
m_textFeet.LoadFromTextureAndChars( THEME->GetPathG(m_sName,"bar"), Feet );
|
||||
m_textFeet.LoadFromTextureAndChars( THEME->GetPathG(sType,"bar"), Feet );
|
||||
SET_XY_AND_ON_COMMAND( &m_textFeet );
|
||||
this->AddChild( &m_textFeet );
|
||||
}
|
||||
|
||||
if( m_bShowDifficulty )
|
||||
{
|
||||
m_Difficulty.Load( THEME->GetPathG(m_sName,"difficulty") );
|
||||
m_Difficulty.Load( THEME->GetPathG(sType,"difficulty") );
|
||||
m_Difficulty->SetName( "Difficulty" );
|
||||
SET_XY_AND_ON_COMMAND( m_Difficulty );
|
||||
this->AddChild( m_Difficulty );
|
||||
@@ -81,7 +86,7 @@ void DifficultyMeter::Load()
|
||||
if( m_bShowMeter )
|
||||
{
|
||||
m_textMeter.SetName( "Meter" );
|
||||
m_textMeter.LoadFromFont( THEME->GetPathF(m_sName,"meter") );
|
||||
m_textMeter.LoadFromFont( THEME->GetPathF(sType,"meter") );
|
||||
SET_XY_AND_ON_COMMAND( m_textMeter );
|
||||
this->AddChild( &m_textMeter );
|
||||
}
|
||||
|
||||
@@ -14,19 +14,43 @@
|
||||
class Steps;
|
||||
class Trail;
|
||||
|
||||
template<class T>
|
||||
class LunaDifficultyMeter : public LunaActorFrame<T>
|
||||
{
|
||||
public:
|
||||
LunaDifficultyMeter() { LUA->Register( Register ); }
|
||||
|
||||
static int Load( T* p, lua_State *L ) { p->Load( SArg(1) ); return 0; }
|
||||
static int SetFromSteps( T* p, lua_State *L )
|
||||
{
|
||||
if( lua_isnil(L,1) ) { p->SetFromSteps( NULL ); }
|
||||
else { Steps *pS = Luna<Steps>::check(L,1); p->SetFromSteps( pS ); }
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Register(lua_State *L)
|
||||
{
|
||||
ADD_METHOD( Load )
|
||||
ADD_METHOD( SetFromSteps )
|
||||
LunaActor<T>::Register( L );
|
||||
}
|
||||
};
|
||||
|
||||
class DifficultyMeter: public ActorFrame
|
||||
{
|
||||
public:
|
||||
DifficultyMeter();
|
||||
|
||||
void Load();
|
||||
void Load( const CString &sType );
|
||||
void SetFromGameState( PlayerNumber pn );
|
||||
void SetFromMeterAndDifficulty( int iMeter, Difficulty dc );
|
||||
void SetFromSteps( const Steps* pSteps );
|
||||
void SetFromTrail( const Trail* pTrail );
|
||||
void Unset();
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
private:
|
||||
void SetFromDifficulty( Difficulty dc );
|
||||
void SetFromCourseDifficulty( CourseDifficulty cd );
|
||||
|
||||
@@ -79,14 +79,14 @@ EditMenu::EditMenu()
|
||||
m_SongTextBanner.SetXY( SONG_TEXT_BANNER_X, SONG_TEXT_BANNER_Y );
|
||||
this->AddChild( &m_SongTextBanner );
|
||||
|
||||
m_Meter.SetName( "EditDifficultyMeter", "DifficultyMeter" );
|
||||
m_Meter.SetName( "DifficultyMeter" );
|
||||
m_Meter.SetXY( METER_X, METER_Y );
|
||||
m_Meter.Load();
|
||||
m_Meter.Load( "EditDifficultyMeter" );
|
||||
this->AddChild( &m_Meter );
|
||||
|
||||
m_SourceMeter.SetName( "EditDifficultyMeter", "DifficultyMeter" );
|
||||
m_SourceMeter.SetName( "DifficultyMeter" );
|
||||
m_SourceMeter.SetXY( SOURCE_METER_X, SOURCE_METER_Y );
|
||||
m_SourceMeter.Load();
|
||||
m_SourceMeter.Load( "EditDifficultyMeter" );
|
||||
this->AddChild( &m_SourceMeter );
|
||||
|
||||
|
||||
|
||||
@@ -391,8 +391,7 @@ void ScreenEvaluation::Init()
|
||||
SET_XY_AND_ON_COMMAND( m_DifficultyIcon[p] );
|
||||
this->AddChild( &m_DifficultyIcon[p] );
|
||||
|
||||
m_DifficultyMeter[p].SetName( ssprintf("ScreenEvaluation DifficultyMeterP%d",p+1) );
|
||||
m_DifficultyMeter[p].Load();
|
||||
m_DifficultyMeter[p].Load( ssprintf("ScreenEvaluation DifficultyMeterP%d",p+1) );
|
||||
switch( m_Type )
|
||||
{
|
||||
case stage:
|
||||
|
||||
@@ -574,11 +574,7 @@ void ScreenGameplay::Init()
|
||||
/* Position it in LoadNextSong. */
|
||||
this->AddChild( &m_DifficultyIcon[p] );
|
||||
|
||||
// FIXME: Find a better way to handle this than changing the name
|
||||
CString sName = m_DifficultyMeter[p].GetName();
|
||||
m_DifficultyMeter[p].SetName( m_sName + ssprintf(" DifficultyMeterP%d",p+1) );
|
||||
m_DifficultyMeter[p].Load();
|
||||
m_DifficultyMeter[p].SetName( sName );
|
||||
m_DifficultyMeter[p].Load( m_sName + ssprintf(" DifficultyMeterP%d",p+1) );
|
||||
/* Position it in LoadNextSong. */
|
||||
this->AddChild( &m_DifficultyMeter[p] );
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ void ScreenNetSelectMusic::Init()
|
||||
ON_COMMAND( m_DifficultyIcon[p] );
|
||||
m_DC[p] = GAMESTATE->m_PreferredDifficulty[p];
|
||||
|
||||
m_DifficultyMeters[p].SetName( "DifficultyMeter", ssprintf("MeterP%d",p+1) );
|
||||
m_DifficultyMeters[p].Load();
|
||||
m_DifficultyMeters[p].SetName( ssprintf("MeterP%d",p+1) );
|
||||
m_DifficultyMeters[p].Load( "DifficultyMeter" );
|
||||
SET_XY_AND_ON_COMMAND( m_DifficultyMeters[p] );
|
||||
this->AddChild( &m_DifficultyMeters[p] );
|
||||
}
|
||||
|
||||
@@ -264,8 +264,8 @@ void ScreenSelectMusic::Init()
|
||||
this->AddChild( &m_PaneDisplay[p] );
|
||||
}
|
||||
|
||||
m_DifficultyMeter[p].SetName( "DifficultyMeter", ssprintf("MeterP%d",p+1) );
|
||||
m_DifficultyMeter[p].Load();
|
||||
m_DifficultyMeter[p].SetName( ssprintf("MeterP%d",p+1) );
|
||||
m_DifficultyMeter[p].Load( "DifficultyMeter" );
|
||||
SET_XY_AND_ON_COMMAND( m_DifficultyMeter[p] );
|
||||
this->AddChild( &m_DifficultyMeter[p] );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user