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
befafa28
Commit
befafa28
authored
May 26, 2010
by
Max-Wilhelm Bruker
Browse files
Fixed elevation of spectator rights; added some spectator options; closes bug 0000005
parent
604d1ffa
Changes
26
Expand all
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/dlg_creategame.cpp
View file @
befafa28
...
@@ -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 &talk"
));
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 @
befafa28
...
@@ -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/gamesmodel.cpp
View file @
befafa28
...
@@ -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/handzone.cpp
View file @
befafa28
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
#include
"protocol_items.h"
#include
"protocol_items.h"
#include
"settingscache.h"
#include
"settingscache.h"
HandZone
::
HandZone
(
Player
*
_p
,
int
_zoneHeight
,
QGraphicsItem
*
parent
)
HandZone
::
HandZone
(
Player
*
_p
,
bool
_contentsKnown
,
int
_zoneHeight
,
QGraphicsItem
*
parent
)
:
CardZone
(
_p
,
"hand"
,
false
,
false
,
_
p
->
getLocal
()
,
parent
),
zoneHeight
(
_zoneHeight
)
:
CardZone
(
_p
,
"hand"
,
false
,
false
,
_
contentsKnown
,
parent
),
zoneHeight
(
_zoneHeight
)
{
{
connect
(
settingsCache
,
SIGNAL
(
handBgPathChanged
()),
this
,
SLOT
(
updateBgPixmap
()));
connect
(
settingsCache
,
SIGNAL
(
handBgPathChanged
()),
this
,
SLOT
(
updateBgPixmap
()));
updateBgPixmap
();
updateBgPixmap
();
...
...
cockatrice/src/handzone.h
View file @
befafa28
...
@@ -11,7 +11,7 @@ private:
...
@@ -11,7 +11,7 @@ private:
private
slots
:
private
slots
:
void
updateBgPixmap
();
void
updateBgPixmap
();
public:
public:
HandZone
(
Player
*
_p
,
int
_zoneHeight
,
QGraphicsItem
*
parent
=
0
);
HandZone
(
Player
*
_p
,
bool
_contentsKnown
,
int
_zoneHeight
,
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
reorganizeCards
();
...
...
cockatrice/src/messagelogwidget.cpp
View file @
befafa28
...
@@ -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 @
befafa28
...
@@ -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 @
befafa28
...
@@ -43,7 +43,7 @@ Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabG
...
@@ -43,7 +43,7 @@ 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
);
hand
=
new
HandZone
(
this
,
_local
||
(
_parent
->
getSpectator
()
&&
_parent
->
getSpectatorsSeeEverything
()),
(
int
)
table
->
boundingRect
().
height
(),
this
);
base
=
QPointF
(
deck
->
boundingRect
().
width
()
+
counterAreaWidth
+
5
,
0
);
base
=
QPointF
(
deck
->
boundingRect
().
width
()
+
counterAreaWidth
+
5
,
0
);
hand
->
setPos
(
base
);
hand
->
setPos
(
base
);
...
...
cockatrice/src/tab_game.cpp
View file @
befafa28
...
@@ -19,8 +19,8 @@
...
@@ -19,8 +19,8 @@
#include
"arrowitem.h"
#include
"arrowitem.h"
#include
"main.h"
#include
"main.h"
TabGame
::
TabGame
(
Client
*
_client
,
int
_gameId
,
const
QString
&
_gameDescription
,
int
_localPlayerId
,
bool
_spectator
,
bool
_resuming
)
TabGame
::
TabGame
(
Client
*
_client
,
int
_gameId
,
const
QString
&
_gameDescription
,
int
_localPlayerId
,
bool
_spectator
,
bool
_spectatorsCanTalk
,
bool
_spectatorsSeeEverything
,
bool
_resuming
)
:
Tab
(),
client
(
_client
),
gameId
(
_gameId
),
gameDescription
(
_gameDescription
),
localPlayerId
(
_localPlayerId
),
spectator
(
_spectator
),
started
(
false
),
resuming
(
_resuming
),
currentPhase
(
-
1
)
:
Tab
(),
client
(
_client
),
gameId
(
_gameId
),
gameDescription
(
_gameDescription
),
localPlayerId
(
_localPlayerId
),
spectator
(
_spectator
),
spectatorsCanTalk
(
_spectatorsCanTalk
),
spectatorsSeeEverything
(
_spectatorsSeeEverything
),
started
(
false
),
resuming
(
_resuming
),
currentPhase
(
-
1
)
{
{
scene
=
new
GameScene
(
this
);
scene
=
new
GameScene
(
this
);
gameView
=
new
GameView
(
scene
);
gameView
=
new
GameView
(
scene
);
...
@@ -74,8 +74,10 @@ TabGame::TabGame(Client *_client, int _gameId, const QString &_gameDescription,
...
@@ -74,8 +74,10 @@ TabGame::TabGame(Client *_client, int _gameId, const QString &_gameDescription,
mainLayout
->
addLayout
(
verticalLayout
);
mainLayout
->
addLayout
(
verticalLayout
);
if
(
spectator
)
{
if
(
spectator
)
{
sayLabel
->
hide
();
if
(
!
spectatorsCanTalk
)
{
sayEdit
->
hide
();
sayLabel
->
hide
();
sayEdit
->
hide
();
}
loadLocalButton
->
hide
();
loadLocalButton
->
hide
();
loadRemoteButton
->
hide
();
loadRemoteButton
->
hide
();
readyStartButton
->
hide
();
readyStartButton
->
hide
();
...
@@ -226,7 +228,15 @@ void TabGame::processGameEventContainer(GameEventContainer *cont)
...
@@ -226,7 +228,15 @@ void TabGame::processGameEventContainer(GameEventContainer *cont)
for
(
int
i
=
0
;
i
<
eventList
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
eventList
.
size
();
++
i
)
{
GameEvent
*
event
=
eventList
[
i
];
GameEvent
*
event
=
eventList
[
i
];
switch
(
event
->
getItemId
())
{
if
(
spectators
.
contains
(
event
->
getPlayerId
()))
{
switch
(
event
->
getItemId
())
{
case
ItemId_Event_Say
:
eventSpectatorSay
(
qobject_cast
<
Event_Say
*>
(
event
),
context
);
break
;
default:
{
qDebug
()
<<
"unhandled spectator game event"
;
break
;
}
}
}
else
switch
(
event
->
getItemId
())
{
case
ItemId_Event_GameStateChanged
:
eventGameStateChanged
(
qobject_cast
<
Event_GameStateChanged
*>
(
event
),
context
);
break
;
case
ItemId_Event_GameStateChanged
:
eventGameStateChanged
(
qobject_cast
<
Event_GameStateChanged
*>
(
event
),
context
);
break
;
case
ItemId_Event_PlayerPropertiesChanged
:
eventPlayerPropertiesChanged
(
qobject_cast
<
Event_PlayerPropertiesChanged
*>
(
event
),
context
);
break
;
case
ItemId_Event_PlayerPropertiesChanged
:
eventPlayerPropertiesChanged
(
qobject_cast
<
Event_PlayerPropertiesChanged
*>
(
event
),
context
);
break
;
case
ItemId_Event_Join
:
eventJoin
(
qobject_cast
<
Event_Join
*>
(
event
),
context
);
break
;
case
ItemId_Event_Join
:
eventJoin
(
qobject_cast
<
Event_Join
*>
(
event
),
context
);
break
;
...
@@ -289,6 +299,11 @@ void TabGame::stopGame()
...
@@ -289,6 +299,11 @@ void TabGame::stopGame()
deckViewContainer
->
show
();
deckViewContainer
->
show
();
}
}
void
TabGame
::
eventSpectatorSay
(
Event_Say
*
event
,
GameEventContext
*
/*context*/
)
{
messageLog
->
logSpectatorSay
(
spectators
.
value
(
event
->
getPlayerId
()),
event
->
getMessage
());
}
void
TabGame
::
eventGameStateChanged
(
Event_GameStateChanged
*
event
,
GameEventContext
*
/*context*/
)
void
TabGame
::
eventGameStateChanged
(
Event_GameStateChanged
*
event
,
GameEventContext
*
/*context*/
)
{
{
const
QList
<
ServerInfo_Player
*>
&
plList
=
event
->
getPlayerList
();
const
QList
<
ServerInfo_Player
*>
&
plList
=
event
->
getPlayerList
();
...
...
cockatrice/src/tab_game.h
View file @
befafa28
...
@@ -33,6 +33,7 @@ class Event_GameStart;
...
@@ -33,6 +33,7 @@ class Event_GameStart;
class
Event_SetActivePlayer
;
class
Event_SetActivePlayer
;
class
Event_SetActivePhase
;
class
Event_SetActivePhase
;
class
Event_Ping
;
class
Event_Ping
;
class
Event_Say
;
class
Player
;
class
Player
;
class
CardZone
;
class
CardZone
;
class
AbstractCardItem
;
class
AbstractCardItem
;
...
@@ -46,6 +47,7 @@ private:
...
@@ -46,6 +47,7 @@ private:
QString
gameDescription
;
QString
gameDescription
;
int
localPlayerId
;
int
localPlayerId
;
bool
spectator
;
bool
spectator
;
bool
spectatorsCanTalk
,
spectatorsSeeEverything
;
QMap
<
int
,
Player
*>
players
;
QMap
<
int
,
Player
*>
players
;
QMap
<
int
,
QString
>
spectators
;
QMap
<
int
,
QString
>
spectators
;
bool
started
;
bool
started
;
...
@@ -73,6 +75,7 @@ private:
...
@@ -73,6 +75,7 @@ private:
void
startGame
();
void
startGame
();
void
stopGame
();
void
stopGame
();
void
eventSpectatorSay
(
Event_Say
*
event
,
GameEventContext
*
context
);
void
eventGameStateChanged
(
Event_GameStateChanged
*
event
,
GameEventContext
*
context
);
void
eventGameStateChanged
(
Event_GameStateChanged
*
event
,
GameEventContext
*
context
);
void
eventPlayerPropertiesChanged
(
Event_PlayerPropertiesChanged
*
event
,
GameEventContext
*
context
);
void
eventPlayerPropertiesChanged
(
Event_PlayerPropertiesChanged
*
event
,
GameEventContext
*
context
);
void
eventJoin
(
Event_Join
*
event
,
GameEventContext
*
context
);
void
eventJoin
(
Event_Join
*
event
,
GameEventContext
*
context
);
...
@@ -100,12 +103,15 @@ private slots:
...
@@ -100,12 +103,15 @@ private slots:
void
actNextPhase
();
void
actNextPhase
();
void
actNextTurn
();
void
actNextTurn
();
public:
public:
TabGame
(
Client
*
_client
,
int
_gameId
,
const
QString
&
_gameDescription
,
int
_localPlayerId
,
bool
_spectator
,
bool
_resuming
);
TabGame
(
Client
*
_client
,
int
_gameId
,
const
QString
&
_gameDescription
,
int
_localPlayerId
,
bool
_spectator
,
bool
_spectatorsCanTalk
,
bool
_spectatorsSeeEverything
,
bool
_resuming
);
~
TabGame
();
~
TabGame
();
void
retranslateUi
();
void
retranslateUi
();
const
QMap
<
int
,
Player
*>
&
getPlayers
()
const
{
return
players
;
}
const
QMap
<
int
,
Player
*>
&
getPlayers
()
const
{
return
players
;
}
int
getGameId
()
const
{
return
gameId
;
}
int
getGameId
()
const
{
return
gameId
;
}
QString
getTabText
()
const
{
return
tr
(
"Game %1: %2"
).
arg
(
gameId
).
arg
(
gameDescription
);
}
QString
getTabText
()
const
{
return
tr
(
"Game %1: %2"
).
arg
(
gameId
).
arg
(
gameDescription
);
}
bool
getSpectator
()
const
{
return
spectator
;
}
bool
getSpectatorsCanTalk
()
const
{
return
spectatorsCanTalk
;
}
bool
getSpectatorsSeeEverything
()
const
{
return
spectatorsSeeEverything
;
}
void
processGameEventContainer
(
GameEventContainer
*
cont
);
void
processGameEventContainer
(
GameEventContainer
*
cont
);
public
slots
:
public
slots
:
...
...
cockatrice/src/tab_server.cpp
View file @
befafa28
...
@@ -81,7 +81,7 @@ void GameSelector::actJoin()
...
@@ -81,7 +81,7 @@ void GameSelector::actJoin()
return
;
return
;
ServerInfo_Game
*
game
=
gameListModel
->
getGame
(
ind
.
data
(
Qt
::
UserRole
).
toInt
());
ServerInfo_Game
*
game
=
gameListModel
->
getGame
(
ind
.
data
(
Qt
::
UserRole
).
toInt
());
QString
password
;
QString
password
;
if
(
game
->
getHasPassword
())
{
if
(
game
->
getHasPassword
()
&&
!
(
spectator
&&
!
game
->
getSpectatorsNeedPassword
())
)
{
bool
ok
;
bool
ok
;
password
=
QInputDialog
::
getText
(
this
,
tr
(
"Join game"
),
tr
(
"Password:"
),
QLineEdit
::
Password
,
QString
(),
&
ok
);
password
=
QInputDialog
::
getText
(
this
,
tr
(
"Join game"
),
tr
(
"Password:"
),
QLineEdit
::
Password
,
QString
(),
&
ok
);
if
(
!
ok
)
if
(
!
ok
)
...
...
cockatrice/src/tab_supervisor.cpp
View file @
befafa28
...
@@ -103,7 +103,7 @@ void TabSupervisor::updatePingTime(int value, int max)
...
@@ -103,7 +103,7 @@ void TabSupervisor::updatePingTime(int value, int max)
void
TabSupervisor
::
gameJoined
(
Event_GameJoined
*
event
)
void
TabSupervisor
::
gameJoined
(
Event_GameJoined
*
event
)
{
{
TabGame
*
tab
=
new
TabGame
(
client
,
event
->
getGameId
(),
event
->
getGameDescription
(),
event
->
getPlayerId
(),
event
->
getSpectator
(),
event
->
getResuming
());
TabGame
*
tab
=
new
TabGame
(
client
,
event
->
getGameId
(),
event
->
getGameDescription
(),
event
->
getPlayerId
(),
event
->
getSpectator
(),
event
->
getSpectatorsCanTalk
(),
event
->
getSpectatorsSeeEverything
(),
event
->
getResuming
());
connect
(
tab
,
SIGNAL
(
gameClosing
(
TabGame
*
)),
this
,
SLOT
(
gameLeft
(
TabGame
*
)));
connect
(
tab
,
SIGNAL
(
gameClosing
(
TabGame
*
)),
this
,
SLOT
(
gameLeft
(
TabGame
*
)));
myAddTab
(
tab
);
myAddTab
(
tab
);
gameTabs
.
insert
(
event
->
getGameId
(),
tab
);
gameTabs
.
insert
(
event
->
getGameId
(),
tab
);
...
...
cockatrice/translations/cockatrice_de.ts
View file @
befafa28
This diff is collapsed.
Click to expand it.
cockatrice/translations/cockatrice_en.ts
View file @
befafa28
This diff is collapsed.
Click to expand it.
common/protocol.cpp
View file @
befafa28
...
@@ -104,7 +104,7 @@ void Command::processResponse(ProtocolResponse *response)
...
@@ -104,7 +104,7 @@ void Command::processResponse(ProtocolResponse *response)
}
}
CommandContainer
::
CommandContainer
(
const
QList
<
Command
*>
&
_commandList
,
int
_cmdId
)
CommandContainer
::
CommandContainer
(
const
QList
<
Command
*>
&
_commandList
,
int
_cmdId
)
:
ProtocolItem
(
"container"
,
"cmd"
),
ticks
(
0
),
resp
(
0
),
gameEventQueuePublic
(
0
),
gameEventQueuePrivate
(
0
)
:
ProtocolItem
(
"container"
,
"cmd"
),
ticks
(
0
),
resp
(
0
),
gameEventQueuePublic
(
0
),
gameEventQueueOmniscient
(
0
),
gameEventQueuePrivate
(
0
)
{
{
if
(
_cmdId
==
-
1
)
if
(
_cmdId
==
-
1
)
_cmdId
=
lastCmdId
++
;
_cmdId
=
lastCmdId
++
;
...
@@ -137,6 +137,13 @@ void CommandContainer::enqueueGameEventPublic(GameEvent *event, int gameId)
...
@@ -137,6 +137,13 @@ void CommandContainer::enqueueGameEventPublic(GameEvent *event, int gameId)
gameEventQueuePublic
->
appendItem
(
event
);
gameEventQueuePublic
->
appendItem
(
event
);
}
}
void
CommandContainer
::
enqueueGameEventOmniscient
(
GameEvent
*
event
,
int
gameId
)
{
if
(
!
gameEventQueueOmniscient
)
gameEventQueueOmniscient
=
new
GameEventContainer
(
QList
<
GameEvent
*>
(),
gameId
);
gameEventQueueOmniscient
->
appendItem
(
event
);
}
void
CommandContainer
::
enqueueGameEventPrivate
(
GameEvent
*
event
,
int
gameId
)
void
CommandContainer
::
enqueueGameEventPrivate
(
GameEvent
*
event
,
int
gameId
)
{
{
if
(
!
gameEventQueuePrivate
)
if
(
!
gameEventQueuePrivate
)
...
...
common/protocol.h
View file @
befafa28
...
@@ -103,6 +103,7 @@ private:
...
@@ -103,6 +103,7 @@ private:
ProtocolResponse
*
resp
;
ProtocolResponse
*
resp
;
QList
<
ProtocolItem
*>
itemQueue
;
QList
<
ProtocolItem
*>
itemQueue
;
GameEventContainer
*
gameEventQueuePublic
;
GameEventContainer
*
gameEventQueuePublic
;
GameEventContainer
*
gameEventQueueOmniscient
;
GameEventContainer
*
gameEventQueuePrivate
;
GameEventContainer
*
gameEventQueuePrivate
;
public:
public:
CommandContainer
(
const
QList
<
Command
*>
&
_commandList
=
QList
<
Command
*>
(),
int
_cmdId
=
-
1
);
CommandContainer
(
const
QList
<
Command
*>
&
_commandList
=
QList
<
Command
*>
(),
int
_cmdId
=
-
1
);
...
@@ -119,6 +120,8 @@ public:
...
@@ -119,6 +120,8 @@ public:
void
enqueueItem
(
ProtocolItem
*
item
)
{
itemQueue
.
append
(
item
);
}
void
enqueueItem
(
ProtocolItem
*
item
)
{
itemQueue
.
append
(
item
);
}
GameEventContainer
*
getGameEventQueuePublic
()
const
{
return
gameEventQueuePublic
;
}
GameEventContainer
*
getGameEventQueuePublic
()
const
{
return
gameEventQueuePublic
;
}
void
enqueueGameEventPublic
(
GameEvent
*
event
,
int
gameId
);
void
enqueueGameEventPublic
(
GameEvent
*
event
,
int
gameId
);
GameEventContainer
*
getGameEventQueueOmniscient
()
const
{
return
gameEventQueueOmniscient
;
}
void
enqueueGameEventOmniscient
(
GameEvent
*
event
,
int
gameId
);
GameEventContainer
*
getGameEventQueuePrivate
()
const
{
return
gameEventQueuePrivate
;
}
GameEventContainer
*
getGameEventQueuePrivate
()
const
{
return
gameEventQueuePrivate
;
}
void
enqueueGameEventPrivate
(
GameEvent
*
event
,
int
gameId
);
void
enqueueGameEventPrivate
(
GameEvent
*
event
,
int
gameId
);
};
};
...
...
common/protocol_datastructures.cpp
View file @
befafa28
...
@@ -18,7 +18,7 @@ ServerInfo_ChatUser::ServerInfo_ChatUser(const QString &_name)
...
@@ -18,7 +18,7 @@ ServerInfo_ChatUser::ServerInfo_ChatUser(const QString &_name)
insertItem
(
new
SerializableItem_String
(
"name"
,
_name
));
insertItem
(
new
SerializableItem_String
(
"name"
,
_name
));
}
}
ServerInfo_Game
::
ServerInfo_Game
(
int
_gameId
,
const
QString
&
_description
,
bool
_hasPassword
,
int
_playerCount
,
int
_maxPlayers
,
const
QString
&
_creatorName
,
bool
_spectatorsAllowed
,
int
_spectatorCount
)
ServerInfo_Game
::
ServerInfo_Game
(
int
_gameId
,
const
QString
&
_description
,
bool
_hasPassword
,
int
_playerCount
,
int
_maxPlayers
,
const
QString
&
_creatorName
,
bool
_spectatorsAllowed
,
bool
_spectatorsNeedPassword
,
int
_spectatorCount
)
:
SerializableItem_Map
(
"game"
)
:
SerializableItem_Map
(
"game"
)
{
{
insertItem
(
new
SerializableItem_Int
(
"game_id"
,
_gameId
));
insertItem
(
new
SerializableItem_Int
(
"game_id"
,
_gameId
));
...
@@ -28,6 +28,7 @@ ServerInfo_Game::ServerInfo_Game(int _gameId, const QString &_description, bool
...
@@ -28,6 +28,7 @@ ServerInfo_Game::ServerInfo_Game(int _gameId, const QString &_description, bool
insertItem
(
new
SerializableItem_Int
(
"max_players"
,
_maxPlayers
));
insertItem
(
new
SerializableItem_Int
(
"max_players"
,
_maxPlayers
));
insertItem
(
new
SerializableItem_String
(
"creator_name"
,
_creatorName
));
insertItem
(
new
SerializableItem_String
(
"creator_name"
,
_creatorName
));
insertItem
(
new
SerializableItem_Bool
(
"spectators_allowed"
,
_spectatorsAllowed
));
insertItem
(
new
SerializableItem_Bool
(
"spectators_allowed"
,
_spectatorsAllowed
));
insertItem
(
new
SerializableItem_Bool
(
"spectators_need_password"
,
_spectatorsNeedPassword
));
insertItem
(
new
SerializableItem_Int
(
"spectator_count"
,
_spectatorCount
));
insertItem
(
new
SerializableItem_Int
(
"spectator_count"
,
_spectatorCount
));
}
}
...
...
common/protocol_datastructures.h
View file @
befafa28
...
@@ -39,7 +39,7 @@ public:
...
@@ -39,7 +39,7 @@ public:
class
ServerInfo_Game
:
public
SerializableItem_Map
{
class
ServerInfo_Game
:
public
SerializableItem_Map
{
public:
public:
ServerInfo_Game
(
int
_gameId
=
-
1
,
const
QString
&
_description
=
QString
(),
bool
_hasPassword
=
false
,
int
_playerCount
=
-
1
,
int
_maxPlayers
=
-
1
,
const
QString
&
_creatorName
=
QString
(),
bool
_spectatorsAllowed
=
false
,
int
_spectatorCount
=
-
1
);
ServerInfo_Game
(
int
_gameId
=
-
1
,
const
QString
&
_description
=
QString
(),
bool
_hasPassword
=
false
,
int
_playerCount
=
-
1
,
int
_maxPlayers
=
-
1
,
const
QString
&
_creatorName
=
QString
(),
bool
_spectatorsAllowed
=
false
,
bool
_spectatorsNeedPassword
=
false
,
int
_spectatorCount
=
-
1
);
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_Game
;
}
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_Game
;
}
int
getGameId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"game_id"
))
->
getData
();
}
int
getGameId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"game_id"
))
->
getData
();
}
QString
getDescription
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"description"
))
->
getData
();
}
QString
getDescription
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"description"
))
->
getData
();
}
...
@@ -48,6 +48,7 @@ public:
...
@@ -48,6 +48,7 @@ public:
int
getMaxPlayers
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"max_players"
))
->
getData
();
}
int
getMaxPlayers
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"max_players"
))
->
getData
();
}
QString
getCreatorName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"creator_name"
))
->
getData
();
}
QString
getCreatorName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"creator_name"
))
->
getData
();
}
bool
getSpectatorsAllowed
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"spectators_allowed"
))
->
getData
();
}
bool
getSpectatorsAllowed
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"spectators_allowed"
))
->
getData
();
}
bool
getSpectatorsNeedPassword
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"spectators_need_password"
))
->
getData
();
}
int
getSpectatorCount
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"spectator_count"
))
->
getData
();
}
int
getSpectatorCount
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"spectator_count"
))
->
getData
();
}
};
};
...
...
common/protocol_items.cpp
View file @
befafa28
...
@@ -58,13 +58,16 @@ Command_ListGames::Command_ListGames()
...
@@ -58,13 +58,16 @@ Command_ListGames::Command_ListGames()
:
Command
(
"list_games"
)
:
Command
(
"list_games"
)
{
{
}
}
Command_CreateGame
::
Command_CreateGame
(
const
QString
&
_description
,
const
QString
&
_password
,
int
_maxPlayers
,
bool
_spectatorsAllowed
)
Command_CreateGame
::
Command_CreateGame
(
const
QString
&
_description
,
const
QString
&
_password
,
int
_maxPlayers
,
bool
_spectatorsAllowed
,
bool
_spectatorsNeedPassword
,
bool
_spectatorsCanTalk
,
bool
_spectatorsSeeEverything
)
:
Command
(
"create_game"
)
:
Command
(
"create_game"
)
{
{
insertItem
(
new
SerializableItem_String
(
"description"
,
_description
));
insertItem
(
new
SerializableItem_String
(
"description"
,
_description
));
insertItem
(
new
SerializableItem_String
(
"password"
,
_password
));
insertItem
(
new
SerializableItem_String
(
"password"
,
_password
));
insertItem
(
new
SerializableItem_Int
(
"max_players"
,
_maxPlayers
));
insertItem
(
new
SerializableItem_Int
(
"max_players"
,
_maxPlayers
));
insertItem
(
new
SerializableItem_Bool
(
"spectators_allowed"
,
_spectatorsAllowed
));
insertItem
(
new
SerializableItem_Bool
(
"spectators_allowed"
,
_spectatorsAllowed
));
insertItem
(
new
SerializableItem_Bool
(
"spectators_need_password"
,
_spectatorsNeedPassword
));
insertItem
(
new
SerializableItem_Bool
(
"spectators_can_talk"
,
_spectatorsCanTalk
));
insertItem
(
new
SerializableItem_Bool
(
"spectators_see_everything"
,
_spectatorsSeeEverything
));
}
}
Command_JoinGame
::
Command_JoinGame
(
int
_gameId
,
const
QString
&
_password
,
bool
_spectator
)
Command_JoinGame
::
Command_JoinGame
(
int
_gameId
,
const
QString
&
_password
,
bool
_spectator
)
:
Command
(
"join_game"
)
:
Command
(
"join_game"
)
...
@@ -297,13 +300,15 @@ Event_ServerMessage::Event_ServerMessage(const QString &_message)
...
@@ -297,13 +300,15 @@ Event_ServerMessage::Event_ServerMessage(const QString &_message)
{
{
insertItem
(
new
SerializableItem_String
(
"message"
,
_message
));
insertItem
(
new
SerializableItem_String
(
"message"
,
_message
));
}
}
Event_GameJoined
::
Event_GameJoined
(
int
_gameId
,
const
QString
&
_gameDescription
,
int
_playerId
,
bool
_spectator
,
bool
_resuming
)
Event_GameJoined
::
Event_GameJoined
(
int
_gameId
,
const
QString
&
_gameDescription
,
int
_playerId
,
bool
_spectator
,
bool
_spectatorsCanTalk
,
bool
_spectatorsSeeEverything
,
bool
_resuming
)
:
GenericEvent
(
"game_joined"
)
:
GenericEvent
(
"game_joined"
)
{
{
insertItem
(
new
SerializableItem_Int
(
"game_id"
,
_gameId
));
insertItem
(
new
SerializableItem_Int
(
"game_id"
,
_gameId
));
insertItem
(
new
SerializableItem_String
(
"game_description"
,
_gameDescription
));
insertItem
(
new
SerializableItem_String
(
"game_description"
,
_gameDescription
));
insertItem
(
new
SerializableItem_Int
(
"player_id"
,
_playerId
));
insertItem
(
new
SerializableItem_Int
(
"player_id"
,
_playerId
));
insertItem
(
new
SerializableItem_Bool
(
"spectator"
,
_spectator
));
insertItem
(
new
SerializableItem_Bool
(
"spectator"
,
_spectator
));
insertItem
(
new
SerializableItem_Bool
(
"spectators_can_talk"
,
_spectatorsCanTalk
));
insertItem
(
new
SerializableItem_Bool
(
"spectators_see_everything"
,
_spectatorsSeeEverything
));
insertItem
(
new
SerializableItem_Bool
(
"resuming"
,
_resuming
));
insertItem
(
new
SerializableItem_Bool
(
"resuming"
,
_resuming
));
}
}
Event_ChatJoinChannel
::
Event_ChatJoinChannel
(
const
QString
&
_channel
,
const
QString
&
_playerName
)
Event_ChatJoinChannel
::
Event_ChatJoinChannel
(
const
QString
&
_channel
,
const
QString
&
_playerName
)
...
...
common/protocol_items.dat
View file @
befafa28
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
1:chat_leave_channel
1:chat_leave_channel
1:chat_say:s,message
1:chat_say:s,message
0:list_games
0:list_games
0:create_game:s,description:s,password:i,max_players:b,spectators_allowed
0:create_game:s,description:s,password:i,max_players:b,spectators_allowed
:b,spectators_need_password:b,spectators_can_talk:b,spectators_see_everything
0:join_game:i,game_id:s,password:b,spectator
0:join_game:i,game_id:s,password:b,spectator
2:leave_game
2:leave_game
2:say:s,message
2:say:s,message
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
3:dump_zone:i,zone_owner_id:s,zone:i,number_cards
3:dump_zone:i,zone_owner_id:s,zone:i,number_cards
3:stop_dump_zone:i,zone_owner_id:s,zone
3:stop_dump_zone:i,zone_owner_id:s,zone
4:server_message:s,message
4:server_message:s,message
4:game_joined:i,game_id:s,game_description:i,player_id:b,spectator:b,resuming
4:game_joined:i,game_id:s,game_description:i,player_id:b,spectator:b,
spectators_can_talk:b,spectators_see_everything:b,
resuming
5:chat_join_channel:s,player_name
5:chat_join_channel:s,player_name
5:chat_leave_channel:s,player_name
5:chat_leave_channel:s,player_name
5:chat_say:s,player_name:s,message
5:chat_say:s,player_name:s,message
...
...
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