mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 18:43:55 -07:00
[VDE] Sample Hand Improvements (#5917)
* Actually call retranslateUi, add spinBox to change sample hand size, add card size slider. * Lint. * Fix include. * Fix include again. * Fix overloads. * Update visual_deck_editor_sample_hand_widget.cpp --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de> Co-authored-by: Zach H <zahalpern+github@gmail.com>
This commit is contained in:
parent
05914e38f0
commit
34400c7f60
6 changed files with 57 additions and 4 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../../../../deck/deck_loader.h"
|
||||
#include "../../../../game/cards/card_database_manager.h"
|
||||
#include "../../../../settings/cache_settings.h"
|
||||
#include "../cards/card_info_picture_widget.h"
|
||||
|
||||
#include <random>
|
||||
|
|
@ -12,23 +13,45 @@ VisualDeckEditorSampleHandWidget::VisualDeckEditorSampleHandWidget(QWidget *pare
|
|||
layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
resetAndHandSizeContainerWidget = new QWidget(this);
|
||||
resetAndHandSizeLayout = new QHBoxLayout(resetAndHandSizeContainerWidget);
|
||||
resetAndHandSizeContainerWidget->setLayout(resetAndHandSizeLayout);
|
||||
|
||||
resetButton = new QPushButton(this);
|
||||
connect(resetButton, SIGNAL(clicked()), this, SLOT(updateDisplay()));
|
||||
layout->addWidget(resetButton);
|
||||
resetAndHandSizeLayout->addWidget(resetButton);
|
||||
|
||||
handSizeSpinBox = new QSpinBox(this);
|
||||
handSizeSpinBox->setValue(SettingsCache::instance().getVisualDeckEditorSampleHandSize());
|
||||
handSizeSpinBox->setMinimum(1);
|
||||
connect(handSizeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), &SettingsCache::instance(),
|
||||
&SettingsCache::setVisualDeckEditorSampleHandSize);
|
||||
connect(handSizeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this,
|
||||
&VisualDeckEditorSampleHandWidget::updateDisplay);
|
||||
resetAndHandSizeLayout->addWidget(handSizeSpinBox);
|
||||
|
||||
layout->addWidget(resetAndHandSizeContainerWidget);
|
||||
|
||||
flowWidget = new FlowWidget(this, Qt::Horizontal, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
|
||||
layout->addWidget(flowWidget);
|
||||
|
||||
for (CardInfoPtr card : getRandomCards(7)) {
|
||||
cardSizeWidget = new CardSizeWidget(this, flowWidget);
|
||||
layout->addWidget(cardSizeWidget);
|
||||
|
||||
for (CardInfoPtr card : getRandomCards(handSizeSpinBox->value())) {
|
||||
auto displayWidget = new CardInfoPictureWidget(this);
|
||||
displayWidget->setCard(card);
|
||||
displayWidget->setScaleFactor(cardSizeWidget->getSlider()->value());
|
||||
flowWidget->addWidget(displayWidget);
|
||||
}
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void VisualDeckEditorSampleHandWidget::retranslateUi()
|
||||
{
|
||||
resetButton->setText(tr("Reset"));
|
||||
resetButton->setText(tr("Draw a new sample hand"));
|
||||
handSizeSpinBox->setToolTip(tr("Sample hand size"));
|
||||
}
|
||||
|
||||
void VisualDeckEditorSampleHandWidget::setDeckModel(DeckListModel *deckModel)
|
||||
|
|
@ -41,9 +64,12 @@ void VisualDeckEditorSampleHandWidget::setDeckModel(DeckListModel *deckModel)
|
|||
void VisualDeckEditorSampleHandWidget::updateDisplay()
|
||||
{
|
||||
flowWidget->clearLayout();
|
||||
for (CardInfoPtr card : getRandomCards(7)) {
|
||||
for (CardInfoPtr card : getRandomCards(handSizeSpinBox->value())) {
|
||||
auto displayWidget = new CardInfoPictureWidget(this);
|
||||
displayWidget->setCard(card);
|
||||
displayWidget->setScaleFactor(cardSizeWidget->getSlider()->value());
|
||||
connect(cardSizeWidget->getSlider(), &QSlider::valueChanged, displayWidget,
|
||||
&CardInfoPictureWidget::setScaleFactor);
|
||||
flowWidget->addWidget(displayWidget);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
#ifndef VISUAL_DECK_EDITOR_SAMPLE_HAND_WIDGET_H
|
||||
#define VISUAL_DECK_EDITOR_SAMPLE_HAND_WIDGET_H
|
||||
|
||||
#include "../../../../client/ui/widgets/cards/card_size_widget.h"
|
||||
#include "../../../../deck/deck_list_model.h"
|
||||
#include "../general/layout_containers/flow_widget.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
#include <QWidget>
|
||||
|
||||
class VisualDeckEditorSampleHandWidget : public QWidget
|
||||
|
|
@ -22,8 +24,12 @@ public slots:
|
|||
private:
|
||||
DeckListModel *deckListModel;
|
||||
QVBoxLayout *layout;
|
||||
QWidget *resetAndHandSizeContainerWidget;
|
||||
QHBoxLayout *resetAndHandSizeLayout;
|
||||
QPushButton *resetButton;
|
||||
QSpinBox *handSizeSpinBox;
|
||||
FlowWidget *flowWidget;
|
||||
CardSizeWidget *cardSizeWidget;
|
||||
};
|
||||
|
||||
#endif // VISUAL_DECK_EDITOR_SAMPLE_HAND_WIDGET_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue