mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
* Have CardDatabase::getPreferredPrintingInfo respect card provider ID overrides (pinned printings)
Took 13 minutes
Took 37 seconds
Took 10 seconds
Took 10 seconds
# Commit time for manual adjustment:
# Took 30 seconds
Took 15 seconds
Took 8 minutes
Took 21 seconds
* Move settings cache and settings card preference provider out of libcockatrice_settings and into cockatrice
Took 52 minutes
Took 9 minutes
Took 1 minute
* Temp cache.
Took 16 minutes
* Dependency Injection for SettingsCache
* Turn SettingsCache into a QSharedPointer.
* Implement interfaces for settings that need it
Took 2 hours 38 minutes
* Adjust oracle.
Took 5 minutes
* Move abstract/noop interfaces to libcockatrice_interfaces so they can be linked against independently.
Took 52 minutes
* Clean up some links.
Took 3 minutes
* Cleanup two includes.
Took 3 minutes
* More fixes.
Took 7 minutes
* More includes that slipped past.
Took 3 minutes
* Stop mocking and start injecting for tests.
Took 15 minutes
* I don't know why remote_client was including main.
Took 4 minutes
* Include.
Took 3 minutes
* Lint.
Took 2 minutes
* Don't use Qt pointers.
Took 1 hour 7 minutes
* Make parser use CardSettingsInterface
Took 13 minutes
* Also adjust constructor lol.
Took 8 minutes
* Lint.
Took 32 minutes
* Revert "Lint."
This reverts commit ecb596c39e.
Took 3 minutes
* Test.
Took 3 minutes
---------
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
108 lines
3.5 KiB
C++
108 lines
3.5 KiB
C++
#include "stack_zone.h"
|
|
|
|
#include "../../client/settings/cache_settings.h"
|
|
#include "../../interface/theme_manager.h"
|
|
#include "../board/arrow_item.h"
|
|
#include "../board/card_drag_item.h"
|
|
#include "../board/card_item.h"
|
|
#include "../player/player.h"
|
|
#include "logic/stack_zone_logic.h"
|
|
|
|
#include <QPainter>
|
|
#include <QSet>
|
|
#include <libcockatrice/protocol/pb/command_move_card.pb.h>
|
|
|
|
StackZone::StackZone(StackZoneLogic *_logic, int _zoneHeight, QGraphicsItem *parent)
|
|
: SelectZone(_logic, parent), zoneHeight(_zoneHeight)
|
|
{
|
|
connect(themeManager, &ThemeManager::themeChanged, this, &StackZone::updateBg);
|
|
updateBg();
|
|
setCacheMode(DeviceCoordinateCache);
|
|
}
|
|
|
|
void StackZone::updateBg()
|
|
{
|
|
update();
|
|
}
|
|
|
|
QRectF StackZone::boundingRect() const
|
|
{
|
|
return {0, 0, 100, zoneHeight};
|
|
}
|
|
|
|
void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
|
{
|
|
QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Stack, getLogic()->getPlayer()->getZoneId());
|
|
painter->fillRect(boundingRect(), brush);
|
|
}
|
|
|
|
void StackZone::handleDropEvent(const QList<CardDragItem *> &dragItems,
|
|
CardZoneLogic *startZone,
|
|
const QPoint &dropPoint)
|
|
{
|
|
if (startZone == nullptr || startZone->getPlayer() == nullptr) {
|
|
return;
|
|
}
|
|
|
|
Command_MoveCard cmd;
|
|
cmd.set_start_player_id(startZone->getPlayer()->getPlayerInfo()->getId());
|
|
cmd.set_start_zone(startZone->getName().toStdString());
|
|
cmd.set_target_player_id(getLogic()->getPlayer()->getPlayerInfo()->getId());
|
|
cmd.set_target_zone(getLogic()->getName().toStdString());
|
|
|
|
int index = 0;
|
|
|
|
if (!getLogic()->getCards().isEmpty()) {
|
|
const auto cardCount = static_cast<int>(getLogic()->getCards().size());
|
|
const auto &card = getLogic()->getCards().at(0);
|
|
|
|
index = qRound(divideCardSpaceInZone(dropPoint.y(), cardCount, boundingRect().height(),
|
|
card->boundingRect().height(), true));
|
|
|
|
// divideCardSpaceInZone is not guaranteed to return a valid index
|
|
// currently, so clamp it to avoid crashes.
|
|
index = qBound(0, index, cardCount - 1);
|
|
|
|
if (startZone == getLogic()) {
|
|
const auto &dragItem = dragItems.at(0);
|
|
const auto &card = getLogic()->getCards().at(index);
|
|
|
|
if (card->getId() == dragItem->getId()) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
cmd.set_x(index);
|
|
cmd.set_y(0);
|
|
|
|
for (CardDragItem *item : dragItems) {
|
|
if (item) {
|
|
cmd.mutable_cards_to_move()->add_card()->set_card_id(item->getId());
|
|
}
|
|
}
|
|
|
|
getLogic()->getPlayer()->getPlayerActions()->sendGameCommand(cmd);
|
|
}
|
|
|
|
void StackZone::reorganizeCards()
|
|
{
|
|
if (!getLogic()->getCards().isEmpty()) {
|
|
const auto cardCount = static_cast<int>(getLogic()->getCards().size());
|
|
qreal totalWidth = boundingRect().width();
|
|
qreal cardWidth = getLogic()->getCards().at(0)->boundingRect().width();
|
|
qreal xspace = 5;
|
|
qreal x1 = xspace;
|
|
qreal x2 = totalWidth - xspace - cardWidth;
|
|
|
|
for (int i = 0; i < cardCount; i++) {
|
|
CardItem *card = getLogic()->getCards().at(i);
|
|
qreal x = (i % 2) ? x2 : x1;
|
|
qreal y = divideCardSpaceInZone(i, cardCount, boundingRect().height(),
|
|
getLogic()->getCards().at(0)->boundingRect().height());
|
|
card->setPos(x, y);
|
|
card->setRealZValue(i);
|
|
}
|
|
}
|
|
update();
|
|
}
|