mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-23 23:23:55 -07:00
Add more sort options to hand sort (#6279)
* Add more sort options to hand sort Took 14 minutes * Move defaultOptions up a level * Directly pass sort order as param * fix include * revert * fallback expandSortOption
This commit is contained in:
parent
6bc2293292
commit
757e9f3415
6 changed files with 74 additions and 14 deletions
|
|
@ -139,9 +139,36 @@ void PlayerActions::actViewHand()
|
|||
player->getGameScene()->toggleZoneView(player, "hand", -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
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 {option};
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerActions::actSortHand()
|
||||
{
|
||||
player->getGraphicsItem()->getHandZoneGraphicsItem()->sortHand();
|
||||
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);
|
||||
}
|
||||
|
||||
void PlayerActions::actViewTopCards()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue