#pragma once //this will make sure that we can use qt with boost (else moc compiler errors) #ifndef QT_NO_KEYWORDS #define QT_NO_KEYWORDS #endif #include #include #include #include #include #include #include "rbx/signal.h" #include "V8Tree/Instance.h" #include "Util/HttpAsync.h" namespace RBX { class DataModel; class BrickColor; namespace Network { class Player; } } typedef QMap PlayersColorCollection; typedef QMap PlayersInfoCollection; typedef boost::unordered_map > PlayerSelectionMap; Q_DECLARE_METATYPE(PlayersColorCollection) class AvatarLoader: public QObject { Q_OBJECT public: AvatarLoader(int playerId, int backgroundColor); int getPlayerId() { return m_PlayerId; } bool hasFinishedLoading() { return m_bFinishedLoading; } QImage& getAvatar() { return m_PlayerAvatar; } Q_SIGNALS: void avatarLoaded(const QImage& image); private: Q_INVOKABLE void headshotThumbnailDataLoaded(int playerId, RBX::HttpFuture future); Q_INVOKABLE void headshotThumbnailLoaded(int playerId, RBX::HttpFuture future); QImage m_PlayerAvatar; int m_PlayerId; int m_BackgroundColor; bool m_bFinishedLoading; }; class PlayersDataManager: public QObject { Q_OBJECT public: PlayersDataManager(QObject* parent, boost::shared_ptr dataModel); ~PlayersDataManager(); void getPlayerAvatar(int playerId, QObject* resultListener, const char* callbackName); void getPlayerName(int playerId, QObject* resultListener, const char* callbackName); int getPlayerColor(int playerId); // must be called with a datamodel lock shared_ptr getLastKnownSelection(int playerId); bool isLocalPlayer(boost::shared_ptr player); boost::shared_ptr getPlayer(const QString& playerName, Qt::CaseSensitivity cs = Qt::CaseInsensitive); Q_SIGNALS: void cloudEditSelectionChanged(int playerId); void playerNameLoaded(int playerId, const QString& playerName); private: QSharedPointer getAvatarLoader(int playerId); void onPlayerAdded(shared_ptr playerInstance); void onPlayerRemoving(shared_ptr playerInstance); void onCloudEditSelectionChanged(int playerId, shared_ptr& newSelection); Q_INVOKABLE void onPlayerNameLoaded(RBX::HttpFuture future); void loadPlayersColorSettings(); void savePlayersColorSettings(); int getNextUnassignedColor(); PlayerSelectionMap m_lastKnownSelectionByPlayerId; boost::shared_ptr m_pDataModel; QList > m_AvatarLoaders; PlayersColorCollection m_PlayersColor; PlayersInfoCollection m_PlayersInfo; int m_CurrentColorCount; };