Selecting game already open in a tab brings user to that tab. (#4653)
* When trying to join a game from GameSelector that's already been joined by you, navigate to its game tab. * return immediately, do not change button states Co-authored-by: ebbit1q <ebbit1q@gmail.com>
This commit is contained in:
parent
8e4ddf366c
commit
72743e834e
10 changed files with 29 additions and 11 deletions
|
@ -21,7 +21,7 @@ UserMessagePosition::UserMessagePosition(QTextCursor &cursor)
|
||||||
relativePosition = cursor.position() - block.position();
|
relativePosition = cursor.position() - block.position();
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatView::ChatView(const TabSupervisor *_tabSupervisor,
|
ChatView::ChatView(TabSupervisor *_tabSupervisor,
|
||||||
const UserlistProxy *_userlistProxy,
|
const UserlistProxy *_userlistProxy,
|
||||||
TabGame *_game,
|
TabGame *_game,
|
||||||
bool _showTimestamps,
|
bool _showTimestamps,
|
||||||
|
|
|
@ -33,7 +33,7 @@ class ChatView : public QTextBrowser
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
protected:
|
protected:
|
||||||
const TabSupervisor *const tabSupervisor;
|
TabSupervisor *const tabSupervisor;
|
||||||
TabGame *const game;
|
TabGame *const game;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -83,7 +83,7 @@ private slots:
|
||||||
void actMessageClicked();
|
void actMessageClicked();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ChatView(const TabSupervisor *_tabSupervisor,
|
ChatView(TabSupervisor *_tabSupervisor,
|
||||||
const UserlistProxy *_userlistProxy,
|
const UserlistProxy *_userlistProxy,
|
||||||
TabGame *_game,
|
TabGame *_game,
|
||||||
bool _showTimestamps,
|
bool _showTimestamps,
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "pb/serverinfo_game.pb.h"
|
#include "pb/serverinfo_game.pb.h"
|
||||||
#include "pending_command.h"
|
#include "pending_command.h"
|
||||||
#include "tab_account.h"
|
#include "tab_account.h"
|
||||||
|
#include "tab_game.h"
|
||||||
#include "tab_room.h"
|
#include "tab_room.h"
|
||||||
#include "tab_supervisor.h"
|
#include "tab_supervisor.h"
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
GameSelector::GameSelector(AbstractClient *_client,
|
GameSelector::GameSelector(AbstractClient *_client,
|
||||||
const TabSupervisor *_tabSupervisor,
|
TabSupervisor *_tabSupervisor,
|
||||||
TabRoom *_room,
|
TabRoom *_room,
|
||||||
const QMap<int, QString> &_rooms,
|
const QMap<int, QString> &_rooms,
|
||||||
const QMap<int, GameTypeMap> &_gameTypes,
|
const QMap<int, GameTypeMap> &_gameTypes,
|
||||||
|
@ -239,6 +240,9 @@ void GameSelector::actJoin()
|
||||||
if (!ind.isValid())
|
if (!ind.isValid())
|
||||||
return;
|
return;
|
||||||
const ServerInfo_Game &game = gameListModel->getGame(ind.data(Qt::UserRole).toInt());
|
const ServerInfo_Game &game = gameListModel->getGame(ind.data(Qt::UserRole).toInt());
|
||||||
|
if (tabSupervisor->switchToGameTabIfAlreadyExists(game.game_id())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
bool spectator = sender() == spectateButton || game.player_count() == game.max_players();
|
bool spectator = sender() == spectateButton || game.player_count() == game.max_players();
|
||||||
bool overrideRestrictions = !tabSupervisor->getAdminLocked();
|
bool overrideRestrictions = !tabSupervisor->getAdminLocked();
|
||||||
QString password;
|
QString password;
|
||||||
|
|
|
@ -38,7 +38,7 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
const TabSupervisor *tabSupervisor;
|
TabSupervisor *tabSupervisor;
|
||||||
TabRoom *room;
|
TabRoom *room;
|
||||||
|
|
||||||
QTreeView *gameListView;
|
QTreeView *gameListView;
|
||||||
|
@ -52,7 +52,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameSelector(AbstractClient *_client,
|
GameSelector(AbstractClient *_client,
|
||||||
const TabSupervisor *_tabSupervisor,
|
TabSupervisor *_tabSupervisor,
|
||||||
TabRoom *_room,
|
TabRoom *_room,
|
||||||
const QMap<int, QString> &_rooms,
|
const QMap<int, QString> &_rooms,
|
||||||
const QMap<int, GameTypeMap> &_gameTypes,
|
const QMap<int, GameTypeMap> &_gameTypes,
|
||||||
|
|
|
@ -831,7 +831,7 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
||||||
SLOT(logAlwaysLookAtTopCard(Player *, CardZone *, bool)));
|
SLOT(logAlwaysLookAtTopCard(Player *, CardZone *, bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageLogWidget::MessageLogWidget(const TabSupervisor *_tabSupervisor,
|
MessageLogWidget::MessageLogWidget(TabSupervisor *_tabSupervisor,
|
||||||
const UserlistProxy *_userlistProxy,
|
const UserlistProxy *_userlistProxy,
|
||||||
TabGame *_game,
|
TabGame *_game,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
|
|
|
@ -102,7 +102,7 @@ public slots:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void connectToPlayer(Player *player);
|
void connectToPlayer(Player *player);
|
||||||
MessageLogWidget(const TabSupervisor *_tabSupervisor,
|
MessageLogWidget(TabSupervisor *_tabSupervisor,
|
||||||
const UserlistProxy *_userlistProxy,
|
const UserlistProxy *_userlistProxy,
|
||||||
TabGame *_game,
|
TabGame *_game,
|
||||||
QWidget *parent = nullptr);
|
QWidget *parent = nullptr);
|
||||||
|
|
|
@ -735,3 +735,16 @@ const ServerInfo_User *TabSupervisor::getOnlineUser(const QString &userName) con
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool TabSupervisor::switchToGameTabIfAlreadyExists(const int gameId)
|
||||||
|
{
|
||||||
|
bool isGameTabExists = false;
|
||||||
|
if (gameTabs.contains(gameId)) {
|
||||||
|
isGameTabExists = true;
|
||||||
|
TabGame *tabGame = gameTabs[gameId];
|
||||||
|
const int gameTabIndex = indexOf(tabGame);
|
||||||
|
setCurrentIndex(gameTabIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return isGameTabExists;
|
||||||
|
}
|
||||||
|
|
|
@ -120,6 +120,7 @@ public:
|
||||||
bool isUserBuddy(const QString &userName) const;
|
bool isUserBuddy(const QString &userName) const;
|
||||||
bool isUserIgnored(const QString &userName) const;
|
bool isUserIgnored(const QString &userName) const;
|
||||||
const ServerInfo_User *getOnlineUser(const QString &userName) const;
|
const ServerInfo_User *getOnlineUser(const QString &userName) const;
|
||||||
|
bool switchToGameTabIfAlreadyExists(const int gameId);
|
||||||
void actShowPopup(const QString &message);
|
void actShowPopup(const QString &message);
|
||||||
signals:
|
signals:
|
||||||
void setMenu(const QList<QMenu *> &newMenuList = QList<QMenu *>());
|
void setMenu(const QList<QMenu *> &newMenuList = QList<QMenu *>());
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
UserContextMenu::UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *parent, TabGame *_game)
|
UserContextMenu::UserContextMenu(TabSupervisor *_tabSupervisor, QWidget *parent, TabGame *_game)
|
||||||
: QObject(parent), client(_tabSupervisor->getClient()), tabSupervisor(_tabSupervisor), game(_game)
|
: QObject(parent), client(_tabSupervisor->getClient()), tabSupervisor(_tabSupervisor), game(_game)
|
||||||
{
|
{
|
||||||
aUserName = new QAction(QString(), this);
|
aUserName = new QAction(QString(), this);
|
||||||
|
|
|
@ -21,7 +21,7 @@ class UserContextMenu : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
const TabSupervisor *tabSupervisor;
|
TabSupervisor *tabSupervisor;
|
||||||
TabGame *game;
|
TabGame *game;
|
||||||
|
|
||||||
QAction *aUserName;
|
QAction *aUserName;
|
||||||
|
@ -49,7 +49,7 @@ private slots:
|
||||||
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
|
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *_parent, TabGame *_game = 0);
|
UserContextMenu(TabSupervisor *_tabSupervisor, QWidget *_parent, TabGame *_game = 0);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void showContextMenu(const QPoint &pos,
|
void showContextMenu(const QPoint &pos,
|
||||||
const QString &userName,
|
const QString &userName,
|
||||||
|
|
Loading…
Reference in a new issue