Merge remote-tracking branch 'devhead/Preview4_0' into tsneo

# Conflicts:
#	Templates/BaseGame/game/data/ui/guis/loadingGui.gui
#	Templates/BaseGame/game/data/ui/guis/mainMenu.gui
#	Templates/BaseGame/game/tools/MainEditor/guis/MainEditorWindow.gui
#	Templates/BaseGame/game/tools/assetBrowser/guis/assetPreviewButtonsTemplate.gui
#	Templates/BaseGame/game/tools/forestEditor/brushes.tscript
This commit is contained in:
Jeff Hutchinson 2021-08-13 20:14:39 -04:00
commit 717c7acca9
2266 changed files with 48780 additions and 26034 deletions

View file

@ -20,7 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "tinyxml/tinyxml.h"
#include "tinyxml/tinyxml2.h"
//-----------------------------------------------------------------------------
// Console implementation of STL map.
@ -31,6 +31,7 @@
#include "console/consoleInternal.h"
#include "console/SimXMLDocument.h"
#include "console/engineAPI.h"
#include "persistence/taml/fsTinyXml.h"
IMPLEMENT_CONOBJECT(SimXMLDocument);
@ -175,7 +176,7 @@ bool SimXMLDocument::onAdd()
if(!m_qDocument)
{
m_qDocument = new TiXmlDocument();
m_qDocument = new VfsXMLDocument();
}
return true;
}
@ -252,7 +253,7 @@ bool SimXMLDocument::saveFile(const char* rFileName)
// -----------------------------------------------------------------------------
bool SimXMLDocument::saveToString(String& str)
{
TiXmlPrinter printer;
tinyxml2::XMLPrinter printer;
bool ret = m_qDocument->Accept( &printer );
if (ret)
str = printer.CStr();
@ -312,7 +313,7 @@ const char* SimXMLDocument::getErrorDesc(void) const
{
return StringTable->insert("No document");
}
return m_qDocument->ErrorDesc();
return m_qDocument->ErrorStr();
}
DefineEngineMethod( SimXMLDocument, getErrorDesc, const char*, (),,
@ -345,11 +346,11 @@ bool SimXMLDocument::pushFirstChildElement(const char* rName)
m_CurrentAttribute = 0;
// Push the first element found under the current element of the given name
TiXmlElement* pElement;
tinyxml2::XMLElement* pElement;
if(!m_paNode.empty())
{
const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement];
tinyxml2::XMLNode* pNode = m_paNode[iLastElement];
if(!pNode)
{
return false;
@ -409,11 +410,11 @@ bool SimXMLDocument::pushChildElement(S32 index)
m_CurrentAttribute = 0;
// Push the first element found under the current element of the given name
TiXmlElement* pElement;
tinyxml2::XMLElement* pElement;
if(!m_paNode.empty())
{
const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement];
tinyxml2::XMLNode* pNode = m_paNode[iLastElement];
if(!pNode)
{
return false;
@ -473,7 +474,7 @@ bool SimXMLDocument::nextSiblingElement(const char* rName)
return false;
}
const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement*& pElement = m_paNode[iLastElement];
tinyxml2::XMLNode*& pElement = m_paNode[iLastElement];
if(!pElement)
{
return false;
@ -507,7 +508,7 @@ const char* SimXMLDocument::elementValue()
return StringTable->EmptyString();
}
const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement];
tinyxml2::XMLNode* pNode = m_paNode[iLastElement];
if(!pNode)
{
return StringTable->EmptyString();
@ -548,7 +549,7 @@ const char* SimXMLDocument::attribute(const char* rAttribute)
return StringTable->EmptyString();
}
const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement];
tinyxml2::XMLElement* pNode = m_paNode[iLastElement]->ToElement();
if(!pNode)
{
return StringTable->EmptyString();
@ -599,7 +600,7 @@ bool SimXMLDocument::attributeExists(const char* rAttribute)
return false;
}
const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement];
tinyxml2::XMLElement* pNode = m_paNode[iLastElement]->ToElement();
if(!pNode)
{
return false;
@ -632,7 +633,7 @@ const char* SimXMLDocument::firstAttribute()
return StringTable->EmptyString();
}
const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement];
tinyxml2::XMLElement* pNode = m_paNode[iLastElement]->ToElement();
if(!pNode)
{
return StringTable->EmptyString();
@ -669,14 +670,18 @@ const char* SimXMLDocument::lastAttribute()
return StringTable->EmptyString();
}
const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement];
tinyxml2::XMLElement* pNode = m_paNode[iLastElement]->ToElement();
if(!pNode)
{
return StringTable->EmptyString();
}
// Gets its last attribute, if any
m_CurrentAttribute = pNode->LastAttribute();
m_CurrentAttribute = pNode->FirstAttribute();
while (m_CurrentAttribute->Next() != NULL)
{
m_CurrentAttribute = m_CurrentAttribute->Next();
}
if(!m_CurrentAttribute)
{
return StringTable->EmptyString();
@ -732,13 +737,29 @@ DefineEngineMethod( SimXMLDocument, nextAttribute, const char*, (),,
// -----------------------------------------------------------------------------
const char* SimXMLDocument::prevAttribute()
{
// Get the current element
if (m_paNode.empty())
{
return StringTable->EmptyString();
}
const S32 iLastElement = m_paNode.size() - 1;
tinyxml2::XMLElement* pNode = m_paNode[iLastElement]->ToElement();
if (!pNode)
{
return StringTable->EmptyString();
}
if(!m_CurrentAttribute)
{
return StringTable->EmptyString();
}
// Gets its next attribute, if any
m_CurrentAttribute = m_CurrentAttribute->Previous();
while (m_CurrentAttribute != NULL && m_CurrentAttribute->Next() != m_CurrentAttribute)
{
m_CurrentAttribute = m_CurrentAttribute->Next();
}
if(!m_CurrentAttribute)
{
return StringTable->EmptyString();
@ -768,7 +789,7 @@ void SimXMLDocument::setAttribute(const char* rAttribute, const char* rVal)
}
const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pElement = m_paNode[iLastElement];
tinyxml2::XMLElement* pElement = m_paNode[iLastElement]->ToElement();
if(!pElement)
{
return;
@ -800,13 +821,13 @@ void SimXMLDocument::setObjectAttributes(const char* objectID)
return;
const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pElement = m_paNode[iLastElement];
tinyxml2::XMLElement* pElement = m_paNode[iLastElement]->ToElement();
if(!pElement)
return;
char textbuf[1024];
TiXmlElement field( "Field" );
TiXmlElement group( "FieldGroup" );
tinyxml2::XMLElement* field = m_qDocument->NewElement("Field");
tinyxml2::XMLElement* group = m_qDocument->NewElement("FieldGroup");
pElement->SetAttribute( "Name", pObject->getName() );
@ -846,13 +867,13 @@ void SimXMLDocument::setObjectAttributes(const char* objectID)
if( !pObject->writeField( itr->pFieldname, textbuf ) )
continue;
field.SetValue( "Property" );
field.SetAttribute( "name", itr->pFieldname );
field->SetValue( "Property" );
field->SetAttribute( "name", itr->pFieldname );
if( cbt != NULL )
field.SetAttribute( "type", cbt->getTypeName() );
field->SetAttribute( "type", cbt->getTypeName() );
else
field.SetAttribute( "type", "TypeString" );
field.SetAttribute( "data", textbuf );
field->SetAttribute( "type", "TypeString" );
field->SetAttribute( "data", textbuf );
pElement->InsertEndChild( field );
@ -917,23 +938,21 @@ DefineEngineMethod( SimXMLDocument, setObjectAttributes, void, ( const char* obj
// -----------------------------------------------------------------------------
void SimXMLDocument::pushNewElement(const char* rName)
{
TiXmlElement cElement( rName );
TiXmlElement* pStackTop = 0;
tinyxml2::XMLElement* cElement = m_qDocument->NewElement( rName );
tinyxml2::XMLNode* pStackTop = 0;
if(m_paNode.empty())
{
pStackTop = dynamic_cast<TiXmlElement*>
(m_qDocument->InsertEndChild( cElement ) );
pStackTop = m_qDocument->InsertEndChild(cElement);
}
else
{
const S32 iFinalElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iFinalElement];
tinyxml2::XMLNode *pNode = m_paNode[iFinalElement];
if(!pNode)
{
return;
}
pStackTop = dynamic_cast<TiXmlElement*>
(pNode->InsertEndChild( cElement ));
pStackTop = pNode->InsertEndChild( cElement );
}
if(!pStackTop)
{
@ -961,13 +980,12 @@ DefineEngineMethod( SimXMLDocument, pushNewElement, void, ( const char* name ),,
// New element is placed on top of element stack.
// -----------------------------------------------------------------------------
void SimXMLDocument::addNewElement(const char* rName)
{
TiXmlElement cElement( rName );
TiXmlElement* pStackTop = 0;
{
tinyxml2::XMLElement* cElement = m_qDocument->NewElement(rName);
tinyxml2::XMLNode* pStackTop = 0;
if(m_paNode.empty())
{
pStackTop = dynamic_cast<TiXmlElement*>
(m_qDocument->InsertEndChild( cElement ));
pStackTop = m_qDocument->InsertEndChild( cElement );
if(!pStackTop)
{
return;
@ -979,8 +997,7 @@ void SimXMLDocument::addNewElement(const char* rName)
const S32 iParentElement = m_paNode.size() - 2;
if(iParentElement < 0)
{
pStackTop = dynamic_cast<TiXmlElement*>
(m_qDocument->InsertEndChild( cElement ));
pStackTop = m_qDocument->InsertEndChild( cElement );
if(!pStackTop)
{
return;
@ -990,13 +1007,12 @@ void SimXMLDocument::addNewElement(const char* rName)
}
else
{
TiXmlElement* pNode = m_paNode[iParentElement];
tinyxml2::XMLNode* pNode = m_paNode[iParentElement];
if(!pNode)
{
return;
}
pStackTop = dynamic_cast<TiXmlElement*>
(pNode->InsertEndChild( cElement ));
pStackTop = pNode->InsertEndChild( cElement );
if(!pStackTop)
{
return;
@ -1029,7 +1045,7 @@ DefineEngineMethod( SimXMLDocument, addNewElement, void, ( const char* name ),,
// -----------------------------------------------------------------------------
void SimXMLDocument::addHeader(void)
{
TiXmlDeclaration cDeclaration("1.0", "utf-8", "yes");
tinyxml2::XMLDeclaration* cDeclaration = m_qDocument->NewDeclaration("xml version=\"1.0\" encoding=\"UTF-8\" standalone =\"yes\"");
m_qDocument->InsertEndChild(cDeclaration);
}
@ -1057,8 +1073,8 @@ DefineEngineMethod( SimXMLDocument, addHeader, void, (),,
void SimXMLDocument::addComment(const char* comment)
{
TiXmlComment cComment;
cComment.SetValue(comment);
tinyxml2::XMLComment* cComment = m_qDocument->NewComment(comment);
cComment->SetValue(comment);
m_qDocument->InsertEndChild(cComment);
}
@ -1093,12 +1109,12 @@ const char* SimXMLDocument::readComment( S32 index )
if(!m_paNode.empty())
{
const S32 iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement];
tinyxml2::XMLNode* pNode = m_paNode[iLastElement];
if(!pNode)
{
return "";
}
TiXmlNode* node = pNode->FirstChild();
tinyxml2::XMLNode* node = pNode->FirstChild();
for( S32 i = 0; i < index; i++ )
{
if( !node )
@ -1109,7 +1125,7 @@ const char* SimXMLDocument::readComment( S32 index )
if( node )
{
TiXmlComment* comment = node->ToComment();
tinyxml2::XMLComment* comment = node->ToComment();
if( comment )
return comment->Value();
}
@ -1120,7 +1136,7 @@ const char* SimXMLDocument::readComment( S32 index )
{
return "";
}
TiXmlNode* node = m_qDocument->FirstChild();
tinyxml2::XMLNode* node = m_qDocument->FirstChild();
for( S32 i = 0; i < index; i++ )
{
if( !node )
@ -1131,7 +1147,7 @@ const char* SimXMLDocument::readComment( S32 index )
if( node )
{
TiXmlComment* comment = node->ToComment();
tinyxml2::XMLComment* comment = node->ToComment();
if( comment )
return comment->Value();
}
@ -1161,11 +1177,11 @@ void SimXMLDocument::addText(const char* text)
return;
const S32 iFinalElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iFinalElement];
tinyxml2::XMLNode* pNode = m_paNode[iFinalElement];
if(!pNode)
return;
TiXmlText cText(text);
tinyxml2::XMLText* cText = m_qDocument->NewText(text);
pNode->InsertEndChild( cText );
}
@ -1206,14 +1222,14 @@ const char* SimXMLDocument::getText()
return "";
const S32 iFinalElement = m_paNode.size() - 1;
TiXmlNode* pNode = m_paNode[iFinalElement];
tinyxml2::XMLNode* pNode = m_paNode[iFinalElement];
if(!pNode)
return "";
if(!pNode->FirstChild())
return "";
TiXmlText* text = pNode->FirstChild()->ToText();
tinyxml2::XMLText* text = pNode->FirstChild()->ToText();
if( !text )
return "";
@ -1266,18 +1282,18 @@ void SimXMLDocument::removeText()
return;
const S32 iFinalElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iFinalElement];
tinyxml2::XMLNode* pNode = m_paNode[iFinalElement];
if(!pNode)
return;
if( !pNode->FirstChild() )
return;
TiXmlText* text = pNode->FirstChild()->ToText();
tinyxml2::XMLText* text = pNode->FirstChild()->ToText();
if( !text )
return;
pNode->RemoveChild(text);
pNode->DeleteChild(text);
}
DefineEngineMethod( SimXMLDocument, removeText, void, (),,
@ -1302,11 +1318,11 @@ void SimXMLDocument::addData(const char* text)
return;
const S32 iFinalElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iFinalElement];
tinyxml2::XMLNode* pNode = m_paNode[iFinalElement];
if(!pNode)
return;
TiXmlText cText(text);
tinyxml2::XMLText* cText = m_qDocument->NewText(text);
pNode->InsertEndChild( cText );
}
@ -1348,14 +1364,14 @@ const char* SimXMLDocument::getData()
return "";
const S32 iFinalElement = m_paNode.size() - 1;
TiXmlNode* pNode = m_paNode[iFinalElement];
tinyxml2::XMLNode* pNode = m_paNode[iFinalElement];
if(!pNode)
return "";
if( !pNode->FirstChild() )
return "";
TiXmlText* text = pNode->FirstChild()->ToText();
tinyxml2::XMLText* text = pNode->FirstChild()->ToText();
if( !text )
return "";