/*! \brief Processes the game's achievements list. It arrives as a JSON object. We parse it and send it to the mainwindow. \param data The data to be parsed. */ void Steam::processReplyAchievements( const QByteArray &data ) { AchievementList achievementList; if( ! data.isEmpty() ) { JSONStreamReader jsonReader; JSONObject *json = jsonReader.read( data ); if( jsonReader.hasError() ) SteamPrivate::jsonError( jsonReader ); else { JSONObject *availableGameStats = NULL; JSONList *achievements = NULL; JSONObject *game = json->valueObject( QL( "game" ) ); if( game ) availableGameStats = game->valueObject( QL( "availableGameStats" ) ); if( availableGameStats ) achievements = availableGameStats->valueList( QL( "achievements" ) ); for( int i = 0; achievements && i < achievements->count(); i++ ) { JSONValue *val = achievements->at( i ); if( ! val || ! val->type() == JSONValue::T_Object ) continue; JSONObject *achievementJson = dynamic_cast< JSONObject * >( val ); achievementList << Achievement( achievementJson ); } } delete json; json = NULL; } emit( achievements( achievementList ) ); }
Achievement& AchievementSet::AddAchievement() { m_Achievements.push_back( Achievement( m_nSetType ) ); return m_Achievements.back(); }