mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 06:22:15 -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 = new QAction(this);
|
||||||
aSortHandByManaValue->setData(CardList::SortByManaValue);
|
aSortHandByManaValue->setData(CardList::SortByManaValue);
|
||||||
|
|
||||||
connect(aSortHandByType, &QAction::triggered, actions, [actions] { actions->actSortHand({}); });
|
connect(aSortHandByType, &QAction::triggered, actions, &PlayerActions::actSortHand);
|
||||||
connect(aSortHandByName, &QAction::triggered, actions,
|
connect(aSortHandByName, &QAction::triggered, actions, &PlayerActions::actSortHand);
|
||||||
[actions] { actions->actSortHand({CardList::SortByMainType, CardList::SortByManaValue}); });
|
connect(aSortHandByManaValue, &QAction::triggered, actions, &PlayerActions::actSortHand);
|
||||||
connect(aSortHandByManaValue, &QAction::triggered, actions,
|
|
||||||
[actions] { actions->actSortHand({CardList::SortByManaValue, CardList::SortByColors}); });
|
|
||||||
|
|
||||||
mSortHand->addAction(aSortHandByName);
|
mSortHand->addAction(aSortHandByName);
|
||||||
mSortHand->addAction(aSortHandByType);
|
mSortHand->addAction(aSortHandByType);
|
||||||
|
|
|
||||||
|
|
@ -140,13 +140,32 @@ void PlayerActions::actViewHand()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sorts the cards in the hand using the given sort options.
|
* @brief The sortHand actions only pass along a single SortOption in its data.
|
||||||
* Appends SortByName and SortByPrinting to the end of the list, so that names and printings are grouped together.
|
* This method fills out the rest of the sort priority list given that option.
|
||||||
*
|
* @param option The single sort option
|
||||||
* @param sortOptions The non-default options to sort the cards by.
|
* @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};
|
static QList defaultOptions = {CardList::SortByName, CardList::SortByPrinting};
|
||||||
|
|
||||||
player->getGraphicsItem()->getHandZoneGraphicsItem()->sortHand(sortOptions + defaultOptions);
|
player->getGraphicsItem()->getHandZoneGraphicsItem()->sortHand(sortOptions + defaultOptions);
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
#ifndef COCKATRICE_PLAYER_ACTIONS_H
|
#ifndef COCKATRICE_PLAYER_ACTIONS_H
|
||||||
#define COCKATRICE_PLAYER_ACTIONS_H
|
#define COCKATRICE_PLAYER_ACTIONS_H
|
||||||
|
|
||||||
#include "../board/card_list.h"
|
|
||||||
#include "event_processing_options.h"
|
#include "event_processing_options.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
||||||
|
|
@ -154,7 +152,7 @@ public slots:
|
||||||
void actRevealRandomHandCard(int revealToPlayerId);
|
void actRevealRandomHandCard(int revealToPlayerId);
|
||||||
void actRevealLibrary(int revealToPlayerId);
|
void actRevealLibrary(int revealToPlayerId);
|
||||||
|
|
||||||
void actSortHand(const QList<CardList::SortOption> &sortOptions);
|
void actSortHand();
|
||||||
|
|
||||||
void cardMenuAction();
|
void cardMenuAction();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue