//////////////////////////////////////////////////////////////////////////// // Load settings from the [screensavername].xml configuration file // the name of the screensaver (filename) is used as the name of // the xml file - this is sent to us by XBMC when the Init func is called. // void CConfig::LoadSettings() { XmlNode node, childNode; //, grandChild; CXmlDocument doc; char szXMLFile[1024]; #ifdef _TEST strcpy(szXMLFile, "MatrixTrails.xml"); #else strcpy(szXMLFile, "Q:\\screensavers\\"); strcat(szXMLFile, gScrName); strcat(szXMLFile, ".xml"); #endif // Load the config file if (doc.Load(szXMLFile) >= 0) { node = doc.GetNextNode(XML_ROOT_NODE); while(node > 0) { if (strcmpi(doc.GetNodeTag(node),"screensaver")) { node = doc.GetNextNode(node); continue; } if (childNode = doc.GetChildNode(node,"CharDelayMin")) m_CharDelayMin = (f32)atof(doc.GetNodeText(childNode)); if (childNode = doc.GetChildNode(node,"CharDelayMax")) m_CharDelayMax = (f32)atof(doc.GetNodeText(childNode)); if (childNode = doc.GetChildNode(node,"FadeSpeedMin")) m_FadeSpeedMin = (f32)atof(doc.GetNodeText(childNode)); if (childNode = doc.GetChildNode(node,"FadeSpeedMax")) m_FadeSpeedMax = (f32)atof(doc.GetNodeText(childNode)); if (childNode = doc.GetChildNode(node,"NumColumns")) m_NumColumns = atoi(doc.GetNodeText(childNode)); if (childNode = doc.GetChildNode(node,"NumRows")) m_NumRows = atoi(doc.GetNodeText(childNode)); if (childNode = doc.GetChildNode(node,"CharCol")) sscanf(doc.GetNodeText(childNode), "%f %f %f", &m_CharCol.r, &m_CharCol.g, &m_CharCol.b); if (childNode = doc.GetChildNode(node,"NumChars")) m_NumChars = atoi(doc.GetNodeText(childNode)); if (childNode = doc.GetChildNode(node,"CharSizeTexX")) m_CharSizeTex.x = (f32)atof(doc.GetNodeText(childNode))/TEXTURESIZE; if (childNode = doc.GetChildNode(node,"CharSizeTexY")) m_CharSizeTex.y = (f32)atof(doc.GetNodeText(childNode))/TEXTURESIZE; node = doc.GetNextNode(node); } doc.Close(); } }
//-- LoadSettings ------------------------------------------------------------- // //----------------------------------------------------------------------------- void ShadeWorm_c::LoadSettings(const char* name) { XmlNode node; CXmlDocument doc; int colId; int index; int col; // Set up the defaults m_numWorms = 16; m_drawTime = 8; m_numColMaps = 0; m_randomColMap = false; char szXMLFile[1024]; strcpy(szXMLFile, "Q:\\screensavers\\"); strcat(szXMLFile, name); strcat(szXMLFile, ".xml"); // Load the config file if (doc.Load(szXMLFile) >= 0) { node = doc.GetNextNode(XML_ROOT_NODE); while(node > 0) { if (!strcmpi(doc.GetNodeTag(node),"NumWorms")) { m_numWorms = atoi(doc.GetNodeText(node)); Clamp(1, 32, m_numWorms); } else if (!strcmpi(doc.GetNodeTag(node),"DrawTime")) { m_drawTime = atoi(doc.GetNodeText(node)); Clamp(1, 10, m_drawTime); } else if (!strcmpi(doc.GetNodeTag(node),"RandomColMap")) { m_randomColMap = !strcmpi(doc.GetNodeText(node),"true"); } else if (!strcmpi(doc.GetNodeTag(node),"Map")) { node = doc.GetNextNode(node); if (m_numColMaps < MAX_COLMAPS) { colId = 0; m_colMaps[m_numColMaps].m_numCols = 0; m_colMaps[m_numColMaps].m_colMap = new ColMapEntry_t[256]; while (node>0) { if (!strcmpi(doc.GetNodeTag(node),"Col")) { if (colId < 256) { char* txt = doc.GetNodeText(node); sscanf(txt, "%d %x\n", &index, &col); if (index > 255) index = 255; if (index < 0) index = 0; m_colMaps[m_numColMaps].m_colMap[colId].m_index = index; m_colMaps[m_numColMaps].m_colMap[colId].m_col = col; colId++; } } else if (!strcmpi(doc.GetNodeTag(node),"/Map")) { m_colMaps[m_numColMaps].m_numCols = colId; m_numColMaps++; break; } node = doc.GetNextNode(node); } } } node = doc.GetNextNode(node); } doc.Close(); } } // LoadSettings
//-- LoadSettings ------------------------------------------------------------- // //----------------------------------------------------------------------------- void ShadeWorm_c::LoadSettings(const char* name) { int colId; int index; int col; // Set up the defaults m_numWorms = 16; m_drawTime = 8; m_numColMaps = 0; m_randomColMap = false; XmlNode node; CXmlDocument doc; char contentPath[MAX_PATH]; getDreamContentPath((char*)&contentPath); char szXMLFile[MAX_PATH]; sprintf((char*)&szXMLFile, "%s\\%s", contentPath, "Resources\\Config.xml"); // Load the config file if (doc.Load(szXMLFile) >= 0) { node = doc.GetNextNode(XML_ROOT_NODE); while(node > 0) { if (!_strcmpi(doc.GetNodeTag(node),"NumWorms")) { m_numWorms = atoi(doc.GetNodeText(node)); Clamp(1, 32, m_numWorms); } else if (!_strcmpi(doc.GetNodeTag(node),"DrawTime")) { m_drawTime = atoi(doc.GetNodeText(node)); Clamp(1, 10, m_drawTime); } else if (!_strcmpi(doc.GetNodeTag(node),"RandomColMap")) { m_randomColMap = !_strcmpi(doc.GetNodeText(node),"true"); } else if (!_strcmpi(doc.GetNodeTag(node),"Map")) { node = doc.GetNextNode(node); if (m_numColMaps < MAX_COLMAPS) { colId = 0; m_colMaps[m_numColMaps].m_numCols = 0; m_colMaps[m_numColMaps].m_colMap = new ColMapEntry_t[256]; while (node>0) { if (!_strcmpi(doc.GetNodeTag(node),"Col")) { if (colId < 256) { char* txt = doc.GetNodeText(node); sscanf(txt, "%d %x\n", &index, &col); if (index > 255) index = 255; if (index < 0) index = 0; m_colMaps[m_numColMaps].m_colMap[colId].m_index = index; m_colMaps[m_numColMaps].m_colMap[colId].m_col = col; colId++; } } else if (!_strcmpi(doc.GetNodeTag(node),"/Map")) { m_colMaps[m_numColMaps].m_numCols = colId; m_numColMaps++; break; } node = doc.GetNextNode(node); } } } node = doc.GetNextNode(node); } doc.Close(); } } // LoadSettings
// Load settings from the [screensavername].xml configuration file // the name of the screensaver (filename) is used as the name of // the xml file - this is sent to us by XBMC when the Init func // is called. void LoadSettings() { XmlNode node, childNode; CXmlDocument doc; char szXMLFile[1024]; strcpy(szXMLFile, "Q:\\screensavers\\"); strcat(szXMLFile, m_szScrName); strcat(szXMLFile, ".xml"); OutputDebugString("Loading XML: "); OutputDebugString(szXMLFile); float xmin = -10.0f, xmax = 10.0f, ymin = -10.0f, ymax = 10.0f, height = 0.0f, elasticity = 0.5f, viscosity = 0.05f, tension = 1.0f, blendability = 0.04f; int xdivs = 50; int ydivs = 50; int divs = 50; SetDefaults(); g_lightDir = D3DXVECTOR3(0.0f,0.6f,-0.8f); // Load the config file if (doc.Load(szXMLFile) >= 0) { node = doc.GetNextNode(XML_ROOT_NODE); while(node > 0) { if (strcmpi(doc.GetNodeTag(node),"screensaver")) { node = doc.GetNextNode(node); continue; } if (childNode = doc.GetChildNode(node,"wireframe")) { world.isWireframe = strcmp(doc.GetNodeText(childNode),"true") == 0; } if (childNode = doc.GetChildNode(node,"elasticity")) { elasticity = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"viscosity")) { viscosity = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"tension")) { tension = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"blendability")) { tension = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"xmin")) { xmin = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"xmax")) { xmax = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"ymin")) { ymin = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"ymax")) { ymax = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"lightx")) { g_lightDir.x = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"lighty")) { g_lightDir.y = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"lightz")) { g_lightDir.z = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"shininess")) { g_shininess = (float)atof(doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"texturefolder")) { strcpy(world.szTextureSearchPath, doc.GetNodeText(childNode)); } if (childNode = doc.GetChildNode(node,"texturemode")) { world.isTextureMode = strcmp(doc.GetNodeText(childNode),"true") == 0; } if (childNode = doc.GetChildNode(node,"nexttexture")) { world.nextTextureTime = (int)(30*(float)atof(doc.GetNodeText(childNode))); } if (childNode = doc.GetChildNode(node,"quality")) { divs = atoi(doc.GetNodeText(childNode)); } node = doc.GetNextNode(node); } doc.Close(); } float scaleRatio = (xmax-xmin)/(ymax-ymin); int totalPoints = (int)(divs * divs * scaleRatio); //world.scaleX = 0.5f; xdivs = (int)sqrt(totalPoints * scaleRatio / world.scaleX); ydivs = totalPoints / xdivs; //xdivs = 144; ydivs= 90; world.waterField = new WaterField(xmin, xmax, ymin, ymax, xdivs, ydivs, height, elasticity, viscosity, tension, blendability, world.isTextureMode); }