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
92d40515
Commit
92d40515
authored
Nov 09, 2010
by
Max-Wilhelm Bruker
Browse files
changed card hover handling
parent
5b7dd037
Changes
12
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/arrowitem.cpp
View file @
92d40515
...
...
@@ -153,12 +153,14 @@ void ArrowDragItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QPointF
endPos
=
event
->
scenePos
();
QList
<
QGraphicsItem
*>
colliding
=
scene
()
->
items
(
endPos
);
ArrowTarget
*
cursorItem
=
0
;
for
(
int
i
=
colliding
.
size
()
-
1
;
i
>=
0
;
i
--
)
if
(
qgraphicsitem_cast
<
PlayerTarget
*>
(
colliding
.
at
(
i
))
||
qgraphicsitem_cast
<
CardItem
*>
(
colliding
.
at
(
i
)))
{
cursorItem
=
static_cast
<
ArrowTarget
*>
(
colliding
.
at
(
i
));
break
;
}
ArrowTarget
*
cursorItem
=
0
;
int
cursorItemZ
=
-
1
;
for
(
int
i
=
colliding
.
size
()
-
1
;
i
>=
0
;
i
--
)
if
(
qgraphicsitem_cast
<
PlayerTarget
*>
(
colliding
.
at
(
i
))
||
qgraphicsitem_cast
<
CardItem
*>
(
colliding
.
at
(
i
)))
if
(
colliding
.
at
(
i
)
->
zValue
()
>
cursorItemZ
)
{
cursorItem
=
static_cast
<
ArrowTarget
*>
(
colliding
.
at
(
i
));
cursorItemZ
=
cursorItem
->
zValue
();
}
if
((
cursorItem
!=
targetItem
)
&&
targetItem
)
{
targetItem
->
setBeingPointedAt
(
false
);
targetItem
->
removeArrowTo
(
this
);
...
...
cockatrice/src/carditem.cpp
View file @
92d40515
...
...
@@ -17,7 +17,7 @@
#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
),
id
(
_cardid
),
realZValue
(
0
),
attacking
(
false
),
facedown
(
false
),
destroyOnZoneChange
(
false
),
doesntUntap
(
false
),
dragItem
(
0
),
attachedTo
(
0
)
{
owner
->
addCard
(
this
);
...
...
@@ -154,6 +154,12 @@ void CardItem::retranslateUi()
}
}
void
CardItem
::
setRealZValue
(
qreal
_zValue
)
{
realZValue
=
_zValue
;
setZValue
(
_zValue
);
}
void
CardItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
painter
->
save
();
...
...
cockatrice/src/carditem.h
View file @
92d40515
...
...
@@ -17,6 +17,7 @@ class CardItem : public AbstractCardItem {
private:
CardZone
*
zone
;
int
id
;
qreal
realZValue
;
bool
attacking
;
bool
facedown
;
QMap
<
int
,
int
>
counters
;
...
...
@@ -47,6 +48,8 @@ public:
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QPoint
getGridPoint
()
const
{
return
gridPoint
;
}
void
setGridPoint
(
const
QPoint
&
_gridPoint
)
{
gridPoint
=
_gridPoint
;
}
qreal
getRealZValue
()
const
{
return
realZValue
;
}
void
setRealZValue
(
qreal
_zValue
);
QPoint
getGridPos
()
const
{
return
gridPoint
;
}
Player
*
getOwner
()
const
{
return
owner
;
}
int
getId
()
const
{
return
id
;
}
...
...
cockatrice/src/gamescene.cpp
View file @
92d40515
...
...
@@ -3,7 +3,7 @@
#include
"zoneviewwidget.h"
#include
"zoneviewzone.h"
#include
<QAction>
#include
<Q
Debug
>
#include
<Q
GraphicsSceneMouseEvent
>
GameScene
::
GameScene
(
QObject
*
parent
)
:
QGraphicsScene
(
parent
)
...
...
@@ -68,8 +68,6 @@ void GameScene::rearrange()
setSceneRect
(
sceneRect
().
x
(),
sceneRect
().
y
(),
sceneWidth
,
sceneHeight
);
processViewSizeChange
(
viewSize
);
qDebug
(
QString
(
"rearrange(): w=%1 h=%2"
).
arg
(
sceneWidth
).
arg
(
sceneHeight
).
toLatin1
());
}
void
GameScene
::
toggleZoneView
(
Player
*
player
,
const
QString
&
zoneName
,
int
numberCards
)
...
...
@@ -141,3 +139,35 @@ void GameScene::processViewSizeChange(const QSize &newSize)
for
(
int
i
=
0
;
i
<
players
.
size
();
++
i
)
players
[
i
]
->
processSceneSizeChange
(
sceneRect
().
size
());
}
bool
GameScene
::
event
(
QEvent
*
event
)
{
if
(
event
->
type
()
==
QEvent
::
GraphicsSceneMouseMove
)
{
QGraphicsSceneMouseEvent
*
mouseEvent
=
static_cast
<
QGraphicsSceneMouseEvent
*>
(
event
);
QList
<
QGraphicsItem
*>
oldItemList
=
items
(
mouseEvent
->
lastScenePos
());
for
(
int
i
=
0
;
i
<
oldItemList
.
size
();
++
i
)
{
CardItem
*
card
=
qgraphicsitem_cast
<
CardItem
*>
(
oldItemList
[
i
]);
if
(
card
)
card
->
setZValue
(
card
->
getRealZValue
());
}
QList
<
QGraphicsItem
*>
itemList
=
items
(
mouseEvent
->
scenePos
());
qreal
maxZ
=
0
;
CardItem
*
maxZCard
=
0
;
QList
<
CardItem
*>
cardList
;
for
(
int
i
=
0
;
i
<
itemList
.
size
();
++
i
)
{
CardItem
*
card
=
qgraphicsitem_cast
<
CardItem
*>
(
itemList
[
i
]);
if
(
!
card
)
continue
;
cardList
.
append
(
card
);
if
(
card
->
getRealZValue
()
>
maxZ
)
{
maxZ
=
card
->
getRealZValue
();
maxZCard
=
card
;
}
}
for
(
int
i
=
0
;
i
<
cardList
.
size
();
++
i
)
cardList
[
i
]
->
setZValue
(
cardList
[
i
]
==
maxZCard
?
2000000004
:
cardList
[
i
]
->
getRealZValue
());
}
return
QGraphicsScene
::
event
(
event
);
}
cockatrice/src/gamescene.h
View file @
92d40515
...
...
@@ -33,6 +33,8 @@ public slots:
void
closeMostRecentZoneView
();
private
slots
:
void
rearrange
();
protected:
bool
event
(
QEvent
*
event
);
};
#endif
cockatrice/src/handzone.cpp
View file @
92d40515
...
...
@@ -75,7 +75,7 @@ void HandZone::reorganizeCards()
c
->
setPos
(
xPadding
+
((
qreal
)
i
)
*
(
totalWidth
-
cardWidth
)
/
(
cardCount
-
1
),
5
);
else
c
->
setPos
(
xPadding
+
((
qreal
)
i
)
*
cardWidth
+
(
totalWidth
-
cardCount
*
cardWidth
)
/
2
,
5
);
c
->
setZValue
(
i
);
c
->
set
Real
ZValue
(
i
);
}
}
else
{
qreal
totalWidth
=
boundingRect
().
width
();
...
...
@@ -95,7 +95,7 @@ void HandZone::reorganizeCards()
c
->
setPos
(
x
,
((
qreal
)
i
)
*
(
totalHeight
-
cardHeight
)
/
(
cardCount
-
1
));
else
c
->
setPos
(
x
,
((
qreal
)
i
)
*
cardHeight
+
(
totalHeight
-
cardCount
*
cardHeight
)
/
2
);
c
->
setZValue
(
i
);
c
->
set
Real
ZValue
(
i
);
}
}
}
...
...
cockatrice/src/pilezone.cpp
View file @
92d40515
...
...
@@ -22,7 +22,7 @@ QRectF PileZone::boundingRect() const
return
QRectF
(
0
,
0
,
CARD_WIDTH
,
CARD_HEIGHT
);
}
void
PileZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
void
PileZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
/*
option
*/
,
QWidget
*
/*
widget
*/
)
{
if
(
!
cards
.
isEmpty
())
cards
.
at
(
0
)
->
paintPicture
(
painter
,
90
);
...
...
cockatrice/src/stackzone.cpp
View file @
92d40515
...
...
@@ -77,7 +77,7 @@ void StackZone::reorganizeCards()
c
->
setPos
(
x
,
((
qreal
)
i
)
*
(
totalHeight
-
cardHeight
)
/
(
cardCount
-
1
));
else
c
->
setPos
(
x
,
((
qreal
)
i
)
*
cardHeight
+
(
totalHeight
-
cardCount
*
cardHeight
)
/
2
);
c
->
setZValue
(
i
);
c
->
set
Real
ZValue
(
i
);
}
}
update
();
...
...
cockatrice/src/tablezone.cpp
View file @
92d40515
...
...
@@ -128,7 +128,7 @@ void TableZone::reorganizeCards()
actualY
+=
5
;
cards
[
i
]
->
setPos
(
actualX
,
actualY
);
cards
[
i
]
->
setZValue
((
actualY
+
CARD_HEIGHT
)
*
100000
00
+
(
actualX
+
1
)
*
100
00
);
cards
[
i
]
->
set
Real
ZValue
((
actualY
+
CARD_HEIGHT
)
*
100000
+
(
actualX
+
1
)
*
100
);
QListIterator
<
CardItem
*>
attachedCardIterator
(
cards
[
i
]
->
getAttachedCards
());
int
j
=
0
;
...
...
@@ -138,7 +138,7 @@ void TableZone::reorganizeCards()
qreal
childX
=
actualX
-
j
*
CARD_WIDTH
/
3.0
;
qreal
childY
=
y
-
5
;
attachedCard
->
setPos
(
childX
,
childY
);
attachedCard
->
setZValue
((
childY
+
CARD_HEIGHT
)
*
100000
00
+
(
childX
+
1
)
*
100
00
);
attachedCard
->
set
Real
ZValue
((
childY
+
CARD_HEIGHT
)
*
100000
+
(
childX
+
1
)
*
100
);
arrowsToUpdate
.
append
(
attachedCard
->
getArrowsFrom
());
arrowsToUpdate
.
append
(
attachedCard
->
getArrowsTo
());
...
...
cockatrice/src/zoneviewwidget.cpp
View file @
92d40515
...
...
@@ -13,7 +13,7 @@ ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberC
:
QGraphicsWidget
(
0
,
Qt
::
Tool
|
Qt
::
CustomizeWindowHint
|
Qt
::
WindowSystemMenuHint
|
Qt
::
WindowTitleHint
/* | Qt::WindowCloseButtonHint*/
),
player
(
_player
)
{
setAttribute
(
Qt
::
WA_DeleteOnClose
);
setZValue
(
100
);
setZValue
(
2000000006
);
QFont
font
;
font
.
setPixelSize
(
10
);
...
...
cockatrice/src/zoneviewzone.cpp
View file @
92d40515
...
...
@@ -95,7 +95,7 @@ void ZoneViewZone::reorganizeCards()
qreal
x
=
(
i
/
rows
)
*
CARD_WIDTH
;
qreal
y
=
(
i
%
rows
)
*
CARD_HEIGHT
/
3
;
c
->
setPos
(
x
,
y
);
c
->
setZValue
(
i
);
c
->
set
Real
ZValue
(
i
);
}
optimumRect
=
QRectF
(
0
,
0
,
cols
*
CARD_WIDTH
,
((
rows
-
1
)
*
CARD_HEIGHT
)
/
3
+
CARD_HEIGHT
);
...
...
common/server_protocolhandler.cpp
View file @
92d40515
...
...
@@ -791,6 +791,11 @@ ResponseCode Server_ProtocolHandler::cmdAttachCard(Command_AttachCard *cmd, Comm
}
if
(
targetCard
)
{
// Unattach all cards attached to the card being attached.
const
QList
<
Server_Card
*>
&
attachedList
=
card
->
getAttachedCards
();
for
(
int
i
=
0
;
i
<
attachedList
.
size
();
++
i
)
unattachCard
(
game
,
player
,
cont
,
attachedList
[
i
]);
card
->
setParentCard
(
targetCard
);
card
->
setCoords
(
-
1
,
card
->
getY
());
cont
->
enqueueGameEventPrivate
(
new
Event_AttachCard
(
player
->
getPlayerId
(),
startzone
->
getName
(),
card
->
getId
(),
targetPlayer
->
getPlayerId
(),
targetzone
->
getName
(),
targetCard
->
getId
()),
game
->
getGameId
());
...
...
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