Fix Bad Gameplay (#3034)
This commit is contained in:
parent
d1b95aad16
commit
bc52882ac4
6 changed files with 805 additions and 1302 deletions
|
@ -2740,10 +2740,8 @@ qreal Player::getMinimumWidth() const
|
|||
|
||||
void Player::setGameStarted()
|
||||
{
|
||||
if (local && aAlwaysRevealTopCard)
|
||||
{
|
||||
if (local)
|
||||
aAlwaysRevealTopCard->setChecked(false);
|
||||
}
|
||||
setConceded(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,34 +59,28 @@ class PendingCommand;
|
|||
|
||||
const int MAX_TOKENS_PER_DIALOG = 99;
|
||||
|
||||
class PlayerArea : public QObject, public QGraphicsItem
|
||||
{
|
||||
class PlayerArea : public QObject, public QGraphicsItem {
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
private:
|
||||
private:
|
||||
QRectF bRect;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void updateBg();
|
||||
|
||||
public:
|
||||
public:
|
||||
enum { Type = typeOther };
|
||||
int type() const override
|
||||
{ return Type; }
|
||||
int type() const { return Type; }
|
||||
|
||||
explicit PlayerArea(QGraphicsItem *parent = nullptr);
|
||||
QRectF boundingRect() const override { return bRect; }
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
PlayerArea(QGraphicsItem *parent = 0);
|
||||
QRectF boundingRect() const { return bRect; }
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
void setSize(qreal width, qreal height);
|
||||
};
|
||||
|
||||
class Player : public QObject, public QGraphicsItem
|
||||
{
|
||||
class Player : public QObject, public QGraphicsItem {
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void openDeckEditor(const DeckLoader *deck);
|
||||
void newCardAdded(AbstractCardItem *card);
|
||||
// Log events
|
||||
|
@ -115,8 +109,7 @@ class Player : public QObject, public QGraphicsItem
|
|||
|
||||
void sizeChanged();
|
||||
void gameConceded();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void actUntapAll();
|
||||
void actRollDie();
|
||||
void actCreateToken();
|
||||
|
@ -141,8 +134,7 @@ class Player : public QObject, public QGraphicsItem
|
|||
void actViewSideboard();
|
||||
|
||||
void actSayMessage();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void addPlayer(Player *player);
|
||||
void removePlayer(Player *player);
|
||||
void playerListActionTriggered();
|
||||
|
@ -174,7 +166,7 @@ class Player : public QObject, public QGraphicsItem
|
|||
void actPlayFacedown();
|
||||
void refreshShortcuts();
|
||||
|
||||
private:
|
||||
private:
|
||||
TabGame *game;
|
||||
QMenu *playerMenu, *handMenu, *moveHandMenu, *graveMenu, *moveGraveMenu, *rfgMenu, *moveRfgMenu, *libraryMenu, *sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu,
|
||||
*mRevealLibrary, *mRevealTopCard, *mRevealHand, *mRevealRandomHandCard, *mRevealRandomGraveyardCard;
|
||||
|
@ -238,6 +230,7 @@ class Player : public QObject, public QGraphicsItem
|
|||
|
||||
void initSayMenu();
|
||||
|
||||
void eventConnectionStateChanged(const Event_ConnectionStateChanged &event);
|
||||
void eventGameSay(const Event_GameSay &event);
|
||||
void eventShuffle(const Event_Shuffle &event);
|
||||
void eventRollDie(const Event_RollDie &event);
|
||||
|
@ -258,16 +251,15 @@ class Player : public QObject, public QGraphicsItem
|
|||
void eventDrawCards(const Event_DrawCards &event);
|
||||
void eventRevealCards(const Event_RevealCards &event);
|
||||
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event);
|
||||
|
||||
public:
|
||||
public:
|
||||
static const int counterAreaWidth = 55;
|
||||
enum CardMenuActionType { cmTap, cmUntap, cmDoesntUntap, cmFlip, cmPeek, cmClone, cmMoveToTopLibrary, cmMoveToBottomLibrary, cmMoveToHand, cmMoveToGraveyard, cmMoveToExile };
|
||||
enum CardsToReveal {RANDOM_CARD_FROM_ZONE = -2};
|
||||
|
||||
enum { Type = typeOther };
|
||||
int type() const override { return Type; }
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
int type() const { return Type; }
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
void playCard(CardItem *c, bool faceDown, bool tapped);
|
||||
void addCard(CardItem *c);
|
||||
|
@ -287,7 +279,7 @@ class Player : public QObject, public QGraphicsItem
|
|||
PlayerTarget *getPlayerTarget() const { return playerTarget; }
|
||||
|
||||
Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_parent);
|
||||
~Player() override;
|
||||
~Player();
|
||||
void retranslateUi();
|
||||
void clear();
|
||||
TabGame *getGame() const { return game; }
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -60,35 +60,29 @@ class LineEditCompleter;
|
|||
class QDockWidget;
|
||||
class QStackedWidget;
|
||||
|
||||
class ToggleButton : public QPushButton
|
||||
{
|
||||
class ToggleButton : public QPushButton {
|
||||
Q_OBJECT
|
||||
private:
|
||||
private:
|
||||
bool state;
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void stateChanged();
|
||||
|
||||
public:
|
||||
explicit ToggleButton(QWidget *parent = nullptr);
|
||||
public:
|
||||
ToggleButton(QWidget *parent = 0);
|
||||
bool getState() const { return state; }
|
||||
void setState(bool _state);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
};
|
||||
|
||||
class DeckViewContainer : public QWidget
|
||||
{
|
||||
class DeckViewContainer : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
private:
|
||||
QPushButton *loadLocalButton, *loadRemoteButton;
|
||||
ToggleButton *readyStartButton, *sideboardLockButton;
|
||||
DeckView *deckView;
|
||||
TabGame *parentGame;
|
||||
int playerId;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void loadLocalDeck();
|
||||
void loadRemoteDeck();
|
||||
void readyStart();
|
||||
|
@ -97,22 +91,21 @@ class DeckViewContainer : public QWidget
|
|||
void sideboardLockButtonClicked();
|
||||
void updateSideboardLockButtonText();
|
||||
void refreshShortcuts();
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void newCardAdded(AbstractCardItem *card);
|
||||
|
||||
public:
|
||||
void notIdle();
|
||||
public:
|
||||
DeckViewContainer(int _playerId, TabGame *parent);
|
||||
void retranslateUi();
|
||||
void setButtonsVisible(bool _visible);
|
||||
void setReadyStart(bool ready);
|
||||
void setSideboardLocked(bool locked);
|
||||
void setDeck(const DeckLoader &deck);
|
||||
};
|
||||
|
||||
class TabGame : public Tab
|
||||
{
|
||||
class TabGame : public Tab {
|
||||
Q_OBJECT
|
||||
private:
|
||||
private:
|
||||
QTimer *gameTimer;
|
||||
int secondsElapsed;
|
||||
QList<AbstractClient *> clients;
|
||||
|
@ -126,6 +119,7 @@ class TabGame : public Tab
|
|||
QMap<int, ServerInfo_User> spectators;
|
||||
bool gameStateKnown;
|
||||
bool resuming;
|
||||
QStringList phasesList;
|
||||
int currentPhase;
|
||||
int activePlayer;
|
||||
CardItem *activeCard;
|
||||
|
@ -153,12 +147,12 @@ class TabGame : public Tab
|
|||
GameView *gameView;
|
||||
QMap<int, DeckViewContainer *> deckViewContainers;
|
||||
QVBoxLayout *cardVInfoLayout, *messageLogLayout, *gamePlayAreaVBox, *deckViewContainerLayout;
|
||||
QHBoxLayout *cardHInfoLayout, *sayHLayout, *replayControlLayout;
|
||||
QHBoxLayout *cardHInfoLayout, *sayHLayout, *mainHLayout, *replayControlLayout;
|
||||
QWidget *cardBoxLayoutWidget, *messageLogLayoutWidget, *gamePlayAreaWidget, *deckViewContainerWidget, *replayControlWidget;
|
||||
QDockWidget *cardInfoDock, *messageLayoutDock, *playerListDock, *replayDock;
|
||||
QAction *playersSeparator;
|
||||
QMenu *gameMenu, *phasesMenu, *viewMenu, *cardInfoDockMenu, *messageLayoutDockMenu, *playerListDockMenu, *replayDockMenu;
|
||||
QAction *aGameInfo, *aConcede, *aLeaveGame, *aCloseReplay, *aNextPhase, *aNextTurn, *aRemoveLocalArrows, *aRotateViewCW, *aRotateViewCCW, *aResetLayout;
|
||||
QAction *aGameInfo, *aConcede, *aLeaveGame, *aCloseReplay, *aNextPhase, *aNextTurn, *aRemoveLocalArrows, *aRotateViewCW, *aRotateViewCCW, *aResetLayout, *aResetReplayLayout;
|
||||
QAction *aCardInfoDockVisible, *aCardInfoDockFloating, *aMessageLayoutDockVisible, *aMessageLayoutDockFloating, *aPlayerListDockVisible, *aPlayerListDockFloating, *aReplayDockVisible, *aReplayDockFloating;
|
||||
QList<QAction *> phaseActions;
|
||||
|
||||
|
@ -182,6 +176,7 @@ class TabGame : public Tab
|
|||
void eventSetActivePlayer(const Event_SetActivePlayer &event, int eventPlayerId, const GameEventContext &context);
|
||||
void setActivePhase(int phase);
|
||||
void eventSetActivePhase(const Event_SetActivePhase &event, int eventPlayerId, const GameEventContext &context);
|
||||
void eventPing(const Event_Ping &event, int eventPlayerId, const GameEventContext &context);
|
||||
void emitUserEvent();
|
||||
void createMenuItems();
|
||||
void createReplayMenuItems();
|
||||
|
@ -193,8 +188,7 @@ class TabGame : public Tab
|
|||
void createDeckViewContainerWidget(bool bReplay=false);
|
||||
void createReplayDock();
|
||||
QString getLeaveReason(Event_Leave::LeaveReason reason);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void gameClosing(TabGame *tab);
|
||||
void playerAdded(Player *player);
|
||||
void playerRemoved(Player *player);
|
||||
|
@ -202,8 +196,8 @@ class TabGame : public Tab
|
|||
void containerProcessingDone();
|
||||
void openMessageDialog(const QString &userName, bool focus);
|
||||
void openDeckEditor(const DeckLoader *deck);
|
||||
|
||||
private slots:
|
||||
void notIdle();
|
||||
private slots:
|
||||
void replayNextEvent();
|
||||
void replayFinished();
|
||||
void replayStartButtonClicked();
|
||||
|
@ -236,24 +230,23 @@ class TabGame : public Tab
|
|||
void actResetLayout();
|
||||
void freeDocksSize();
|
||||
|
||||
bool eventFilter(QObject *o, QEvent *e) override;
|
||||
bool eventFilter(QObject *o, QEvent *e);
|
||||
void dockVisibleTriggered();
|
||||
void dockFloatingTriggered();
|
||||
void dockTopLevelChanged(bool topLevel);
|
||||
|
||||
public:
|
||||
public:
|
||||
TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes);
|
||||
TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);
|
||||
~TabGame() override;
|
||||
void retranslateUi() override;
|
||||
~TabGame();
|
||||
void retranslateUi();
|
||||
void updatePlayerListDockTitle();
|
||||
void closeRequest() override;
|
||||
void closeRequest();
|
||||
const QMap<int, Player *> &getPlayers() const { return players; }
|
||||
CardItem *getCard(int playerId, const QString &zoneName, int cardId) const;
|
||||
bool isHost() const { return hostId == localPlayerId; }
|
||||
bool getIsLocalGame() const { return isLocalGame; }
|
||||
int getGameId() const { return gameInfo.game_id(); }
|
||||
QString getTabText() const override;
|
||||
QString getTabText() const;
|
||||
bool getSpectator() const { return spectator; }
|
||||
bool getSpectatorsSeeEverything() const { return gameInfo.spectators_omniscient(); }
|
||||
bool isSpectator();
|
||||
|
@ -266,8 +259,7 @@ class TabGame : public Tab
|
|||
void processGameEventContainer(const GameEventContainer &cont, AbstractClient *client);
|
||||
PendingCommand *prepareGameCommand(const ::google::protobuf::Message &cmd);
|
||||
PendingCommand *prepareGameCommand(const QList< const ::google::protobuf::Message * > &cmdList);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void sendGameCommand(PendingCommand *pend, int playerId = -1);
|
||||
void sendGameCommand(const ::google::protobuf::Message &command, int playerId = -1);
|
||||
};
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
#include "pb/serverinfo_room.pb.h"
|
||||
#include "pb/moderator_commands.pb.h"
|
||||
|
||||
CloseButton::CloseButton(QWidget *parent) : QAbstractButton(parent)
|
||||
CloseButton::CloseButton(QWidget *parent)
|
||||
: QAbstractButton(parent)
|
||||
{
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
setCursor(Qt::ArrowCursor);
|
||||
|
@ -38,9 +39,9 @@ CloseButton::CloseButton(QWidget *parent) : QAbstractButton(parent)
|
|||
QSize CloseButton::sizeHint() const
|
||||
{
|
||||
ensurePolished();
|
||||
int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, nullptr, this);
|
||||
int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, nullptr, this);
|
||||
return {width, height};
|
||||
int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this);
|
||||
int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, 0, this);
|
||||
return QSize(width, height);
|
||||
}
|
||||
|
||||
void CloseButton::enterEvent(QEvent *event)
|
||||
|
@ -62,34 +63,24 @@ void CloseButton::paintEvent(QPaintEvent * /*event*/)
|
|||
opt.init(this);
|
||||
opt.state |= QStyle::State_AutoRaise;
|
||||
if (isEnabled() && underMouse() && !isChecked() && !isDown())
|
||||
{
|
||||
opt.state |= QStyle::State_Raised;
|
||||
}
|
||||
|
||||
if (isChecked())
|
||||
{
|
||||
opt.state |= QStyle::State_On;
|
||||
}
|
||||
|
||||
if (isDown())
|
||||
{
|
||||
opt.state |= QStyle::State_Sunken;
|
||||
}
|
||||
|
||||
if (const auto *tb = qobject_cast<const QTabBar *>(parent()))
|
||||
{
|
||||
if (const QTabBar *tb = qobject_cast<const QTabBar *>(parent())) {
|
||||
int index = tb->currentIndex();
|
||||
auto position = static_cast<QTabBar::ButtonPosition>(style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tb));
|
||||
QTabBar::ButtonPosition position = (QTabBar::ButtonPosition) style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tb);
|
||||
if (tb->tabButton(index, position) == this)
|
||||
{
|
||||
opt.state |= QStyle::State_Selected;
|
||||
}
|
||||
}
|
||||
|
||||
style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this);
|
||||
}
|
||||
|
||||
TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent) : QTabWidget(parent), userInfo(nullptr), client(_client), tabServer(nullptr), tabUserLists(nullptr), tabDeckStorage(nullptr), tabReplays(nullptr), tabAdmin(nullptr), tabLog(nullptr)
|
||||
TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent)
|
||||
: QTabWidget(parent), userInfo(0), client(_client), tabServer(0), tabUserLists(0), tabDeckStorage(0), tabReplays(0), tabAdmin(0), tabLog(0)
|
||||
{
|
||||
setElideMode(Qt::ElideRight);
|
||||
setMovable(true);
|
||||
|
@ -122,64 +113,43 @@ void TabSupervisor::retranslateUi()
|
|||
tabs.append(tabLog);
|
||||
QMapIterator<int, TabRoom *> roomIterator(roomTabs);
|
||||
while (roomIterator.hasNext())
|
||||
{
|
||||
tabs.append(roomIterator.next().value());
|
||||
}
|
||||
|
||||
QMapIterator<int, TabGame *> gameIterator(gameTabs);
|
||||
while (gameIterator.hasNext())
|
||||
{
|
||||
tabs.append(gameIterator.next().value());
|
||||
}
|
||||
|
||||
QListIterator<TabGame *> replayIterator(replayTabs);
|
||||
while (replayIterator.hasNext())
|
||||
{
|
||||
tabs.append(replayIterator.next());
|
||||
}
|
||||
|
||||
QListIterator<TabDeckEditor *> deckEditorIterator(deckEditorTabs);
|
||||
while (deckEditorIterator.hasNext())
|
||||
{
|
||||
tabs.append(deckEditorIterator.next());
|
||||
}
|
||||
|
||||
QMapIterator<QString, TabMessage *> messageIterator(messageTabs);
|
||||
while (messageIterator.hasNext())
|
||||
{
|
||||
tabs.append(messageIterator.next().value());
|
||||
}
|
||||
|
||||
for (auto &tab : tabs)
|
||||
{
|
||||
if (tab)
|
||||
{
|
||||
int idx = indexOf(tab);
|
||||
QString tabText = tab->getTabText();
|
||||
for (int i = 0; i < tabs.size(); ++i)
|
||||
if (tabs[i]) {
|
||||
int idx = indexOf(tabs[i]);
|
||||
QString tabText = tabs[i]->getTabText();
|
||||
setTabText(idx, sanitizeTabName(tabText));
|
||||
setTabToolTip(idx, sanitizeHtml(tabText));
|
||||
tab->retranslateUi();
|
||||
}
|
||||
tabs[i]->retranslateUi();
|
||||
}
|
||||
}
|
||||
|
||||
bool TabSupervisor::closeRequest()
|
||||
{
|
||||
if (getGameCount())
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Are you sure?"), tr("There are still open games. Are you sure you want to quit?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No)
|
||||
{
|
||||
if (getGameCount()) {
|
||||
if (QMessageBox::question(this, tr("Are you sure?"), tr("There are still open games. Are you sure you want to quit?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (TabDeckEditor *tab : deckEditorTabs)
|
||||
{
|
||||
if (!tab->confirmClose())
|
||||
foreach(TabDeckEditor *tab, deckEditorTabs)
|
||||
{
|
||||
if(!tab->confirmClose())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -215,52 +185,53 @@ int TabSupervisor::myAddTab(Tab *tab)
|
|||
return idx;
|
||||
}
|
||||
|
||||
void TabSupervisor::start(const ServerInfo_User &_userInfo)
|
||||
{
|
||||
void TabSupervisor::start(const ServerInfo_User &_userInfo) {
|
||||
isLocalGame = false;
|
||||
userInfo = new ServerInfo_User(_userInfo);
|
||||
|
||||
tabServer = new TabServer(this, client);
|
||||
connect(tabServer, SIGNAL(roomJoined(const ServerInfo_Room &, bool)), this, SLOT(addRoomTab(const ServerInfo_Room &, bool)));
|
||||
connect(tabServer, SIGNAL(roomJoined(
|
||||
const ServerInfo_Room &, bool)), this, SLOT(addRoomTab(
|
||||
const ServerInfo_Room &, bool)));
|
||||
myAddTab(tabServer);
|
||||
|
||||
tabUserLists = new TabUserLists(this, client, *userInfo);
|
||||
connect(tabUserLists, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
|
||||
connect(tabUserLists, SIGNAL(openMessageDialog(
|
||||
const QString &, bool)), this, SLOT(addMessageTab(
|
||||
const QString &, bool)));
|
||||
connect(tabUserLists, SIGNAL(userJoined(ServerInfo_User)), this, SLOT(processUserJoined(ServerInfo_User)));
|
||||
connect(tabUserLists, SIGNAL(userLeft(const QString &)), this, SLOT(processUserLeft(const QString &)));
|
||||
connect(tabUserLists, SIGNAL(userLeft(
|
||||
const QString &)), this, SLOT(processUserLeft(
|
||||
const QString &)));
|
||||
myAddTab(tabUserLists);
|
||||
|
||||
updatePingTime(0, -1);
|
||||
|
||||
if (userInfo->user_level() & ServerInfo_User::IsRegistered)
|
||||
{
|
||||
if (userInfo->user_level() & ServerInfo_User::IsRegistered) {
|
||||
tabDeckStorage = new TabDeckStorage(this, client);
|
||||
connect(tabDeckStorage, SIGNAL(openDeckEditor(const DeckLoader *)), this, SLOT(addDeckEditorTab(const DeckLoader *)));
|
||||
connect(tabDeckStorage, SIGNAL(openDeckEditor(
|
||||
const DeckLoader *)), this, SLOT(addDeckEditorTab(
|
||||
const DeckLoader *)));
|
||||
myAddTab(tabDeckStorage);
|
||||
|
||||
tabReplays = new TabReplays(this, client);
|
||||
connect(tabReplays, SIGNAL(openReplay(GameReplay* )), this, SLOT(openReplay(GameReplay* )));
|
||||
connect(tabReplays, SIGNAL(openReplay(GameReplay * )), this, SLOT(openReplay(GameReplay * )));
|
||||
myAddTab(tabReplays);
|
||||
}
|
||||
else
|
||||
{
|
||||
tabDeckStorage = nullptr;
|
||||
tabReplays = nullptr;
|
||||
} else {
|
||||
tabDeckStorage = 0;
|
||||
tabReplays = 0;
|
||||
}
|
||||
|
||||
if (userInfo->user_level() & ServerInfo_User::IsModerator)
|
||||
{
|
||||
tabAdmin = new TabAdmin(this, client, static_cast<bool>(userInfo->user_level() & ServerInfo_User::IsAdmin));
|
||||
if (userInfo->user_level() & ServerInfo_User::IsModerator) {
|
||||
tabAdmin = new TabAdmin(this, client, (userInfo->user_level() & ServerInfo_User::IsAdmin));
|
||||
connect(tabAdmin, SIGNAL(adminLockChanged(bool)), this, SIGNAL(adminLockChanged(bool)));
|
||||
myAddTab(tabAdmin);
|
||||
|
||||
tabLog = new TabLog(this, client);
|
||||
myAddTab(tabLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
tabAdmin = nullptr;
|
||||
tabLog = nullptr;
|
||||
} else {
|
||||
tabAdmin = 0;
|
||||
tabLog = 0;
|
||||
}
|
||||
|
||||
retranslateUi();
|
||||
|
@ -276,117 +247,82 @@ void TabSupervisor::startLocal(const QList<AbstractClient *> &_clients)
|
|||
isLocalGame = true;
|
||||
userInfo = new ServerInfo_User;
|
||||
localClients = _clients;
|
||||
for (auto &localClient : localClients)
|
||||
{
|
||||
connect(localClient, SIGNAL(gameEventContainerReceived(const GameEventContainer &)), this, SLOT(processGameEventContainer(const GameEventContainer &)));
|
||||
}
|
||||
|
||||
for (int i = 0; i < localClients.size(); ++i)
|
||||
connect(localClients[i], SIGNAL(gameEventContainerReceived(const GameEventContainer &)), this, SLOT(processGameEventContainer(const GameEventContainer &)));
|
||||
connect(localClients.first(), SIGNAL(gameJoinedEventReceived(const Event_GameJoined &)), this, SLOT(localGameJoined(const Event_GameJoined &)));
|
||||
}
|
||||
|
||||
void TabSupervisor::stop()
|
||||
{
|
||||
if ((!client) && localClients.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!localClients.isEmpty())
|
||||
{
|
||||
for (auto &localClient : localClients)
|
||||
{
|
||||
localClient->deleteLater();
|
||||
}
|
||||
|
||||
if (!localClients.isEmpty()) {
|
||||
for (int i = 0; i < localClients.size(); ++i)
|
||||
localClients[i]->deleteLater();
|
||||
localClients.clear();
|
||||
|
||||
emit localGameEnded();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (tabUserLists)
|
||||
{
|
||||
tabUserLists->deleteLater();
|
||||
}
|
||||
|
||||
if (tabServer)
|
||||
{
|
||||
tabServer->deleteLater();
|
||||
}
|
||||
|
||||
if (tabDeckStorage)
|
||||
{
|
||||
tabDeckStorage->deleteLater();
|
||||
}
|
||||
|
||||
if (tabReplays)
|
||||
{
|
||||
tabReplays->deleteLater();
|
||||
}
|
||||
|
||||
if (tabAdmin)
|
||||
{
|
||||
tabAdmin->deleteLater();
|
||||
}
|
||||
|
||||
if (tabLog)
|
||||
{
|
||||
tabLog->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
tabUserLists = nullptr;
|
||||
tabServer = nullptr;
|
||||
tabDeckStorage = nullptr;
|
||||
tabReplays = nullptr;
|
||||
tabAdmin = nullptr;
|
||||
tabLog = nullptr;
|
||||
tabUserLists = 0;
|
||||
tabServer = 0;
|
||||
tabDeckStorage = 0;
|
||||
tabReplays = 0;
|
||||
tabAdmin = 0;
|
||||
tabLog = 0;
|
||||
|
||||
QMapIterator<int, TabRoom *> roomIterator(roomTabs);
|
||||
while (roomIterator.hasNext())
|
||||
{
|
||||
roomIterator.next().value()->deleteLater();
|
||||
}
|
||||
roomTabs.clear();
|
||||
|
||||
QMapIterator<int, TabGame *> gameIterator(gameTabs);
|
||||
while (gameIterator.hasNext())
|
||||
{
|
||||
gameIterator.next().value()->deleteLater();
|
||||
}
|
||||
gameTabs.clear();
|
||||
|
||||
QListIterator<TabGame *> replayIterator(replayTabs);
|
||||
while (replayIterator.hasNext())
|
||||
{
|
||||
replayIterator.next()->deleteLater();
|
||||
}
|
||||
replayTabs.clear();
|
||||
|
||||
delete userInfo;
|
||||
userInfo = nullptr;
|
||||
userInfo = 0;
|
||||
}
|
||||
|
||||
void TabSupervisor::updatePingTime(int value, int max)
|
||||
{
|
||||
if (!tabServer || tabServer->getContentsChanged())
|
||||
{
|
||||
if (!tabServer)
|
||||
return;
|
||||
if (tabServer->getContentsChanged())
|
||||
return;
|
||||
}
|
||||
|
||||
setTabIcon(indexOf(tabServer), QIcon(PingPixmapGenerator::generatePixmap(15, value, max)));
|
||||
}
|
||||
|
||||
void TabSupervisor::closeButtonPressed()
|
||||
{
|
||||
Tab *tab = dynamic_cast<Tab *>(dynamic_cast<CloseButton *>(sender())->property("tab").value<QObject *>());
|
||||
Tab *tab = static_cast<Tab *>(static_cast<CloseButton *>(sender())->property("tab").value<QObject *>());
|
||||
tab->closeRequest();
|
||||
}
|
||||
|
||||
void TabSupervisor::addCloseButtonToTab(Tab *tab, int tabIndex)
|
||||
{
|
||||
auto closeSide = static_cast<QTabBar::ButtonPosition>(tabBar()->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tabBar()));
|
||||
auto *closeButton = new CloseButton;
|
||||
QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition) tabBar()->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tabBar());
|
||||
CloseButton *closeButton = new CloseButton;
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(closeButtonPressed()));
|
||||
closeButton->setProperty("tab", qVariantFromValue((QObject *) tab));
|
||||
tabBar()->setTabButton(tabIndex, closeSide, closeButton);
|
||||
|
@ -397,16 +333,10 @@ void TabSupervisor::gameJoined(const Event_GameJoined &event)
|
|||
QMap<int, QString> roomGameTypes;
|
||||
TabRoom *room = roomTabs.value(event.game_info().room_id());
|
||||
if (room)
|
||||
{
|
||||
roomGameTypes = room->getGameTypes();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < event.game_types_size(); ++i)
|
||||
{
|
||||
roomGameTypes.insert(event.game_types(i).game_type_id(), QString::fromStdString(event.game_types(i).description()));
|
||||
}
|
||||
}
|
||||
|
||||
TabGame *tab = new TabGame(this, QList<AbstractClient *>() << client, event, roomGameTypes);
|
||||
connect(tab, SIGNAL(gameClosing(TabGame *)), this, SLOT(gameLeft(TabGame *)));
|
||||
|
@ -428,8 +358,7 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
|
|||
gameTabs.insert(event.game_info().game_id(), tab);
|
||||
setCurrentWidget(tab);
|
||||
|
||||
for (int i = 1; i < localClients.size(); ++i)
|
||||
{
|
||||
for (int i = 1; i < localClients.size(); ++i) {
|
||||
Command_JoinGame cmd;
|
||||
cmd.set_game_id(event.game_info().game_id());
|
||||
localClients[i]->sendCommand(localClients[i]->prepareRoomCommand(cmd, 0));
|
||||
|
@ -438,28 +367,19 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
|
|||
|
||||
void TabSupervisor::gameLeft(TabGame *tab)
|
||||
{
|
||||
if (tab == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (tab == currentWidget())
|
||||
{
|
||||
emit setMenu();
|
||||
}
|
||||
|
||||
gameTabs.remove(tab->getGameId());
|
||||
removeTab(indexOf(tab));
|
||||
|
||||
if (!localClients.isEmpty())
|
||||
{
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent)
|
||||
{
|
||||
auto *tab = new TabRoom(this, client, userInfo, info);
|
||||
TabRoom *tab = new TabRoom(this, client, userInfo, info);
|
||||
connect(tab, SIGNAL(maximizeClient()), this, SLOT(maximizeMainWindow()));
|
||||
connect(tab, SIGNAL(roomClosing(TabRoom *)), this, SLOT(roomLeft(TabRoom *)));
|
||||
connect(tab, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
|
||||
|
@ -467,22 +387,13 @@ void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent)
|
|||
addCloseButtonToTab(tab, tabIndex);
|
||||
roomTabs.insert(info.room_id(), tab);
|
||||
if (setCurrent)
|
||||
{
|
||||
setCurrentWidget(tab);
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::roomLeft(TabRoom *tab)
|
||||
{
|
||||
if (tab == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (tab == currentWidget())
|
||||
{
|
||||
emit setMenu();
|
||||
}
|
||||
|
||||
roomTabs.remove(tab->getRoomId());
|
||||
removeTab(indexOf(tab));
|
||||
|
@ -490,7 +401,7 @@ void TabSupervisor::roomLeft(TabRoom *tab)
|
|||
|
||||
void TabSupervisor::openReplay(GameReplay *replay)
|
||||
{
|
||||
auto *replayTab = new TabGame(this, replay);
|
||||
TabGame *replayTab = new TabGame(this, replay);
|
||||
connect(replayTab, SIGNAL(gameClosing(TabGame *)), this, SLOT(replayLeft(TabGame *)));
|
||||
int tabIndex = myAddTab(replayTab);
|
||||
addCloseButtonToTab(replayTab, tabIndex);
|
||||
|
@ -501,9 +412,7 @@ void TabSupervisor::openReplay(GameReplay *replay)
|
|||
void TabSupervisor::replayLeft(TabGame *tab)
|
||||
{
|
||||
if (tab == currentWidget())
|
||||
{
|
||||
emit setMenu();
|
||||
}
|
||||
|
||||
replayTabs.removeAt(replayTabs.indexOf(tab));
|
||||
}
|
||||
|
@ -511,30 +420,20 @@ void TabSupervisor::replayLeft(TabGame *tab)
|
|||
TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus)
|
||||
{
|
||||
if (receiverName == QString::fromStdString(userInfo->name()))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return 0;
|
||||
|
||||
ServerInfo_User otherUser;
|
||||
UserListTWI *twi = tabUserLists->getAllUsersList()->getUsers().value(receiverName);
|
||||
if (twi)
|
||||
{
|
||||
otherUser = twi->getUserInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
otherUser.set_name(receiverName.toStdString());
|
||||
}
|
||||
|
||||
TabMessage *tab;
|
||||
tab = messageTabs.value(QString::fromStdString(otherUser.name()));
|
||||
if (tab)
|
||||
{
|
||||
if (tab) {
|
||||
if (focus)
|
||||
{
|
||||
setCurrentWidget(tab);
|
||||
}
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
|
@ -545,28 +444,18 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus
|
|||
addCloseButtonToTab(tab, tabIndex);
|
||||
messageTabs.insert(receiverName, tab);
|
||||
if (focus)
|
||||
{
|
||||
setCurrentWidget(tab);
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
|
||||
void TabSupervisor::maximizeMainWindow()
|
||||
{
|
||||
void TabSupervisor::maximizeMainWindow() {
|
||||
emit showWindowIfHidden();
|
||||
}
|
||||
|
||||
void TabSupervisor::talkLeft(TabMessage *tab)
|
||||
{
|
||||
if (tab == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (tab == currentWidget())
|
||||
{
|
||||
emit setMenu();
|
||||
}
|
||||
|
||||
messageTabs.remove(tab->getUserName());
|
||||
removeTab(indexOf(tab));
|
||||
|
@ -574,13 +463,9 @@ void TabSupervisor::talkLeft(TabMessage *tab)
|
|||
|
||||
TabDeckEditor *TabSupervisor::addDeckEditorTab(const DeckLoader *deckToOpen)
|
||||
{
|
||||
auto *tab = new TabDeckEditor(this);
|
||||
|
||||
TabDeckEditor *tab = new TabDeckEditor(this);
|
||||
if (deckToOpen)
|
||||
{
|
||||
tab->setDeck(new DeckLoader(*deckToOpen));
|
||||
}
|
||||
|
||||
connect(tab, SIGNAL(deckEditorClosing(TabDeckEditor *)), this, SLOT(deckEditorClosed(TabDeckEditor *)));
|
||||
int tabIndex = myAddTab(tab);
|
||||
addCloseButtonToTab(tab, tabIndex);
|
||||
|
@ -591,15 +476,8 @@ TabDeckEditor *TabSupervisor::addDeckEditorTab(const DeckLoader *deckToOpen)
|
|||
|
||||
void TabSupervisor::deckEditorClosed(TabDeckEditor *tab)
|
||||
{
|
||||
if (tab == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (tab == currentWidget())
|
||||
{
|
||||
emit setMenu();
|
||||
}
|
||||
|
||||
deckEditorTabs.removeAt(deckEditorTabs.indexOf(tab));
|
||||
removeTab(indexOf(tab));
|
||||
|
@ -607,18 +485,13 @@ void TabSupervisor::deckEditorClosed(TabDeckEditor *tab)
|
|||
|
||||
void TabSupervisor::tabUserEvent(bool globalEvent)
|
||||
{
|
||||
auto *tab = dynamic_cast<Tab *>(sender());
|
||||
|
||||
if (tab != currentWidget())
|
||||
{
|
||||
Tab *tab = static_cast<Tab *>(sender());
|
||||
if (tab != currentWidget()) {
|
||||
tab->setContentsChanged(true);
|
||||
setTabIcon(indexOf(tab), QPixmap("theme:icons/tab_changed"));
|
||||
}
|
||||
|
||||
if (globalEvent && settingsCache->getNotificationsEnabled())
|
||||
{
|
||||
QApplication::alert(this);
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::updateTabText(Tab *tab, const QString &newTabText)
|
||||
|
@ -631,129 +504,90 @@ void TabSupervisor::updateTabText(Tab *tab, const QString &newTabText)
|
|||
void TabSupervisor::processRoomEvent(const RoomEvent &event)
|
||||
{
|
||||
TabRoom *tab = roomTabs.value(event.room_id(), 0);
|
||||
|
||||
if (tab)
|
||||
{
|
||||
tab->processRoomEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::processGameEventContainer(const GameEventContainer &cont)
|
||||
{
|
||||
TabGame *tab = gameTabs.value(cont.game_id());
|
||||
|
||||
if (tab)
|
||||
{
|
||||
tab->processGameEventContainer(cont, qobject_cast<AbstractClient *>(sender()));
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "gameEvent: invalid gameId";
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::processUserMessageEvent(const Event_UserMessage &event)
|
||||
{
|
||||
QString senderName = QString::fromStdString(event.sender_name());
|
||||
TabMessage *tab = messageTabs.value(senderName);
|
||||
|
||||
if (tab == nullptr)
|
||||
{
|
||||
if (!tab)
|
||||
tab = messageTabs.value(QString::fromStdString(event.receiver_name()));
|
||||
}
|
||||
|
||||
if (tab == nullptr)
|
||||
{
|
||||
if (!tab) {
|
||||
UserListTWI *twi = tabUserLists->getAllUsersList()->getUsers().value(senderName);
|
||||
|
||||
if (twi)
|
||||
{
|
||||
if (twi) {
|
||||
UserLevelFlags userLevel = UserLevelFlags(twi->getUserInfo().user_level());
|
||||
if (settingsCache->getIgnoreUnregisteredUserMessages() && !userLevel.testFlag(ServerInfo_User::IsRegistered))
|
||||
{
|
||||
if (settingsCache->getIgnoreUnregisteredUserMessages() &&
|
||||
!userLevel.testFlag(ServerInfo_User::IsRegistered))
|
||||
// Flags are additive, so reg/mod/admin are all IsRegistered
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tab = addMessageTab(QString::fromStdString(event.sender_name()), false);
|
||||
}
|
||||
|
||||
if (tab == nullptr)
|
||||
{
|
||||
if (!tab)
|
||||
return;
|
||||
}
|
||||
|
||||
tab->processUserMessageEvent(event);
|
||||
}
|
||||
|
||||
void TabSupervisor::processUserLeft(const QString &userName)
|
||||
{
|
||||
TabMessage *tab = messageTabs.value(userName);
|
||||
|
||||
if (tab)
|
||||
{
|
||||
tab->processUserLeft();
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::processUserJoined(const ServerInfo_User &userInfo)
|
||||
{
|
||||
TabMessage *tab = messageTabs.value(QString::fromStdString(userInfo.name()));
|
||||
if (tab)
|
||||
{
|
||||
tab->processUserJoined(userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::updateCurrent(int index)
|
||||
{
|
||||
if (index != -1)
|
||||
{
|
||||
auto *tab = dynamic_cast<Tab *>(widget(index));
|
||||
if (tab->getContentsChanged())
|
||||
{
|
||||
if (index != -1) {
|
||||
Tab *tab = static_cast<Tab *>(widget(index));
|
||||
if (tab->getContentsChanged()) {
|
||||
setTabIcon(index, QIcon());
|
||||
tab->setContentsChanged(false);
|
||||
}
|
||||
emit setMenu(dynamic_cast<Tab *>(widget(index))->getTabMenus());
|
||||
emit setMenu(static_cast<Tab *>(widget(index))->getTabMenus());
|
||||
tab->tabActivated();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else
|
||||
emit setMenu();
|
||||
}
|
||||
}
|
||||
|
||||
bool TabSupervisor::getAdminLocked() const
|
||||
{
|
||||
if (!tabAdmin)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return tabAdmin->getLocked();
|
||||
}
|
||||
|
||||
void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event)
|
||||
{
|
||||
|
||||
switch ((Event_NotifyUser::NotificationType) event.type())
|
||||
{
|
||||
switch ((Event_NotifyUser::NotificationType) event.type()) {
|
||||
case Event_NotifyUser::UNKNOWN: QMessageBox::information(this, tr("Unknown Event"), tr("The server has sent you a message that your client does not understand.\nThis message might mean there is a new version of Cockatrice available or this server is running a custom or pre-release version.\n\nTo update your client, go to Help -> Check for Updates.")); break;
|
||||
case Event_NotifyUser::IDLEWARNING: QMessageBox::information(this, tr("Idle Timeout"), tr("You are about to be logged out due to inactivity.")); break;
|
||||
case Event_NotifyUser::PROMOTED: QMessageBox::information(this, tr("Promotion"), tr("You have been promoted to moderator. Please log out and back in for changes to take effect.")); break;
|
||||
case Event_NotifyUser::WARNING:
|
||||
{
|
||||
case Event_NotifyUser::WARNING: {
|
||||
if (!QString::fromStdString(event.warning_reason()).simplified().isEmpty())
|
||||
{
|
||||
QMessageBox::warning(this, tr("Warned"), tr("You have received a warning due to %1.\nPlease refrain from engaging in this activity or further actions may be taken against you. If you have any questions, please private message a moderator.").arg(QString::fromStdString(event.warning_reason()).simplified()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Event_NotifyUser::CUSTOM:
|
||||
{
|
||||
if (!QString::fromStdString(event.custom_title()).simplified().isEmpty() && !QString::fromStdString(event.custom_content()).simplified().isEmpty())
|
||||
{
|
||||
case Event_NotifyUser::CUSTOM: {
|
||||
if (!QString::fromStdString(event.custom_title()).simplified().isEmpty() && !QString::fromStdString(event.custom_content()).simplified().isEmpty()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setParent(this);
|
||||
msgBox.setWindowFlags(Qt::Dialog);
|
||||
|
@ -766,7 +600,7 @@ void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event)
|
|||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
default: ;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -783,11 +617,8 @@ QString TabSupervisor::getOwnUsername() const
|
|||
|
||||
bool TabSupervisor::isUserBuddy(const QString &userName) const
|
||||
{
|
||||
if (!getUserListsTab() || !getUserListsTab()->getBuddyList())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getUserListsTab()) return false;
|
||||
if (!getUserListsTab()->getBuddyList()) return false;
|
||||
QMap<QString, UserListTWI *> buddyList = getUserListsTab()->getBuddyList()->getUsers();
|
||||
bool senderIsBuddy = buddyList.contains(userName);
|
||||
return senderIsBuddy;
|
||||
|
@ -795,30 +626,23 @@ bool TabSupervisor::isUserBuddy(const QString &userName) const
|
|||
|
||||
bool TabSupervisor::isUserIgnored(const QString &userName) const
|
||||
{
|
||||
if (!getUserListsTab() || !getUserListsTab()->getIgnoreList())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getUserListsTab()) return false;
|
||||
if (!getUserListsTab()->getIgnoreList()) return false;
|
||||
QMap<QString, UserListTWI *> buddyList = getUserListsTab()->getIgnoreList()->getUsers();
|
||||
bool senderIsBuddy = buddyList.contains(userName);
|
||||
return senderIsBuddy;
|
||||
}
|
||||
|
||||
const ServerInfo_User* TabSupervisor::getOnlineUser(const QString &userName) const
|
||||
const ServerInfo_User * TabSupervisor::getOnlineUser(const QString &userName) const
|
||||
{
|
||||
if (!getUserListsTab() || !getUserListsTab()->getAllUsersList())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!getUserListsTab()) return nullptr;
|
||||
if (!getUserListsTab()->getAllUsersList()) return nullptr;
|
||||
QMap<QString, UserListTWI *> userList = getUserListsTab()->getAllUsersList()->getUsers();
|
||||
const QString &userNameToMatchLower = userName.toLower();
|
||||
QMap<QString, UserListTWI *>::iterator i;
|
||||
|
||||
for (i = userList.begin(); i != userList.end(); ++i)
|
||||
if (i.key().toLower() == userNameToMatchLower)
|
||||
{
|
||||
if (i.key().toLower() == userNameToMatchLower) {
|
||||
const ServerInfo_User &userInfo = i.value()->getUserInfo();
|
||||
return &userInfo;
|
||||
}
|
||||
|
|
|
@ -30,24 +30,21 @@ class ServerInfo_User;
|
|||
class GameReplay;
|
||||
class DeckList;
|
||||
|
||||
class CloseButton : public QAbstractButton
|
||||
{
|
||||
class CloseButton : public QAbstractButton {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CloseButton(QWidget *parent = nullptr);
|
||||
QSize sizeHint() const override;
|
||||
inline QSize minimumSizeHint() const override { return sizeHint(); }
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
public:
|
||||
CloseButton(QWidget *parent = 0);
|
||||
QSize sizeHint() const;
|
||||
inline QSize minimumSizeHint() const { return sizeHint(); }
|
||||
protected:
|
||||
void enterEvent(QEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
};
|
||||
|
||||
class TabSupervisor : public QTabWidget, public UserlistProxy
|
||||
{
|
||||
class TabSupervisor : public QTabWidget, public UserlistProxy {
|
||||
Q_OBJECT
|
||||
private:
|
||||
private:
|
||||
ServerInfo_User *userInfo;
|
||||
AbstractClient *client;
|
||||
QList<AbstractClient *> localClients;
|
||||
|
@ -67,10 +64,9 @@ class TabSupervisor : public QTabWidget, public UserlistProxy
|
|||
QString sanitizeTabName(QString dirty) const;
|
||||
QString sanitizeHtml(QString dirty) const;
|
||||
bool isLocalGame;
|
||||
|
||||
public:
|
||||
explicit TabSupervisor(AbstractClient *_client, QWidget *parent = nullptr);
|
||||
~TabSupervisor() override;
|
||||
public:
|
||||
TabSupervisor(AbstractClient *_client, QWidget *parent = 0);
|
||||
~TabSupervisor();
|
||||
void retranslateUi();
|
||||
void start(const ServerInfo_User &userInfo);
|
||||
void startLocal(const QList<AbstractClient *> &_clients);
|
||||
|
@ -83,24 +79,21 @@ class TabSupervisor : public QTabWidget, public UserlistProxy
|
|||
const QMap<int, TabRoom *> &getRoomTabs() const { return roomTabs; }
|
||||
bool getAdminLocked() const;
|
||||
bool closeRequest();
|
||||
bool isOwnUserRegistered() const override;
|
||||
QString getOwnUsername() const override;
|
||||
bool isUserBuddy(const QString &userName) const override;
|
||||
bool isUserIgnored(const QString &userName) const override;
|
||||
const ServerInfo_User* getOnlineUser(const QString &userName) const override;
|
||||
|
||||
signals:
|
||||
bool isOwnUserRegistered() const;
|
||||
QString getOwnUsername() const;
|
||||
bool isUserBuddy(const QString &userName) const;
|
||||
bool isUserIgnored(const QString &userName) const;
|
||||
const ServerInfo_User* getOnlineUser(const QString &userName) const;
|
||||
signals:
|
||||
void setMenu(const QList<QMenu *> &newMenuList = QList<QMenu *>());
|
||||
void localGameEnded();
|
||||
void adminLockChanged(bool lock);
|
||||
void showWindowIfHidden();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
TabDeckEditor *addDeckEditorTab(const DeckLoader *deckToOpen);
|
||||
void openReplay(GameReplay *replay);
|
||||
void maximizeMainWindow();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void closeButtonPressed();
|
||||
void updateCurrent(int index);
|
||||
void updatePingTime(int value, int max);
|
||||
|
|
Loading…
Reference in a new issue