Пример #1
0
void SkinManager::parseScript(DataStreamPtr& stream, const String& groupName)
{
	try
	{
		String line = "";
		Skin *pSkin = 0;

		while(!stream->eof())
		{
			line = stream->getLine();

			// Ignore blanks & comments
			if (!line.length() || line.substr(0, 2) == "//")
			{
				continue;
			}

			if (!pSkin)
			{
				// No current skin
				// So first valid data should be skin name
#ifdef ROR_USE_OGRE_1_9
				pSkin = (Skin *)createResource(line, groupName).getPointer();
#else
				pSkin = (Skin *)create(line, groupName).getPointer();
#endif
				if (pSkin)
				{
					pSkin->_notifyOrigin(stream->getName());
					stream->skipLine("{");
				}
			} else
			{
				// Already in skin
				if (line == "}")
				{
					// Finished
					//addImpl((Ogre::ResourcePtr)pSkin);
					pSkin = 0;
					// NB skin isn't loaded until required
				} else
				{
					ParseSkinAttribute(line, pSkin);
				}
			}
		}
	} catch(Ogre::ItemIdentityException e)
	{
		// this catches duplicates -> to be ignored
		// this happens since we load the full skin data off the cache, so we don't need
		// to re-add it to the SkinManager
		return;
	}
}
Пример #2
0
    //---------------------------------------------------------------------
    void FontManager::parseScript(DataStreamPtr& stream, const String& groupName)
    {
        String line;
        FontPtr pFont;

        while( !stream->eof() )
        {
            line = stream->getLine();
            // Ignore blanks & comments
            if( !line.length() || line.substr( 0, 2 ) == "//" )
            {
                continue;
            }
            else
            {
                if (pFont.isNull())
                {
                    // No current font
                    // So first valid data should be font name
                    if (StringUtil::startsWith(line, "font "))
                    {
                        // chop off the 'particle_system ' needed by new compilers
                        line = line.substr(5);
                    }
                    pFont = create(line, groupName);
                    pFont->_notifyOrigin(stream->getName());
                    // Skip to and over next {
                    stream->skipLine("{");
                }
                else
                {
                    // Already in font
                    if (line == "}")
                    {
                        // Finished 
                        pFont.setNull();
                        // NB font isn't loaded until required
                    }
                    else
                    {
                        parseAttribute(line, pFont);
                    }
                }
            }
        }
    }