mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-04 04:23:55 -07:00
initial commit: buddy list, ignore list
This commit is contained in:
parent
5e99950e1f
commit
acac5addd6
24 changed files with 197 additions and 62 deletions
|
|
@ -47,6 +47,8 @@ signals:
|
|||
void gameJoinedEventReceived(Event_GameJoined *event);
|
||||
void messageEventReceived(Event_Message *event);
|
||||
void userInfoChanged(ServerInfo_User *userInfo);
|
||||
void buddyListReceived(const QList<ServerInfo_User *> &buddyList);
|
||||
void ignoreListReceived(const QList<ServerInfo_User *> &ignoreList);
|
||||
protected slots:
|
||||
void processProtocolItem(ProtocolItem *item);
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -18,10 +18,6 @@ DlgCreateGame::DlgCreateGame(AbstractClient *_client, int _roomId, const QMap<in
|
|||
descriptionEdit = new QLineEdit;
|
||||
descriptionLabel->setBuddy(descriptionEdit);
|
||||
|
||||
passwordLabel = new QLabel(tr("&Password:"));
|
||||
passwordEdit = new QLineEdit;
|
||||
passwordLabel->setBuddy(passwordEdit);
|
||||
|
||||
maxPlayersLabel = new QLabel(tr("P&layers:"));
|
||||
maxPlayersEdit = new QSpinBox();
|
||||
maxPlayersEdit->setMinimum(1);
|
||||
|
|
@ -40,6 +36,22 @@ DlgCreateGame::DlgCreateGame(AbstractClient *_client, int _roomId, const QMap<in
|
|||
QGroupBox *gameTypeGroupBox = new QGroupBox(tr("Game type"));
|
||||
gameTypeGroupBox->setLayout(gameTypeLayout);
|
||||
|
||||
passwordLabel = new QLabel(tr("&Password:"));
|
||||
passwordEdit = new QLineEdit;
|
||||
passwordLabel->setBuddy(passwordEdit);
|
||||
|
||||
onlyBuddiesCheckBox = new QCheckBox(tr("Only &buddies can join"));
|
||||
onlyRegisteredCheckBox = new QCheckBox(tr("Only ®istered users can join"));
|
||||
|
||||
QGridLayout *joinRestrictionsLayout = new QGridLayout;
|
||||
joinRestrictionsLayout->addWidget(passwordLabel, 0, 0);
|
||||
joinRestrictionsLayout->addWidget(passwordEdit, 0, 1);
|
||||
joinRestrictionsLayout->addWidget(onlyBuddiesCheckBox, 1, 0, 1, 2);
|
||||
joinRestrictionsLayout->addWidget(onlyRegisteredCheckBox, 2, 0, 1, 2);
|
||||
|
||||
QGroupBox *joinRestrictionsGroupBox = new QGroupBox(tr("Joining restrictions"));
|
||||
joinRestrictionsGroupBox->setLayout(joinRestrictionsLayout);
|
||||
|
||||
spectatorsAllowedCheckBox = new QCheckBox(tr("&Spectators allowed"));
|
||||
spectatorsAllowedCheckBox->setChecked(true);
|
||||
connect(spectatorsAllowedCheckBox, SIGNAL(stateChanged(int)), this, SLOT(spectatorsAllowedChanged(int)));
|
||||
|
|
@ -57,11 +69,10 @@ DlgCreateGame::DlgCreateGame(AbstractClient *_client, int _roomId, const QMap<in
|
|||
QGridLayout *grid = new QGridLayout;
|
||||
grid->addWidget(descriptionLabel, 0, 0);
|
||||
grid->addWidget(descriptionEdit, 0, 1);
|
||||
grid->addWidget(passwordLabel, 1, 0);
|
||||
grid->addWidget(passwordEdit, 1, 1);
|
||||
grid->addWidget(maxPlayersLabel, 2, 0);
|
||||
grid->addWidget(maxPlayersEdit, 2, 1);
|
||||
grid->addWidget(gameTypeGroupBox, 3, 0, 1, 2);
|
||||
grid->addWidget(maxPlayersLabel, 1, 0);
|
||||
grid->addWidget(maxPlayersEdit, 1, 1);
|
||||
grid->addWidget(gameTypeGroupBox, 2, 0, 1, 2);
|
||||
grid->addWidget(joinRestrictionsGroupBox, 3, 0, 1, 2);
|
||||
grid->addWidget(spectatorsGroupBox, 4, 0, 1, 2);
|
||||
|
||||
okButton = new QPushButton(tr("&OK"));
|
||||
|
|
@ -102,6 +113,8 @@ void DlgCreateGame::actOK()
|
|||
passwordEdit->text(),
|
||||
maxPlayersEdit->value(),
|
||||
gameTypeList,
|
||||
onlyBuddiesCheckBox->isChecked(),
|
||||
onlyRegisteredCheckBox->isChecked(),
|
||||
spectatorsAllowedCheckBox->isChecked(),
|
||||
spectatorsNeedPasswordCheckBox->isChecked(),
|
||||
spectatorsCanTalkCheckBox->isChecked(),
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ private:
|
|||
QLabel *descriptionLabel, *passwordLabel, *maxPlayersLabel;
|
||||
QLineEdit *descriptionEdit, *passwordEdit;
|
||||
QSpinBox *maxPlayersEdit;
|
||||
QCheckBox *onlyBuddiesCheckBox, *onlyRegisteredCheckBox;
|
||||
QCheckBox *spectatorsAllowedCheckBox, *spectatorsNeedPasswordCheckBox, *spectatorsCanTalkCheckBox, *spectatorsSeeEverythingCheckBox;
|
||||
QPushButton *okButton, *cancelButton;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,8 +40,16 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
|
|||
return result.join(", ");
|
||||
}
|
||||
case 3: return g->getHasPassword() ? (g->getSpectatorsNeedPassword() ? tr("yes") : tr("yes, free for spectators")) : tr("no");
|
||||
case 4: return QString("%1/%2").arg(g->getPlayerCount()).arg(g->getMaxPlayers());
|
||||
case 5: return g->getSpectatorsAllowed() ? QVariant(g->getSpectatorCount()) : QVariant(tr("not allowed"));
|
||||
case 4: {
|
||||
QStringList result;
|
||||
if (g->getOnlyBuddies())
|
||||
result.append(tr("buddies only"));
|
||||
if (g->getOnlyRegistered())
|
||||
result.append(tr("reg. users only"));
|
||||
return result.join(", ");
|
||||
}
|
||||
case 5: return QString("%1/%2").arg(g->getPlayerCount()).arg(g->getMaxPlayers());
|
||||
case 6: return g->getSpectatorsAllowed() ? QVariant(g->getSpectatorCount()) : QVariant(tr("not allowed"));
|
||||
default: return QVariant();
|
||||
}
|
||||
}
|
||||
|
|
@ -55,8 +63,9 @@ QVariant GamesModel::headerData(int section, Qt::Orientation orientation, int ro
|
|||
case 1: return tr("Creator");
|
||||
case 2: return tr("Game type");
|
||||
case 3: return tr("Password");
|
||||
case 4: return tr("Players");
|
||||
case 5: return tr("Spectators");
|
||||
case 4: return tr("Restrictions");
|
||||
case 5: return tr("Players");
|
||||
case 6: return tr("Spectators");
|
||||
default: return QVariant();
|
||||
}
|
||||
}
|
||||
|
|
@ -73,7 +82,7 @@ void GamesModel::updateGameList(ServerInfo_Game *_game)
|
|||
for (int i = 0; i < oldGameTypeList.size(); ++i)
|
||||
gameTypeList.append(new GameTypeId(oldGameTypeList[i]->getData()));
|
||||
|
||||
ServerInfo_Game *game = new ServerInfo_Game(_game->getGameId(), _game->getDescription(), _game->getHasPassword(), _game->getPlayerCount(), _game->getMaxPlayers(), gameTypeList, new ServerInfo_User(_game->getCreatorInfo()), _game->getSpectatorsAllowed(), _game->getSpectatorsNeedPassword(), _game->getSpectatorCount());
|
||||
ServerInfo_Game *game = new ServerInfo_Game(_game->getGameId(), _game->getDescription(), _game->getHasPassword(), _game->getPlayerCount(), _game->getMaxPlayers(), gameTypeList, new ServerInfo_User(_game->getCreatorInfo()), _game->getOnlyBuddies(), _game->getOnlyRegistered(), _game->getSpectatorsAllowed(), _game->getSpectatorsNeedPassword(), _game->getSpectatorCount());
|
||||
for (int i = 0; i < gameList.size(); i++)
|
||||
if (gameList[i]->getGameId() == game->getGameId()) {
|
||||
if (game->getPlayerCount() == 0) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public:
|
|||
GamesModel(const QMap<int, QString> &_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 5; }
|
||||
int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const { return 7; }
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ public:
|
|||
LocalServerInterface *newConnection();
|
||||
protected:
|
||||
ServerInfo_User *getUserData(const QString &name);
|
||||
QList<ServerInfo_User *> getBuddyList(const QString & /*name*/) { return QList<ServerInfo_User *>(); }
|
||||
QList<ServerInfo_User *> getIgnoreList(const QString & /*name*/) { return QList<ServerInfo_User *>(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -51,6 +51,8 @@ void RemoteClient::loginResponse(ProtocolResponse *response)
|
|||
}
|
||||
setStatus(StatusLoggedIn);
|
||||
emit userInfoChanged(resp->getUserInfo());
|
||||
emit buddyListReceived(resp->getBuddyList());
|
||||
emit ignoreListReceived(resp->getIgnoreList());
|
||||
} else {
|
||||
emit serverError(response->getResponseCode());
|
||||
setStatus(StatusDisconnecting);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ GameSelector::GameSelector(AbstractClient *_client, TabRoom *_room, QWidget *par
|
|||
retranslateUi();
|
||||
setLayout(mainLayout);
|
||||
|
||||
setMinimumWidth(gameListView->columnWidth(0) * gameListModel->columnCount());
|
||||
setMinimumWidth((qreal) (gameListView->columnWidth(0) * gameListModel->columnCount()) / 1.5);
|
||||
setMinimumHeight(400);
|
||||
|
||||
connect(showFullGamesCheckBox, SIGNAL(stateChanged(int)), this, SLOT(showFullGamesChanged(int)));
|
||||
|
|
@ -77,6 +77,8 @@ void GameSelector::checkResponse(ResponseCode response)
|
|||
case RespSpectatorsNotAllowed: QMessageBox::critical(this, tr("Error"), tr("Spectators are not allowed in this game.")); break;
|
||||
case RespGameFull: QMessageBox::critical(this, tr("Error"), tr("The game is already full.")); break;
|
||||
case RespNameNotFound: QMessageBox::critical(this, tr("Error"), tr("The game does not exist any more.")); break;
|
||||
case RespUserLevelTooLow: QMessageBox::critical(this, tr("Error"), tr("This game is only open to registered users.")); break;
|
||||
case RespOnlyBuddies: QMessageBox::critical(this, tr("Error"), tr("This game is only open to its creator's buddies.")); break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
#include "protocol_items.h"
|
||||
#include "userlist.h"
|
||||
#include "userinfobox.h"
|
||||
//#include "pixmapgenerator.h"
|
||||
#include <QDebug>
|
||||
|
||||
RoomSelector::RoomSelector(AbstractClient *_client, QWidget *parent)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue