bool PlayerManager::load()
{
    std::cout << "Load XML file" << std::endl;

    if (!NullDevice)
    {
        std::cout << "Any device !" << std::endl;
        return false;
    }

    io::IXMLReader* xml = NullDevice->getFileSystem()->createXMLReader(playerFilePath);
    if (!xml)
    {
        std::cout << "Can't create XMLReader !" << std::endl;
        return false;
    }

    const core::stringw statTag(L"stat");
    core::stringw currentSection;
    const core::stringw playerTag(L"player");

    while (xml->read())
    {
        switch (xml->getNodeType())
        {
            case io::EXN_ELEMENT:
            {
                if (currentSection.empty() && playerTag.equals_ignore_case(xml->getNodeName()))
                    currentSection = playerTag;

                else if (currentSection.equals_ignore_case(playerTag) && statTag.equals_ignore_case(xml->getNodeName() ))
                {
                    core::stringw key = xml->getAttributeValueSafe(L"name");
                    if(!key.empty())
                        PlayerMap[key] = xml->getAttributeValueSafe(L"value");
                }
            }break;

            case io::EXN_ELEMENT_END:
                currentSection = L"";
            break;

            default:
            break;
        }
    }

    xml->drop();

    std::cout << "File loaded" << std::endl;
    return true;
}
Example #2
0
bool GUITable::doesRowStartWith(const Row *row, const core::stringw &str) const
{
	if (row == NULL)
		return false;

	for (s32 j = 0; j < row->cellcount; ++j) {
		Cell *cell = &row->cells[j];
		if (cell->content_type == COLUMN_TYPE_TEXT) {
			const core::stringw &cellstr = m_strings[cell->content_index];
			if (cellstr.size() >= str.size() &&
					str.equals_ignore_case(cellstr.subString(0, str.size())))
				return true;
		}
	}
	return false;
}