mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-11 21:04:07 -07:00
revert
This commit is contained in:
parent
107c5a4160
commit
add0e19c34
3 changed files with 28 additions and 13 deletions
|
|
@ -26,11 +26,9 @@ HandMenu::HandMenu(Player *_player, PlayerActions *actions, QWidget *parent) : T
|
|||
aSortHandByManaValue = new QAction(this);
|
||||
aSortHandByManaValue->setData(CardList::SortByManaValue);
|
||||
|
||||
connect(aSortHandByType, &QAction::triggered, actions, [actions] { actions->actSortHand({}); });
|
||||
connect(aSortHandByName, &QAction::triggered, actions,
|
||||
[actions] { actions->actSortHand({CardList::SortByMainType, CardList::SortByManaValue}); });
|
||||
connect(aSortHandByManaValue, &QAction::triggered, actions,
|
||||
[actions] { actions->actSortHand({CardList::SortByManaValue, CardList::SortByColors}); });
|
||||
connect(aSortHandByType, &QAction::triggered, actions, &PlayerActions::actSortHand);
|
||||
connect(aSortHandByName, &QAction::triggered, actions, &PlayerActions::actSortHand);
|
||||
connect(aSortHandByManaValue, &QAction::triggered, actions, &PlayerActions::actSortHand);
|
||||
|
||||
mSortHand->addAction(aSortHandByName);
|
||||
mSortHand->addAction(aSortHandByType);
|
||||
|
|
|
|||
|
|
@ -140,13 +140,32 @@ void PlayerActions::actViewHand()
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Sorts the cards in the hand using the given sort options.
|
||||
* Appends SortByName and SortByPrinting to the end of the list, so that names and printings are grouped together.
|
||||
*
|
||||
* @param sortOptions The non-default options to sort the cards by.
|
||||
* @brief The sortHand actions only pass along a single SortOption in its data.
|
||||
* This method fills out the rest of the sort priority list given that option.
|
||||
* @param option The single sort option
|
||||
* @return The sort priority list
|
||||
*/
|
||||
void PlayerActions::actSortHand(const QList<CardList::SortOption> &sortOptions)
|
||||
static QList<CardList::SortOption> expandSortOption(CardList::SortOption option)
|
||||
{
|
||||
switch (option) {
|
||||
case CardList::SortByName:
|
||||
return {};
|
||||
case CardList::SortByMainType:
|
||||
return {CardList::SortByMainType, CardList::SortByManaValue};
|
||||
case CardList::SortByManaValue:
|
||||
return {CardList::SortByManaValue, CardList::SortByColors};
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerActions::actSortHand()
|
||||
{
|
||||
auto *action = qobject_cast<QAction *>(sender());
|
||||
CardList::SortOption option = static_cast<CardList::SortOption>(action->data().toInt());
|
||||
|
||||
QList<CardList::SortOption> sortOptions = expandSortOption(option);
|
||||
|
||||
static QList defaultOptions = {CardList::SortByName, CardList::SortByPrinting};
|
||||
|
||||
player->getGraphicsItem()->getHandZoneGraphicsItem()->sortHand(sortOptions + defaultOptions);
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
#ifndef COCKATRICE_PLAYER_ACTIONS_H
|
||||
#define COCKATRICE_PLAYER_ACTIONS_H
|
||||
|
||||
#include "../board/card_list.h"
|
||||
#include "event_processing_options.h"
|
||||
#include "player.h"
|
||||
|
||||
|
|
@ -154,7 +152,7 @@ public slots:
|
|||
void actRevealRandomHandCard(int revealToPlayerId);
|
||||
void actRevealLibrary(int revealToPlayerId);
|
||||
|
||||
void actSortHand(const QList<CardList::SortOption> &sortOptions);
|
||||
void actSortHand();
|
||||
|
||||
void cardMenuAction();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue