diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index b4add56ff4..22f91eb182 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -363,18 +363,6 @@ void ActorUtil::RunCommand( Actor& actor, const CString &sScreenName, const CStr actor.RunCommands( THEME->GetMetricA(sScreenName,actor.GetID()+sCommandName+"Command") ); } -void AutoActor::Load( const CString &sPath ) -{ - Unload(); - m_pActor = ActorUtil::MakeActor( sPath ); -} - -void AutoActor::LoadAndSetName( const CString &sScreenName, const CString &sActorName ) -{ - Load( THEME->GetPathG(sScreenName,sActorName) ); - m_pActor->SetName( sActorName ); -} - /* * (c) 2003-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/ActorUtil.h b/stepmania/src/ActorUtil.h index 4efbd018a7..37157b8f6b 100644 --- a/stepmania/src/ActorUtil.h +++ b/stepmania/src/ActorUtil.h @@ -1,3 +1,5 @@ +/* ActorScroller - ActorFrame that moves its children. */ + #ifndef ActorUtil_H #define ActorUtil_H @@ -6,11 +8,6 @@ struct XNode; -#define SET_XY( actor ) ActorUtil::SetXY( actor, m_sName ) -#define ON_COMMAND( actor ) ActorUtil::OnCommand( actor, m_sName ) -#define OFF_COMMAND( actor ) ActorUtil::OffCommand( actor, m_sName ) -#define SET_XY_AND_ON_COMMAND( actor ) ActorUtil::SetXYAndOnCommand( actor, m_sName ) -#define COMMAND( actor, command_name ) ActorUtil::RunCommand( actor, m_sName, command_name ) namespace ActorUtil { @@ -38,25 +35,12 @@ namespace ActorUtil Actor* MakeActor( const RageTextureID &ID ); }; -// creates the appropriate Actor derivitive on load and -// automatically deletes Actor on deconstruction. -class AutoActor -{ -public: - AutoActor() { m_pActor = NULL; } - ~AutoActor() { Unload(); } - operator const Actor* () const { return m_pActor; } - operator Actor* () { return m_pActor; } - const Actor *operator->() const { return m_pActor; } - Actor *operator->() { return m_pActor; } - void Unload() { if(m_pActor) { delete m_pActor; m_pActor=NULL; } } - bool IsLoaded() const { return m_pActor != NULL; } - void Load( const CString &sPath ); - void LoadAndSetName( const CString &sScreenName, const CString &sActorName ); +#define SET_XY( actor ) ActorUtil::SetXY( actor, m_sName ) +#define ON_COMMAND( actor ) ActorUtil::OnCommand( actor, m_sName ) +#define OFF_COMMAND( actor ) ActorUtil::OffCommand( actor, m_sName ) +#define SET_XY_AND_ON_COMMAND( actor ) ActorUtil::SetXYAndOnCommand( actor, m_sName ) +#define COMMAND( actor, command_name ) ActorUtil::RunCommand( actor, m_sName, command_name ) -protected: - Actor* m_pActor; -}; #endif diff --git a/stepmania/src/AutoActor.cpp b/stepmania/src/AutoActor.cpp new file mode 100644 index 0000000000..73de0b039a --- /dev/null +++ b/stepmania/src/AutoActor.cpp @@ -0,0 +1,48 @@ +#include "global.h" +#include "AutoActor.h" +#include "ThemeManager.h" +#include "Actor.h" +#include "ActorUtil.h" + +void AutoActor::Unload() +{ + delete m_pActor; + m_pActor=NULL; +} + +void AutoActor::Load( const CString &sPath ) +{ + Unload(); + m_pActor = ActorUtil::MakeActor( sPath ); +} + +void AutoActor::LoadAndSetName( const CString &sScreenName, const CString &sActorName ) +{ + Load( THEME->GetPathG(sScreenName,sActorName) ); + m_pActor->SetName( sActorName ); +} + +/* + * (c) 2003-2004 Chris Danford + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ diff --git a/stepmania/src/AutoActor.h b/stepmania/src/AutoActor.h new file mode 100644 index 0000000000..d2406bf9cc --- /dev/null +++ b/stepmania/src/AutoActor.h @@ -0,0 +1,53 @@ +/* ActorScroller - ActorFrame that moves its children. */ + +#ifndef AutoActor_H +#define AutoActor_H + +class Actor; + +// creates the appropriate Actor derivitive on load and +// automatically deletes Actor on deconstruction. +class AutoActor +{ +public: + AutoActor() { m_pActor = NULL; } + ~AutoActor() { Unload(); } + operator const Actor* () const { return m_pActor; } + operator Actor* () { return m_pActor; } + const Actor *operator->() const { return m_pActor; } + Actor *operator->() { return m_pActor; } + void Unload(); + bool IsLoaded() const { return m_pActor != NULL; } + void Load( const CString &sPath ); + void LoadAndSetName( const CString &sScreenName, const CString &sActorName ); + +protected: + Actor* m_pActor; +}; + +#endif + +/* + * (c) 2003-2004 Chris Danford + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ diff --git a/stepmania/src/BPMDisplay.cpp b/stepmania/src/BPMDisplay.cpp index 25a0b124f6..e5f1edc4da 100644 --- a/stepmania/src/BPMDisplay.cpp +++ b/stepmania/src/BPMDisplay.cpp @@ -6,6 +6,7 @@ #include "GameState.h" #include "Course.h" #include "Style.h" +#include "ActorUtil.h" BPMDisplay::BPMDisplay() { diff --git a/stepmania/src/BPMDisplay.h b/stepmania/src/BPMDisplay.h index 2c78c9a6df..945b746cfe 100644 --- a/stepmania/src/BPMDisplay.h +++ b/stepmania/src/BPMDisplay.h @@ -8,7 +8,7 @@ #include "ActorFrame.h" #include "BitmapText.h" #include "Quad.h" -#include "ActorUtil.h" +#include "AutoActor.h" #include "ThemeMetric.h" class Song; class Course; diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index bd77966a52..04f983cf15 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -83,6 +83,33 @@ BitmapText::~BitmapText() FONT->UnloadFont( m_pFont ); } + +void BitmapText::LoadFromNode( const CString& sDir, const XNode* pNode ) +{ + CString sText; + pNode->GetAttrValue("Text", sText ); + CString sAltText; + pNode->GetAttrValue("AltText", sAltText ); + + ThemeManager::EvaluateString( sText ); + ThemeManager::EvaluateString( sAltText ); + + + /* Be careful: if sFile is "", and we don't check it, then we can end up recursively + * loading the BGAnimationLayer that we're in. */ + CString sFont; + pNode->GetAttrValue("Font", sFont ); + if( sFont == "" ) + RageException::Throw( "An object '%s' in '%s' is missing the Font attribute", + pNode->m_sName.c_str(), sDir.c_str() ); + + LoadFromFont( THEME->GetPathToF( sFont ) ); + SetText( sText, sAltText ); + + Actor::LoadFromNode( sDir, pNode ); +} + + bool BitmapText::LoadFromFont( const CString& sFontFilePath ) { CHECKPOINT_M( ssprintf("BitmapText::LoadFromFont(%s)", sFontFilePath.c_str()) ); diff --git a/stepmania/src/BitmapText.h b/stepmania/src/BitmapText.h index 5126d5ca40..f6761e721e 100644 --- a/stepmania/src/BitmapText.h +++ b/stepmania/src/BitmapText.h @@ -32,6 +32,7 @@ public: BitmapText(); virtual ~BitmapText(); + void LoadFromNode( const CString& sDir, const XNode* pNode ); bool LoadFromFont( const CString& sFontName ); bool LoadFromTextureAndChars( const CString& sTexturePath, const CString& sChars ); diff --git a/stepmania/src/DifficultyMeter.h b/stepmania/src/DifficultyMeter.h index f7d40da8df..c62f4de306 100644 --- a/stepmania/src/DifficultyMeter.h +++ b/stepmania/src/DifficultyMeter.h @@ -5,10 +5,11 @@ #include "BitmapText.h" #include "PlayerNumber.h" -#include "ActorFrame.h" +#include "AutoActor.h" #include "GameConstantsAndTypes.h" #include "ActorUtil.h" #include "Difficulty.h" +#include "ActorFrame.h" class Steps; class Trail; diff --git a/stepmania/src/Makefile.am b/stepmania/src/Makefile.am index 2a12b55e65..4212e21bcf 100644 --- a/stepmania/src/Makefile.am +++ b/stepmania/src/Makefile.am @@ -266,7 +266,9 @@ RageUtil_WorkerThread.cpp RageUtil_WorkerThread.h Actors = \ Actor.cpp Actor.h ActorCollision.h ActorFrame.cpp ActorFrame.h \ -ActorScroller.cpp ActorScroller.h ActorUtil.cpp ActorUtil.h BitmapText.cpp BitmapText.h Model.cpp Model.h \ +ActorScroller.cpp ActorScroller.h ActorUtil.cpp ActorUtil.h \ +AutoActor.cpp AutoActor.h \ +BitmapText.cpp BitmapText.h Model.cpp Model.h \ ModelManager.cpp ModelManager.h ModelTypes.cpp ModelTypes.h Quad.h Sprite.cpp Sprite.h GlobalSingletons = \ diff --git a/stepmania/src/MeterDisplay.h b/stepmania/src/MeterDisplay.h index 1f3b7a7f10..928e17c57a 100644 --- a/stepmania/src/MeterDisplay.h +++ b/stepmania/src/MeterDisplay.h @@ -3,7 +3,7 @@ #include "ActorFrame.h" #include "Sprite.h" -#include "ActorUtil.h" +#include "AutoActor.h" class MeterDisplay : public ActorFrame diff --git a/stepmania/src/MusicWheel.h b/stepmania/src/MusicWheel.h index a3cf126351..c9680de946 100644 --- a/stepmania/src/MusicWheel.h +++ b/stepmania/src/MusicWheel.h @@ -3,7 +3,7 @@ #ifndef MUSICWHEEL_H #define MUSICWHEEL_H -#include "ActorUtil.h" +#include "AutoActor.h" #include "ActorFrame.h" #include "RageSound.h" #include "RandomSample.h" diff --git a/stepmania/src/PaneDisplay.cpp b/stepmania/src/PaneDisplay.cpp index d9d3880f16..7939ccdcc9 100644 --- a/stepmania/src/PaneDisplay.cpp +++ b/stepmania/src/PaneDisplay.cpp @@ -10,6 +10,7 @@ #include "Course.h" #include "Style.h" #include "Command.h" +#include "ActorUtil.h" #define SHIFT_X(p) THEME->GetMetricF(m_sName, ssprintf("ShiftP%iX", p+1)) #define SHIFT_Y(p) THEME->GetMetricF(m_sName, ssprintf("ShiftP%iY", p+1)) diff --git a/stepmania/src/PaneDisplay.h b/stepmania/src/PaneDisplay.h index fe1ac73374..6a4c7ffe31 100644 --- a/stepmania/src/PaneDisplay.h +++ b/stepmania/src/PaneDisplay.h @@ -6,7 +6,7 @@ #include "Sprite.h" #include "PlayerNumber.h" #include "BitmapText.h" -#include "ActorUtil.h" +#include "AutoActor.h" #include "GameConstantsAndTypes.h" enum PaneTypes diff --git a/stepmania/src/ReceptorArrow.h b/stepmania/src/ReceptorArrow.h index 5bcbb3a9f2..dd4db8d626 100644 --- a/stepmania/src/ReceptorArrow.h +++ b/stepmania/src/ReceptorArrow.h @@ -4,7 +4,7 @@ #define RECEPTOR_ARROW_H #include "ActorFrame.h" -#include "ActorUtil.h" +#include "AutoActor.h" #include "PlayerNumber.h" #include "GameConstantsAndTypes.h" diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index af3c871dcb..9906e96004 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -28,6 +28,7 @@ #include "PlayerState.h" #include "ScreenTextEntry.h" #include "Style.h" +#include "ActorUtil.h" const float RECORD_HOLD_SECONDS = 0.3f; diff --git a/stepmania/src/ScreenGameplayMultiplayer.cpp b/stepmania/src/ScreenGameplayMultiplayer.cpp index 13b1398a3d..400da096e6 100644 --- a/stepmania/src/ScreenGameplayMultiplayer.cpp +++ b/stepmania/src/ScreenGameplayMultiplayer.cpp @@ -19,6 +19,7 @@ #include "Style.h" #include "PlayerState.h" #include "InputMapper.h" +#include "ActorUtil.h" // // Defines diff --git a/stepmania/src/ScreenHowToPlay.cpp b/stepmania/src/ScreenHowToPlay.cpp index 2939f9cd8d..53e4cb7d25 100644 --- a/stepmania/src/ScreenHowToPlay.cpp +++ b/stepmania/src/ScreenHowToPlay.cpp @@ -15,6 +15,7 @@ #include "ThemeMetric.h" #include "PlayerState.h" #include "Style.h" +#include "ActorUtil.h" static const ThemeMetric SECONDS_TO_SHOW ("ScreenHowToPlay","SecondsToShow"); static const ThemeMetric STEPFILE ("ScreenHowToPlay","Stepfile"); diff --git a/stepmania/src/ScreenManager.h b/stepmania/src/ScreenManager.h index 0acc86d5ca..d1c150f850 100644 --- a/stepmania/src/ScreenManager.h +++ b/stepmania/src/ScreenManager.h @@ -18,7 +18,7 @@ class ScreenSystemLayer; class BGAnimation; -typedef Screen* (*CreateScreenFn)(const CString&); +typedef Screen* (*CreateScreenFn)(const CString& sClassName); class ScreenManager { diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 2c1b83396c..65592dedee 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -1526,6 +1526,8 @@ void ScreenSelectMusic::AfterMusicChange() m_Artists.push_back( pSong->GetDisplayArtist() ); m_AltArtists.push_back( pSong->GetTranslitArtist() ); + + MESSAGEMAN->Broadcast( "OnSongChanged" ); } break; case TYPE_ROULETTE: @@ -1629,6 +1631,8 @@ void ScreenSelectMusic::AfterMusicChange() COMMAND( m_sprCourseHasMods, "Hide" ); } + MESSAGEMAN->Broadcast( "OnCourseChanged" ); + break; } default: diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index f4fbab0f4d..f6e07a82f2 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -62,7 +62,7 @@ IntDir=.\../Debug6 TargetDir=\stepmania\stepmania\Program TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -99,7 +99,7 @@ IntDir=.\../Release6 TargetDir=\stepmania\stepmania\Program TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -1706,6 +1706,14 @@ SOURCE=.\ActorUtil.h # End Source File # Begin Source File +SOURCE=.\AutoActor.cpp +# End Source File +# Begin Source File + +SOURCE=.\AutoActor.h +# End Source File +# Begin Source File + SOURCE=.\BitmapText.cpp # End Source File # Begin Source File diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index 853117f8e0..1b7a5d5dfc 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -2231,6 +2231,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ + + + + diff --git a/stepmania/src/Transition.h b/stepmania/src/Transition.h index 9dc05b7947..2a658396d6 100644 --- a/stepmania/src/Transition.h +++ b/stepmania/src/Transition.h @@ -4,7 +4,7 @@ #define TRANSITION_H #include "Actor.h" -#include "ActorUtil.h" +#include "AutoActor.h" #include "ScreenMessage.h" #include "RandomSample.h"