Impaler[WrG]
Civ4:Col UI programmer
I have an idea that could be of Huge assistence to mod makers who need to combine work made by multiple people. This always requires that people paste new XML elements on to the existing ones. But their is one area ware they dont, the Text files. Its possible to add an unlimited number of xml files in the text folder and they all load. I though, what if the same could be done for Units, Buildings and Techs the 3 most commonly moded objects. After examing the source that loads the Text files and the other files I think its possible.
This is how the Text files are loaded
enumerateFiles is key it grabs everyfile in the specified directory, it could be used to grap new files out of a new directory we create within the Units/Tech/Buildings folders which would hold many small xml files each holding a single element.
I think I can use some of the standard C++ functions to enumerate directories, If so this will be even better as we can have a directory of directories and each game object could be packaged under a single folder containing all the objects XML such as the ArtDefine, UnitClass and Artfiles (.nif and .dds).
Adding a new object would be achived by dragging and dropping the folder!!
The only downside is it would likly require that the cach be ignored for these 3 particular files which would slow down loading by about a second or 2, but as most people are constant switching mods and not loading from the catch much as it is they wont mind.
This is how the Text files are loaded
// load all files in the xml text directory
//
std::vector<CvString> files;
gDLL->enumerateFiles(files, "xml\\text\\*.xml");
int i;
for(i=0;i<(int)files.size();i++)
{
bLoaded = LoadCivXml(m_pFXml, files); // Load the XML
if (!bLoaded)
{
char szMessage[1024];
sprintf( szMessage, "LoadXML call failed for %s. \n Current XML file is: %s", files.c_str(), GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Load Error");
}
if (bLoaded)
{
// if the xml is successfully validated
if (Validate())
{
SetGameText("Civ4GameText", "Civ4GameText/TEXT");
}
}
}
DestroyFXml();
enumerateFiles is key it grabs everyfile in the specified directory, it could be used to grap new files out of a new directory we create within the Units/Tech/Buildings folders which would hold many small xml files each holding a single element.
I think I can use some of the standard C++ functions to enumerate directories, If so this will be even better as we can have a directory of directories and each game object could be packaged under a single folder containing all the objects XML such as the ArtDefine, UnitClass and Artfiles (.nif and .dds).
Adding a new object would be achived by dragging and dropping the folder!!
The only downside is it would likly require that the cach be ignored for these 3 particular files which would slow down loading by about a second or 2, but as most people are constant switching mods and not loading from the catch much as it is they wont mind.