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
2451c39e
Commit
2451c39e
authored
Nov 05, 2010
by
Max-Wilhelm Bruker
Browse files
fixed player area layout
parent
7bff2044
Changes
7
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/abstractcarditem.cpp
View file @
2451c39e
...
...
@@ -50,7 +50,7 @@ QSizeF AbstractCardItem::getTranslatedSize(QPainter *painter) const
);
}
void
AbstractCardItem
::
transformPainter
(
QPainter
*
painter
,
const
QSizeF
&
translatedSize
)
void
AbstractCardItem
::
transformPainter
(
QPainter
*
painter
,
const
QSizeF
&
translatedSize
,
int
angle
)
{
QRectF
totalBoundingRect
=
painter
->
combinedTransform
().
mapRect
(
boundingRect
());
...
...
@@ -58,7 +58,7 @@ void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &transla
QTransform
pixmapTransform
;
pixmapTransform
.
translate
(
totalBoundingRect
.
width
()
/
2
,
totalBoundingRect
.
height
()
/
2
);
pixmapTransform
.
rotate
(
tapA
ngle
);
pixmapTransform
.
rotate
(
a
ngle
);
pixmapTransform
.
translate
(
-
translatedSize
.
width
()
/
2
,
-
translatedSize
.
height
()
/
2
);
painter
->
setTransform
(
pixmapTransform
);
...
...
@@ -70,16 +70,16 @@ void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &transla
painter
->
setFont
(
f
);
}
void
AbstractCardItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
void
AbstractCardItem
::
paint
Picture
(
QPainter
*
painter
,
int
angle
)
{
painter
->
save
();
QSizeF
translatedSize
=
getTranslatedSize
(
painter
);
QRectF
totalBoundingRect
=
painter
->
combinedTransform
().
mapRect
(
boundingRect
());
qreal
scaleFactor
=
translatedSize
.
width
()
/
boundingRect
().
width
();
QPixmap
*
translatedPixmap
=
info
->
getPixmap
(
translatedSize
.
toSize
());
painter
->
save
();
if
(
translatedPixmap
)
{
transformPainter
(
painter
,
translatedSize
);
transformPainter
(
painter
,
translatedSize
,
angle
);
painter
->
drawPixmap
(
QPointF
(
0
,
0
),
*
translatedPixmap
);
}
else
{
QString
colorStr
;
...
...
@@ -116,12 +116,19 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
painter
->
setPen
(
pen
);
painter
->
drawRect
(
QRectF
(
1
,
1
,
CARD_WIDTH
-
2
,
CARD_HEIGHT
-
2
));
transformPainter
(
painter
,
translatedSize
);
transformPainter
(
painter
,
translatedSize
,
angle
);
painter
->
setPen
(
textColor
);
painter
->
drawText
(
QRectF
(
4
*
scaleFactor
,
4
*
scaleFactor
,
translatedSize
.
width
()
-
8
*
scaleFactor
,
translatedSize
.
height
()
-
8
*
scaleFactor
),
Qt
::
AlignTop
|
Qt
::
AlignLeft
|
Qt
::
TextWrapAnywhere
,
name
);
}
painter
->
restore
();
}
void
AbstractCardItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
{
painter
->
save
();
paintPicture
(
painter
,
tapAngle
);
if
(
isSelected
())
{
painter
->
setPen
(
Qt
::
red
);
painter
->
drawRect
(
QRectF
(
0.5
,
0.5
,
CARD_WIDTH
-
1
,
CARD_HEIGHT
-
1
));
...
...
cockatrice/src/abstractcarditem.h
View file @
2451c39e
...
...
@@ -35,6 +35,7 @@ public:
AbstractCardItem
(
const
QString
&
_name
=
QString
(),
Player
*
_owner
=
0
,
QGraphicsItem
*
parent
=
0
);
~
AbstractCardItem
();
QRectF
boundingRect
()
const
;
void
paintPicture
(
QPainter
*
painter
,
int
angle
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
CardInfo
*
getInfo
()
const
{
return
info
;
}
QString
getName
()
const
{
return
name
;
}
...
...
@@ -46,7 +47,7 @@ public:
void
processHoverEvent
();
protected:
QSizeF
getTranslatedSize
(
QPainter
*
painter
)
const
;
void
transformPainter
(
QPainter
*
painter
,
const
QSizeF
&
translatedSize
);
void
transformPainter
(
QPainter
*
painter
,
const
QSizeF
&
translatedSize
,
int
angle
);
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
...
...
cockatrice/src/carditem.cpp
View file @
2451c39e
...
...
@@ -174,7 +174,7 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QSizeF
translatedSize
=
getTranslatedSize
(
painter
);
qreal
scaleFactor
=
translatedSize
.
width
()
/
boundingRect
().
width
();
transformPainter
(
painter
,
translatedSize
);
transformPainter
(
painter
,
translatedSize
,
tapAngle
);
painter
->
setBackground
(
Qt
::
black
);
painter
->
setBackgroundMode
(
Qt
::
OpaqueMode
);
painter
->
setPen
(
Qt
::
white
);
...
...
cockatrice/src/gamescene.cpp
View file @
2451c39e
...
...
@@ -3,6 +3,7 @@
#include
"zoneviewwidget.h"
#include
"zoneviewzone.h"
#include
<QAction>
#include
<QDebug>
GameScene
::
GameScene
(
QObject
*
parent
)
:
QGraphicsScene
(
parent
)
...
...
@@ -131,10 +132,10 @@ void GameScene::processViewSizeChange(const QSize &newSize)
qreal
minRatio
=
minWidth
/
sceneRect
().
height
();
if
(
minRatio
>
newRatio
)
{
// Aspect ratio is dominated by table width.
setSceneRect
(
sceneRect
().
x
(),
sceneRect
().
y
()
,
minWidth
,
sceneRect
().
height
());
setSceneRect
(
0
,
0
,
minWidth
,
sceneRect
().
height
());
}
else
{
// Aspect ratio is dominated by window dimensions.
setSceneRect
(
sceneRect
().
x
(),
sceneRect
().
y
()
,
newRatio
*
sceneRect
().
height
(),
sceneRect
().
height
());
setSceneRect
(
0
,
0
,
newRatio
*
sceneRect
().
height
(),
sceneRect
().
height
());
}
for
(
int
i
=
0
;
i
<
players
.
size
();
++
i
)
...
...
cockatrice/src/pilezone.cpp
View file @
2451c39e
...
...
@@ -13,6 +13,8 @@ PileZone::PileZone(Player *_p, const QString &_name, bool _isShufflable, bool _c
setCacheMode
(
DeviceCoordinateCache
);
// Do not move this line to the parent constructor!
setAcceptsHoverEvents
(
true
);
setCursor
(
Qt
::
OpenHandCursor
);
setTransform
(
QTransform
().
translate
((
float
)
CARD_WIDTH
/
2
,
(
float
)
CARD_HEIGHT
/
2
).
rotate
(
90
).
translate
((
float
)
-
CARD_WIDTH
/
2
,
(
float
)
-
CARD_HEIGHT
/
2
));
}
QRectF
PileZone
::
boundingRect
()
const
...
...
@@ -22,14 +24,15 @@ QRectF PileZone::boundingRect() const
void
PileZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
if
(
!
cards
.
isEmpty
())
{
painter
->
save
();
cards
.
at
(
0
)
->
paint
(
painter
,
option
,
widget
);
painter
->
restore
();
}
if
(
!
cards
.
isEmpty
())
cards
.
at
(
0
)
->
paintPicture
(
painter
,
90
);
paintNumberEllipse
(
cards
.
size
(),
32
,
Qt
::
white
,
-
1
,
-
1
,
painter
);
painter
->
drawRect
(
QRectF
(
0.5
,
0.5
,
CARD_WIDTH
-
1
,
CARD_HEIGHT
-
1
));
painter
->
translate
((
float
)
CARD_WIDTH
/
2
,
(
float
)
CARD_HEIGHT
/
2
);
painter
->
rotate
(
-
90
);
painter
->
translate
((
float
)
-
CARD_WIDTH
/
2
,
(
float
)
-
CARD_HEIGHT
/
2
);
paintNumberEllipse
(
cards
.
size
(),
28
,
Qt
::
white
,
-
1
,
-
1
,
painter
);
}
void
PileZone
::
addCardImpl
(
CardItem
*
card
,
int
x
,
int
/*y*/
)
...
...
cockatrice/src/player.cpp
View file @
2451c39e
...
...
@@ -32,14 +32,13 @@ Player::Player(ServerInfo_User *info, int _id, bool _local, TabGame *_parent)
updateBgPixmap
();
playerTarget
=
new
PlayerTarget
(
this
);
playerTarget
->
setPos
(
QPointF
(
counterAreaWidth
+
(
CARD_WIDTH
+
5
-
playerTarget
->
boundingRect
().
width
())
/
2.0
,
5
));
QPointF
base
=
QPointF
(
counterAreaWidth
,
5
+
playerTarget
->
boundingRect
().
height
()
+
10
);
playerTarget
->
setPos
(
QPointF
(
counterAreaWidth
+
(
CARD_HEIGHT
+
5
-
playerTarget
->
boundingRect
().
width
())
/
2.0
,
5
));
PileZone
*
deck
=
new
PileZone
(
this
,
"deck"
,
true
,
false
,
this
);
QPointF
base
=
QPointF
(
counterAreaWidth
+
(
CARD_HEIGHT
-
CARD_WIDTH
+
5
)
/
2.0
,
5
+
playerTarget
->
boundingRect
().
height
()
+
5
-
(
CARD_HEIGHT
-
CARD_WIDTH
)
/
2.0
);
deck
->
setPos
(
base
);
qreal
h
=
deck
->
boundingRect
().
height
()
+
10
;
qreal
h
=
deck
->
boundingRect
().
width
()
+
5
;
PileZone
*
grave
=
new
PileZone
(
this
,
"grave"
,
false
,
true
,
this
);
grave
->
setPos
(
base
+
QPointF
(
0
,
h
));
...
...
@@ -51,7 +50,7 @@ Player::Player(ServerInfo_User *info, int _id, bool _local, TabGame *_parent)
sb
->
setVisible
(
false
);
HandCounter
*
handCounter
=
new
HandCounter
(
this
);
handCounter
->
setPos
(
base
+
QPointF
(
0
,
3
*
h
));
handCounter
->
setPos
(
base
+
QPointF
(
0
,
3
*
h
+
7
));
table
=
new
TableZone
(
this
,
this
);
connect
(
table
,
SIGNAL
(
sizeChanged
()),
this
,
SLOT
(
updateBoundingRect
()));
...
...
@@ -310,7 +309,7 @@ void Player::playerListActionTriggered()
void
Player
::
rearrangeZones
()
{
QPointF
base
=
QPointF
(
CARD_
WIDTH
+
counterAreaWidth
+
5
,
0
);
QPointF
base
=
QPointF
(
CARD_
HEIGHT
+
counterAreaWidth
+
5
,
0
);
if
(
settingsCache
->
getHorizontalHand
())
{
if
(
mirrored
)
{
...
...
@@ -358,7 +357,7 @@ void Player::updateBgPixmap()
void
Player
::
updateBoundingRect
()
{
prepareGeometryChange
();
qreal
width
=
CARD_
WIDTH
+
5
+
counterAreaWidth
+
stack
->
boundingRect
().
width
();
qreal
width
=
CARD_
HEIGHT
+
5
+
counterAreaWidth
+
stack
->
boundingRect
().
width
();
if
(
settingsCache
->
getHorizontalHand
())
bRect
=
QRectF
(
0
,
0
,
width
+
table
->
boundingRect
().
width
(),
table
->
boundingRect
().
height
()
+
hand
->
boundingRect
().
height
());
else
...
...
@@ -981,7 +980,7 @@ QRectF Player::boundingRect() const
void
Player
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
{
int
totalWidth
=
CARD_
WIDTH
+
counterAreaWidth
+
5
;
int
totalWidth
=
CARD_
HEIGHT
+
counterAreaWidth
+
5
;
if
(
bgPixmap
.
isNull
())
painter
->
fillRect
(
QRectF
(
0
,
0
,
totalWidth
,
boundingRect
().
height
()),
QColor
(
200
,
200
,
200
));
else
...
...
@@ -1404,7 +1403,7 @@ QString Player::getName() const
qreal
Player
::
getMinimumWidth
()
const
{
qreal
result
=
table
->
getMinimumWidth
()
+
CARD_
WIDTH
+
5
+
counterAreaWidth
+
stack
->
boundingRect
().
width
();
qreal
result
=
table
->
getMinimumWidth
()
+
CARD_
HEIGHT
+
5
+
counterAreaWidth
+
stack
->
boundingRect
().
width
();
if
(
!
settingsCache
->
getHorizontalHand
())
result
+=
hand
->
boundingRect
().
width
();
return
result
;
...
...
@@ -1423,7 +1422,7 @@ void Player::processSceneSizeChange(const QSizeF &newSize)
// This will need to be changed if player areas are displayed side by side (e.g. 2x2 for a 4-player game)
qreal
fullPlayerWidth
=
newSize
.
width
();
qreal
tableWidth
=
fullPlayerWidth
-
CARD_
WIDTH
-
5
-
counterAreaWidth
-
stack
->
boundingRect
().
width
();
qreal
tableWidth
=
fullPlayerWidth
-
CARD_
HEIGHT
-
5
-
counterAreaWidth
-
stack
->
boundingRect
().
width
();
if
(
!
settingsCache
->
getHorizontalHand
())
tableWidth
-=
hand
->
boundingRect
().
width
();
...
...
cockatrice/src/playertarget.cpp
View file @
2451c39e
...
...
@@ -17,7 +17,7 @@ PlayerTarget::PlayerTarget(Player *_owner)
QRectF
PlayerTarget
::
boundingRect
()
const
{
return
QRectF
(
0
,
0
,
64
,
64
);
return
QRectF
(
0
,
0
,
100
,
64
);
}
void
PlayerTarget
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
/*option*/
,
QWidget
*
/*widget*/
)
...
...
@@ -41,7 +41,10 @@ void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*o
QPixmapCache
::
insert
(
cacheKey
,
cachedPixmap
);
}
painter
->
resetTransform
();
painter
->
translate
((
translatedSize
.
width
()
-
cachedPixmap
.
width
())
/
2.0
,
0
);
painter
->
drawPixmap
(
cachedPixmap
.
rect
(),
cachedPixmap
,
cachedPixmap
.
rect
());
painter
->
resetTransform
();
QString
name
=
info
->
getName
();
if
(
name
.
size
()
>
13
)
...
...
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