move Style XML saving/loading into StyleID
This commit is contained in:
@@ -287,7 +287,9 @@ void AddPlayerStatsToProfile( Profile *pProfile, const StageStats &ss, PlayerNum
|
||||
const int iMeter = clamp( ss.iMeter[p], 0, MAX_METER );
|
||||
|
||||
pProfile->m_iNumSongsPlayedByPlayMode[ss.playMode]++;
|
||||
pProfile->m_iNumSongsPlayedByStyle[ss.pStyle]++;
|
||||
StyleID sID;
|
||||
sID.FromStyle( ss.pStyle );
|
||||
pProfile->m_iNumSongsPlayedByStyle[sID]++;
|
||||
pProfile->m_iNumSongsPlayedByDifficulty[ss.pSteps[p]->GetDifficulty()]++;
|
||||
pProfile->m_iNumSongsPlayedByMeter[iMeter]++;
|
||||
pProfile->m_iTotalDancePoints += ss.iActualDancePoints[p];
|
||||
|
||||
@@ -68,7 +68,7 @@ RandomSample.cpp RandomSample.h RadarValues.cpp RadarValues.h \
|
||||
ScoreKeeper.h ScoreKeeperMAX2.cpp ScoreKeeperMAX2.h \
|
||||
ScoreKeeperRave.cpp ScoreKeeperRave.h Song.cpp song.h SongCacheIndex.cpp SongCacheIndex.h \
|
||||
SongOptions.cpp SongOptions.h SongUtil.cpp SongUtil.h StageStats.cpp StageStats.h Steps.cpp Steps.h \
|
||||
StepsUtil.cpp StepsUtil.h Style.cpp Style.h \
|
||||
StepsUtil.cpp StepsUtil.h Style.cpp Style.h StyleUtil.cpp StyleUtil.h \
|
||||
StyleInput.h TimingData.cpp TimingData.h \
|
||||
Trail.cpp Trail.h TrailUtil.cpp TrailUtil.h TitleSubstitution.cpp TitleSubstitution.h
|
||||
|
||||
|
||||
@@ -769,18 +769,17 @@ XNode* Profile::SaveGeneralDataCreateNode() const
|
||||
|
||||
{
|
||||
XNode* pNumSongsPlayedByStyle = pGeneralDataNode->AppendChild("NumSongsPlayedByStyle");
|
||||
for( map<const Style*,int>::const_iterator iter = m_iNumSongsPlayedByStyle.begin();
|
||||
for( map<StyleID,int>::const_iterator iter = m_iNumSongsPlayedByStyle.begin();
|
||||
iter != m_iNumSongsPlayedByStyle.end();
|
||||
iter++ )
|
||||
{
|
||||
const Style *s = iter->first;
|
||||
const GameDef *g = GAMEMAN->GetGameDefForGame( s->m_Game );
|
||||
ASSERT( g );
|
||||
const StyleID &s = iter->first;
|
||||
int iNumPlays = iter->second;
|
||||
XNode *pStyleNode = pNumSongsPlayedByStyle->AppendChild( "Style", iNumPlays );
|
||||
|
||||
pStyleNode->AppendAttr( "Game", g->m_szName );
|
||||
pStyleNode->AppendAttr( "Style", s->m_szName );
|
||||
XNode *pStyleNode = s.CreateNode();
|
||||
pStyleNode->SetValue( iNumPlays );
|
||||
|
||||
pNumSongsPlayedByStyle->AppendChild( pStyleNode );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -919,18 +918,10 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode )
|
||||
if( style->name != "Style" )
|
||||
continue;
|
||||
|
||||
CString sGame;
|
||||
if( !style->GetAttrValue( "Game", sGame ) )
|
||||
WARN_AND_CONTINUE;
|
||||
Game g = GAMEMAN->StringToGameType( sGame );
|
||||
if( g == GAME_INVALID )
|
||||
WARN_AND_CONTINUE;
|
||||
StyleID s;
|
||||
s.LoadFromNode( style );
|
||||
|
||||
CString sStyle;
|
||||
if( !style->GetAttrValue( "Style", sStyle ) )
|
||||
WARN_AND_CONTINUE;
|
||||
const Style* s = GAMEMAN->GameAndStringToStyle( g, sStyle );
|
||||
if( s == NULL )
|
||||
if( !s.IsValid() )
|
||||
WARN_AND_CONTINUE;
|
||||
|
||||
style->GetValue( m_iNumSongsPlayedByStyle[s] );
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "StepsUtil.h" // for StepsID
|
||||
#include "CourseUtil.h" // for CourseID
|
||||
#include "TrailUtil.h" // for TrailID
|
||||
#include "StyleUtil.h" // for StyleID
|
||||
|
||||
struct XNode;
|
||||
|
||||
@@ -107,7 +108,7 @@ public:
|
||||
set<int> m_UnlockedSongs;
|
||||
mutable CString m_sLastPlayedMachineGuid; // mutable because we overwrite this on save, and I don't want to remove const from the whole save chain. -Chris
|
||||
int m_iNumSongsPlayedByPlayMode[NUM_PLAY_MODES];
|
||||
map<const Style*,int> m_iNumSongsPlayedByStyle;
|
||||
map<StyleID,int> m_iNumSongsPlayedByStyle;
|
||||
int m_iNumSongsPlayedByDifficulty[NUM_DIFFICULTIES];
|
||||
int m_iNumSongsPlayedByMeter[MAX_METER+1];
|
||||
int m_iNumSongsPassedByPlayMode[NUM_PLAY_MODES];
|
||||
|
||||
@@ -62,7 +62,7 @@ IntDir=.\../Debug6
|
||||
TargetDir=\stepmania\stepmania\Program
|
||||
TargetName=StepMania-debug
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=disasm\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=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -996,6 +996,14 @@ SOURCE=.\StyleInput.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StyleUtil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StyleUtil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\TimingData.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -878,6 +878,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\
|
||||
<File
|
||||
RelativePath="StyleInput.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="StyleUtil.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="StyleUtil.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="TimingData.cpp">
|
||||
</File>
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
#include "global.h"
|
||||
#include "StyleUtil.h"
|
||||
#include "GameManager.h"
|
||||
#include "XmlFile.h"
|
||||
|
||||
|
||||
void StyleID::FromStyle( const Style *p )
|
||||
{
|
||||
if( p )
|
||||
{
|
||||
sGame = GAMEMAN->GetGameDefForGame(p->m_Game)->m_szName;
|
||||
sStyle = p->m_szName;
|
||||
}
|
||||
else
|
||||
{
|
||||
sGame = "";
|
||||
sStyle = "";
|
||||
}
|
||||
}
|
||||
|
||||
const Style *StyleID::ToStyle() const
|
||||
{
|
||||
Game game = GameManager::StringToGameType( sGame );
|
||||
if( game == GAME_INVALID )
|
||||
return NULL;
|
||||
|
||||
return GAMEMAN->GameAndStringToStyle( game, sStyle );
|
||||
}
|
||||
|
||||
XNode* StyleID::CreateNode() const
|
||||
{
|
||||
XNode* pNode = new XNode;
|
||||
pNode->name = "Style";
|
||||
|
||||
pNode->AppendAttr( "Game", sGame );
|
||||
pNode->AppendAttr( "Style", sStyle );
|
||||
|
||||
return pNode;
|
||||
}
|
||||
|
||||
void StyleID::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
Unset();
|
||||
ASSERT( pNode->name == "Style" );
|
||||
|
||||
sGame = "";
|
||||
pNode->GetAttrValue("Game", sGame);
|
||||
|
||||
sStyle = "";
|
||||
pNode->GetAttrValue("Style", sStyle);
|
||||
}
|
||||
|
||||
bool StyleID::IsValid() const
|
||||
{
|
||||
return !sGame.empty() && !sStyle.empty();
|
||||
}
|
||||
|
||||
bool StyleID::operator<( const StyleID &rhs ) const
|
||||
{
|
||||
#define COMP(a) if(a<rhs.a) return true; if(a>rhs.a) return false;
|
||||
COMP(sGame);
|
||||
COMP(sStyle);
|
||||
#undef COMP
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford, Glenn Maynard
|
||||
* 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.
|
||||
*/
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef STYLEUTIL_H
|
||||
#define STYLEUTIL_H
|
||||
|
||||
#include "Style.h"
|
||||
|
||||
struct XNode;
|
||||
|
||||
class StyleID
|
||||
{
|
||||
CString sGame;
|
||||
CString sStyle;
|
||||
|
||||
public:
|
||||
StyleID() { Unset(); }
|
||||
void Unset() { FromStyle(NULL); }
|
||||
void FromStyle( const Style *p );
|
||||
const Style *ToStyle() const;
|
||||
bool operator<( const StyleID &rhs ) const;
|
||||
|
||||
XNode* CreateNode() const;
|
||||
void LoadFromNode( const XNode* pNode );
|
||||
bool IsValid() const;
|
||||
static void FlushCache();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford, Glenn Maynard
|
||||
* 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.
|
||||
*/
|
||||
@@ -625,6 +625,31 @@ bool XNode::GetXML( RageFile &f, LPDISP_OPT opt /*= &optDefault*/ )
|
||||
return true;
|
||||
}
|
||||
|
||||
//========================================================
|
||||
// Name : GetValue
|
||||
// Desc :
|
||||
// Param :
|
||||
// Return :
|
||||
//--------------------------------------------------------
|
||||
// Coder Date Desc
|
||||
//========================================================
|
||||
void XNode::SetValue(int v)
|
||||
{
|
||||
value = ssprintf("%d",v);
|
||||
}
|
||||
void XNode::SetValue(float v)
|
||||
{
|
||||
value = ssprintf("%f",v);
|
||||
}
|
||||
void XNode::SetValue(bool v)
|
||||
{
|
||||
value = ssprintf("%d",v);
|
||||
}
|
||||
void XNode::SetValue(unsigned v)
|
||||
{
|
||||
value = ssprintf("%u",v);
|
||||
}
|
||||
|
||||
//========================================================
|
||||
// Name : GetAttr
|
||||
// Desc : get attribute with attribute name
|
||||
|
||||
@@ -127,6 +127,10 @@ struct XNode
|
||||
void GetValue(float &out) const { out = (float) atof(value); }
|
||||
void GetValue(bool &out) const { out = atoi(value) != 0; }
|
||||
void GetValue(unsigned &out) const { out = (unsigned)atoi(value) != 0; }
|
||||
void SetValue(int v);
|
||||
void SetValue(float v);
|
||||
void SetValue(bool v);
|
||||
void SetValue(unsigned v);
|
||||
|
||||
// internal variables
|
||||
LPXNode parent; // parent node
|
||||
|
||||
Reference in New Issue
Block a user