From 83defce27b5251f6ffceaeea3f33c8d075af31f7 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 2 Oct 2006 22:52:57 +0000 Subject: [PATCH] XML update --- stepmania/src/Actor.cpp | 24 ++++++++++++------------ stepmania/src/ActorUtil.cpp | 2 +- stepmania/src/ExportStrings.cpp | 2 +- stepmania/src/Font.cpp | 10 +++++----- stepmania/src/IniFile.cpp | 2 +- stepmania/src/InputMapper.cpp | 3 ++- stepmania/src/TitleSubstitution.cpp | 2 +- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 960da261c4..cedb633fa8 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -212,7 +212,7 @@ void Actor::LoadFromNode( const RString& sDir, const XNode* pNode ) { FOREACH_CONST_Child( pNode, pChild ) { - if( pChild->m_sName == "Input" ) + if( pChild->GetName() == "Input" ) { /* If parameters are specified here, save their values to the actor. */ RString sName; @@ -235,7 +235,7 @@ void Actor::LoadFromNode( const RString& sDir, const XNode* pNode ) LUA->Release( L ); } - if( pChild->m_sName == "Context" ) + if( pChild->GetName() == "Context" ) { RString sName; if( !pChild->GetAttrValue( "Name", sName ) ) @@ -262,17 +262,17 @@ void Actor::LoadFromNode( const RString& sDir, const XNode* pNode ) { // Load Name, if any. const RString &sKeyName = pAttr->first; - const RString &sValue = pAttr->second; - if( sKeyName == "Name" ) SetName( sValue ); - else if( sKeyName == "BaseRotationX" ) SetBaseRotationX( StringToFloat(sValue) ); - else if( sKeyName == "BaseRotationY" ) SetBaseRotationY( StringToFloat(sValue) ); - else if( sKeyName == "BaseRotationZ" ) SetBaseRotationZ( StringToFloat(sValue) ); - else if( sKeyName == "BaseZoomX" ) SetBaseZoomX( StringToFloat(sValue) ); - else if( sKeyName == "BaseZoomY" ) SetBaseZoomY( StringToFloat(sValue) ); - else if( sKeyName == "BaseZoomZ" ) SetBaseZoomZ( StringToFloat(sValue) ); + const XNodeValue &sValue = pAttr->second; + if( sKeyName == "Name" ) SetName( sValue.GetValue() ); + else if( sKeyName == "BaseRotationX" ) SetBaseRotationX( sValue.GetValue() ); + else if( sKeyName == "BaseRotationY" ) SetBaseRotationY( sValue.GetValue() ); + else if( sKeyName == "BaseRotationZ" ) SetBaseRotationZ( sValue.GetValue() ); + else if( sKeyName == "BaseZoomX" ) SetBaseZoomX( sValue.GetValue() ); + else if( sKeyName == "BaseZoomY" ) SetBaseZoomY( sValue.GetValue() ); + else if( sKeyName == "BaseZoomZ" ) SetBaseZoomZ( sValue.GetValue() ); else if( EndsWith(sKeyName,"Command") ) { - apActorCommands apac = ActorUtil::ParseActorCommands( sValue ); + apActorCommands apac = ActorUtil::ParseActorCommands( sValue.GetValue(), ssprintf("%s: %s", sDir.c_str(), sKeyName.c_str()) ); RString sCmdName = sKeyName.Left( sKeyName.size()-7 ); AddCommand( sCmdName, apac ); @@ -284,7 +284,7 @@ void Actor::LoadFromNode( const RString& sDir, const XNode* pNode ) // FOREACH_CONST_Child( pNode, c ) { - RString sKeyName = c->m_sName; + RString sKeyName = c->GetName(); if( sKeyName != "Command" ) continue; /* not a command */ diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index 762e79f54c..5e3516826d 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -315,7 +315,7 @@ static void MergeActorXML( XNode *pChild, const XNode *pParent ) RString sWarning = ssprintf( "Overriding \"%s\" (\"%s\") in XML node \"%s\" with \"%s\" in XML node \"%s\"", p->first.c_str(), - p->second.c_str(), + p->second.GetValue().c_str(), pChild->GetName().c_str(), sOld.c_str(), pParent->GetName().c_str() ); diff --git a/stepmania/src/ExportStrings.cpp b/stepmania/src/ExportStrings.cpp index 7207528e2f..a00801e94a 100644 --- a/stepmania/src/ExportStrings.cpp +++ b/stepmania/src/ExportStrings.cpp @@ -36,7 +36,7 @@ void ExportStrings::Nsis() FOREACH_CONST_Attr( child, attr ) { RString sName = attr->first; - RString sValue = attr->second; + RString sValue = attr->second.GetValue(); sValue.Replace( "\\n", "$\\n" ); RString sLine = ssprintf( "LangString %s ${LANG_%s} \"%s\"", sName.c_str(), sLangNameUpper.c_str(), sValue.c_str() ); out.PutLine( sLine ); diff --git a/stepmania/src/Font.cpp b/stepmania/src/Font.cpp index fa10ab1d09..36372449bf 100644 --- a/stepmania/src/Font.cpp +++ b/stepmania/src/Font.cpp @@ -396,14 +396,14 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr FOREACH_CONST_Attr( pNode, pAttr ) { RString sName = pAttr->first; - const RString &sValue = pAttr->second; + const XNodeValue &sValue = pAttr->second; sName.MakeUpper(); /* If val is an integer, it's a width, eg. "10=27". */ if( IsAnInt(sName) ) { - cfg.m_mapGlyphWidths[atoi(sName)] = atoi( sValue ); + cfg.m_mapGlyphWidths[atoi(sName)] = sValue.GetValue(); continue; } @@ -439,7 +439,7 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr continue; } - cfg.CharToGlyphNo[c] = atoi( sValue ); + cfg.CharToGlyphNo[c] = sValue.GetValue(); continue; } @@ -488,7 +488,7 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr iCount = iLast - iFirst + 1; } - RString sRet = cfg.MapRange( asMatches[0], iFirst, atoi(sValue), iCount ); + RString sRet = cfg.MapRange( asMatches[0], iFirst, sValue.GetValue(), iCount ); if( !sRet.empty() ) RageException::Throw( "Font definition \"%s\" has an invalid range \"%s\": %s.", ini.GetPath().c_str(), sName.c_str(), sRet.c_str() ); @@ -514,7 +514,7 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr ini.GetPath().c_str(), iFirstFrame, iNumFramesHigh ); /* Decode the string. */ - const wstring wdata( RStringToWstring(sValue) ); + const wstring wdata( RStringToWstring(sValue.GetValue()) ); if( int(wdata.size()) > iNumFramesWide ) RageException::Throw( "The font definition \"%s\" assigns %i characters to row %i (\"%ls\"), but the font is only %i characters wide.", diff --git a/stepmania/src/IniFile.cpp b/stepmania/src/IniFile.cpp index cf2ba33048..dc6bf615e4 100644 --- a/stepmania/src/IniFile.cpp +++ b/stepmania/src/IniFile.cpp @@ -98,7 +98,7 @@ bool IniFile::WriteFile( RageFileBasic &f ) const FOREACH_CONST_Attr( pKey, pAttr ) { const RString &sName = pAttr->first; - const RString &sValue = pAttr->second; + const RString &sValue = pAttr->second.GetValue(); // TODO: Are there esacpe rules for these? DEBUG_ASSERT( sName.find('\n') == sName.npos ); diff --git a/stepmania/src/InputMapper.cpp b/stepmania/src/InputMapper.cpp index 2a5d66297f..88fb1606bb 100644 --- a/stepmania/src/InputMapper.cpp +++ b/stepmania/src/InputMapper.cpp @@ -561,7 +561,8 @@ void InputMapper::ReadMappingsFromDisk() FOREACH_CONST_Attr( Key, i ) { const RString &name = i->first; - const RString &value = i->second; + RString value; + i->second.GetValue( value ); GameInput GameI; GameI.FromString( m_pInputScheme, name ); diff --git a/stepmania/src/TitleSubstitution.cpp b/stepmania/src/TitleSubstitution.cpp index 7fba5d2066..d951199a64 100644 --- a/stepmania/src/TitleSubstitution.cpp +++ b/stepmania/src/TitleSubstitution.cpp @@ -50,7 +50,7 @@ void TitleTrans::LoadFromNode( const XNode* pNode ) /* Surround each regex with ^(...)$, to force all comparisons to default * to being a full-line match. (Add ".*" manually if this isn't wanted.) */ const RString &sKeyName = attr->first; - const RString &sValue = attr->second; + const RString &sValue = attr->second.GetValue(); if( sKeyName == "DontTransliterate" ) translit = false; else if( sKeyName == "TitleFrom" ) TitleFrom = "^(" + sValue + ")$"; else if( sKeyName == "ArtistFrom" ) ArtistFrom = "^(" + sValue + ")$";