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
e1a72832
Commit
e1a72832
authored
May 29, 2010
by
Max-Wilhelm Bruker
Browse files
Merge branch 'master' of
ssh://cockatrice.de/home/cockgit/cockatrice
Conflicts: cockatrice/cockatrice.pro cockatrice/src/player.cpp
parents
aaf236d0
ac15d1b5
Changes
48
Hide whitespace changes
Inline
Side-by-side
cockatrice/cockatrice.pro
View file @
e1a72832
...
@@ -21,10 +21,13 @@ HEADERS += src/counter.h \
...
@@ -21,10 +21,13 @@ HEADERS += src/counter.h \
src
/
tablezone
.
h
\
src
/
tablezone
.
h
\
src
/
handzone
.
h
\
src
/
handzone
.
h
\
src
/
handcounter
.
h
\
src
/
handcounter
.
h
\
src
/
handzone_vert
.
h
\
src
/
handzone_horiz
.
h
\
src
/
carddatabase
.
h
\
src
/
carddatabase
.
h
\
src
/
gameview
.
h
\
src
/
gameview
.
h
\
src
/
deck_picturecacher
.
h
\
src
/
deck_picturecacher
.
h
\
src
/
decklistmodel
.
h
\
src
/
decklistmodel
.
h
\
src
/
dlg_load_deck_from_clipboard
.
h
\
src
/
dlg_load_remote_deck
.
h
\
src
/
dlg_load_remote_deck
.
h
\
src
/
cardinfowidget
.
h
\
src
/
cardinfowidget
.
h
\
src
/
messagelogwidget
.
h
\
src
/
messagelogwidget
.
h
\
...
@@ -75,10 +78,13 @@ SOURCES += src/counter.cpp \
...
@@ -75,10 +78,13 @@ SOURCES += src/counter.cpp \
src
/
tablezone
.
cpp
\
src
/
tablezone
.
cpp
\
src
/
handzone
.
cpp
\
src
/
handzone
.
cpp
\
src
/
handcounter
.
cpp
\
src
/
handcounter
.
cpp
\
src
/
handzone_vert
.
cpp
\
src
/
handzone_horiz
.
cpp
\
src
/
carddatabase
.
cpp
\
src
/
carddatabase
.
cpp
\
src
/
gameview
.
cpp
\
src
/
gameview
.
cpp
\
src
/
deck_picturecacher
.
cpp
\
src
/
deck_picturecacher
.
cpp
\
src
/
decklistmodel
.
cpp
\
src
/
decklistmodel
.
cpp
\
src
/
dlg_load_deck_from_clipboard
.
cpp
\
src
/
dlg_load_remote_deck
.
cpp
\
src
/
dlg_load_remote_deck
.
cpp
\
src
/
cardinfowidget
.
cpp
\
src
/
cardinfowidget
.
cpp
\
src
/
messagelogwidget
.
cpp
\
src
/
messagelogwidget
.
cpp
\
...
...
cockatrice/src/dlg_creategame.cpp
View file @
e1a72832
...
@@ -14,11 +14,25 @@ DlgCreateGame::DlgCreateGame(Client *_client, QWidget *parent)
...
@@ -14,11 +14,25 @@ DlgCreateGame::DlgCreateGame(Client *_client, QWidget *parent)
passwordLabel
->
setBuddy
(
passwordEdit
);
passwordLabel
->
setBuddy
(
passwordEdit
);
maxPlayersLabel
=
new
QLabel
(
tr
(
"P&layers:"
));
maxPlayersLabel
=
new
QLabel
(
tr
(
"P&layers:"
));
maxPlayersEdit
=
new
QLineEdit
(
"2"
);
maxPlayersEdit
=
new
QSpinBox
();
maxPlayersEdit
->
setMinimum
(
1
);
maxPlayersEdit
->
setMaximum
(
100
);
maxPlayersEdit
->
setValue
(
2
);
maxPlayersLabel
->
setBuddy
(
maxPlayersEdit
);
maxPlayersLabel
->
setBuddy
(
maxPlayersEdit
);
spectatorsAllowedCheckBox
=
new
QCheckBox
(
tr
(
"&Spectators allowed"
));
spectatorsAllowedCheckBox
=
new
QCheckBox
(
tr
(
"&Spectators allowed"
));
spectatorsAllowedCheckBox
->
setChecked
(
true
);
spectatorsAllowedCheckBox
->
setChecked
(
true
);
connect
(
spectatorsAllowedCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
spectatorsAllowedChanged
(
int
)));
spectatorsNeedPasswordCheckBox
=
new
QCheckBox
(
tr
(
"Spectators &need a password to join"
));
spectatorsCanTalkCheckBox
=
new
QCheckBox
(
tr
(
"Spectators can &chat"
));
spectatorsSeeEverythingCheckBox
=
new
QCheckBox
(
tr
(
"Spectators see &everything"
));
QVBoxLayout
*
spectatorsLayout
=
new
QVBoxLayout
;
spectatorsLayout
->
addWidget
(
spectatorsAllowedCheckBox
);
spectatorsLayout
->
addWidget
(
spectatorsNeedPasswordCheckBox
);
spectatorsLayout
->
addWidget
(
spectatorsCanTalkCheckBox
);
spectatorsLayout
->
addWidget
(
spectatorsSeeEverythingCheckBox
);
spectatorsGroupBox
=
new
QGroupBox
(
tr
(
"Spectators"
));
spectatorsGroupBox
->
setLayout
(
spectatorsLayout
);
QGridLayout
*
grid
=
new
QGridLayout
;
QGridLayout
*
grid
=
new
QGridLayout
;
grid
->
addWidget
(
descriptionLabel
,
0
,
0
);
grid
->
addWidget
(
descriptionLabel
,
0
,
0
);
...
@@ -27,7 +41,7 @@ DlgCreateGame::DlgCreateGame(Client *_client, QWidget *parent)
...
@@ -27,7 +41,7 @@ DlgCreateGame::DlgCreateGame(Client *_client, QWidget *parent)
grid
->
addWidget
(
passwordEdit
,
1
,
1
);
grid
->
addWidget
(
passwordEdit
,
1
,
1
);
grid
->
addWidget
(
maxPlayersLabel
,
2
,
0
);
grid
->
addWidget
(
maxPlayersLabel
,
2
,
0
);
grid
->
addWidget
(
maxPlayersEdit
,
2
,
1
);
grid
->
addWidget
(
maxPlayersEdit
,
2
,
1
);
grid
->
addWidget
(
spectators
AllowedCheck
Box
,
3
,
0
,
1
,
2
);
grid
->
addWidget
(
spectators
Group
Box
,
3
,
0
,
1
,
2
);
okButton
=
new
QPushButton
(
tr
(
"&OK"
));
okButton
=
new
QPushButton
(
tr
(
"&OK"
));
okButton
->
setDefault
(
true
);
okButton
->
setDefault
(
true
);
...
@@ -53,13 +67,15 @@ DlgCreateGame::DlgCreateGame(Client *_client, QWidget *parent)
...
@@ -53,13 +67,15 @@ DlgCreateGame::DlgCreateGame(Client *_client, QWidget *parent)
void
DlgCreateGame
::
actOK
()
void
DlgCreateGame
::
actOK
()
{
{
bool
ok
;
Command_CreateGame
*
createCommand
=
new
Command_CreateGame
(
int
maxPlayers
=
maxPlayersEdit
->
text
().
toInt
(
&
ok
);
descriptionEdit
->
text
(),
if
(
!
ok
)
{
passwordEdit
->
text
(),
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"Invalid number of players."
));
maxPlayersEdit
->
value
(),
return
;
spectatorsAllowedCheckBox
->
isChecked
(),
}
spectatorsNeedPasswordCheckBox
->
isChecked
(),
Command_CreateGame
*
createCommand
=
new
Command_CreateGame
(
descriptionEdit
->
text
(),
passwordEdit
->
text
(),
maxPlayers
,
spectatorsAllowedCheckBox
->
isChecked
());
spectatorsCanTalkCheckBox
->
isChecked
(),
spectatorsSeeEverythingCheckBox
->
isChecked
()
);
connect
(
createCommand
,
SIGNAL
(
finished
(
ResponseCode
)),
this
,
SLOT
(
checkResponse
(
ResponseCode
)));
connect
(
createCommand
,
SIGNAL
(
finished
(
ResponseCode
)),
this
,
SLOT
(
checkResponse
(
ResponseCode
)));
client
->
sendCommand
(
createCommand
);
client
->
sendCommand
(
createCommand
);
...
@@ -79,3 +95,10 @@ void DlgCreateGame::checkResponse(ResponseCode response)
...
@@ -79,3 +95,10 @@ void DlgCreateGame::checkResponse(ResponseCode response)
return
;
return
;
}
}
}
}
void
DlgCreateGame
::
spectatorsAllowedChanged
(
int
state
)
{
spectatorsNeedPasswordCheckBox
->
setEnabled
(
state
);
spectatorsCanTalkCheckBox
->
setEnabled
(
state
);
spectatorsSeeEverythingCheckBox
->
setEnabled
(
state
);
}
cockatrice/src/dlg_creategame.h
View file @
e1a72832
...
@@ -8,6 +8,8 @@ class QLabel;
...
@@ -8,6 +8,8 @@ class QLabel;
class
QLineEdit
;
class
QLineEdit
;
class
QPushButton
;
class
QPushButton
;
class
QCheckBox
;
class
QCheckBox
;
class
QGroupBox
;
class
QSpinBox
;
class
DlgCreateGame
:
public
QDialog
{
class
DlgCreateGame
:
public
QDialog
{
Q_OBJECT
Q_OBJECT
...
@@ -16,12 +18,15 @@ public:
...
@@ -16,12 +18,15 @@ public:
private
slots
:
private
slots
:
void
actOK
();
void
actOK
();
void
checkResponse
(
ResponseCode
response
);
void
checkResponse
(
ResponseCode
response
);
void
spectatorsAllowedChanged
(
int
state
);
private:
private:
Client
*
client
;
Client
*
client
;
QGroupBox
*
spectatorsGroupBox
;
QLabel
*
descriptionLabel
,
*
passwordLabel
,
*
maxPlayersLabel
;
QLabel
*
descriptionLabel
,
*
passwordLabel
,
*
maxPlayersLabel
;
QLineEdit
*
descriptionEdit
,
*
passwordEdit
,
*
maxPlayersEdit
;
QLineEdit
*
descriptionEdit
,
*
passwordEdit
;
QCheckBox
*
spectatorsAllowedCheckBox
;
QSpinBox
*
maxPlayersEdit
;
QCheckBox
*
spectatorsAllowedCheckBox
,
*
spectatorsNeedPasswordCheckBox
,
*
spectatorsCanTalkCheckBox
,
*
spectatorsSeeEverythingCheckBox
;
QPushButton
*
okButton
,
*
cancelButton
;
QPushButton
*
okButton
,
*
cancelButton
;
};
};
...
...
cockatrice/src/dlg_load_deck_from_clipboard.cpp
0 → 100644
View file @
e1a72832
#include
<QClipboard>
#include
<QPlainTextEdit>
#include
<QPushButton>
#include
<QVBoxLayout>
#include
<QHBoxLayout>
#include
<QKeySequence>
#include
<QApplication>
#include
<QTextStream>
#include
<QMessageBox>
#include
"dlg_load_deck_from_clipboard.h"
#include
"decklist.h"
DlgLoadDeckFromClipboard
::
DlgLoadDeckFromClipboard
(
QWidget
*
parent
)
:
QDialog
(
parent
),
deckList
(
0
)
{
contentsEdit
=
new
QPlainTextEdit
;
refreshButton
=
new
QPushButton
(
tr
(
"&Refresh"
));
refreshButton
->
setShortcut
(
QKeySequence
(
"F5"
));
okButton
=
new
QPushButton
(
tr
(
"&OK"
));
okButton
->
setDefault
(
true
);
cancelButton
=
new
QPushButton
(
tr
(
"&Cancel"
));
QHBoxLayout
*
buttonLayout
=
new
QHBoxLayout
;
buttonLayout
->
addWidget
(
refreshButton
);
buttonLayout
->
addStretch
();
buttonLayout
->
addWidget
(
okButton
);
buttonLayout
->
addWidget
(
cancelButton
);
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addWidget
(
contentsEdit
);
mainLayout
->
addLayout
(
buttonLayout
);
setLayout
(
mainLayout
);
setWindowTitle
(
tr
(
"Load deck from clipboard"
));
resize
(
500
,
500
);
connect
(
refreshButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actRefresh
()));
connect
(
okButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actOK
()));
connect
(
cancelButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reject
()));
actRefresh
();
}
void
DlgLoadDeckFromClipboard
::
actRefresh
()
{
contentsEdit
->
setPlainText
(
QApplication
::
clipboard
()
->
text
());
}
void
DlgLoadDeckFromClipboard
::
actOK
()
{
QString
buffer
=
contentsEdit
->
toPlainText
();
QTextStream
stream
(
&
buffer
);
DeckList
*
l
=
new
DeckList
;
if
(
l
->
loadFromStream_Plain
(
stream
))
{
deckList
=
l
;
accept
();
}
else
{
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"Invalid deck list."
));
delete
l
;
}
}
cockatrice/src/dlg_load_deck_from_clipboard.h
0 → 100644
View file @
e1a72832
#ifndef DLG_LOAD_DECK_FROM_CLIPBOARD_H
#define DLG_LOAD_DECK_FROM_CLIPBOARD_H
#include
<QDialog>
class
DeckList
;
class
QPlainTextEdit
;
class
QPushButton
;
class
DlgLoadDeckFromClipboard
:
public
QDialog
{
Q_OBJECT
private
slots
:
void
actOK
();
void
actRefresh
();
private:
DeckList
*
deckList
;
public:
DlgLoadDeckFromClipboard
(
QWidget
*
parent
=
0
);
DeckList
*
getDeckList
()
const
{
return
deckList
;
}
private:
QPlainTextEdit
*
contentsEdit
;
QPushButton
*
refreshButton
,
*
okButton
,
*
cancelButton
;
};
#endif
cockatrice/src/dlg_settings.cpp
View file @
e1a72832
...
@@ -199,6 +199,16 @@ AppearanceSettingsPage::AppearanceSettingsPage()
...
@@ -199,6 +199,16 @@ AppearanceSettingsPage::AppearanceSettingsPage()
zoneBgGroupBox
=
new
QGroupBox
;
zoneBgGroupBox
=
new
QGroupBox
;
zoneBgGroupBox
->
setLayout
(
zoneBgGrid
);
zoneBgGroupBox
->
setLayout
(
zoneBgGrid
);
horizontalHandCheckBox
=
new
QCheckBox
;
horizontalHandCheckBox
->
setChecked
(
settingsCache
->
getHorizontalHand
());
connect
(
horizontalHandCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
settingsCache
,
SLOT
(
setHorizontalHand
(
int
)));
QGridLayout
*
handGrid
=
new
QGridLayout
;
handGrid
->
addWidget
(
horizontalHandCheckBox
,
0
,
0
,
1
,
2
);
handGroupBox
=
new
QGroupBox
;
handGroupBox
->
setLayout
(
handGrid
);
economicGridCheckBox
=
new
QCheckBox
;
economicGridCheckBox
=
new
QCheckBox
;
economicGridCheckBox
->
setChecked
(
settingsCache
->
getEconomicGrid
());
economicGridCheckBox
->
setChecked
(
settingsCache
->
getEconomicGrid
());
connect
(
economicGridCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
settingsCache
,
SLOT
(
setEconomicGrid
(
int
)));
connect
(
economicGridCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
settingsCache
,
SLOT
(
setEconomicGrid
(
int
)));
...
@@ -225,6 +235,7 @@ AppearanceSettingsPage::AppearanceSettingsPage()
...
@@ -225,6 +235,7 @@ AppearanceSettingsPage::AppearanceSettingsPage()
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addWidget
(
zoneBgGroupBox
);
mainLayout
->
addWidget
(
zoneBgGroupBox
);
mainLayout
->
addWidget
(
handGroupBox
);
mainLayout
->
addWidget
(
tableGroupBox
);
mainLayout
->
addWidget
(
tableGroupBox
);
mainLayout
->
addWidget
(
zoneViewGroupBox
);
mainLayout
->
addWidget
(
zoneViewGroupBox
);
...
@@ -239,6 +250,9 @@ void AppearanceSettingsPage::retranslateUi()
...
@@ -239,6 +250,9 @@ void AppearanceSettingsPage::retranslateUi()
tableBgLabel
->
setText
(
tr
(
"Path to table background:"
));
tableBgLabel
->
setText
(
tr
(
"Path to table background:"
));
playerAreaBgLabel
->
setText
(
tr
(
"Path to player info background:"
));
playerAreaBgLabel
->
setText
(
tr
(
"Path to player info background:"
));
handGroupBox
->
setTitle
(
tr
(
"Hand layout"
));
horizontalHandCheckBox
->
setText
(
tr
(
"Display hand horizontally (wastes space)"
));
tableGroupBox
->
setTitle
(
tr
(
"Table grid layout"
));
tableGroupBox
->
setTitle
(
tr
(
"Table grid layout"
));
economicGridCheckBox
->
setText
(
tr
(
"Economic layout"
));
economicGridCheckBox
->
setText
(
tr
(
"Economic layout"
));
...
...
cockatrice/src/dlg_settings.h
View file @
e1a72832
...
@@ -60,8 +60,8 @@ signals:
...
@@ -60,8 +60,8 @@ signals:
private:
private:
QLabel
*
handBgLabel
,
*
tableBgLabel
,
*
playerAreaBgLabel
;
QLabel
*
handBgLabel
,
*
tableBgLabel
,
*
playerAreaBgLabel
;
QLineEdit
*
handBgEdit
,
*
tableBgEdit
,
*
playerAreaBgEdit
;
QLineEdit
*
handBgEdit
,
*
tableBgEdit
,
*
playerAreaBgEdit
;
QCheckBox
*
economicGridCheckBox
,
*
zoneViewSortByNameCheckBox
,
*
zoneViewSortByTypeCheckBox
;
QCheckBox
*
horizontalHandCheckBox
,
*
economicGridCheckBox
,
*
zoneViewSortByNameCheckBox
,
*
zoneViewSortByTypeCheckBox
;
QGroupBox
*
zoneBgGroupBox
,
*
tableGroupBox
,
*
zoneViewGroupBox
;
QGroupBox
*
zoneBgGroupBox
,
*
handGroupBox
,
*
tableGroupBox
,
*
zoneViewGroupBox
;
public:
public:
AppearanceSettingsPage
();
AppearanceSettingsPage
();
void
retranslateUi
();
void
retranslateUi
();
...
...
cockatrice/src/gamescene.cpp
View file @
e1a72832
...
@@ -103,3 +103,26 @@ void GameScene::closeMostRecentZoneView()
...
@@ -103,3 +103,26 @@ void GameScene::closeMostRecentZoneView()
if
(
!
views
.
isEmpty
())
if
(
!
views
.
isEmpty
())
views
.
last
()
->
close
();
views
.
last
()
->
close
();
}
}
void
GameScene
::
processViewSizeChange
(
const
QSize
&
newSize
)
{
qreal
newRatio
=
((
qreal
)
newSize
.
width
())
/
newSize
.
height
();
qreal
minWidth
=
0
;
for
(
int
i
=
0
;
i
<
players
.
size
();
++
i
)
{
qreal
w
=
players
[
i
]
->
getMinimumWidth
();
if
(
w
>
minWidth
)
minWidth
=
w
;
}
qreal
minRatio
=
minWidth
/
sceneRect
().
height
();
if
(
minRatio
>
newRatio
)
{
// Aspect ratio is dominated by table width.
setSceneRect
(
sceneRect
().
x
(),
sceneRect
().
y
(),
minWidth
,
sceneRect
().
height
());
}
else
{
// Aspect ratio is dominated by window dimensions.
setSceneRect
(
sceneRect
().
x
(),
sceneRect
().
y
(),
newRatio
*
sceneRect
().
height
(),
sceneRect
().
height
());
}
for
(
int
i
=
0
;
i
<
players
.
size
();
++
i
)
players
[
i
]
->
processSceneSizeChange
(
sceneRect
().
size
());
}
cockatrice/src/gamescene.h
View file @
e1a72832
...
@@ -19,6 +19,7 @@ public:
...
@@ -19,6 +19,7 @@ public:
GameScene
(
QObject
*
parent
=
0
);
GameScene
(
QObject
*
parent
=
0
);
void
retranslateUi
();
void
retranslateUi
();
const
QRectF
&
getPlayersRect
()
const
{
return
playersRect
;
}
const
QRectF
&
getPlayersRect
()
const
{
return
playersRect
;
}
void
processViewSizeChange
(
const
QSize
&
newSize
);
public
slots
:
public
slots
:
void
toggleZoneView
(
Player
*
player
,
const
QString
&
zoneName
,
int
numberCards
);
void
toggleZoneView
(
Player
*
player
,
const
QString
&
zoneName
,
int
numberCards
);
void
removeZoneView
(
ZoneViewWidget
*
item
);
void
removeZoneView
(
ZoneViewWidget
*
item
);
...
...
cockatrice/src/gamesmodel.cpp
View file @
e1a72832
...
@@ -27,7 +27,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
...
@@ -27,7 +27,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
switch
(
index
.
column
())
{
switch
(
index
.
column
())
{
case
0
:
return
g
->
getDescription
();
case
0
:
return
g
->
getDescription
();
case
1
:
return
g
->
getCreatorName
();
case
1
:
return
g
->
getCreatorName
();
case
2
:
return
g
->
getHasPassword
()
?
tr
(
"yes"
)
:
tr
(
"no"
);
case
2
:
return
g
->
getHasPassword
()
?
(
g
->
getSpectatorsNeedPassword
()
?
tr
(
"yes"
)
:
tr
(
"yes, free for spectators"
)
)
:
tr
(
"no"
);
case
3
:
return
QString
(
"%1/%2"
).
arg
(
g
->
getPlayerCount
()).
arg
(
g
->
getMaxPlayers
());
case
3
:
return
QString
(
"%1/%2"
).
arg
(
g
->
getPlayerCount
()).
arg
(
g
->
getMaxPlayers
());
case
4
:
return
g
->
getSpectatorsAllowed
()
?
QVariant
(
g
->
getSpectatorCount
())
:
QVariant
(
tr
(
"not allowed"
));
case
4
:
return
g
->
getSpectatorsAllowed
()
?
QVariant
(
g
->
getSpectatorCount
())
:
QVariant
(
tr
(
"not allowed"
));
default:
return
QVariant
();
default:
return
QVariant
();
...
@@ -56,7 +56,7 @@ ServerInfo_Game *GamesModel::getGame(int row)
...
@@ -56,7 +56,7 @@ ServerInfo_Game *GamesModel::getGame(int row)
void
GamesModel
::
updateGameList
(
ServerInfo_Game
*
_game
)
void
GamesModel
::
updateGameList
(
ServerInfo_Game
*
_game
)
{
{
ServerInfo_Game
*
game
=
new
ServerInfo_Game
(
_game
->
getGameId
(),
_game
->
getDescription
(),
_game
->
getHasPassword
(),
_game
->
getPlayerCount
(),
_game
->
getMaxPlayers
(),
_game
->
getCreatorName
(),
_game
->
getSpectatorsAllowed
(),
_game
->
getSpectatorCount
());
ServerInfo_Game
*
game
=
new
ServerInfo_Game
(
_game
->
getGameId
(),
_game
->
getDescription
(),
_game
->
getHasPassword
(),
_game
->
getPlayerCount
(),
_game
->
getMaxPlayers
(),
_game
->
getCreatorName
(),
_game
->
getSpectatorsAllowed
(),
_game
->
getSpectatorsNeedPassword
(),
_game
->
getSpectatorCount
());
for
(
int
i
=
0
;
i
<
gameList
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
gameList
.
size
();
i
++
)
if
(
gameList
[
i
]
->
getGameId
()
==
game
->
getGameId
())
{
if
(
gameList
[
i
]
->
getGameId
()
==
game
->
getGameId
())
{
if
(
game
->
getPlayerCount
()
==
0
)
{
if
(
game
->
getPlayerCount
()
==
0
)
{
...
...
cockatrice/src/gameview.cpp
View file @
e1a72832
#include
"gameview.h"
#include
"gameview.h"
#include
"gamescene.h"
#include
<QResizeEvent>
#include
<QAction>
#include
<QAction>
GameView
::
GameView
(
QGraphicsScene
*
scene
,
QWidget
*
parent
)
GameView
::
GameView
(
QGraphicsScene
*
scene
,
QWidget
*
parent
)
...
@@ -21,6 +23,10 @@ GameView::GameView(QGraphicsScene *scene, QWidget *parent)
...
@@ -21,6 +23,10 @@ GameView::GameView(QGraphicsScene *scene, QWidget *parent)
void
GameView
::
resizeEvent
(
QResizeEvent
*
event
)
void
GameView
::
resizeEvent
(
QResizeEvent
*
event
)
{
{
QGraphicsView
::
resizeEvent
(
event
);
QGraphicsView
::
resizeEvent
(
event
);
GameScene
*
s
=
dynamic_cast
<
GameScene
*>
(
scene
());
if
(
s
)
{
s
->
processViewSizeChange
(
event
->
size
());
}
updateSceneRect
(
scene
()
->
sceneRect
());
updateSceneRect
(
scene
()
->
sceneRect
());
}
}
...
...
cockatrice/src/handzone.cpp
View file @
e1a72832
#include
<QtGui>
#include
"handzone.h"
#include
"handzone.h"
#include
"settingscache.h"
#include
"player.h"
#include
"player.h"
#include
"client.h"
#include
"protocol_items.h"
#include
"protocol_items.h"
#include
"settingscache.h"
HandZone
::
HandZone
(
Player
*
_p
,
int
_
z
on
eHeight
,
QGraphicsItem
*
parent
)
HandZone
::
HandZone
(
Player
*
_p
,
bool
_
c
on
tentsKnown
,
QGraphicsItem
*
parent
)
:
CardZone
(
_p
,
"hand"
,
false
,
false
,
_
p
->
getLocal
(),
parent
),
zoneHeight
(
_zoneHeigh
t
)
:
CardZone
(
_p
,
"hand"
,
false
,
false
,
_
contentsKnown
,
paren
t
)
{
{
connect
(
settingsCache
,
SIGNAL
(
handBgPathChanged
()),
this
,
SLOT
(
updateBgPixmap
()));
connect
(
settingsCache
,
SIGNAL
(
handBgPathChanged
()),
this
,
SLOT
(
updateBgPixmap
()));
updateBgPixmap
();
updateBgPixmap
();
setCacheMode
(
DeviceCoordinateCache
);
}
}
void
HandZone
::
updateBgPixmap
()
void
HandZone
::
updateBgPixmap
()
...
@@ -22,46 +18,6 @@ void HandZone::updateBgPixmap()
...
@@ -22,46 +18,6 @@ void HandZone::updateBgPixmap()
update
();
update
();
}
}
QRectF
HandZone
::
boundingRect
()
const
{
return
QRectF
(
0
,
0
,
100
,
zoneHeight
);
}
void
HandZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
{
if
(
bgPixmap
.
isNull
())
painter
->
fillRect
(
boundingRect
(),
Qt
::
darkGreen
);
else
painter
->
fillRect
(
boundingRect
(),
QBrush
(
bgPixmap
));
}
void
HandZone
::
reorganizeCards
()
{
if
(
!
cards
.
isEmpty
())
{
const
int
cardCount
=
cards
.
size
();
qreal
totalWidth
=
boundingRect
().
width
();
qreal
totalHeight
=
boundingRect
().
height
();
qreal
cardWidth
=
cards
.
at
(
0
)
->
boundingRect
().
width
();
qreal
cardHeight
=
cards
.
at
(
0
)
->
boundingRect
().
height
();
qreal
xspace
=
5
;
qreal
x1
=
xspace
;
qreal
x2
=
totalWidth
-
xspace
-
cardWidth
;
for
(
int
i
=
0
;
i
<
cardCount
;
i
++
)
{
CardItem
*
c
=
cards
.
at
(
i
);
qreal
x
=
i
%
2
?
x2
:
x1
;
// If the total height of the cards is smaller than the available height,
// the cards do not need to overlap and are displayed in the center of the area.
if
(
cardHeight
*
cardCount
>
totalHeight
)
c
->
setPos
(
x
,
((
qreal
)
i
)
*
(
totalHeight
-
cardHeight
)
/
(
cardCount
-
1
));
else
c
->
setPos
(
x
,
((
qreal
)
i
)
*
cardHeight
+
(
totalHeight
-
cardCount
*
cardHeight
)
/
2
);
c
->
setZValue
(
i
);
}
}
update
();
}
void
HandZone
::
addCardImpl
(
CardItem
*
card
,
int
x
,
int
/*y*/
)
void
HandZone
::
addCardImpl
(
CardItem
*
card
,
int
x
,
int
/*y*/
)
{
{
if
(
x
==
-
1
)
if
(
x
==
-
1
)
...
...
cockatrice/src/handzone.h
View file @
e1a72832
...
@@ -5,19 +5,17 @@
...
@@ -5,19 +5,17 @@
class
HandZone
:
public
CardZone
{
class
HandZone
:
public
CardZone
{
Q_OBJECT
Q_OBJECT
pr
ivate
:
pr
otected
:
QPixmap
bgPixmap
;
QPixmap
bgPixmap
;
int
zoneHeight
;
private
slots
:
private
slots
:
void
updateBgPixmap
();
void
updateBgPixmap
();
public:
public:
HandZone
(
Player
*
_p
,
int
_zoneHeight
,
QGraphicsItem
*
parent
=
0
);
HandZone
(
Player
*
_p
,
bool
_contentsKnown
,
QGraphicsItem
*
parent
=
0
);
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
reorganizeCards
();
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
virtual
void
setWidth
(
qreal
_width
)
=
0
;
protected:
protected:
void
addCardImpl
(
CardItem
*
card
,
int
x
,
int
y
);
void
addCardImpl
(
CardItem
*
card
,
int
x
,
int
y
);
};
};
#endif
#endif
cockatrice/src/handzone_horiz.cpp
0 → 100644
View file @
e1a72832
#include
<QPainter>
#include
"handzone_horiz.h"
#include
"player.h"
HandZoneHoriz
::
HandZoneHoriz
(
Player
*
_p
,
bool
_contentsKnown
,
QGraphicsItem
*
parent
)
:
HandZone
(
_p
,
_contentsKnown
,
parent
),
width
(
CARD_WIDTH
*
10
)
{
setCacheMode
(
DeviceCoordinateCache
);
}
QRectF
HandZoneHoriz
::
boundingRect
()
const
{
return
QRectF
(
0
,
0
,
width
,
CARD_HEIGHT
+
10
);
}
void
HandZoneHoriz
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
{
if
(
bgPixmap
.
isNull
())
painter
->
fillRect
(
boundingRect
(),
Qt
::
darkGreen
);
else
painter
->
fillRect
(
boundingRect
(),
QBrush
(
bgPixmap
));
}
void
HandZoneHoriz
::
reorganizeCards
()
{
if
(
!
cards
.
isEmpty
())
{
const
int
cardCount
=
cards
.
size
();
const
int
xPadding
=
5
;
qreal
totalWidth
=
boundingRect
().
width
()
-
2
*
xPadding
;
qreal
cardWidth
=
cards
.
at
(
0
)
->
boundingRect
().
width
();
for
(
int
i
=
0
;
i
<
cardCount
;
i
++
)
{
CardItem
*
c
=
cards
.
at
(
i
);
// If the total width of the cards is smaller than the available width,
// the cards do not need to overlap and are displayed in the center of the area.
if
(
cardWidth
*
cardCount
>
totalWidth
)
c
->
setPos
(
xPadding
+
((
qreal
)
i
)
*
(
totalWidth
-
cardWidth
)
/
(
cardCount
-
1
),
5
);
else
c
->
setPos
(
xPadding
+
((
qreal
)
i
)
*
cardWidth
+
(
totalWidth
-
cardCount
*
cardWidth
)
/
2
,
5
);
c
->
setZValue
(
i
);
}
}
update
();
}
void
HandZoneHoriz
::
setWidth
(
qreal
_width
)
{
prepareGeometryChange
();
width
=
_width
;
reorganizeCards
();
}
cockatrice/src/handzone_horiz.h
0 → 100644
View file @
e1a72832
#ifndef HANDZONE_HORIZ_H
#define HANDZONE_HORIZ_H
#include
"handzone.h"
class
HandZoneHoriz
:
public
HandZone
{
Q_OBJECT
private:
qreal
width
;
public:
HandZoneHoriz
(
Player
*
_p
,
bool
_contentsKnown
,
QGraphicsItem
*
parent
=
0
);
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
reorganizeCards
();
void
setWidth
(
qreal
_width
);
};
#endif
cockatrice/src/handzone_vert.cpp
0 → 100644
View file @
e1a72832
#include
<QtGui>
#include
"handzone_vert.h"
#include
"player.h"
#include
"client.h"
#include
"protocol_items.h"
#include
"settingscache.h"
HandZoneVert
::
HandZoneVert
(
Player
*
_p
,
bool
_contentsKnown
,
int
_zoneHeight
,
QGraphicsItem
*
parent
)
:
HandZone
(
_p
,
_contentsKnown
,
parent
),
zoneHeight
(
_zoneHeight
)
{
setCacheMode
(
DeviceCoordinateCache
);
}
QRectF
HandZoneVert
::
boundingRect
()
const
{
return
QRectF
(
0
,
0
,
100
,
zoneHeight
);
}
void
HandZoneVert
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
{
if
(
bgPixmap
.
isNull
())
painter
->
fillRect
(
boundingRect
(),
Qt
::
darkGreen
);
else
painter
->
fillRect
(
boundingRect
(),
QBrush
(
bgPixmap
));
}
void
HandZoneVert
::
reorganizeCards
()
{
if
(
!
cards
.
isEmpty
())
{
const
int
cardCount
=
cards
.
size
();
qreal
totalWidth
=
boundingRect
().
width
();
qreal
totalHeight
=
boundingRect
().
height
();
qreal
cardWidth
=
cards
.
at
(
0
)
->
boundingRect
().
width
();
qreal
cardHeight
=
cards
.
at
(
0
)
->
boundingRect
().
height
();
qreal
xspace
=
5
;
qreal
x1
=
xspace
;
qreal
x2
=
totalWidth
-
xspace
-
cardWidth
;
for
(
int
i
=
0
;
i
<
cardCount
;
i
++
)
{
CardItem
*
c
=
cards
.
at
(
i
);
qreal
x
=
i
%
2
?
x2
:
x1
;
// If the total height of the cards is smaller than the available height,
// the cards do not need to overlap and are displayed in the center of the area.
if
(
cardHeight
*
cardCount
>
totalHeight
)
c
->
setPos
(
x
,
((
qreal
)
i
)
*
(
totalHeight
-
cardHeight
)
/
(
cardCount
-
1
));
else
c
->
setPos
(
x
,
((
qreal
)
i
)
*
cardHeight
+
(
totalHeight
-
cardCount
*
cardHeight
)
/
2
);
c
->
setZValue
(
i
);
}
}
update
();
}
cockatrice/src/handzone_vert.h
0 → 100644
View file @
e1a72832
#ifndef HANDZONE_VERT_H
#define HANDZONE_VERT_H
#include
"handzone.h"
class
HandZoneVert
:
public
HandZone
{
Q_OBJECT
private:
int
zoneHeight
;
public:
HandZoneVert
(
Player
*
_p
,
bool
_contentsKnown
,
int
_zoneHeight
,
QGraphicsItem
*
parent
=
0
);
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
reorganizeCards
();
void
setWidth
(
qreal
/*_width*/
)
{
}
};
#endif
cockatrice/src/messagelogwidget.cpp
View file @
e1a72832
...
@@ -104,7 +104,12 @@ void MessageLogWidget::logGameStart()
...
@@ -104,7 +104,12 @@ void MessageLogWidget::logGameStart()
void
MessageLogWidget
::
logSay
(
Player
*
player
,
QString
message
)
void
MessageLogWidget
::
logSay
(
Player
*
player
,
QString
message
)
{
{
append
(
QString
(
"<font color=
\"
red
\"
>%1:</font> %2"
).
arg
(
sanitizeHtml
(
player
->
getName
())).
arg
(
sanitizeHtml
(
message
)));
append
(
QString
(
"<b><font color=
\"
red
\"
>%1:</font></b> %2"
).
arg
(
sanitizeHtml
(
player
->
getName
())).
arg
(
sanitizeHtml
(
message
)));
}
void
MessageLogWidget
::
logSpectatorSay
(
QString
spectatorName
,
QString
message
)
{
append
(
QString
(
"<font color=
\"
red
\"
>%1:</font> %2"
).
arg
(
sanitizeHtml
(
spectatorName
)).
arg
(
sanitizeHtml
(
message
)));
}
}
void
MessageLogWidget
::
logShuffle
(
Player
*
player
)
void
MessageLogWidget
::
logShuffle
(
Player
*
player
)
...
...
cockatrice/src/messagelogwidget.h
View file @
e1a72832
...
@@ -33,6 +33,7 @@ public slots:
...
@@ -33,6 +33,7 @@ public slots:
void
logConcede
(
Player
*
player
);
void
logConcede
(
Player
*
player
);
void
logGameStart
();
void
logGameStart
();
void
logSay
(
Player
*
player
,
QString
message
);
void
logSay
(
Player
*
player
,
QString
message
);
void
logSpectatorSay
(
QString
spectatorName
,
QString
message
);
void
logShuffle
(
Player
*
player
);
void
logShuffle
(
Player
*
player
);
void
logRollDie
(
Player
*
player
,
int
sides
,
int
roll
);
void
logRollDie
(
Player
*
player
,
int
sides
,
int
roll
);
void
logDrawCards
(
Player
*
player
,
int
number
);
void
logDrawCards
(
Player
*
player
,
int
number
);
...
...
cockatrice/src/player.cpp
View file @
e1a72832
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
#include
"tablezone.h"
#include
"tablezone.h"
#include
"handzone.h"
#include
"handzone.h"
#include
"handcounter.h"
#include
"handcounter.h"
#include
"handzone_vert.h"
#include
"handzone_horiz.h"
#include
"cardlist.h"
#include
"cardlist.h"
#include
"tab_game.h"
#include
"tab_game.h"
#include
"protocol_items.h"
#include
"protocol_items.h"
...
@@ -18,8 +20,8 @@
...
@@ -18,8 +20,8 @@
#include
<QPainter>
#include
<QPainter>
#include
<QMenu>
#include
<QMenu>
Player
::
Player
(
const
QString
&
_name
,
int
_id
,
bool
_local
,
Client
*
_client
,
TabGame
*
_parent
)
Player
::
Player
(
const
QString
&
_name
,
int
_id
,
bool
_local
,
bool
_mirrored
,
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
),
mirrored
(
_mirrored
),
client
(
_client
)
{
{
setCacheMode
(
DeviceCoordinateCache
);
setCacheMode
(
DeviceCoordinateCache
);
...
@@ -47,13 +49,26 @@ Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabG
...
@@ -47,13 +49,26 @@ Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabG
table
=
new
TableZone
(
this
,
this
);
table
=
new
TableZone
(
this
,
this
);
connect
(
table
,
SIGNAL
(
sizeChanged
()),
this
,
SLOT
(
updateBoundingRect
()));
connect
(
table
,
SIGNAL
(
sizeChanged
()),
this
,
SLOT
(
updateBoundingRect
()));
hand
=
new
HandZone
(
this
,
(
int
)
table
->
boundingRect
().
height
(),
this
);
connect
(
hand
,
SIGNAL
(
cardCountChanged
()),
handCounter
,
SLOT
(
updateNumber
()));
base
=
QPointF
(
deck
->
boundingRect
().
width
()
+
counterAreaWidth
+
5
,
0
);
base
=
QPointF
(
deck
->
boundingRect
().
width
()
+
counterAreaWidth
+
5
,
0
);
hand
->
setPos
(
base
);
base
+=
QPointF
(
hand
->
boundingRect
().
width
(),
0
);
if
(
settingsCache
->
getHorizontalHand
())
{
table
->
setPos
(
base
);
hand
=
new
HandZoneHoriz
(
this
,
_local
||
(
_parent
->
getSpectator
()
&&
_parent
->
getSpectatorsSeeEverything
()),
this
);
if
(
mirrored
)
{
hand
->
setPos
(
counterAreaWidth
+
CARD_WIDTH
+
5
,
base
.
y
());
table
->
setPos
(
base
.
x
(),
base
.
y
()
+
hand
->
boundingRect
().
height
());
}
else
{
table
->
setPos
(
base
);
hand
->
setPos
(
counterAreaWidth
+
CARD_WIDTH
+
5
,
base
.
y
()
+
table
->
boundingRect
().
height
());
}
}
else
{
hand
=
new
HandZoneVert
(
this
,
_local
||
(
_parent
->
getSpectator
()
&&
_parent
->
getSpectatorsSeeEverything
()),
(
int
)
table
->
boundingRect
().
height
(),
this
);
hand
->
setPos
(
base
);
base
+=
QPointF
(
hand
->
boundingRect
().
width
(),
0
);
table
->
setPos
(
base
);
}
connect
(
hand
,
SIGNAL
(
cardCountChanged
()),
handCounter
,
SLOT
(
updateNumber
()));
updateBoundingRect
();
updateBoundingRect
();
...
@@ -286,7 +301,10 @@ void Player::updateBgPixmap()
...
@@ -286,7 +301,10 @@ void Player::updateBgPixmap()
void
Player
::
updateBoundingRect
()
void
Player
::
updateBoundingRect
()
{
{
prepareGeometryChange
();
prepareGeometryChange
();
bRect
=
QRectF
(
0
,
0
,
CARD_WIDTH
+
5
+
counterAreaWidth
+
hand
->
boundingRect
().
width
()
+
table
->
boundingRect
().
width
(),
table
->
boundingRect
().
height
());
if
(
settingsCache
->
getHorizontalHand
())
bRect
=
QRectF
(
0
,
0
,
CARD_WIDTH
+
5
+
counterAreaWidth
+
table
->
boundingRect
().
width
(),
table
->
boundingRect
().
height
()
+
hand
->
boundingRect
().
height
());
else
bRect
=
QRectF
(
0
,
0
,
CARD_WIDTH
+
5
+
counterAreaWidth
+
hand
->
boundingRect
().
width
()
+
table
->
boundingRect
().
width
(),
table
->
boundingRect
().
height
());
emit
sizeChanged
();
emit
sizeChanged
();
}
}
...
@@ -712,17 +730,16 @@ QRectF Player::boundingRect() const
...
@@ -712,17 +730,16 @@ QRectF Player::boundingRect() const
void
Player
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
void
Player
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*/
*
option
*/
,
QWidget
*/
*
widget
*/
)
{
{
if
(
bgPixmap
.
isNull
())
painter
->
fillRect
(
boundingRect
(),
QColor
(
200
,
200
,
200
));
else
painter
->
fillRect
(
boundingRect
(),
QBrush
(
bgPixmap
));
QString
nameStr
=
getName
();
QString
nameStr
=
getName
();
QFont
font
(
"Times"
);
QFont
font
(
"Times"
);
font
.
setPixelSize
(
20
);
font
.
setPixelSize
(
20
);
// font.setWeight(QFont::Bold);
// font.setWeight(QFont::Bold);
int
totalWidth
=
CARD_WIDTH
+
counterAreaWidth
+
5
;
int
totalWidth
=
CARD_WIDTH
+
counterAreaWidth
+
5
;
if
(
bgPixmap
.
isNull
())
painter
->
fillRect
(
QRectF
(
0
,
0
,
totalWidth
,
boundingRect
().
height
()),
QColor
(
200
,
200
,
200
));
else
painter
->
fillRect
(
QRectF
(
0
,
0
,
totalWidth
,
boundingRect
().
height
()),
QBrush
(
bgPixmap
));
if
(
getActive
())
{
if
(
getActive
())
{
QFontMetrics
fm
(
font
);
QFontMetrics
fm
(
font
);
...
@@ -1000,3 +1017,18 @@ void Player::actMoveToExile(CardItem *card)
...
@@ -1000,3 +1017,18 @@ void Player::actMoveToExile(CardItem *card)
CardZone
*
startZone
=
qgraphicsitem_cast
<
CardZone
*>
(
card
->
parentItem
());
CardZone
*
startZone
=
qgraphicsitem_cast
<
CardZone
*>
(
card
->
parentItem
());
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
card
->
getId
(),
"rfg"
,
0
,
0
,
false
));
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
card
->
getId
(),
"rfg"
,
0
,
0
,
false
));
}
}
qreal
Player
::
getMinimumWidth
()
const
{
return
table
->
getMinimumWidth
()
+
CARD_WIDTH
+
5
+
counterAreaWidth
;
}
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
;
table
->
setWidth
(
tableWidth
);
hand
->
setWidth
(
tableWidth
);
}
Prev
1
2
3
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