2003-04-07 03:25:44 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: Character
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "Character.h"
|
|
|
|
|
#include "IniFile.h"
|
|
|
|
|
#include "RageUtil.h"
|
2003-07-22 07:47:27 +00:00
|
|
|
#include "arch/arch.h"
|
2003-04-07 03:25:44 +00:00
|
|
|
|
|
|
|
|
|
2003-06-09 19:22:04 +00:00
|
|
|
bool Character::Load( CString sCharDir )
|
2003-04-07 03:25:44 +00:00
|
|
|
{
|
2003-06-09 19:22:04 +00:00
|
|
|
// Save character directory
|
2003-12-10 09:26:05 +00:00
|
|
|
if( sCharDir.Right(1) != "/" )
|
|
|
|
|
sCharDir += "/";
|
2003-06-09 19:22:04 +00:00
|
|
|
m_sCharDir = sCharDir;
|
|
|
|
|
|
|
|
|
|
// Save character name
|
|
|
|
|
vector<CString> as;
|
2003-12-10 09:26:05 +00:00
|
|
|
split( sCharDir, "/", as );
|
2003-06-09 19:22:04 +00:00
|
|
|
m_sName = as.back();
|
|
|
|
|
|
|
|
|
|
// Save attacks
|
2003-04-07 03:25:44 +00:00
|
|
|
IniFile ini;
|
2003-06-09 19:22:04 +00:00
|
|
|
ini.SetPath( sCharDir+"character.ini" );
|
|
|
|
|
if( !ini.ReadFile() )
|
|
|
|
|
return false;
|
2003-04-07 03:25:44 +00:00
|
|
|
for( int i=0; i<NUM_ATTACK_LEVELS; i++ )
|
|
|
|
|
for( int j=0; j<NUM_ATTACKS_PER_LEVEL; j++ )
|
|
|
|
|
ini.GetValue( "Character", ssprintf("Level%dAttack%d",i+1,j+1), m_sAttacks[i][j] );
|
2003-06-09 19:22:04 +00:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CString GetRandomFileInDir( CString sDir )
|
|
|
|
|
{
|
|
|
|
|
CStringArray asFiles;
|
|
|
|
|
GetDirListing( sDir, asFiles, false, true );
|
|
|
|
|
if( asFiles.empty() )
|
|
|
|
|
return "";
|
|
|
|
|
else
|
|
|
|
|
return asFiles[rand()%asFiles.size()];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-02 03:41:59 +00:00
|
|
|
CString Character::GetModelPath() const
|
2003-09-25 04:22:51 +00:00
|
|
|
{
|
|
|
|
|
CString s = m_sCharDir + "model.txt";
|
|
|
|
|
if( DoesFileExist(s) )
|
|
|
|
|
return s;
|
|
|
|
|
else
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-10 09:26:05 +00:00
|
|
|
CString Character::GetRestAnimationPath() const { return DerefRedir(GetRandomFileInDir(m_sCharDir + "Rest/")); }
|
|
|
|
|
CString Character::GetWarmUpAnimationPath() const { return DerefRedir(GetRandomFileInDir(m_sCharDir + "WarmUp/")); }
|
|
|
|
|
CString Character::GetDanceAnimationPath() const { return DerefRedir(GetRandomFileInDir(m_sCharDir + "Dance/")); }
|
2003-11-02 03:41:59 +00:00
|
|
|
CString Character::GetTakingABreakPath() const
|
2003-06-09 19:22:04 +00:00
|
|
|
{
|
|
|
|
|
CStringArray as;
|
|
|
|
|
GetDirListing( m_sCharDir+"break.png", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"break.jpg", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"break.gif", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"break.bmp", as, false, true );
|
|
|
|
|
if( as.empty() )
|
|
|
|
|
return "";
|
|
|
|
|
else
|
|
|
|
|
return as[0];
|
|
|
|
|
}
|
2003-11-02 03:41:59 +00:00
|
|
|
|
2003-11-21 04:35:06 +00:00
|
|
|
CString Character::GetSongSelectIconPath() const
|
|
|
|
|
{
|
|
|
|
|
CStringArray as;
|
|
|
|
|
// first try and find an icon specific to the select music screen
|
|
|
|
|
// so you can have different icons for music select / char select
|
|
|
|
|
GetDirListing( m_sCharDir+"selectmusicicon.png", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"selectmusicicon.jpg", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"selectmusicicon.gif", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"selectmusicicon.bmp", as, false, true );
|
|
|
|
|
|
|
|
|
|
if( as.empty() )
|
|
|
|
|
{
|
|
|
|
|
// if that failed, try using the regular icon
|
|
|
|
|
GetDirListing( m_sCharDir+"icon.png", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"icon.jpg", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"icon.gif", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"icon.bmp", as, false, true );
|
2003-12-19 09:30:54 +00:00
|
|
|
if( as.empty() )
|
|
|
|
|
return "";
|
|
|
|
|
else
|
|
|
|
|
return as[0];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return as[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CString Character::GetStageIconPath() const
|
|
|
|
|
{
|
|
|
|
|
CStringArray as;
|
|
|
|
|
// first try and find an icon specific to the select music screen
|
|
|
|
|
// so you can have different icons for music select / char select
|
|
|
|
|
GetDirListing( m_sCharDir+"stageicon.png", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"stageicon.jpg", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"stageicon.gif", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"stageicon.bmp", as, false, true );
|
|
|
|
|
|
|
|
|
|
if( as.empty() )
|
|
|
|
|
{
|
|
|
|
|
// if that failed, try using the regular icon
|
|
|
|
|
GetDirListing( m_sCharDir+"card.png", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"card.jpg", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"card.gif", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"card.bmp", as, false, true );
|
2003-11-21 04:35:06 +00:00
|
|
|
if( as.empty() )
|
|
|
|
|
return "";
|
|
|
|
|
else
|
|
|
|
|
return as[0];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return as[0];
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-02 03:41:59 +00:00
|
|
|
CString Character::GetCardPath() const
|
2003-06-09 19:22:04 +00:00
|
|
|
{
|
|
|
|
|
CStringArray as;
|
|
|
|
|
GetDirListing( m_sCharDir+"card.png", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"card.jpg", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"card.gif", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"card.bmp", as, false, true );
|
|
|
|
|
if( as.empty() )
|
|
|
|
|
return "";
|
|
|
|
|
else
|
|
|
|
|
return as[0];
|
|
|
|
|
}
|
2003-11-02 03:41:59 +00:00
|
|
|
|
|
|
|
|
CString Character::GetIconPath() const
|
2003-06-09 19:22:04 +00:00
|
|
|
{
|
|
|
|
|
CStringArray as;
|
|
|
|
|
GetDirListing( m_sCharDir+"icon.png", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"icon.jpg", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"icon.gif", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"icon.bmp", as, false, true );
|
|
|
|
|
if( as.empty() )
|
|
|
|
|
return "";
|
|
|
|
|
else
|
|
|
|
|
return as[0];
|
2003-04-07 03:25:44 +00:00
|
|
|
}
|
2003-11-02 03:41:59 +00:00
|
|
|
|
|
|
|
|
CString Character::GetHeadPath() const
|
2003-09-29 09:21:26 +00:00
|
|
|
{
|
|
|
|
|
CStringArray as;
|
|
|
|
|
GetDirListing( m_sCharDir+"head*.png", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"head*.jpg", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"head*.gif", as, false, true );
|
|
|
|
|
GetDirListing( m_sCharDir+"head*.bmp", as, false, true );
|
|
|
|
|
if( as.empty() )
|
|
|
|
|
return "";
|
|
|
|
|
else
|
|
|
|
|
return as[0];
|
|
|
|
|
}
|
2003-06-09 19:22:04 +00:00
|
|
|
|
2003-12-04 04:28:19 +00:00
|
|
|
bool Character::Has2DElems()
|
|
|
|
|
{
|
2003-12-10 09:26:05 +00:00
|
|
|
if( DoesFileExist(m_sCharDir + "2DFail/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
2003-12-04 04:28:19 +00:00
|
|
|
return true;
|
2003-12-10 09:26:05 +00:00
|
|
|
if( DoesFileExist(m_sCharDir + "2DFever/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
2003-12-04 04:28:19 +00:00
|
|
|
return true;
|
2003-12-10 09:26:05 +00:00
|
|
|
if( DoesFileExist(m_sCharDir + "2DGood/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
2003-12-04 04:28:19 +00:00
|
|
|
return true;
|
2003-12-10 09:26:05 +00:00
|
|
|
if( DoesFileExist(m_sCharDir + "2DMiss/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
2003-12-04 04:28:19 +00:00
|
|
|
return true;
|
2003-12-10 09:26:05 +00:00
|
|
|
if( DoesFileExist(m_sCharDir + "2DWin/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
2003-12-04 04:28:19 +00:00
|
|
|
return true;
|
2003-12-10 09:26:05 +00:00
|
|
|
if( DoesFileExist(m_sCharDir + "2DWinFever/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
2003-12-04 04:28:19 +00:00
|
|
|
return true;
|
2003-12-10 09:26:05 +00:00
|
|
|
if( DoesFileExist(m_sCharDir + "2DGreat/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
2003-12-04 04:28:19 +00:00
|
|
|
return true;
|
2003-12-10 09:26:05 +00:00
|
|
|
if( DoesFileExist(m_sCharDir + "2DIdle/BGAnimation.ini") ) // check 2D Idle BGAnim exists
|
2003-12-04 04:28:19 +00:00
|
|
|
return true;
|
|
|
|
|
return false;
|
2003-12-04 04:58:06 +00:00
|
|
|
}
|
|
|
|
|
|