moderators can override game restrictions and kick players when spectating; game host privileges shift when host leaves

This commit is contained in:
Max-Wilhelm Bruker 2011-11-13 13:13:41 +01:00
parent bca7b6414b
commit c7ef61f750
22 changed files with 165 additions and 90 deletions

View file

@ -6,6 +6,7 @@
#include <QMessageBox>
#include <QFileDialog>
#include "tab_game.h"
#include "tab_supervisor.h"
#include "cardinfowidget.h"
#include "playerlistwidget.h"
#include "messagelogwidget.h"
@ -158,8 +159,8 @@ void DeckViewContainer::setDeck(DeckList *deck)
readyStartButton->setEnabled(true);
}
TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, int _gameId, const QString &_gameDescription, int _localPlayerId, ServerInfo_User *_userInfo, bool _spectator, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, bool _resuming)
: Tab(_tabSupervisor), clients(_clients), gameId(_gameId), gameDescription(_gameDescription), localPlayerId(_localPlayerId), spectator(_spectator), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), gameStateKnown(false), started(false), resuming(_resuming), currentPhase(-1)
TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, int _gameId, const QString &_gameDescription, int _hostId, int _localPlayerId, bool _spectator, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, bool _resuming)
: Tab(_tabSupervisor), clients(_clients), gameId(_gameId), gameDescription(_gameDescription), hostId(_hostId), localPlayerId(_localPlayerId), spectator(_spectator), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), gameStateKnown(false), started(false), resuming(_resuming), currentPhase(-1)
{
phasesToolbar = new PhasesToolbar;
phasesToolbar->hide();
@ -170,13 +171,13 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
gameView->hide();
cardInfo = new CardInfoWidget(CardInfoWidget::ModeGameTab);
playerListWidget = new PlayerListWidget(tabSupervisor, clients.first(), this, true);
playerListWidget = new PlayerListWidget(tabSupervisor, clients.first(), this);
playerListWidget->setFocusPolicy(Qt::NoFocus);
connect(playerListWidget, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
timeElapsedLabel = new QLabel;
timeElapsedLabel->setAlignment(Qt::AlignCenter);
messageLog = new MessageLogWidget(_userInfo->getName(), _userInfo->getGender() == ServerInfo_User::Female);
messageLog = new MessageLogWidget(tabSupervisor->getUserInfo()->getName(), tabSupervisor->getUserInfo()->getGender() == ServerInfo_User::Female);
connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString)));
connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
@ -208,11 +209,11 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
mainLayout->addLayout(deckViewContainerLayout, 10);
mainLayout->addWidget(splitter);
if (spectator && !spectatorsCanTalk) {
if (spectator && !spectatorsCanTalk && tabSupervisor->getAdminLocked()) {
sayLabel->hide();
sayEdit->hide();
}
connect(tabSupervisor, SIGNAL(adminLockChanged(bool)), this, SLOT(adminLockChanged(bool)));
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(actSay()));
// Menu actions
@ -314,6 +315,13 @@ void TabGame::closeRequest()
actLeaveGame();
}
void TabGame::adminLockChanged(bool lock)
{
bool v = !(spectator && !spectatorsCanTalk && lock);
sayLabel->setVisible(v);
sayEdit->setVisible(v);
}
void TabGame::actConcede()
{
if (QMessageBox::question(this, tr("Concede"), tr("Are you sure you want to concede this game?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
@ -433,6 +441,7 @@ void TabGame::processGameEventContainer(GameEventContainer *cont, AbstractClient
case ItemId_Event_Join: eventJoin(static_cast<Event_Join *>(event), context); break;
case ItemId_Event_Leave: eventLeave(static_cast<Event_Leave *>(event), context); break;
case ItemId_Event_Kicked: eventKicked(static_cast<Event_Kicked *>(event), context); break;
case ItemId_Event_GameHostChanged: eventGameHostChanged(static_cast<Event_GameHostChanged *>(event), context); break;
case ItemId_Event_GameClosed: eventGameClosed(static_cast<Event_GameClosed *>(event), context); break;
case ItemId_Event_SetActivePlayer: eventSetActivePlayer(static_cast<Event_SetActivePlayer *>(event), context); break;
case ItemId_Event_SetActivePhase: eventSetActivePhase(static_cast<Event_SetActivePhase *>(event), context); break;
@ -672,6 +681,11 @@ void TabGame::eventKicked(Event_Kicked * /*event*/, GameEventContext * /*context
deleteLater();
}
void TabGame::eventGameHostChanged(Event_GameHostChanged *event, GameEventContext * /*context*/)
{
hostId = event->getPlayerId();
}
void TabGame::eventGameClosed(Event_GameClosed * /*event*/, GameEventContext * /*context*/)
{
started = false;