mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 19:13:55 -07:00
local playing bugfixes
This commit is contained in:
parent
00077565ab
commit
168d184e8f
21 changed files with 71 additions and 52 deletions
|
|
@ -7,7 +7,8 @@ class QGraphicsScene;
|
|||
class CardZone;
|
||||
class CardInfo;
|
||||
|
||||
class AbstractCardDragItem : public QGraphicsItem {
|
||||
class AbstractCardDragItem : public QObject, public QGraphicsItem {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
AbstractCardItem *item;
|
||||
QPointF hotSpot;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "abstractclient.h"
|
||||
#include "protocol.h"
|
||||
#include "protocol_items.h"
|
||||
#include <QDebug>
|
||||
|
||||
AbstractClient::AbstractClient(QObject *parent)
|
||||
: QObject(parent), status(StatusDisconnected)
|
||||
|
|
@ -21,8 +22,9 @@ void AbstractClient::processProtocolItem(ProtocolItem *item)
|
|||
|
||||
pendingCommands.remove(cmdCont->getCmdId());
|
||||
cmdCont->processResponse(response);
|
||||
delete response;
|
||||
delete cmdCont;
|
||||
if (response->getReceiverMayDelete())
|
||||
delete response;
|
||||
cmdCont->deleteLater();
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -35,21 +37,24 @@ void AbstractClient::processProtocolItem(ProtocolItem *item)
|
|||
case ItemId_Event_ListChatChannels: emit listChatChannelsEventReceived(qobject_cast<Event_ListChatChannels *>(item)); break;
|
||||
case ItemId_Event_GameJoined: emit gameJoinedEventReceived(qobject_cast<Event_GameJoined *>(item)); break;
|
||||
}
|
||||
delete genericEvent;
|
||||
if (genericEvent->getReceiverMayDelete())
|
||||
delete genericEvent;
|
||||
return;
|
||||
}
|
||||
|
||||
GameEventContainer *gameEventContainer = qobject_cast<GameEventContainer *>(item);
|
||||
if (gameEventContainer) {
|
||||
emit gameEventContainerReceived(gameEventContainer);
|
||||
delete gameEventContainer;
|
||||
if (gameEventContainer->getReceiverMayDelete())
|
||||
delete gameEventContainer;
|
||||
return;
|
||||
}
|
||||
|
||||
ChatEvent *chatEvent = qobject_cast<ChatEvent *>(item);
|
||||
if (chatEvent) {
|
||||
emit chatEventReceived(chatEvent);
|
||||
delete chatEvent;
|
||||
if (chatEvent->getReceiverMayDelete())
|
||||
delete chatEvent;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ CardDragItem *CardItem::createDragItem(int _id, const QPointF &_pos, const QPoin
|
|||
|
||||
void CardItem::deleteDragItem()
|
||||
{
|
||||
delete dragItem;
|
||||
dragItem->deleteLater();
|
||||
dragItem = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -376,7 +376,7 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
cardMenu->exec(event->screenPos());
|
||||
} else if ((event->button() == Qt::LeftButton) && !settingsCache->getDoubleClickToPlay())
|
||||
playCard(event);
|
||||
|
||||
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ LocalClient::LocalClient(LocalServerInterface *_lsi, QObject *parent)
|
|||
: AbstractClient(parent), lsi(_lsi)
|
||||
{
|
||||
connect(lsi, SIGNAL(itemToClient(ProtocolItem *)), this, SLOT(itemFromServer(ProtocolItem *)));
|
||||
sendCommand(new Command_Login("Player", QString()));
|
||||
}
|
||||
|
||||
LocalClient::~LocalClient()
|
||||
|
|
@ -14,6 +15,8 @@ LocalClient::~LocalClient()
|
|||
|
||||
void LocalClient::sendCommandContainer(CommandContainer *cont)
|
||||
{
|
||||
cont->setReceiverMayDelete(false);
|
||||
pendingCommands.insert(cont->getCmdId(), cont);
|
||||
lsi->itemFromClient(cont);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "localserverinterface.h"
|
||||
#include "localserver.h"
|
||||
#include <QDebug>
|
||||
|
||||
LocalServerInterface::LocalServerInterface(LocalServer *_server)
|
||||
: Server_ProtocolHandler(_server, _server)
|
||||
|
|
@ -10,10 +11,12 @@ LocalServerInterface::~LocalServerInterface()
|
|||
{
|
||||
}
|
||||
|
||||
bool LocalServerInterface::sendProtocolItem(ProtocolItem *item, bool deleteItem)
|
||||
void LocalServerInterface::sendProtocolItem(ProtocolItem *item, bool deleteItem)
|
||||
{
|
||||
item->setReceiverMayDelete(false);
|
||||
emit itemToClient(item);
|
||||
return false;
|
||||
if (deleteItem)
|
||||
delete item;
|
||||
}
|
||||
|
||||
void LocalServerInterface::itemFromClient(ProtocolItem *item)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public:
|
|||
LocalServerInterface(LocalServer *_server);
|
||||
~LocalServerInterface();
|
||||
|
||||
bool sendProtocolItem(ProtocolItem *item, bool deleteItem = true);
|
||||
void sendProtocolItem(ProtocolItem *item, bool deleteItem = true);
|
||||
|
||||
signals:
|
||||
void itemToClient(ProtocolItem *item);
|
||||
|
|
|
|||
|
|
@ -739,6 +739,7 @@ void Player::eventDrawCards(Event_DrawCards *event)
|
|||
|
||||
void Player::processGameEvent(GameEvent *event, GameEventContext *context)
|
||||
{
|
||||
qDebug() << "player event: id=" << event->getItemId();
|
||||
switch (event->getItemId()) {
|
||||
case ItemId_Event_Say: eventSay(qobject_cast<Event_Say *>(event)); break;
|
||||
case ItemId_Event_Shuffle: eventShuffle(qobject_cast<Event_Shuffle *>(event)); break;
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ void ZoneViewZone::removeCard(int position)
|
|||
return;
|
||||
|
||||
CardItem *card = cards.takeAt(position);
|
||||
delete card;
|
||||
card->deleteLater();
|
||||
reorganizeCards();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue