mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-20 09:22:15 -07:00
implement thing
This commit is contained in:
parent
2c3a15208a
commit
a20820a9cd
8 changed files with 78 additions and 62 deletions
|
|
@ -31,7 +31,7 @@ ZoneViewZone::ZoneViewZone(Player *_p,
|
|||
QGraphicsItem *parent)
|
||||
: SelectZone(_p, _origZone->getName(), false, false, true, parent, true), bRect(QRectF()), minRows(0),
|
||||
numberCards(_numberCards), origZone(_origZone), revealZone(_revealZone),
|
||||
writeableRevealZone(_writeableRevealZone), sortByName(false), sortByType(false)
|
||||
writeableRevealZone(_writeableRevealZone), groupBy(CardList::NoSort), sortBy(CardList::NoSort)
|
||||
{
|
||||
if (!(revealZone && !writeableRevealZone)) {
|
||||
origZone->getViews().append(this);
|
||||
|
|
@ -116,20 +116,25 @@ void ZoneViewZone::reorganizeCards()
|
|||
|
||||
// sort cards
|
||||
QList<CardList::SortOption> sortOptions;
|
||||
if (sortByType) {
|
||||
sortOptions << CardList::SortByType;
|
||||
if (groupBy != CardList::NoSort) {
|
||||
sortOptions << groupBy;
|
||||
}
|
||||
|
||||
if (sortByName) {
|
||||
sortOptions << CardList::SortByName;
|
||||
if (sortBy != CardList::NoSort) {
|
||||
sortOptions << sortBy;
|
||||
|
||||
// implicitly sort by name at the end so that cards with the same name appear together
|
||||
if (sortBy != CardList::SortByName) {
|
||||
sortOptions << CardList::SortByName;
|
||||
}
|
||||
}
|
||||
|
||||
cardsToDisplay.sortBy(sortOptions);
|
||||
|
||||
// position cards
|
||||
GridSize gridSize;
|
||||
if (pileView && sortByType) {
|
||||
gridSize = positionCardsForDisplay(cardsToDisplay, CardList::SortByType);
|
||||
if (pileView) {
|
||||
gridSize = positionCardsForDisplay(cardsToDisplay, groupBy);
|
||||
} else {
|
||||
gridSize = positionCardsForDisplay(cardsToDisplay);
|
||||
}
|
||||
|
|
@ -217,17 +222,15 @@ ZoneViewZone::GridSize ZoneViewZone::positionCardsForDisplay(CardList &cards, Ca
|
|||
}
|
||||
}
|
||||
|
||||
void ZoneViewZone::setSortByName(int _sortByName)
|
||||
void ZoneViewZone::setGroupBy(CardList::SortOption _groupBy)
|
||||
{
|
||||
sortByName = _sortByName;
|
||||
groupBy = _groupBy;
|
||||
reorganizeCards();
|
||||
}
|
||||
|
||||
void ZoneViewZone::setSortByType(int _sortByType)
|
||||
void ZoneViewZone::setSortBy(CardList::SortOption _sortBy)
|
||||
{
|
||||
sortByType = _sortByType;
|
||||
if (!sortByType)
|
||||
pileView = false;
|
||||
sortBy = _sortBy;
|
||||
reorganizeCards();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ private:
|
|||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint);
|
||||
CardZone *origZone;
|
||||
bool revealZone, writeableRevealZone;
|
||||
bool sortByName, sortByType;
|
||||
CardList::SortOption groupBy, sortBy;
|
||||
bool pileView;
|
||||
|
||||
struct GridSize
|
||||
|
|
@ -75,8 +75,8 @@ public:
|
|||
}
|
||||
void setWriteableRevealZone(bool _writeableRevealZone);
|
||||
public slots:
|
||||
void setSortByName(int _sortByName);
|
||||
void setSortByType(int _sortByType);
|
||||
void setGroupBy(CardList::SortOption _groupBy);
|
||||
void setSortBy(CardList::SortOption _sortBy);
|
||||
void setPileView(int _pileView);
|
||||
private slots:
|
||||
void zoneDumpReceived(const Response &r);
|
||||
|
|
|
|||
|
|
@ -46,16 +46,30 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
|||
QGraphicsLinearLayout *hPilebox = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||
QGraphicsLinearLayout *hFilterbox = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||
|
||||
QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget;
|
||||
sortByNameProxy->setWidget(&sortByNameCheckBox);
|
||||
hFilterbox->addItem(sortByNameProxy);
|
||||
// groupBy options
|
||||
groupBySelector.addItem(tr("Group by ---"), CardList::NoSort);
|
||||
groupBySelector.addItem(tr("Group by Type"), CardList::SortByType);
|
||||
groupBySelector.addItem(tr("Group by Mana Value"), CardList::SortByManaValue);
|
||||
|
||||
QGraphicsProxyWidget *sortByTypeProxy = new QGraphicsProxyWidget;
|
||||
sortByTypeProxy->setWidget(&sortByTypeCheckBox);
|
||||
hFilterbox->addItem(sortByTypeProxy);
|
||||
QGraphicsProxyWidget *groupBySelectorProxy = new QGraphicsProxyWidget;
|
||||
groupBySelectorProxy->setWidget(&groupBySelector);
|
||||
groupBySelectorProxy->setZValue(2000000008);
|
||||
hFilterbox->addItem(groupBySelectorProxy);
|
||||
|
||||
// sortBy options
|
||||
sortBySelector.addItem(tr("Sort by ---"), CardList::NoSort);
|
||||
sortBySelector.addItem(tr("Sort by Name"), CardList::SortByName);
|
||||
sortBySelector.addItem(tr("Sort by Type"), CardList::SortByType);
|
||||
sortBySelector.addItem(tr("Sort by Mana Value"), CardList::SortByManaValue);
|
||||
|
||||
QGraphicsProxyWidget *sortBySelectorProxy = new QGraphicsProxyWidget;
|
||||
sortBySelectorProxy->setWidget(&sortBySelector);
|
||||
sortBySelectorProxy->setZValue(2000000007);
|
||||
hFilterbox->addItem(sortBySelectorProxy);
|
||||
|
||||
vbox->addItem(hFilterbox);
|
||||
|
||||
// line
|
||||
QGraphicsProxyWidget *lineProxy = new QGraphicsProxyWidget;
|
||||
QFrame *line = new QFrame;
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
|
|
@ -63,10 +77,12 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
|||
lineProxy->setWidget(line);
|
||||
vbox->addItem(lineProxy);
|
||||
|
||||
// pile view options
|
||||
QGraphicsProxyWidget *pileViewProxy = new QGraphicsProxyWidget;
|
||||
pileViewProxy->setWidget(&pileViewCheckBox);
|
||||
hPilebox->addItem(pileViewProxy);
|
||||
|
||||
// shuffle options
|
||||
if (_origZone->getIsShufflable() && numberCards == -1) {
|
||||
shuffleCheckBox.setChecked(true);
|
||||
QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget;
|
||||
|
|
@ -104,14 +120,12 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
|||
|
||||
// only wire up sort options after creating ZoneViewZone, since it segfaults otherwise.
|
||||
if (numberCards < 0) {
|
||||
connect(&sortByNameCheckBox, &QCheckBox::QT_STATE_CHANGED, this, &ZoneViewWidget::processSortByName);
|
||||
connect(&sortByTypeCheckBox, &QCheckBox::QT_STATE_CHANGED, this, &ZoneViewWidget::processSortByType);
|
||||
connect(&groupBySelector, &QComboBox::currentIndexChanged, this, &ZoneViewWidget::processGroupBy);
|
||||
connect(&sortBySelector, &QComboBox::currentIndexChanged, this, &ZoneViewWidget::processSortBy);
|
||||
connect(&pileViewCheckBox, &QCheckBox::QT_STATE_CHANGED, this, &ZoneViewWidget::processSetPileView);
|
||||
sortByNameCheckBox.setChecked(SettingsCache::instance().getZoneViewSortByName());
|
||||
sortByTypeCheckBox.setChecked(SettingsCache::instance().getZoneViewSortByType());
|
||||
groupBySelector.setCurrentIndex(groupBySelector.findData(SettingsCache::instance().getZoneViewGroupBy()));
|
||||
sortBySelector.setCurrentIndex(sortBySelector.findData(SettingsCache::instance().getZoneViewSortBy()));
|
||||
pileViewCheckBox.setChecked(SettingsCache::instance().getZoneViewPileView());
|
||||
if (!SettingsCache::instance().getZoneViewSortByType())
|
||||
pileViewCheckBox.setEnabled(false);
|
||||
}
|
||||
|
||||
retranslateUi();
|
||||
|
|
@ -122,18 +136,18 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
|||
zone->initializeCards(cardList);
|
||||
}
|
||||
|
||||
void ZoneViewWidget::processSortByType(QT_STATE_CHANGED_T value)
|
||||
void ZoneViewWidget::processGroupBy(int index)
|
||||
{
|
||||
pileViewCheckBox.setEnabled(value);
|
||||
SettingsCache::instance().setZoneViewSortByType(value);
|
||||
zone->setPileView(pileViewCheckBox.isChecked());
|
||||
zone->setSortByType(value);
|
||||
auto option = static_cast<CardList::SortOption>(groupBySelector.itemData(index).toInt());
|
||||
SettingsCache::instance().setZoneViewGroupBy(option);
|
||||
zone->setGroupBy(option);
|
||||
}
|
||||
|
||||
void ZoneViewWidget::processSortByName(QT_STATE_CHANGED_T value)
|
||||
void ZoneViewWidget::processSortBy(int index)
|
||||
{
|
||||
SettingsCache::instance().setZoneViewSortByName(value);
|
||||
zone->setSortByName(value);
|
||||
auto option = static_cast<CardList::SortOption>(sortBySelector.itemData(index).toInt());
|
||||
SettingsCache::instance().setZoneViewSortBy(option);
|
||||
zone->setSortBy(option);
|
||||
}
|
||||
|
||||
void ZoneViewWidget::processSetPileView(QT_STATE_CHANGED_T value)
|
||||
|
|
@ -145,8 +159,6 @@ void ZoneViewWidget::processSetPileView(QT_STATE_CHANGED_T value)
|
|||
void ZoneViewWidget::retranslateUi()
|
||||
{
|
||||
setWindowTitle(zone->getTranslatedName(false, CaseNominative));
|
||||
sortByNameCheckBox.setText(tr("sort by name"));
|
||||
sortByTypeCheckBox.setText(tr("sort by type"));
|
||||
shuffleCheckBox.setText(tr("shuffle when closing"));
|
||||
pileViewCheckBox.setText(tr("pile view"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "../../utility/macros.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
|
|
@ -14,7 +15,6 @@ class ZoneViewZone;
|
|||
class Player;
|
||||
class CardDatabase;
|
||||
class QScrollBar;
|
||||
class QCheckBox;
|
||||
class GameScene;
|
||||
class ServerInfo_Card;
|
||||
class QGraphicsSceneMouseEvent;
|
||||
|
|
@ -47,8 +47,8 @@ private:
|
|||
QPushButton *closeButton;
|
||||
QScrollBar *scrollBar;
|
||||
ScrollableGraphicsProxyWidget *scrollBarProxy;
|
||||
QCheckBox sortByNameCheckBox;
|
||||
QCheckBox sortByTypeCheckBox;
|
||||
QComboBox groupBySelector;
|
||||
QComboBox sortBySelector;
|
||||
QCheckBox shuffleCheckBox;
|
||||
QCheckBox pileViewCheckBox;
|
||||
|
||||
|
|
@ -58,8 +58,8 @@ private:
|
|||
signals:
|
||||
void closePressed(ZoneViewWidget *zv);
|
||||
private slots:
|
||||
void processSortByType(QT_STATE_CHANGED_T value);
|
||||
void processSortByName(QT_STATE_CHANGED_T value);
|
||||
void processGroupBy(int value);
|
||||
void processSortBy(int value);
|
||||
void processSetPileView(QT_STATE_CHANGED_T value);
|
||||
void resizeToZoneContents();
|
||||
void handleScrollBarChange(int value);
|
||||
|
|
|
|||
|
|
@ -252,8 +252,8 @@ SettingsCache::SettingsCache()
|
|||
chatMentionColor = settings->value("chat/mentioncolor", "A6120D").toString();
|
||||
chatHighlightColor = settings->value("chat/highlightcolor", "A6120D").toString();
|
||||
|
||||
zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool();
|
||||
zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool();
|
||||
zoneViewGroupBy = settings->value("zoneview/groupby", 2).toInt();
|
||||
zoneViewSortBy = settings->value("zoneview/sortby", 1).toInt();
|
||||
zoneViewPileView = settings->value("zoneview/pileview", true).toBool();
|
||||
|
||||
soundEnabled = settings->value("sound/enabled", false).toBool();
|
||||
|
|
@ -582,16 +582,16 @@ void SettingsCache::setChatHighlightColor(const QString &_chatHighlightColor)
|
|||
settings->setValue("chat/highlightcolor", chatHighlightColor);
|
||||
}
|
||||
|
||||
void SettingsCache::setZoneViewSortByName(QT_STATE_CHANGED_T _zoneViewSortByName)
|
||||
void SettingsCache::setZoneViewGroupBy(int _zoneViewGroupBy)
|
||||
{
|
||||
zoneViewSortByName = static_cast<bool>(_zoneViewSortByName);
|
||||
settings->setValue("zoneview/sortbyname", zoneViewSortByName);
|
||||
zoneViewGroupBy = _zoneViewGroupBy;
|
||||
settings->setValue("zoneview/groupby", zoneViewGroupBy);
|
||||
}
|
||||
|
||||
void SettingsCache::setZoneViewSortByType(QT_STATE_CHANGED_T _zoneViewSortByType)
|
||||
void SettingsCache::setZoneViewSortBy(int _zoneViewSortBy)
|
||||
{
|
||||
zoneViewSortByType = static_cast<bool>(_zoneViewSortByType);
|
||||
settings->setValue("zoneview/sortbytype", zoneViewSortByType);
|
||||
zoneViewSortBy = _zoneViewSortBy;
|
||||
settings->setValue("zoneview/sortby", zoneViewSortBy);
|
||||
}
|
||||
|
||||
void SettingsCache::setZoneViewPileView(QT_STATE_CHANGED_T _zoneViewPileView)
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ private:
|
|||
QString chatHighlightColor;
|
||||
bool chatMentionForeground;
|
||||
bool chatHighlightForeground;
|
||||
bool zoneViewSortByName, zoneViewSortByType, zoneViewPileView;
|
||||
int zoneViewSortBy, zoneViewGroupBy;
|
||||
bool zoneViewPileView;
|
||||
bool soundEnabled;
|
||||
QString soundThemeName;
|
||||
bool ignoreUnregisteredUsers;
|
||||
|
|
@ -327,13 +328,13 @@ public:
|
|||
{
|
||||
return chatHighlightForeground;
|
||||
}
|
||||
bool getZoneViewSortByName() const
|
||||
int getZoneViewGroupBy() const
|
||||
{
|
||||
return zoneViewSortByName;
|
||||
return zoneViewGroupBy;
|
||||
}
|
||||
bool getZoneViewSortByType() const
|
||||
int getZoneViewSortBy() const
|
||||
{
|
||||
return zoneViewSortByType;
|
||||
return zoneViewSortBy;
|
||||
}
|
||||
/**
|
||||
Returns if the view should be sorted into pile view.
|
||||
|
|
@ -563,8 +564,8 @@ public slots:
|
|||
void setChatMentionCompleter(QT_STATE_CHANGED_T _chatMentionCompleter);
|
||||
void setChatMentionForeground(QT_STATE_CHANGED_T _chatMentionForeground);
|
||||
void setChatHighlightForeground(QT_STATE_CHANGED_T _chatHighlightForeground);
|
||||
void setZoneViewSortByName(QT_STATE_CHANGED_T _zoneViewSortByName);
|
||||
void setZoneViewSortByType(QT_STATE_CHANGED_T _zoneViewSortByType);
|
||||
void setZoneViewGroupBy(const int _zoneViewGroupBy);
|
||||
void setZoneViewSortBy(const int _zoneViewSortBy);
|
||||
void setZoneViewPileView(QT_STATE_CHANGED_T _zoneViewPileView);
|
||||
void setSoundEnabled(QT_STATE_CHANGED_T _soundEnabled);
|
||||
void setSoundThemeName(const QString &_soundThemeName);
|
||||
|
|
|
|||
|
|
@ -184,10 +184,10 @@ void SettingsCache::setChatMentionColor(const QString & /* _chatMentionColor */)
|
|||
void SettingsCache::setChatHighlightColor(const QString & /* _chatHighlightColor */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setZoneViewSortByName(QT_STATE_CHANGED_T /* _zoneViewSortByName */)
|
||||
void SettingsCache::setZoneViewGroupBy(int /* _zoneViewSortByName */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setZoneViewSortByType(QT_STATE_CHANGED_T /* _zoneViewSortByType */)
|
||||
void SettingsCache::setZoneViewSortBy(int /* _zoneViewSortByType */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setZoneViewPileView(QT_STATE_CHANGED_T /* _zoneViewPileView */)
|
||||
|
|
|
|||
|
|
@ -188,10 +188,10 @@ void SettingsCache::setChatMentionColor(const QString & /* _chatMentionColor */)
|
|||
void SettingsCache::setChatHighlightColor(const QString & /* _chatHighlightColor */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setZoneViewSortByName(QT_STATE_CHANGED_T /* _zoneViewSortByName */)
|
||||
void SettingsCache::setZoneViewGroupBy(int /* _zoneViewGroupBy */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setZoneViewSortByType(QT_STATE_CHANGED_T /* _zoneViewSortByType */)
|
||||
void SettingsCache::setZoneViewSortBy(int /* _zoneViewSortBy */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setZoneViewPileView(QT_STATE_CHANGED_T /* _zoneViewPileView */)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue