mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
Remember past entries in "reveal card until X" window (#5755)
This commit is contained in:
parent
99376e75d6
commit
2e01dfd23a
4 changed files with 36 additions and 16 deletions
|
|
@ -3,7 +3,6 @@
|
||||||
#include "../game/cards/card_database.h"
|
#include "../game/cards/card_database.h"
|
||||||
#include "../game/cards/card_database_manager.h"
|
#include "../game/cards/card_database_manager.h"
|
||||||
#include "../game/filters/filter_string.h"
|
#include "../game/filters/filter_string.h"
|
||||||
#include "trice_limits.h"
|
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
@ -14,15 +13,17 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
DlgMoveTopCardsUntil::DlgMoveTopCardsUntil(QWidget *parent, QString _expr, uint _numberOfHits, bool autoPlay)
|
DlgMoveTopCardsUntil::DlgMoveTopCardsUntil(QWidget *parent, QStringList exprs, uint _numberOfHits, bool autoPlay)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
exprLabel = new QLabel(tr("Card name (or search expressions):"));
|
exprLabel = new QLabel(tr("Card name (or search expressions):"));
|
||||||
|
|
||||||
exprEdit = new QLineEdit(this);
|
exprComboBox = new QComboBox(this);
|
||||||
exprEdit->setFocus();
|
exprComboBox->setFocus();
|
||||||
exprEdit->setText(_expr);
|
exprComboBox->setEditable(true);
|
||||||
exprLabel->setBuddy(exprEdit);
|
exprComboBox->setInsertPolicy(QComboBox::InsertAtTop);
|
||||||
|
exprComboBox->insertItems(0, exprs);
|
||||||
|
exprLabel->setBuddy(exprComboBox);
|
||||||
|
|
||||||
numberOfHitsLabel = new QLabel(tr("Number of hits:"));
|
numberOfHitsLabel = new QLabel(tr("Number of hits:"));
|
||||||
numberOfHitsEdit = new QSpinBox(this);
|
numberOfHitsEdit = new QSpinBox(this);
|
||||||
|
|
@ -43,7 +44,7 @@ DlgMoveTopCardsUntil::DlgMoveTopCardsUntil(QWidget *parent, QString _expr, uint
|
||||||
|
|
||||||
auto *mainLayout = new QVBoxLayout;
|
auto *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(exprLabel);
|
mainLayout->addWidget(exprLabel);
|
||||||
mainLayout->addWidget(exprEdit);
|
mainLayout->addWidget(exprComboBox);
|
||||||
mainLayout->addItem(grid);
|
mainLayout->addItem(grid);
|
||||||
mainLayout->addWidget(autoPlayCheckBox);
|
mainLayout->addWidget(autoPlayCheckBox);
|
||||||
mainLayout->addWidget(buttonBox);
|
mainLayout->addWidget(buttonBox);
|
||||||
|
|
@ -92,7 +93,7 @@ bool DlgMoveTopCardsUntil::validateMatchExists(const FilterString &filterString)
|
||||||
|
|
||||||
void DlgMoveTopCardsUntil::validateAndAccept()
|
void DlgMoveTopCardsUntil::validateAndAccept()
|
||||||
{
|
{
|
||||||
auto movingCardsUntilFilter = FilterString(exprEdit->text());
|
auto movingCardsUntilFilter = FilterString(exprComboBox->currentText());
|
||||||
if (!movingCardsUntilFilter.valid()) {
|
if (!movingCardsUntilFilter.valid()) {
|
||||||
QMessageBox::warning(this, tr("Invalid filter"), movingCardsUntilFilter.error(), QMessageBox::Ok);
|
QMessageBox::warning(this, tr("Invalid filter"), movingCardsUntilFilter.error(), QMessageBox::Ok);
|
||||||
return;
|
return;
|
||||||
|
|
@ -102,12 +103,29 @@ void DlgMoveTopCardsUntil::validateAndAccept()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// move currently selected text to top of history list
|
||||||
|
if (exprComboBox->currentIndex() != 0) {
|
||||||
|
QString currentExpr = exprComboBox->currentText();
|
||||||
|
exprComboBox->removeItem(exprComboBox->currentIndex());
|
||||||
|
exprComboBox->insertItem(0, currentExpr);
|
||||||
|
exprComboBox->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DlgMoveTopCardsUntil::getExpr() const
|
QString DlgMoveTopCardsUntil::getExpr() const
|
||||||
{
|
{
|
||||||
return exprEdit->text();
|
return exprComboBox->currentText();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList DlgMoveTopCardsUntil::getExprs() const
|
||||||
|
{
|
||||||
|
QStringList exprs;
|
||||||
|
for (int i = 0; i < exprComboBox->count(); ++i) {
|
||||||
|
exprs.append(exprComboBox->itemText(i));
|
||||||
|
}
|
||||||
|
return exprs;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint DlgMoveTopCardsUntil::getNumberOfHits() const
|
uint DlgMoveTopCardsUntil::getNumberOfHits() const
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
#define DLG_MOVE_TOP_CARDS_UNTIL_H
|
#define DLG_MOVE_TOP_CARDS_UNTIL_H
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
|
||||||
class FilterString;
|
class FilterString;
|
||||||
|
|
@ -15,7 +15,7 @@ class DlgMoveTopCardsUntil : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QLabel *exprLabel, *numberOfHitsLabel;
|
QLabel *exprLabel, *numberOfHitsLabel;
|
||||||
QLineEdit *exprEdit;
|
QComboBox *exprComboBox;
|
||||||
QSpinBox *numberOfHitsEdit;
|
QSpinBox *numberOfHitsEdit;
|
||||||
QDialogButtonBox *buttonBox;
|
QDialogButtonBox *buttonBox;
|
||||||
QCheckBox *autoPlayCheckBox;
|
QCheckBox *autoPlayCheckBox;
|
||||||
|
|
@ -25,10 +25,11 @@ class DlgMoveTopCardsUntil : public QDialog
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DlgMoveTopCardsUntil(QWidget *parent = nullptr,
|
explicit DlgMoveTopCardsUntil(QWidget *parent = nullptr,
|
||||||
QString expr = QString(),
|
QStringList exprs = QStringList(),
|
||||||
uint numberOfHits = 1,
|
uint numberOfHits = 1,
|
||||||
bool autoPlay = false);
|
bool autoPlay = false);
|
||||||
QString getExpr() const;
|
QString getExpr() const;
|
||||||
|
QStringList getExprs() const;
|
||||||
uint getNumberOfHits() const;
|
uint getNumberOfHits() const;
|
||||||
bool isAutoPlay() const;
|
bool isAutoPlay() const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1443,19 +1443,20 @@ void Player::actMoveTopCardsUntil()
|
||||||
{
|
{
|
||||||
stopMoveTopCardsUntil();
|
stopMoveTopCardsUntil();
|
||||||
|
|
||||||
DlgMoveTopCardsUntil dlg(game, movingCardsUntilExpr, movingCardsUntilNumberOfHits, movingCardsUntilAutoPlay);
|
DlgMoveTopCardsUntil dlg(game, movingCardsUntilExprs, movingCardsUntilNumberOfHits, movingCardsUntilAutoPlay);
|
||||||
if (!dlg.exec()) {
|
if (!dlg.exec()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
movingCardsUntilExpr = dlg.getExpr();
|
auto expr = dlg.getExpr();
|
||||||
|
movingCardsUntilExprs = dlg.getExprs();
|
||||||
movingCardsUntilNumberOfHits = dlg.getNumberOfHits();
|
movingCardsUntilNumberOfHits = dlg.getNumberOfHits();
|
||||||
movingCardsUntilAutoPlay = dlg.isAutoPlay();
|
movingCardsUntilAutoPlay = dlg.isAutoPlay();
|
||||||
|
|
||||||
if (zones.value("deck")->getCards().empty()) {
|
if (zones.value("deck")->getCards().empty()) {
|
||||||
stopMoveTopCardsUntil();
|
stopMoveTopCardsUntil();
|
||||||
} else {
|
} else {
|
||||||
movingCardsUntilFilter = FilterString(movingCardsUntilExpr);
|
movingCardsUntilFilter = FilterString(expr);
|
||||||
movingCardsUntilCounter = movingCardsUntilNumberOfHits;
|
movingCardsUntilCounter = movingCardsUntilNumberOfHits;
|
||||||
movingCardsUntil = true;
|
movingCardsUntil = true;
|
||||||
actMoveTopCardToPlay();
|
actMoveTopCardToPlay();
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ private:
|
||||||
|
|
||||||
bool movingCardsUntil;
|
bool movingCardsUntil;
|
||||||
QTimer *moveTopCardTimer;
|
QTimer *moveTopCardTimer;
|
||||||
QString movingCardsUntilExpr = {};
|
QStringList movingCardsUntilExprs = {};
|
||||||
int movingCardsUntilNumberOfHits = 1;
|
int movingCardsUntilNumberOfHits = 1;
|
||||||
bool movingCardsUntilAutoPlay = false;
|
bool movingCardsUntilAutoPlay = false;
|
||||||
FilterString movingCardsUntilFilter;
|
FilterString movingCardsUntilFilter;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue