- a few fixes for taking auto-sreenshots from g3d viewer,in prep for html tool

This commit is contained in:
Mark Vejvoda
2011-01-29 04:35:55 +00:00
parent 2e5c5be357
commit be8627dc0a
2 changed files with 69 additions and 57 deletions

View File

@@ -130,8 +130,8 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
printf("\n%s\t\t\t\tdisplays this help text.",(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_HELP])); printf("\n%s\t\t\t\tdisplays this help text.",(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_HELP]));
printf("\n%s=x\t\t\tAuto load the unit / skill information specified in path/filename x",(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_UNIT])); printf("\n%s=x\t\t\tAuto load the unit / skill information specified in path/filename x",(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_UNIT]));
printf("\n \t\tWhere x is a g3d filename to load seperated with a comma and the skill name to load:"); printf("\n \t\tWhere x is a g3d filename to load seperated with a comma and one or more skill names to try loading:");
printf("\n \t\texample: %s %s=techs/megapack/factions/tech/units/battle_machine,attack_skill",argv0,(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_MODEL])); printf("\n \t\texample: %s %s=techs/megapack/factions/tech/units/battle_machine,attack_skill,stop_skill",argv0,(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_MODEL]));
printf("\n%s=x\t\t\tAuto load the model specified in path/filename x",(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_MODEL])); printf("\n%s=x\t\t\tAuto load the model specified in path/filename x",(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_MODEL]));
printf("\n \t\tWhere x is a g3d filename to load:"); printf("\n \t\tWhere x is a g3d filename to load:");
@@ -179,7 +179,7 @@ vector<string> autoScreenShotParams;
const string MainWindow::winHeader= "G3D viewer " + g3dviewerVersionString; const string MainWindow::winHeader= "G3D viewer " + g3dviewerVersionString;
MainWindow::MainWindow( std::pair<string,string> unitToLoad, MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
const string modelPath, const string modelPath,
const string particlePath, const string particlePath,
const string projectileParticlePath, const string projectileParticlePath,
@@ -193,7 +193,7 @@ MainWindow::MainWindow( std::pair<string,string> unitToLoad,
//getGlPlatformExtensions(); //getGlPlatformExtensions();
renderer= Renderer::getInstance(); renderer= Renderer::getInstance();
unitPathList = unitToLoad; unitPath = unitToLoad;
if(modelPath != "") { if(modelPath != "") {
this->modelPathList.push_back(modelPath); this->modelPathList.push_back(modelPath);
@@ -748,26 +748,19 @@ void MainWindow::loadUnit(string path, string skillName) {
if(path != "" && fileExists(path) == true) { if(path != "" && fileExists(path) == true) {
// std::cout << "Clearing list..." << std::endl; // std::cout << "Clearing list..." << std::endl;
this->unitPathList.first = path; this->unitPath.first = path;
this->unitPathList.second = skillName; this->unitPath.second.push_back(skillName);
} }
try{ try{
if(this->unitPathList.first != "") { if(this->unitPath.first != "") {
string titlestring = winHeader; string titlestring = winHeader;
string unitPath = this->unitPathList.first; string unitPath = this->unitPath.first;
//string dir= extractDirectoryPathFromFile(unitPath);
string dir = unitPath; string dir = unitPath;
//size_t pos = dir.find_last_of(folderDelimiter);
//if(pos == dir.length()-1) {
// dir.erase(dir.length() -1);
//}
string name= lastDir(dir); string name= lastDir(dir);
string path= dir + "/" + name + ".xml"; string path= dir + "/" + name + ".xml";
//unitPath= extractFileFromDirectoryPath(unitPath);
titlestring = unitPath + " - "+ titlestring; titlestring = unitPath + " - "+ titlestring;
std::string unitXML = path; std::string unitXML = path;
@@ -777,53 +770,70 @@ void MainWindow::loadUnit(string path, string skillName) {
string skillParticleProjectileFile = ""; string skillParticleProjectileFile = "";
string skillParticleSplashFile = ""; string skillParticleSplashFile = "";
printf("Loading unit from file [%s] skill [%s]\n",unitXML.c_str(),this->unitPathList.second.c_str()); printf("Loading unit from file [%s]\n",unitXML.c_str());
if(fileExists(unitXML) == true) { if(fileExists(unitXML) == true) {
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load(unitXML); xmlTree.load(unitXML);
const XmlNode *unitNode= xmlTree.getRootNode(); const XmlNode *unitNode= xmlTree.getRootNode();
bool foundSkillName = false;
for(int skillIdx = 0; foundSkillName == false && skillIdx < this->unitPath.second.size(); ++skillIdx) {
string lookipForSkillName = this->unitPath.second[skillIdx];
const XmlNode *skillsNode= unitNode->getChild("skills"); const XmlNode *skillsNode= unitNode->getChild("skills");
for(int i = 0; i < skillsNode->getChildCount(); ++i) { for(int i = 0; i < skillsNode->getChildCount(); ++i) {
const XmlNode *sn= skillsNode->getChild("skill", i); const XmlNode *sn= skillsNode->getChild("skill", i);
const XmlNode *typeNode= sn->getChild("type"); const XmlNode *typeNode= sn->getChild("type");
const XmlNode *nameNode= sn->getChild("name"); const XmlNode *nameNode= sn->getChild("name");
string skillXmlName = nameNode->getAttribute("value")->getRestrictedValue(); string skillXmlName = nameNode->getAttribute("value")->getRestrictedValue();
if(skillXmlName == this->unitPathList.second) { if(skillXmlName == lookipForSkillName) {
if(sn->getChild("animation") != NULL) foundSkillName = true;
if(sn->getChild("animation") != NULL) {
skillModelFile = unitPath + '/' + sn->getChild("animation")->getAttribute("path")->getRestrictedValue(); skillModelFile = unitPath + '/' + sn->getChild("animation")->getAttribute("path")->getRestrictedValue();
}
if(sn->hasChild("particles") == true) {
const XmlNode *particlesNode= sn->getChild("particles"); const XmlNode *particlesNode= sn->getChild("particles");
for(int j = 0; particlesNode != NULL && particlesNode->getAttribute("value")->getRestrictedValue() == "true" && //for(int j = 0; particlesNode != NULL && particlesNode->getAttribute("value")->getRestrictedValue() == "true" &&
j < particlesNode->getChildCount(); ++j) { // j < particlesNode->getChildCount(); ++j) {
const XmlNode *pf= particlesNode->getChild("particle-file", j); if(particlesNode != NULL && particlesNode->getAttribute("value")->getRestrictedValue() == "true" &&
particlesNode->hasChild("particle-file") == true) {
const XmlNode *pf= particlesNode->getChild("particle-file");
if(pf != NULL) { if(pf != NULL) {
skillParticleFile = unitPath + '/' + pf->getAttribute("path")->getRestrictedValue(); skillParticleFile = unitPath + '/' + pf->getAttribute("path")->getRestrictedValue();
break; break;
} }
} }
}
if(sn->hasChild("projectile") == true) {
const XmlNode *particlesProjectileNode= sn->getChild("projectile"); const XmlNode *particlesProjectileNode= sn->getChild("projectile");
for(int j = 0; particlesProjectileNode != NULL && particlesProjectileNode->getAttribute("value")->getRestrictedValue() == "true" && //for(int j = 0; particlesProjectileNode != NULL && particlesProjectileNode->getAttribute("value")->getRestrictedValue() == "true" &&
j < particlesProjectileNode->getChildCount(); ++j) { // j < particlesProjectileNode->getChildCount(); ++j) {
const XmlNode *pf= particlesProjectileNode->getChild("particle", j); if(particlesProjectileNode != NULL && particlesProjectileNode->getAttribute("value")->getRestrictedValue() == "true" &&
particlesProjectileNode->hasChild("particle") == true) {
const XmlNode *pf= particlesProjectileNode->getChild("particle");
if(pf != NULL && pf->getAttribute("value")->getRestrictedValue() == "true") { if(pf != NULL && pf->getAttribute("value")->getRestrictedValue() == "true") {
skillParticleProjectileFile = unitPath + '/' + pf->getAttribute("path")->getRestrictedValue(); skillParticleProjectileFile = unitPath + '/' + pf->getAttribute("path")->getRestrictedValue();
break;
} }
} }
}
if(sn->hasChild("splash") == true) {
const XmlNode *particlesSplashNode= sn->getChild("splash"); const XmlNode *particlesSplashNode= sn->getChild("splash");
for(int j = 0; particlesSplashNode != NULL && particlesSplashNode->getAttribute("value")->getRestrictedValue() == "true" && //for(int j = 0; particlesSplashNode != NULL && particlesSplashNode->getAttribute("value")->getRestrictedValue() == "true" &&
j < particlesSplashNode->getChildCount(); ++j) { // j < particlesSplashNode->getChildCount(); ++j) {
const XmlNode *pf= particlesSplashNode->getChild("particle", j); if(particlesSplashNode != NULL && particlesSplashNode->getAttribute("value")->getRestrictedValue() == "true" &&
particlesSplashNode->hasChild("particle") == true) {
const XmlNode *pf= particlesSplashNode->getChild("particle");
if(pf != NULL && pf->getAttribute("value")->getRestrictedValue() == "true") { if(pf != NULL && pf->getAttribute("value")->getRestrictedValue() == "true") {
skillParticleSplashFile = unitPath + '/' + pf->getAttribute("path")->getRestrictedValue(); skillParticleSplashFile = unitPath + '/' + pf->getAttribute("path")->getRestrictedValue();
break;
} }
} }
}
break; break;
} }
} }
}
if(skillModelFile != "") { if(skillModelFile != "") {
this->modelPathList.push_back(skillModelFile); this->modelPathList.push_back(skillModelFile);
@@ -1640,7 +1650,7 @@ bool App::OnInit(){
} }
} }
std::pair<string,string> unitToLoad; std::pair<string,vector<string> > unitToLoad;
if(hasCommandArgument(argc, argv,(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_UNIT])) == true) { if(hasCommandArgument(argc, argv,(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_UNIT])) == true) {
const wxWX2MBbuf param = (const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_UNIT]); const wxWX2MBbuf param = (const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_UNIT]);
//printf("param = [%s]\n",(const char*)param); //printf("param = [%s]\n",(const char*)param);
@@ -1661,7 +1671,9 @@ bool App::OnInit(){
if(delimitedList.size() >= 2) { if(delimitedList.size() >= 2) {
unitToLoad.first = delimitedList[0]; unitToLoad.first = delimitedList[0];
unitToLoad.second = delimitedList[1]; for(int i = 1; i < delimitedList.size(); ++i) {
unitToLoad.second.push_back(delimitedList[i]);
}
} }
else { else {
printf("\nInvalid path specified on commandline [%s] value [%s]\n\n",(const char *)wxConvCurrent->cWX2MB(argv[foundParamIndIndex]),(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); printf("\nInvalid path specified on commandline [%s] value [%s]\n\n",(const char *)wxConvCurrent->cWX2MB(argv[foundParamIndIndex]),(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));

View File

@@ -74,7 +74,7 @@ private:
Model *model; Model *model;
std::pair<string,string> unitPathList; std::pair<string,vector<string> > unitPath;
std::vector<string> modelPathList; std::vector<string> modelPathList;
std::vector<string> particlePathList; std::vector<string> particlePathList;
std::vector<string> particleProjectilePathList; std::vector<string> particleProjectilePathList;
@@ -112,7 +112,7 @@ private:
void saveScreenshot(); void saveScreenshot();
public: public:
MainWindow( std::pair<string,string> unitToLoad, MainWindow( std::pair<string,vector<string> > unitToLoad,
const string modelPath,const string particlePath, const string modelPath,const string particlePath,
const string projectileParticlePath,const string splashParticlePath, const string projectileParticlePath,const string splashParticlePath,
float defaultAnimation,int defaultParticleLoopStart, float defaultAnimation,int defaultParticleLoopStart,