Merge branch 'devel' of git://github.com/mbruker/Cockatrice into devel
This commit is contained in:
commit
539b693ac4
60 changed files with 1399 additions and 993 deletions
|
@ -63,6 +63,7 @@ SET(cockatrice_SOURCES
|
||||||
src/chatview.cpp
|
src/chatview.cpp
|
||||||
src/userlist.cpp
|
src/userlist.cpp
|
||||||
src/userinfobox.cpp
|
src/userinfobox.cpp
|
||||||
|
src/user_context_menu.cpp
|
||||||
src/remotedecklist_treewidget.cpp
|
src/remotedecklist_treewidget.cpp
|
||||||
src/remotereplaylist_treewidget.cpp
|
src/remotereplaylist_treewidget.cpp
|
||||||
src/deckview.cpp
|
src/deckview.cpp
|
||||||
|
@ -135,6 +136,7 @@ SET(cockatrice_HEADERS
|
||||||
src/chatview.h
|
src/chatview.h
|
||||||
src/userlist.h
|
src/userlist.h
|
||||||
src/userinfobox.h
|
src/userinfobox.h
|
||||||
|
src/user_context_menu.h
|
||||||
src/remotedecklist_treewidget.h
|
src/remotedecklist_treewidget.h
|
||||||
src/remotereplaylist_treewidget.h
|
src/remotereplaylist_treewidget.h
|
||||||
src/deckview.h
|
src/deckview.h
|
||||||
|
|
|
@ -25,7 +25,6 @@ AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, int _id
|
||||||
|
|
||||||
AbstractCardItem::~AbstractCardItem()
|
AbstractCardItem::~AbstractCardItem()
|
||||||
{
|
{
|
||||||
qDebug() << "AbstractCardItem destructor:" << name;
|
|
||||||
emit deleteCardInfoPopup(name);
|
emit deleteCardInfoPopup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,6 +234,7 @@ void PictureLoader::setPicDownload(bool _picDownload)
|
||||||
|
|
||||||
CardInfo::CardInfo(CardDatabase *_db,
|
CardInfo::CardInfo(CardDatabase *_db,
|
||||||
const QString &_name,
|
const QString &_name,
|
||||||
|
bool _isToken,
|
||||||
const QString &_manacost,
|
const QString &_manacost,
|
||||||
const QString &_cardtype,
|
const QString &_cardtype,
|
||||||
const QString &_powtough,
|
const QString &_powtough,
|
||||||
|
@ -248,6 +249,7 @@ CardInfo::CardInfo(CardDatabase *_db,
|
||||||
const QMap<QString, QString> &_picURLsSt)
|
const QMap<QString, QString> &_picURLsSt)
|
||||||
: db(_db),
|
: db(_db),
|
||||||
name(_name),
|
name(_name),
|
||||||
|
isToken(_isToken),
|
||||||
sets(_sets),
|
sets(_sets),
|
||||||
manacost(_manacost),
|
manacost(_manacost),
|
||||||
cardtype(_cardtype),
|
cardtype(_cardtype),
|
||||||
|
@ -426,6 +428,8 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
||||||
xml.writeTextElement("loyalty", QString::number(info->getLoyalty()));
|
xml.writeTextElement("loyalty", QString::number(info->getLoyalty()));
|
||||||
if (info->getCipt())
|
if (info->getCipt())
|
||||||
xml.writeTextElement("cipt", "1");
|
xml.writeTextElement("cipt", "1");
|
||||||
|
if (info->getIsToken())
|
||||||
|
xml.writeTextElement("token", "1");
|
||||||
xml.writeEndElement(); // card
|
xml.writeEndElement(); // card
|
||||||
|
|
||||||
return xml;
|
return xml;
|
||||||
|
@ -469,7 +473,7 @@ void CardDatabase::clear()
|
||||||
delete setIt.value();
|
delete setIt.value();
|
||||||
}
|
}
|
||||||
setHash.clear();
|
setHash.clear();
|
||||||
|
|
||||||
QHashIterator<QString, CardInfo *> i(cardHash);
|
QHashIterator<QString, CardInfo *> i(cardHash);
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
i.next();
|
i.next();
|
||||||
|
@ -485,7 +489,7 @@ CardInfo *CardDatabase::getCard(const QString &cardName)
|
||||||
else if (cardHash.contains(cardName))
|
else if (cardHash.contains(cardName))
|
||||||
return cardHash.value(cardName);
|
return cardHash.value(cardName);
|
||||||
else {
|
else {
|
||||||
CardInfo *newCard = new CardInfo(this, cardName);
|
CardInfo *newCard = new CardInfo(this, cardName, true);
|
||||||
newCard->addToSet(getSet("TK"));
|
newCard->addToSet(getSet("TK"));
|
||||||
cardHash.insert(cardName, newCard);
|
cardHash.insert(cardName, newCard);
|
||||||
return newCard;
|
return newCard;
|
||||||
|
@ -558,6 +562,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
int tableRow = 0;
|
int tableRow = 0;
|
||||||
int loyalty = 0;
|
int loyalty = 0;
|
||||||
bool cipt = false;
|
bool cipt = false;
|
||||||
|
bool isToken = false;
|
||||||
while (!xml.atEnd()) {
|
while (!xml.atEnd()) {
|
||||||
if (xml.readNext() == QXmlStreamReader::EndElement)
|
if (xml.readNext() == QXmlStreamReader::EndElement)
|
||||||
break;
|
break;
|
||||||
|
@ -588,8 +593,10 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
|
||||||
cipt = (xml.readElementText() == "1");
|
cipt = (xml.readElementText() == "1");
|
||||||
else if (xml.name() == "loyalty")
|
else if (xml.name() == "loyalty")
|
||||||
loyalty = xml.readElementText().toInt();
|
loyalty = xml.readElementText().toInt();
|
||||||
|
else if (xml.name() == "token")
|
||||||
|
isToken = xml.readElementText().toInt();
|
||||||
}
|
}
|
||||||
cardHash.insert(name, new CardInfo(this, name, manacost, type, pt, text, colors, loyalty, cipt, tableRow, sets, picURLs, picURLsHq, picURLsSt));
|
cardHash.insert(name, new CardInfo(this, name, isToken, manacost, type, pt, text, colors, loyalty, cipt, tableRow, sets, picURLs, picURLsHq, picURLsSt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,7 @@ private:
|
||||||
CardDatabase *db;
|
CardDatabase *db;
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
|
bool isToken;
|
||||||
SetList sets;
|
SetList sets;
|
||||||
QString manacost;
|
QString manacost;
|
||||||
QString cardtype;
|
QString cardtype;
|
||||||
|
@ -106,6 +107,7 @@ private:
|
||||||
public:
|
public:
|
||||||
CardInfo(CardDatabase *_db,
|
CardInfo(CardDatabase *_db,
|
||||||
const QString &_name = QString(),
|
const QString &_name = QString(),
|
||||||
|
bool _isToken = false,
|
||||||
const QString &_manacost = QString(),
|
const QString &_manacost = QString(),
|
||||||
const QString &_cardtype = QString(),
|
const QString &_cardtype = QString(),
|
||||||
const QString &_powtough = QString(),
|
const QString &_powtough = QString(),
|
||||||
|
@ -120,6 +122,7 @@ public:
|
||||||
const QStringMap &_picURLsSt = QStringMap());
|
const QStringMap &_picURLsSt = QStringMap());
|
||||||
~CardInfo();
|
~CardInfo();
|
||||||
const QString &getName() const { return name; }
|
const QString &getName() const { return name; }
|
||||||
|
bool getIsToken() const { return isToken; }
|
||||||
const SetList &getSets() const { return sets; }
|
const SetList &getSets() const { return sets; }
|
||||||
const QString &getManaCost() const { return manacost; }
|
const QString &getManaCost() const { return manacost; }
|
||||||
const QString &getCardType() const { return cardtype; }
|
const QString &getCardType() const { return cardtype; }
|
||||||
|
|
|
@ -71,7 +71,8 @@ void CardDatabaseModel::updateCardList()
|
||||||
}
|
}
|
||||||
|
|
||||||
CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
|
CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
|
||||||
: QSortFilterProxyModel(parent)
|
: QSortFilterProxyModel(parent),
|
||||||
|
isToken(ShowAll)
|
||||||
{
|
{
|
||||||
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
setSortCaseSensitivity(Qt::CaseInsensitive);
|
setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
@ -79,7 +80,10 @@ CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
|
||||||
|
|
||||||
bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
|
bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
|
||||||
{
|
{
|
||||||
CardInfo *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
|
CardInfo const *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
|
||||||
|
|
||||||
|
if (((isToken == ShowTrue) && !info->getIsToken()) || (isToken == ShowFalse) && info->getIsToken())
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!cardNameBeginning.isEmpty())
|
if (!cardNameBeginning.isEmpty())
|
||||||
if (!info->getName().startsWith(cardNameBeginning, Qt::CaseInsensitive))
|
if (!info->getName().startsWith(cardNameBeginning, Qt::CaseInsensitive))
|
||||||
|
@ -89,6 +93,10 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
|
||||||
if (!info->getName().contains(cardName, Qt::CaseInsensitive))
|
if (!info->getName().contains(cardName, Qt::CaseInsensitive))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!cardNameSet.isEmpty())
|
||||||
|
if (!cardNameSet.contains(info->getName()))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!cardText.isEmpty())
|
if (!cardText.isEmpty())
|
||||||
if (!info->getText().contains(cardText, Qt::CaseInsensitive))
|
if (!info->getText().contains(cardText, Qt::CaseInsensitive))
|
||||||
return false;
|
return false;
|
||||||
|
@ -96,7 +104,7 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
|
||||||
if (!cardColors.isEmpty())
|
if (!cardColors.isEmpty())
|
||||||
if (QSet<QString>::fromList(info->getColors()).intersect(cardColors).isEmpty() && !(info->getColors().isEmpty() && cardColors.contains("X")))
|
if (QSet<QString>::fromList(info->getColors()).intersect(cardColors).isEmpty() && !(info->getColors().isEmpty() && cardColors.contains("X")))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!cardTypes.isEmpty())
|
if (!cardTypes.isEmpty())
|
||||||
if (!cardTypes.contains(info->getMainCardType()))
|
if (!cardTypes.contains(info->getMainCardType()))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
CardInfo *getCard(int index) const { return cardList[index]; }
|
CardInfo const *getCard(int index) const { return cardList[index]; }
|
||||||
private:
|
private:
|
||||||
QList<CardInfo *> cardList;
|
QList<CardInfo *> cardList;
|
||||||
CardDatabase *db;
|
CardDatabase *db;
|
||||||
|
@ -26,13 +26,18 @@ private slots:
|
||||||
|
|
||||||
class CardDatabaseDisplayModel : public QSortFilterProxyModel {
|
class CardDatabaseDisplayModel : public QSortFilterProxyModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum FilterBool { ShowTrue, ShowFalse, ShowAll };
|
||||||
private:
|
private:
|
||||||
|
FilterBool isToken;
|
||||||
QString cardNameBeginning, cardName, cardText;
|
QString cardNameBeginning, cardName, cardText;
|
||||||
QSet<QString> cardTypes, cardColors;
|
QSet<QString> cardNameSet, cardTypes, cardColors;
|
||||||
public:
|
public:
|
||||||
CardDatabaseDisplayModel(QObject *parent = 0);
|
CardDatabaseDisplayModel(QObject *parent = 0);
|
||||||
|
void setIsToken(FilterBool _isToken) { isToken = _isToken; invalidate(); }
|
||||||
void setCardNameBeginning(const QString &_beginning) { cardNameBeginning = _beginning; invalidate(); }
|
void setCardNameBeginning(const QString &_beginning) { cardNameBeginning = _beginning; invalidate(); }
|
||||||
void setCardName(const QString &_cardName) { cardName = _cardName; invalidate(); }
|
void setCardName(const QString &_cardName) { cardName = _cardName; invalidate(); }
|
||||||
|
void setCardNameSet(const QSet<QString> &_cardNameSet) { cardNameSet = _cardNameSet; invalidate(); }
|
||||||
void setCardText(const QString &_cardText) { cardText = _cardText; invalidate(); }
|
void setCardText(const QString &_cardText) { cardText = _cardText; invalidate(); }
|
||||||
void setCardTypes(const QSet<QString> &_cardTypes) { cardTypes = _cardTypes; invalidate(); }
|
void setCardTypes(const QSet<QString> &_cardTypes) { cardTypes = _cardTypes; invalidate(); }
|
||||||
void setCardColors(const QSet<QString> &_cardColors) { cardColors = _cardColors; invalidate(); }
|
void setCardColors(const QSet<QString> &_cardColors) { cardColors = _cardColors; invalidate(); }
|
||||||
|
|
|
@ -4,16 +4,29 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include "chatview.h"
|
#include "chatview.h"
|
||||||
|
#include "user_level.h"
|
||||||
|
#include "user_context_menu.h"
|
||||||
|
#include "tab_supervisor.h"
|
||||||
|
#include "pixmapgenerator.h"
|
||||||
|
|
||||||
ChatView::ChatView(const QString &_ownName, bool _showTimestamps, QWidget *parent)
|
ChatView::ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTimestamps, QWidget *parent)
|
||||||
: QTextBrowser(parent), evenNumber(true), ownName(_ownName), showTimestamps(_showTimestamps)
|
: QTextBrowser(parent), tabSupervisor(_tabSupervisor), game(_game), evenNumber(true), showTimestamps(_showTimestamps), hoveredItemType(HoveredNothing)
|
||||||
{
|
{
|
||||||
|
userContextMenu = new UserContextMenu(tabSupervisor, this, game);
|
||||||
|
connect(userContextMenu, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
|
||||||
|
|
||||||
|
viewport()->setCursor(Qt::IBeamCursor);
|
||||||
setReadOnly(true);
|
setReadOnly(true);
|
||||||
setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
|
setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
|
||||||
setOpenLinks(false);
|
setOpenLinks(false);
|
||||||
connect(this, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl &)));
|
connect(this, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatView::retranslateUi()
|
||||||
|
{
|
||||||
|
userContextMenu->retranslateUi();
|
||||||
|
}
|
||||||
|
|
||||||
QTextCursor ChatView::prepareBlock(bool same)
|
QTextCursor ChatView::prepareBlock(bool same)
|
||||||
{
|
{
|
||||||
lastSender.clear();
|
lastSender.clear();
|
||||||
|
@ -40,7 +53,7 @@ void ChatView::appendHtml(const QString &html)
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatView::appendMessage(QString sender, QString message, QColor playerColor, bool playerBold)
|
void ChatView::appendMessage(QString message, QString sender, UserLevelFlags userLevel, bool playerBold)
|
||||||
{
|
{
|
||||||
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
||||||
bool sameSender = (sender == lastSender) && !lastSender.isEmpty();
|
bool sameSender = (sender == lastSender) && !lastSender.isEmpty();
|
||||||
|
@ -55,18 +68,22 @@ void ChatView::appendMessage(QString sender, QString message, QColor playerColor
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextCharFormat senderFormat;
|
QTextCharFormat senderFormat;
|
||||||
if (sender == ownName) {
|
if (tabSupervisor && (sender == QString::fromStdString(tabSupervisor->getUserInfo()->name()))) {
|
||||||
senderFormat.setFontWeight(QFont::Bold);
|
senderFormat.setFontWeight(QFont::Bold);
|
||||||
senderFormat.setForeground(Qt::red);
|
senderFormat.setForeground(Qt::red);
|
||||||
} else {
|
} else {
|
||||||
if (playerColor == QColor())
|
senderFormat.setForeground(Qt::blue);
|
||||||
senderFormat.setForeground(QColor(0, 0, 254));
|
|
||||||
else
|
|
||||||
senderFormat.setForeground(playerColor);
|
|
||||||
if (playerBold)
|
if (playerBold)
|
||||||
senderFormat.setFontWeight(QFont::Bold);
|
senderFormat.setFontWeight(QFont::Bold);
|
||||||
}
|
}
|
||||||
|
senderFormat.setAnchor(true);
|
||||||
|
senderFormat.setAnchorHref("user://" + QString::number(userLevel) + "_" + sender);
|
||||||
if (!sameSender) {
|
if (!sameSender) {
|
||||||
|
if (!sender.isEmpty()) {
|
||||||
|
const int pixelSize = QFontInfo(cursor.charFormat().font()).pixelSize();
|
||||||
|
cursor.insertImage(UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel).toImage(), QString::number(pixelSize) + "_" + QString::number((int) userLevel));
|
||||||
|
cursor.insertText(" ");
|
||||||
|
}
|
||||||
cursor.setCharFormat(senderFormat);
|
cursor.setCharFormat(senderFormat);
|
||||||
if (!sender.isEmpty())
|
if (!sender.isEmpty())
|
||||||
sender.append(": ");
|
sender.append(": ");
|
||||||
|
@ -88,33 +105,41 @@ void ChatView::appendMessage(QString sender, QString message, QColor playerColor
|
||||||
|
|
||||||
if (message.startsWith("[card]")) {
|
if (message.startsWith("[card]")) {
|
||||||
message = message.mid(6);
|
message = message.mid(6);
|
||||||
QTextCharFormat tempFormat = messageFormat;
|
|
||||||
tempFormat.setForeground(Qt::blue);
|
|
||||||
cursor.setCharFormat(tempFormat);
|
|
||||||
int closeTagIndex = message.indexOf("[/card]");
|
int closeTagIndex = message.indexOf("[/card]");
|
||||||
cursor.insertText(message.left(closeTagIndex));
|
QString cardName = message.left(closeTagIndex);
|
||||||
cursor.setCharFormat(messageFormat);
|
|
||||||
if (closeTagIndex == -1)
|
if (closeTagIndex == -1)
|
||||||
message.clear();
|
message.clear();
|
||||||
else
|
else
|
||||||
message = message.mid(closeTagIndex + 7);
|
message = message.mid(closeTagIndex + 7);
|
||||||
|
|
||||||
|
QTextCharFormat tempFormat = messageFormat;
|
||||||
|
tempFormat.setForeground(Qt::blue);
|
||||||
|
tempFormat.setAnchor(true);
|
||||||
|
tempFormat.setAnchorHref("card://" + cardName);
|
||||||
|
|
||||||
|
cursor.setCharFormat(tempFormat);
|
||||||
|
cursor.insertText(cardName);
|
||||||
|
cursor.setCharFormat(messageFormat);
|
||||||
} else if (message.startsWith("[url]")) {
|
} else if (message.startsWith("[url]")) {
|
||||||
message = message.mid(5);
|
message = message.mid(5);
|
||||||
int closeTagIndex = message.indexOf("[/url]");
|
int closeTagIndex = message.indexOf("[/url]");
|
||||||
QString url = message.left(closeTagIndex);
|
QString url = message.left(closeTagIndex);
|
||||||
if (!url.startsWith("http://"))
|
|
||||||
url.prepend("http://");
|
|
||||||
QTextCharFormat tempFormat = messageFormat;
|
|
||||||
tempFormat.setForeground(QColor(0, 0, 254));
|
|
||||||
tempFormat.setAnchor(true);
|
|
||||||
tempFormat.setAnchorHref(url);
|
|
||||||
cursor.setCharFormat(tempFormat);
|
|
||||||
cursor.insertText(url);
|
|
||||||
cursor.setCharFormat(messageFormat);
|
|
||||||
if (closeTagIndex == -1)
|
if (closeTagIndex == -1)
|
||||||
message.clear();
|
message.clear();
|
||||||
else
|
else
|
||||||
message = message.mid(closeTagIndex + 6);
|
message = message.mid(closeTagIndex + 6);
|
||||||
|
|
||||||
|
if (!url.contains("://"))
|
||||||
|
url.prepend("http://");
|
||||||
|
|
||||||
|
QTextCharFormat tempFormat = messageFormat;
|
||||||
|
tempFormat.setForeground(Qt::blue);
|
||||||
|
tempFormat.setAnchor(true);
|
||||||
|
tempFormat.setAnchorHref(url);
|
||||||
|
|
||||||
|
cursor.setCharFormat(tempFormat);
|
||||||
|
cursor.insertText(url);
|
||||||
|
cursor.setCharFormat(messageFormat);
|
||||||
} else
|
} else
|
||||||
from = 1;
|
from = 1;
|
||||||
}
|
}
|
||||||
|
@ -148,47 +173,61 @@ QTextFragment ChatView::getFragmentUnderMouse(const QPoint &pos) const
|
||||||
return QTextFragment();
|
return QTextFragment();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChatView::getCardNameUnderMouse(QTextFragment frag) const
|
|
||||||
{
|
|
||||||
if (frag.charFormat().foreground().color() == Qt::blue)
|
|
||||||
return frag.text();
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ChatView::getCardNameUnderMouse(const QPoint &pos) const
|
|
||||||
{
|
|
||||||
return getCardNameUnderMouse(getFragmentUnderMouse(pos));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChatView::mouseMoveEvent(QMouseEvent *event)
|
void ChatView::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QTextFragment frag = getFragmentUnderMouse(event->pos());
|
QString anchorHref = getFragmentUnderMouse(event->pos()).charFormat().anchorHref();
|
||||||
QString cardName = getCardNameUnderMouse(frag);
|
if (!anchorHref.isEmpty()) {
|
||||||
if (!cardName.isEmpty()) {
|
const int delimiterIndex = anchorHref.indexOf("://");
|
||||||
viewport()->setCursor(Qt::PointingHandCursor);
|
if (delimiterIndex != -1) {
|
||||||
emit cardNameHovered(cardName);
|
const QString scheme = anchorHref.left(delimiterIndex);
|
||||||
} else if (frag.charFormat().isAnchor())
|
hoveredContent = anchorHref.mid(delimiterIndex + 3);
|
||||||
viewport()->setCursor(Qt::PointingHandCursor);
|
if (scheme == "card") {
|
||||||
else
|
hoveredItemType = HoveredCard;
|
||||||
|
emit cardNameHovered(hoveredContent);
|
||||||
|
} else if (scheme == "user")
|
||||||
|
hoveredItemType = HoveredUser;
|
||||||
|
else
|
||||||
|
hoveredItemType = HoveredUrl;
|
||||||
|
viewport()->setCursor(Qt::PointingHandCursor);
|
||||||
|
} else {
|
||||||
|
hoveredItemType = HoveredNothing;
|
||||||
|
viewport()->setCursor(Qt::IBeamCursor);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hoveredItemType = HoveredNothing;
|
||||||
viewport()->setCursor(Qt::IBeamCursor);
|
viewport()->setCursor(Qt::IBeamCursor);
|
||||||
|
}
|
||||||
|
|
||||||
QTextBrowser::mouseMoveEvent(event);
|
QTextBrowser::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatView::mousePressEvent(QMouseEvent *event)
|
void ChatView::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if ((event->button() == Qt::MidButton) || (event->button() == Qt::LeftButton)) {
|
switch (hoveredItemType) {
|
||||||
QString cardName = getCardNameUnderMouse(event->pos());
|
case HoveredCard: {
|
||||||
if (!cardName.isEmpty())
|
if ((event->button() == Qt::MidButton) || (event->button() == Qt::LeftButton))
|
||||||
emit showCardInfoPopup(event->globalPos(), cardName);
|
emit showCardInfoPopup(event->globalPos(), hoveredContent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HoveredUser: {
|
||||||
|
if (event->button() == Qt::RightButton) {
|
||||||
|
const int delimiterIndex = hoveredContent.indexOf("_");
|
||||||
|
UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt());
|
||||||
|
const QString userName = hoveredContent.mid(delimiterIndex + 1);
|
||||||
|
|
||||||
|
userContextMenu->showContextMenu(event->globalPos(), userName, userLevel);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
QTextBrowser::mousePressEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextBrowser::mousePressEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatView::mouseReleaseEvent(QMouseEvent *event)
|
void ChatView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if ((event->button() == Qt::MidButton) || (event->button() == Qt::LeftButton))
|
if (hoveredItemType == HoveredCard && ((event->button() == Qt::MidButton) || (event->button() == Qt::LeftButton)))
|
||||||
emit deleteCardInfoPopup(QString("_"));
|
emit deleteCardInfoPopup(QString("_"));
|
||||||
|
|
||||||
QTextBrowser::mouseReleaseEvent(event);
|
QTextBrowser::mouseReleaseEvent(event);
|
||||||
|
@ -196,5 +235,8 @@ void ChatView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void ChatView::openLink(const QUrl &link)
|
void ChatView::openLink(const QUrl &link)
|
||||||
{
|
{
|
||||||
|
if ((link.scheme() == "card") || (link.scheme() == "user"))
|
||||||
|
return;
|
||||||
|
|
||||||
QDesktopServices::openUrl(link);
|
QDesktopServices::openUrl(link);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,27 +5,36 @@
|
||||||
#include <QTextFragment>
|
#include <QTextFragment>
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include "user_level.h"
|
||||||
|
|
||||||
class QTextTable;
|
class QTextTable;
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
|
class UserContextMenu;
|
||||||
|
class TabSupervisor;
|
||||||
|
class TabGame;
|
||||||
|
|
||||||
class ChatView : public QTextBrowser {
|
class ChatView : public QTextBrowser {
|
||||||
Q_OBJECT;
|
Q_OBJECT
|
||||||
|
protected:
|
||||||
|
const TabSupervisor * const tabSupervisor;
|
||||||
|
TabGame * const game;
|
||||||
private:
|
private:
|
||||||
|
enum HoveredItemType { HoveredNothing, HoveredUrl, HoveredCard, HoveredUser };
|
||||||
|
UserContextMenu *userContextMenu;
|
||||||
QString lastSender;
|
QString lastSender;
|
||||||
bool evenNumber;
|
bool evenNumber;
|
||||||
QString ownName;
|
|
||||||
bool showTimestamps;
|
bool showTimestamps;
|
||||||
|
HoveredItemType hoveredItemType;
|
||||||
|
QString hoveredContent;
|
||||||
QTextFragment getFragmentUnderMouse(const QPoint &pos) const;
|
QTextFragment getFragmentUnderMouse(const QPoint &pos) const;
|
||||||
QString getCardNameUnderMouse(QTextFragment frag) const;
|
|
||||||
QString getCardNameUnderMouse(const QPoint &pos) const;
|
|
||||||
QTextCursor prepareBlock(bool same = false);
|
QTextCursor prepareBlock(bool same = false);
|
||||||
private slots:
|
private slots:
|
||||||
void openLink(const QUrl &link);
|
void openLink(const QUrl &link);
|
||||||
public:
|
public:
|
||||||
ChatView(const QString &_ownName, bool _showTimestamps, QWidget *parent = 0);
|
ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTimestamps, QWidget *parent = 0);
|
||||||
|
void retranslateUi();
|
||||||
void appendHtml(const QString &html);
|
void appendHtml(const QString &html);
|
||||||
void appendMessage(QString sender, QString message, QColor playerColor = QColor(), bool playerBold = false);
|
void appendMessage(QString message, QString sender = QString(), UserLevelFlags userLevel = UserLevelFlags(), bool playerBold = false);
|
||||||
protected:
|
protected:
|
||||||
void enterEvent(QEvent *event);
|
void enterEvent(QEvent *event);
|
||||||
void leaveEvent(QEvent *event);
|
void leaveEvent(QEvent *event);
|
||||||
|
@ -33,6 +42,7 @@ protected:
|
||||||
void mousePressEvent(QMouseEvent *event);
|
void mousePressEvent(QMouseEvent *event);
|
||||||
void mouseReleaseEvent(QMouseEvent *event);
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
signals:
|
signals:
|
||||||
|
void openMessageDialog(const QString &userName, bool focus);
|
||||||
void cardNameHovered(QString cardName);
|
void cardNameHovered(QString cardName);
|
||||||
void showCardInfoPopup(QPoint pos, QString cardName);
|
void showCardInfoPopup(QPoint pos, QString cardName);
|
||||||
void deleteCardInfoPopup(QString cardName);
|
void deleteCardInfoPopup(QString cardName);
|
||||||
|
|
|
@ -274,6 +274,7 @@ DeckViewScene::DeckViewScene(QObject *parent)
|
||||||
DeckViewScene::~DeckViewScene()
|
DeckViewScene::~DeckViewScene()
|
||||||
{
|
{
|
||||||
clearContents();
|
clearContents();
|
||||||
|
delete deck;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckViewScene::clearContents()
|
void DeckViewScene::clearContents()
|
||||||
|
|
|
@ -6,10 +6,17 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QTreeView>
|
||||||
|
#include <QRadioButton>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include "decklist.h"
|
||||||
#include "dlg_create_token.h"
|
#include "dlg_create_token.h"
|
||||||
|
#include "carddatabasemodel.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
DlgCreateToken::DlgCreateToken(QWidget *parent)
|
DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent), predefinedTokens(_predefinedTokens)
|
||||||
{
|
{
|
||||||
nameLabel = new QLabel(tr("&Name:"));
|
nameLabel = new QLabel(tr("&Name:"));
|
||||||
nameEdit = new QLineEdit(tr("Token"));
|
nameEdit = new QLineEdit(tr("Token"));
|
||||||
|
@ -24,7 +31,7 @@ DlgCreateToken::DlgCreateToken(QWidget *parent)
|
||||||
colorEdit->addItem(tr("red"), "r");
|
colorEdit->addItem(tr("red"), "r");
|
||||||
colorEdit->addItem(tr("green"), "g");
|
colorEdit->addItem(tr("green"), "g");
|
||||||
colorEdit->addItem(tr("multicolor"), "m");
|
colorEdit->addItem(tr("multicolor"), "m");
|
||||||
colorEdit->addItem(tr("colorless"), "");
|
colorEdit->addItem(tr("colorless"), QString());
|
||||||
colorLabel->setBuddy(colorEdit);
|
colorLabel->setBuddy(colorEdit);
|
||||||
|
|
||||||
ptLabel = new QLabel(tr("&P/T:"));
|
ptLabel = new QLabel(tr("&P/T:"));
|
||||||
|
@ -49,12 +56,62 @@ DlgCreateToken::DlgCreateToken(QWidget *parent)
|
||||||
grid->addWidget(annotationEdit, 3, 1);
|
grid->addWidget(annotationEdit, 3, 1);
|
||||||
grid->addWidget(destroyCheckBox, 4, 0, 1, 2);
|
grid->addWidget(destroyCheckBox, 4, 0, 1, 2);
|
||||||
|
|
||||||
|
QGroupBox *tokenDataGroupBox = new QGroupBox(tr("Token data"));
|
||||||
|
tokenDataGroupBox->setLayout(grid);
|
||||||
|
|
||||||
|
cardDatabaseModel = new CardDatabaseModel(db, this);
|
||||||
|
cardDatabaseDisplayModel = new CardDatabaseDisplayModel(this);
|
||||||
|
cardDatabaseDisplayModel->setSourceModel(cardDatabaseModel);
|
||||||
|
cardDatabaseDisplayModel->setIsToken(CardDatabaseDisplayModel::ShowTrue);
|
||||||
|
|
||||||
|
chooseTokenFromAllRadioButton = new QRadioButton(tr("Show &all tokens"));
|
||||||
|
connect(chooseTokenFromAllRadioButton, SIGNAL(toggled(bool)), this, SLOT(actChooseTokenFromAll(bool)));
|
||||||
|
chooseTokenFromDeckRadioButton = new QRadioButton(tr("Show tokens from this &deck"));
|
||||||
|
connect(chooseTokenFromDeckRadioButton, SIGNAL(toggled(bool)), this, SLOT(actChooseTokenFromDeck(bool)));
|
||||||
|
QTreeView *chooseTokenView = new QTreeView;
|
||||||
|
chooseTokenView->setModel(cardDatabaseDisplayModel);
|
||||||
|
chooseTokenView->setUniformRowHeights(true);
|
||||||
|
chooseTokenView->setRootIsDecorated(false);
|
||||||
|
chooseTokenView->setAlternatingRowColors(true);
|
||||||
|
chooseTokenView->setSortingEnabled(true);
|
||||||
|
chooseTokenView->sortByColumn(0, Qt::AscendingOrder);
|
||||||
|
chooseTokenView->resizeColumnToContents(0);
|
||||||
|
chooseTokenView->header()->setStretchLastSection(false);
|
||||||
|
chooseTokenView->header()->hideSection(1);
|
||||||
|
chooseTokenView->header()->hideSection(2);
|
||||||
|
chooseTokenView->header()->setResizeMode(3, QHeaderView::ResizeToContents);
|
||||||
|
chooseTokenView->header()->setResizeMode(4, QHeaderView::ResizeToContents);
|
||||||
|
connect(chooseTokenView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(tokenSelectionChanged(QModelIndex, QModelIndex)));
|
||||||
|
|
||||||
|
if (predefinedTokens.isEmpty())
|
||||||
|
chooseTokenFromAllRadioButton->setChecked(true);
|
||||||
|
else {
|
||||||
|
chooseTokenFromDeckRadioButton->setChecked(true);
|
||||||
|
cardDatabaseDisplayModel->setCardNameSet(QSet<QString>::fromList(predefinedTokens));
|
||||||
|
}
|
||||||
|
|
||||||
|
QVBoxLayout *tokenChooseLayout = new QVBoxLayout;
|
||||||
|
tokenChooseLayout->addWidget(chooseTokenFromAllRadioButton);
|
||||||
|
tokenChooseLayout->addWidget(chooseTokenFromDeckRadioButton);
|
||||||
|
tokenChooseLayout->addWidget(chooseTokenView);
|
||||||
|
|
||||||
|
QGroupBox *tokenChooseGroupBox = new QGroupBox(tr("Choose token from list"));
|
||||||
|
tokenChooseGroupBox->setLayout(tokenChooseLayout);
|
||||||
|
|
||||||
|
QVBoxLayout *leftVBox = new QVBoxLayout;
|
||||||
|
leftVBox->addWidget(tokenDataGroupBox);
|
||||||
|
leftVBox->addStretch();
|
||||||
|
|
||||||
|
QHBoxLayout *hbox = new QHBoxLayout;
|
||||||
|
hbox->addLayout(leftVBox);
|
||||||
|
hbox->addWidget(tokenChooseGroupBox);
|
||||||
|
|
||||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk()));
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk()));
|
||||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(grid);
|
mainLayout->addLayout(hbox);
|
||||||
mainLayout->addWidget(buttonBox);
|
mainLayout->addWidget(buttonBox);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
@ -63,6 +120,30 @@ DlgCreateToken::DlgCreateToken(QWidget *parent)
|
||||||
setMinimumWidth(300);
|
setMinimumWidth(300);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DlgCreateToken::tokenSelectionChanged(const QModelIndex ¤t, const QModelIndex & /*previous*/)
|
||||||
|
{
|
||||||
|
const QModelIndex realIndex = cardDatabaseDisplayModel->mapToSource(current);
|
||||||
|
const CardInfo *cardInfo = cardDatabaseModel->getCard(realIndex.row());
|
||||||
|
|
||||||
|
nameEdit->setText(cardInfo->getName());
|
||||||
|
const QString cardColor = cardInfo->getColors().isEmpty() ? QString() : (cardInfo->getColors().size() > 1 ? QString("m") : cardInfo->getColors().first());
|
||||||
|
colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString));
|
||||||
|
ptEdit->setText(cardInfo->getPowTough());
|
||||||
|
annotationEdit->setText(cardInfo->getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgCreateToken::actChooseTokenFromAll(bool checked)
|
||||||
|
{
|
||||||
|
if (checked)
|
||||||
|
cardDatabaseDisplayModel->setCardNameSet(QSet<QString>());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgCreateToken::actChooseTokenFromDeck(bool checked)
|
||||||
|
{
|
||||||
|
if (checked)
|
||||||
|
cardDatabaseDisplayModel->setCardNameSet(QSet<QString>::fromList(predefinedTokens));
|
||||||
|
}
|
||||||
|
|
||||||
void DlgCreateToken::actOk()
|
void DlgCreateToken::actOk()
|
||||||
{
|
{
|
||||||
accept();
|
accept();
|
||||||
|
|
|
@ -2,29 +2,41 @@
|
||||||
#define DLG_CREATETOKEN_H
|
#define DLG_CREATETOKEN_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QLineEdit>
|
#include <QModelIndex>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class QLineEdit;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QRadioButton;
|
||||||
|
class DeckList;
|
||||||
|
class CardDatabaseModel;
|
||||||
|
class CardDatabaseDisplayModel;
|
||||||
|
|
||||||
class DlgCreateToken : public QDialog {
|
class DlgCreateToken : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DlgCreateToken(QWidget *parent = 0);
|
DlgCreateToken(const QStringList &_predefinedTokens, QWidget *parent = 0);
|
||||||
QString getName() const;
|
QString getName() const;
|
||||||
QString getColor() const;
|
QString getColor() const;
|
||||||
QString getPT() const;
|
QString getPT() const;
|
||||||
QString getAnnotation() const;
|
QString getAnnotation() const;
|
||||||
bool getDestroy() const;
|
bool getDestroy() const;
|
||||||
private slots:
|
private slots:
|
||||||
|
void tokenSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
|
void actChooseTokenFromAll(bool checked);
|
||||||
|
void actChooseTokenFromDeck(bool checked);
|
||||||
void actOk();
|
void actOk();
|
||||||
private:
|
private:
|
||||||
|
CardDatabaseModel *cardDatabaseModel;
|
||||||
|
CardDatabaseDisplayModel *cardDatabaseDisplayModel;
|
||||||
|
QStringList predefinedTokens;
|
||||||
QLabel *nameLabel, *colorLabel, *ptLabel, *annotationLabel;
|
QLabel *nameLabel, *colorLabel, *ptLabel, *annotationLabel;
|
||||||
QComboBox *colorEdit;
|
QComboBox *colorEdit;
|
||||||
QLineEdit *nameEdit, *ptEdit, *annotationEdit;
|
QLineEdit *nameEdit, *ptEdit, *annotationEdit;
|
||||||
QCheckBox *destroyCheckBox;
|
QCheckBox *destroyCheckBox;
|
||||||
|
QRadioButton *chooseTokenFromAllRadioButton, *chooseTokenFromDeckRadioButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -55,7 +55,8 @@ void DlgCreateGame::sharedCtor()
|
||||||
|
|
||||||
onlyBuddiesCheckBox = new QCheckBox(tr("Only &buddies can join"));
|
onlyBuddiesCheckBox = new QCheckBox(tr("Only &buddies can join"));
|
||||||
onlyRegisteredCheckBox = new QCheckBox(tr("Only ®istered users can join"));
|
onlyRegisteredCheckBox = new QCheckBox(tr("Only ®istered users can join"));
|
||||||
onlyRegisteredCheckBox->setChecked(true);
|
if (room && room->getUserInfo()->user_level() & ServerInfo_User::IsRegistered)
|
||||||
|
onlyRegisteredCheckBox->setChecked(true);
|
||||||
|
|
||||||
QGridLayout *joinRestrictionsLayout = new QGridLayout;
|
QGridLayout *joinRestrictionsLayout = new QGridLayout;
|
||||||
joinRestrictionsLayout->addWidget(passwordLabel, 0, 0);
|
joinRestrictionsLayout->addWidget(passwordLabel, 0, 0);
|
||||||
|
|
|
@ -61,12 +61,17 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &allGameTypes, QWidget *
|
||||||
QGroupBox *maxPlayersGroupBox = new QGroupBox(tr("Maximum player count"));
|
QGroupBox *maxPlayersGroupBox = new QGroupBox(tr("Maximum player count"));
|
||||||
maxPlayersGroupBox->setLayout(maxPlayersFilterLayout);
|
maxPlayersGroupBox->setLayout(maxPlayersFilterLayout);
|
||||||
|
|
||||||
QGridLayout *leftColumn = new QGridLayout;
|
QGridLayout *leftGrid = new QGridLayout;
|
||||||
leftColumn->addWidget(gameNameFilterLabel, 0, 0);
|
leftGrid->addWidget(gameNameFilterLabel, 0, 0);
|
||||||
leftColumn->addWidget(gameNameFilterEdit, 0, 1);
|
leftGrid->addWidget(gameNameFilterEdit, 0, 1);
|
||||||
leftColumn->addWidget(creatorNameFilterLabel, 1, 0);
|
leftGrid->addWidget(creatorNameFilterLabel, 1, 0);
|
||||||
leftColumn->addWidget(creatorNameFilterEdit, 1, 1);
|
leftGrid->addWidget(creatorNameFilterEdit, 1, 1);
|
||||||
leftColumn->addWidget(maxPlayersGroupBox, 2, 0, 1, 2);
|
leftGrid->addWidget(maxPlayersGroupBox, 2, 0, 1, 2);
|
||||||
|
leftGrid->addWidget(unavailableGamesVisibleCheckBox, 3, 0, 1, 2);
|
||||||
|
|
||||||
|
QVBoxLayout *leftColumn = new QVBoxLayout;
|
||||||
|
leftColumn->addLayout(leftGrid);
|
||||||
|
leftColumn->addStretch();
|
||||||
|
|
||||||
QVBoxLayout *rightColumn = new QVBoxLayout;
|
QVBoxLayout *rightColumn = new QVBoxLayout;
|
||||||
rightColumn->addWidget(gameTypeFilterGroupBox);
|
rightColumn->addWidget(gameTypeFilterGroupBox);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "pb/serverinfo_game.pb.h"
|
#include "pb/serverinfo_game.pb.h"
|
||||||
#include "pb/response.pb.h"
|
#include "pb/response.pb.h"
|
||||||
|
|
||||||
GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent)
|
GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent)
|
||||||
: QGroupBox(parent), client(_client), tabSupervisor(_tabSupervisor), room(_room)
|
: QGroupBox(parent), client(_client), tabSupervisor(_tabSupervisor), room(_room)
|
||||||
{
|
{
|
||||||
gameListView = new QTreeView;
|
gameListView = new QTreeView;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define GAMESELECTOR_H
|
#define GAMESELECTOR_H
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
//#include "tab_room.h"
|
|
||||||
#include "gametypemap.h"
|
#include "gametypemap.h"
|
||||||
|
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
|
@ -28,7 +27,7 @@ signals:
|
||||||
void gameJoined(int gameId);
|
void gameJoined(int gameId);
|
||||||
private:
|
private:
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
TabSupervisor *tabSupervisor;
|
const TabSupervisor *tabSupervisor;
|
||||||
TabRoom *room;
|
TabRoom *room;
|
||||||
|
|
||||||
QTreeView *gameListView;
|
QTreeView *gameListView;
|
||||||
|
@ -36,7 +35,7 @@ private:
|
||||||
GamesProxyModel *gameListProxyModel;
|
GamesProxyModel *gameListProxyModel;
|
||||||
QPushButton *filterButton, *clearFilterButton, *createButton, *joinButton, *spectateButton;
|
QPushButton *filterButton, *clearFilterButton, *createButton, *joinButton, *spectateButton;
|
||||||
public:
|
public:
|
||||||
GameSelector(AbstractClient *_client, TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent = 0);
|
GameSelector(AbstractClient *_client, const TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent = 0);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void processGameInfo(const ServerInfo_Game &info);
|
void processGameInfo(const ServerInfo_Game &info);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,15 +7,6 @@ GamesModel::GamesModel(const QMap<int, QString> &_rooms, const QMap<int, GameTyp
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GamesModel::~GamesModel()
|
|
||||||
{
|
|
||||||
if (!gameList.isEmpty()) {
|
|
||||||
beginRemoveRows(QModelIndex(), 0, gameList.size() - 1);
|
|
||||||
gameList.clear();
|
|
||||||
endRemoveRows();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant GamesModel::data(const QModelIndex &index, int role) const
|
QVariant GamesModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
|
@ -81,12 +72,12 @@ void GamesModel::updateGameList(const ServerInfo_Game &game)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < gameList.size(); i++)
|
for (int i = 0; i < gameList.size(); i++)
|
||||||
if (gameList[i].game_id() == game.game_id()) {
|
if (gameList[i].game_id() == game.game_id()) {
|
||||||
if (!game.has_player_count()) {
|
if (game.closed()) {
|
||||||
beginRemoveRows(QModelIndex(), i, i);
|
beginRemoveRows(QModelIndex(), i, i);
|
||||||
gameList.removeAt(i);
|
gameList.removeAt(i);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
} else {
|
} else {
|
||||||
gameList[i] = game;
|
gameList[i].MergeFrom(game);
|
||||||
emit dataChanged(index(i, 0), index(i, 7));
|
emit dataChanged(index(i, 0), index(i, 7));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include "gametypemap.h"
|
#include "gametypemap.h"
|
||||||
|
#include "pb/serverinfo_game.pb.h"
|
||||||
|
|
||||||
class ServerInfo_Game;
|
|
||||||
class ServerInfo_User;
|
class ServerInfo_User;
|
||||||
|
|
||||||
class GamesModel : public QAbstractTableModel {
|
class GamesModel : public QAbstractTableModel {
|
||||||
|
@ -18,7 +18,6 @@ private:
|
||||||
QMap<int, GameTypeMap> gameTypes;
|
QMap<int, GameTypeMap> gameTypes;
|
||||||
public:
|
public:
|
||||||
GamesModel(const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QObject *parent = 0);
|
GamesModel(const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QObject *parent = 0);
|
||||||
~GamesModel();
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const { return parent.isValid() ? 0 : gameList.size(); }
|
int rowCount(const QModelIndex &parent = QModelIndex()) const { return parent.isValid() ? 0 : gameList.size(); }
|
||||||
int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const { return 8; }
|
int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const { return 8; }
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "cardzone.h"
|
#include "cardzone.h"
|
||||||
#include "carditem.h"
|
#include "carditem.h"
|
||||||
#include "soundengine.h"
|
#include "soundengine.h"
|
||||||
|
#include "tab_supervisor.h"
|
||||||
#include "pb/serverinfo_user.pb.h"
|
#include "pb/serverinfo_user.pb.h"
|
||||||
#include "pb/context_move_card.pb.h"
|
#include "pb/context_move_card.pb.h"
|
||||||
#include "pb/context_mulligan.pb.h"
|
#include "pb/context_mulligan.pb.h"
|
||||||
|
@ -21,9 +22,14 @@ bool MessageLogWidget::isFemale(Player *player) const
|
||||||
return player->getUserInfo()->gender() == ServerInfo_User::Female;
|
return player->getUserInfo()->gender() == ServerInfo_User::Female;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MessageLogWidget::userIsFemale() const
|
||||||
|
{
|
||||||
|
return (tabSupervisor && tabSupervisor->getUserInfo()->gender() & ServerInfo_User::Female);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logGameJoined(int gameId)
|
void MessageLogWidget::logGameJoined(int gameId)
|
||||||
{
|
{
|
||||||
if (female)
|
if (userIsFemale())
|
||||||
appendHtml(tr("You have joined game #%1.", "female").arg(gameId));
|
appendHtml(tr("You have joined game #%1.", "female").arg(gameId));
|
||||||
else
|
else
|
||||||
appendHtml(tr("You have joined game #%1.", "male").arg(gameId));
|
appendHtml(tr("You have joined game #%1.", "male").arg(gameId));
|
||||||
|
@ -31,7 +37,7 @@ void MessageLogWidget::logGameJoined(int gameId)
|
||||||
|
|
||||||
void MessageLogWidget::logReplayStarted(int gameId)
|
void MessageLogWidget::logReplayStarted(int gameId)
|
||||||
{
|
{
|
||||||
if (female)
|
if (userIsFemale())
|
||||||
appendHtml(tr("You are watching a replay of game #%1.", "female").arg(gameId));
|
appendHtml(tr("You are watching a replay of game #%1.", "female").arg(gameId));
|
||||||
else
|
else
|
||||||
appendHtml(tr("You are watching a replay of game #%1.", "male").arg(gameId));
|
appendHtml(tr("You are watching a replay of game #%1.", "male").arg(gameId));
|
||||||
|
@ -143,12 +149,12 @@ void MessageLogWidget::logConnectionStateChanged(Player *player, bool connection
|
||||||
|
|
||||||
void MessageLogWidget::logSay(Player *player, QString message)
|
void MessageLogWidget::logSay(Player *player, QString message)
|
||||||
{
|
{
|
||||||
appendMessage(player->getName(), message, QColor(), true);
|
appendMessage(message, player->getName(), UserLevelFlags(player->getUserInfo()->user_level()), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logSpectatorSay(QString spectatorName, QString message)
|
void MessageLogWidget::logSpectatorSay(QString spectatorName, UserLevelFlags spectatorUserLevel, QString message)
|
||||||
{
|
{
|
||||||
appendMessage(spectatorName, message, QColor(), false);
|
appendMessage(message, spectatorName, spectatorUserLevel, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logShuffle(Player *player, CardZone *zone)
|
void MessageLogWidget::logShuffle(Player *player, CardZone *zone)
|
||||||
|
@ -858,7 +864,7 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
||||||
connect(player, SIGNAL(logAlwaysRevealTopCard(Player *, CardZone *, bool)), this, SLOT(logAlwaysRevealTopCard(Player *, CardZone *, bool)));
|
connect(player, SIGNAL(logAlwaysRevealTopCard(Player *, CardZone *, bool)), this, SLOT(logAlwaysRevealTopCard(Player *, CardZone *, bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageLogWidget::MessageLogWidget(const QString &_ownName, bool _female, QWidget *parent)
|
MessageLogWidget::MessageLogWidget(const TabSupervisor *_tabSupervisor, TabGame *_game, QWidget *parent)
|
||||||
: ChatView(_ownName, false, parent), female(_female)
|
: ChatView(_tabSupervisor, _game, false, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#define MESSAGELOGWIDGET_H
|
#define MESSAGELOGWIDGET_H
|
||||||
|
|
||||||
#include "chatview.h"
|
#include "chatview.h"
|
||||||
#include <QAbstractSocket>
|
|
||||||
#include "translation.h"
|
#include "translation.h"
|
||||||
|
#include "user_level.h"
|
||||||
|
|
||||||
class Player;
|
class Player;
|
||||||
class CardZone;
|
class CardZone;
|
||||||
|
@ -28,9 +28,9 @@ private:
|
||||||
|
|
||||||
QString sanitizeHtml(QString dirty) const;
|
QString sanitizeHtml(QString dirty) const;
|
||||||
bool isFemale(Player *player) const;
|
bool isFemale(Player *player) const;
|
||||||
|
bool userIsFemale() const;
|
||||||
QPair<QString, QString> getFromStr(CardZone *zone, QString cardName, int position, bool ownerChange) const;
|
QPair<QString, QString> getFromStr(CardZone *zone, QString cardName, int position, bool ownerChange) const;
|
||||||
MessageContext currentContext;
|
MessageContext currentContext;
|
||||||
bool female;
|
|
||||||
|
|
||||||
QList<LogMoveCard> moveCardQueue;
|
QList<LogMoveCard> moveCardQueue;
|
||||||
QMap<CardItem *, QString> moveCardPT;
|
QMap<CardItem *, QString> moveCardPT;
|
||||||
|
@ -55,7 +55,7 @@ public slots:
|
||||||
void logGameStart();
|
void logGameStart();
|
||||||
void logConnectionStateChanged(Player *player, bool connectionState);
|
void logConnectionStateChanged(Player *player, bool connectionState);
|
||||||
void logSay(Player *player, QString message);
|
void logSay(Player *player, QString message);
|
||||||
void logSpectatorSay(QString spectatorName, QString message);
|
void logSpectatorSay(QString spectatorName, UserLevelFlags spectatorUserLevel, QString message);
|
||||||
void logShuffle(Player *player, CardZone *zone);
|
void logShuffle(Player *player, CardZone *zone);
|
||||||
void logRollDie(Player *player, int sides, int roll);
|
void logRollDie(Player *player, int sides, int roll);
|
||||||
void logDrawCards(Player *player, int number);
|
void logDrawCards(Player *player, int number);
|
||||||
|
@ -85,7 +85,7 @@ public slots:
|
||||||
void containerProcessingDone();
|
void containerProcessingDone();
|
||||||
public:
|
public:
|
||||||
void connectToPlayer(Player *player);
|
void connectToPlayer(Player *player);
|
||||||
MessageLogWidget(const QString &_ownName, bool _female, QWidget *parent = 0);
|
MessageLogWidget(const TabSupervisor *_tabSupervisor, TabGame *_game, QWidget *parent = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -131,18 +131,18 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr
|
||||||
|
|
||||||
QMap<QString, QPixmap> CountryPixmapGenerator::pmCache;
|
QMap<QString, QPixmap> CountryPixmapGenerator::pmCache;
|
||||||
|
|
||||||
QPixmap UserLevelPixmapGenerator::generatePixmap(int height, int userLevel)
|
QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel)
|
||||||
{
|
{
|
||||||
int key = height * 10000 + userLevel;
|
int key = height * 10000 + (int) userLevel;
|
||||||
if (pmCache.contains(key))
|
if (pmCache.contains(key))
|
||||||
return pmCache.value(key);
|
return pmCache.value(key);
|
||||||
|
|
||||||
QString levelString;
|
QString levelString;
|
||||||
if (userLevel & ServerInfo_User::IsAdmin)
|
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
|
||||||
levelString = "admin";
|
levelString = "admin";
|
||||||
else if (userLevel & ServerInfo_User::IsModerator)
|
else if (userLevel.testFlag(ServerInfo_User::IsModerator))
|
||||||
levelString = "moderator";
|
levelString = "moderator";
|
||||||
else if (userLevel &ServerInfo_User::IsRegistered)
|
else if (userLevel.testFlag(ServerInfo_User::IsRegistered))
|
||||||
levelString = "registered";
|
levelString = "registered";
|
||||||
else
|
else
|
||||||
levelString = "normal";
|
levelString = "normal";
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
|
#include "user_level.h"
|
||||||
|
|
||||||
class PhasePixmapGenerator {
|
class PhasePixmapGenerator {
|
||||||
private:
|
private:
|
||||||
static QMap<QString, QPixmap> pmCache;
|
static QMap<QString, QPixmap> pmCache;
|
||||||
|
@ -48,7 +50,7 @@ class UserLevelPixmapGenerator {
|
||||||
private:
|
private:
|
||||||
static QMap<int, QPixmap> pmCache;
|
static QMap<int, QPixmap> pmCache;
|
||||||
public:
|
public:
|
||||||
static QPixmap generatePixmap(int height, int userLevel);
|
static QPixmap generatePixmap(int height, UserLevelFlags userLevel);
|
||||||
static void clear() { pmCache.clear(); }
|
static void clear() { pmCache.clear(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "dlg_create_token.h"
|
#include "dlg_create_token.h"
|
||||||
#include "carddatabase.h"
|
#include "carddatabase.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
|
#include "decklist.h"
|
||||||
|
#include "main.h"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
@ -95,7 +97,19 @@ void PlayerArea::setSize(qreal width, qreal height)
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_parent)
|
Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_parent)
|
||||||
: QObject(_parent), game(_parent), shortcutsActive(false), defaultNumberTopCards(3), lastTokenDestroy(true), id(_id), active(false), local(_local), mirrored(false), handVisible(false), conceded(false), dialogSemaphore(false)
|
: QObject(_parent),
|
||||||
|
game(_parent),
|
||||||
|
shortcutsActive(false),
|
||||||
|
defaultNumberTopCards(3),
|
||||||
|
lastTokenDestroy(true),
|
||||||
|
id(_id),
|
||||||
|
active(false),
|
||||||
|
local(_local),
|
||||||
|
mirrored(false),
|
||||||
|
handVisible(false),
|
||||||
|
conceded(false),
|
||||||
|
dialogSemaphore(false),
|
||||||
|
deck(0)
|
||||||
{
|
{
|
||||||
userInfo = new ServerInfo_User;
|
userInfo = new ServerInfo_User;
|
||||||
userInfo->CopyFrom(info);
|
userInfo->CopyFrom(info);
|
||||||
|
@ -295,6 +309,8 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
||||||
aCreateAnotherToken = new QAction(this);
|
aCreateAnotherToken = new QAction(this);
|
||||||
connect(aCreateAnotherToken, SIGNAL(triggered()), this, SLOT(actCreateAnotherToken()));
|
connect(aCreateAnotherToken, SIGNAL(triggered()), this, SLOT(actCreateAnotherToken()));
|
||||||
aCreateAnotherToken->setEnabled(false);
|
aCreateAnotherToken->setEnabled(false);
|
||||||
|
|
||||||
|
createPredefinedTokenMenu = new QMenu(QString());
|
||||||
|
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
countersMenu = playerMenu->addMenu(QString());
|
countersMenu = playerMenu->addMenu(QString());
|
||||||
|
@ -305,6 +321,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
playerMenu->addAction(aCreateToken);
|
playerMenu->addAction(aCreateToken);
|
||||||
playerMenu->addAction(aCreateAnotherToken);
|
playerMenu->addAction(aCreateAnotherToken);
|
||||||
|
playerMenu->addMenu(createPredefinedTokenMenu);
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
sayMenu = playerMenu->addMenu(QString());
|
sayMenu = playerMenu->addMenu(QString());
|
||||||
initSayMenu();
|
initSayMenu();
|
||||||
|
@ -320,11 +337,11 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
||||||
allPlayersActions.append(newAction);
|
allPlayersActions.append(newAction);
|
||||||
playerLists[i]->addSeparator();
|
playerLists[i]->addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
countersMenu = 0;
|
countersMenu = 0;
|
||||||
sbMenu = 0;
|
sbMenu = 0;
|
||||||
aCreateAnotherToken = 0;
|
aCreateAnotherToken = 0;
|
||||||
|
createPredefinedTokenMenu = 0;
|
||||||
aCardMenu = 0;
|
aCardMenu = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,6 +616,7 @@ void Player::retranslateUi()
|
||||||
aRollDie->setText(tr("R&oll die..."));
|
aRollDie->setText(tr("R&oll die..."));
|
||||||
aCreateToken->setText(tr("&Create token..."));
|
aCreateToken->setText(tr("&Create token..."));
|
||||||
aCreateAnotherToken->setText(tr("C&reate another token"));
|
aCreateAnotherToken->setText(tr("C&reate another token"));
|
||||||
|
createPredefinedTokenMenu->setTitle(tr("Cr&eate predefined token"));
|
||||||
sayMenu->setTitle(tr("S&ay"));
|
sayMenu->setTitle(tr("S&ay"));
|
||||||
|
|
||||||
QMapIterator<int, AbstractCounter *> counterIterator(counters);
|
QMapIterator<int, AbstractCounter *> counterIterator(counters);
|
||||||
|
@ -723,6 +741,24 @@ void Player::initSayMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::setDeck(DeckList *_deck)
|
||||||
|
{
|
||||||
|
deck = _deck;
|
||||||
|
|
||||||
|
createPredefinedTokenMenu->clear();
|
||||||
|
predefinedTokens.clear();
|
||||||
|
InnerDecklistNode *tokenZone = dynamic_cast<InnerDecklistNode *>(deck->getRoot()->findChild("tokens"));
|
||||||
|
if (tokenZone)
|
||||||
|
for (int i = 0; i < tokenZone->size(); ++i) {
|
||||||
|
const QString tokenName = tokenZone->at(i)->getName();
|
||||||
|
predefinedTokens.append(tokenName);
|
||||||
|
QAction *a = createPredefinedTokenMenu->addAction(tokenName);
|
||||||
|
if (i < 10)
|
||||||
|
a->setShortcut("Alt+" + QString::number((i + 1) % 10));
|
||||||
|
connect(a, SIGNAL(triggered()), this, SLOT(actCreatePredefinedToken()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Player::actViewLibrary()
|
void Player::actViewLibrary()
|
||||||
{
|
{
|
||||||
static_cast<GameScene *>(scene())->toggleZoneView(this, "deck", -1);
|
static_cast<GameScene *>(scene())->toggleZoneView(this, "deck", -1);
|
||||||
|
@ -876,7 +912,7 @@ void Player::actRollDie()
|
||||||
|
|
||||||
void Player::actCreateToken()
|
void Player::actCreateToken()
|
||||||
{
|
{
|
||||||
DlgCreateToken dlg;
|
DlgCreateToken dlg(predefinedTokens);
|
||||||
if (!dlg.exec())
|
if (!dlg.exec())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -905,6 +941,21 @@ void Player::actCreateAnotherToken()
|
||||||
sendGameCommand(cmd);
|
sendGameCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::actCreatePredefinedToken()
|
||||||
|
{
|
||||||
|
QAction *action = static_cast<QAction *>(sender());
|
||||||
|
CardInfo *cardInfo = db->getCard(action->text());
|
||||||
|
|
||||||
|
lastTokenName = cardInfo->getName();
|
||||||
|
lastTokenColor = cardInfo->getColors().isEmpty() ? QString() : cardInfo->getColors().first().toLower();
|
||||||
|
lastTokenPT = cardInfo->getPowTough();
|
||||||
|
lastTokenAnnotation = cardInfo->getText();
|
||||||
|
lastTokenDestroy = true;
|
||||||
|
aCreateAnotherToken->setEnabled(true);
|
||||||
|
|
||||||
|
actCreateAnotherToken();
|
||||||
|
}
|
||||||
|
|
||||||
void Player::actSayMessage()
|
void Player::actSayMessage()
|
||||||
{
|
{
|
||||||
QAction *a = qobject_cast<QAction *>(sender());
|
QAction *a = qobject_cast<QAction *>(sender());
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
namespace google { namespace protobuf { class Message; } }
|
namespace google { namespace protobuf { class Message; } }
|
||||||
class CardDatabase;
|
class CardDatabase;
|
||||||
|
class DeckList;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QAction;
|
class QAction;
|
||||||
class ZoneViewZone;
|
class ZoneViewZone;
|
||||||
|
@ -133,6 +134,7 @@ private slots:
|
||||||
void updateBoundingRect();
|
void updateBoundingRect();
|
||||||
void rearrangeZones();
|
void rearrangeZones();
|
||||||
|
|
||||||
|
void actCreatePredefinedToken();
|
||||||
void cardMenuAction();
|
void cardMenuAction();
|
||||||
void actCardCounterTrigger();
|
void actCardCounterTrigger();
|
||||||
void actAttach();
|
void actAttach();
|
||||||
|
@ -152,7 +154,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TabGame *game;
|
TabGame *game;
|
||||||
QMenu *playerMenu, *handMenu, *graveMenu, *rfgMenu, *libraryMenu, *sbMenu, *countersMenu, *sayMenu,
|
QMenu *playerMenu, *handMenu, *graveMenu, *rfgMenu, *libraryMenu, *sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu,
|
||||||
*mRevealLibrary, *mRevealTopCard, *mRevealHand, *mRevealRandomHandCard;
|
*mRevealLibrary, *mRevealTopCard, *mRevealHand, *mRevealRandomHandCard;
|
||||||
QList<QMenu *> playerLists;
|
QList<QMenu *> playerLists;
|
||||||
QList<QAction *> allPlayersActions;
|
QList<QAction *> allPlayersActions;
|
||||||
|
@ -187,6 +189,9 @@ private:
|
||||||
bool clearCardsToDelete();
|
bool clearCardsToDelete();
|
||||||
QList<CardItem *> cardsToDelete;
|
QList<CardItem *> cardsToDelete;
|
||||||
|
|
||||||
|
DeckList *deck;
|
||||||
|
QStringList predefinedTokens;
|
||||||
|
|
||||||
PlayerArea *playerArea;
|
PlayerArea *playerArea;
|
||||||
QMap<QString, CardZone *> zones;
|
QMap<QString, CardZone *> zones;
|
||||||
StackZone *stack;
|
StackZone *stack;
|
||||||
|
@ -256,6 +261,7 @@ public:
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void clear();
|
void clear();
|
||||||
TabGame *getGame() const { return game; }
|
TabGame *getGame() const { return game; }
|
||||||
|
void setDeck(DeckList *_deck);
|
||||||
QMenu *getPlayerMenu() const { return playerMenu; }
|
QMenu *getPlayerMenu() const { return playerMenu; }
|
||||||
int getId() const { return id; }
|
int getId() const { return id; }
|
||||||
QString getName() const;
|
QString getName() const;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "tab_userlists.h"
|
#include "tab_userlists.h"
|
||||||
#include "userlist.h"
|
#include "userlist.h"
|
||||||
#include "userinfobox.h"
|
#include "userinfobox.h"
|
||||||
|
#include "user_context_menu.h"
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
@ -60,7 +61,11 @@ PlayerListWidget::PlayerListWidget(TabSupervisor *_tabSupervisor, AbstractClient
|
||||||
if (tabSupervisor) {
|
if (tabSupervisor) {
|
||||||
itemDelegate = new PlayerListItemDelegate(this);
|
itemDelegate = new PlayerListItemDelegate(this);
|
||||||
setItemDelegate(itemDelegate);
|
setItemDelegate(itemDelegate);
|
||||||
}
|
|
||||||
|
userContextMenu = new UserContextMenu(tabSupervisor, this, game);
|
||||||
|
connect(userContextMenu, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
|
||||||
|
} else
|
||||||
|
userContextMenu = 0;
|
||||||
|
|
||||||
setMinimumHeight(60);
|
setMinimumHeight(60);
|
||||||
setIconSize(QSize(20, 15));
|
setIconSize(QSize(20, 15));
|
||||||
|
@ -105,7 +110,7 @@ void PlayerListWidget::updatePlayerProperties(const ServerInfo_PlayerProperties
|
||||||
player->setIcon(2, gameStarted ? (prop.conceded() ? concededIcon : QIcon()) : (prop.ready_start() ? readyIcon : notReadyIcon));
|
player->setIcon(2, gameStarted ? (prop.conceded() ? concededIcon : QIcon()) : (prop.ready_start() ? readyIcon : notReadyIcon));
|
||||||
if (prop.has_user_info()) {
|
if (prop.has_user_info()) {
|
||||||
player->setData(3, Qt::UserRole, prop.user_info().user_level());
|
player->setData(3, Qt::UserRole, prop.user_info().user_level());
|
||||||
player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, prop.user_info().user_level())));
|
player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, UserLevelFlags(prop.user_info().user_level()))));
|
||||||
player->setText(4, QString::fromStdString(prop.user_info().name()));
|
player->setText(4, QString::fromStdString(prop.user_info().name()));
|
||||||
const QString country = QString::fromStdString(prop.user_info().country());
|
const QString country = QString::fromStdString(prop.user_info().country());
|
||||||
if (!country.isEmpty())
|
if (!country.isEmpty())
|
||||||
|
@ -162,93 +167,12 @@ void PlayerListWidget::setGameStarted(bool _gameStarted, bool resuming)
|
||||||
|
|
||||||
void PlayerListWidget::showContextMenu(const QPoint &pos, const QModelIndex &index)
|
void PlayerListWidget::showContextMenu(const QPoint &pos, const QModelIndex &index)
|
||||||
{
|
{
|
||||||
|
if (!userContextMenu)
|
||||||
|
return;
|
||||||
|
|
||||||
const QString &userName = index.sibling(index.row(), 4).data(Qt::UserRole).toString();
|
const QString &userName = index.sibling(index.row(), 4).data(Qt::UserRole).toString();
|
||||||
int playerId = index.sibling(index.row(), 4).data(Qt::UserRole + 1).toInt();
|
int playerId = index.sibling(index.row(), 4).data(Qt::UserRole + 1).toInt();
|
||||||
ServerInfo_User::UserLevelFlags userLevel = static_cast<ServerInfo_User::UserLevelFlags>(index.sibling(index.row(), 3).data(Qt::UserRole).toInt());
|
UserLevelFlags userLevel(index.sibling(index.row(), 3).data(Qt::UserRole).toInt());
|
||||||
|
|
||||||
QAction *aUserName = new QAction(userName, this);
|
userContextMenu->showContextMenu(pos, userName, userLevel, playerId);
|
||||||
aUserName->setEnabled(false);
|
|
||||||
QAction *aDetails = new QAction(tr("User &details"), this);
|
|
||||||
QAction *aChat = new QAction(tr("Direct &chat"), this);
|
|
||||||
QAction *aAddToBuddyList = new QAction(tr("Add to &buddy list"), this);
|
|
||||||
QAction *aRemoveFromBuddyList = new QAction(tr("Remove from &buddy list"), this);
|
|
||||||
QAction *aAddToIgnoreList = new QAction(tr("Add to &ignore list"), this);
|
|
||||||
QAction *aRemoveFromIgnoreList = new QAction(tr("Remove from &ignore list"), this);
|
|
||||||
QAction *aKick = new QAction(tr("Kick from &game"), this);
|
|
||||||
|
|
||||||
QMenu *menu = new QMenu(this);
|
|
||||||
menu->addAction(aUserName);
|
|
||||||
menu->addSeparator();
|
|
||||||
menu->addAction(aDetails);
|
|
||||||
menu->addAction(aChat);
|
|
||||||
if ((userLevel & ServerInfo_User::IsRegistered) && (tabSupervisor->getUserLevel() & ServerInfo_User::IsRegistered)) {
|
|
||||||
menu->addSeparator();
|
|
||||||
if (tabSupervisor->getUserListsTab()->getBuddyList()->getUsers().contains(userName))
|
|
||||||
menu->addAction(aRemoveFromBuddyList);
|
|
||||||
else
|
|
||||||
menu->addAction(aAddToBuddyList);
|
|
||||||
if (tabSupervisor->getUserListsTab()->getIgnoreList()->getUsers().contains(userName))
|
|
||||||
menu->addAction(aRemoveFromIgnoreList);
|
|
||||||
else
|
|
||||||
menu->addAction(aAddToIgnoreList);
|
|
||||||
}
|
|
||||||
if (game->isHost() || !game->getTabSupervisor()->getAdminLocked()) {
|
|
||||||
menu->addSeparator();
|
|
||||||
menu->addAction(aKick);
|
|
||||||
}
|
|
||||||
if (userName == QString::fromStdString(game->getTabSupervisor()->getUserInfo()->name())) {
|
|
||||||
aChat->setEnabled(false);
|
|
||||||
aAddToBuddyList->setEnabled(false);
|
|
||||||
aRemoveFromBuddyList->setEnabled(false);
|
|
||||||
aAddToIgnoreList->setEnabled(false);
|
|
||||||
aRemoveFromIgnoreList->setEnabled(false);
|
|
||||||
aKick->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
QAction *actionClicked = menu->exec(pos);
|
|
||||||
if (actionClicked == aDetails) {
|
|
||||||
UserInfoBox *infoWidget = new UserInfoBox(client, true, this, Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
|
||||||
infoWidget->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
infoWidget->updateInfo(userName);
|
|
||||||
} else if (actionClicked == aChat)
|
|
||||||
emit openMessageDialog(userName, true);
|
|
||||||
else if (actionClicked == aAddToBuddyList) {
|
|
||||||
Command_AddToList cmd;
|
|
||||||
cmd.set_list("buddy");
|
|
||||||
cmd.set_user_name(userName.toStdString());
|
|
||||||
|
|
||||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
|
||||||
} else if (actionClicked == aRemoveFromBuddyList) {
|
|
||||||
Command_RemoveFromList cmd;
|
|
||||||
cmd.set_list("buddy");
|
|
||||||
cmd.set_user_name(userName.toStdString());
|
|
||||||
|
|
||||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
|
||||||
} else if (actionClicked == aAddToIgnoreList) {
|
|
||||||
Command_AddToList cmd;
|
|
||||||
cmd.set_list("ignore");
|
|
||||||
cmd.set_user_name(userName.toStdString());
|
|
||||||
|
|
||||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
|
||||||
} else if (actionClicked == aRemoveFromIgnoreList) {
|
|
||||||
Command_RemoveFromList cmd;
|
|
||||||
cmd.set_list("ignore");
|
|
||||||
cmd.set_user_name(userName.toStdString());
|
|
||||||
|
|
||||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
|
||||||
} else if (actionClicked == aKick) {
|
|
||||||
Command_KickFromGame cmd;
|
|
||||||
cmd.set_player_id(playerId);
|
|
||||||
game->sendGameCommand(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete menu;
|
|
||||||
delete aUserName;
|
|
||||||
delete aDetails;
|
|
||||||
delete aChat;
|
|
||||||
delete aAddToBuddyList;
|
|
||||||
delete aRemoveFromBuddyList;
|
|
||||||
delete aAddToIgnoreList;
|
|
||||||
delete aRemoveFromIgnoreList;
|
|
||||||
delete aKick;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ class ServerInfo_PlayerProperties;
|
||||||
class TabSupervisor;
|
class TabSupervisor;
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
class TabGame;
|
class TabGame;
|
||||||
|
class UserContextMenu;
|
||||||
|
|
||||||
class PlayerListItemDelegate : public QStyledItemDelegate {
|
class PlayerListItemDelegate : public QStyledItemDelegate {
|
||||||
public:
|
public:
|
||||||
|
@ -31,6 +32,7 @@ private:
|
||||||
TabSupervisor *tabSupervisor;
|
TabSupervisor *tabSupervisor;
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
TabGame *game;
|
TabGame *game;
|
||||||
|
UserContextMenu *userContextMenu;
|
||||||
QIcon readyIcon, notReadyIcon, concededIcon, playerIcon, spectatorIcon, lockIcon;
|
QIcon readyIcon, notReadyIcon, concededIcon, playerIcon, spectatorIcon, lockIcon;
|
||||||
bool gameStarted;
|
bool gameStarted;
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -87,7 +87,7 @@ void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*o
|
||||||
|
|
||||||
QPixmap tempPixmap;
|
QPixmap tempPixmap;
|
||||||
if (fullPixmap.isNull())
|
if (fullPixmap.isNull())
|
||||||
tempPixmap = UserLevelPixmapGenerator::generatePixmap(translatedSize.height(), info->user_level());
|
tempPixmap = UserLevelPixmapGenerator::generatePixmap(translatedSize.height(), UserLevelFlags(info->user_level()));
|
||||||
else
|
else
|
||||||
tempPixmap = fullPixmap.scaled(translatedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
tempPixmap = fullPixmap.scaled(translatedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,9 @@ void RemoteClient::readData()
|
||||||
|
|
||||||
ServerMessage newServerMessage;
|
ServerMessage newServerMessage;
|
||||||
newServerMessage.ParseFromArray(inputBuffer.data(), messageLength);
|
newServerMessage.ParseFromArray(inputBuffer.data(), messageLength);
|
||||||
qDebug(("IN " + QString::number(messageLength) + ": " + QString::fromStdString(newServerMessage.DebugString())).toUtf8());
|
#ifdef QT_DEBUG
|
||||||
|
qDebug(("IN " + QString::number(messageLength) + ": " + QString::fromStdString(newServerMessage.ShortDebugString())).toUtf8());
|
||||||
|
#endif
|
||||||
inputBuffer.remove(0, messageLength);
|
inputBuffer.remove(0, messageLength);
|
||||||
messageInProgress = false;
|
messageInProgress = false;
|
||||||
|
|
||||||
|
@ -133,7 +135,9 @@ void RemoteClient::sendCommandContainer(const CommandContainer &cont)
|
||||||
{
|
{
|
||||||
QByteArray buf;
|
QByteArray buf;
|
||||||
unsigned int size = cont.ByteSize();
|
unsigned int size = cont.ByteSize();
|
||||||
qDebug(("OUT " + QString::number(size) + ": " + QString::fromStdString(cont.DebugString())).toUtf8());
|
#ifdef QT_DEBUG
|
||||||
|
qDebug(("OUT " + QString::number(size) + ": " + QString::fromStdString(cont.ShortDebugString())).toUtf8());
|
||||||
|
#endif
|
||||||
buf.resize(size + 4);
|
buf.resize(size + 4);
|
||||||
cont.SerializeToArray(buf.data() + 4, size);
|
cont.SerializeToArray(buf.data() + 4, size);
|
||||||
buf.data()[3] = (unsigned char) size;
|
buf.data()[3] = (unsigned char) size;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "dlg_creategame.h"
|
#include "dlg_creategame.h"
|
||||||
#include "tab_game.h"
|
#include "tab_game.h"
|
||||||
|
@ -234,8 +235,8 @@ void DeckViewContainer::setDeck(DeckList *deck)
|
||||||
sideboardLockButton->setEnabled(true);
|
sideboardLockButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TabGame::TabGame(GameReplay *_replay)
|
TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
|
||||||
: Tab(0),
|
: Tab(_tabSupervisor),
|
||||||
hostId(-1),
|
hostId(-1),
|
||||||
localPlayerId(-1),
|
localPlayerId(-1),
|
||||||
spectator(true),
|
spectator(true),
|
||||||
|
@ -282,7 +283,7 @@ TabGame::TabGame(GameReplay *_replay)
|
||||||
|
|
||||||
timeElapsedLabel = new QLabel;
|
timeElapsedLabel = new QLabel;
|
||||||
timeElapsedLabel->setAlignment(Qt::AlignCenter);
|
timeElapsedLabel->setAlignment(Qt::AlignCenter);
|
||||||
messageLog = new MessageLogWidget(QString(), false);
|
messageLog = new MessageLogWidget(tabSupervisor, this);
|
||||||
connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString)));
|
connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString)));
|
||||||
connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||||
connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||||
|
@ -411,7 +412,8 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
|
||||||
|
|
||||||
timeElapsedLabel = new QLabel;
|
timeElapsedLabel = new QLabel;
|
||||||
timeElapsedLabel->setAlignment(Qt::AlignCenter);
|
timeElapsedLabel->setAlignment(Qt::AlignCenter);
|
||||||
messageLog = new MessageLogWidget(QString::fromStdString(tabSupervisor->getUserInfo()->name()), tabSupervisor->getUserInfo()->gender() == ServerInfo_User::Female);
|
messageLog = new MessageLogWidget(tabSupervisor, this);
|
||||||
|
connect(messageLog, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
|
||||||
connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString)));
|
connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString)));
|
||||||
connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||||
connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||||
|
@ -813,6 +815,17 @@ AbstractClient *TabGame::getClientForPlayer(int playerId) const
|
||||||
return clients.first();
|
return clients.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TabGame::getPlayerIdByName(const QString &playerName) const
|
||||||
|
{
|
||||||
|
QMapIterator<int, Player *> playerIterator(players);
|
||||||
|
while (playerIterator.hasNext()) {
|
||||||
|
const Player *const p = playerIterator.next().value();
|
||||||
|
if (p->getName() == playerName)
|
||||||
|
return p->getId();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void TabGame::sendGameCommand(PendingCommand *pend, int playerId)
|
void TabGame::sendGameCommand(PendingCommand *pend, int playerId)
|
||||||
{
|
{
|
||||||
getClientForPlayer(playerId)->sendCommand(pend);
|
getClientForPlayer(playerId)->sendCommand(pend);
|
||||||
|
@ -898,12 +911,13 @@ void TabGame::closeGame()
|
||||||
|
|
||||||
void TabGame::eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, const GameEventContext & /*context*/)
|
void TabGame::eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, const GameEventContext & /*context*/)
|
||||||
{
|
{
|
||||||
messageLog->logSpectatorSay(spectators.value(eventPlayerId), QString::fromStdString(event.message()));
|
const ServerInfo_User &userInfo = spectators.value(eventPlayerId);
|
||||||
|
messageLog->logSpectatorSay(QString::fromStdString(userInfo.name()), UserLevelFlags(userInfo.user_level()), QString::fromStdString(event.message()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabGame::eventSpectatorLeave(const Event_Leave & /*event*/, int eventPlayerId, const GameEventContext & /*context*/)
|
void TabGame::eventSpectatorLeave(const Event_Leave & /*event*/, int eventPlayerId, const GameEventContext & /*context*/)
|
||||||
{
|
{
|
||||||
messageLog->logLeaveSpectator(spectators.value(eventPlayerId));
|
messageLog->logLeaveSpectator(QString::fromStdString(spectators.value(eventPlayerId).name()));
|
||||||
playerListWidget->removePlayer(eventPlayerId);
|
playerListWidget->removePlayer(eventPlayerId);
|
||||||
spectators.remove(eventPlayerId);
|
spectators.remove(eventPlayerId);
|
||||||
|
|
||||||
|
@ -919,7 +933,7 @@ void TabGame::eventGameStateChanged(const Event_GameStateChanged &event, int /*e
|
||||||
const int playerId = prop.player_id();
|
const int playerId = prop.player_id();
|
||||||
if (prop.spectator()) {
|
if (prop.spectator()) {
|
||||||
if (!spectators.contains(playerId)) {
|
if (!spectators.contains(playerId)) {
|
||||||
spectators.insert(playerId, QString::fromStdString(prop.user_info().name()));
|
spectators.insert(playerId, prop.user_info());
|
||||||
playerListWidget->addPlayer(prop);
|
playerListWidget->addPlayer(prop);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -935,6 +949,7 @@ void TabGame::eventGameStateChanged(const Event_GameStateChanged &event, int /*e
|
||||||
DeckList *newDeck = new DeckList(QString::fromStdString(playerInfo.deck_list()));
|
DeckList *newDeck = new DeckList(QString::fromStdString(playerInfo.deck_list()));
|
||||||
db->cacheCardPixmaps(newDeck->getCardList());
|
db->cacheCardPixmaps(newDeck->getCardList());
|
||||||
deckViewContainer->setDeck(newDeck);
|
deckViewContainer->setDeck(newDeck);
|
||||||
|
player->setDeck(newDeck);
|
||||||
}
|
}
|
||||||
deckViewContainer->setReadyStart(prop.ready_start());
|
deckViewContainer->setReadyStart(prop.ready_start());
|
||||||
deckViewContainer->setSideboardLocked(prop.sideboard_locked());
|
deckViewContainer->setSideboardLocked(prop.sideboard_locked());
|
||||||
|
@ -1023,7 +1038,7 @@ void TabGame::eventJoin(const Event_Join &event, int /*eventPlayerId*/, const Ga
|
||||||
if (players.contains(playerId))
|
if (players.contains(playerId))
|
||||||
return;
|
return;
|
||||||
if (playerInfo.spectator()) {
|
if (playerInfo.spectator()) {
|
||||||
spectators.insert(playerId, QString::fromStdString(playerInfo.user_info().name()));
|
spectators.insert(playerId, playerInfo.user_info());
|
||||||
messageLog->logJoinSpectator(QString::fromStdString(playerInfo.user_info().name()));
|
messageLog->logJoinSpectator(QString::fromStdString(playerInfo.user_info().name()));
|
||||||
} else {
|
} else {
|
||||||
Player *newPlayer = addPlayer(playerId, playerInfo.user_info());
|
Player *newPlayer = addPlayer(playerId, playerInfo.user_info());
|
||||||
|
|
|
@ -107,7 +107,7 @@ private:
|
||||||
int localPlayerId;
|
int localPlayerId;
|
||||||
bool spectator;
|
bool spectator;
|
||||||
QMap<int, Player *> players;
|
QMap<int, Player *> players;
|
||||||
QMap<int, QString> spectators;
|
QMap<int, ServerInfo_User> spectators;
|
||||||
bool gameStateKnown;
|
bool gameStateKnown;
|
||||||
bool resuming;
|
bool resuming;
|
||||||
QStringList phasesList;
|
QStringList phasesList;
|
||||||
|
@ -195,7 +195,7 @@ private slots:
|
||||||
void actNextTurn();
|
void actNextTurn();
|
||||||
public:
|
public:
|
||||||
TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes);
|
TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes);
|
||||||
TabGame(GameReplay *replay);
|
TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);
|
||||||
~TabGame();
|
~TabGame();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
|
@ -208,6 +208,7 @@ public:
|
||||||
bool getSpectatorsSeeEverything() const { return gameInfo.spectators_omniscient(); }
|
bool getSpectatorsSeeEverything() const { return gameInfo.spectators_omniscient(); }
|
||||||
Player *getActiveLocalPlayer() const;
|
Player *getActiveLocalPlayer() const;
|
||||||
AbstractClient *getClientForPlayer(int playerId) const;
|
AbstractClient *getClientForPlayer(int playerId) const;
|
||||||
|
int getPlayerIdByName(const QString &playerName) const;
|
||||||
|
|
||||||
void setActiveCard(CardItem *_card) { activeCard = _card; }
|
void setActiveCard(CardItem *_card) { activeCard = _card; }
|
||||||
CardItem *getActiveCard() const { return activeCard; }
|
CardItem *getActiveCard() const { return activeCard; }
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
#include "pending_command.h"
|
#include "pending_command.h"
|
||||||
#include "pb/session_commands.pb.h"
|
#include "pb/session_commands.pb.h"
|
||||||
#include "pb/event_user_message.pb.h"
|
#include "pb/event_user_message.pb.h"
|
||||||
|
#include "pb/serverinfo_user.pb.h"
|
||||||
|
|
||||||
TabMessage::TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, const QString &_ownName, const QString &_userName)
|
TabMessage::TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &_ownUserInfo, const ServerInfo_User &_otherUserInfo)
|
||||||
: Tab(_tabSupervisor), client(_client), userName(_userName), userOnline(true)
|
: Tab(_tabSupervisor), client(_client), ownUserInfo(new ServerInfo_User(_ownUserInfo)), otherUserInfo(new ServerInfo_User(_otherUserInfo)), userOnline(true)
|
||||||
{
|
{
|
||||||
chatView = new ChatView(_ownName, true);
|
chatView = new ChatView(tabSupervisor, 0, true);
|
||||||
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||||
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||||
sayEdit = new QLineEdit;
|
sayEdit = new QLineEdit;
|
||||||
|
@ -37,6 +38,8 @@ TabMessage::TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, c
|
||||||
TabMessage::~TabMessage()
|
TabMessage::~TabMessage()
|
||||||
{
|
{
|
||||||
emit talkClosing(this);
|
emit talkClosing(this);
|
||||||
|
delete ownUserInfo;
|
||||||
|
delete otherUserInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabMessage::retranslateUi()
|
void TabMessage::retranslateUi()
|
||||||
|
@ -45,6 +48,16 @@ void TabMessage::retranslateUi()
|
||||||
aLeave->setText(tr("&Leave"));
|
aLeave->setText(tr("&Leave"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString TabMessage::getUserName() const
|
||||||
|
{
|
||||||
|
return QString::fromStdString(otherUserInfo->name());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TabMessage::getTabText() const
|
||||||
|
{
|
||||||
|
return tr("Talking to %1").arg(QString::fromStdString(otherUserInfo->name()));
|
||||||
|
}
|
||||||
|
|
||||||
void TabMessage::closeRequest()
|
void TabMessage::closeRequest()
|
||||||
{
|
{
|
||||||
actLeave();
|
actLeave();
|
||||||
|
@ -56,7 +69,7 @@ void TabMessage::sendMessage()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Command_Message cmd;
|
Command_Message cmd;
|
||||||
cmd.set_user_name(userName.toStdString());
|
cmd.set_user_name(otherUserInfo->name());
|
||||||
cmd.set_message(sayEdit->text().toStdString());
|
cmd.set_message(sayEdit->text().toStdString());
|
||||||
|
|
||||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||||
|
@ -69,7 +82,7 @@ void TabMessage::sendMessage()
|
||||||
void TabMessage::messageSent(const Response &response)
|
void TabMessage::messageSent(const Response &response)
|
||||||
{
|
{
|
||||||
if (response.response_code() == Response::RespInIgnoreList)
|
if (response.response_code() == Response::RespInIgnoreList)
|
||||||
chatView->appendMessage(QString(), tr("This user is ignoring you."));
|
chatView->appendMessage(tr("This user is ignoring you."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabMessage::actLeave()
|
void TabMessage::actLeave()
|
||||||
|
@ -79,18 +92,20 @@ void TabMessage::actLeave()
|
||||||
|
|
||||||
void TabMessage::processUserMessageEvent(const Event_UserMessage &event)
|
void TabMessage::processUserMessageEvent(const Event_UserMessage &event)
|
||||||
{
|
{
|
||||||
chatView->appendMessage(QString::fromStdString(event.sender_name()), QString::fromStdString(event.message()));
|
const UserLevelFlags userLevel(event.sender_name() == otherUserInfo->name() ? otherUserInfo->user_level() : ownUserInfo->user_level());
|
||||||
|
chatView->appendMessage(QString::fromStdString(event.message()), QString::fromStdString(event.sender_name()), userLevel);
|
||||||
emit userEvent();
|
emit userEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabMessage::processUserLeft()
|
void TabMessage::processUserLeft()
|
||||||
{
|
{
|
||||||
chatView->appendMessage(QString(), tr("%1 has left the server.").arg(userName));
|
chatView->appendMessage(tr("%1 has left the server.").arg(QString::fromStdString(otherUserInfo->name())));
|
||||||
userOnline = false;
|
userOnline = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabMessage::processUserJoined()
|
void TabMessage::processUserJoined(const ServerInfo_User &_userInfo)
|
||||||
{
|
{
|
||||||
chatView->appendMessage(QString(), tr("%1 has joined the server.").arg(userName));
|
chatView->appendMessage(tr("%1 has joined the server.").arg(QString::fromStdString(otherUserInfo->name())));
|
||||||
userOnline = true;
|
userOnline = true;
|
||||||
|
*otherUserInfo = _userInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,14 @@ class ChatView;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class Event_UserMessage;
|
class Event_UserMessage;
|
||||||
class Response;
|
class Response;
|
||||||
|
class ServerInfo_User;
|
||||||
|
|
||||||
class TabMessage : public Tab {
|
class TabMessage : public Tab {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
QString userName;
|
ServerInfo_User *ownUserInfo;
|
||||||
|
ServerInfo_User *otherUserInfo;
|
||||||
bool userOnline;
|
bool userOnline;
|
||||||
|
|
||||||
ChatView *chatView;
|
ChatView *chatView;
|
||||||
|
@ -27,16 +29,16 @@ private slots:
|
||||||
void actLeave();
|
void actLeave();
|
||||||
void messageSent(const Response &response);
|
void messageSent(const Response &response);
|
||||||
public:
|
public:
|
||||||
TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, const QString &_ownName, const QString &_userName);
|
TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &_ownUserInfo, const ServerInfo_User &_otherUserInfo);
|
||||||
~TabMessage();
|
~TabMessage();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
QString getUserName() const { return userName; }
|
QString getUserName() const;
|
||||||
QString getTabText() const { return tr("Talking to %1").arg(userName); }
|
QString getTabText() const;
|
||||||
|
|
||||||
void processUserMessageEvent(const Event_UserMessage &event);
|
void processUserMessageEvent(const Event_UserMessage &event);
|
||||||
void processUserLeft();
|
void processUserLeft();
|
||||||
void processUserJoined();
|
void processUserJoined(const ServerInfo_User &_userInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,7 +40,8 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI
|
||||||
userList = new UserList(tabSupervisor, client, UserList::RoomList);
|
userList = new UserList(tabSupervisor, client, UserList::RoomList);
|
||||||
connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool)));
|
connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool)));
|
||||||
|
|
||||||
chatView = new ChatView(QString::fromStdString(ownUser->name()), true);
|
chatView = new ChatView(tabSupervisor, 0, true);
|
||||||
|
connect(chatView, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
|
||||||
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||||
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||||
sayLabel = new QLabel;
|
sayLabel = new QLabel;
|
||||||
|
@ -105,6 +106,7 @@ TabRoom::~TabRoom()
|
||||||
void TabRoom::retranslateUi()
|
void TabRoom::retranslateUi()
|
||||||
{
|
{
|
||||||
gameSelector->retranslateUi();
|
gameSelector->retranslateUi();
|
||||||
|
chatView->retranslateUi();
|
||||||
sayLabel->setText(tr("&Say:"));
|
sayLabel->setText(tr("&Say:"));
|
||||||
chatGroupBox->setTitle(tr("Chat"));
|
chatGroupBox->setTitle(tr("Chat"));
|
||||||
tabMenu->setTitle(tr("&Room"));
|
tabMenu->setTitle(tr("&Room"));
|
||||||
|
@ -142,7 +144,7 @@ void TabRoom::sendMessage()
|
||||||
void TabRoom::sayFinished(const Response &response)
|
void TabRoom::sayFinished(const Response &response)
|
||||||
{
|
{
|
||||||
if (response.response_code() == Response::RespChatFlood)
|
if (response.response_code() == Response::RespChatFlood)
|
||||||
chatView->appendMessage(QString(), tr("You are flooding the chat. Please wait a couple of seconds."));
|
chatView->appendMessage(tr("You are flooding the chat. Please wait a couple of seconds."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabRoom::actLeaveRoom()
|
void TabRoom::actLeaveRoom()
|
||||||
|
@ -197,20 +199,13 @@ void TabRoom::processRoomSayEvent(const Event_RoomSay &event)
|
||||||
if (tabSupervisor->getUserListsTab()->getIgnoreList()->getUsers().contains(senderName))
|
if (tabSupervisor->getUserListsTab()->getIgnoreList()->getUsers().contains(senderName))
|
||||||
return;
|
return;
|
||||||
UserListTWI *twi = userList->getUsers().value(senderName);
|
UserListTWI *twi = userList->getUsers().value(senderName);
|
||||||
QColor senderColor;
|
UserLevelFlags userLevel;
|
||||||
if (twi && (senderName != QString::fromStdString(ownUser->name()))) {
|
if (twi) {
|
||||||
ServerInfo_User::UserLevelFlags userLevel = static_cast<ServerInfo_User::UserLevelFlags>(twi->getUserLevel());
|
userLevel = UserLevelFlags(twi->getUserInfo().user_level());
|
||||||
if (userLevel & ServerInfo_User::IsModerator)
|
if (settingsCache->getIgnoreUnregisteredUsers() && !userLevel.testFlag(ServerInfo_User::IsRegistered))
|
||||||
senderColor = Qt::darkMagenta;
|
return;
|
||||||
else if (userLevel & ServerInfo_User::IsRegistered)
|
|
||||||
senderColor = Qt::darkGreen;
|
|
||||||
else {
|
|
||||||
if (settingsCache->getIgnoreUnregisteredUsers())
|
|
||||||
return;
|
|
||||||
senderColor = QColor(0, 0, 254);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
chatView->appendMessage(QString::fromStdString(event.name()), QString::fromStdString(event.message()), senderColor);
|
chatView->appendMessage(QString::fromStdString(event.message()), senderName, userLevel);
|
||||||
emit userEvent(false);
|
emit userEvent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
const QMap<int, QString> &getGameTypes() const { return gameTypes; }
|
const QMap<int, QString> &getGameTypes() const { return gameTypes; }
|
||||||
QString getChannelName() const { return roomName; }
|
QString getChannelName() const { return roomName; }
|
||||||
QString getTabText() const { return roomName; }
|
QString getTabText() const { return roomName; }
|
||||||
|
const ServerInfo_User *getUserInfo() const { return ownUser; }
|
||||||
|
|
||||||
PendingCommand *prepareRoomCommand(const ::google::protobuf::Message &cmd);
|
PendingCommand *prepareRoomCommand(const ::google::protobuf::Message &cmd);
|
||||||
void sendRoomCommand(PendingCommand *pend);
|
void sendRoomCommand(PendingCommand *pend);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "tab_message.h"
|
#include "tab_message.h"
|
||||||
#include "tab_userlists.h"
|
#include "tab_userlists.h"
|
||||||
#include "pixmapgenerator.h"
|
#include "pixmapgenerator.h"
|
||||||
|
#include "userlist.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
@ -96,21 +97,31 @@ TabSupervisor::~TabSupervisor()
|
||||||
void TabSupervisor::retranslateUi()
|
void TabSupervisor::retranslateUi()
|
||||||
{
|
{
|
||||||
QList<Tab *> tabs;
|
QList<Tab *> tabs;
|
||||||
if (tabServer)
|
tabs.append(tabServer);
|
||||||
tabs.append(tabServer);
|
tabs.append(tabReplays);
|
||||||
if (tabDeckStorage)
|
tabs.append(tabDeckStorage);
|
||||||
tabs.append(tabDeckStorage);
|
tabs.append(tabAdmin);
|
||||||
|
tabs.append(tabUserLists);
|
||||||
QMapIterator<int, TabRoom *> roomIterator(roomTabs);
|
QMapIterator<int, TabRoom *> roomIterator(roomTabs);
|
||||||
while (roomIterator.hasNext())
|
while (roomIterator.hasNext())
|
||||||
tabs.append(roomIterator.next().value());
|
tabs.append(roomIterator.next().value());
|
||||||
QMapIterator<int, TabGame *> gameIterator(gameTabs);
|
QMapIterator<int, TabGame *> gameIterator(gameTabs);
|
||||||
while (gameIterator.hasNext())
|
while (gameIterator.hasNext())
|
||||||
tabs.append(gameIterator.next().value());
|
tabs.append(gameIterator.next().value());
|
||||||
|
QListIterator<TabGame *> replayIterator(replayTabs);
|
||||||
|
while (replayIterator.hasNext())
|
||||||
|
tabs.append(replayIterator.next());
|
||||||
|
|
||||||
for (int i = 0; i < tabs.size(); ++i) {
|
for (int i = 0; i < tabs.size(); ++i)
|
||||||
setTabText(indexOf(tabs[i]), tabs[i]->getTabText());
|
if (tabs[i]) {
|
||||||
tabs[i]->retranslateUi();
|
setTabText(indexOf(tabs[i]), tabs[i]->getTabText());
|
||||||
}
|
tabs[i]->retranslateUi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractClient *TabSupervisor::getClient() const
|
||||||
|
{
|
||||||
|
return localClients.isEmpty() ? client : localClients.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TabSupervisor::myAddTab(Tab *tab)
|
int TabSupervisor::myAddTab(Tab *tab)
|
||||||
|
@ -129,7 +140,7 @@ void TabSupervisor::start(const ServerInfo_User &_userInfo)
|
||||||
|
|
||||||
tabUserLists = new TabUserLists(this, client, *userInfo);
|
tabUserLists = new TabUserLists(this, client, *userInfo);
|
||||||
connect(tabUserLists, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
|
connect(tabUserLists, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
|
||||||
connect(tabUserLists, SIGNAL(userJoined(const QString &)), this, SLOT(processUserJoined(const QString &)));
|
connect(tabUserLists, SIGNAL(userJoined(ServerInfo_User)), this, SLOT(processUserJoined(ServerInfo_User)));
|
||||||
connect(tabUserLists, SIGNAL(userLeft(const QString &)), this, SLOT(processUserLeft(const QString &)));
|
connect(tabUserLists, SIGNAL(userLeft(const QString &)), this, SLOT(processUserLeft(const QString &)));
|
||||||
myAddTab(tabUserLists);
|
myAddTab(tabUserLists);
|
||||||
|
|
||||||
|
@ -316,7 +327,7 @@ void TabSupervisor::roomLeft(TabRoom *tab)
|
||||||
|
|
||||||
void TabSupervisor::openReplay(GameReplay *replay)
|
void TabSupervisor::openReplay(GameReplay *replay)
|
||||||
{
|
{
|
||||||
TabGame *replayTab = new TabGame(replay);
|
TabGame *replayTab = new TabGame(this, replay);
|
||||||
connect(replayTab, SIGNAL(gameClosing(TabGame *)), this, SLOT(replayLeft(TabGame *)));
|
connect(replayTab, SIGNAL(gameClosing(TabGame *)), this, SLOT(replayLeft(TabGame *)));
|
||||||
int tabIndex = myAddTab(replayTab);
|
int tabIndex = myAddTab(replayTab);
|
||||||
addCloseButtonToTab(replayTab, tabIndex);
|
addCloseButtonToTab(replayTab, tabIndex);
|
||||||
|
@ -337,7 +348,13 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus
|
||||||
if (receiverName == QString::fromStdString(userInfo->name()))
|
if (receiverName == QString::fromStdString(userInfo->name()))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
TabMessage *tab = new TabMessage(this, client, QString::fromStdString(userInfo->name()), receiverName);
|
ServerInfo_User otherUser;
|
||||||
|
UserListTWI *twi = tabUserLists->getAllUsersList()->getUsers().value(receiverName);
|
||||||
|
if (twi)
|
||||||
|
otherUser = twi->getUserInfo();
|
||||||
|
else
|
||||||
|
otherUser.set_name(receiverName.toStdString());
|
||||||
|
TabMessage *tab = new TabMessage(this, client, *userInfo, otherUser);
|
||||||
connect(tab, SIGNAL(talkClosing(TabMessage *)), this, SLOT(talkLeft(TabMessage *)));
|
connect(tab, SIGNAL(talkClosing(TabMessage *)), this, SLOT(talkLeft(TabMessage *)));
|
||||||
int tabIndex = myAddTab(tab);
|
int tabIndex = myAddTab(tab);
|
||||||
addCloseButtonToTab(tab, tabIndex);
|
addCloseButtonToTab(tab, tabIndex);
|
||||||
|
@ -402,11 +419,11 @@ void TabSupervisor::processUserLeft(const QString &userName)
|
||||||
tab->processUserLeft();
|
tab->processUserLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::processUserJoined(const QString &userName)
|
void TabSupervisor::processUserJoined(const ServerInfo_User &userInfo)
|
||||||
{
|
{
|
||||||
TabMessage *tab = messageTabs.value(userName);
|
TabMessage *tab = messageTabs.value(QString::fromStdString(userInfo.name()));
|
||||||
if (tab)
|
if (tab)
|
||||||
tab->processUserJoined();
|
tab->processUserJoined(userInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::updateCurrent(int index)
|
void TabSupervisor::updateCurrent(int index)
|
||||||
|
@ -428,8 +445,3 @@ bool TabSupervisor::getAdminLocked() const
|
||||||
return true;
|
return true;
|
||||||
return tabAdmin->getLocked();
|
return tabAdmin->getLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TabSupervisor::getUserLevel() const
|
|
||||||
{
|
|
||||||
return userInfo->user_level();
|
|
||||||
}
|
|
||||||
|
|
|
@ -64,9 +64,9 @@ public:
|
||||||
int getGameCount() const { return gameTabs.size(); }
|
int getGameCount() const { return gameTabs.size(); }
|
||||||
TabUserLists *getUserListsTab() const { return tabUserLists; }
|
TabUserLists *getUserListsTab() const { return tabUserLists; }
|
||||||
ServerInfo_User *getUserInfo() const { return userInfo; }
|
ServerInfo_User *getUserInfo() const { return userInfo; }
|
||||||
|
AbstractClient *getClient() const;
|
||||||
const QMap<int, TabRoom *> &getRoomTabs() const { return roomTabs; }
|
const QMap<int, TabRoom *> &getRoomTabs() const { return roomTabs; }
|
||||||
bool getAdminLocked() const;
|
bool getAdminLocked() const;
|
||||||
int getUserLevel() const;
|
|
||||||
signals:
|
signals:
|
||||||
void setMenu(QMenu *menu);
|
void setMenu(QMenu *menu);
|
||||||
void localGameEnded();
|
void localGameEnded();
|
||||||
|
@ -84,7 +84,7 @@ private slots:
|
||||||
void openReplay(GameReplay *replay);
|
void openReplay(GameReplay *replay);
|
||||||
void replayLeft(TabGame *tab);
|
void replayLeft(TabGame *tab);
|
||||||
void processUserLeft(const QString &userName);
|
void processUserLeft(const QString &userName);
|
||||||
void processUserJoined(const QString &userName);
|
void processUserJoined(const ServerInfo_User &userInfo);
|
||||||
void talkLeft(TabMessage *tab);
|
void talkLeft(TabMessage *tab);
|
||||||
void tabUserEvent(bool globalEvent);
|
void tabUserEvent(bool globalEvent);
|
||||||
void processRoomEvent(const RoomEvent &event);
|
void processRoomEvent(const RoomEvent &event);
|
||||||
|
|
|
@ -88,7 +88,7 @@ void TabUserLists::processUserJoinedEvent(const Event_UserJoined &event)
|
||||||
ignoreList->sortItems();
|
ignoreList->sortItems();
|
||||||
buddyList->sortItems();
|
buddyList->sortItems();
|
||||||
|
|
||||||
emit userJoined(userName);
|
emit userJoined(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabUserLists::processUserLeftEvent(const Event_UserLeft &event)
|
void TabUserLists::processUserLeftEvent(const Event_UserLeft &event)
|
||||||
|
|
|
@ -21,7 +21,7 @@ class TabUserLists : public Tab {
|
||||||
signals:
|
signals:
|
||||||
void openMessageDialog(const QString &userName, bool focus);
|
void openMessageDialog(const QString &userName, bool focus);
|
||||||
void userLeft(const QString &userName);
|
void userLeft(const QString &userName);
|
||||||
void userJoined(const QString &userName);
|
void userJoined(const ServerInfo_User &userInfo);
|
||||||
private slots:
|
private slots:
|
||||||
void processListUsersResponse(const Response &response);
|
void processListUsersResponse(const Response &response);
|
||||||
void processUserJoinedEvent(const Event_UserJoined &event);
|
void processUserJoinedEvent(const Event_UserJoined &event);
|
||||||
|
@ -40,8 +40,9 @@ public:
|
||||||
TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &userInfo, QWidget *parent = 0);
|
TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &userInfo, QWidget *parent = 0);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
QString getTabText() const { return tr("User lists"); }
|
QString getTabText() const { return tr("User lists"); }
|
||||||
UserList *getBuddyList() const { return buddyList; }
|
const UserList *getAllUsersList() const { return allUsersList; }
|
||||||
UserList *getIgnoreList() const { return ignoreList; }
|
const UserList *getBuddyList() const { return buddyList; }
|
||||||
|
const UserList *getIgnoreList() const { return ignoreList; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
198
cockatrice/src/user_context_menu.cpp
Normal file
198
cockatrice/src/user_context_menu.cpp
Normal file
|
@ -0,0 +1,198 @@
|
||||||
|
#include <QAction>
|
||||||
|
#include <QMenu>
|
||||||
|
#include "user_context_menu.h"
|
||||||
|
#include "tab_supervisor.h"
|
||||||
|
#include "tab_userlists.h"
|
||||||
|
#include "tab_game.h"
|
||||||
|
#include "userlist.h"
|
||||||
|
#include "abstractclient.h"
|
||||||
|
#include "userinfobox.h"
|
||||||
|
#include "gameselector.h"
|
||||||
|
#include "pending_command.h"
|
||||||
|
|
||||||
|
#include "pb/commands.pb.h"
|
||||||
|
#include "pb/session_commands.pb.h"
|
||||||
|
#include "pb/moderator_commands.pb.h"
|
||||||
|
#include "pb/command_kick_from_game.pb.h"
|
||||||
|
#include "pb/response_get_games_of_user.pb.h"
|
||||||
|
#include "pb/response_get_user_info.pb.h"
|
||||||
|
|
||||||
|
UserContextMenu::UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *parent, TabGame *_game)
|
||||||
|
: QObject(parent), client(_tabSupervisor->getClient()), tabSupervisor(_tabSupervisor), game(_game)
|
||||||
|
{
|
||||||
|
aUserName = new QAction(QString(), this);
|
||||||
|
aUserName->setEnabled(false);
|
||||||
|
aDetails = new QAction(QString(), this);
|
||||||
|
aChat = new QAction(QString(), this);
|
||||||
|
aShowGames = new QAction(QString(), this);
|
||||||
|
aAddToBuddyList = new QAction(QString(), this);
|
||||||
|
aRemoveFromBuddyList = new QAction(QString(), this);
|
||||||
|
aAddToIgnoreList = new QAction(QString(), this);
|
||||||
|
aRemoveFromIgnoreList = new QAction(QString(), this);
|
||||||
|
aKick = new QAction(QString(), this);
|
||||||
|
aBan = new QAction(QString(), this);
|
||||||
|
|
||||||
|
retranslateUi();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserContextMenu::retranslateUi()
|
||||||
|
{
|
||||||
|
aDetails->setText(tr("User &details"));
|
||||||
|
aChat->setText(tr("Direct &chat"));
|
||||||
|
aShowGames->setText(tr("Show this user's &games"));
|
||||||
|
aAddToBuddyList->setText(tr("Add to &buddy list"));
|
||||||
|
aRemoveFromBuddyList->setText(tr("Remove from &buddy list"));
|
||||||
|
aAddToIgnoreList->setText(tr("Add to &ignore list"));
|
||||||
|
aRemoveFromIgnoreList->setText(tr("Remove from &ignore list"));
|
||||||
|
aKick->setText(tr("Kick from &game"));
|
||||||
|
aBan->setText(tr("Ban from &server"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer)
|
||||||
|
{
|
||||||
|
const Response_GetGamesOfUser &response = resp.GetExtension(Response_GetGamesOfUser::ext);
|
||||||
|
const Command_GetGamesOfUser &cmd = commandContainer.session_command(0).GetExtension(Command_GetGamesOfUser::ext);
|
||||||
|
|
||||||
|
QMap<int, GameTypeMap> gameTypeMap;
|
||||||
|
QMap<int, QString> roomMap;
|
||||||
|
const int roomListSize = response.room_list_size();
|
||||||
|
for (int i = 0; i < roomListSize; ++i) {
|
||||||
|
const ServerInfo_Room &roomInfo = response.room_list(i);
|
||||||
|
roomMap.insert(roomInfo.room_id(), QString::fromStdString(roomInfo.name()));
|
||||||
|
GameTypeMap tempMap;
|
||||||
|
const int gameTypeListSize = roomInfo.gametype_list_size();
|
||||||
|
for (int j = 0; j < gameTypeListSize; ++j) {
|
||||||
|
const ServerInfo_GameType &gameTypeInfo = roomInfo.gametype_list(j);
|
||||||
|
tempMap.insert(gameTypeInfo.game_type_id(), QString::fromStdString(gameTypeInfo.description()));
|
||||||
|
}
|
||||||
|
gameTypeMap.insert(roomInfo.room_id(), tempMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameSelector *selector = new GameSelector(client, tabSupervisor, 0, roomMap, gameTypeMap);
|
||||||
|
const int gameListSize = response.game_list_size();
|
||||||
|
for (int i = 0; i < gameListSize; ++i)
|
||||||
|
selector->processGameInfo(response.game_list(i));
|
||||||
|
|
||||||
|
selector->setWindowTitle(tr("%1's games").arg(QString::fromStdString(cmd.user_name())));
|
||||||
|
selector->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
selector->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserContextMenu::banUser_processUserInfoResponse(const Response &r)
|
||||||
|
{
|
||||||
|
const Response_GetUserInfo &response = r.GetExtension(Response_GetUserInfo::ext);
|
||||||
|
|
||||||
|
// The dialog needs to be non-modal in order to not block the event queue of the client.
|
||||||
|
BanDialog *dlg = new BanDialog(response.user_info(), static_cast<QWidget *>(parent()));
|
||||||
|
connect(dlg, SIGNAL(accepted()), this, SLOT(banUser_dialogFinished()));
|
||||||
|
dlg->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserContextMenu::banUser_dialogFinished()
|
||||||
|
{
|
||||||
|
BanDialog *dlg = static_cast<BanDialog *>(sender());
|
||||||
|
|
||||||
|
Command_BanFromServer cmd;
|
||||||
|
cmd.set_user_name(dlg->getBanName().toStdString());
|
||||||
|
cmd.set_address(dlg->getBanIP().toStdString());
|
||||||
|
cmd.set_minutes(dlg->getMinutes());
|
||||||
|
cmd.set_reason(dlg->getReason().toStdString());
|
||||||
|
cmd.set_visible_reason(dlg->getVisibleReason().toStdString());
|
||||||
|
|
||||||
|
client->sendCommand(client->prepareModeratorCommand(cmd));
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, int playerId)
|
||||||
|
{
|
||||||
|
aUserName->setText(userName);
|
||||||
|
|
||||||
|
QMenu *menu = new QMenu(static_cast<QWidget *>(parent()));
|
||||||
|
menu->addAction(aUserName);
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addAction(aDetails);
|
||||||
|
menu->addAction(aShowGames);
|
||||||
|
menu->addAction(aChat);
|
||||||
|
if (userLevel.testFlag(ServerInfo_User::IsRegistered) && (tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsRegistered)) {
|
||||||
|
menu->addSeparator();
|
||||||
|
if (tabSupervisor->getUserListsTab()->getBuddyList()->getUsers().contains(userName))
|
||||||
|
menu->addAction(aRemoveFromBuddyList);
|
||||||
|
else
|
||||||
|
menu->addAction(aAddToBuddyList);
|
||||||
|
if (tabSupervisor->getUserListsTab()->getIgnoreList()->getUsers().contains(userName))
|
||||||
|
menu->addAction(aRemoveFromIgnoreList);
|
||||||
|
else
|
||||||
|
menu->addAction(aAddToIgnoreList);
|
||||||
|
}
|
||||||
|
if (game && (game->isHost() || !tabSupervisor->getAdminLocked())) {
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addAction(aKick);
|
||||||
|
}
|
||||||
|
if (!tabSupervisor->getAdminLocked()) {
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addAction(aBan);
|
||||||
|
}
|
||||||
|
bool anotherUser = userName != QString::fromStdString(tabSupervisor->getUserInfo()->name());
|
||||||
|
aChat->setEnabled(anotherUser);
|
||||||
|
aShowGames->setEnabled(anotherUser);
|
||||||
|
aAddToBuddyList->setEnabled(anotherUser);
|
||||||
|
aRemoveFromBuddyList->setEnabled(anotherUser);
|
||||||
|
aAddToIgnoreList->setEnabled(anotherUser);
|
||||||
|
aRemoveFromIgnoreList->setEnabled(anotherUser);
|
||||||
|
aKick->setEnabled(anotherUser);
|
||||||
|
aBan->setEnabled(anotherUser);
|
||||||
|
|
||||||
|
QAction *actionClicked = menu->exec(pos);
|
||||||
|
if (actionClicked == aDetails) {
|
||||||
|
UserInfoBox *infoWidget = new UserInfoBox(client, true, static_cast<QWidget *>(parent()), Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||||
|
infoWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
infoWidget->updateInfo(userName);
|
||||||
|
} else if (actionClicked == aChat)
|
||||||
|
emit openMessageDialog(userName, true);
|
||||||
|
else if (actionClicked == aShowGames) {
|
||||||
|
Command_GetGamesOfUser cmd;
|
||||||
|
cmd.set_user_name(userName.toStdString());
|
||||||
|
|
||||||
|
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||||
|
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(gamesOfUserReceived(Response, CommandContainer)));
|
||||||
|
|
||||||
|
client->sendCommand(pend);
|
||||||
|
} else if (actionClicked == aAddToBuddyList) {
|
||||||
|
Command_AddToList cmd;
|
||||||
|
cmd.set_list("buddy");
|
||||||
|
cmd.set_user_name(userName.toStdString());
|
||||||
|
|
||||||
|
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||||
|
} else if (actionClicked == aRemoveFromBuddyList) {
|
||||||
|
Command_RemoveFromList cmd;
|
||||||
|
cmd.set_list("buddy");
|
||||||
|
cmd.set_user_name(userName.toStdString());
|
||||||
|
|
||||||
|
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||||
|
} else if (actionClicked == aAddToIgnoreList) {
|
||||||
|
Command_AddToList cmd;
|
||||||
|
cmd.set_list("ignore");
|
||||||
|
cmd.set_user_name(userName.toStdString());
|
||||||
|
|
||||||
|
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||||
|
} else if (actionClicked == aRemoveFromIgnoreList) {
|
||||||
|
Command_RemoveFromList cmd;
|
||||||
|
cmd.set_list("ignore");
|
||||||
|
cmd.set_user_name(userName.toStdString());
|
||||||
|
|
||||||
|
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||||
|
} else if (actionClicked == aKick) {
|
||||||
|
Command_KickFromGame cmd;
|
||||||
|
cmd.set_player_id(game->getPlayerIdByName(userName));
|
||||||
|
game->sendGameCommand(cmd);
|
||||||
|
} else if (actionClicked == aBan) {
|
||||||
|
Command_GetUserInfo cmd;
|
||||||
|
cmd.set_user_name(userName.toStdString());
|
||||||
|
|
||||||
|
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||||
|
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUser_processUserInfoResponse(Response)));
|
||||||
|
|
||||||
|
client->sendCommand(pend);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete menu;
|
||||||
|
}
|
42
cockatrice/src/user_context_menu.h
Normal file
42
cockatrice/src/user_context_menu.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef USER_CONTEXT_MENU_H
|
||||||
|
#define USER_CONTEXT_MENU_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "user_level.h"
|
||||||
|
|
||||||
|
class QAction;
|
||||||
|
class TabSupervisor;
|
||||||
|
class TabGame;
|
||||||
|
class QPoint;
|
||||||
|
class CommandContainer;
|
||||||
|
class Response;
|
||||||
|
class AbstractClient;
|
||||||
|
|
||||||
|
class UserContextMenu : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
AbstractClient *client;
|
||||||
|
const TabSupervisor *tabSupervisor;
|
||||||
|
TabGame *game;
|
||||||
|
|
||||||
|
QAction *aUserName;
|
||||||
|
QAction *aDetails;
|
||||||
|
QAction *aShowGames;
|
||||||
|
QAction *aChat;
|
||||||
|
QAction *aAddToBuddyList, *aRemoveFromBuddyList;
|
||||||
|
QAction *aAddToIgnoreList, *aRemoveFromIgnoreList;
|
||||||
|
QAction *aKick;
|
||||||
|
QAction *aBan;
|
||||||
|
signals:
|
||||||
|
void openMessageDialog(const QString &userName, bool focus);
|
||||||
|
private slots:
|
||||||
|
void banUser_processUserInfoResponse(const Response &resp);
|
||||||
|
void banUser_dialogFinished();
|
||||||
|
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
|
||||||
|
public:
|
||||||
|
UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *_parent, TabGame *_game = 0);
|
||||||
|
void retranslateUi();
|
||||||
|
void showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, int playerId = -1);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -56,7 +56,7 @@ void UserInfoBox::retranslateUi()
|
||||||
|
|
||||||
void UserInfoBox::updateInfo(const ServerInfo_User &user)
|
void UserInfoBox::updateInfo(const ServerInfo_User &user)
|
||||||
{
|
{
|
||||||
const int userLevel = user.user_level();
|
const UserLevelFlags userLevel(user.user_level());
|
||||||
|
|
||||||
QPixmap avatarPixmap;
|
QPixmap avatarPixmap;
|
||||||
const std::string bmp = user.avatar_bmp();
|
const std::string bmp = user.avatar_bmp();
|
||||||
|
@ -70,11 +70,11 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user)
|
||||||
countryLabel2->setPixmap(CountryPixmapGenerator::generatePixmap(15, QString::fromStdString(user.country())));
|
countryLabel2->setPixmap(CountryPixmapGenerator::generatePixmap(15, QString::fromStdString(user.country())));
|
||||||
userLevelLabel2->setPixmap(UserLevelPixmapGenerator::generatePixmap(15, userLevel));
|
userLevelLabel2->setPixmap(UserLevelPixmapGenerator::generatePixmap(15, userLevel));
|
||||||
QString userLevelText;
|
QString userLevelText;
|
||||||
if (userLevel & ServerInfo_User::IsAdmin)
|
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
|
||||||
userLevelText = tr("Administrator");
|
userLevelText = tr("Administrator");
|
||||||
else if (userLevel & ServerInfo_User::IsModerator)
|
else if (userLevel.testFlag(ServerInfo_User::IsModerator))
|
||||||
userLevelText = tr("Moderator");
|
userLevelText = tr("Moderator");
|
||||||
else if (userLevel & ServerInfo_User::IsRegistered)
|
else if (userLevel.testFlag(ServerInfo_User::IsRegistered))
|
||||||
userLevelText = tr("Registered user");
|
userLevelText = tr("Registered user");
|
||||||
else
|
else
|
||||||
userLevelText = tr("Unregistered user");
|
userLevelText = tr("Unregistered user");
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "abstractclient.h"
|
#include "abstractclient.h"
|
||||||
#include "pixmapgenerator.h"
|
#include "pixmapgenerator.h"
|
||||||
#include "userinfobox.h"
|
#include "userinfobox.h"
|
||||||
|
#include "user_context_menu.h"
|
||||||
#include "gameselector.h"
|
#include "gameselector.h"
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
@ -169,19 +170,27 @@ bool UserListItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||||
return QStyledItemDelegate::editorEvent(event, model, option, index);
|
return QStyledItemDelegate::editorEvent(event, model, option, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
UserListTWI::UserListTWI()
|
UserListTWI::UserListTWI(const ServerInfo_User &_userInfo)
|
||||||
: QTreeWidgetItem(Type)
|
: QTreeWidgetItem(Type)
|
||||||
{
|
{
|
||||||
|
setUserInfo(_userInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UserListTWI::getUserName() const
|
void UserListTWI::setUserInfo(const ServerInfo_User &_userInfo)
|
||||||
{
|
{
|
||||||
return data(2, Qt::UserRole).toString();
|
userInfo = _userInfo;
|
||||||
|
|
||||||
|
setData(0, Qt::UserRole, userInfo.user_level());
|
||||||
|
setIcon(0, QIcon(UserLevelPixmapGenerator::generatePixmap(12, UserLevelFlags(userInfo.user_level()))));
|
||||||
|
setIcon(1, QIcon(CountryPixmapGenerator::generatePixmap(12, QString::fromStdString(userInfo.country()))));
|
||||||
|
setData(2, Qt::UserRole, QString::fromStdString(userInfo.name()));
|
||||||
|
setData(2, Qt::DisplayRole, QString::fromStdString(userInfo.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int UserListTWI::getUserLevel() const
|
void UserListTWI::setOnline(bool online)
|
||||||
{
|
{
|
||||||
return data(0, Qt::UserRole).toInt();
|
setData(0, Qt::UserRole + 1, online);
|
||||||
|
setData(2, Qt::ForegroundRole, online ? QBrush() : QBrush(Qt::gray));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UserListTWI::operator<(const QTreeWidgetItem &other) const
|
bool UserListTWI::operator<(const QTreeWidgetItem &other) const
|
||||||
|
@ -202,6 +211,8 @@ UserList::UserList(TabSupervisor *_tabSupervisor, AbstractClient *_client, UserL
|
||||||
: QGroupBox(parent), tabSupervisor(_tabSupervisor), client(_client), type(_type), onlineCount(0)
|
: QGroupBox(parent), tabSupervisor(_tabSupervisor), client(_client), type(_type), onlineCount(0)
|
||||||
{
|
{
|
||||||
itemDelegate = new UserListItemDelegate(this);
|
itemDelegate = new UserListItemDelegate(this);
|
||||||
|
userContextMenu = new UserContextMenu(tabSupervisor, this);
|
||||||
|
connect(userContextMenu, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
|
||||||
|
|
||||||
userTree = new QTreeWidget;
|
userTree = new QTreeWidget;
|
||||||
userTree->setColumnCount(3);
|
userTree->setColumnCount(3);
|
||||||
|
@ -236,25 +247,17 @@ void UserList::processUserInfo(const ServerInfo_User &user, bool online)
|
||||||
{
|
{
|
||||||
const QString userName = QString::fromStdString(user.name());
|
const QString userName = QString::fromStdString(user.name());
|
||||||
UserListTWI *item = users.value(userName);
|
UserListTWI *item = users.value(userName);
|
||||||
if (!item) {
|
if (item)
|
||||||
item = new UserListTWI;
|
item->setUserInfo(user);
|
||||||
|
else {
|
||||||
|
item = new UserListTWI(user);
|
||||||
users.insert(userName, item);
|
users.insert(userName, item);
|
||||||
userTree->addTopLevelItem(item);
|
userTree->addTopLevelItem(item);
|
||||||
if (online)
|
if (online)
|
||||||
++onlineCount;
|
++onlineCount;
|
||||||
updateCount();
|
updateCount();
|
||||||
}
|
}
|
||||||
item->setData(0, Qt::UserRole, user.user_level());
|
item->setOnline(online);
|
||||||
item->setIcon(0, QIcon(UserLevelPixmapGenerator::generatePixmap(12, user.user_level())));
|
|
||||||
item->setIcon(1, QIcon(CountryPixmapGenerator::generatePixmap(12, QString::fromStdString(user.country()))));
|
|
||||||
item->setData(2, Qt::UserRole, QString::fromStdString(user.name()));
|
|
||||||
item->setData(2, Qt::DisplayRole, QString::fromStdString(user.name()));
|
|
||||||
|
|
||||||
item->setData(0, Qt::UserRole + 1, online);
|
|
||||||
if (online)
|
|
||||||
item->setData(2, Qt::ForegroundRole, QBrush());
|
|
||||||
else
|
|
||||||
item->setData(2, Qt::ForegroundRole, QBrush(Qt::gray));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UserList::deleteUser(const QString &userName)
|
bool UserList::deleteUser(const QString &userName)
|
||||||
|
@ -273,25 +276,18 @@ bool UserList::deleteUser(const QString &userName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserList::setUserOnline(QTreeWidgetItem *item, bool online)
|
|
||||||
{
|
|
||||||
item->setData(0, Qt::UserRole + 1, online);
|
|
||||||
|
|
||||||
if (online) {
|
|
||||||
item->setData(2, Qt::ForegroundRole, QBrush());
|
|
||||||
++onlineCount;
|
|
||||||
} else {
|
|
||||||
item->setData(2, Qt::ForegroundRole, QBrush(Qt::gray));
|
|
||||||
--onlineCount;
|
|
||||||
}
|
|
||||||
updateCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserList::setUserOnline(const QString &userName, bool online)
|
void UserList::setUserOnline(const QString &userName, bool online)
|
||||||
{
|
{
|
||||||
UserListTWI *twi = users.value(userName);
|
UserListTWI *twi = users.value(userName);
|
||||||
if (twi)
|
if (!twi)
|
||||||
setUserOnline(twi, online);
|
return;
|
||||||
|
|
||||||
|
twi->setOnline(online);
|
||||||
|
if (online)
|
||||||
|
++onlineCount;
|
||||||
|
else
|
||||||
|
--onlineCount;
|
||||||
|
updateCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserList::updateCount()
|
void UserList::updateCount()
|
||||||
|
@ -307,165 +303,11 @@ void UserList::userClicked(QTreeWidgetItem *item, int /*column*/)
|
||||||
emit openMessageDialog(item->data(2, Qt::UserRole).toString(), true);
|
emit openMessageDialog(item->data(2, Qt::UserRole).toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserList::gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer)
|
|
||||||
{
|
|
||||||
const Response_GetGamesOfUser &response = resp.GetExtension(Response_GetGamesOfUser::ext);
|
|
||||||
const Command_GetGamesOfUser &cmd = commandContainer.session_command(0).GetExtension(Command_GetGamesOfUser::ext);
|
|
||||||
|
|
||||||
QMap<int, GameTypeMap> gameTypeMap;
|
|
||||||
QMap<int, QString> roomMap;
|
|
||||||
const int roomListSize = response.room_list_size();
|
|
||||||
for (int i = 0; i < roomListSize; ++i) {
|
|
||||||
const ServerInfo_Room &roomInfo = response.room_list(i);
|
|
||||||
roomMap.insert(roomInfo.room_id(), QString::fromStdString(roomInfo.name()));
|
|
||||||
GameTypeMap tempMap;
|
|
||||||
const int gameTypeListSize = roomInfo.gametype_list_size();
|
|
||||||
for (int j = 0; j < gameTypeListSize; ++j) {
|
|
||||||
const ServerInfo_GameType &gameTypeInfo = roomInfo.gametype_list(j);
|
|
||||||
tempMap.insert(gameTypeInfo.game_type_id(), QString::fromStdString(gameTypeInfo.description()));
|
|
||||||
}
|
|
||||||
gameTypeMap.insert(roomInfo.room_id(), tempMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameSelector *selector = new GameSelector(client, tabSupervisor, 0, roomMap, gameTypeMap);
|
|
||||||
const int gameListSize = response.game_list_size();
|
|
||||||
for (int i = 0; i < gameListSize; ++i)
|
|
||||||
selector->processGameInfo(response.game_list(i));
|
|
||||||
|
|
||||||
selector->setWindowTitle(tr("%1's games").arg(QString::fromStdString(cmd.user_name())));
|
|
||||||
selector->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
selector->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserList::banUser_processUserInfoResponse(const Response &r)
|
|
||||||
{
|
|
||||||
const Response_GetUserInfo &response = r.GetExtension(Response_GetUserInfo::ext);
|
|
||||||
|
|
||||||
// The dialog needs to be non-modal in order to not block the event queue of the client.
|
|
||||||
BanDialog *dlg = new BanDialog(response.user_info(), this);
|
|
||||||
connect(dlg, SIGNAL(accepted()), this, SLOT(banUser_dialogFinished()));
|
|
||||||
dlg->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserList::banUser_dialogFinished()
|
|
||||||
{
|
|
||||||
BanDialog *dlg = static_cast<BanDialog *>(sender());
|
|
||||||
|
|
||||||
Command_BanFromServer cmd;
|
|
||||||
cmd.set_user_name(dlg->getBanName().toStdString());
|
|
||||||
cmd.set_address(dlg->getBanIP().toStdString());
|
|
||||||
cmd.set_minutes(dlg->getMinutes());
|
|
||||||
cmd.set_reason(dlg->getReason().toStdString());
|
|
||||||
cmd.set_visible_reason(dlg->getVisibleReason().toStdString());
|
|
||||||
|
|
||||||
client->sendCommand(client->prepareModeratorCommand(cmd));
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserList::showContextMenu(const QPoint &pos, const QModelIndex &index)
|
void UserList::showContextMenu(const QPoint &pos, const QModelIndex &index)
|
||||||
{
|
{
|
||||||
UserListTWI *twi = static_cast<UserListTWI *>(userTree->topLevelItem(index.row()));
|
const ServerInfo_User &userInfo = static_cast<UserListTWI *>(userTree->topLevelItem(index.row()))->getUserInfo();
|
||||||
const QString &userName = twi->getUserName();
|
|
||||||
ServerInfo_User::UserLevelFlags userLevel = static_cast<ServerInfo_User::UserLevelFlags>(twi->getUserLevel());
|
|
||||||
|
|
||||||
QAction *aUserName = new QAction(userName, this);
|
userContextMenu->showContextMenu(pos, QString::fromStdString(userInfo.name()), UserLevelFlags(userInfo.user_level()));
|
||||||
aUserName->setEnabled(false);
|
|
||||||
QAction *aDetails = new QAction(tr("User &details"), this);
|
|
||||||
QAction *aChat = new QAction(tr("Direct &chat"), this);
|
|
||||||
QAction *aShowGames = new QAction(tr("Show this user's &games"), this);
|
|
||||||
QAction *aAddToBuddyList = new QAction(tr("Add to &buddy list"), this);
|
|
||||||
QAction *aRemoveFromBuddyList = new QAction(tr("Remove from &buddy list"), this);
|
|
||||||
QAction *aAddToIgnoreList = new QAction(tr("Add to &ignore list"), this);
|
|
||||||
QAction *aRemoveFromIgnoreList = new QAction(tr("Remove from &ignore list"), this);
|
|
||||||
QAction *aBan = new QAction(tr("Ban from &server"), this);
|
|
||||||
|
|
||||||
QMenu *menu = new QMenu(this);
|
|
||||||
menu->addAction(aUserName);
|
|
||||||
menu->addSeparator();
|
|
||||||
menu->addAction(aDetails);
|
|
||||||
menu->addAction(aShowGames);
|
|
||||||
menu->addAction(aChat);
|
|
||||||
if ((userLevel & ServerInfo_User::IsRegistered) && (tabSupervisor->getUserLevel() & ServerInfo_User::IsRegistered)) {
|
|
||||||
menu->addSeparator();
|
|
||||||
if (tabSupervisor->getUserListsTab()->getBuddyList()->getUsers().contains(userName))
|
|
||||||
menu->addAction(aRemoveFromBuddyList);
|
|
||||||
else
|
|
||||||
menu->addAction(aAddToBuddyList);
|
|
||||||
if (tabSupervisor->getUserListsTab()->getIgnoreList()->getUsers().contains(userName))
|
|
||||||
menu->addAction(aRemoveFromIgnoreList);
|
|
||||||
else
|
|
||||||
menu->addAction(aAddToIgnoreList);
|
|
||||||
}
|
|
||||||
if (!tabSupervisor->getAdminLocked()) {
|
|
||||||
menu->addSeparator();
|
|
||||||
menu->addAction(aBan);
|
|
||||||
}
|
|
||||||
if (userName == QString::fromStdString(tabSupervisor->getUserInfo()->name())) {
|
|
||||||
aChat->setEnabled(false);
|
|
||||||
aAddToBuddyList->setEnabled(false);
|
|
||||||
aRemoveFromBuddyList->setEnabled(false);
|
|
||||||
aAddToIgnoreList->setEnabled(false);
|
|
||||||
aRemoveFromIgnoreList->setEnabled(false);
|
|
||||||
aBan->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
QAction *actionClicked = menu->exec(pos);
|
|
||||||
if (actionClicked == aDetails) {
|
|
||||||
UserInfoBox *infoWidget = new UserInfoBox(client, true, this, Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
|
||||||
infoWidget->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
infoWidget->updateInfo(userName);
|
|
||||||
} else if (actionClicked == aChat)
|
|
||||||
emit openMessageDialog(userName, true);
|
|
||||||
else if (actionClicked == aAddToBuddyList) {
|
|
||||||
Command_AddToList cmd;
|
|
||||||
cmd.set_list("buddy");
|
|
||||||
cmd.set_user_name(userName.toStdString());
|
|
||||||
|
|
||||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
|
||||||
} else if (actionClicked == aRemoveFromBuddyList) {
|
|
||||||
Command_RemoveFromList cmd;
|
|
||||||
cmd.set_list("buddy");
|
|
||||||
cmd.set_user_name(userName.toStdString());
|
|
||||||
|
|
||||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
|
||||||
} else if (actionClicked == aShowGames) {
|
|
||||||
Command_GetGamesOfUser cmd;
|
|
||||||
cmd.set_user_name(userName.toStdString());
|
|
||||||
|
|
||||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
|
||||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(gamesOfUserReceived(Response, CommandContainer)));
|
|
||||||
|
|
||||||
client->sendCommand(pend);
|
|
||||||
} else if (actionClicked == aAddToIgnoreList) {
|
|
||||||
Command_AddToList cmd;
|
|
||||||
cmd.set_list("ignore");
|
|
||||||
cmd.set_user_name(userName.toStdString());
|
|
||||||
|
|
||||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
|
||||||
} else if (actionClicked == aRemoveFromIgnoreList) {
|
|
||||||
Command_RemoveFromList cmd;
|
|
||||||
cmd.set_list("ignore");
|
|
||||||
cmd.set_user_name(userName.toStdString());
|
|
||||||
|
|
||||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
|
||||||
} else if (actionClicked == aBan) {
|
|
||||||
Command_GetUserInfo cmd;
|
|
||||||
cmd.set_user_name(userName.toStdString());
|
|
||||||
|
|
||||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
|
||||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUser_processUserInfoResponse(Response)));
|
|
||||||
|
|
||||||
client->sendCommand(pend);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete menu;
|
|
||||||
delete aUserName;
|
|
||||||
delete aDetails;
|
|
||||||
delete aChat;
|
|
||||||
delete aAddToBuddyList;
|
|
||||||
delete aRemoveFromBuddyList;
|
|
||||||
delete aAddToIgnoreList;
|
|
||||||
delete aRemoveFromIgnoreList;
|
|
||||||
delete aBan;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserList::sortItems()
|
void UserList::sortItems()
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
|
#include "user_level.h"
|
||||||
|
|
||||||
class QTreeWidget;
|
class QTreeWidget;
|
||||||
class ServerInfo_User;
|
class ServerInfo_User;
|
||||||
|
@ -17,6 +18,7 @@ class QRadioButton;
|
||||||
class QPlainTextEdit;
|
class QPlainTextEdit;
|
||||||
class Response;
|
class Response;
|
||||||
class CommandContainer;
|
class CommandContainer;
|
||||||
|
class UserContextMenu;
|
||||||
|
|
||||||
class BanDialog : public QDialog {
|
class BanDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -46,10 +48,13 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
class UserListTWI : public QTreeWidgetItem {
|
class UserListTWI : public QTreeWidgetItem {
|
||||||
|
private:
|
||||||
|
ServerInfo_User userInfo;
|
||||||
public:
|
public:
|
||||||
UserListTWI();
|
UserListTWI(const ServerInfo_User &_userInfo);
|
||||||
QString getUserName() const;
|
const ServerInfo_User &getUserInfo() const { return userInfo; }
|
||||||
int getUserLevel() const;
|
void setUserInfo(const ServerInfo_User &_userInfo);
|
||||||
|
void setOnline(bool online);
|
||||||
bool operator<(const QTreeWidgetItem &other) const;
|
bool operator<(const QTreeWidgetItem &other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,15 +69,12 @@ private:
|
||||||
UserListType type;
|
UserListType type;
|
||||||
QTreeWidget *userTree;
|
QTreeWidget *userTree;
|
||||||
UserListItemDelegate *itemDelegate;
|
UserListItemDelegate *itemDelegate;
|
||||||
|
UserContextMenu *userContextMenu;
|
||||||
int onlineCount;
|
int onlineCount;
|
||||||
QString titleStr;
|
QString titleStr;
|
||||||
void updateCount();
|
void updateCount();
|
||||||
void setUserOnline(QTreeWidgetItem *user, bool online);
|
|
||||||
private slots:
|
private slots:
|
||||||
void userClicked(QTreeWidgetItem *item, int column);
|
void userClicked(QTreeWidgetItem *item, int column);
|
||||||
void banUser_processUserInfoResponse(const Response &resp);
|
|
||||||
void banUser_dialogFinished();
|
|
||||||
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
|
|
||||||
signals:
|
signals:
|
||||||
void openMessageDialog(const QString &userName, bool focus);
|
void openMessageDialog(const QString &userName, bool focus);
|
||||||
void addBuddy(const QString &userName);
|
void addBuddy(const QString &userName);
|
||||||
|
|
|
@ -437,13 +437,17 @@ void WndDeckEditor::recursiveExpand(const QModelIndex &index)
|
||||||
deckView->expand(index);
|
deckView->expand(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WndDeckEditor::addCardHelper(const QString &zoneName)
|
void WndDeckEditor::addCardHelper(QString zoneName)
|
||||||
{
|
{
|
||||||
const QModelIndex currentIndex = databaseView->selectionModel()->currentIndex();
|
const QModelIndex currentIndex = databaseView->selectionModel()->currentIndex();
|
||||||
if (!currentIndex.isValid())
|
if (!currentIndex.isValid())
|
||||||
return;
|
return;
|
||||||
const QString cardName = currentIndex.sibling(currentIndex.row(), 0).data().toString();
|
const QString cardName = currentIndex.sibling(currentIndex.row(), 0).data().toString();
|
||||||
|
|
||||||
|
CardInfo *info = db->getCard(cardName);
|
||||||
|
if (info->getIsToken())
|
||||||
|
zoneName = "tokens";
|
||||||
|
|
||||||
QModelIndex newCardIndex = deckModel->addCard(cardName, zoneName);
|
QModelIndex newCardIndex = deckModel->addCard(cardName, zoneName);
|
||||||
recursiveExpand(newCardIndex);
|
recursiveExpand(newCardIndex);
|
||||||
deckView->setCurrentIndex(newCardIndex);
|
deckView->setCurrentIndex(newCardIndex);
|
||||||
|
|
|
@ -58,7 +58,7 @@ private slots:
|
||||||
|
|
||||||
void finishedUpdatingPrices();
|
void finishedUpdatingPrices();
|
||||||
private:
|
private:
|
||||||
void addCardHelper(const QString &zoneName);
|
void addCardHelper(QString zoneName);
|
||||||
void recursiveExpand(const QModelIndex &index);
|
void recursiveExpand(const QModelIndex &index);
|
||||||
bool confirmClose();
|
bool confirmClose();
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,7 @@ void MainWindow::actWatchReplay()
|
||||||
GameReplay *replay = new GameReplay;
|
GameReplay *replay = new GameReplay;
|
||||||
replay->ParseFromArray(buf.data(), buf.size());
|
replay->ParseFromArray(buf.data(), buf.size());
|
||||||
|
|
||||||
TabGame *replayWatcher = new TabGame(replay);
|
TabGame *replayWatcher = new TabGame(0, replay);
|
||||||
replayWatcher->show();
|
replayWatcher->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -98,6 +98,8 @@ QString InnerDecklistNode::visibleNameFromName(const QString &_name)
|
||||||
return QObject::tr("Maindeck");
|
return QObject::tr("Maindeck");
|
||||||
else if (_name == "side")
|
else if (_name == "side")
|
||||||
return QObject::tr("Sideboard");
|
return QObject::tr("Sideboard");
|
||||||
|
else if (_name == "tokens")
|
||||||
|
return QObject::tr("Tokens");
|
||||||
else
|
else
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,5 @@ message ServerInfo_Game {
|
||||||
optional uint32 spectators_count = 31;
|
optional uint32 spectators_count = 31;
|
||||||
optional bool started = 50;
|
optional bool started = 50;
|
||||||
optional uint32 start_time = 51;
|
optional uint32 start_time = 51;
|
||||||
|
optional bool closed = 52;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
message ServerInfo_User {
|
message ServerInfo_User {
|
||||||
enum UserLevelFlags {
|
enum UserLevelFlag {
|
||||||
IsNothing = 0;
|
IsNothing = 0;
|
||||||
IsUser = 1;
|
IsUser = 1;
|
||||||
IsRegistered = 2;
|
IsRegistered = 2;
|
||||||
IsModerator = 4;
|
IsModerator = 4;
|
||||||
IsAdmin = 8;
|
IsAdmin = 8;
|
||||||
|
|
|
@ -294,7 +294,9 @@ void Server_Game::doStartGameIfReady()
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
|
|
||||||
ServerInfo_Game gameInfo;
|
ServerInfo_Game gameInfo;
|
||||||
getInfo(gameInfo);
|
gameInfo.set_room_id(room->getId());
|
||||||
|
gameInfo.set_game_id(gameId);
|
||||||
|
gameInfo.set_started(true);
|
||||||
emit gameInfoChanged(gameInfo);
|
emit gameInfoChanged(gameInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,6 +329,14 @@ void Server_Game::stopGameIfFinished()
|
||||||
}
|
}
|
||||||
|
|
||||||
sendGameStateToPlayers();
|
sendGameStateToPlayers();
|
||||||
|
|
||||||
|
locker.unlock();
|
||||||
|
|
||||||
|
ServerInfo_Game gameInfo;
|
||||||
|
gameInfo.set_room_id(room->getId());
|
||||||
|
gameInfo.set_game_id(gameId);
|
||||||
|
gameInfo.set_started(false);
|
||||||
|
emit gameInfoChanged(gameInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
Response::ResponseCode Server_Game::checkJoin(ServerInfo_User *user, const QString &_password, bool spectator, bool overrideRestrictions)
|
Response::ResponseCode Server_Game::checkJoin(ServerInfo_User *user, const QString &_password, bool spectator, bool overrideRestrictions)
|
||||||
|
@ -377,7 +387,7 @@ void Server_Game::addPlayer(Server_AbstractUserInterface *userInterface, Respons
|
||||||
newPlayer->moveToThread(thread());
|
newPlayer->moveToThread(thread());
|
||||||
|
|
||||||
Event_Join joinEvent;
|
Event_Join joinEvent;
|
||||||
joinEvent.mutable_player_properties()->CopyFrom(newPlayer->getProperties(true));
|
newPlayer->getProperties(*joinEvent.mutable_player_properties(), true);
|
||||||
sendGameEventContainer(prepareGameEvent(joinEvent, -1));
|
sendGameEventContainer(prepareGameEvent(joinEvent, -1));
|
||||||
|
|
||||||
const QString playerName = QString::fromStdString(newPlayer->getUserInfo()->name());
|
const QString playerName = QString::fromStdString(newPlayer->getUserInfo()->name());
|
||||||
|
@ -393,7 +403,9 @@ void Server_Game::addPlayer(Server_AbstractUserInterface *userInterface, Respons
|
||||||
|
|
||||||
if (broadcastUpdate) {
|
if (broadcastUpdate) {
|
||||||
ServerInfo_Game gameInfo;
|
ServerInfo_Game gameInfo;
|
||||||
getInfo(gameInfo);
|
gameInfo.set_room_id(room->getId());
|
||||||
|
gameInfo.set_game_id(gameId);
|
||||||
|
gameInfo.set_player_count(getPlayerCount());
|
||||||
emit gameInfoChanged(gameInfo);
|
emit gameInfoChanged(gameInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,9 +433,10 @@ void Server_Game::removePlayer(Server_Player *player)
|
||||||
bool spectator = player->getSpectator();
|
bool spectator = player->getSpectator();
|
||||||
player->prepareDestroy();
|
player->prepareDestroy();
|
||||||
|
|
||||||
if (!getPlayerCount())
|
if (!getPlayerCount()) {
|
||||||
deleteLater();
|
deleteLater();
|
||||||
else if (!spectator) {
|
return;
|
||||||
|
} else if (!spectator) {
|
||||||
if (playerHost) {
|
if (playerHost) {
|
||||||
int newHostId = -1;
|
int newHostId = -1;
|
||||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||||
|
@ -445,7 +458,9 @@ void Server_Game::removePlayer(Server_Player *player)
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInfo_Game gameInfo;
|
ServerInfo_Game gameInfo;
|
||||||
getInfo(gameInfo);
|
gameInfo.set_room_id(room->getId());
|
||||||
|
gameInfo.set_game_id(gameId);
|
||||||
|
gameInfo.set_player_count(getPlayerCount());
|
||||||
emit gameInfoChanged(gameInfo);
|
emit gameInfoChanged(gameInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,8 +660,10 @@ void Server_Game::getInfo(ServerInfo_Game &result) const
|
||||||
QMutexLocker locker(&gameMutex);
|
QMutexLocker locker(&gameMutex);
|
||||||
|
|
||||||
result.set_room_id(room->getId());
|
result.set_room_id(room->getId());
|
||||||
result.set_game_id(getGameId());
|
result.set_game_id(gameId);
|
||||||
if (!players.isEmpty()) {
|
if (players.isEmpty())
|
||||||
|
result.set_closed(true);
|
||||||
|
else {
|
||||||
for (int i = 0; i < gameTypes.size(); ++i)
|
for (int i = 0; i < gameTypes.size(); ++i)
|
||||||
result.add_game_types(gameTypes[i]);
|
result.add_game_types(gameTypes[i]);
|
||||||
|
|
||||||
|
|
|
@ -240,9 +240,8 @@ void Server_Player::clearZones()
|
||||||
lastDrawList.clear();
|
lastDrawList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInfo_PlayerProperties Server_Player::getProperties(bool withUserInfo)
|
void Server_Player::getProperties(ServerInfo_PlayerProperties &result, bool withUserInfo)
|
||||||
{
|
{
|
||||||
ServerInfo_PlayerProperties result;
|
|
||||||
result.set_player_id(playerId);
|
result.set_player_id(playerId);
|
||||||
if (withUserInfo)
|
if (withUserInfo)
|
||||||
result.mutable_user_info()->CopyFrom(*userInfo);
|
result.mutable_user_info()->CopyFrom(*userInfo);
|
||||||
|
@ -253,8 +252,6 @@ ServerInfo_PlayerProperties Server_Player::getProperties(bool withUserInfo)
|
||||||
if (deck)
|
if (deck)
|
||||||
result.set_deck_hash(deck->getDeckHash().toStdString());
|
result.set_deck_hash(deck->getDeckHash().toStdString());
|
||||||
result.set_ping_seconds(pingTime);
|
result.set_ping_seconds(pingTime);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_Player::addZone(Server_CardZone *zone)
|
void Server_Player::addZone(Server_CardZone *zone)
|
||||||
|
@ -1674,7 +1671,7 @@ void Server_Player::disconnectClient()
|
||||||
|
|
||||||
void Server_Player::getInfo(ServerInfo_Player *info, Server_Player *playerWhosAsking, bool omniscient, bool withUserInfo)
|
void Server_Player::getInfo(ServerInfo_Player *info, Server_Player *playerWhosAsking, bool omniscient, bool withUserInfo)
|
||||||
{
|
{
|
||||||
info->mutable_properties()->CopyFrom(getProperties(withUserInfo));
|
getProperties(*info->mutable_properties(), withUserInfo);
|
||||||
if (playerWhosAsking == this)
|
if (playerWhosAsking == this)
|
||||||
if (deck)
|
if (deck)
|
||||||
info->set_deck_list(deck->writeToString_Native().toStdString());
|
info->set_deck_list(deck->writeToString_Native().toStdString());
|
||||||
|
|
|
@ -105,7 +105,7 @@ public:
|
||||||
|
|
||||||
int getPingTime() const { return pingTime; }
|
int getPingTime() const { return pingTime; }
|
||||||
void setPingTime(int _pingTime) { pingTime = _pingTime; }
|
void setPingTime(int _pingTime) { pingTime = _pingTime; }
|
||||||
ServerInfo_PlayerProperties getProperties(bool withUserInfo);
|
void getProperties(ServerInfo_PlayerProperties &result, bool withUserInfo);
|
||||||
|
|
||||||
int newCardId();
|
int newCardId();
|
||||||
int newCounterId() const;
|
int newCounterId() const;
|
||||||
|
|
|
@ -422,7 +422,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdGetGamesOfUser(const Command_G
|
||||||
while (roomIterator.hasNext()) {
|
while (roomIterator.hasNext()) {
|
||||||
Server_Room *room = roomIterator.next().value();
|
Server_Room *room = roomIterator.next().value();
|
||||||
room->gamesMutex.lock();
|
room->gamesMutex.lock();
|
||||||
re->add_room_list()->CopyFrom(room->getInfo(false, true));
|
room->getInfo(*re->add_room_list(), false, true);
|
||||||
QListIterator<ServerInfo_Game> gameIterator(room->getGamesOfUser(QString::fromStdString(cmd.user_name())));
|
QListIterator<ServerInfo_Game> gameIterator(room->getGamesOfUser(QString::fromStdString(cmd.user_name())));
|
||||||
while (gameIterator.hasNext())
|
while (gameIterator.hasNext())
|
||||||
re->add_game_list()->CopyFrom(gameIterator.next());
|
re->add_game_list()->CopyFrom(gameIterator.next());
|
||||||
|
@ -470,7 +470,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdListRooms(const Command_ListRo
|
||||||
Event_ListRooms event;
|
Event_ListRooms event;
|
||||||
QMapIterator<int, Server_Room *> roomIterator(server->getRooms());
|
QMapIterator<int, Server_Room *> roomIterator(server->getRooms());
|
||||||
while (roomIterator.hasNext())
|
while (roomIterator.hasNext())
|
||||||
event.add_room_list()->CopyFrom(roomIterator.next().value()->getInfo(false));
|
roomIterator.next().value()->getInfo(*event.add_room_list(), false);
|
||||||
rc.enqueuePreResponseItem(ServerMessage::SESSION_EVENT, prepareSessionEvent(event));
|
rc.enqueuePreResponseItem(ServerMessage::SESSION_EVENT, prepareSessionEvent(event));
|
||||||
|
|
||||||
acceptsRoomListChanges = true;
|
acceptsRoomListChanges = true;
|
||||||
|
@ -498,7 +498,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdJoinRoom(const Command_JoinRoo
|
||||||
rc.enqueuePostResponseItem(ServerMessage::ROOM_EVENT, r->prepareRoomEvent(joinMessageEvent));
|
rc.enqueuePostResponseItem(ServerMessage::ROOM_EVENT, r->prepareRoomEvent(joinMessageEvent));
|
||||||
|
|
||||||
Response_JoinRoom *re = new Response_JoinRoom;
|
Response_JoinRoom *re = new Response_JoinRoom;
|
||||||
re->mutable_room_info()->CopyFrom(r->getInfo(true));
|
r->getInfo(*re->mutable_room_info(), true);
|
||||||
|
|
||||||
rc.setResponseExtension(re);
|
rc.setResponseExtension(re);
|
||||||
return Response::RespOk;
|
return Response::RespOk;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "pb/event_leave_room.pb.h"
|
#include "pb/event_leave_room.pb.h"
|
||||||
#include "pb/event_list_games.pb.h"
|
#include "pb/event_list_games.pb.h"
|
||||||
#include "pb/event_room_say.pb.h"
|
#include "pb/event_room_say.pb.h"
|
||||||
|
#include "pb/serverinfo_room.pb.h"
|
||||||
#include <google/protobuf/descriptor.h>
|
#include <google/protobuf/descriptor.h>
|
||||||
|
|
||||||
Server_Room::Server_Room(int _id, const QString &_name, const QString &_description, bool _autoJoin, const QString &_joinMessage, const QStringList &_gameTypes, Server *parent)
|
Server_Room::Server_Room(int _id, const QString &_name, const QString &_description, bool _autoJoin, const QString &_joinMessage, const QStringList &_gameTypes, Server *parent)
|
||||||
|
@ -38,9 +39,8 @@ Server *Server_Room::getServer() const
|
||||||
return static_cast<Server *>(parent());
|
return static_cast<Server *>(parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInfo_Room Server_Room::getInfo(bool complete, bool showGameTypes, bool updating, bool includeExternalData) const
|
const ServerInfo_Room &Server_Room::getInfo(ServerInfo_Room &result, bool complete, bool showGameTypes, bool updating, bool includeExternalData) const
|
||||||
{
|
{
|
||||||
ServerInfo_Room result;
|
|
||||||
result.set_room_id(id);
|
result.set_room_id(id);
|
||||||
|
|
||||||
if (!updating) {
|
if (!updating) {
|
||||||
|
@ -104,7 +104,8 @@ void Server_Room::addClient(Server_ProtocolHandler *client)
|
||||||
userList.append(client);
|
userList.append(client);
|
||||||
usersLock.unlock();
|
usersLock.unlock();
|
||||||
|
|
||||||
emit roomInfoChanged(getInfo(false, false, true));
|
ServerInfo_Room roomInfo;
|
||||||
|
emit roomInfoChanged(getInfo(roomInfo, false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_Room::removeClient(Server_ProtocolHandler *client)
|
void Server_Room::removeClient(Server_ProtocolHandler *client)
|
||||||
|
@ -117,7 +118,8 @@ void Server_Room::removeClient(Server_ProtocolHandler *client)
|
||||||
event.set_name(client->getUserInfo()->name());
|
event.set_name(client->getUserInfo()->name());
|
||||||
sendRoomEvent(prepareRoomEvent(event));
|
sendRoomEvent(prepareRoomEvent(event));
|
||||||
|
|
||||||
emit roomInfoChanged(getInfo(false, false, true));
|
ServerInfo_Room roomInfo;
|
||||||
|
emit roomInfoChanged(getInfo(roomInfo, false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_Room::addExternalUser(const ServerInfo_User &userInfo)
|
void Server_Room::addExternalUser(const ServerInfo_User &userInfo)
|
||||||
|
@ -132,7 +134,8 @@ void Server_Room::addExternalUser(const ServerInfo_User &userInfo)
|
||||||
externalUsers.insert(QString::fromStdString(userInfo.name()), userInfoContainer);
|
externalUsers.insert(QString::fromStdString(userInfo.name()), userInfoContainer);
|
||||||
usersLock.unlock();
|
usersLock.unlock();
|
||||||
|
|
||||||
emit roomInfoChanged(getInfo(false, false, true));
|
ServerInfo_Room roomInfo;
|
||||||
|
emit roomInfoChanged(getInfo(roomInfo, false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_Room::removeExternalUser(const QString &name)
|
void Server_Room::removeExternalUser(const QString &name)
|
||||||
|
@ -147,7 +150,8 @@ void Server_Room::removeExternalUser(const QString &name)
|
||||||
event.set_name(name.toStdString());
|
event.set_name(name.toStdString());
|
||||||
sendRoomEvent(prepareRoomEvent(event), false);
|
sendRoomEvent(prepareRoomEvent(event), false);
|
||||||
|
|
||||||
emit roomInfoChanged(getInfo(false, false, true));
|
ServerInfo_Room roomInfo;
|
||||||
|
emit roomInfoChanged(getInfo(roomInfo, false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_Room::updateExternalGameList(const ServerInfo_Game &gameInfo)
|
void Server_Room::updateExternalGameList(const ServerInfo_Game &gameInfo)
|
||||||
|
@ -161,7 +165,8 @@ void Server_Room::updateExternalGameList(const ServerInfo_Game &gameInfo)
|
||||||
gamesMutex.unlock();
|
gamesMutex.unlock();
|
||||||
|
|
||||||
broadcastGameListUpdate(gameInfo, false);
|
broadcastGameListUpdate(gameInfo, false);
|
||||||
emit roomInfoChanged(getInfo(false, false, true));
|
ServerInfo_Room roomInfo;
|
||||||
|
emit roomInfoChanged(getInfo(roomInfo, false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
Response::ResponseCode Server_Room::processJoinGameCommand(const Command_JoinGame &cmd, ResponseContainer &rc, Server_AbstractUserInterface *userInterface)
|
Response::ResponseCode Server_Room::processJoinGameCommand(const Command_JoinGame &cmd, ResponseContainer &rc, Server_AbstractUserInterface *userInterface)
|
||||||
|
@ -215,7 +220,7 @@ void Server_Room::sendRoomEvent(RoomEvent *event, bool sendToIsl)
|
||||||
delete event;
|
delete event;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_Room::broadcastGameListUpdate(ServerInfo_Game gameInfo, bool sendToIsl)
|
void Server_Room::broadcastGameListUpdate(const ServerInfo_Game &gameInfo, bool sendToIsl)
|
||||||
{
|
{
|
||||||
Event_ListGames event;
|
Event_ListGames event;
|
||||||
event.add_game_list()->CopyFrom(gameInfo);
|
event.add_game_list()->CopyFrom(gameInfo);
|
||||||
|
@ -236,7 +241,8 @@ void Server_Room::addGame(Server_Game *game)
|
||||||
game->gameMutex.unlock();
|
game->gameMutex.unlock();
|
||||||
|
|
||||||
emit gameListChanged(gameInfo);
|
emit gameListChanged(gameInfo);
|
||||||
emit roomInfoChanged(getInfo(false, false, true));
|
ServerInfo_Room roomInfo;
|
||||||
|
emit roomInfoChanged(getInfo(roomInfo, false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_Room::removeGame(Server_Game *game)
|
void Server_Room::removeGame(Server_Game *game)
|
||||||
|
@ -252,7 +258,8 @@ void Server_Room::removeGame(Server_Game *game)
|
||||||
|
|
||||||
games.remove(game->getGameId());
|
games.remove(game->getGameId());
|
||||||
|
|
||||||
emit roomInfoChanged(getInfo(false, false, true));
|
ServerInfo_Room roomInfo;
|
||||||
|
emit roomInfoChanged(getInfo(roomInfo, false, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Server_Room::getGamesCreatedByUser(const QString &userName) const
|
int Server_Room::getGamesCreatedByUser(const QString &userName) const
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QReadWriteLock>
|
#include <QReadWriteLock>
|
||||||
#include "serverinfo_user_container.h"
|
#include "serverinfo_user_container.h"
|
||||||
#include "pb/serverinfo_room.pb.h"
|
|
||||||
#include "pb/response.pb.h"
|
#include "pb/response.pb.h"
|
||||||
|
|
||||||
class Server_ProtocolHandler;
|
class Server_ProtocolHandler;
|
||||||
|
@ -26,8 +25,8 @@ class Server_AbstractUserInterface;
|
||||||
class Server_Room : public QObject {
|
class Server_Room : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
signals:
|
signals:
|
||||||
void roomInfoChanged(ServerInfo_Room roomInfo);
|
void roomInfoChanged(const ServerInfo_Room &roomInfo);
|
||||||
void gameListChanged(ServerInfo_Game gameInfo);
|
void gameListChanged(const ServerInfo_Game &gameInfo);
|
||||||
private:
|
private:
|
||||||
int id;
|
int id;
|
||||||
QString name;
|
QString name;
|
||||||
|
@ -40,7 +39,7 @@ private:
|
||||||
QList<Server_ProtocolHandler *> userList;
|
QList<Server_ProtocolHandler *> userList;
|
||||||
QMap<QString, ServerInfo_User_Container> externalUsers;
|
QMap<QString, ServerInfo_User_Container> externalUsers;
|
||||||
private slots:
|
private slots:
|
||||||
void broadcastGameListUpdate(ServerInfo_Game gameInfo, bool sendToIsl = true);
|
void broadcastGameListUpdate(const ServerInfo_Game &gameInfo, bool sendToIsl = true);
|
||||||
public:
|
public:
|
||||||
mutable QReadWriteLock usersLock;
|
mutable QReadWriteLock usersLock;
|
||||||
mutable QMutex gamesMutex;
|
mutable QMutex gamesMutex;
|
||||||
|
@ -55,7 +54,7 @@ public:
|
||||||
const QMap<int, Server_Game *> &getGames() const { return games; }
|
const QMap<int, Server_Game *> &getGames() const { return games; }
|
||||||
const QMap<int, ServerInfo_Game> &getExternalGames() const { return externalGames; }
|
const QMap<int, ServerInfo_Game> &getExternalGames() const { return externalGames; }
|
||||||
Server *getServer() const;
|
Server *getServer() const;
|
||||||
ServerInfo_Room getInfo(bool complete, bool showGameTypes = false, bool updating = false, bool includeExternalData = true) const;
|
const ServerInfo_Room &getInfo(ServerInfo_Room &result, bool complete, bool showGameTypes = false, bool updating = false, bool includeExternalData = true) const;
|
||||||
int getGamesCreatedByUser(const QString &name) const;
|
int getGamesCreatedByUser(const QString &name) const;
|
||||||
QList<ServerInfo_Game> getGamesOfUser(const QString &name) const;
|
QList<ServerInfo_Game> getGamesOfUser(const QString &name) const;
|
||||||
|
|
||||||
|
|
10
common/user_level.h
Normal file
10
common/user_level.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef USER_LEVEL_H
|
||||||
|
#define USER_LEVEL_H
|
||||||
|
|
||||||
|
#include "pb/serverinfo_user.pb.h"
|
||||||
|
#include <QFlags>
|
||||||
|
|
||||||
|
Q_DECLARE_FLAGS(UserLevelFlags, ServerInfo_User::UserLevelFlag)
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(UserLevelFlags)
|
||||||
|
|
||||||
|
#endif
|
|
@ -75,6 +75,7 @@ bool OracleImporter::readSetsFromXml(QXmlStreamReader &xml)
|
||||||
|
|
||||||
CardInfo *OracleImporter::addCard(const QString &setName,
|
CardInfo *OracleImporter::addCard(const QString &setName,
|
||||||
QString cardName,
|
QString cardName,
|
||||||
|
bool isToken,
|
||||||
int cardId,
|
int cardId,
|
||||||
const QString &cardCost,
|
const QString &cardCost,
|
||||||
const QString &cardType,
|
const QString &cardType,
|
||||||
|
@ -125,7 +126,7 @@ CardInfo *OracleImporter::addCard(const QString &setName,
|
||||||
|
|
||||||
bool cipt = (cardText.contains(cardName + " enters the battlefield tapped."));
|
bool cipt = (cardText.contains(cardName + " enters the battlefield tapped."));
|
||||||
|
|
||||||
card = new CardInfo(this, cardName, cardCost, cardType, cardPT, fullCardText, colors, cardLoyalty, cipt);
|
card = new CardInfo(this, cardName, isToken, cardCost, cardType, cardPT, fullCardText, colors, cardLoyalty, cipt);
|
||||||
int tableRow = 1;
|
int tableRow = 1;
|
||||||
QString mainCardType = card->getMainCardType();
|
QString mainCardType = card->getMainCardType();
|
||||||
if ((mainCardType == "Land") || mArtifact)
|
if ((mainCardType == "Land") || mArtifact)
|
||||||
|
@ -183,7 +184,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QByteArray &data)
|
||||||
for (int i = 0; i < cardTextSplit.size(); ++i)
|
for (int i = 0; i < cardTextSplit.size(); ++i)
|
||||||
cardTextSplit[i] = cardTextSplit[i].trimmed();
|
cardTextSplit[i] = cardTextSplit[i].trimmed();
|
||||||
|
|
||||||
CardInfo *card = addCard(set->getShortName(), cardName, cardId, cardCost, cardType, cardPT, cardLoyalty, cardTextSplit);
|
CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, cardCost, cardType, cardPT, cardLoyalty, cardTextSplit);
|
||||||
if (!set->contains(card)) {
|
if (!set->contains(card)) {
|
||||||
card->addToSet(set);
|
card->addToSet(set);
|
||||||
cards++;
|
cards++;
|
||||||
|
|
|
@ -35,7 +35,7 @@ private:
|
||||||
|
|
||||||
void downloadNextFile();
|
void downloadNextFile();
|
||||||
bool readSetsFromXml(QXmlStreamReader &xml);
|
bool readSetsFromXml(QXmlStreamReader &xml);
|
||||||
CardInfo *addCard(const QString &setName, QString cardName, int cardId, const QString &cardCost, const QString &cardType, const QString &cardPT, int cardLoyalty, const QStringList &cardText);
|
CardInfo *addCard(const QString &setName, QString cardName, bool isToken, int cardId, const QString &cardCost, const QString &cardType, const QString &cardPT, int cardLoyalty, const QStringList &cardText);
|
||||||
private slots:
|
private slots:
|
||||||
void httpRequestFinished(int requestId, bool error);
|
void httpRequestFinished(int requestId, bool error);
|
||||||
void readResponseHeader(const QHttpResponseHeader &responseHeader);
|
void readResponseHeader(const QHttpResponseHeader &responseHeader);
|
||||||
|
|
|
@ -129,7 +129,7 @@ void IslInterface::initServer()
|
||||||
Server_Room *room = roomIterator.next().value();
|
Server_Room *room = roomIterator.next().value();
|
||||||
room->usersLock.lockForRead();
|
room->usersLock.lockForRead();
|
||||||
room->gamesMutex.lock();
|
room->gamesMutex.lock();
|
||||||
event.add_room_list()->CopyFrom(room->getInfo(true, true, false, false));
|
room->getInfo(*event.add_room_list(), true, true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
IslMessage message;
|
IslMessage message;
|
||||||
|
|
|
@ -80,11 +80,11 @@ Servatrice::Servatrice(QSettings *_settings, QObject *parent)
|
||||||
else
|
else
|
||||||
databaseType = DatabaseNone;
|
databaseType = DatabaseNone;
|
||||||
dbPrefix = settings->value("database/prefix").toString();
|
dbPrefix = settings->value("database/prefix").toString();
|
||||||
if (databaseType != DatabaseNone)
|
if (databaseType != DatabaseNone) {
|
||||||
openDatabase();
|
openDatabase();
|
||||||
|
updateServerList();
|
||||||
updateServerList();
|
clearSessionTables();
|
||||||
clearSessionTables();
|
}
|
||||||
|
|
||||||
const QString roomMethod = settings->value("rooms/method").toString();
|
const QString roomMethod = settings->value("rooms/method").toString();
|
||||||
if (roomMethod == "sql") {
|
if (roomMethod == "sql") {
|
||||||
|
|
Loading…
Reference in a new issue