mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 10:33:54 -07:00
fixed game list update bug, minor optimizations, restrict client protocol output to QT_DEBUG mode
This commit is contained in:
parent
118b575e58
commit
ae19d3dc4b
13 changed files with 75 additions and 50 deletions
|
|
@ -25,7 +25,6 @@ AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, int _id
|
|||
|
||||
AbstractCardItem::~AbstractCardItem()
|
||||
{
|
||||
qDebug() << "AbstractCardItem destructor:" << name;
|
||||
emit deleteCardInfoPopup(name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ void DlgCreateGame::sharedCtor()
|
|||
|
||||
onlyBuddiesCheckBox = new QCheckBox(tr("Only &buddies 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;
|
||||
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"));
|
||||
maxPlayersGroupBox->setLayout(maxPlayersFilterLayout);
|
||||
|
||||
QGridLayout *leftColumn = new QGridLayout;
|
||||
leftColumn->addWidget(gameNameFilterLabel, 0, 0);
|
||||
leftColumn->addWidget(gameNameFilterEdit, 0, 1);
|
||||
leftColumn->addWidget(creatorNameFilterLabel, 1, 0);
|
||||
leftColumn->addWidget(creatorNameFilterEdit, 1, 1);
|
||||
leftColumn->addWidget(maxPlayersGroupBox, 2, 0, 1, 2);
|
||||
QGridLayout *leftGrid = new QGridLayout;
|
||||
leftGrid->addWidget(gameNameFilterLabel, 0, 0);
|
||||
leftGrid->addWidget(gameNameFilterEdit, 0, 1);
|
||||
leftGrid->addWidget(creatorNameFilterLabel, 1, 0);
|
||||
leftGrid->addWidget(creatorNameFilterEdit, 1, 1);
|
||||
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;
|
||||
rightColumn->addWidget(gameTypeFilterGroupBox);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
if (!index.isValid())
|
||||
|
|
@ -81,12 +72,12 @@ void GamesModel::updateGameList(const ServerInfo_Game &game)
|
|||
{
|
||||
for (int i = 0; i < gameList.size(); i++)
|
||||
if (gameList[i].game_id() == game.game_id()) {
|
||||
if (!game.has_player_count()) {
|
||||
if (game.closed()) {
|
||||
beginRemoveRows(QModelIndex(), i, i);
|
||||
gameList.removeAt(i);
|
||||
endRemoveRows();
|
||||
} else {
|
||||
gameList[i] = game;
|
||||
gameList[i].MergeFrom(game);
|
||||
emit dataChanged(index(i, 0), index(i, 7));
|
||||
}
|
||||
return;
|
||||
|
|
@ -107,9 +98,10 @@ GamesProxyModel::GamesProxyModel(QObject *parent, ServerInfo_User *_ownUser)
|
|||
{
|
||||
setDynamicSortFilter(true);
|
||||
}
|
||||
|
||||
#include <QDebug>
|
||||
void GamesProxyModel::setUnavailableGamesVisible(bool _unavailableGamesVisible)
|
||||
{
|
||||
qDebug() << "setting to" << _unavailableGamesVisible;
|
||||
unavailableGamesVisible = _unavailableGamesVisible;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#include <QList>
|
||||
#include <QSet>
|
||||
#include "gametypemap.h"
|
||||
#include "pb/serverinfo_game.pb.h"
|
||||
|
||||
class ServerInfo_Game;
|
||||
class ServerInfo_User;
|
||||
|
||||
class GamesModel : public QAbstractTableModel {
|
||||
|
|
@ -18,7 +18,6 @@ private:
|
|||
QMap<int, GameTypeMap> gameTypes;
|
||||
public:
|
||||
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 columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const { return 8; }
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
|
|
|
|||
|
|
@ -118,7 +118,9 @@ void RemoteClient::readData()
|
|||
|
||||
ServerMessage newServerMessage;
|
||||
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);
|
||||
messageInProgress = false;
|
||||
|
||||
|
|
@ -133,7 +135,9 @@ void RemoteClient::sendCommandContainer(const CommandContainer &cont)
|
|||
{
|
||||
QByteArray buf;
|
||||
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);
|
||||
cont.SerializeToArray(buf.data() + 4, size);
|
||||
buf.data()[3] = (unsigned char) size;
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public:
|
|||
const QMap<int, QString> &getGameTypes() const { return gameTypes; }
|
||||
QString getChannelName() const { return roomName; }
|
||||
QString getTabText() const { return roomName; }
|
||||
const ServerInfo_User *getUserInfo() const { return ownUser; }
|
||||
|
||||
PendingCommand *prepareRoomCommand(const ::google::protobuf::Message &cmd);
|
||||
void sendRoomCommand(PendingCommand *pend);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue