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
da4c2559
Commit
da4c2559
authored
Jun 19, 2014
by
Gavin Bisesi
Browse files
Merge pull request #61 from VanNostrand/win32
Windows MSVC support
parents
3401098e
a22a703f
Changes
24
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
da4c2559
...
...
@@ -50,15 +50,21 @@ elseif(WIN32)
endif
()
# Define proper compilation flags
IF
(
CMAKE_COMPILER_IS_GNUCC
)
IF
(
MSVC
)
# Visual Studio:
# Maximum optimization
set
(
CMAKE_CXX_FLAGS_RELEASE
"/Ox"
)
# Generate complete debugging information
#set(CMAKE_CXX_FLAGS_DEBUG "/Zi")
ELSEIF
(
CMAKE_COMPILER_IS_GNUCXX
)
# linux/gcc, bsd/gcc, windows/mingw
set
(
CMAKE_CXX_FLAGS_RELEASE
"-s -O2"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"-ggdb -O0"
)
else
()
ELSE
()
# other: osx/llvm, bsd/llvm
set
(
CMAKE_CXX_FLAGS_RELEASE
"-O2"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"-g -O0"
)
ENDIF
(
CMAKE_COMPILER_IS_GNUCC
)
ENDIF
(
)
# GNU systems need to define the Mersenne exponent for the RNG to compile w/o warning
IF
(
CMAKE_CXX_COMPILER_ID MATCHES
"GNU|Clang"
)
...
...
cockatrice/CMakeLists.txt
View file @
da4c2559
...
...
@@ -154,8 +154,11 @@ INCLUDE_DIRECTORIES(${QT_MOBILITY_MULTIMEDIAKIT_INCLUDE_DIR})
# Build cockatrice binary and link it
ADD_EXECUTABLE
(
cockatrice WIN32 MACOSX_BUNDLE
${
cockatrice_SOURCES
}
${
cockatrice_QM
}
${
cockatrice_RESOURCES_RCC
}
${
cockatrice_MOC_SRCS
}
)
TARGET_LINK_LIBRARIES
(
cockatrice cockatrice_common
${
QT_LIBRARIES
}
${
QT_MOBILITY_MULTIMEDIAKIT_LIBRARY
}
)
TARGET_LINK_LIBRARIES
(
cockatrice cockatrice_common
${
QT_QTMAIN_LIBRARY
}
${
QT_LIBRARIES
}
${
QT_MOBILITY_MULTIMEDIAKIT_LIBRARY
}
)
if
(
MSVC
)
set_target_properties
(
cockatrice PROPERTIES LINK_FLAGS
"/SUBSYSTEM:WINDOWS"
)
endif
(
MSVC
)
if
(
UNIX
)
if
(
APPLE
)
...
...
cockatrice/src/abstractcarditem.cpp
View file @
da4c2559
...
...
@@ -2,7 +2,10 @@
#include
<QGraphicsScene>
#include
<QCursor>
#include
<QGraphicsSceneMouseEvent>
#include
<math.h>
#include
<cmath>
#ifdef _WIN32
#include
"round.h"
#endif
/* _WIN32 */
#include
"carddatabase.h"
#include
"cardinfowidget.h"
#include
"abstractcarditem.h"
...
...
@@ -143,7 +146,7 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
painter
->
restore
();
}
void
AbstractCardItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
void
AbstractCardItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
/*option*/
,
QWidget
*
/*widget*/
)
{
painter
->
save
();
...
...
cockatrice/src/arrowitem.cpp
View file @
da4c2559
#define _USE_MATH_DEFINES
#include
<cmath>
#include
"arrowitem.h"
#include
"playertarget.h"
#include
"carditem.h"
#include
"cardzone.h"
#include
"player.h"
#include
"math.h"
#include
<QPainter>
#include
<QGraphicsSceneMouseEvent>
#include
<QGraphicsScene>
...
...
@@ -64,7 +66,7 @@ void ArrowItem::updatePath(const QPointF &endPoint)
{
const
double
arrowWidth
=
15.0
;
const
double
headWidth
=
40.0
;
const
double
headLength
=
headWidth
/
sqrt
(
2
)
;
const
double
headLength
=
headWidth
/
pow
(
2
,
0.5
);
// aka headWidth /
sqrt
(2)
but this produces a compile error with MSVC++
const
double
phi
=
15
;
if
(
!
startItem
)
...
...
cockatrice/src/cardzone.cpp
View file @
da4c2559
...
...
@@ -148,7 +148,7 @@ QString CardZone::getTranslatedName(bool hisOwn, GrammaticalCase gc) const
return
QString
();
}
void
CardZone
::
mouseDoubleClickEvent
(
QGraphicsSceneMouseEvent
*/
*
event
*/
)
void
CardZone
::
mouseDoubleClickEvent
(
QGraphicsSceneMouseEvent
*
/*event*/
)
{
if
(
doubleClickAction
)
doubleClickAction
->
trigger
();
...
...
cockatrice/src/counter_general.cpp
View file @
da4c2559
...
...
@@ -13,7 +13,7 @@ QRectF GeneralCounter::boundingRect() const
return
QRectF
(
0
,
0
,
radius
*
2
,
radius
*
2
);
}
void
GeneralCounter
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
void
GeneralCounter
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
/*option*/
,
QWidget
*
/*widget*/
)
{
QRectF
mapRect
=
painter
->
combinedTransform
().
mapRect
(
boundingRect
());
int
translatedHeight
=
mapRect
.
size
().
height
();
...
...
cockatrice/src/decklistmodel.h
View file @
da4c2559
...
...
@@ -19,7 +19,7 @@ public:
int
getNumber
()
const
{
return
dataNode
->
getNumber
();
}
void
setNumber
(
int
_number
)
{
dataNode
->
setNumber
(
_number
);
}
float
getPrice
()
const
{
return
dataNode
->
getPrice
();
}
void
setPrice
(
float
_price
)
{
dataNode
->
setPrice
(
_price
);
}
void
setPrice
(
const
float
_price
)
{
dataNode
->
setPrice
(
_price
);
}
QString
getName
()
const
{
return
dataNode
->
getName
();
}
void
setName
(
const
QString
&
_name
)
{
dataNode
->
setName
(
_name
);
}
DecklistCardNode
*
getDataNode
()
const
{
return
dataNode
;
}
...
...
cockatrice/src/filtertree.cpp
View file @
da4c2559
...
...
@@ -266,7 +266,7 @@ FilterItemList *FilterTree::attrTypeList(CardFilter::Attr attr,
int
FilterTree
::
findTermIndex
(
CardFilter
::
Attr
attr
,
CardFilter
::
Type
type
,
const
QString
&
term
)
{
attrTypeList
(
attr
,
type
)
->
termIndex
(
term
);
return
attrTypeList
(
attr
,
type
)
->
termIndex
(
term
);
}
int
FilterTree
::
findTermIndex
(
const
CardFilter
*
f
)
...
...
cockatrice/src/gamesmodel.cpp
View file @
da4c2559
...
...
@@ -180,9 +180,9 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc
if
(
!
gameTypeFilter
.
isEmpty
()
&&
gameTypes
.
intersect
(
gameTypeFilter
).
isEmpty
())
return
false
;
if
((
maxPlayersFilterMin
!=
-
1
)
&&
(
game
.
max_players
()
<
maxPlayersFilterMin
))
if
((
maxPlayersFilterMin
!=
-
1
)
&&
(
(
int
)
game
.
max_players
()
<
maxPlayersFilterMin
))
return
false
;
if
((
maxPlayersFilterMax
!=
-
1
)
&&
(
game
.
max_players
()
>
maxPlayersFilterMax
))
if
((
maxPlayersFilterMax
!=
-
1
)
&&
(
(
int
)
game
.
max_players
()
>
maxPlayersFilterMax
))
return
false
;
return
true
;
...
...
cockatrice/src/handzone.cpp
View file @
da4c2559
...
...
@@ -75,7 +75,7 @@ QRectF HandZone::boundingRect() const
return
QRectF
(
0
,
0
,
100
,
zoneHeight
);
}
void
HandZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
void
HandZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
/*option*/
,
QWidget
*
/*widget*/
)
{
if
(
bgPixmap
.
isNull
())
painter
->
fillRect
(
boundingRect
(),
Qt
::
darkGreen
);
...
...
cockatrice/src/main.cpp
View file @
da4c2559
...
...
@@ -19,6 +19,8 @@
***************************************************************************/
#include
<QApplication>
#include
<QFile>
#include
<QTextStream>
#include
<QTextCodec>
#include
<QtPlugin>
#include
<QTranslator>
...
...
@@ -28,7 +30,6 @@
#include
<QIcon>
#include
<QDir>
#include
<QDesktopServices>
#include
<stdio.h>
#include
"main.h"
#include
"window_main.h"
...
...
@@ -56,11 +57,11 @@ QString translationPath = QString();
void
myMessageOutput
(
QtMsgType
/*type*/
,
const
char
*
msg
)
{
static
FILE
*
f
=
NULL
;
if
(
!
f
)
f
=
fopen
(
"qdebug.txt"
,
"w"
);
fprintf
(
f
,
"%s
\n
"
,
msg
)
;
f
flush
(
f
);
QFile
file
(
"qdebug.txt"
)
;
file
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Truncate
|
QIODevice
::
Text
);
QTextStream
out
(
&
file
);
out
<<
msg
<<
endl
;
f
ile
.
close
(
);
}
void
installNewTranslator
()
...
...
cockatrice/src/phasestoolbar.cpp
View file @
da4c2559
...
...
@@ -3,7 +3,10 @@
#include
<QPen>
#include
<QTimer>
#include
<QDebug>
#include
<math.h>
#include
<cmath>
#ifdef _WIN32
#include
"round.h"
#endif
/* _WIN32 */
#include
"phasestoolbar.h"
#include
"pixmapgenerator.h"
...
...
@@ -85,7 +88,7 @@ void PhaseButton::mousePressEvent(QGraphicsSceneMouseEvent * /*event*/)
emit
clicked
();
}
void
PhaseButton
::
mouseDoubleClickEvent
(
QGraphicsSceneMouseEvent
*/
*
event
*/
)
void
PhaseButton
::
mouseDoubleClickEvent
(
QGraphicsSceneMouseEvent
*
/*event*/
)
{
triggerDoubleClickAction
();
}
...
...
cockatrice/src/pilezone.cpp
View file @
da4c2559
...
...
@@ -105,7 +105,7 @@ void PileZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
setCursor
(
Qt
::
OpenHandCursor
);
}
void
PileZone
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*/
*
event
*/
)
void
PileZone
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
/*event*/
)
{
setCursor
(
Qt
::
OpenHandCursor
);
}
...
...
cockatrice/src/pixmapgenerator.cpp
View file @
da4c2559
...
...
@@ -2,7 +2,10 @@
#include
"pb/serverinfo_user.pb.h"
#include
<QPainter>
#include
<QSvgRenderer>
#include
<math.h>
#include
<cmath>
#ifdef _WIN32
#include
"round.h"
#endif
/* _WIN32 */
#include
<QDebug>
QMap
<
QString
,
QPixmap
>
PhasePixmapGenerator
::
pmCache
;
...
...
cockatrice/src/player.cpp
View file @
da4c2559
...
...
@@ -85,7 +85,7 @@ void PlayerArea::updateBgPixmap()
update
();
}
void
PlayerArea
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
void
PlayerArea
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
/*option*/
,
QWidget
*
/*widget*/
)
{
painter
->
fillRect
(
bRect
,
bgPixmapBrush
);
}
...
...
@@ -1430,7 +1430,7 @@ QRectF Player::boundingRect() const
return
bRect
;
}
void
Player
::
paint
(
QPainter
*
/*painter*/
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
void
Player
::
paint
(
QPainter
*
/*painter*/
,
const
QStyleOptionGraphicsItem
*
/*option*/
,
QWidget
*
/*widget*/
)
{
}
...
...
cockatrice/src/playertarget.cpp
View file @
da4c2559
...
...
@@ -5,7 +5,10 @@
#include
<QPainter>
#include
<QPixmapCache>
#include
<QDebug>
#include
<math.h>
#include
<cmath>
#ifdef _WIN32
#include
"round.h"
#endif
/* _WIN32 */
PlayerCounter
::
PlayerCounter
(
Player
*
_player
,
int
_id
,
const
QString
&
_name
,
int
_value
,
QGraphicsItem
*
parent
)
:
AbstractCounter
(
_player
,
_id
,
_name
,
false
,
_value
,
parent
)
...
...
@@ -87,7 +90,8 @@ void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*o
cachedPixmap
=
QPixmap
(
translatedSize
.
width
(),
translatedSize
.
height
());
QPainter
tempPainter
(
&
cachedPixmap
);
QRadialGradient
grad
(
translatedRect
.
center
(),
sqrt
(
translatedSize
.
width
()
*
translatedSize
.
width
()
+
translatedSize
.
height
()
*
translatedSize
.
height
())
/
2
);
// pow(foo, 0.5) equals to sqrt(foo), but using sqrt(foo) in this context will produce a compile error with MSVC++
QRadialGradient
grad
(
translatedRect
.
center
(),
pow
(
translatedSize
.
width
()
*
translatedSize
.
width
()
+
translatedSize
.
height
()
*
translatedSize
.
height
(),
0.5
)
/
2
);
grad
.
setColorAt
(
1
,
Qt
::
black
);
grad
.
setColorAt
(
0
,
QColor
(
180
,
180
,
180
));
tempPainter
.
fillRect
(
QRectF
(
0
,
0
,
translatedSize
.
width
(),
translatedSize
.
height
()),
grad
);
...
...
cockatrice/src/replay_timeline_widget.cpp
View file @
da4c2559
...
...
@@ -2,7 +2,10 @@
#include
<QPainter>
#include
<QPalette>
#include
<QTimer>
#include
<math.h>
#include
<cmath>
#ifdef _WIN32
#include
"round.h"
#endif
/* _WIN32 */
ReplayTimelineWidget
::
ReplayTimelineWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
),
maxBinValue
(
1
),
maxTime
(
1
),
timeScaleFactor
(
1.0
),
currentTime
(
0
),
currentEvent
(
0
)
...
...
cockatrice/src/round.h
0 → 100644
View file @
da4c2559
#ifndef MSVC_ROUND_FIX
#define MSVC_ROUND_FIX
/**
* This helper function exists only because MS VC++ 2010 does not support round() in
* <cmath>. round() works with g++ and clang++ but is formally a C++11 extension.
* So this file exists for MS VC++ only.
*/
inline
double
round
(
double
val
)
{
return
floor
(
val
+
0
.
5
);
}
#endif
/* MSVC_ROUND_FIX */
cockatrice/src/stackzone.cpp
View file @
da4c2559
...
...
@@ -46,7 +46,7 @@ QRectF StackZone::boundingRect() const
return
QRectF
(
0
,
0
,
100
,
zoneHeight
);
}
void
StackZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
void
StackZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
/*option*/
,
QWidget
*
/*widget*/
)
{
if
(
bgPixmap
.
isNull
())
painter
->
fillRect
(
boundingRect
(),
QColor
(
113
,
43
,
43
));
...
...
cockatrice/src/tablezone.cpp
View file @
da4c2559
#include
<QPainter>
#include
<QSet>
#include
<QGraphicsScene>
#include
<math.h>
#include
<cmath>
#ifdef _WIN32
#include
"round.h"
#endif
/* _WIN32 */
#include
"tablezone.h"
#include
"player.h"
#include
"settingscache.h"
...
...
@@ -46,7 +49,7 @@ bool TableZone::isInverted() const
return
((
player
->
getMirrored
()
&&
!
settingsCache
->
getInvertVerticalCoordinate
())
||
(
!
player
->
getMirrored
()
&&
settingsCache
->
getInvertVerticalCoordinate
()));
}
void
TableZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
void
TableZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
/*option*/
,
QWidget
*
/*widget*/
)
{
if
(
bgPixmap
.
isNull
())
painter
->
fillRect
(
boundingRect
(),
QColor
(
0
,
0
,
100
));
...
...
Prev
1
2
Next
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