split AutoActor into a separate file

This commit is contained in:
Chris Danford
2005-02-09 05:27:51 +00:00
parent 613b99d26f
commit 1de61aa8ae
23 changed files with 173 additions and 46 deletions
-12
View File
@@ -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.
+7 -23
View File
@@ -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
+48
View File
@@ -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.
*/
+53
View File
@@ -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.
*/
+1
View File
@@ -6,6 +6,7 @@
#include "GameState.h"
#include "Course.h"
#include "Style.h"
#include "ActorUtil.h"
BPMDisplay::BPMDisplay()
{
+1 -1
View File
@@ -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;
+27
View File
@@ -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()) );
+1
View File
@@ -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 );
+2 -1
View File
@@ -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;
+3 -1
View File
@@ -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 = \
+1 -1
View File
@@ -3,7 +3,7 @@
#include "ActorFrame.h"
#include "Sprite.h"
#include "ActorUtil.h"
#include "AutoActor.h"
class MeterDisplay : public ActorFrame
+1 -1
View File
@@ -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"
+1
View File
@@ -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))
+1 -1
View File
@@ -6,7 +6,7 @@
#include "Sprite.h"
#include "PlayerNumber.h"
#include "BitmapText.h"
#include "ActorUtil.h"
#include "AutoActor.h"
#include "GameConstantsAndTypes.h"
enum PaneTypes
+1 -1
View File
@@ -4,7 +4,7 @@
#define RECEPTOR_ARROW_H
#include "ActorFrame.h"
#include "ActorUtil.h"
#include "AutoActor.h"
#include "PlayerNumber.h"
#include "GameConstantsAndTypes.h"
+1
View File
@@ -28,6 +28,7 @@
#include "PlayerState.h"
#include "ScreenTextEntry.h"
#include "Style.h"
#include "ActorUtil.h"
const float RECORD_HOLD_SECONDS = 0.3f;
@@ -19,6 +19,7 @@
#include "Style.h"
#include "PlayerState.h"
#include "InputMapper.h"
#include "ActorUtil.h"
//
// Defines
+1
View File
@@ -15,6 +15,7 @@
#include "ThemeMetric.h"
#include "PlayerState.h"
#include "Style.h"
#include "ActorUtil.h"
static const ThemeMetric<float> SECONDS_TO_SHOW ("ScreenHowToPlay","SecondsToShow");
static const ThemeMetric<CString> STEPFILE ("ScreenHowToPlay","Stepfile");
+1 -1
View File
@@ -18,7 +18,7 @@ class ScreenSystemLayer;
class BGAnimation;
typedef Screen* (*CreateScreenFn)(const CString&);
typedef Screen* (*CreateScreenFn)(const CString& sClassName);
class ScreenManager
{
+4
View File
@@ -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:
+10 -2
View File
@@ -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
+6
View File
@@ -2231,6 +2231,12 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File
RelativePath="ActorUtil.h">
</File>
<File
RelativePath="AutoActor.cpp">
</File>
<File
RelativePath="AutoActor.h">
</File>
<File
RelativePath=".\BitmapText.cpp">
</File>
+1 -1
View File
@@ -4,7 +4,7 @@
#define TRANSITION_H
#include "Actor.h"
#include "ActorUtil.h"
#include "AutoActor.h"
#include "ScreenMessage.h"
#include "RandomSample.h"