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
ae82996c
Commit
ae82996c
authored
Jun 30, 2009
by
Max-Wilhelm Bruker
Browse files
made counters look nicer
parent
5d40996c
Changes
9
Hide whitespace changes
Inline
Side-by-side
cockatrice/cockatrice.pro
View file @
ae82996c
...
@@ -16,5 +16,5 @@ QT += network svg
...
@@ -16,5 +16,5 @@ QT += network svg
#
QTPLUGIN
+=
qjpeg
#
QTPLUGIN
+=
qjpeg
#
Input
#
Input
HEADERS
+=
src
/
counter
.
h
src
/
gameselector
.
h
src
/
dlg_creategame
.
h
src
/
dlg_connect
.
h
src
/
gamesmodel
.
h
src
/
client
.
h
src
/
window_main
.
h
src
/
servergame
.
h
src
/
servereventdata
.
h
src
/
zonelist
.
h
src
/
cardzone
.
h
src
/
player
.
h
src
/
cardlist
.
h
src
/
carditem
.
h
src
/
tablezone
.
h
src
/
handzone
.
h
src
/
playerlist
.
h
src
/
game
.
h
src
/
carddatabase
.
h
src
/
gameview
.
h
src
/
decklistmodel
.
h
src
/
dlg_startgame
.
h
src
/
cardinfowidget
.
h
src
/
messagelogwidget
.
h
src
/
serverzonecard
.
h
src
/
zoneviewzone
.
h
src
/
zoneviewwidget
.
h
src
/
libraryzone
.
h
src
/
pilezone
.
h
src
/
carddragitem
.
h
src
/
zoneviewlayout
.
h
src
/
playerarea
.
h
src
/
carddatabasemodel
.
h
src
/
window_deckeditor
.
h
src
/
decklist
.
h
setsmodel
.
h
src
/
window_sets
.
h
src
/
dlg_editmessages
.
h
HEADERS
+=
src
/
counter
.
h
src
/
gameselector
.
h
src
/
dlg_creategame
.
h
src
/
dlg_connect
.
h
src
/
gamesmodel
.
h
src
/
client
.
h
src
/
window_main
.
h
src
/
servergame
.
h
src
/
servereventdata
.
h
src
/
zonelist
.
h
src
/
cardzone
.
h
src
/
player
.
h
src
/
cardlist
.
h
src
/
carditem
.
h
src
/
tablezone
.
h
src
/
handzone
.
h
src
/
playerlist
.
h
src
/
game
.
h
src
/
carddatabase
.
h
src
/
gameview
.
h
src
/
decklistmodel
.
h
src
/
dlg_startgame
.
h
src
/
cardinfowidget
.
h
src
/
messagelogwidget
.
h
src
/
serverzonecard
.
h
src
/
zoneviewzone
.
h
src
/
zoneviewwidget
.
h
src
/
libraryzone
.
h
src
/
pilezone
.
h
src
/
carddragitem
.
h
src
/
zoneviewlayout
.
h
src
/
playerarea
.
h
src
/
carddatabasemodel
.
h
src
/
window_deckeditor
.
h
src
/
decklist
.
h
setsmodel
.
h
src
/
window_sets
.
h
src
/
dlg_editmessages
.
h
src
/
abstractgraphicsitem
.
h
SOURCES
+=
src
/
counter
.
cpp
src
/
gameselector
.
cpp
src
/
dlg_creategame
.
cpp
src
/
dlg_connect
.
cpp
src
/
client
.
cpp
src
/
main
.
cpp
src
/
window_main
.
cpp
src
/
servereventdata
.
cpp
src
/
gamesmodel
.
cpp
src
/
player
.
cpp
src
/
cardzone
.
cpp
src
/
zonelist
.
cpp
src
/
cardlist
.
cpp
src
/
carditem
.
cpp
src
/
tablezone
.
cpp
src
/
handzone
.
cpp
src
/
playerlist
.
cpp
src
/
game
.
cpp
src
/
carddatabase
.
cpp
src
/
gameview
.
cpp
src
/
decklistmodel
.
cpp
src
/
dlg_startgame
.
cpp
src
/
cardinfowidget
.
cpp
src
/
messagelogwidget
.
cpp
src
/
zoneviewzone
.
cpp
src
/
zoneviewwidget
.
cpp
src
/
libraryzone
.
cpp
src
/
pilezone
.
cpp
src
/
carddragitem
.
cpp
src
/
zoneviewlayout
.
cpp
src
/
playerarea
.
cpp
src
/
carddatabasemodel
.
cpp
src
/
window_deckeditor
.
cpp
src
/
decklist
.
cpp
src
/
setsmodel
.
cpp
src
/
window_sets
.
cpp
src
/
dlg_editmessages
.
cpp
SOURCES
+=
src
/
counter
.
cpp
src
/
gameselector
.
cpp
src
/
dlg_creategame
.
cpp
src
/
dlg_connect
.
cpp
src
/
client
.
cpp
src
/
main
.
cpp
src
/
window_main
.
cpp
src
/
servereventdata
.
cpp
src
/
gamesmodel
.
cpp
src
/
player
.
cpp
src
/
cardzone
.
cpp
src
/
zonelist
.
cpp
src
/
cardlist
.
cpp
src
/
carditem
.
cpp
src
/
tablezone
.
cpp
src
/
handzone
.
cpp
src
/
playerlist
.
cpp
src
/
game
.
cpp
src
/
carddatabase
.
cpp
src
/
gameview
.
cpp
src
/
decklistmodel
.
cpp
src
/
dlg_startgame
.
cpp
src
/
cardinfowidget
.
cpp
src
/
messagelogwidget
.
cpp
src
/
zoneviewzone
.
cpp
src
/
zoneviewwidget
.
cpp
src
/
libraryzone
.
cpp
src
/
pilezone
.
cpp
src
/
carddragitem
.
cpp
src
/
zoneviewlayout
.
cpp
src
/
playerarea
.
cpp
src
/
carddatabasemodel
.
cpp
src
/
window_deckeditor
.
cpp
src
/
decklist
.
cpp
src
/
setsmodel
.
cpp
src
/
window_sets
.
cpp
src
/
dlg_editmessages
.
cpp
src
/
abstractgraphicsitem
.
cpp
cockatrice/src/abstractgraphicsitem.cpp
0 → 100644
View file @
ae82996c
#include
"abstractgraphicsitem.h"
#include
<QPainter>
void
AbstractGraphicsItem
::
paintNumberEllipse
(
int
number
,
QPainter
*
painter
)
{
painter
->
save
();
QString
numStr
=
QString
::
number
(
number
);
QFont
font
(
"Times"
);
font
.
setPixelSize
(
32
);
font
.
setWeight
(
QFont
::
Bold
);
QFontMetrics
fm
(
font
);
double
w
=
fm
.
width
(
numStr
)
*
1.5
;
double
h
=
fm
.
height
()
*
1.5
;
if
(
w
<
h
)
w
=
h
;
painter
->
setPen
(
QColor
(
255
,
255
,
255
,
0
));
QRadialGradient
grad
(
QPointF
(
0.5
,
0.5
),
0.5
);
grad
.
setCoordinateMode
(
QGradient
::
ObjectBoundingMode
);
grad
.
setColorAt
(
0
,
QColor
(
255
,
255
,
255
,
200
));
grad
.
setColorAt
(
0.7
,
QColor
(
255
,
255
,
255
,
200
));
grad
.
setColorAt
(
1
,
QColor
(
255
,
255
,
255
,
0
));
painter
->
setBrush
(
QBrush
(
grad
));
painter
->
drawEllipse
(
QRectF
((
boundingRect
().
width
()
-
w
)
/
2.0
,
(
boundingRect
().
height
()
-
h
)
/
2.0
,
w
,
h
));
painter
->
setPen
(
Qt
::
black
);
painter
->
setFont
(
font
);
painter
->
drawText
(
boundingRect
(),
Qt
::
AlignCenter
,
numStr
);
painter
->
restore
();
}
cockatrice/src/abstractgraphicsitem.h
0 → 100644
View file @
ae82996c
#ifndef ABSTRACTGRAPHICSITEM_H
#define ABSTRACTGRAPHICSITEM_H
#include
<QGraphicsItem>
class
AbstractGraphicsItem
:
public
QGraphicsItem
{
protected:
void
paintNumberEllipse
(
int
number
,
QPainter
*
painter
);
public:
AbstractGraphicsItem
(
QGraphicsItem
*
parent
=
0
)
:
QGraphicsItem
(
parent
)
{
}
};
#endif
cockatrice/src/carditem.cpp
View file @
ae82996c
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#include
"player.h"
#include
"player.h"
CardItem
::
CardItem
(
CardDatabase
*
_db
,
const
QString
&
_name
,
int
_cardid
,
QGraphicsItem
*
parent
)
CardItem
::
CardItem
(
CardDatabase
*
_db
,
const
QString
&
_name
,
int
_cardid
,
QGraphicsItem
*
parent
)
:
Q
GraphicsItem
(
parent
),
db
(
_db
),
name
(
_name
),
id
(
_cardid
),
tapped
(
false
),
attacking
(
false
),
facedown
(
false
),
counters
(
0
),
doesntUntap
(
false
),
dragItem
(
NULL
)
:
Abstract
GraphicsItem
(
parent
),
db
(
_db
),
name
(
_name
),
id
(
_cardid
),
tapped
(
false
),
attacking
(
false
),
facedown
(
false
),
counters
(
0
),
doesntUntap
(
false
),
dragItem
(
NULL
)
{
{
setCursor
(
Qt
::
OpenHandCursor
);
setCursor
(
Qt
::
OpenHandCursor
);
setFlag
(
ItemIsSelectable
);
setFlag
(
ItemIsSelectable
);
...
@@ -61,23 +61,9 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
...
@@ -61,23 +61,9 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
painter
->
setPen
(
Qt
::
red
);
painter
->
setPen
(
Qt
::
red
);
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
));
}
}
if
(
counters
)
{
if
(
counters
)
QString
numStr
=
QString
::
number
(
counters
);
paintNumberEllipse
(
counters
,
painter
);
QFont
font
(
"Times"
,
32
,
QFont
::
Bold
);
QFontMetrics
fm
(
font
);
QRect
br
=
fm
.
boundingRect
(
numStr
);
double
w
=
br
.
width
()
*
1.42
;
double
h
=
br
.
height
()
*
1.42
;
if
(
w
<
h
)
w
=
h
;
painter
->
setPen
(
Qt
::
black
);
painter
->
setBrush
(
QColor
(
255
,
255
,
255
,
150
));
painter
->
drawEllipse
(
QRectF
((
boundingRect
().
width
()
-
w
)
/
2.0
,
(
boundingRect
().
height
()
-
h
)
/
2.0
,
w
,
h
));
painter
->
setFont
(
font
);
painter
->
drawText
(
boundingRect
(),
Qt
::
AlignCenter
,
numStr
);
}
painter
->
restore
();
painter
->
restore
();
}
}
...
...
cockatrice/src/carditem.h
View file @
ae82996c
#ifndef CARDITEM_H
#ifndef CARDITEM_H
#define CARDITEM_H
#define CARDITEM_H
#include
<QG
raphics
I
tem
>
#include
"abstractg
raphics
i
tem
.h"
class
CardDatabase
;
class
CardDatabase
;
class
CardDragItem
;
class
CardDragItem
;
class
CardZone
;
class
CardZone
;
const
int
CARD_WIDTH
=
72
;
const
int
CARD_WIDTH
=
72
;
const
int
CARD_HEIGHT
=
102
;
const
int
CARD_HEIGHT
=
102
;
const
int
RASTER_WIDTH
=
36
;
const
int
RASTER_WIDTH
=
36
;
...
@@ -22,7 +21,7 @@ enum CardItemType {
...
@@ -22,7 +21,7 @@ enum CardItemType {
typeOther
=
QGraphicsItem
::
UserType
+
4
typeOther
=
QGraphicsItem
::
UserType
+
4
};
};
class
CardItem
:
public
Q
GraphicsItem
{
class
CardItem
:
public
Abstract
GraphicsItem
{
private:
private:
CardDatabase
*
db
;
CardDatabase
*
db
;
QString
name
;
QString
name
;
...
...
cockatrice/src/cardzone.cpp
View file @
ae82996c
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
#include
"zoneviewzone.h"
#include
"zoneviewzone.h"
CardZone
::
CardZone
(
Player
*
_p
,
const
QString
&
_name
,
bool
_hasCardAttr
,
bool
_isShufflable
,
QGraphicsItem
*
parent
,
bool
isView
)
CardZone
::
CardZone
(
Player
*
_p
,
const
QString
&
_name
,
bool
_hasCardAttr
,
bool
_isShufflable
,
QGraphicsItem
*
parent
,
bool
isView
)
:
Q
GraphicsItem
(
parent
),
player
(
_p
),
name
(
_name
),
cards
(
NULL
),
view
(
NULL
),
menu
(
NULL
),
hasCardAttr
(
_hasCardAttr
),
isShufflable
(
_isShufflable
)
:
Abstract
GraphicsItem
(
parent
),
player
(
_p
),
name
(
_name
),
cards
(
NULL
),
view
(
NULL
),
menu
(
NULL
),
hasCardAttr
(
_hasCardAttr
),
isShufflable
(
_isShufflable
)
{
{
if
(
!
isView
)
if
(
!
isView
)
player
->
addZone
(
this
);
player
->
addZone
(
this
);
...
@@ -109,26 +109,3 @@ void CardZone::moveAllToZone(const QString &targetZone, int targetX)
...
@@ -109,26 +109,3 @@ void CardZone::moveAllToZone(const QString &targetZone, int targetX)
for
(
int
i
=
cards
->
size
()
-
1
;
i
>=
0
;
i
--
)
for
(
int
i
=
cards
->
size
()
-
1
;
i
>=
0
;
i
--
)
player
->
client
->
moveCard
(
cards
->
at
(
i
)
->
getId
(),
getName
(),
targetZone
,
targetX
);
player
->
client
->
moveCard
(
cards
->
at
(
i
)
->
getId
(),
getName
(),
targetZone
,
targetX
);
}
}
void
CardZone
::
paintCardNumberEllipse
(
QPainter
*
painter
)
{
painter
->
save
();
QString
numStr
=
QString
::
number
(
cards
->
size
());
QFont
font
(
"Times"
,
32
,
QFont
::
Bold
);
QFontMetrics
fm
(
font
);
QRect
br
=
fm
.
boundingRect
(
numStr
);
double
w
=
br
.
width
()
*
1.42
;
double
h
=
br
.
height
()
*
1.42
;
if
(
w
<
h
)
w
=
h
;
painter
->
setPen
(
QPen
(
QColor
(
"black"
)));
painter
->
setBrush
(
QColor
(
255
,
255
,
255
,
150
));
painter
->
drawEllipse
(
QRectF
((
boundingRect
().
width
()
-
w
)
/
2.0
,
(
boundingRect
().
height
()
-
h
)
/
2.0
,
w
,
h
));
painter
->
setFont
(
font
);
painter
->
drawText
(
boundingRect
(),
Qt
::
AlignCenter
,
numStr
);
painter
->
restore
();
}
cockatrice/src/cardzone.h
View file @
ae82996c
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include
<QString>
#include
<QString>
#include
"cardlist.h"
#include
"cardlist.h"
#include
"abstractgraphicsitem.h"
class
Player
;
class
Player
;
class
ZoneViewZone
;
class
ZoneViewZone
;
...
@@ -10,7 +11,7 @@ class QMenu;
...
@@ -10,7 +11,7 @@ class QMenu;
class
QAction
;
class
QAction
;
class
QPainter
;
class
QPainter
;
class
CardZone
:
public
Q
GraphicsItem
{
class
CardZone
:
public
Abstract
GraphicsItem
{
protected:
protected:
Player
*
player
;
Player
*
player
;
QString
name
;
QString
name
;
...
@@ -23,7 +24,6 @@ protected:
...
@@ -23,7 +24,6 @@ protected:
void
mouseDoubleClickEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseDoubleClickEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
addCardImpl
(
CardItem
*
card
,
int
x
,
int
y
)
=
0
;
virtual
void
addCardImpl
(
CardItem
*
card
,
int
x
,
int
y
)
=
0
;
void
paintCardNumberEllipse
(
QPainter
*
painter
);
public:
public:
enum
{
Type
=
typeZone
};
enum
{
Type
=
typeZone
};
int
type
()
const
{
return
Type
;
}
int
type
()
const
{
return
Type
;
}
...
...
cockatrice/src/libraryzone.cpp
View file @
ae82996c
...
@@ -29,7 +29,7 @@ void LibraryZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
...
@@ -29,7 +29,7 @@ void LibraryZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
painter
->
drawPixmap
(
translatedPixmap
->
rect
(),
*
translatedPixmap
,
translatedPixmap
->
rect
());
painter
->
drawPixmap
(
translatedPixmap
->
rect
(),
*
translatedPixmap
,
translatedPixmap
->
rect
());
painter
->
restore
();
painter
->
restore
();
paint
Card
NumberEllipse
(
painter
);
paintNumberEllipse
(
cards
->
size
(),
painter
);
}
}
void
LibraryZone
::
addCardImpl
(
CardItem
*
card
,
int
x
,
int
/*y*/
)
void
LibraryZone
::
addCardImpl
(
CardItem
*
card
,
int
x
,
int
/*y*/
)
...
...
cockatrice/src/pilezone.cpp
View file @
ae82996c
...
@@ -26,7 +26,7 @@ void PileZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
...
@@ -26,7 +26,7 @@ void PileZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
painter
->
restore
();
painter
->
restore
();
}
}
paint
Card
NumberEllipse
(
painter
);
paintNumberEllipse
(
cards
->
size
(),
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