mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
[DeckAnalytics] Add a checkbox to include/exclude sideboard for calculation
Took 15 minutes
This commit is contained in:
parent
58a8c7d3df
commit
1639f2e310
4 changed files with 29 additions and 1 deletions
|
|
@ -29,10 +29,14 @@ DeckAnalyticsWidget::DeckAnalyticsWidget(QWidget *parent, DeckListStatisticsAnal
|
|||
removeButton = new QPushButton(this);
|
||||
saveButton = new QPushButton(this);
|
||||
loadButton = new QPushButton(this);
|
||||
includeSideboardCheckBox = new QCheckBox(this);
|
||||
includeSideboardCheckBox->setChecked(true);
|
||||
|
||||
controlLayout->addWidget(addButton);
|
||||
controlLayout->addWidget(removeButton);
|
||||
controlLayout->addWidget(saveButton);
|
||||
controlLayout->addWidget(loadButton);
|
||||
controlLayout->addWidget(includeSideboardCheckBox);
|
||||
|
||||
layout->addWidget(controlContainer);
|
||||
|
||||
|
|
@ -40,6 +44,7 @@ DeckAnalyticsWidget::DeckAnalyticsWidget(QWidget *parent, DeckListStatisticsAnal
|
|||
connect(removeButton, &QPushButton::clicked, this, &DeckAnalyticsWidget::onRemoveSelected);
|
||||
connect(saveButton, &QPushButton::clicked, this, &DeckAnalyticsWidget::saveLayout);
|
||||
connect(loadButton, &QPushButton::clicked, this, &DeckAnalyticsWidget::loadLayout);
|
||||
connect(includeSideboardCheckBox, &QCheckBox::clicked, this, &DeckAnalyticsWidget::includeSideboardChanged);
|
||||
|
||||
// Scroll area and container
|
||||
scrollArea = new QScrollArea(this);
|
||||
|
|
@ -66,6 +71,13 @@ void DeckAnalyticsWidget::retranslateUi()
|
|||
removeButton->setText(tr("Remove Panel"));
|
||||
saveButton->setText(tr("Save Layout"));
|
||||
loadButton->setText(tr("Load Layout"));
|
||||
includeSideboardCheckBox->setText(tr("Include Sideboard"));
|
||||
}
|
||||
|
||||
void DeckAnalyticsWidget::includeSideboardChanged(bool checked)
|
||||
{
|
||||
statsAnalyzer->getConfig().includeSideboard = checked;
|
||||
updateDisplays();
|
||||
}
|
||||
|
||||
void DeckAnalyticsWidget::updateDisplays()
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "deck_list_statistics_analyzer.h"
|
||||
#include "resizable_panel.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QJsonObject>
|
||||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
|
|
@ -29,6 +30,7 @@ public slots:
|
|||
public:
|
||||
explicit DeckAnalyticsWidget(QWidget *parent, DeckListStatisticsAnalyzer *analyzer);
|
||||
void retranslateUi();
|
||||
void includeSideboardChanged(bool checked);
|
||||
|
||||
private slots:
|
||||
void onAddPanel();
|
||||
|
|
@ -57,6 +59,8 @@ private:
|
|||
QPushButton *saveButton;
|
||||
QPushButton *loadButton;
|
||||
|
||||
QCheckBox *includeSideboardCheckBox;
|
||||
|
||||
QScrollArea *scrollArea;
|
||||
QWidget *panelContainer;
|
||||
QVBoxLayout *panelLayout;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,13 @@ void DeckListStatisticsAnalyzer::analyze()
|
|||
{
|
||||
clearData();
|
||||
|
||||
QList<const DecklistCardNode *> nodes = model->getCardNodes();
|
||||
QList<const DecklistCardNode *> nodes;
|
||||
|
||||
if (config.includeSideboard) {
|
||||
nodes = model->getCardNodes();
|
||||
} else {
|
||||
nodes = model->getCardNodesForZone(DECK_ZONE_MAIN);
|
||||
}
|
||||
|
||||
for (auto node : nodes) {
|
||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(node->getName());
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ struct DeckListStatisticsAnalyzerConfig
|
|||
bool computeCategories = true;
|
||||
bool computeCurveBreakdowns = true;
|
||||
bool computeProbabilities = true;
|
||||
bool includeSideboard = true;
|
||||
};
|
||||
|
||||
class DeckListStatisticsAnalyzer : public QObject
|
||||
|
|
@ -133,6 +134,11 @@ public:
|
|||
return model;
|
||||
}
|
||||
|
||||
DeckListStatisticsAnalyzerConfig &getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
signals:
|
||||
void statsUpdated();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue