mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-03 03:53:56 -07:00
* fix #2624 * feedback++
This commit is contained in:
parent
38ad71b06a
commit
29904c49da
8 changed files with 48 additions and 16 deletions
|
|
@ -42,10 +42,10 @@ void MessageLogWidget::logJoin(Player *player)
|
|||
appendHtmlServerMessage(tr("%1 has joined the game.").arg(sanitizeHtml(player->getName())));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logLeave(Player *player)
|
||||
void MessageLogWidget::logLeave(Player *player, QString reason)
|
||||
{
|
||||
soundEngine->playSound("player_leave");
|
||||
appendHtmlServerMessage(tr("%1 has left the game.").arg(sanitizeHtml(player->getName())));
|
||||
appendHtmlServerMessage(tr("%1 has left the game (%2).").arg(sanitizeHtml(player->getName()), sanitizeHtml(reason)));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logGameClosed()
|
||||
|
|
@ -64,10 +64,10 @@ void MessageLogWidget::logJoinSpectator(QString name)
|
|||
appendHtmlServerMessage(tr("%1 is now watching the game.").arg(sanitizeHtml(name)));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logLeaveSpectator(QString name)
|
||||
void MessageLogWidget::logLeaveSpectator(QString name, QString reason)
|
||||
{
|
||||
soundEngine->playSound("spectator_leave");
|
||||
appendHtmlServerMessage(tr("%1 is not watching the game any more.").arg(sanitizeHtml(name)));
|
||||
appendHtmlServerMessage(tr("%1 is not watching the game any more (%2).").arg(sanitizeHtml(name), sanitizeHtml(reason)));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logDeckSelect(Player *player, QString deckHash, int sideboardSize)
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ public slots:
|
|||
void logGameJoined(int gameId);
|
||||
void logReplayStarted(int gameId);
|
||||
void logJoin(Player *player);
|
||||
void logLeave(Player *player);
|
||||
void logLeave(Player *player, QString reason);
|
||||
void logGameClosed();
|
||||
void logKicked();
|
||||
void logJoinSpectator(QString name);
|
||||
void logLeaveSpectator(QString name);
|
||||
void logLeaveSpectator(QString name, QString reason);
|
||||
void logDeckSelect(Player *player, QString deckHash, int sideboardSize);
|
||||
void logReadyStart(Player *player);
|
||||
void logNotReadyStart(Player *player);
|
||||
|
|
|
|||
|
|
@ -891,12 +891,12 @@ void TabGame::eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, c
|
|||
messageLog->logSpectatorSay(QString::fromStdString(userInfo.name()), UserLevelFlags(userInfo.user_level()), QString::fromStdString(userInfo.privlevel()), 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*/)
|
||||
{
|
||||
QString playerName = "@" + QString::fromStdString(spectators.value(eventPlayerId).name());
|
||||
if (sayEdit && autocompleteUserList.removeOne(playerName))
|
||||
sayEdit->setCompletionList(autocompleteUserList);
|
||||
messageLog->logLeaveSpectator(QString::fromStdString(spectators.value(eventPlayerId).name()));
|
||||
messageLog->logLeaveSpectator(QString::fromStdString(spectators.value(eventPlayerId).name()), getLeaveReason(event.reason()));
|
||||
playerListWidget->removePlayer(eventPlayerId);
|
||||
spectators.remove(eventPlayerId);
|
||||
|
||||
|
|
@ -1042,7 +1042,26 @@ void TabGame::eventJoin(const Event_Join &event, int /*eventPlayerId*/, const Ga
|
|||
emitUserEvent();
|
||||
}
|
||||
|
||||
void TabGame::eventLeave(const Event_Leave & /*event*/, int eventPlayerId, const GameEventContext & /*context*/)
|
||||
QString TabGame::getLeaveReason(Event_Leave::LeaveReason reason)
|
||||
{
|
||||
switch(reason)
|
||||
{
|
||||
case Event_Leave::USER_KICKED:
|
||||
return tr("kicked by game host or moderator");
|
||||
break;
|
||||
case Event_Leave::USER_LEFT:
|
||||
return tr("player left the game");
|
||||
break;
|
||||
case Event_Leave::USER_DISCONNECTED:
|
||||
return tr("player disconnected from server");
|
||||
break;
|
||||
case Event_Leave::OTHER:
|
||||
default:
|
||||
return tr("reason unknown");
|
||||
break;
|
||||
}
|
||||
}
|
||||
void TabGame::eventLeave(const Event_Leave & event, int eventPlayerId, const GameEventContext & /*context*/)
|
||||
{
|
||||
Player *player = players.value(eventPlayerId, 0);
|
||||
if (!player)
|
||||
|
|
@ -1052,7 +1071,7 @@ void TabGame::eventLeave(const Event_Leave & /*event*/, int eventPlayerId, const
|
|||
if(sayEdit && autocompleteUserList.removeOne(playerName))
|
||||
sayEdit->setCompletionList(autocompleteUserList);
|
||||
|
||||
messageLog->logLeave(player);
|
||||
messageLog->logLeave(player, getLeaveReason(event.reason()));
|
||||
playerListWidget->removePlayer(eventPlayerId);
|
||||
players.remove(eventPlayerId);
|
||||
emit playerRemoved(player);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <QCompleter>
|
||||
#include "tab.h"
|
||||
#include "pb/serverinfo_game.pb.h"
|
||||
#include "pb/event_leave.pb.h"
|
||||
|
||||
class AbstractClient;
|
||||
class CardDatabase;
|
||||
|
|
@ -186,6 +187,7 @@ private:
|
|||
void createPlayAreaWidget(bool bReplay=false);
|
||||
void createDeckViewContainerWidget(bool bReplay=false);
|
||||
void createReplayDock();
|
||||
QString getLeaveReason(Event_Leave::LeaveReason reason);
|
||||
signals:
|
||||
void gameClosing(TabGame *tab);
|
||||
void playerAdded(Player *player);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue