Exemple #1
0
void HighScoreImpl::LoadFromNode( const XNode *pNode )
{
	ASSERT( pNode->GetName() == "HighScore" );

	RString s;

	pNode->GetChildValue( "Name", sName );
	pNode->GetChildValue( "Grade", s );
	grade = StringToGrade( s );
	pNode->GetChildValue( "Score",			iScore );
	pNode->GetChildValue( "PercentDP",		fPercentDP );
	pNode->GetChildValue( "SurviveSeconds",		fSurviveSeconds );
	pNode->GetChildValue( "MaxCombo",		iMaxCombo );
	pNode->GetChildValue( "StageAward",		s ); stageAward = StringToStageAward(s);
	pNode->GetChildValue( "PeakComboAward",	s ); peakComboAward = StringToPeakComboAward(s);
	pNode->GetChildValue( "Modifiers",		sModifiers );
	pNode->GetChildValue( "DateTime",		s ); dateTime.FromString( s );
	pNode->GetChildValue( "PlayerGuid",		sPlayerGuid );
	pNode->GetChildValue( "MachineGuid",		sMachineGuid );
	pNode->GetChildValue( "ProductID",		iProductID );
	const XNode* pTapNoteScores = pNode->GetChild( "TapNoteScores" );
	if( pTapNoteScores )
		FOREACH_ENUM( TapNoteScore, tns )
			pTapNoteScores->GetChildValue( TapNoteScoreToString(tns), iTapNoteScores[tns] );
	const XNode* pHoldNoteScores = pNode->GetChild( "HoldNoteScores" );
	if( pHoldNoteScores )
		FOREACH_ENUM( HoldNoteScore, hns )
			pHoldNoteScores->GetChildValue( HoldNoteScoreToString(hns), iHoldNoteScores[hns] );
	const XNode* pRadarValues = pNode->GetChild( "RadarValues" );
	if( pRadarValues )
		radarValues.LoadFromNode( pRadarValues );
	pNode->GetChildValue( "LifeRemainingSeconds",	fLifeRemainingSeconds );
	pNode->GetChildValue( "Disqualified",		bDisqualified);

	// Validate input.
	grade = clamp( grade, Grade_Tier01, Grade_Failed );
}
Exemple #2
0
void HighScoreList::LoadFromNode( const XNode* pHighScoreList )
{
	Init();

	ASSERT( pHighScoreList->GetName() == "HighScoreList" );
	FOREACH_CONST_Child( pHighScoreList, p )
	{
		const RString &name = p->GetName();
		if( name == "NumTimesPlayed" )
		{
			p->GetTextValue( iNumTimesPlayed );
		}
		else if( name == "LastPlayed" )
		{
			RString s;
			p->GetTextValue( s );
			dtLastPlayed.FromString( s );
		}
		else if( name == "HighGrade" )
		{
			RString s;
			p->GetTextValue( s );
			HighGrade = StringToGrade( s );
		}
		else if( name == "HighScore" )
		{
			vHighScores.resize( vHighScores.size()+1 );
			vHighScores.back().LoadFromNode( p );

			// ignore all high scores that are 0
			if( vHighScores.back().GetScore() == 0 )
				vHighScores.pop_back();
			else
				HighGrade = min( vHighScores.back().GetGrade(), HighGrade );
		}
	}
}
void ConditionalBGA::Load(const CString &szScreenName)
{
	RageFile file;

	CString szConditionalBGAFile = THEME->GetCurThemeDir() + szScreenName + " ConditionalBGA.ini";


//	char filepath[512];
//	strcpy(filepath,""); // empty the path first
//	strcpy(filepath,szConditionalBGAFile.c_str());
	
	LOG->Trace("ConditionalBGA Load:%s",szConditionalBGAFile.c_str());

	bool loaded = file.Open(szConditionalBGAFile,RageFile::READ);
//	FILE* fp = NULL;
//	fp = fopen(filepath,"r");
	if(!loaded)
	{
		LOG->Trace("ConditionalBGA File Not Found");
		return;
	}
	else
	{
		CString currentline;
		int bgano=0;

		while(!file.AtEOF())
		{
			file.GetLine(currentline); // get the current line
	
			// kill any possible comments
			CStringArray asKillComments;
			asKillComments.clear(); // get rid of anything in there
			split(currentline, "#",asKillComments); // A comment starting with #
			if(!asKillComments.empty())
			{
				currentline = asKillComments[0]; // there was some commentstuff here, take the first bit to be the actual data
			}
			asKillComments.clear(); // get rid of anything in there
			split(currentline, "/",asKillComments); // A comment starting with // or /*
			if(!asKillComments.empty())
			{
				currentline = asKillComments[0]; // there was some commentstuff here, take the first bit to be the actual data
			}
			TrimRight(currentline); // nuke trailing whitespace

			// start parsing the data
			if(currentline.c_str()[0] == '[') // we found a new bganimation
			{
				if(!m_bgainfo.empty()) // last one wasnt empty
				{
					CheckBgaRequirements(m_bgainfo[bgano]);
					bgano++;
				}
				BgaCondInfo temp;
				m_bgainfo.push_back(temp);
				ClearINFO(bgano); // wipe out the old info structure.

				CStringArray asSplitLine;
				split(currentline,"[",asSplitLine);
				split(asSplitLine[0],"]",asSplitLine);
				if(!asSplitLine.empty() && asSplitLine.size() >= 1)
					m_bgainfo[bgano].bganame = asSplitLine[asSplitLine.size() - 1];
			}
			else
			{
				CStringArray asSplitLine;
				split(currentline,":",asSplitLine);
				if(asSplitLine.empty()) continue;

				if(!asSplitLine[0].CompareNoCase("clear") && asSplitLine.size() > 1)
				{
					if(!asSplitLine[1].CompareNoCase("true") || !asSplitLine[1].CompareNoCase("cleared") || !asSplitLine[1].CompareNoCase("clear")) // true / clear (any clear condition)
						m_bgainfo[bgano].cleared = CBGA_CSCLEARED;
					else if(!asSplitLine[1].CompareNoCase("false") || !asSplitLine[1].CompareNoCase("failed")) // false / failed 
						m_bgainfo[bgano].cleared = CBGA_CSFAILED;
					else if(!asSplitLine[1].CompareNoCase("maxcombo") || !asSplitLine[1].CompareNoCase("fullcombo")) // passed with maxcombo 
						m_bgainfo[bgano].cleared = CBGA_CSMAXCOMBO;
					else if(!asSplitLine[1].CompareNoCase("brokencombo")) // passed with a broken combo 
						m_bgainfo[bgano].cleared = CBGA_CSBROKECOMBO;	

			//		LOG->Trace("Clear Conditon: %d",info.cleared);
				}
				if(!asSplitLine[0].CompareNoCase("songtitle") && asSplitLine.size() > 1)
				{
					m_bgainfo[bgano].songtitle = asSplitLine[1];
				//	LOG->Trace("SongTitle: %s",info.songtitle.c_str());
				}
				if(!asSplitLine[0].CompareNoCase("songartist") && asSplitLine.size() > 1)
				{
					m_bgainfo[bgano].songartist = asSplitLine[1];
				//	LOG->Trace("SongArtist: %s",info.songartist.c_str());
				}
				if(!asSplitLine[0].CompareNoCase("songday") && asSplitLine.size() > 1)
				{
					CStringArray asDays;
					split( asSplitLine[1], ",", asDays );
					for( unsigned d=0; d<asDays.size(); d++ )
					{
						int dn = atoi(asDays[d].c_str());
						if(!(dn < 1 || dn > 32)) // ignore if date is out of range
						{
							m_bgainfo[bgano].songdays.push_back(dn);
						}
					}
			//		for(d=0; d<info.songdays.size(); d++)
			//		{
			//			LOG->Trace("SongDay: %d",info.songdays[d]);
			//		}
				}
				if(!asSplitLine[0].CompareNoCase("songmonth") && asSplitLine.size() > 1)
				{
					CStringArray asMonths;
					split( asSplitLine[1], ",", asMonths );
					for( unsigned d=0; d<asMonths.size(); d++ )
					{
						int dn = atoi(asMonths[d].c_str());
						if(!(dn < 1 || dn > 12)) // ignore if date is out of range
						{
							m_bgainfo[bgano].songmonths.push_back(dn);
						}
					}
		//			for(d=0; d<info.songmonths.size(); d++)
		//			{
		//				LOG->Trace("SongMonth: %d",info.songmonths[d]);
		//			}
				}

				// foot meter ratings
				if(!asSplitLine[0].CompareNoCase("songdifficulty") && asSplitLine.size() > 1)
				{
					CStringArray asDifficulties;
					split( asSplitLine[1], ",", asDifficulties );
					
					for(unsigned d=0;d<asDifficulties.size();d++)
					{
						// check to see if the last character is a +
						bool bHandled = false;
						if(asDifficulties[d].c_str()[strlen(asDifficulties[d].c_str())-1] == '+')
						{
							bHandled = true;
							CStringArray asVal;
							split(asDifficulties[d],"+",asVal);
							int temp=0;
							temp = 0 - atoi(asVal[0].c_str()); // negative numbers will indicate 'greater than' for this system
							m_bgainfo[bgano].songmeters.push_back(temp);
						}

						if(!bHandled) // didnt find the + (gt) so find a - (range)
						{
							bool isarange=false;
							for(unsigned b=0; b<strlen(asDifficulties[d].c_str());b++)
							{
								if(asDifficulties[d].c_str()[b] == '-')
								{
									bHandled = isarange = true;
									break;
								}
							}
							if(isarange)
							{
								CStringArray asVal;
								split(asDifficulties[d],"-",asVal);
								int imin=0,imax=0,itmp=0;
								imin=atoi(asVal[0].c_str());
								imax=atoi(asVal[1].c_str());
								itmp=imin;
								while(itmp<=imax) // fill in the values between the min and max range inclusive
								{
									m_bgainfo[bgano].songmeters.push_back(itmp);
									itmp++;
								}
							}
						}

						if(!bHandled) // its not a range so must be a value on its own
						{
							int tmp = atoi(asDifficulties[d].c_str());
							m_bgainfo[bgano].songmeters.push_back(tmp);
						}

					}
				}

				// mods that mustn't be present
				if(!asSplitLine[0].CompareNoCase("moddisallow") && asSplitLine.size() > 1)
				{
					m_bgainfo[bgano].dpoused = true;
					m_bgainfo[bgano].disallowedpo.FromString(asSplitLine[1]);

				}
				
				// heavy, light e.t.c.
				if(!asSplitLine[0].CompareNoCase("songrating") && asSplitLine.size() > 1)
				{
					CStringArray asDifficulties;
					split( asSplitLine[1], ",", asDifficulties );
					for( unsigned d=0; d<asDifficulties.size(); d++ )
					{
						m_bgainfo[bgano].difficulties.push_back(StringToDifficulty(asDifficulties[d]));
					}
		//			for(d=0; d<info.difficulties.size(); d++)
		//			{
		//				LOG->Trace("Difficulty: %d",info.difficulties[d]);
		//			}
				}
				if(!asSplitLine[0].CompareNoCase("grade") && asSplitLine.size() > 1)
				{
					CStringArray asGrades;
					split( asSplitLine[1], ",", asGrades );
					for( unsigned d=0; d<asGrades.size(); d++ )
					{
						m_bgainfo[bgano].grades.push_back(StringToGrade(asGrades[d]));
					}

				}
				if(!asSplitLine[0].CompareNoCase("style") && asSplitLine.size() > 1)
				{
					LOG->Info("Comparing Styles");
					CStringArray asStyles;
					split( asSplitLine[1], ",", asStyles );
					for( unsigned d=0; d<asStyles.size(); d++ )
					{
						LOG->Info( "Style:%s", asStyles[d].c_str() );

						m_bgainfo[bgano].styles.push_back(GAMEMAN->GameAndStringToStyle(GAMESTATE->m_pCurGame,asStyles[d]));
					}

				}


			}

		}
		if(bganimtouse.CompareNoCase("")!=0)
		{
			LOG->Info("Best Match BGA Was: %s",bganimtouse.c_str());
			bganim.LoadFromAniDir( THEME->GetPathToB(bganimtouse) );
		}

	}
	file.Close(); 
}