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
9f79bd2c
Commit
9f79bd2c
authored
Jun 17, 2010
by
Max-Wilhelm Bruker
Browse files
nicer looking counters on cards
parent
f33abf14
Changes
5
Show whitespace changes
Inline
Side-by-side
cockatrice/src/abstractgraphicsitem.cpp
View file @
9f79bd2c
#include
"abstractgraphicsitem.h"
#include
"abstractgraphicsitem.h"
#include
<QPainter>
#include
<QPainter>
void
AbstractGraphicsItem
::
paintNumberEllipse
(
int
number
,
int
fontSize
,
const
QColor
&
color
,
int
position
,
QPainter
*
painter
)
void
AbstractGraphicsItem
::
paintNumberEllipse
(
int
number
,
int
fontSize
,
const
QColor
&
color
,
int
position
,
int
count
,
QPainter
*
painter
)
{
{
painter
->
save
();
painter
->
save
();
...
@@ -31,8 +31,13 @@ void AbstractGraphicsItem::paintNumberEllipse(int number, int fontSize, const QC
...
@@ -31,8 +31,13 @@ void AbstractGraphicsItem::paintNumberEllipse(int number, int fontSize, const QC
if
(
position
==
-
1
)
if
(
position
==
-
1
)
textRect
=
QRectF
((
boundingRect
().
width
()
-
w
)
/
2.0
,
(
boundingRect
().
height
()
-
h
)
/
2.0
,
w
,
h
);
textRect
=
QRectF
((
boundingRect
().
width
()
-
w
)
/
2.0
,
(
boundingRect
().
height
()
-
h
)
/
2.0
,
w
,
h
);
else
{
else
{
qreal
offset
=
boundingRect
().
width
()
/
20.0
;
qreal
xOffset
=
10
;
textRect
=
QRectF
(
offset
,
offset
*
(
position
+
1
)
+
h
*
position
,
w
,
h
);
qreal
yOffset
=
20
;
qreal
spacing
=
2
;
if
(
position
<
2
)
textRect
=
QRectF
(
count
==
1
?
((
boundingRect
().
width
()
-
w
)
/
2.0
)
:
(
position
%
2
==
0
?
xOffset
:
(
boundingRect
().
width
()
-
xOffset
-
w
)),
yOffset
,
w
,
h
);
else
textRect
=
QRectF
(
count
==
3
?
((
boundingRect
().
width
()
-
w
)
/
2.0
)
:
(
position
%
2
==
0
?
xOffset
:
(
boundingRect
().
width
()
-
xOffset
-
w
)),
yOffset
+
(
spacing
+
h
)
*
(
position
/
2
),
w
,
h
);
}
}
painter
->
drawEllipse
(
textRect
);
painter
->
drawEllipse
(
textRect
);
...
...
cockatrice/src/abstractgraphicsitem.h
View file @
9f79bd2c
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
class
AbstractGraphicsItem
:
public
QGraphicsItem
{
class
AbstractGraphicsItem
:
public
QGraphicsItem
{
protected:
protected:
void
paintNumberEllipse
(
int
number
,
int
radius
,
const
QColor
&
color
,
int
position
,
QPainter
*
painter
);
void
paintNumberEllipse
(
int
number
,
int
radius
,
const
QColor
&
color
,
int
position
,
int
count
,
QPainter
*
painter
);
public:
public:
AbstractGraphicsItem
(
QGraphicsItem
*
parent
=
0
)
:
QGraphicsItem
(
parent
)
{
}
AbstractGraphicsItem
(
QGraphicsItem
*
parent
=
0
)
:
QGraphicsItem
(
parent
)
{
}
};
};
...
...
cockatrice/src/carditem.cpp
View file @
9f79bd2c
...
@@ -34,7 +34,7 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
...
@@ -34,7 +34,7 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QColor
color
;
QColor
color
;
color
.
setHsv
(
counterIterator
.
key
()
*
60
,
150
,
255
);
color
.
setHsv
(
counterIterator
.
key
()
*
60
,
150
,
255
);
paintNumberEllipse
(
counterIterator
.
value
(),
14
,
color
,
i
,
painter
);
paintNumberEllipse
(
counterIterator
.
value
(),
14
,
color
,
i
,
counters
.
size
(),
painter
);
++
i
;
++
i
;
}
}
if
(
!
pt
.
isEmpty
())
{
if
(
!
pt
.
isEmpty
())
{
...
...
cockatrice/src/handcounter.cpp
View file @
9f79bd2c
...
@@ -42,5 +42,5 @@ void HandCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*op
...
@@ -42,5 +42,5 @@ void HandCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*op
painter
->
drawPixmap
(
cachedPixmap
.
rect
(),
cachedPixmap
,
cachedPixmap
.
rect
());
painter
->
drawPixmap
(
cachedPixmap
.
rect
(),
cachedPixmap
,
cachedPixmap
.
rect
());
painter
->
restore
();
painter
->
restore
();
paintNumberEllipse
(
number
,
24
,
Qt
::
white
,
-
1
,
painter
);
paintNumberEllipse
(
number
,
24
,
Qt
::
white
,
-
1
,
-
1
,
painter
);
}
}
cockatrice/src/pilezone.cpp
View file @
9f79bd2c
...
@@ -28,7 +28,7 @@ void PileZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
...
@@ -28,7 +28,7 @@ void PileZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
painter
->
restore
();
painter
->
restore
();
}
}
paintNumberEllipse
(
cards
.
size
(),
32
,
Qt
::
white
,
-
1
,
painter
);
paintNumberEllipse
(
cards
.
size
(),
32
,
Qt
::
white
,
-
1
,
-
1
,
painter
);
painter
->
drawRect
(
QRectF
(
0.5
,
0.5
,
CARD_WIDTH
-
1
,
CARD_HEIGHT
-
1
));
painter
->
drawRect
(
QRectF
(
0.5
,
0.5
,
CARD_WIDTH
-
1
,
CARD_HEIGHT
-
1
));
}
}
...
...
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