demand character graphics as needed, not on CharacterMan's c'tor (because the display isn't yet initialized)
This commit is contained in:
@@ -7,8 +7,6 @@
|
||||
|
||||
bool Character::Load( CString sCharDir )
|
||||
{
|
||||
m_Preload.UnloadAll();
|
||||
|
||||
// Save character directory
|
||||
if( sCharDir.Right(1) != "/" )
|
||||
sCharDir += "/";
|
||||
@@ -36,10 +34,6 @@ bool Character::Load( CString sCharDir )
|
||||
// get display name (if any)
|
||||
ini.GetValue( "Character", "DisplayName", m_sDisplayName );
|
||||
|
||||
CString sIconPath = GetIconPath();
|
||||
if( !sIconPath.empty() )
|
||||
m_Preload.Load( sIconPath );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -179,6 +173,18 @@ bool Character::Has2DElems()
|
||||
return false;
|
||||
}
|
||||
|
||||
void Character::DemandGraphics()
|
||||
{
|
||||
CString s = GetIconPath();
|
||||
if( !s.empty() )
|
||||
m_Preload.Load( s );
|
||||
}
|
||||
|
||||
void Character::UndemandGraphics()
|
||||
{
|
||||
m_Preload.UnloadAll();
|
||||
}
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ public:
|
||||
return m_sCharacterID.CompareNoCase("default") == 0;
|
||||
}
|
||||
|
||||
void DemandGraphics();
|
||||
void UndemandGraphics();
|
||||
|
||||
//
|
||||
// Lua
|
||||
//
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "CharacterManager.h"
|
||||
#include "Character.h"
|
||||
#include "GameState.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#define CHARACTERS_DIR "/Characters/"
|
||||
|
||||
@@ -78,6 +79,18 @@ Character* CharacterManager::GetDefaultCharacter()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CharacterManager::DemandGraphics()
|
||||
{
|
||||
FOREACH( Character*, m_pCharacters, c )
|
||||
(*c)->DemandGraphics();
|
||||
}
|
||||
|
||||
void CharacterManager::UndemandGraphics()
|
||||
{
|
||||
FOREACH( Character*, m_pCharacters, c )
|
||||
(*c)->UndemandGraphics();
|
||||
}
|
||||
|
||||
Character* CharacterManager::GetCharacterFromID( CString sCharacterID )
|
||||
{
|
||||
for( unsigned i=0; i<m_pCharacters.size(); i++ )
|
||||
|
||||
@@ -18,6 +18,9 @@ public:
|
||||
Character* GetDefaultCharacter();
|
||||
Character* GetCharacterFromID( CString sCharacterID );
|
||||
|
||||
void DemandGraphics();
|
||||
void UndemandGraphics();
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "Game.h"
|
||||
#include "InputMapper.h"
|
||||
#include "ProfileManager.h"
|
||||
#include "CharacterManager.h"
|
||||
|
||||
#define COIN_MODE_CHANGE_SCREEN THEME->GetMetric (m_sName,"CoinModeChangeScreen")
|
||||
|
||||
@@ -49,12 +50,16 @@ void ScreenTitleMenu::Init()
|
||||
|
||||
this->SortByDrawOrder();
|
||||
|
||||
CHARMAN->DemandGraphics();
|
||||
|
||||
SOUND->PlayOnceFromAnnouncer( "title menu game name" );
|
||||
}
|
||||
|
||||
ScreenTitleMenu::~ScreenTitleMenu()
|
||||
{
|
||||
LOG->Trace( "ScreenTitleMenu::~ScreenTitleMenu()" );
|
||||
|
||||
CHARMAN->UndemandGraphics();
|
||||
}
|
||||
|
||||
void ScreenTitleMenu::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
||||
|
||||
Reference in New Issue
Block a user