File indexing completed on 2024-05-12 05:39:49
0001 /************************************************************************* 0002 * Copyright (C) 2011 by Joseph Boudou * 0003 * Copyright (C) 2014 by Renaud Guezennec * 0004 * * 0005 * https://rolisteam.org/ * 0006 * * 0007 * Rolisteam is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published * 0009 * by the Free Software Foundation; either version 2 of the License, * 0010 * or (at your option) any later version. * 0011 * * 0012 * This program is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0015 * GNU General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU General Public License * 0018 * along with this program; if not, write to the * 0019 * Free Software Foundation, Inc., * 0020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0021 *************************************************************************/ 0022 #ifndef PERSONS_H 0023 #define PERSONS_H 0024 0025 #include <QColor> 0026 #include <QImage> 0027 #include <QList> 0028 #include <QMap> 0029 #include <QObject> 0030 0031 #include "network_global.h" 0032 0033 class Character; 0034 class Player; 0035 0036 /** 0037 * @brief Abstract class for players and characters. 0038 */ 0039 class NETWORK_EXPORT Person : public QObject 0040 { 0041 Q_OBJECT 0042 Q_PROPERTY(QString uuid READ uuid WRITE setUuid NOTIFY uuidChanged) 0043 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) 0044 Q_PROPERTY(QColor color READ getColor WRITE setColor NOTIFY colorChanged) 0045 Q_PROPERTY(QByteArray avatar READ avatar WRITE setAvatar NOTIFY avatarChanged) 0046 public: 0047 Person(QObject* parent= nullptr); 0048 Person(const QString& name, const QColor& color, const QString& uuid= QString()); 0049 virtual ~Person() override; 0050 0051 QString name() const; 0052 QString uuid() const; 0053 0054 QColor getColor() const; 0055 virtual Person* parentPerson() const; 0056 void setParentPerson(Person* parent); 0057 virtual QByteArray avatar() const; 0058 virtual bool hasAvatar() const; 0059 virtual bool isLeaf() const; 0060 0061 virtual QHash<QString, QString> getVariableDictionnary()= 0; 0062 virtual QIcon icon() const; 0063 0064 public slots: 0065 bool setColor(const QColor& color); 0066 virtual void setAvatar(const QByteArray& p); 0067 void setName(const QString& name); 0068 void setUuid(const QString& uuid); 0069 0070 signals: 0071 void uuidChanged(QString id); 0072 void nameChanged(QString id); 0073 void colorChanged(); 0074 void avatarChanged(); 0075 0076 protected: 0077 QString m_name; 0078 QString m_uuid; 0079 QColor m_color; 0080 QByteArray m_avatar; 0081 Person* m_parentPerson= nullptr; 0082 }; 0083 0084 #endif