- fix auto loading scenario from commandline
This commit is contained in:
parent
c7c82b56e1
commit
2c788e074a
|
@ -313,7 +313,8 @@ void MenuStateScenario::update() {
|
||||||
if(this->autoloadScenarioName != "") {
|
if(this->autoloadScenarioName != "") {
|
||||||
string scenarioPath = Scenario::getScenarioPath(dirList, this->autoloadScenarioName);
|
string scenarioPath = Scenario::getScenarioPath(dirList, this->autoloadScenarioName);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("[%s:%s] Line: %d this->autoloadScenarioName [%s] scenarioPath [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->autoloadScenarioName.c_str(),scenarioPath.c_str());
|
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("[%s:%s] Line: %d this->autoloadScenarioName [%s] scenarioPath [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->autoloadScenarioName.c_str(),scenarioPath.c_str());
|
||||||
|
printf("[%s:%s] Line: %d this->autoloadScenarioName [%s] scenarioPath [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->autoloadScenarioName.c_str(),scenarioPath.c_str());
|
||||||
|
|
||||||
loadScenarioInfo(scenarioPath, &scenarioInfo );
|
loadScenarioInfo(scenarioPath, &scenarioInfo );
|
||||||
//if(scenarioInfo.namei18n != "") {
|
//if(scenarioInfo.namei18n != "") {
|
||||||
|
@ -323,7 +324,8 @@ void MenuStateScenario::update() {
|
||||||
this->autoloadScenarioName = formatString(this->autoloadScenarioName);
|
this->autoloadScenarioName = formatString(this->autoloadScenarioName);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("[%s:%s] Line: %d this->autoloadScenarioName [%s] scenarioPath [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->autoloadScenarioName.c_str(),scenarioPath.c_str());
|
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("[%s:%s] Line: %d this->autoloadScenarioName [%s] scenarioPath [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->autoloadScenarioName.c_str(),scenarioPath.c_str());
|
||||||
|
printf("[%s:%s] Line: %d this->autoloadScenarioName [%s] scenarioPath [%s] file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->autoloadScenarioName.c_str(),scenarioPath.c_str(),scenarioInfo.file.c_str());
|
||||||
|
|
||||||
listBoxScenario.setSelectedItem(this->autoloadScenarioName,false);
|
listBoxScenario.setSelectedItem(this->autoloadScenarioName,false);
|
||||||
|
|
||||||
|
@ -335,8 +337,15 @@ void MenuStateScenario::update() {
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
this->autoloadScenarioName = "";
|
this->autoloadScenarioName = "";
|
||||||
if(listBoxScenario.getItemCount() > 0 && listBoxScenario.getSelectedItemIndex() >= 0 && listBoxScenario.getSelectedItemIndex() < (int)scenarioFiles.size()) {
|
if(listBoxScenario.getItemCount() > 0 && listBoxScenario.getSelectedItemIndex() >= 0 &&
|
||||||
|
listBoxScenario.getSelectedItemIndex() < (int)scenarioFiles.size()) {
|
||||||
|
|
||||||
|
printf("[%s:%s] Line: %d scenarioFiles[listBoxScenario.getSelectedItemIndex()] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,scenarioFiles[listBoxScenario.getSelectedItemIndex()].c_str());
|
||||||
|
|
||||||
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[listBoxScenario.getSelectedItemIndex()]), &scenarioInfo);
|
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[listBoxScenario.getSelectedItemIndex()]), &scenarioInfo);
|
||||||
|
|
||||||
|
printf("[%s:%s] Line: %d scenarioInfo.file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,scenarioInfo.file.c_str());
|
||||||
|
|
||||||
labelInfo.setText(scenarioInfo.desc);
|
labelInfo.setText(scenarioInfo.desc);
|
||||||
if(scenarioInfo.namei18n != "") {
|
if(scenarioInfo.namei18n != "") {
|
||||||
labelScenarioName.setText(scenarioInfo.namei18n);
|
labelScenarioName.setText(scenarioInfo.namei18n);
|
||||||
|
|
|
@ -140,6 +140,7 @@ string Scenario::getScenarioPath(const vector<string> dirList, const string &sce
|
||||||
string currentPath = dirList[idx];
|
string currentPath = dirList[idx];
|
||||||
endPathWithSlash(currentPath);
|
endPathWithSlash(currentPath);
|
||||||
scenarioFile = currentPath + scenarioName + "/" + scenarioName + ".xml";
|
scenarioFile = currentPath + scenarioName + "/" + scenarioName + ".xml";
|
||||||
|
//printf("\n[%s:%s] Line: %d scenarioName [%s] scenarioFile [%s]\n",__FILE__,__FUNCTION__,__LINE__,scenarioName.c_str(),scenarioFile.c_str());
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n[%s:%s] Line: %d scenarioName [%s] scenarioFile [%s]\n",__FILE__,__FUNCTION__,__LINE__,scenarioName.c_str(),scenarioFile.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n[%s:%s] Line: %d scenarioName [%s] scenarioFile [%s]\n",__FILE__,__FUNCTION__,__LINE__,scenarioName.c_str(),scenarioFile.c_str());
|
||||||
//printf("\n[%s:%s] Line: %d scenarioName [%s] scenarioFile [%s]\n",__FILE__,__FUNCTION__,__LINE__,scenarioName.c_str(),scenarioFile.c_str());
|
//printf("\n[%s:%s] Line: %d scenarioName [%s] scenarioFile [%s]\n",__FILE__,__FUNCTION__,__LINE__,scenarioName.c_str(),scenarioFile.c_str());
|
||||||
|
|
|
@ -294,7 +294,7 @@ void LuaScript::saveGame(XmlNode *rootNode) {
|
||||||
break;
|
break;
|
||||||
case LUA_TTABLE:
|
case LUA_TTABLE:
|
||||||
{
|
{
|
||||||
if(LuaScript::debugModeEnabled == true) printf("LUA TABLE DETECTED - START\n");
|
if(LuaScript::debugModeEnabled == true) printf("================ LUA TABLE DETECTED - START =================\n");
|
||||||
for (lua_pushnil(L); lua_next(L, -2) ;) {
|
for (lua_pushnil(L); lua_next(L, -2) ;) {
|
||||||
if(LuaScript::debugModeEnabled == true) printf("LUA TABLE loop A\n");
|
if(LuaScript::debugModeEnabled == true) printf("LUA TABLE loop A\n");
|
||||||
|
|
||||||
|
@ -363,6 +363,7 @@ void LuaScript::saveGame(XmlNode *rootNode) {
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(LuaScript::debugModeEnabled == true) printf("---------------------------- LUA TABLE DETECTED - END ----------------------------\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -429,20 +430,25 @@ void LuaScript::loadGame(const XmlNode *rootNode) {
|
||||||
string variable = node->getAttribute("variable")->getValue();
|
string variable = node->getAttribute("variable")->getValue();
|
||||||
int value_type = node->getAttribute("value_type")->getIntValue();
|
int value_type = node->getAttribute("value_type")->getIntValue();
|
||||||
|
|
||||||
if(LuaScript::debugModeEnabled) printf("i: %d [%s] [%d]\n",i,variable.c_str(),value_type);
|
if(LuaScript::debugModeEnabled) printf(" index #: %d [%s] [%d]\n",i,variable.c_str(),value_type);
|
||||||
|
|
||||||
switch (value_type) {
|
switch (value_type) {
|
||||||
case LUA_TSTRING:
|
case LUA_TSTRING:
|
||||||
|
if(LuaScript::debugModeEnabled) printf(" value [%s]\n",node->getAttribute("value")->getValue().c_str());
|
||||||
lua_pushstring( luaState, node->getAttribute("value")->getValue().c_str() );
|
lua_pushstring( luaState, node->getAttribute("value")->getValue().c_str() );
|
||||||
break;
|
break;
|
||||||
case LUA_TNUMBER:
|
case LUA_TNUMBER:
|
||||||
|
if(LuaScript::debugModeEnabled) printf(" value [%s]\n",node->getAttribute("value")->getValue().c_str());
|
||||||
lua_pushnumber( luaState, node->getAttribute("value")->getFloatValue() );
|
lua_pushnumber( luaState, node->getAttribute("value")->getFloatValue() );
|
||||||
break;
|
break;
|
||||||
case LUA_TBOOLEAN:
|
case LUA_TBOOLEAN:
|
||||||
|
if(LuaScript::debugModeEnabled) printf(" value [%s]\n",node->getAttribute("value")->getValue().c_str());
|
||||||
lua_pushboolean( luaState, node->getAttribute("value")->getBoolValue() );
|
lua_pushboolean( luaState, node->getAttribute("value")->getBoolValue() );
|
||||||
break;
|
break;
|
||||||
case LUA_TTABLE:
|
case LUA_TTABLE:
|
||||||
{
|
{
|
||||||
|
if(LuaScript::debugModeEnabled == true) printf("================ LUA TABLE DETECTED - START =================\n");
|
||||||
|
|
||||||
lua_newtable(luaState); /* We will pass a table */
|
lua_newtable(luaState); /* We will pass a table */
|
||||||
vector<XmlNode *> luaScriptTableNode = node->getChildList("Table");
|
vector<XmlNode *> luaScriptTableNode = node->getChildList("Table");
|
||||||
|
|
||||||
|
@ -452,32 +458,44 @@ void LuaScript::loadGame(const XmlNode *rootNode) {
|
||||||
XmlNode *nodeTable = luaScriptTableNode[j];
|
XmlNode *nodeTable = luaScriptTableNode[j];
|
||||||
|
|
||||||
int key_type = nodeTable->getAttribute("key_type")->getIntValue();
|
int key_type = nodeTable->getAttribute("key_type")->getIntValue();
|
||||||
|
if(LuaScript::debugModeEnabled == true) printf("Table item key_type: %d [%s]\n",key_type,lua_typename(luaState, key_type));
|
||||||
|
|
||||||
switch (key_type) {
|
switch (key_type) {
|
||||||
case LUA_TSTRING:
|
case LUA_TSTRING:
|
||||||
|
if(LuaScript::debugModeEnabled) printf(" table item key [%s]\n",nodeTable->getAttribute("key")->getValue().c_str());
|
||||||
lua_pushstring( luaState, nodeTable->getAttribute("key")->getValue().c_str() );
|
lua_pushstring( luaState, nodeTable->getAttribute("key")->getValue().c_str() );
|
||||||
break;
|
break;
|
||||||
case LUA_TNUMBER:
|
case LUA_TNUMBER:
|
||||||
|
if(LuaScript::debugModeEnabled) printf(" table item key [%s]\n",nodeTable->getAttribute("key")->getValue().c_str());
|
||||||
lua_pushnumber( luaState, nodeTable->getAttribute("key")->getFloatValue() );
|
lua_pushnumber( luaState, nodeTable->getAttribute("key")->getFloatValue() );
|
||||||
break;
|
break;
|
||||||
case LUA_TBOOLEAN:
|
case LUA_TBOOLEAN:
|
||||||
|
if(LuaScript::debugModeEnabled) printf(" table item key [%s]\n",nodeTable->getAttribute("key")->getValue().c_str());
|
||||||
lua_pushboolean( luaState, nodeTable->getAttribute("key")->getBoolValue() );
|
lua_pushboolean( luaState, nodeTable->getAttribute("key")->getBoolValue() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int value_type = nodeTable->getAttribute("value_type")->getIntValue();
|
int value_type = nodeTable->getAttribute("value_type")->getIntValue();
|
||||||
|
if(LuaScript::debugModeEnabled == true) printf("Table item value_type: %d [%s]\n",value_type,lua_typename(luaState, value_type));
|
||||||
|
|
||||||
switch (value_type) {
|
switch (value_type) {
|
||||||
case LUA_TSTRING:
|
case LUA_TSTRING:
|
||||||
|
if(LuaScript::debugModeEnabled) printf(" table item value [%s]\n",nodeTable->getAttribute("value")->getValue().c_str());
|
||||||
lua_pushstring( luaState, nodeTable->getAttribute("value")->getValue().c_str() );
|
lua_pushstring( luaState, nodeTable->getAttribute("value")->getValue().c_str() );
|
||||||
break;
|
break;
|
||||||
case LUA_TNUMBER:
|
case LUA_TNUMBER:
|
||||||
|
if(LuaScript::debugModeEnabled) printf(" table item value [%s]\n",nodeTable->getAttribute("value")->getValue().c_str());
|
||||||
lua_pushnumber( luaState, nodeTable->getAttribute("value")->getFloatValue() );
|
lua_pushnumber( luaState, nodeTable->getAttribute("value")->getFloatValue() );
|
||||||
break;
|
break;
|
||||||
case LUA_TBOOLEAN:
|
case LUA_TBOOLEAN:
|
||||||
|
if(LuaScript::debugModeEnabled) printf(" table item value [%s]\n",nodeTable->getAttribute("value")->getValue().c_str());
|
||||||
lua_pushboolean( luaState, nodeTable->getAttribute("value")->getBoolValue() );
|
lua_pushboolean( luaState, nodeTable->getAttribute("value")->getBoolValue() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_rawset(luaState, -3); /* Stores the pair in the table */
|
lua_rawset(luaState, -3); /* Stores the pair in the table */
|
||||||
}
|
}
|
||||||
|
if(LuaScript::debugModeEnabled == true) printf("----------------- LUA TABLE DETECTED - END -----------------\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user