Exemplo n.º 1
0
 bool MapParser::parseBrushes(const BBox& worldBounds, Model::BrushList& brushes) {
     size_t oldSize = brushes.size();
     try {
         Model::Brush* brush = NULL;
         while ((brush = parseBrush(worldBounds, NULL)) != NULL)
             brushes.push_back(brush);
         return !brushes.empty();
     } catch (MapParserException e) {
         Utility::deleteAll(brushes, oldSize);
         m_tokenizer.reset();
         return false;
     }
 }
Exemplo n.º 2
0
 Model::Entity* MapParser::parseEntity(const BBox& worldBounds, Utility::ProgressIndicator* indicator) {
     Token token = m_tokenizer.nextToken();
     if (token.type() == TokenType::Eof)
         return NULL;
     
     expect(TokenType::OBrace | TokenType::CBrace, token);
     if (token.type() == TokenType::CBrace)
         return NULL;
     
     Model::Entity* entity = new Model::Entity(worldBounds);
     size_t firstLine = token.line();
     
     while ((token = m_tokenizer.nextToken()).type() != TokenType::Eof) {
         switch (token.type()) {
             case TokenType::String: {
                 String key = token.data();
                 expect(TokenType::String, token = m_tokenizer.nextToken());
                 String value = token.data();
                 entity->setProperty(key, value);
                 break;
             }
             case TokenType::OBrace: {
                 m_tokenizer.pushToken(token);
                 bool moreBrushes = true;
                 while (moreBrushes) {
                     Model::Brush* brush = parseBrush(worldBounds, indicator);
                     if (brush != NULL)
                         entity->addBrush(*brush);
                     expect(TokenType::OBrace | TokenType::CBrace, token = m_tokenizer.nextToken());
                     moreBrushes = (token.type() == TokenType::OBrace);
                     m_tokenizer.pushToken(token);
                 }
                 break;
             }
             case TokenType::CBrace: {
                 if (indicator != NULL)
                     indicator->update(static_cast<int>(token.position()));
                 entity->setFilePosition(firstLine, token.line() - firstLine);
                 return entity;
             }
             default:
                 delete entity;
                 throw MapParserException(token, TokenType::String | TokenType::OBrace | TokenType::CBrace);
         }
     }
     
     return entity;
 }
Exemplo n.º 3
0
TxSkin::brush* TxSkin::parseBrush( LPWSTR section, LPWSTR key, LPWSTR iniFile )
{
	WCHAR str[255];
	GetPrivateProfileString(section, key, L"", str, 255, iniFile);
	return parseBrush(str);
}