mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 00:04:48 -07:00
user details box
This commit is contained in:
parent
09595cc691
commit
7f7398de6a
12 changed files with 207 additions and 85 deletions
|
|
@ -3,11 +3,12 @@
|
|||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
ServerInfo_User::ServerInfo_User(const QString &_name, int _userLevel, const QString &_country, const QByteArray &_avatarBmp)
|
||||
ServerInfo_User::ServerInfo_User(const QString &_name, int _userLevel, const QString &_realName, const QString &_country, const QByteArray &_avatarBmp)
|
||||
: SerializableItem_Map("user")
|
||||
{
|
||||
insertItem(new SerializableItem_String("name", _name));
|
||||
insertItem(new SerializableItem_Int("userlevel", _userLevel));
|
||||
insertItem(new SerializableItem_String("real_name", _realName));
|
||||
insertItem(new SerializableItem_String("country", _country));
|
||||
insertItem(new SerializableItem_ByteArray("avatar_bmp", _avatarBmp));
|
||||
}
|
||||
|
|
@ -17,6 +18,7 @@ ServerInfo_User::ServerInfo_User(const ServerInfo_User *other, bool complete)
|
|||
{
|
||||
insertItem(new SerializableItem_String("name", other->getName()));
|
||||
insertItem(new SerializableItem_Int("userlevel", other->getUserLevel()));
|
||||
insertItem(new SerializableItem_String("real_name", other->getRealName()));
|
||||
insertItem(new SerializableItem_String("country", other->getCountry()));
|
||||
insertItem(new SerializableItem_ByteArray("avatar_bmp", complete ? other->getAvatarBmp() : QByteArray()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,12 +29,13 @@ public:
|
|||
IsJudge = 0x04,
|
||||
IsAdmin = 0x08
|
||||
};
|
||||
ServerInfo_User(const QString &_name = QString(), int _userLevel = IsNothing, const QString &_country = QString(), const QByteArray &_avatarBmp = QByteArray());
|
||||
ServerInfo_User(const QString &_name = QString(), int _userLevel = IsNothing, const QString &_realName = QString(), const QString &_country = QString(), const QByteArray &_avatarBmp = QByteArray());
|
||||
ServerInfo_User(const ServerInfo_User *other, bool complete = true);
|
||||
static SerializableItem *newItem() { return new ServerInfo_User; }
|
||||
QString getName() const { return static_cast<SerializableItem_String *>(itemMap.value("name"))->getData(); }
|
||||
int getUserLevel() const { return static_cast<SerializableItem_Int *>(itemMap.value("userlevel"))->getData(); }
|
||||
void setUserLevel(int _userLevel) { static_cast<SerializableItem_Int *>(itemMap.value("userlevel"))->setData(_userLevel); }
|
||||
QString getRealName() const { return static_cast<SerializableItem_String *>(itemMap.value("real_name"))->getData(); }
|
||||
QString getCountry() const { return static_cast<SerializableItem_String *>(itemMap.value("country"))->getData(); }
|
||||
QByteArray getAvatarBmp() const { return static_cast<SerializableItem_ByteArray *>(itemMap.value("avatar_bmp"))->getData(); }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -266,9 +266,9 @@ ResponseCode Server_ProtocolHandler::cmdGetUserInfo(Command_GetUserInfo *cmd, Co
|
|||
Server_ProtocolHandler *handler = server->getUsers().value(cmd->getUserName());
|
||||
if (!handler)
|
||||
return RespNameNotFound;
|
||||
result = handler->getUserInfo();
|
||||
result = new ServerInfo_User(handler->getUserInfo());
|
||||
}
|
||||
|
||||
|
||||
cont->setResponse(new Response_GetUserInfo(cont->getCmdId(), RespOk, result));
|
||||
return RespNothing;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue