Files
itgmania212121/stepmania/src/Character.cpp
T

192 lines
5.5 KiB
C++
Raw Normal View History

#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"
bool Character::Load( CString sCharDir )
{
// Save character directory
2003-12-10 09:26:05 +00:00
if( sCharDir.Right(1) != "/" )
sCharDir += "/";
m_sCharDir = sCharDir;
// Save character name
vector<CString> as;
2003-12-10 09:26:05 +00:00
split( sCharDir, "/", as );
m_sName = as.back();
// Save attacks
IniFile ini;
ini.SetPath( sCharDir+"character.ini" );
if( !ini.ReadFile() )
return false;
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] );
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
{
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
{
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
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 );
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 );
if( as.empty() )
return "";
else
return as[0];
}
else
return as[0];
}
2003-11-02 03:41:59 +00:00
CString Character::GetCardPath() const
{
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
{
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-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-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
}