Preserve spaces in scenario strings (and other longer strings) by using CDATA

- Involves a hack-mod of ticpp::Text to support it (for some reason, the support was there in TinyXML but not exposed by ticpp)
- Don't save all the intro strings if most are empty
- Don't save the init special if there isn't one
- Fix not saving the "I don't know" response for dialogue personalities

Strings that now preserve spaces:
- Descriptions of items, special items, and quests
- Descriptions of special shop items that call a special node when purchased
- Scenario, town, and outdoor strings
- Sign strings
- Journal strings
- All dialogue strings (both in personalities and in talk nodes)
This commit is contained in:
2015-07-02 02:15:24 -04:00
parent 1f5a1118f8
commit fecd268d5a
7 changed files with 163 additions and 42 deletions

View File

@@ -758,17 +758,19 @@ Comment::Comment( const std::string& comment )
//*****************************************************************************
Text::Text()
Text::Text(bool cdata)
: NodeImp< TiXmlText >( new TiXmlText("") )
{
m_impRC->InitRef();
if(cdata) m_tiXmlPointer->SetCDATA(true);
}
Text::Text( const std::string& value )
Text::Text( const std::string& value, bool cdata )
: NodeImp< TiXmlText >( new TiXmlText( value ) )
{
m_impRC->InitRef();
if(cdata) m_tiXmlPointer->SetCDATA(true);
}
Text::Text( TiXmlText* text )

View File

@@ -1361,7 +1361,7 @@ namespace ticpp
/**
Constructor.
*/
Text();
explicit Text(bool cdata = false);
/**
Constructor.
@@ -1373,7 +1373,7 @@ namespace ticpp
Constructor.
@overload
*/
Text( const std::string& value );
Text( const std::string& value, bool cdata = false );
/**
Streams value into a string and creates a Text with it.
@@ -1385,10 +1385,19 @@ namespace ticpp
@see TiXmlText
*/
template < class T >
Text( const T& value )
Text( const T& value, bool cdata = false )
: NodeImp< TiXmlText >( new TiXmlText( ToString( value ) ) )
{
m_impRC->InitRef();
if(cdata) m_tiXmlPointer->SetCDATA(true);
}
void SetCdata(bool cdata) {
m_tiXmlPointer->SetCDATA(cdata);
}
bool isCdata() const {
return m_tiXmlPointer->CDATA();
}
};

View File

@@ -32,12 +32,12 @@ namespace ticpp {
template<typename T> void PushAttribute(std::string attrName, T attrVal) {
openElements.top()->SetAttribute(attrName, boost::lexical_cast<std::string>(attrVal));
}
template<typename T> void PushText(T textVal) {
PushNode(new Text(boost::lexical_cast<std::string>(textVal)));
template<typename T> void PushText(T textVal, bool cdata = false) {
PushNode(new Text(boost::lexical_cast<std::string>(textVal), cdata));
}
template<typename T> void PushElement(std::string tagName, T elemVal) {
template<typename T> void PushElement(std::string tagName, T elemVal, bool cdata = false) {
OpenElement(tagName);
PushText(elemVal);
PushText(elemVal, cdata);
CloseElement(tagName);
}
};
@@ -47,12 +47,12 @@ template<> inline void ticpp::Printer::PushAttribute(std::string attrName, bool
PushAttribute(attrName, attrVal ? "true" : "false");
}
template<> inline void ticpp::Printer::PushElement(std::string attrName, bool attrVal) {
PushElement(attrName, attrVal ? "true" : "false");
template<> inline void ticpp::Printer::PushElement(std::string attrName, bool attrVal, bool cdata) {
PushElement(attrName, attrVal ? "true" : "false", cdata);
}
template<> inline void ticpp::Printer::PushText(bool textVal) {
PushText(textVal ? "true" : "false");
template<> inline void ticpp::Printer::PushText(bool textVal, bool cdata) {
PushText(textVal ? "true" : "false", cdata);
}
#endif