Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
23188736
Commit
23188736
authored
Dec 23, 2010
by
Max-Wilhelm Bruker
Browse files
card menu improvement, change controller support (bug #3)
parent
4f9252c6
Changes
25
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/abstractcarddragitem.h
View file @
23188736
...
...
@@ -20,6 +20,7 @@ public:
~
AbstractCardDragItem
();
QRectF
boundingRect
()
const
{
return
QRectF
(
0
,
0
,
CARD_WIDTH
,
CARD_HEIGHT
);
}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
AbstractCardItem
*
getItem
()
const
{
return
item
;
}
QPointF
getHotSpot
()
const
{
return
hotSpot
;
}
void
addChildDrag
(
AbstractCardDragItem
*
child
);
virtual
void
updatePosition
(
const
QPointF
&
cursorScenePos
)
=
0
;
...
...
cockatrice/src/carddragitem.cpp
View file @
23188736
...
...
@@ -75,11 +75,11 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
CardZone
*
startZone
=
static_cast
<
CardItem
*>
(
item
)
->
getZone
();
if
(
currentZone
&&
!
(
static_cast
<
CardItem
*>
(
item
)
->
getAttachedTo
()
&&
(
startZone
==
currentZone
)))
{
if
(
!
occupied
)
currentZone
->
handleDropEvent
(
id
,
startZone
,
(
sp
-
currentZone
->
scenePos
()).
toPoint
(),
faceDown
);
currentZone
->
handleDropEvent
(
this
,
startZone
,
(
sp
-
currentZone
->
scenePos
()).
toPoint
(),
faceDown
);
for
(
int
i
=
0
;
i
<
childDrags
.
size
();
i
++
)
{
CardDragItem
*
c
=
static_cast
<
CardDragItem
*>
(
childDrags
[
i
]);
if
(
!
(
static_cast
<
CardItem
*>
(
c
->
item
)
->
getAttachedTo
()
&&
(
startZone
==
currentZone
))
&&
!
c
->
occupied
)
currentZone
->
handleDropEvent
(
c
->
id
,
startZone
,
(
sp
-
currentZone
->
scenePos
()
+
c
->
getHotSpot
()).
toPoint
(),
faceDown
);
currentZone
->
handleDropEvent
(
static_cast
<
CardDragItem
*>
(
c
)
,
startZone
,
(
sp
-
currentZone
->
scenePos
()
+
c
->
getHotSpot
()).
toPoint
(),
faceDown
);
sc
->
removeItem
(
c
);
}
}
...
...
cockatrice/src/carddragitem.h
View file @
23188736
...
...
@@ -13,6 +13,7 @@ private:
CardZone
*
currentZone
;
public:
CardDragItem
(
CardItem
*
_item
,
int
_id
,
const
QPointF
&
_hotSpot
,
bool
_faceDown
,
AbstractCardDragItem
*
parentDrag
=
0
);
int
getId
()
const
{
return
id
;
}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
updatePosition
(
const
QPointF
&
cursorScenePos
);
protected:
...
...
cockatrice/src/carditem.cpp
View file @
23188736
...
...
@@ -17,91 +17,68 @@
#include
"tab_game.h"
CardItem
::
CardItem
(
Player
*
_owner
,
const
QString
&
_name
,
int
_cardid
,
QGraphicsItem
*
parent
)
:
AbstractCardItem
(
_name
,
_owner
,
parent
),
id
(
_cardid
),
attacking
(
false
),
facedown
(
false
),
destroyOnZoneChange
(
false
),
doesntUntap
(
false
),
dragItem
(
0
),
attachedTo
(
0
)
:
AbstractCardItem
(
_name
,
_owner
,
parent
),
zone
(
0
),
id
(
_cardid
),
attacking
(
false
),
facedown
(
false
),
destroyOnZoneChange
(
false
),
doesntUntap
(
false
),
dragItem
(
0
),
attachedTo
(
0
)
{
owner
->
addCard
(
this
);
if
(
owner
->
getLocal
())
{
aTap
=
new
QAction
(
this
);
aTap
->
setData
(
0
);
connect
(
aTap
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
cardMenuAction
()));
aUntap
=
new
QAction
(
this
);
aUntap
->
setData
(
1
);
connect
(
aUntap
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
cardMenuAction
()));
aDoesntUntap
=
new
QAction
(
this
);
aDoesntUntap
->
setData
(
2
);
connect
(
aDoesntUntap
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
cardMenuAction
()));
aAttach
=
new
QAction
(
this
);
connect
(
aAttach
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
actAttach
()));
aUnattach
=
new
QAction
(
this
);
connect
(
aUnattach
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
actUnattach
()));
aSetPT
=
new
QAction
(
this
);
connect
(
aSetPT
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
actSetPT
()));
aSetAnnotation
=
new
QAction
(
this
);
connect
(
aSetAnnotation
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
actSetAnnotation
()));
aFlip
=
new
QAction
(
this
);
aFlip
->
setData
(
3
);
connect
(
aFlip
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
cardMenuAction
()));
aClone
=
new
QAction
(
this
);
aClone
->
setData
(
4
);
connect
(
aClone
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
cardMenuAction
()));
aMoveToTopLibrary
=
new
QAction
(
this
);
aMoveToTopLibrary
->
setData
(
5
);
aMoveToBottomLibrary
=
new
QAction
(
this
);
aMoveToBottomLibrary
->
setData
(
6
);
aMoveToGraveyard
=
new
QAction
(
this
);
aMoveToGraveyard
->
setData
(
7
);
aMoveToExile
=
new
QAction
(
this
);
aMoveToExile
->
setData
(
8
);
connect
(
aMoveToTopLibrary
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
cardMenuAction
()));
connect
(
aMoveToBottomLibrary
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
cardMenuAction
()));
connect
(
aMoveToGraveyard
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
cardMenuAction
()));
connect
(
aMoveToExile
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
cardMenuAction
()));
cardMenu
=
new
QMenu
;
cardMenu
->
addAction
(
aTap
);
cardMenu
->
addAction
(
aUntap
);
cardMenu
->
addAction
(
aDoesntUntap
);
cardMenu
->
addAction
(
aFlip
);
cardMenu
->
addSeparator
();
cardMenu
->
addAction
(
aAttach
);
cardMenu
->
addAction
(
aUnattach
);
cardMenu
->
addSeparator
();
cardMenu
->
addAction
(
aSetPT
);
cardMenu
->
addAction
(
aSetAnnotation
);
cardMenu
->
addSeparator
();
cardMenu
->
addAction
(
aClone
);
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
QAction
*
tempAddCounter
=
new
QAction
(
this
);
tempAddCounter
->
setData
(
9
+
i
*
1000
);
QAction
*
tempRemoveCounter
=
new
QAction
(
this
);
tempRemoveCounter
->
setData
(
10
+
i
*
1000
);
QAction
*
tempSetCounter
=
new
QAction
(
this
);
tempSetCounter
->
setData
(
11
+
i
*
1000
);
aAddCounter
.
append
(
tempAddCounter
);
aRemoveCounter
.
append
(
tempRemoveCounter
);
aSetCounter
.
append
(
tempSetCounter
);
connect
(
tempAddCounter
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
actCardCounterTrigger
()));
connect
(
tempRemoveCounter
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
actCardCounterTrigger
()));
connect
(
tempSetCounter
,
SIGNAL
(
triggered
()),
owner
,
SLOT
(
actCardCounterTrigger
()));
cardMenu
->
addSeparator
();
cardMenu
->
addAction
(
tempAddCounter
);
cardMenu
->
addAction
(
tempRemoveCounter
);
cardMenu
->
addAction
(
tempSetCounter
);
}
cardMenu
->
addSeparator
();
moveMenu
=
cardMenu
->
addMenu
(
QString
());
moveMenu
->
addAction
(
aMoveToTopLibrary
);
moveMenu
->
addAction
(
aMoveToBottomLibrary
);
moveMenu
->
addAction
(
aMoveToGraveyard
);
moveMenu
->
addAction
(
aMoveToExile
);
aTap
=
new
QAction
(
this
);
aTap
->
setData
(
0
);
connect
(
aTap
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cardMenuAction
()));
aUntap
=
new
QAction
(
this
);
aUntap
->
setData
(
1
);
connect
(
aUntap
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cardMenuAction
()));
aDoesntUntap
=
new
QAction
(
this
);
aDoesntUntap
->
setData
(
2
);
connect
(
aDoesntUntap
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cardMenuAction
()));
aAttach
=
new
QAction
(
this
);
connect
(
aAttach
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actAttach
()));
aUnattach
=
new
QAction
(
this
);
connect
(
aUnattach
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actUnattach
()));
aSetPT
=
new
QAction
(
this
);
connect
(
aSetPT
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actSetPT
()));
aSetAnnotation
=
new
QAction
(
this
);
connect
(
aSetAnnotation
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actSetAnnotation
()));
aFlip
=
new
QAction
(
this
);
aFlip
->
setData
(
3
);
connect
(
aFlip
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cardMenuAction
()));
aClone
=
new
QAction
(
this
);
aClone
->
setData
(
4
);
connect
(
aClone
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cardMenuAction
()));
aMoveToTopLibrary
=
new
QAction
(
this
);
aMoveToTopLibrary
->
setData
(
5
);
aMoveToBottomLibrary
=
new
QAction
(
this
);
aMoveToBottomLibrary
->
setData
(
6
);
aMoveToGraveyard
=
new
QAction
(
this
);
aMoveToGraveyard
->
setData
(
7
);
aMoveToExile
=
new
QAction
(
this
);
aMoveToExile
->
setData
(
8
);
connect
(
aMoveToTopLibrary
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cardMenuAction
()));
connect
(
aMoveToBottomLibrary
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cardMenuAction
()));
connect
(
aMoveToGraveyard
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cardMenuAction
()));
connect
(
aMoveToExile
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cardMenuAction
()));
aPlay
=
new
QAction
(
this
);
connect
(
aPlay
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actPlay
()));
retranslateUi
();
}
else
cardMenu
=
0
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
QAction
*
tempAddCounter
=
new
QAction
(
this
);
tempAddCounter
->
setData
(
9
+
i
*
1000
);
QAction
*
tempRemoveCounter
=
new
QAction
(
this
);
tempRemoveCounter
->
setData
(
10
+
i
*
1000
);
QAction
*
tempSetCounter
=
new
QAction
(
this
);
tempSetCounter
->
setData
(
11
+
i
*
1000
);
aAddCounter
.
append
(
tempAddCounter
);
aRemoveCounter
.
append
(
tempRemoveCounter
);
aSetCounter
.
append
(
tempSetCounter
);
connect
(
tempAddCounter
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actCardCounterTrigger
()));
connect
(
tempRemoveCounter
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actCardCounterTrigger
()));
connect
(
tempSetCounter
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actCardCounterTrigger
()));
}
cardMenu
=
new
QMenu
;
moveMenu
=
new
QMenu
;
retranslateUi
();
updateCardMenu
();
}
CardItem
::~
CardItem
()
...
...
@@ -110,6 +87,8 @@ CardItem::~CardItem()
delete
cardMenu
;
cardMenu
=
0
;
delete
moveMenu
;
moveMenu
=
0
;
deleteDragItem
();
}
...
...
@@ -139,39 +118,87 @@ void CardItem::deleteLater()
AbstractCardItem
::
deleteLater
();
}
void
CardItem
::
r
et
ranslateUi
(
)
void
CardItem
::
s
et
Zone
(
CardZone
*
_zone
)
{
zone
=
_zone
;
updateCardMenu
();
}
void
CardItem
::
updateCardMenu
()
{
cardMenu
->
clear
();
if
(
owner
->
getLocal
())
{
aTap
->
setText
(
tr
(
"&Tap"
));
aUntap
->
setText
(
tr
(
"&Untap"
));
aDoesntUntap
->
setText
(
tr
(
"Toggle &normal untapping"
));
aFlip
->
setText
(
tr
(
"&Flip"
));
aClone
->
setText
(
tr
(
"&Clone"
));
aAttach
->
setText
(
tr
(
"&Attach to card..."
));
aAttach
->
setShortcut
(
tr
(
"Ctrl+A"
));
aUnattach
->
setText
(
tr
(
"Unattac&h"
));
aSetPT
->
setText
(
tr
(
"Set &P/T..."
));
aSetAnnotation
->
setText
(
tr
(
"&Set annotation..."
));
QStringList
counterColors
;
counterColors
.
append
(
tr
(
"red"
));
counterColors
.
append
(
tr
(
"yellow"
));
counterColors
.
append
(
tr
(
"green"
));
for
(
int
i
=
0
;
i
<
aAddCounter
.
size
();
++
i
)
aAddCounter
[
i
]
->
setText
(
tr
(
"&Add counter (%1)"
).
arg
(
counterColors
[
i
]));
for
(
int
i
=
0
;
i
<
aRemoveCounter
.
size
();
++
i
)
aRemoveCounter
[
i
]
->
setText
(
tr
(
"&Remove counter (%1)"
).
arg
(
counterColors
[
i
]));
for
(
int
i
=
0
;
i
<
aSetCounter
.
size
();
++
i
)
aSetCounter
[
i
]
->
setText
(
tr
(
"&Set counters (%1)..."
).
arg
(
counterColors
[
i
]));
aMoveToTopLibrary
->
setText
(
tr
(
"&top of library"
));
aMoveToBottomLibrary
->
setText
(
tr
(
"&bottom of library"
));
aMoveToGraveyard
->
setText
(
tr
(
"&graveyard"
));
aMoveToGraveyard
->
setShortcut
(
tr
(
"Ctrl+Del"
));
aMoveToExile
->
setText
(
tr
(
"&exile"
));
if
(
zone
)
{
if
(
zone
->
getName
()
==
"table"
)
{
cardMenu
->
addAction
(
aTap
);
cardMenu
->
addAction
(
aUntap
);
cardMenu
->
addAction
(
aDoesntUntap
);
cardMenu
->
addAction
(
aFlip
);
cardMenu
->
addSeparator
();
cardMenu
->
addAction
(
aAttach
);
if
(
attachedTo
)
cardMenu
->
addAction
(
aUnattach
);
cardMenu
->
addSeparator
();
cardMenu
->
addAction
(
aSetPT
);
cardMenu
->
addAction
(
aSetAnnotation
);
cardMenu
->
addSeparator
();
cardMenu
->
addAction
(
aClone
);
for
(
int
i
=
0
;
i
<
aAddCounter
.
size
();
++
i
)
{
cardMenu
->
addSeparator
();
cardMenu
->
addAction
(
aAddCounter
[
i
]);
cardMenu
->
addAction
(
aRemoveCounter
[
i
]);
cardMenu
->
addAction
(
aSetCounter
[
i
]);
}
cardMenu
->
addSeparator
();
}
else
{
cardMenu
->
addAction
(
aPlay
);
}
}
moveMenu
->
setTitle
(
tr
(
"&Move to"
));
moveMenu
->
clear
();
moveMenu
->
addAction
(
aMoveToTopLibrary
);
moveMenu
->
addAction
(
aMoveToBottomLibrary
);
moveMenu
->
addAction
(
aMoveToGraveyard
);
moveMenu
->
addAction
(
aMoveToExile
);
cardMenu
->
addMenu
(
moveMenu
);
}
}
void
CardItem
::
retranslateUi
()
{
aPlay
->
setText
(
tr
(
"&Play"
));
aTap
->
setText
(
tr
(
"&Tap"
));
aUntap
->
setText
(
tr
(
"&Untap"
));
aDoesntUntap
->
setText
(
tr
(
"Toggle &normal untapping"
));
aFlip
->
setText
(
tr
(
"&Flip"
));
aClone
->
setText
(
tr
(
"&Clone"
));
aAttach
->
setText
(
tr
(
"&Attach to card..."
));
aAttach
->
setShortcut
(
tr
(
"Ctrl+A"
));
aUnattach
->
setText
(
tr
(
"Unattac&h"
));
aSetPT
->
setText
(
tr
(
"Set &P/T..."
));
aSetAnnotation
->
setText
(
tr
(
"&Set annotation..."
));
QStringList
counterColors
;
counterColors
.
append
(
tr
(
"red"
));
counterColors
.
append
(
tr
(
"yellow"
));
counterColors
.
append
(
tr
(
"green"
));
for
(
int
i
=
0
;
i
<
aAddCounter
.
size
();
++
i
)
aAddCounter
[
i
]
->
setText
(
tr
(
"&Add counter (%1)"
).
arg
(
counterColors
[
i
]));
for
(
int
i
=
0
;
i
<
aRemoveCounter
.
size
();
++
i
)
aRemoveCounter
[
i
]
->
setText
(
tr
(
"&Remove counter (%1)"
).
arg
(
counterColors
[
i
]));
for
(
int
i
=
0
;
i
<
aSetCounter
.
size
();
++
i
)
aSetCounter
[
i
]
->
setText
(
tr
(
"&Set counters (%1)..."
).
arg
(
counterColors
[
i
]));
aMoveToTopLibrary
->
setText
(
tr
(
"&top of library"
));
aMoveToBottomLibrary
->
setText
(
tr
(
"&bottom of library"
));
aMoveToGraveyard
->
setText
(
tr
(
"&graveyard"
));
aMoveToGraveyard
->
setShortcut
(
tr
(
"Ctrl+Del"
));
aMoveToExile
->
setText
(
tr
(
"&exile"
));
moveMenu
->
setTitle
(
tr
(
"&Move to"
));
}
void
CardItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
painter
->
save
();
...
...
@@ -263,6 +290,8 @@ void CardItem::setAttachedTo(CardItem *_attachedTo)
if
(
zone
)
zone
->
reorganizeCards
();
updateCardMenu
();
}
void
CardItem
::
resetState
()
...
...
@@ -376,7 +405,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
setCursor
(
Qt
::
OpenHandCursor
);
}
void
CardItem
::
playCard
(
QGraphicsSceneMouseEvent
*
event
)
void
CardItem
::
playCard
(
bool
faceDown
)
{
// Do nothing if the card belongs to another player
if
(
!
owner
->
getLocal
())
...
...
@@ -385,22 +414,19 @@ void CardItem::playCard(QGraphicsSceneMouseEvent *event)
TableZone
*
tz
=
qobject_cast
<
TableZone
*>
(
zone
);
if
(
tz
)
tz
->
toggleTapped
();
else
{
bool
faceDown
=
event
->
modifiers
().
testFlag
(
Qt
::
ShiftModifier
);
bool
tapped
=
info
->
getCipt
();
zone
->
getPlayer
()
->
playCard
(
this
,
faceDown
,
tapped
);
}
else
zone
->
getPlayer
()
->
playCard
(
this
,
faceDown
,
info
->
getCipt
());
}
void
CardItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
event
->
button
()
==
Qt
::
RightButton
)
{
if
(
cardMenu
)
cardMenu
->
exec
(
event
->
screenPos
());
if
(
!
cardMenu
->
isEmpty
())
cardMenu
->
exec
(
event
->
screenPos
());
}
else
if
((
event
->
button
()
==
Qt
::
LeftButton
)
&&
!
settingsCache
->
getDoubleClickToPlay
())
{
setCursor
(
Qt
::
OpenHandCursor
);
playCard
(
event
);
playCard
(
event
->
modifiers
().
testFlag
(
Qt
::
ShiftModifier
)
);
}
AbstractCardItem
::
mouseReleaseEvent
(
event
);
...
...
@@ -409,7 +435,7 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void
CardItem
::
mouseDoubleClickEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
settingsCache
->
getDoubleClickToPlay
())
playCard
(
event
);
playCard
(
event
->
modifiers
().
testFlag
(
Qt
::
ShiftModifier
)
);
event
->
accept
();
}
...
...
@@ -423,3 +449,38 @@ QVariant CardItem::itemChange(GraphicsItemChange change, const QVariant &value)
}
return
QGraphicsItem
::
itemChange
(
change
,
value
);
}
void
CardItem
::
cardMenuAction
()
{
owner
->
cardMenuAction
(
static_cast
<
QAction
*>
(
sender
()));
}
void
CardItem
::
actAttach
()
{
owner
->
actAttach
(
static_cast
<
QAction
*>
(
sender
()));
}
void
CardItem
::
actUnattach
()
{
owner
->
actUnattach
(
static_cast
<
QAction
*>
(
sender
()));
}
void
CardItem
::
actSetPT
()
{
owner
->
actSetPT
(
static_cast
<
QAction
*>
(
sender
()));
}
void
CardItem
::
actSetAnnotation
()
{
owner
->
actSetAnnotation
(
static_cast
<
QAction
*>
(
sender
()));
}
void
CardItem
::
actCardCounterTrigger
()
{
owner
->
actCardCounterTrigger
(
static_cast
<
QAction
*>
(
sender
()));
}
void
CardItem
::
actPlay
()
{
playCard
(
false
);
}
\ No newline at end of file
cockatrice/src/carditem.h
View file @
23188736
...
...
@@ -30,12 +30,21 @@ private:
QList
<
CardItem
*>
attachedCards
;
QList
<
QAction
*>
aAddCounter
,
aSetCounter
,
aRemoveCounter
;
QAction
*
aTap
,
*
aUntap
,
*
aDoesntUntap
,
*
aAttach
,
*
aUnattach
,
*
aSetPT
,
*
aSetAnnotation
,
*
aFlip
,
*
aClone
,
QAction
*
aPlay
,
*
aTap
,
*
aUntap
,
*
aDoesntUntap
,
*
aAttach
,
*
aUnattach
,
*
aSetPT
,
*
aSetAnnotation
,
*
aFlip
,
*
aClone
,
*
aMoveToTopLibrary
,
*
aMoveToBottomLibrary
,
*
aMoveToGraveyard
,
*
aMoveToExile
;
QMenu
*
cardMenu
,
*
moveMenu
;
void
playCard
(
QGraphicsSceneMouseEvent
*
event
);
void
playCard
(
bool
faceDown
);
void
prepareDelete
();
private
slots
:
void
cardMenuAction
();
void
actCardCounterTrigger
();
void
actAttach
();
void
actUnattach
();
void
actSetPT
();
void
actSetAnnotation
();
void
actPlay
();
public
slots
:
void
deleteLater
();
public:
...
...
@@ -45,13 +54,14 @@ public:
~
CardItem
();
void
retranslateUi
();
CardZone
*
getZone
()
const
{
return
zone
;
}
void
setZone
(
CardZone
*
_zone
)
{
zone
=
_zone
;
}
void
setZone
(
CardZone
*
_zone
)
;
QMenu
*
getCardMenu
()
const
{
return
cardMenu
;
}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QPoint
getGridPoint
()
const
{
return
gridPoint
;
}
void
setGridPoint
(
const
QPoint
&
_gridPoint
)
{
gridPoint
=
_gridPoint
;
}
QPoint
getGridPos
()
const
{
return
gridPoint
;
}
Player
*
getOwner
()
const
{
return
owner
;
}
void
setOwner
(
Player
*
_owner
)
{
owner
=
_owner
;
}
int
getId
()
const
{
return
id
;
}
void
setId
(
int
_id
)
{
id
=
_id
;
}
bool
getAttacking
()
const
{
return
attacking
;
}
...
...
@@ -75,6 +85,7 @@ public:
const
QList
<
CardItem
*>
&
getAttachedCards
()
const
{
return
attachedCards
;
}
void
resetState
();
void
processCardInfo
(
ServerInfo_Card
*
info
);
void
updateCardMenu
();
CardDragItem
*
createDragItem
(
int
_id
,
const
QPointF
&
_pos
,
const
QPointF
&
_scenePos
,
bool
faceDown
);
void
deleteDragItem
();
...
...
cockatrice/src/cardzone.cpp
View file @
23188736
...
...
@@ -166,7 +166,7 @@ void CardZone::moveAllToZone()
// Cards need to be moved in reverse order so that the other
// cards' list index doesn't change
for
(
int
i
=
cards
.
size
()
-
1
;
i
>=
0
;
i
--
)
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
getName
(),
cards
.
at
(
i
)
->
getId
(),
targetZone
,
targetX
));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
getName
(),
cards
.
at
(
i
)
->
getId
(),
player
->
getId
(),
targetZone
,
targetX
));
}
QPointF
CardZone
::
closestGridPoint
(
const
QPointF
&
point
)
...
...
cockatrice/src/cardzone.h
View file @
23188736
...
...
@@ -12,6 +12,7 @@ class ZoneViewZone;
class
QMenu
;
class
QAction
;
class
QPainter
;
class
CardDragItem
;
class
CardZone
:
public
QObject
,
public
AbstractGraphicsItem
{
Q_OBJECT
...
...
@@ -34,7 +35,7 @@ public slots:
public:
enum
{
Type
=
typeZone
};
int
type
()
const
{
return
Type
;
}
virtual
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
)
=
0
;
virtual
void
handleDropEvent
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
)
=
0
;
CardZone
(
Player
*
_player
,
const
QString
&
_name
,
bool
_hasCardAttr
,
bool
_isShufflable
,
bool
_contentsKnown
,
QGraphicsItem
*
parent
=
0
,
bool
isView
=
false
);
~
CardZone
();
void
retranslateUi
();
...
...
cockatrice/src/handzone.cpp
View file @
23188736
...
...
@@ -3,6 +3,7 @@
#include
"settingscache.h"
#include
"player.h"
#include
"protocol_items.h"
#include
"carddragitem.h"
HandZone
::
HandZone
(
Player
*
_p
,
bool
_contentsKnown
,
int
_zoneHeight
,
QGraphicsItem
*
parent
)
:
SelectZone
(
_p
,
"hand"
,
false
,
false
,
_contentsKnown
,
parent
),
zoneHeight
(
_zoneHeight
)
...
...
@@ -36,9 +37,9 @@ void HandZone::addCardImpl(CardItem *card, int x, int /*y*/)
card
->
update
();
}
void
HandZone
::
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
void
HandZone
::
handleDropEvent
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
{
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
cardId
,
getName
(),
cards
.
size
(),
-
1
,
false
));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
dragItem
->
getId
(),
player
->
getId
()
,
getName
(),
cards
.
size
(),
-
1
,
false
));
}
QRectF
HandZone
::
boundingRect
()
const
...
...
cockatrice/src/handzone.h
View file @
23188736
...
...
@@ -14,7 +14,7 @@ public slots:
void
updateOrientation
();
public:
HandZone
(
Player
*
_p
,
bool
_contentsKnown
,
int
_zoneHeight
,
QGraphicsItem
*
parent
=
0
);
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
void
handleDropEvent
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
reorganizeCards
();
...
...
cockatrice/src/pilezone.cpp
View file @
23188736
...
...
@@ -48,9 +48,9 @@ void PileZone::addCardImpl(CardItem *card, int x, int /*y*/)
card
->
setParentItem
(
this
);
}
void
PileZone
::
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
void
PileZone
::
handleDropEvent
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
{
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
cardId
,
getName
(),
0
,
0
,
false
));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
dragItem
->
getId
(),
player
->
getId
()
,
getName
(),
0
,
0
,
false
));
}
void
PileZone
::
reorganizeCards
()
...
...
cockatrice/src/pilezone.h
View file @
23188736
...
...
@@ -9,7 +9,7 @@ public:
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
reorganizeCards
();
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
void
handleDropEvent
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
protected:
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
cockatrice/src/player.cpp
View file @
23188736
...
...
@@ -562,7 +562,7 @@ void Player::actMoveTopCardsToGrave()
if
(
number
>
maxCards
)
number
=
maxCards
;
for
(
int
i
=
0
;
i
<
number
;
++
i
)
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
"deck"
,
0
,
"grave"
,
0
,
0
,
false
));
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
"deck"
,
0
,
getId
(),
"grave"
,
0
,
0
,
false
));
sendCommandContainer
(
new
CommandContainer
(
commandList
));
}
...
...
@@ -577,13 +577,13 @@ void Player::actMoveTopCardsToExile()
if
(
number
>
maxCards
)
number
=
maxCards
;
for
(
int
i
=
0
;
i
<
number
;
++
i
)
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
"deck"
,
0
,
"rfg"
,
0
,
0
,
false
));
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
"deck"
,
0
,
getId
(),
"rfg"
,
0
,
0
,
false
));
sendCommandContainer
(
new
CommandContainer
(
commandList
));
}
void
Player
::
actMoveTopCardToBottom
()
{
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
"deck"
,
0
,
"deck"
,
-
1
,
0
,
false
));
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
"deck"
,
0
,
getId
(),
"deck"
,
-
1
,
0
,
false
));
}
void
Player
::
actUntapAll
()
...
...
@@ -790,7 +790,10 @@ void Player::eventStopDumpZone(Event_StopDumpZone *event)
void
Player
::
eventMoveCard
(
Event_MoveCard
*
event
)
{
CardZone
*
startZone
=
zones
.
value
(
event
->
getStartZone
(),
0
);
CardZone
*
targetZone
=
zones
.
value
(
event
->
getTargetZone
(),
0
);
Player
*
targetPlayer
=
static_cast
<
TabGame
*>
(
parent
())
->
getPlayers
().
value
(
event
->
getTargetPlayerId
());
if
(
!
targetPlayer
)
return
;
CardZone
*
targetZone
=
targetPlayer
->
getZones
().
value
(
event
->
getTargetZone
(),
0
);
if
(
!
startZone
||
!
targetZone
)
return
;
...
...
@@ -820,6 +823,13 @@ void Player::eventMoveCard(Event_MoveCard *event)
if
(
startZone
!=
targetZone
)
{
card
->
setBeingPointedAt
(
false
);
card
->
setHovered
(
false
);
const
QList
<
CardItem
*>
&
attachedCards
=
card
->
getAttachedCards
();
for
(
int
i
=
0
;
i
<
attachedCards
.
size
();
++
i
)
attachedCards
[
i
]
->
setParentItem
(
targetZone
);
if
(
startZone
->
getPlayer
()
!=
targetZone
->
getPlayer
())
card
->
setOwner
(
targetZone
->
getPlayer
());
}
// The log event has to be sent before the card is added to the target zone
...
...
@@ -1076,10 +1086,10 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
{
CardInfo
*
ci
=
c
->
getInfo
();
if
(
ci
->
getTableRow
()
==
3
)
s
tack
->
handleDropEvent
(
c
->
getId
(),
c
->
getZone
(),
QPoint
()
,
false
);
s
endGameCommand
(
new
Command_MoveCard
(
-
1
,
c
->
getZone
()
->
getName
(),
c
->
getId
(),
getId
(),
"stack"
,
0
,
0
,
false
)
)
;
else
{
QPoint
gridPoint
=
QPoint
(
-
1
,
2
-
ci
->
getTableRow
());
table
->
handleDropEventByGrid
(
c
->
getId
(),
c
->
getZone
(),
gridPoint
,
faceDown
,
tapped
);
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
c
->
getZone
()
->
getName
(),
c
->
getId
(),
getId
(),
"table"
,
gridPoint
.
x
(),
gridPoint
.
y
()
,
faceDown
,
tapped
)
)
;
}
}
...
...
@@ -1246,9 +1256,8 @@ bool Player::clearCardsToDelete()
return
true
;
}
void
Player
::
cardMenuAction
()
void
Player
::
cardMenuAction
(
QAction
*
a
)
{
QAction
*
a
=
static_cast
<
QAction
*>
(
sender
());
QList
<
QGraphicsItem
*>
sel
=
scene
()
->
selectedItems
();
QList
<
Command
*>
commandList
;
while
(
!
sel
.
isEmpty
())
{
...
...
@@ -1276,16 +1285,16 @@ void Player::cardMenuAction()
commandList
.
append
(
new
Command_CreateToken
(
-
1
,
card
->
getZone
()
->
getName
(),
card
->
getName
(),
card
->
getColor
(),
card
->
getPT
(),
card
->
getAnnotation
(),
card
->
getDestroyOnZoneChange
(),
-
1
,
card
->
getGridPoint
().
y
()));
break
;
case
5
:
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
card
->
getZone
()
->
getName
(),
card
->
getId
(),
"deck"
,
0
,
0
,
false
));
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
card
->
getZone
()
->
getName
(),
card
->
getId
(),
getId
(),
"deck"
,
0
,
0
,
false
));
break
;
case
6
:
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
card
->
getZone
()
->
getName
(),
card
->
getId
(),
"deck"
,
-
1
,
0
,
false
));
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
card
->
getZone
()
->
getName
(),
card
->
getId
(),
getId
(),
"deck"
,
-
1
,
0
,
false
));
break
;
case
7
:
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
card
->
getZone
()
->
getName
(),
card
->
getId
(),
"grave"
,
0
,
0
,
false
));
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
card
->
getZone
()
->
getName
(),
card
->
getId
(),
getId
(),
"grave"
,
0
,
0
,
false
));
break
;
case
8
:
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
card
->
getZone
()
->
getName
(),
card
->
getId
(),
"rfg"
,
0
,
0
,
false
));
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
card
->
getZone
()
->
getName
(),
card
->
getId
(),
getId
(),
"rfg"
,
0
,
0
,
false
));
break
;
default:
;
}
...
...
@@ -1293,7 +1302,7 @@ void Player::cardMenuAction()
sendCommandContainer
(
new
CommandContainer
(
commandList
));
}
void
Player
::
actSetPT
()
void
Player
::
actSetPT
(
QAction
*
/*a*/
)
{
QString
oldPT
;
QListIterator
<
QGraphicsItem
*>
i
(
scene
()
->
selectedItems
());
...
...
@@ -1318,7 +1327,7 @@ void Player::actSetPT()
}
}
void
Player
::
actSetAnnotation
()
void
Player
::
actSetAnnotation
(
QAction
*
/*a*/
)
{
QString
oldAnnotation
;
QListIterator
<
QGraphicsItem
*>
i
(
scene
()
->
selectedItems
());
...
...
@@ -1344,24 +1353,22 @@ void Player::actSetAnnotation()
}
}
void
Player
::
actAttach
()
void
Player
::
actAttach
(
QAction
*
a
)
{
CardItem
*
card
=
static_cast
<
CardItem
*>
(
sender
()
->
parent
());
CardItem
*
card
=
static_cast
<
CardItem
*>
(
a
->
parent
());
ArrowAttachItem
*
arrow
=
new
ArrowAttachItem
(
card
);
scene
()
->
addItem
(
arrow
);
arrow
->
grabMouse
();
}
void
Player
::
actUnattach
()
void
Player
::
actUnattach
(
QAction
*
a
)
{
CardItem
*
card
=
static_cast
<
CardItem
*>
(
sender
()
->
parent
());
CardItem
*
card
=
static_cast
<
CardItem
*>
(
a
->
parent
());
sendGameCommand
(
new
Command_AttachCard
(
-
1
,
card
->
getZone
()
->
getName
(),
card
->
getId
(),
-
1
,
QString
(),
-
1
));
}
void
Player
::
actCardCounterTrigger
()
void
Player
::
actCardCounterTrigger
(
QAction
*
a
)
{
QAction
*
a
=
static_cast
<
QAction
*>
(
sender
());
int
counterId
=
a
->
data
().
toInt
()
/
1000
;
int
action
=
a
->
data
().
toInt
()
%
1000
;
switch
(
action
)
{
...
...
cockatrice/src/player.h
View file @
23188736
...
...
@@ -94,12 +94,12 @@ public slots:
void
actSayMessage
();
void
actAttach
();
void
actUnattach
();
void
actSetPT
();
void
actSetAnnotation
();
void
cardMenuAction
();
void
actCardCounterTrigger
();
void
actAttach
(
QAction
*
action
);
void
actUnattach
(
QAction
*
action
);
void
actSetPT
(
QAction
*
action
);
void
actSetAnnotation
(
QAction
*
action
);
void
cardMenuAction
(
QAction
*
action
);
void
actCardCounterTrigger
(
QAction
*
action
);
private
slots
:
void
addPlayer
(
Player
*
player
);
...
...
cockatrice/src/stackzone.cpp
View file @
23188736
...
...
@@ -5,6 +5,7 @@
#include
"settingscache.h"
#include
"player.h"
#include
"protocol_items.h"
#include
"carddragitem.h"
StackZone
::
StackZone
(
Player
*
_p
,
int
_zoneHeight
,
QGraphicsItem
*
parent
)
:
SelectZone
(
_p
,
"stack"
,
false
,
false
,
true
,
parent
),
zoneHeight
(
_zoneHeight
)
...
...
@@ -51,11 +52,11 @@ void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio
painter
->
fillRect
(
boundingRect
(),
QBrush
(
bgPixmap
));
}
void
StackZone
::
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
void
StackZone
::
handleDropEvent
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
{
if
(
startZone
==
this
)
return
;
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
cardId
,
getName
(),
0
,
0
,
false
));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
dragItem
->
getId
(),
player
->
getId
()
,
getName
(),
0
,
0
,
false
));
}
void
StackZone
::
reorganizeCards
()
...
...
cockatrice/src/stackzone.h
View file @
23188736
...
...
@@ -12,7 +12,7 @@ private slots:
void
updateBgPixmap
();
public:
StackZone
(
Player
*
_p
,
int
_zoneHeight
,
QGraphicsItem
*
parent
=
0
);
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
void
handleDropEvent
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
reorganizeCards
();
...
...
cockatrice/src/tablezone.cpp
View file @
23188736
...
...
@@ -7,6 +7,7 @@
#include
"protocol_items.h"
#include
"settingscache.h"
#include
"arrowitem.h"
#include
"carddragitem.h"
TableZone
::
TableZone
(
Player
*
_p
,
QGraphicsItem
*
parent
)
:
SelectZone
(
_p
,
"table"
,
true
,
false
,
true
,
parent
),
active
(
false
)
...
...
@@ -84,14 +85,14 @@ void TableZone::addCardImpl(CardItem *card, int _x, int _y)
card
->
update
();
}
void
TableZone
::
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
)
void
TableZone
::
handleDropEvent
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
)
{
handleDropEventByGrid
(
cardId
,
startZone
,
mapToGrid
(
dropPoint
),
faceDown
);
handleDropEventByGrid
(
dragItem
,
startZone
,
mapToGrid
(
dropPoint
),
faceDown
);
}
void
TableZone
::
handleDropEventByGrid
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
gridPoint
,
bool
faceDown
,
bool
tapped
)
void
TableZone
::
handleDropEventByGrid
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
gridPoint
,
bool
faceDown
,
bool
tapped
)
{
p
layer
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
cardId
,
getName
(),
gridPoint
.
x
(),
gridPoint
.
y
(),
faceDown
,
tapped
));
static_cast
<
CardItem
*>
(
dragItem
->
getItem
())
->
getZone
()
->
getP
layer
()
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
dragItem
->
getId
(),
player
->
getId
()
,
getName
(),
gridPoint
.
x
(),
gridPoint
.
y
(),
faceDown
,
tapped
));
}
void
TableZone
::
reorganizeCards
()
...
...
@@ -223,18 +224,21 @@ CardItem *TableZone::getCardFromCoords(const QPointF &point) const
return
getCardFromGrid
(
gridPoint
);
}
QPointF
TableZone
::
mapFromGrid
(
const
QPoint
&
gridPoint
)
const
QPointF
TableZone
::
mapFromGrid
(
QPoint
gridPoint
)
const
{
qreal
x
,
y
;
x
=
marginX
+
(
gridPoint
.
x
()
%
3
)
*
CARD_WIDTH
/
3.0
;
for
(
int
i
=
0
;
i
<
gridPoint
.
x
()
/
3
;
++
i
)
x
+=
gridPointWidth
.
value
(
gridPoint
.
y
()
*
1000
+
i
,
CARD_WIDTH
)
+
paddingX
;
y
=
boxLineWidth
+
gridPoint
.
y
()
*
(
CARD_HEIGHT
+
paddingY
+
20
)
+
(
gridPoint
.
x
()
%
3
)
*
10
;
if
(
isInverted
())
gridPoint
.
setY
(
2
-
gridPoint
.
y
());
y
=
boxLineWidth
+
gridPoint
.
y
()
*
(
CARD_HEIGHT
+
paddingY
+
20
)
+
(
gridPoint
.
x
()
%
3
)
*
10
;
/*
if (isInverted())
y = height - CARD_HEIGHT - y;
*/
return
QPointF
(
x
,
y
);
}
...
...
@@ -242,9 +246,9 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
{
qreal
x
=
mapPoint
.
x
()
-
marginX
;
qreal
y
=
mapPoint
.
y
();
if
(
isInverted
())
/*
if (isInverted())
y = height - y;
y
-=
boxLineWidth
;
*/
y
-=
boxLineWidth
;
if
(
x
<
0
)
x
=
0
;
...
...
@@ -256,6 +260,8 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
y
=
height
-
CARD_HEIGHT
;
int
resultY
=
round
(
y
/
(
CARD_HEIGHT
+
paddingY
+
20
));
if
(
isInverted
())
resultY
=
2
-
resultY
;
int
baseX
=
-
1
;
qreal
oldTempX
=
0
,
tempX
=
0
;
...
...
cockatrice/src/tablezone.h
View file @
23188736
...
...
@@ -29,11 +29,11 @@ public:
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
toggleTapped
();
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
=
false
);
void
handleDropEventByGrid
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
gridPoint
,
bool
faceDown
=
false
,
bool
tapped
=
false
);
void
handleDropEvent
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
=
false
);
void
handleDropEventByGrid
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
gridPoint
,
bool
faceDown
=
false
,
bool
tapped
=
false
);
CardItem
*
getCardFromGrid
(
const
QPoint
&
gridPoint
)
const
;
CardItem
*
getCardFromCoords
(
const
QPointF
&
point
)
const
;
QPointF
mapFromGrid
(
const
QPoint
&
gridPoint
)
const
;
QPointF
mapFromGrid
(
QPoint
gridPoint
)
const
;
QPoint
mapToGrid
(
const
QPointF
&
mapPoint
)
const
;
QPointF
closestGridPoint
(
const
QPointF
&
point
);
CardItem
*
takeCard
(
int
position
,
int
cardId
,
bool
canResize
=
true
);
...
...
cockatrice/src/zoneviewzone.cpp
View file @
23188736
...
...
@@ -3,6 +3,7 @@
#include
"zoneviewzone.h"
#include
"player.h"
#include
"protocol_items.h"
#include
"carddragitem.h"
ZoneViewZone
::
ZoneViewZone
(
Player
*
_p
,
CardZone
*
_origZone
,
int
_numberCards
,
QGraphicsItem
*
parent
)
:
SelectZone
(
_p
,
_origZone
->
getName
(),
false
,
false
,
true
,
parent
,
true
),
bRect
(
QRectF
()),
minRows
(
0
),
numberCards
(
_numberCards
),
origZone
(
_origZone
),
sortByName
(
false
),
sortByType
(
false
)
...
...
@@ -122,9 +123,9 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
card
->
update
();
}
void
ZoneViewZone
::
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
void
ZoneViewZone
::
handleDropEvent
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
{
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
cardId
,
getName
(),
0
,
0
,
false
));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
dragItem
->
getId
(),
player
->
getId
()
,
getName
(),
0
,
0
,
false
));
}
void
ZoneViewZone
::
removeCard
(
int
position
)
...
...
cockatrice/src/zoneviewzone.h
View file @
23188736
...
...
@@ -13,7 +13,7 @@ class ZoneViewZone : public SelectZone, public QGraphicsLayoutItem {
private:
QRectF
bRect
,
optimumRect
;
int
minRows
,
numberCards
;
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
void
handleDropEvent
(
CardDragItem
*
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
CardZone
*
origZone
;
bool
sortByName
,
sortByType
;
public:
...
...
common/protocol_items.cpp
View file @
23188736
...
...
@@ -118,11 +118,12 @@ Command_DrawCards::Command_DrawCards(int _gameId, int _number)
{
insertItem
(
new
SerializableItem_Int
(
"number"
,
_number
));
}
Command_MoveCard
::
Command_MoveCard
(
int
_gameId
,
const
QString
&
_startZone
,
int
_cardId
,
const
QString
&
_targetZone
,
int
_x
,
int
_y
,
bool
_faceDown
,
bool
_tapped
)
Command_MoveCard
::
Command_MoveCard
(
int
_gameId
,
const
QString
&
_startZone
,
int
_cardId
,
int
_targetPlayerId
,
const
QString
&
_targetZone
,
int
_x
,
int
_y
,
bool
_faceDown
,
bool
_tapped
)
:
GameCommand
(
"move_card"
,
_gameId
)
{
insertItem
(
new
SerializableItem_String
(
"start_zone"
,
_startZone
));
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
insertItem
(
new
SerializableItem_Int
(
"target_player_id"
,
_targetPlayerId
));
insertItem
(
new
SerializableItem_String
(
"target_zone"
,
_targetZone
));
insertItem
(
new
SerializableItem_Int
(
"x"
,
_x
));
insertItem
(
new
SerializableItem_Int
(
"y"
,
_y
));
...
...
@@ -283,13 +284,14 @@ Event_RollDie::Event_RollDie(int _playerId, int _sides, int _value)
insertItem
(
new
SerializableItem_Int
(
"sides"
,
_sides
));
insertItem
(
new
SerializableItem_Int
(
"value"
,
_value
));
}
Event_MoveCard
::
Event_MoveCard
(
int
_playerId
,
int
_cardId
,
const
QString
&
_cardName
,
const
QString
&
_startZone
,
int
_position
,
const
QString
&
_targetZone
,
int
_x
,
int
_y
,
int
_newCardId
,
bool
_faceDown
)
Event_MoveCard
::
Event_MoveCard
(
int
_playerId
,
int
_cardId
,
const
QString
&
_cardName
,
const
QString
&
_startZone
,
int
_position
,
int
_targetPlayerId
,
const
QString
&
_targetZone
,
int
_x
,
int
_y
,
int
_newCardId
,
bool
_faceDown
)
:
GameEvent
(
"move_card"
,
_playerId
)
{
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
insertItem
(
new
SerializableItem_String
(
"card_name"
,
_cardName
));
insertItem
(
new
SerializableItem_String
(
"start_zone"
,
_startZone
));
insertItem
(
new
SerializableItem_Int
(
"position"
,
_position
));
insertItem
(
new
SerializableItem_Int
(
"target_player_id"
,
_targetPlayerId
));
insertItem
(
new
SerializableItem_String
(
"target_zone"
,
_targetZone
));
insertItem
(
new
SerializableItem_Int
(
"x"
,
_x
));
insertItem
(
new
SerializableItem_Int
(
"y"
,
_y
));
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment