Cockatrice/cockatrice/src/game_graphics/dialogs/dlg_create_token.h
Bryce! 3d8c729517
[Client] Preview token edits live and preserve custom drafts (#7737)
* Preview token edits live and preserve custom drafts

* Restore the upstream reveal-random-hand-cards action

The rebase onto upstream/master took the PR side of player_actions.cpp and
dropped PlayerActions::actRevealRandomHandCards, which upstream added after
the PR merge base. Re-apply the face-down P/T fix on the current file so the
branch keeps both changes.

* Draw the token preview P/T as the hover-panel pill

The preview painted the name and P/T unconditionally: the name duplicated the
artwork, and the raw P/T text was drawn even when it matched the printed value,
which looked wrong at non-default dialog sizes.

- Suppress the card name over a token picture via a small AbstractCardItem hook;
  cards without art still show it.
- Draw only a P/T that differs from the printed getPowTough() as the #7700
  hover-panel pill: dark rounded scrim, bold white text, anchored on the printed
  P/T box and clamped inside the card.
- Use designated CardRef initializers in the new code.

The face-up draft still previews while face-down creation is selected.

---------

Co-authored-by: Lukas Brübach <44814898+BruebachL@users.noreply.github.com>
2026-11-09 12:59:53 +01:00

65 lines
1.7 KiB
C++

/**
* @file dlg_create_token.h
* @ingroup GameDialogs
*/
//! \todo Document this file.
#ifndef DLG_CREATETOKEN_H
#define DLG_CREATETOKEN_H
#include <QDialog>
#include <QList>
#include <QString>
#include <QStringList>
#include <libcockatrice/game/player/token_info.h>
#include <qtmetamacros.h>
class QLabel;
class QLineEdit;
class QComboBox;
class QCheckBox;
class QRadioButton;
class QTreeView;
class CardDatabaseModel;
class TokenDisplayModel;
class TokenPreviewWidget;
class QModelIndex;
class QWidget;
class DlgCreateToken : public QDialog
{
Q_OBJECT
public:
explicit DlgCreateToken(const QStringList &_predefinedTokens, QWidget *parent = nullptr);
[[nodiscard]] TokenInfo getTokenInfo() const;
protected:
void closeEvent(QCloseEvent *event) override;
private slots:
void faceDownCheckBoxToggled(bool checked);
void tokenSelectionChanged(const QModelIndex &current, const QModelIndex &previous);
void updateSearch(const QString &search);
void updatePreview();
void actChooseTokenFromAll(bool checked);
void actChooseTokenFromDeck(bool checked);
void actOk();
void actReject();
private:
CardDatabaseModel *cardDatabaseModel;
TokenDisplayModel *cardDatabaseDisplayModel;
QStringList predefinedTokens;
QLabel *nameLabel, *colorLabel, *ptLabel, *annotationLabel;
QComboBox *colorEdit;
QLineEdit *nameEdit, *ptEdit, *annotationEdit;
QCheckBox *destroyCheckBox;
QCheckBox *faceDownCheckBox;
QRadioButton *chooseTokenFromAllRadioButton, *chooseTokenFromDeckRadioButton;
TokenPreviewWidget *pic;
QTreeView *chooseTokenView;
[[nodiscard]] TokenInfo tokenDraft() const;
void updateSearchFieldWithoutUpdatingFilter(const QString &newValue) const;
};
#endif