Example #1
0
void Client::addPlayer(const QString &player_info){
    QStringList texts = player_info.split(":");
    QString name = texts.at(0);
    QString base64 = texts.at(1);
    QByteArray data = QByteArray::fromBase64(base64.toAscii());
    QString screen_name = QString::fromUtf8(data);
    QString avatar = texts.at(2);

    ClientPlayer *player = new ClientPlayer(this);
    player->setObjectName(name);
    player->setScreenName(screen_name);
    player->setProperty("avatar", avatar);

    alive_count ++;

    emit player_added(player);
}
Example #2
0
void Client::addPlayer(const QJsonValue &player_info){
	QJsonArray texts = player_info.toArray();
	QString name = texts.at(0).toString();
	QString screen_name = texts.at(1).toString();
	QString avatar = texts.at(2).toString();

	ClientPlayer *player = new ClientPlayer(this);
	player->setObjectName(name);
	player->setScreenName(screen_name);
	player->setProperty("avatar", avatar);

	players << player;

	alive_count++;

	emit player_added(player);
}