mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-05 21:13:55 -07:00
Double click to untap works when multi-zone select (#5253)
This commit is contained in:
parent
ac16206ddb
commit
c9d5d5609c
1 changed files with 16 additions and 8 deletions
|
|
@ -213,16 +213,24 @@ void TableZone::reorganizeCards()
|
||||||
|
|
||||||
void TableZone::toggleTapped()
|
void TableZone::toggleTapped()
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> selectedItems = scene()->selectedItems();
|
QList<QGraphicsItem *> selectedItemsRaw = scene()->selectedItems();
|
||||||
bool tapAll = false;
|
QList<QGraphicsItem *> selectedItems;
|
||||||
for (int i = 0; i < selectedItems.size(); i++)
|
|
||||||
if (!qgraphicsitem_cast<CardItem *>(selectedItems[i])->getTapped()) {
|
auto isCardOnTable = [](const QGraphicsItem *item) {
|
||||||
tapAll = true;
|
if (auto card = qgraphicsitem_cast<const CardItem *>(item)) {
|
||||||
break;
|
return card->getZone()->getName() == "table";
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::copy_if(selectedItemsRaw.begin(), selectedItemsRaw.end(), std::back_inserter(selectedItems), isCardOnTable);
|
||||||
|
|
||||||
|
bool tapAll = std::any_of(selectedItems.begin(), selectedItems.end(), [](const QGraphicsItem *item) {
|
||||||
|
return !qgraphicsitem_cast<const CardItem *>(item)->getTapped();
|
||||||
|
});
|
||||||
QList<const ::google::protobuf::Message *> cmdList;
|
QList<const ::google::protobuf::Message *> cmdList;
|
||||||
for (int i = 0; i < selectedItems.size(); i++) {
|
for (const auto &selectedItem : selectedItems) {
|
||||||
CardItem *temp = qgraphicsitem_cast<CardItem *>(selectedItems[i]);
|
CardItem *temp = qgraphicsitem_cast<CardItem *>(selectedItem);
|
||||||
if (temp->getTapped() != tapAll) {
|
if (temp->getTapped() != tapAll) {
|
||||||
Command_SetCardAttr *cmd = new Command_SetCardAttr;
|
Command_SetCardAttr *cmd = new Command_SetCardAttr;
|
||||||
cmd->set_zone(name.toStdString());
|
cmd->set_zone(name.toStdString());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue