Fixed elevation of spectator rights; added some spectator options; closes bug 0000005

This commit is contained in:
Max-Wilhelm Bruker 2010-05-26 21:36:54 +02:00
parent 604d1ffa94
commit befafa28ae
26 changed files with 430 additions and 220 deletions

View file

@ -19,8 +19,8 @@
#include "arrowitem.h"
#include "main.h"
TabGame::TabGame(Client *_client, int _gameId, const QString &_gameDescription, int _localPlayerId, bool _spectator, bool _resuming)
: Tab(), client(_client), gameId(_gameId), gameDescription(_gameDescription), localPlayerId(_localPlayerId), spectator(_spectator), started(false), resuming(_resuming), currentPhase(-1)
TabGame::TabGame(Client *_client, int _gameId, const QString &_gameDescription, int _localPlayerId, bool _spectator, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, bool _resuming)
: Tab(), client(_client), gameId(_gameId), gameDescription(_gameDescription), localPlayerId(_localPlayerId), spectator(_spectator), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), started(false), resuming(_resuming), currentPhase(-1)
{
scene = new GameScene(this);
gameView = new GameView(scene);
@ -74,8 +74,10 @@ TabGame::TabGame(Client *_client, int _gameId, const QString &_gameDescription,
mainLayout->addLayout(verticalLayout);
if (spectator) {
sayLabel->hide();
sayEdit->hide();
if (!spectatorsCanTalk) {
sayLabel->hide();
sayEdit->hide();
}
loadLocalButton->hide();
loadRemoteButton->hide();
readyStartButton->hide();
@ -226,7 +228,15 @@ void TabGame::processGameEventContainer(GameEventContainer *cont)
for (int i = 0; i < eventList.size(); ++i) {
GameEvent *event = eventList[i];
switch (event->getItemId()) {
if (spectators.contains(event->getPlayerId())) {
switch (event->getItemId()) {
case ItemId_Event_Say: eventSpectatorSay(qobject_cast<Event_Say *>(event), context); break;
default: {
qDebug() << "unhandled spectator game event";
break;
}
}
} else switch (event->getItemId()) {
case ItemId_Event_GameStateChanged: eventGameStateChanged(qobject_cast<Event_GameStateChanged *>(event), context); break;
case ItemId_Event_PlayerPropertiesChanged: eventPlayerPropertiesChanged(qobject_cast<Event_PlayerPropertiesChanged *>(event), context); break;
case ItemId_Event_Join: eventJoin(qobject_cast<Event_Join *>(event), context); break;
@ -289,6 +299,11 @@ void TabGame::stopGame()
deckViewContainer->show();
}
void TabGame::eventSpectatorSay(Event_Say *event, GameEventContext * /*context*/)
{
messageLog->logSpectatorSay(spectators.value(event->getPlayerId()), event->getMessage());
}
void TabGame::eventGameStateChanged(Event_GameStateChanged *event, GameEventContext * /*context*/)
{
const QList<ServerInfo_Player *> &plList = event->getPlayerList();