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
0fdc01f6
Commit
0fdc01f6
authored
Nov 10, 2010
by
Max-Wilhelm Bruker
Browse files
GameScene::event() optimization
parent
f7963e71
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/abstractcarditem.cpp
View file @
0fdc01f6
...
...
@@ -173,6 +173,9 @@ void AbstractCardItem::setName(const QString &_name)
void
AbstractCardItem
::
setHovered
(
bool
_hovered
)
{
if
(
isHovered
==
_hovered
)
return
;
isHovered
=
_hovered
;
setZValue
(
_hovered
?
2000000004
:
realZValue
);
update
();
...
...
cockatrice/src/gamescene.cpp
View file @
0fdc01f6
...
...
@@ -145,11 +145,13 @@ bool GameScene::event(QEvent *event)
if
(
event
->
type
()
==
QEvent
::
GraphicsSceneMouseMove
)
{
QGraphicsSceneMouseEvent
*
mouseEvent
=
static_cast
<
QGraphicsSceneMouseEvent
*>
(
event
);
QSet
<
CardItem
*>
cardsToUnhover
;
QList
<
QGraphicsItem
*>
oldItemList
=
items
(
mouseEvent
->
lastScenePos
());
for
(
int
i
=
0
;
i
<
oldItemList
.
size
();
++
i
)
{
CardItem
*
card
=
qgraphicsitem_cast
<
CardItem
*>
(
oldItemList
[
i
]);
if
(
card
)
card
->
setHovered
(
false
);
card
sToUnhover
.
insert
(
card
);
}
QList
<
QGraphicsItem
*>
itemList
=
items
(
mouseEvent
->
scenePos
());
...
...
@@ -159,24 +161,31 @@ bool GameScene::event(QEvent *event)
for
(
int
i
=
0
;
i
<
itemList
.
size
();
++
i
)
if
((
zone
=
qgraphicsitem_cast
<
CardZone
*>
(
itemList
[
i
])))
break
;
if
(
zone
)
{
qreal
maxZ
=
-
1
;
CardItem
*
maxZCard
=
0
;
QList
<
CardItem
*>
cardList
;
qreal
maxZ
=
-
1
;
for
(
int
i
=
0
;
i
<
itemList
.
size
();
++
i
)
{
CardItem
*
card
=
qgraphicsitem_cast
<
CardItem
*>
(
itemList
[
i
]);
if
(
!
card
)
continue
;
if
(
card
->
getZone
()
!=
zone
)
continue
;
cardList
.
append
(
card
);
if
(
card
->
getRealZValue
()
>
maxZ
)
{
maxZ
=
card
->
getRealZValue
();
maxZCard
=
card
;
}
cardsToUnhover
.
insert
(
card
);
}
if
(
maxZCard
)
{
cardsToUnhover
.
remove
(
maxZCard
);
maxZCard
->
setHovered
(
true
);
}
for
(
int
i
=
0
;
i
<
cardList
.
size
();
++
i
)
cardList
[
i
]
->
setHovered
(
cardList
[
i
]
==
maxZCard
);
}
QSet
<
CardItem
*>::
const_iterator
i
=
cardsToUnhover
.
constBegin
();
while
(
i
!=
cardsToUnhover
.
constEnd
())
{
(
*
i
)
->
setHovered
(
false
);
++
i
;
}
}
return
QGraphicsScene
::
event
(
event
);
...
...
cockatrice/translations/cockatrice_de.ts
View file @
0fdc01f6
This diff is collapsed.
Click to expand it.
cockatrice/translations/cockatrice_en.ts
View file @
0fdc01f6
This diff is collapsed.
Click to expand it.
cockatrice/translations/cockatrice_es.ts
View file @
0fdc01f6
This diff is collapsed.
Click to expand it.
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