Cockatrice/cockatrice/src/game_graphics/deckview/deck_view_container.h
BruebachL 711386574d
[Client] Tell the user when their playmat art is blocked (#7533)
* [Client] Tell the user when their playmat art is blocked

A server DENY rule silently drops banned playmat art: SetPlaymat fails
with no handler and DeckSelect strips the mat while answering RespOk.

Surface both cases with the same critical message box the banner card
art flow uses. DeckSelect strips are detected by comparing the
requested mat, passed via PendingCommand extraData, against the
server-echoed deck. Notices dedupe per card and reset on success.

* [Client] Gate playmat blocked notice on RespFunctionNotAllowed per review

Only SetPlaymat with RespFunctionNotAllowed signals a card art DENY
rule. Older servers answer RespInvalidCommand and strip the mat from
DeckSelect, so drop the DeckSelect comparison to avoid false
blacklisted popups on pre-playmat servers.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
Co-authored-by: BruebachL <bruebachl@users.noreply.github.com>
2026-10-16 19:50:57 +02:00

107 lines
3 KiB
C++

/**
* @file deck_view_container.h
* @ingroup Lobby
*/
//! \todo Document this file.
#ifndef DECK_VIEW_CONTAINER_H
#define DECK_VIEW_CONTAINER_H
#include "libcockatrice/deck_list/deck_list.h"
#include "libcockatrice/utility/playmat_params.h"
#include <QPushButton>
#include <QString>
#include <QWidget>
#include <qtmetamacros.h>
class QVBoxLayout;
class AbstractCardItem;
class VisualDeckStorageWidget;
class Response;
class TabGame;
class DeckView;
/**
* Custom QButton implementation in order to have the red/green toggling square around the button
*/
class ToggleButton : public QPushButton
{
Q_OBJECT
private:
bool state;
signals:
void stateChanged();
public:
explicit ToggleButton(QWidget *parent = nullptr);
[[nodiscard]] bool getState() const
{
return state;
}
void setState(bool _state);
protected:
void paintEvent(QPaintEvent *event) override;
};
/**
* This widget contains the deck selection view that is used before a game begins.
*/
class DeckViewContainer : public QWidget
{
Q_OBJECT
private:
QVBoxLayout *deckViewLayout;
QPushButton *loadLocalButton, *loadRemoteButton, *loadFromClipboardButton, *loadFromWebsiteButton;
QPushButton *unloadDeckButton, *forceStartGameButton;
ToggleButton *readyStartButton, *sideboardLockButton;
DeckView *deckView;
VisualDeckStorageWidget *visualDeckStorageWidget;
TabGame *parentGame;
int playerId;
int playmatRotationIndex = 0; ///< Per-match cursor for round-robin playmat mode.
DeckList currentDeck; ///< Cached deck for live settings re-resolution.
PlaymatInfo lastResolvedPlaymat; ///< Tracks last sent playmat to avoid repeats in random mode.
QString lastBlacklistedPlaymatNotice; ///< Card name already reported as blacklisted, to avoid repeat popups.
void tryCreateVisualDeckStorageWidget();
void sendReadyStartCommand(bool ready);
void notifyPlaymatBlacklisted(const QString &cardName, const QString &message);
private slots:
void switchToDeckSelectView();
void switchToDeckLoadedView();
void loadLocalDeck();
void loadRemoteDeck();
void loadFromClipboard();
void loadFromWebsite();
void unloadDeck();
void readyStart();
void forceStart();
void deckSelectFinished(const Response &r);
void sideboardPlanChanged();
void sideboardLockButtonClicked();
void updateSideboardLockButtonText();
void refreshShortcuts();
void onPlaymatSettingsChanged();
signals:
void newCardAdded(AbstractCardItem *card);
void notIdle();
public:
DeckViewContainer(int _playerId, TabGame *parent);
void retranslateUi();
void setReadyStart(bool ready);
void readyAndUpdate();
void setSideboardLocked(bool locked);
void setDeck(const DeckList &deck);
void setVisualDeckStorageExists(bool exists);
void advancePlaymatRotation();
void resolveAndSendPlaymat();
public slots:
void loadDeckFromFile(const QString &filePath);
void loadDeckFromDeckList(const DeckList &deck);
};
#endif // DECK_VIEW_CONTAINER_H