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
e9a02038
Commit
e9a02038
authored
Mar 06, 2010
by
Max-Wilhelm Bruker
Browse files
make more use of SettingsCache
parent
2c9a8c2b
Changes
10
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/carditem.h
View file @
e9a02038
...
@@ -34,6 +34,7 @@ public:
...
@@ -34,6 +34,7 @@ public:
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QPoint
getGridPoint
()
const
{
return
gridPoint
;
}
QPoint
getGridPoint
()
const
{
return
gridPoint
;
}
void
setGridPoint
(
const
QPoint
&
_gridPoint
)
{
gridPoint
=
_gridPoint
;
}
void
setGridPoint
(
const
QPoint
&
_gridPoint
)
{
gridPoint
=
_gridPoint
;
}
QPoint
getGridPos
()
const
{
return
gridPoint
;
}
Player
*
getOwner
()
const
{
return
owner
;
}
Player
*
getOwner
()
const
{
return
owner
;
}
int
getId
()
const
{
return
id
;
}
int
getId
()
const
{
return
id
;
}
void
setId
(
int
_id
)
{
id
=
_id
;
}
void
setId
(
int
_id
)
{
id
=
_id
;
}
...
...
cockatrice/src/dlg_settings.cpp
View file @
e9a02038
...
@@ -169,28 +169,25 @@ AppearanceSettingsPage::AppearanceSettingsPage()
...
@@ -169,28 +169,25 @@ AppearanceSettingsPage::AppearanceSettingsPage()
{
{
zoneBgGroupBox
=
new
QGroupBox
;
zoneBgGroupBox
=
new
QGroupBox
;
QSettings
settings
;
QSettings
settings
;
settings
.
beginGroup
(
"zonebg"
);
handBgLabel
=
new
QLabel
;
handBgLabel
=
new
QLabel
;
handBgEdit
=
new
QLineEdit
(
settings
.
value
(
"hand"
).
toString
());
handBgEdit
=
new
QLineEdit
(
settings
Cache
->
getHandBgPath
());
handBgEdit
->
setReadOnly
(
true
);
handBgEdit
->
setReadOnly
(
true
);
QPushButton
*
handBgButton
=
new
QPushButton
(
"..."
);
QPushButton
*
handBgButton
=
new
QPushButton
(
"..."
);
connect
(
handBgButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
handBgButtonClicked
()));
connect
(
handBgButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
handBgButtonClicked
()));
tableBgLabel
=
new
QLabel
;
tableBgLabel
=
new
QLabel
;
tableBgEdit
=
new
QLineEdit
(
settings
.
value
(
"table"
).
toString
());
tableBgEdit
=
new
QLineEdit
(
settings
Cache
->
getTableBgPath
());
tableBgEdit
->
setReadOnly
(
true
);
tableBgEdit
->
setReadOnly
(
true
);
QPushButton
*
tableBgButton
=
new
QPushButton
(
"..."
);
QPushButton
*
tableBgButton
=
new
QPushButton
(
"..."
);
connect
(
tableBgButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
tableBgButtonClicked
()));
connect
(
tableBgButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
tableBgButtonClicked
()));
playerAreaBgLabel
=
new
QLabel
;
playerAreaBgLabel
=
new
QLabel
;
playerAreaBgEdit
=
new
QLineEdit
(
settings
.
value
(
"playerarea"
).
toString
());
playerAreaBgEdit
=
new
QLineEdit
(
settings
Cache
->
getPlayerBgPath
());
playerAreaBgEdit
->
setReadOnly
(
true
);
playerAreaBgEdit
->
setReadOnly
(
true
);
QPushButton
*
playerAreaBgButton
=
new
QPushButton
(
"..."
);
QPushButton
*
playerAreaBgButton
=
new
QPushButton
(
"..."
);
connect
(
playerAreaBgButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
playerAreaBgButtonClicked
()));
connect
(
playerAreaBgButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
playerAreaBgButtonClicked
()));
settings
.
endGroup
();
QGridLayout
*
zoneBgGrid
=
new
QGridLayout
;
QGridLayout
*
zoneBgGrid
=
new
QGridLayout
;
zoneBgGrid
->
addWidget
(
handBgLabel
,
0
,
0
);
zoneBgGrid
->
addWidget
(
handBgLabel
,
0
,
0
);
zoneBgGrid
->
addWidget
(
handBgEdit
,
0
,
1
);
zoneBgGrid
->
addWidget
(
handBgEdit
,
0
,
1
);
...
@@ -256,12 +253,9 @@ void AppearanceSettingsPage::handBgButtonClicked()
...
@@ -256,12 +253,9 @@ void AppearanceSettingsPage::handBgButtonClicked()
QString
path
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Choose path"
));
QString
path
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Choose path"
));
if
(
path
.
isEmpty
())
if
(
path
.
isEmpty
())
return
;
return
;
QSettings
settings
;
settings
.
beginGroup
(
"zonebg"
);
settings
.
setValue
(
"hand"
,
path
);
handBgEdit
->
setText
(
path
);
emit
handBgChanged
(
path
);
handBgEdit
->
setText
(
path
);
settingsCache
->
setHandBgPath
(
path
);
}
}
void
AppearanceSettingsPage
::
tableBgButtonClicked
()
void
AppearanceSettingsPage
::
tableBgButtonClicked
()
...
@@ -269,12 +263,9 @@ void AppearanceSettingsPage::tableBgButtonClicked()
...
@@ -269,12 +263,9 @@ void AppearanceSettingsPage::tableBgButtonClicked()
QString
path
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Choose path"
));
QString
path
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Choose path"
));
if
(
path
.
isEmpty
())
if
(
path
.
isEmpty
())
return
;
return
;
QSettings
settings
;
settings
.
beginGroup
(
"zonebg"
);
settings
.
setValue
(
"table"
,
path
);
tableBgEdit
->
setText
(
path
);
tableBgEdit
->
setText
(
path
);
settingsCache
->
setTableBgPath
(
path
);
emit
tableBgChanged
(
path
);
}
}
void
AppearanceSettingsPage
::
playerAreaBgButtonClicked
()
void
AppearanceSettingsPage
::
playerAreaBgButtonClicked
()
...
@@ -282,12 +273,9 @@ void AppearanceSettingsPage::playerAreaBgButtonClicked()
...
@@ -282,12 +273,9 @@ void AppearanceSettingsPage::playerAreaBgButtonClicked()
QString
path
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Choose path"
));
QString
path
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Choose path"
));
if
(
path
.
isEmpty
())
if
(
path
.
isEmpty
())
return
;
return
;
QSettings
settings
;
settings
.
beginGroup
(
"zonebg"
);
settings
.
setValue
(
"playerarea"
,
path
);
playerAreaBgEdit
->
setText
(
path
);
emit
playerAreaBgChanged
(
path
);
playerAreaBgEdit
->
setText
(
path
);
settingsCache
->
setPlayerBgPath
(
path
);
}
}
void
AppearanceSettingsPage
::
zoneViewSortingCheckBoxChanged
(
int
state
)
void
AppearanceSettingsPage
::
zoneViewSortingCheckBoxChanged
(
int
state
)
...
...
cockatrice/src/handzone.cpp
View file @
e9a02038
...
@@ -3,17 +3,23 @@
...
@@ -3,17 +3,23 @@
#include
"player.h"
#include
"player.h"
#include
"client.h"
#include
"client.h"
#include
"protocol_items.h"
#include
"protocol_items.h"
#include
"settingscache.h"
HandZone
::
HandZone
(
Player
*
_p
,
int
_zoneHeight
,
QGraphicsItem
*
parent
)
HandZone
::
HandZone
(
Player
*
_p
,
int
_zoneHeight
,
QGraphicsItem
*
parent
)
:
CardZone
(
_p
,
"hand"
,
false
,
false
,
_p
->
getLocal
(),
parent
),
zoneHeight
(
_zoneHeight
)
:
CardZone
(
_p
,
"hand"
,
false
,
false
,
_p
->
getLocal
(),
parent
),
zoneHeight
(
_zoneHeight
)
{
{
QSettings
settings
;
connect
(
settingsCache
,
SIGNAL
(
handBgPathChanged
()),
this
,
SLOT
(
updateBgPixmap
()));
QString
bgPath
=
settings
.
value
(
"zonebg/hand"
).
toString
();
updateBgPixmap
();
if
(
!
bgPath
.
isEmpty
())
bgPixmap
.
load
(
bgPath
);
setCacheMode
(
DeviceCoordinateCache
);
setCacheMode
(
DeviceCoordinateCache
);
setAcceptsHoverEvents
(
true
);
// Awkwardly, this is needed to repaint the cached item after it has been corrupted by buggy rubberband drag.
}
void
HandZone
::
updateBgPixmap
()
{
QString
bgPath
=
settingsCache
->
getHandBgPath
();
if
(
!
bgPath
.
isEmpty
())
bgPixmap
.
load
(
bgPath
);
update
();
}
}
QRectF
HandZone
::
boundingRect
()
const
QRectF
HandZone
::
boundingRect
()
const
...
...
cockatrice/src/handzone.h
View file @
e9a02038
...
@@ -4,9 +4,12 @@
...
@@ -4,9 +4,12 @@
#include
"cardzone.h"
#include
"cardzone.h"
class
HandZone
:
public
CardZone
{
class
HandZone
:
public
CardZone
{
Q_OBJECT
private:
private:
QPixmap
bgPixmap
;
QPixmap
bgPixmap
;
int
zoneHeight
;
int
zoneHeight
;
private
slots
:
void
updateBgPixmap
();
public:
public:
HandZone
(
Player
*
_p
,
int
_zoneHeight
,
QGraphicsItem
*
parent
=
0
);
HandZone
(
Player
*
_p
,
int
_zoneHeight
,
QGraphicsItem
*
parent
=
0
);
QRectF
boundingRect
()
const
;
QRectF
boundingRect
()
const
;
...
...
cockatrice/src/player.cpp
View file @
e9a02038
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
#include
"tab_game.h"
#include
"tab_game.h"
#include
"protocol_items.h"
#include
"protocol_items.h"
#include
"gamescene.h"
#include
"gamescene.h"
#include
"settingscache.h"
#include
<QSettings>
#include
<QSettings>
#include
<QPainter>
#include
<QPainter>
#include
<QMenu>
#include
<QMenu>
...
@@ -19,12 +20,11 @@
...
@@ -19,12 +20,11 @@
Player
::
Player
(
const
QString
&
_name
,
int
_id
,
bool
_local
,
Client
*
_client
,
TabGame
*
_parent
)
Player
::
Player
(
const
QString
&
_name
,
int
_id
,
bool
_local
,
Client
*
_client
,
TabGame
*
_parent
)
:
QObject
(
_parent
),
defaultNumberTopCards
(
3
),
name
(
_name
),
id
(
_id
),
active
(
false
),
local
(
_local
),
client
(
_client
)
:
QObject
(
_parent
),
defaultNumberTopCards
(
3
),
name
(
_name
),
id
(
_id
),
active
(
false
),
local
(
_local
),
client
(
_client
)
{
{
QSettings
settings
;
QString
bgPath
=
settings
.
value
(
"zonebg/playerarea"
).
toString
();
if
(
!
bgPath
.
isEmpty
())
bgPixmap
.
load
(
bgPath
);
setCacheMode
(
DeviceCoordinateCache
);
setCacheMode
(
DeviceCoordinateCache
);
connect
(
settingsCache
,
SIGNAL
(
playerBgPathChanged
()),
this
,
SLOT
(
updateBgPixmap
()));
updateBgPixmap
();
QPointF
base
=
QPointF
(
counterAreaWidth
,
50
);
QPointF
base
=
QPointF
(
counterAreaWidth
,
50
);
PileZone
*
deck
=
new
PileZone
(
this
,
"deck"
,
true
,
false
,
this
);
PileZone
*
deck
=
new
PileZone
(
this
,
"deck"
,
true
,
false
,
this
);
...
@@ -265,6 +265,16 @@ Player::~Player()
...
@@ -265,6 +265,16 @@ Player::~Player()
delete
cardMenu
;
delete
cardMenu
;
}
}
void
Player
::
updateBgPixmap
()
{
QString
bgPath
=
settingsCache
->
getPlayerBgPath
();
if
(
!
bgPath
.
isEmpty
())
{
qDebug
()
<<
"loading"
<<
bgPath
;
bgPixmap
.
load
(
bgPath
);
}
update
();
}
void
Player
::
updateBoundingRect
()
void
Player
::
updateBoundingRect
()
{
{
prepareGeometryChange
();
prepareGeometryChange
();
...
...
cockatrice/src/player.h
View file @
e9a02038
...
@@ -78,6 +78,7 @@ public slots:
...
@@ -78,6 +78,7 @@ public slots:
void
actSayMessage
();
void
actSayMessage
();
private
slots
:
private
slots
:
void
updateBgPixmap
();
void
updateBoundingRect
();
void
updateBoundingRect
();
void
cardMenuAction
();
void
cardMenuAction
();
void
actSetCounters
();
void
actSetCounters
();
...
...
cockatrice/src/settingscache.cpp
View file @
e9a02038
...
@@ -11,6 +11,10 @@ SettingsCache::SettingsCache()
...
@@ -11,6 +11,10 @@ SettingsCache::SettingsCache()
picsPath
=
settings
->
value
(
"paths/pics"
).
toString
();
picsPath
=
settings
->
value
(
"paths/pics"
).
toString
();
cardDatabasePath
=
settings
->
value
(
"paths/carddatabase"
).
toString
();
cardDatabasePath
=
settings
->
value
(
"paths/carddatabase"
).
toString
();
handBgPath
=
settings
->
value
(
"zonebg/hand"
).
toString
();
tableBgPath
=
settings
->
value
(
"zonebg/table"
).
toString
();
playerBgPath
=
settings
->
value
(
"zonebg/playerarea"
).
toString
();
picDownload
=
settings
->
value
(
"personal/picturedownload"
,
0
).
toInt
();
picDownload
=
settings
->
value
(
"personal/picturedownload"
,
0
).
toInt
();
doubleClickToPlay
=
settings
->
value
(
"interface/doubleclicktoplay"
,
1
).
toInt
();
doubleClickToPlay
=
settings
->
value
(
"interface/doubleclicktoplay"
,
1
).
toInt
();
economicGrid
=
settings
->
value
(
"table/economic"
,
0
).
toInt
();
economicGrid
=
settings
->
value
(
"table/economic"
,
0
).
toInt
();
...
@@ -43,6 +47,27 @@ void SettingsCache::setCardDatabasePath(const QString &_cardDatabasePath)
...
@@ -43,6 +47,27 @@ void SettingsCache::setCardDatabasePath(const QString &_cardDatabasePath)
emit
cardDatabasePathChanged
();
emit
cardDatabasePathChanged
();
}
}
void
SettingsCache
::
setHandBgPath
(
const
QString
&
_handBgPath
)
{
handBgPath
=
_handBgPath
;
settings
->
setValue
(
"zonebg/hand"
,
handBgPath
);
emit
handBgPathChanged
();
}
void
SettingsCache
::
setTableBgPath
(
const
QString
&
_tableBgPath
)
{
tableBgPath
=
_tableBgPath
;
settings
->
setValue
(
"zonebg/table"
,
tableBgPath
);
emit
tableBgPathChanged
();
}
void
SettingsCache
::
setPlayerBgPath
(
const
QString
&
_playerBgPath
)
{
playerBgPath
=
_playerBgPath
;
settings
->
setValue
(
"zonebg/player"
,
playerBgPath
);
emit
playerBgPathChanged
();
}
void
SettingsCache
::
setPicDownload
(
int
_picDownload
)
void
SettingsCache
::
setPicDownload
(
int
_picDownload
)
{
{
picDownload
=
_picDownload
;
picDownload
=
_picDownload
;
...
@@ -60,4 +85,5 @@ void SettingsCache::setEconomicGrid(int _economicGrid)
...
@@ -60,4 +85,5 @@ void SettingsCache::setEconomicGrid(int _economicGrid)
{
{
economicGrid
=
_economicGrid
;
economicGrid
=
_economicGrid
;
settings
->
setValue
(
"table/economic"
,
economicGrid
);
settings
->
setValue
(
"table/economic"
,
economicGrid
);
emit
economicGridChanged
();
}
}
cockatrice/src/settingscache.h
View file @
e9a02038
...
@@ -11,12 +11,17 @@ signals:
...
@@ -11,12 +11,17 @@ signals:
void
langChanged
();
void
langChanged
();
void
picsPathChanged
();
void
picsPathChanged
();
void
cardDatabasePathChanged
();
void
cardDatabasePathChanged
();
void
handBgPathChanged
();
void
tableBgPathChanged
();
void
playerBgPathChanged
();
void
picDownloadChanged
();
void
picDownloadChanged
();
void
economicGridChanged
();
private:
private:
QSettings
*
settings
;
QSettings
*
settings
;
QString
lang
;
QString
lang
;
QString
deckPath
,
picsPath
,
cardDatabasePath
;
QString
deckPath
,
picsPath
,
cardDatabasePath
;
QString
handBgPath
,
tableBgPath
,
playerBgPath
;
bool
picDownload
;
bool
picDownload
;
bool
doubleClickToPlay
;
bool
doubleClickToPlay
;
bool
economicGrid
;
bool
economicGrid
;
...
@@ -26,6 +31,9 @@ public:
...
@@ -26,6 +31,9 @@ public:
QString
getDeckPath
()
const
{
return
deckPath
;
}
QString
getDeckPath
()
const
{
return
deckPath
;
}
QString
getPicsPath
()
const
{
return
picsPath
;
}
QString
getPicsPath
()
const
{
return
picsPath
;
}
QString
getCardDatabasePath
()
const
{
return
cardDatabasePath
;
}
QString
getCardDatabasePath
()
const
{
return
cardDatabasePath
;
}
QString
getHandBgPath
()
const
{
return
handBgPath
;
}
QString
getTableBgPath
()
const
{
return
tableBgPath
;
}
QString
getPlayerBgPath
()
const
{
return
playerBgPath
;
}
bool
getPicDownload
()
const
{
return
picDownload
;
}
bool
getPicDownload
()
const
{
return
picDownload
;
}
bool
getDoubleClickToPlay
()
const
{
return
doubleClickToPlay
;
}
bool
getDoubleClickToPlay
()
const
{
return
doubleClickToPlay
;
}
bool
getEconomicGrid
()
const
{
return
economicGrid
;
}
bool
getEconomicGrid
()
const
{
return
economicGrid
;
}
...
@@ -34,6 +42,9 @@ public slots:
...
@@ -34,6 +42,9 @@ public slots:
void
setDeckPath
(
const
QString
&
_deckPath
);
void
setDeckPath
(
const
QString
&
_deckPath
);
void
setPicsPath
(
const
QString
&
_picsPath
);
void
setPicsPath
(
const
QString
&
_picsPath
);
void
setCardDatabasePath
(
const
QString
&
_cardDatabasePath
);
void
setCardDatabasePath
(
const
QString
&
_cardDatabasePath
);
void
setHandBgPath
(
const
QString
&
_handBgPath
);
void
setTableBgPath
(
const
QString
&
_tableBgPath
);
void
setPlayerBgPath
(
const
QString
&
_playerBgPath
);
void
setPicDownload
(
int
_picDownload
);
void
setPicDownload
(
int
_picDownload
);
void
setDoubleClickToPlay
(
int
_doubleClickToPlay
);
void
setDoubleClickToPlay
(
int
_doubleClickToPlay
);
void
setEconomicGrid
(
int
_economicGrid
);
void
setEconomicGrid
(
int
_economicGrid
);
...
...
cockatrice/src/tablezone.cpp
View file @
e9a02038
...
@@ -3,17 +3,16 @@
...
@@ -3,17 +3,16 @@
#include
"player.h"
#include
"player.h"
#include
"client.h"
#include
"client.h"
#include
"protocol_items.h"
#include
"protocol_items.h"
#include
"settingscache.h"
TableZone
::
TableZone
(
Player
*
_p
,
QGraphicsItem
*
parent
)
TableZone
::
TableZone
(
Player
*
_p
,
QGraphicsItem
*
parent
)
:
CardZone
(
_p
,
"table"
,
true
,
false
,
true
,
parent
)
:
CardZone
(
_p
,
"table"
,
true
,
false
,
true
,
parent
)
{
{
QSettings
settings
;
connect
(
settingsCache
,
SIGNAL
(
tableBgPathChanged
()),
this
,
SLOT
(
updateBgPixmap
()));
QString
bgPath
=
settings
.
value
(
"zonebg/table"
).
toString
();
connect
(
settingsCache
,
SIGNAL
(
economicGridChanged
()),
this
,
SLOT
(
reorganizeCards
()));
if
(
!
bgPath
.
isEmpty
())
updateBgPixmap
();
bgPixmap
.
load
(
bgPath
);
economicGrid
=
settings
.
value
(
"table/economic"
,
1
).
toInt
();
if
(
settingsCache
->
getEconomicGrid
())
if
(
economicGrid
)
height
=
(
int
)
(
14.0
/
3
*
CARD_HEIGHT
+
3
*
paddingY
);
height
=
(
int
)
(
14.0
/
3
*
CARD_HEIGHT
+
3
*
paddingY
);
else
else
height
=
4
*
CARD_HEIGHT
+
3
*
paddingY
;
height
=
4
*
CARD_HEIGHT
+
3
*
paddingY
;
...
@@ -23,6 +22,14 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
...
@@ -23,6 +22,14 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
setAcceptsHoverEvents
(
true
);
setAcceptsHoverEvents
(
true
);
}
}
void
TableZone
::
updateBgPixmap
()
{
QString
bgPath
=
settingsCache
->
getTableBgPath
();
if
(
!
bgPath
.
isEmpty
())
bgPixmap
.
load
(
bgPath
);
update
();
}
QRectF
TableZone
::
boundingRect
()
const
QRectF
TableZone
::
boundingRect
()
const
{
{
return
QRectF
(
0
,
0
,
width
,
height
);
return
QRectF
(
0
,
0
,
width
,
height
);
...
@@ -43,19 +50,11 @@ void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio
...
@@ -43,19 +50,11 @@ void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio
void
TableZone
::
addCardImpl
(
CardItem
*
card
,
int
_x
,
int
_y
)
void
TableZone
::
addCardImpl
(
CardItem
*
card
,
int
_x
,
int
_y
)
{
{
QPointF
mapPoint
=
mapFromGrid
(
QPoint
(
_x
,
_y
));
qreal
x
=
mapPoint
.
x
();
qreal
y
=
mapPoint
.
y
();
cards
.
append
(
card
);
cards
.
append
(
card
);
if
(
!
player
->
getLocal
())
y
=
height
-
CARD_HEIGHT
-
y
;
card
->
setPos
(
x
,
y
);
card
->
setGridPoint
(
QPoint
(
_x
,
_y
));
card
->
setGridPoint
(
QPoint
(
_x
,
_y
));
resizeToContents
();
resizeToContents
();
card
->
setZValue
((
y
+
CARD_HEIGHT
)
*
10000000
+
x
+
1000
);
card
->
setParentItem
(
this
);
card
->
setParentItem
(
this
);
card
->
setVisible
(
true
);
card
->
setVisible
(
true
);
card
->
update
();
card
->
update
();
...
@@ -73,6 +72,17 @@ void TableZone::handleDropEventByGrid(int cardId, CardZone *startZone, const QPo
...
@@ -73,6 +72,17 @@ void TableZone::handleDropEventByGrid(int cardId, CardZone *startZone, const QPo
void
TableZone
::
reorganizeCards
()
void
TableZone
::
reorganizeCards
()
{
{
for
(
int
i
=
0
;
i
<
cards
.
size
();
++
i
)
{
QPointF
mapPoint
=
mapFromGrid
(
cards
[
i
]
->
getGridPos
());
qreal
x
=
mapPoint
.
x
();
qreal
y
=
mapPoint
.
y
();
if
(
!
player
->
getLocal
())
y
=
height
-
CARD_HEIGHT
-
y
;
cards
[
i
]
->
setPos
(
x
,
y
);
cards
[
i
]
->
setZValue
((
y
+
CARD_HEIGHT
)
*
10000000
+
x
+
1000
);
}
update
();
update
();
}
}
...
@@ -130,7 +140,7 @@ CardItem *TableZone::getCardFromGrid(const QPoint &gridPoint) const
...
@@ -130,7 +140,7 @@ CardItem *TableZone::getCardFromGrid(const QPoint &gridPoint) const
QPointF
TableZone
::
mapFromGrid
(
const
QPoint
&
gridPoint
)
const
QPointF
TableZone
::
mapFromGrid
(
const
QPoint
&
gridPoint
)
const
{
{
if
(
gridPoint
.
y
()
==
3
)
{
if
(
gridPoint
.
y
()
==
3
)
{
if
(
e
conomicGrid
)
if
(
settingsCache
->
getE
conomicGrid
()
)
return
QPointF
(
return
QPointF
(
20
+
(
CARD_WIDTH
*
gridPoint
.
x
()
+
CARD_WIDTH
*
(
gridPoint
.
x
()
/
3
))
/
2
,
20
+
(
CARD_WIDTH
*
gridPoint
.
x
()
+
CARD_WIDTH
*
(
gridPoint
.
x
()
/
3
))
/
2
,
(
CARD_HEIGHT
+
paddingY
)
*
gridPoint
.
y
()
+
(
gridPoint
.
x
()
%
3
*
CARD_HEIGHT
)
/
3
(
CARD_HEIGHT
+
paddingY
)
*
gridPoint
.
y
()
+
(
gridPoint
.
x
()
%
3
*
CARD_HEIGHT
)
/
3
...
@@ -166,7 +176,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
...
@@ -166,7 +176,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
);
);
if
(
result
.
y
()
==
3
)
{
if
(
result
.
y
()
==
3
)
{
if
(
e
conomicGrid
)
if
(
settingsCache
->
getE
conomicGrid
()
)
return
QPoint
(
return
QPoint
(
(
int
)
(
x
*
2
/
CARD_WIDTH
-
floor
(
x
/
(
2
*
CARD_WIDTH
))),
(
int
)
(
x
*
2
/
CARD_WIDTH
-
floor
(
x
/
(
2
*
CARD_WIDTH
))),
3
3
...
...
cockatrice/src/tablezone.h
View file @
e9a02038
...
@@ -10,7 +10,10 @@ signals:
...
@@ -10,7 +10,10 @@ signals:
private:
private:
int
width
,
height
;
int
width
,
height
;
QPixmap
bgPixmap
;
QPixmap
bgPixmap
;
bool
economicGrid
;
private
slots
:
void
updateBgPixmap
();
public
slots
:
void
reorganizeCards
();
public:
public:
static
const
int
paddingY
=
20
;
static
const
int
paddingY
=
20
;
static
const
int
marginX
=
20
;
static
const
int
marginX
=
20
;
...
@@ -19,7 +22,6 @@ public:
...
@@ -19,7 +22,6 @@ public:
TableZone
(
Player
*
_p
,
QGraphicsItem
*
parent
=
0
);
TableZone
(
Player
*
_p
,
QGraphicsItem
*
parent
=
0
);
QRectF
boundingRect
()
const
;
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
reorganizeCards
();
void
toggleTapped
();
void
toggleTapped
();
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
=
false
);
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
=
false
);
void
handleDropEventByGrid
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
gridPoint
,
bool
faceDown
=
false
,
bool
tapped
=
false
);
void
handleDropEventByGrid
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
gridPoint
,
bool
faceDown
=
false
,
bool
tapped
=
false
);
...
...
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