avatar changes
This commit is contained in:
parent
28a77f10e4
commit
2f422f5a20
6 changed files with 29 additions and 19 deletions
|
@ -20,8 +20,8 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Player::Player(const QString &_name, int _id, bool _local, TabGame *_parent)
|
Player::Player(ServerInfo_User *info, int _id, bool _local, TabGame *_parent)
|
||||||
: QObject(_parent), shortcutsActive(false), defaultNumberTopCards(3), lastTokenDestroy(true), name(_name), id(_id), active(false), local(_local), mirrored(false), dialogSemaphore(false)
|
: QObject(_parent), shortcutsActive(false), defaultNumberTopCards(3), lastTokenDestroy(true), userInfo(new ServerInfo_User(info)), id(_id), active(false), local(_local), mirrored(false), dialogSemaphore(false)
|
||||||
{
|
{
|
||||||
setCacheMode(DeviceCoordinateCache);
|
setCacheMode(DeviceCoordinateCache);
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ Player::Player(const QString &_name, int _id, bool _local, TabGame *_parent)
|
||||||
connect(settingsCache, SIGNAL(playerBgPathChanged()), this, SLOT(updateBgPixmap()));
|
connect(settingsCache, SIGNAL(playerBgPathChanged()), this, SLOT(updateBgPixmap()));
|
||||||
updateBgPixmap();
|
updateBgPixmap();
|
||||||
|
|
||||||
playerTarget = new PlayerTarget(name, CARD_WIDTH + counterAreaWidth + 5, this);
|
// playerTarget = new PlayerTarget(CARD_WIDTH + counterAreaWidth + 5, this);
|
||||||
|
playerTarget = new PlayerTarget(this);
|
||||||
playerTarget->setPos(QPointF(0, 0));
|
playerTarget->setPos(QPointF(0, 0));
|
||||||
|
|
||||||
QPointF base = QPointF(counterAreaWidth, 50);
|
QPointF base = QPointF(counterAreaWidth, 50);
|
||||||
|
@ -239,6 +240,7 @@ Player::~Player()
|
||||||
|
|
||||||
clearCounters();
|
clearCounters();
|
||||||
delete playerMenu;
|
delete playerMenu;
|
||||||
|
delete userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::rearrangeZones()
|
void Player::rearrangeZones()
|
||||||
|
@ -289,7 +291,7 @@ void Player::retranslateUi()
|
||||||
{
|
{
|
||||||
aViewGraveyard->setText(tr("&View graveyard"));
|
aViewGraveyard->setText(tr("&View graveyard"));
|
||||||
aViewRfg->setText(tr("&View exile"));
|
aViewRfg->setText(tr("&View exile"));
|
||||||
playerMenu->setTitle(tr("Player \"%1\"").arg(name));
|
playerMenu->setTitle(tr("Player \"%1\"").arg(userInfo->getName()));
|
||||||
graveMenu->setTitle(tr("&Graveyard"));
|
graveMenu->setTitle(tr("&Graveyard"));
|
||||||
rfgMenu->setTitle(tr("&Exile"));
|
rfgMenu->setTitle(tr("&Exile"));
|
||||||
|
|
||||||
|
@ -1270,6 +1272,11 @@ QMenu *Player::getCardMenu() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Player::getName() const
|
||||||
|
{
|
||||||
|
return userInfo->getName();
|
||||||
|
}
|
||||||
|
|
||||||
qreal Player::getMinimumWidth() const
|
qreal Player::getMinimumWidth() const
|
||||||
{
|
{
|
||||||
qreal result = table->getMinimumWidth() + CARD_WIDTH + 5 + counterAreaWidth;
|
qreal result = table->getMinimumWidth() + CARD_WIDTH + 5 + counterAreaWidth;
|
||||||
|
|
|
@ -17,6 +17,7 @@ class CardZone;
|
||||||
class TableZone;
|
class TableZone;
|
||||||
class HandZone;
|
class HandZone;
|
||||||
class PlayerTarget;
|
class PlayerTarget;
|
||||||
|
class ServerInfo_User;
|
||||||
class ServerInfo_Player;
|
class ServerInfo_Player;
|
||||||
class ServerInfo_Arrow;
|
class ServerInfo_Arrow;
|
||||||
class ServerInfo_Counter;
|
class ServerInfo_Counter;
|
||||||
|
@ -115,7 +116,7 @@ private:
|
||||||
int defaultNumberTopCards;
|
int defaultNumberTopCards;
|
||||||
QString lastTokenName, lastTokenColor, lastTokenPT, lastTokenAnnotation;
|
QString lastTokenName, lastTokenColor, lastTokenPT, lastTokenAnnotation;
|
||||||
bool lastTokenDestroy;
|
bool lastTokenDestroy;
|
||||||
QString name;
|
ServerInfo_User *userInfo;
|
||||||
int id;
|
int id;
|
||||||
bool active;
|
bool active;
|
||||||
bool local;
|
bool local;
|
||||||
|
@ -183,12 +184,13 @@ public:
|
||||||
void clearArrows();
|
void clearArrows();
|
||||||
PlayerTarget *getPlayerTarget() const { return playerTarget; }
|
PlayerTarget *getPlayerTarget() const { return playerTarget; }
|
||||||
|
|
||||||
Player(const QString &_name, int _id, bool _local, TabGame *_parent);
|
Player(ServerInfo_User *info, int _id, bool _local, TabGame *_parent);
|
||||||
~Player();
|
~Player();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
QMenu *getPlayerMenu() const { return playerMenu; }
|
QMenu *getPlayerMenu() const { return playerMenu; }
|
||||||
int getId() const { return id; }
|
int getId() const { return id; }
|
||||||
QString getName() const { return name; }
|
QString getName() const;
|
||||||
|
ServerInfo_User *getUserInfo() const { return userInfo; }
|
||||||
bool getLocal() const { return local; }
|
bool getLocal() const { return local; }
|
||||||
bool getMirrored() const { return mirrored; }
|
bool getMirrored() const { return mirrored; }
|
||||||
const QMap<QString, CardZone *> &getZones() const { return zones; }
|
const QMap<QString, CardZone *> &getZones() const { return zones; }
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#include "playertarget.h"
|
#include "playertarget.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
#include "protocol_datastructures.h"
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
PlayerTarget::PlayerTarget(const QString &_name, int _maxWidth, Player *_owner)
|
PlayerTarget::PlayerTarget(Player *_owner)
|
||||||
: ArrowTarget(_owner, _owner), name(_name), maxWidth(_maxWidth)
|
: ArrowTarget(_owner, _owner)
|
||||||
{
|
{
|
||||||
font = QFont("Times");
|
font = QFont("Times");
|
||||||
font.setStyleHint(QFont::Serif);
|
font.setStyleHint(QFont::Serif);
|
||||||
|
@ -12,13 +13,14 @@ PlayerTarget::PlayerTarget(const QString &_name, int _maxWidth, Player *_owner)
|
||||||
|
|
||||||
QRectF PlayerTarget::boundingRect() const
|
QRectF PlayerTarget::boundingRect() const
|
||||||
{
|
{
|
||||||
return QRectF(0, 0, maxWidth, 30);
|
return QRectF(0, 0, 64, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||||
{
|
{
|
||||||
|
ServerInfo_User *info = owner->getUserInfo();
|
||||||
painter->fillRect(boundingRect(), QColor(255, 255, 255, 100));
|
painter->fillRect(boundingRect(), QColor(255, 255, 255, 100));
|
||||||
painter->setFont(font);
|
painter->setFont(font);
|
||||||
painter->setPen(Qt::black);
|
painter->setPen(Qt::black);
|
||||||
painter->drawText(boundingRect(), Qt::AlignCenter, name);
|
painter->drawText(boundingRect(), Qt::AlignCenter, info->getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,12 @@ class Player;
|
||||||
|
|
||||||
class PlayerTarget : public ArrowTarget {
|
class PlayerTarget : public ArrowTarget {
|
||||||
private:
|
private:
|
||||||
QString name;
|
|
||||||
QFont font;
|
QFont font;
|
||||||
int maxWidth;
|
|
||||||
public:
|
public:
|
||||||
enum { Type = typePlayerTarget };
|
enum { Type = typePlayerTarget };
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
|
|
||||||
PlayerTarget(const QString &_name, int _maxWidth, Player *parent = 0);
|
PlayerTarget(Player *parent = 0);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
};
|
};
|
||||||
|
|
|
@ -320,10 +320,10 @@ void TabGame::actRemoveLocalArrows()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Player *TabGame::addPlayer(int playerId, const QString &playerName)
|
Player *TabGame::addPlayer(int playerId, ServerInfo_User *info)
|
||||||
{
|
{
|
||||||
bool local = ((clients.size() > 1) || (playerId == localPlayerId));
|
bool local = ((clients.size() > 1) || (playerId == localPlayerId));
|
||||||
Player *newPlayer = new Player(playerName, playerId, local, this);
|
Player *newPlayer = new Player(info, playerId, local, this);
|
||||||
scene->addPlayer(newPlayer);
|
scene->addPlayer(newPlayer);
|
||||||
|
|
||||||
connect(newPlayer, SIGNAL(newCardAdded(AbstractCardItem *)), this, SLOT(newCardAdded(AbstractCardItem *)));
|
connect(newPlayer, SIGNAL(newCardAdded(AbstractCardItem *)), this, SLOT(newCardAdded(AbstractCardItem *)));
|
||||||
|
@ -494,7 +494,7 @@ void TabGame::eventGameStateChanged(Event_GameStateChanged *event, GameEventCont
|
||||||
} else {
|
} else {
|
||||||
Player *player = players.value(prop->getPlayerId(), 0);
|
Player *player = players.value(prop->getPlayerId(), 0);
|
||||||
if (!player) {
|
if (!player) {
|
||||||
player = addPlayer(prop->getPlayerId(), prop->getUserInfo()->getName());
|
player = addPlayer(prop->getPlayerId(), prop->getUserInfo());
|
||||||
playerListWidget->addPlayer(prop);
|
playerListWidget->addPlayer(prop);
|
||||||
}
|
}
|
||||||
player->processPlayerInfo(pl);
|
player->processPlayerInfo(pl);
|
||||||
|
@ -560,7 +560,7 @@ void TabGame::eventJoin(Event_Join *event, GameEventContext * /*context*/)
|
||||||
messageLog->logJoinSpectator(playerInfo->getUserInfo()->getName());
|
messageLog->logJoinSpectator(playerInfo->getUserInfo()->getName());
|
||||||
playerListWidget->addPlayer(playerInfo);
|
playerListWidget->addPlayer(playerInfo);
|
||||||
} else {
|
} else {
|
||||||
Player *newPlayer = addPlayer(playerInfo->getPlayerId(), playerInfo->getUserInfo()->getName());
|
Player *newPlayer = addPlayer(playerInfo->getPlayerId(), playerInfo->getUserInfo());
|
||||||
messageLog->logJoin(newPlayer);
|
messageLog->logJoin(newPlayer);
|
||||||
playerListWidget->addPlayer(playerInfo);
|
playerListWidget->addPlayer(playerInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ class TabGame;
|
||||||
class DeckList;
|
class DeckList;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
|
class ServerInfo_User;
|
||||||
|
|
||||||
class ReadyStartButton : public QPushButton {
|
class ReadyStartButton : public QPushButton {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -111,7 +112,7 @@ private:
|
||||||
QMenu *playersMenu;
|
QMenu *playersMenu;
|
||||||
QAction *aConcede, *aLeaveGame, *aNextPhase, *aNextTurn, *aRemoveLocalArrows;
|
QAction *aConcede, *aLeaveGame, *aNextPhase, *aNextTurn, *aRemoveLocalArrows;
|
||||||
|
|
||||||
Player *addPlayer(int playerId, const QString &playerName);
|
Player *addPlayer(int playerId, ServerInfo_User *info);
|
||||||
|
|
||||||
void startGame();
|
void startGame();
|
||||||
void stopGame();
|
void stopGame();
|
||||||
|
|
Loading…
Reference in a new issue