示例#1
0
////////////////////////////////////////////////////////////////////////////
// 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();
	}
}
示例#2
0
// 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);
}