Commit f10d9c9b authored by Max-Wilhelm Bruker's avatar Max-Wilhelm Bruker
Browse files

strip newlines from msg in cmdRoomSay; improved i18n in MessageLogWidget

parent 9090bc33
This diff is collapsed.
...@@ -31,6 +31,7 @@ private: ...@@ -31,6 +31,7 @@ private:
bool isFemale(Player *player) const; bool isFemale(Player *player) const;
QPair<QString, QString> getFromStr(CardZone *zone, QString cardName, int position) const; QPair<QString, QString> getFromStr(CardZone *zone, QString cardName, int position) const;
MessageContext currentContext; MessageContext currentContext;
bool female;
QList<LogMoveCard> moveCardQueue; QList<LogMoveCard> moveCardQueue;
QMap<CardItem *, QString> moveCardPT; QMap<CardItem *, QString> moveCardPT;
...@@ -39,13 +40,6 @@ private: ...@@ -39,13 +40,6 @@ private:
Player *mulliganPlayer; Player *mulliganPlayer;
int mulliganNumber; int mulliganNumber;
public slots: public slots:
void logConnecting(QString hostname);
void logConnected();
void logDisconnected();
void logSocketError(const QString &errorString);
void logServerError(ResponseCode response);
void logProtocolVersionMismatch(int clientVersion, int serverVersion);
void logProtocolError();
void logGameJoined(int gameId); void logGameJoined(int gameId);
void logJoin(Player *player); void logJoin(Player *player);
void logLeave(Player *player); void logLeave(Player *player);
...@@ -88,7 +82,7 @@ public slots: ...@@ -88,7 +82,7 @@ public slots:
void containerProcessingDone(); void containerProcessingDone();
public: public:
void connectToPlayer(Player *player); void connectToPlayer(Player *player);
MessageLogWidget(const QString &_ownName, QWidget *parent = 0); MessageLogWidget(const QString &_ownName, bool _female, QWidget *parent = 0);
}; };
#endif #endif
...@@ -158,7 +158,7 @@ void DeckViewContainer::setDeck(DeckList *deck) ...@@ -158,7 +158,7 @@ void DeckViewContainer::setDeck(DeckList *deck)
readyStartButton->setEnabled(true); readyStartButton->setEnabled(true);
} }
TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, int _gameId, const QString &_gameDescription, int _localPlayerId, const QString &_userName, bool _spectator, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, bool _resuming) 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), started(false), resuming(_resuming), currentPhase(-1) : Tab(_tabSupervisor), clients(_clients), gameId(_gameId), gameDescription(_gameDescription), localPlayerId(_localPlayerId), spectator(_spectator), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), started(false), resuming(_resuming), currentPhase(-1)
{ {
phasesToolbar = new PhasesToolbar; phasesToolbar = new PhasesToolbar;
...@@ -176,7 +176,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client ...@@ -176,7 +176,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
timeElapsedLabel = new QLabel; timeElapsedLabel = new QLabel;
timeElapsedLabel->setAlignment(Qt::AlignCenter); timeElapsedLabel->setAlignment(Qt::AlignCenter);
messageLog = new MessageLogWidget(_userName); messageLog = new MessageLogWidget(_userInfo->getName(), _userInfo->getGender() == ServerInfo_User::Female);
connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString))); connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString)));
connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString))); connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString))); connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
......
...@@ -155,7 +155,7 @@ private slots: ...@@ -155,7 +155,7 @@ private slots:
void actNextPhase(); void actNextPhase();
void actNextTurn(); void actNextTurn();
public: public:
TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, int _gameId, const QString &_gameDescription, int _localPlayerId, const QString &_userName, bool _spectator, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, bool _resuming); TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, int _gameId, const QString &_gameDescription, int _localPlayerId, ServerInfo_User *_userInfo, bool _spectator, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, bool _resuming);
~TabGame(); ~TabGame();
void retranslateUi(); void retranslateUi();
void closeRequest(); void closeRequest();
......
...@@ -105,11 +105,10 @@ int TabSupervisor::myAddTab(Tab *tab) ...@@ -105,11 +105,10 @@ int TabSupervisor::myAddTab(Tab *tab)
return addTab(tab, tab->getTabText()); return addTab(tab, tab->getTabText());
} }
void TabSupervisor::start(AbstractClient *_client, ServerInfo_User *userInfo) void TabSupervisor::start(AbstractClient *_client, ServerInfo_User *_userInfo)
{ {
client = _client; client = _client;
userName = userInfo->getName(); userInfo = new ServerInfo_User(_userInfo);
userLevel = userInfo->getUserLevel();
connect(client, SIGNAL(roomEventReceived(RoomEvent *)), this, SLOT(processRoomEvent(RoomEvent *))); connect(client, SIGNAL(roomEventReceived(RoomEvent *)), this, SLOT(processRoomEvent(RoomEvent *)));
connect(client, SIGNAL(gameEventContainerReceived(GameEventContainer *)), this, SLOT(processGameEventContainer(GameEventContainer *))); connect(client, SIGNAL(gameEventContainerReceived(GameEventContainer *)), this, SLOT(processGameEventContainer(GameEventContainer *)));
...@@ -146,6 +145,7 @@ void TabSupervisor::start(AbstractClient *_client, ServerInfo_User *userInfo) ...@@ -146,6 +145,7 @@ void TabSupervisor::start(AbstractClient *_client, ServerInfo_User *userInfo)
void TabSupervisor::startLocal(const QList<AbstractClient *> &_clients) void TabSupervisor::startLocal(const QList<AbstractClient *> &_clients)
{ {
userInfo = new ServerInfo_User;
localClients = _clients; localClients = _clients;
for (int i = 0; i < localClients.size(); ++i) for (int i = 0; i < localClients.size(); ++i)
connect(localClients[i], SIGNAL(gameEventContainerReceived(GameEventContainer *)), this, SLOT(processGameEventContainer(GameEventContainer *))); connect(localClients[i], SIGNAL(gameEventContainerReceived(GameEventContainer *)), this, SLOT(processGameEventContainer(GameEventContainer *)));
...@@ -192,6 +192,9 @@ void TabSupervisor::stop() ...@@ -192,6 +192,9 @@ void TabSupervisor::stop()
while (messageIterator.hasNext()) while (messageIterator.hasNext())
messageIterator.next().value()->deleteLater(); messageIterator.next().value()->deleteLater();
messageTabs.clear(); messageTabs.clear();
delete userInfo;
userInfo = 0;
} }
void TabSupervisor::updatePingTime(int value, int max) void TabSupervisor::updatePingTime(int value, int max)
...@@ -221,7 +224,7 @@ void TabSupervisor::addCloseButtonToTab(Tab *tab, int tabIndex) ...@@ -221,7 +224,7 @@ void TabSupervisor::addCloseButtonToTab(Tab *tab, int tabIndex)
void TabSupervisor::gameJoined(Event_GameJoined *event) void TabSupervisor::gameJoined(Event_GameJoined *event)
{ {
TabGame *tab = new TabGame(this, QList<AbstractClient *>() << client, event->getGameId(), event->getGameDescription(), event->getPlayerId(), userName, event->getSpectator(), event->getSpectatorsCanTalk(), event->getSpectatorsSeeEverything(), event->getResuming()); TabGame *tab = new TabGame(this, QList<AbstractClient *>() << client, event->getGameId(), event->getGameDescription(), event->getPlayerId(), userInfo, event->getSpectator(), event->getSpectatorsCanTalk(), event->getSpectatorsSeeEverything(), event->getResuming());
connect(tab, SIGNAL(gameClosing(TabGame *)), this, SLOT(gameLeft(TabGame *))); connect(tab, SIGNAL(gameClosing(TabGame *)), this, SLOT(gameLeft(TabGame *)));
connect(tab, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool))); connect(tab, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
int tabIndex = myAddTab(tab); int tabIndex = myAddTab(tab);
...@@ -232,7 +235,7 @@ void TabSupervisor::gameJoined(Event_GameJoined *event) ...@@ -232,7 +235,7 @@ void TabSupervisor::gameJoined(Event_GameJoined *event)
void TabSupervisor::localGameJoined(Event_GameJoined *event) void TabSupervisor::localGameJoined(Event_GameJoined *event)
{ {
TabGame *tab = new TabGame(this, localClients, event->getGameId(), event->getGameDescription(), event->getPlayerId(), QString(), event->getSpectator(), event->getSpectatorsCanTalk(), event->getSpectatorsSeeEverything(), event->getResuming()); TabGame *tab = new TabGame(this, localClients, event->getGameId(), event->getGameDescription(), event->getPlayerId(), userInfo, event->getSpectator(), event->getSpectatorsCanTalk(), event->getSpectatorsSeeEverything(), event->getResuming());
connect(tab, SIGNAL(gameClosing(TabGame *)), this, SLOT(gameLeft(TabGame *))); connect(tab, SIGNAL(gameClosing(TabGame *)), this, SLOT(gameLeft(TabGame *)));
int tabIndex = myAddTab(tab); int tabIndex = myAddTab(tab);
addCloseButtonToTab(tab, tabIndex); addCloseButtonToTab(tab, tabIndex);
...@@ -258,7 +261,7 @@ void TabSupervisor::gameLeft(TabGame *tab) ...@@ -258,7 +261,7 @@ void TabSupervisor::gameLeft(TabGame *tab)
void TabSupervisor::addRoomTab(ServerInfo_Room *info, bool setCurrent) void TabSupervisor::addRoomTab(ServerInfo_Room *info, bool setCurrent)
{ {
TabRoom *tab = new TabRoom(this, client, userName, info); TabRoom *tab = new TabRoom(this, client, userInfo->getName(), info);
connect(tab, SIGNAL(roomClosing(TabRoom *)), this, SLOT(roomLeft(TabRoom *))); connect(tab, SIGNAL(roomClosing(TabRoom *)), this, SLOT(roomLeft(TabRoom *)));
connect(tab, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool))); connect(tab, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
int tabIndex = myAddTab(tab); int tabIndex = myAddTab(tab);
...@@ -278,10 +281,10 @@ void TabSupervisor::roomLeft(TabRoom *tab) ...@@ -278,10 +281,10 @@ void TabSupervisor::roomLeft(TabRoom *tab)
TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus) TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus)
{ {
if (receiverName == userName) if (receiverName == userInfo->getName())
return 0; return 0;
TabMessage *tab = new TabMessage(this, client, userName, receiverName); TabMessage *tab = new TabMessage(this, client, userInfo->getName(), receiverName);
connect(tab, SIGNAL(talkClosing(TabMessage *)), this, SLOT(talkLeft(TabMessage *))); connect(tab, SIGNAL(talkClosing(TabMessage *)), this, SLOT(talkLeft(TabMessage *)));
int tabIndex = myAddTab(tab); int tabIndex = myAddTab(tab);
addCloseButtonToTab(tab, tabIndex); addCloseButtonToTab(tab, tabIndex);
...@@ -372,3 +375,8 @@ bool TabSupervisor::getAdminLocked() const ...@@ -372,3 +375,8 @@ bool TabSupervisor::getAdminLocked() const
return true; return true;
return tabAdmin->getLocked(); return tabAdmin->getLocked();
} }
int TabSupervisor::getUserLevel() const
{
return userInfo->getUserLevel();
}
...@@ -37,8 +37,7 @@ protected: ...@@ -37,8 +37,7 @@ protected:
class TabSupervisor : public QTabWidget { class TabSupervisor : public QTabWidget {
Q_OBJECT Q_OBJECT
private: private:
QString userName; ServerInfo_User *userInfo;
int userLevel;
QIcon *tabChangedIcon; QIcon *tabChangedIcon;
AbstractClient *client; AbstractClient *client;
QList<AbstractClient *> localClients; QList<AbstractClient *> localClients;
...@@ -61,7 +60,7 @@ public: ...@@ -61,7 +60,7 @@ public:
int getGameCount() const { return gameTabs.size(); } int getGameCount() const { return gameTabs.size(); }
TabUserLists *getUserListsTab() const { return tabUserLists; } TabUserLists *getUserListsTab() const { return tabUserLists; }
bool getAdminLocked() const; bool getAdminLocked() const;
int getUserLevel() const { return userLevel; } int getUserLevel() const;
signals: signals:
void setMenu(QMenu *menu); void setMenu(QMenu *menu);
void localGameEnded(); void localGameEnded();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -468,8 +468,9 @@ ResponseCode Server_ProtocolHandler::cmdRoomSay(Command_RoomSay *cmd, CommandCon ...@@ -468,8 +468,9 @@ ResponseCode Server_ProtocolHandler::cmdRoomSay(Command_RoomSay *cmd, CommandCon
if ((totalSize > server->getMaxMessageSizePerInterval()) || (totalCount > server->getMaxMessageCountPerInterval())) if ((totalSize > server->getMaxMessageSizePerInterval()) || (totalCount > server->getMaxMessageCountPerInterval()))
return RespChatFlood; return RespChatFlood;
} }
msg.replace(QChar('\n'), QChar(' '));
room->say(this, cmd->getMessage()); room->say(this, msg);
return RespOk; return RespOk;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment