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
f115342e
Commit
f115342e
authored
Dec 18, 2011
by
Max-Wilhelm Bruker
Browse files
local mode is working again
parent
38e47816
Changes
24
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/abstractclient.cpp
View file @
f115342e
...
...
@@ -98,6 +98,15 @@ PendingCommand *AbstractClient::prepareSessionCommand(const ::google::protobuf::
return
new
PendingCommand
(
cont
);
}
PendingCommand
*
AbstractClient
::
prepareRoomCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
,
int
roomId
)
{
CommandContainer
cont
;
RoomCommand
*
c
=
cont
.
add_room_command
();
cont
.
set_room_id
(
roomId
);
c
->
GetReflection
()
->
MutableMessage
(
c
,
cmd
.
GetDescriptor
()
->
FindExtensionByName
(
"ext"
))
->
CopyFrom
(
cmd
);
return
new
PendingCommand
(
cont
);
}
PendingCommand
*
AbstractClient
::
prepareModeratorCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
)
{
CommandContainer
cont
;
...
...
cockatrice/src/abstractclient.h
View file @
f115342e
...
...
@@ -77,6 +77,7 @@ public:
void
sendCommand
(
PendingCommand
*
pend
);
PendingCommand
*
prepareSessionCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
);
PendingCommand
*
prepareRoomCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
,
int
roomId
);
PendingCommand
*
prepareModeratorCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
);
PendingCommand
*
prepareAdminCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
);
};
...
...
cockatrice/src/gameselector.cpp
View file @
f115342e
...
...
@@ -37,9 +37,10 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso
filterLayout
->
addWidget
(
showFullGamesCheckBox
);
filterLayout
->
addWidget
(
showRunningGamesCheckBox
);
if
(
room
)
if
(
room
)
{
createButton
=
new
QPushButton
;
else
connect
(
createButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actCreate
()));
}
else
createButton
=
0
;
joinButton
=
new
QPushButton
;
spectateButton
=
new
QPushButton
;
...
...
@@ -68,7 +69,6 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso
connect
(
showFullGamesCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
showFullGamesChanged
(
int
)));
connect
(
showRunningGamesCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
showRunningGamesChanged
(
int
)));
connect
(
createButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actCreate
()));
connect
(
joinButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actJoin
()));
connect
(
spectateButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actJoin
()));
}
...
...
@@ -132,9 +132,15 @@ void GameSelector::actJoin()
cmd
.
set_spectator
(
spectator
);
cmd
.
set_override_restrictions
(
overrideRestrictions
);
PendingCommand
*
pend
=
room
->
prepareRoomCommand
(
cmd
);
TabRoom
*
r
=
tabSupervisor
->
getRoomTabs
().
value
(
game
->
getRoomId
());
if
(
!
r
)
{
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"Please join the respective room first."
));
return
;
}
PendingCommand
*
pend
=
r
->
prepareRoomCommand
(
cmd
);
connect
(
pend
,
SIGNAL
(
finished
(
ResponseCode
)),
this
,
SLOT
(
checkResponse
(
ResponseCode
)));
r
oom
->
sendRoomCommand
(
pend
);
r
->
sendRoomCommand
(
pend
);
if
(
createButton
)
createButton
->
setEnabled
(
false
);
...
...
cockatrice/src/localclient.cpp
View file @
f115342e
...
...
@@ -24,9 +24,7 @@ LocalClient::~LocalClient()
void
LocalClient
::
sendCommandContainer
(
const
CommandContainer
&
cont
)
{
// cont->setReceiverMayDelete(false);
// pendingCommands.insert(cont->getCmdId(), cont);
// lsi->itemFromClient(cont);
lsi
->
itemFromClient
(
cont
);
}
void
LocalClient
::
itemFromServer
(
ProtocolItem
*
item
)
...
...
cockatrice/src/localserverinterface.cpp
View file @
f115342e
...
...
@@ -19,8 +19,9 @@ void LocalServerInterface::sendProtocolItem(ProtocolItem *item, bool deleteItem)
if
(
deleteItem
)
delete
item
;
}
void
LocalServerInterface
::
itemFromClient
(
ProtocolItem
*
item
)
#include
"pb/commands.pb.h"
void
LocalServerInterface
::
itemFromClient
(
const
CommandContainer
&
item
)
{
//processCommandContainer(static_cast<CommandContainer *>(item));
qDebug
()
<<
"READ"
<<
QString
::
fromStdString
(
item
.
ShortDebugString
());
processCommandContainer
(
item
);
}
cockatrice/src/localserverinterface.h
View file @
f115342e
...
...
@@ -10,17 +10,17 @@ class LocalServerInterface : public Server_ProtocolHandler
Q_OBJECT
private:
DeckList
*
getDeckFromDatabase
(
int
/*deckId*/
)
{
return
0
;
}
ResponseCode
cmdAddToList
(
const
Command_AddToList
&
/*cmd*/
,
Command
Container
*
/*
cont
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdRemoveFromList
(
const
Command_RemoveFromList
&
/*cmd*/
,
Command
Container
*
/*
cont
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckList
(
const
Command_DeckList
&
/*cmd*/
,
Command
Container
*
/*
cont
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckNewDir
(
const
Command_DeckNewDir
&
/*cmd*/
,
Command
Container
*
/*
cont
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckDelDir
(
const
Command_DeckDelDir
&
/*cmd*/
,
Command
Container
*
/*
cont
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckDel
(
const
Command_DeckDel
&
/*cmd*/
,
Command
Container
*
/*
cont
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckUpload
(
const
Command_DeckUpload
&
/*cmd*/
,
Command
Container
*
/*
cont
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckDownload
(
const
Command_DeckDownload
&
/*cmd*/
,
Command
Container
*
/*
cont
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdBanFromServer
(
const
Command_BanFromServer
&
/*cmd*/
,
Command
Container
*
/*
cont
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdShutdownServer
(
const
Command_ShutdownServer
&
/*cmd*/
,
Command
Container
*
/*
cont
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdUpdateServerMessage
(
const
Command_UpdateServerMessage
&
/*cmd*/
,
Command
Container
*
/*
cont
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdAddToList
(
const
Command_AddToList
&
/*cmd*/
,
Bla
Container
*
/*
bla
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdRemoveFromList
(
const
Command_RemoveFromList
&
/*cmd*/
,
Bla
Container
*
/*
bla
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckList
(
const
Command_DeckList
&
/*cmd*/
,
Bla
Container
*
/*
bla
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckNewDir
(
const
Command_DeckNewDir
&
/*cmd*/
,
Bla
Container
*
/*
bla
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckDelDir
(
const
Command_DeckDelDir
&
/*cmd*/
,
Bla
Container
*
/*
bla
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckDel
(
const
Command_DeckDel
&
/*cmd*/
,
Bla
Container
*
/*
bla
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckUpload
(
const
Command_DeckUpload
&
/*cmd*/
,
Bla
Container
*
/*
bla
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdDeckDownload
(
const
Command_DeckDownload
&
/*cmd*/
,
Bla
Container
*
/*
bla
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdBanFromServer
(
const
Command_BanFromServer
&
/*cmd*/
,
Bla
Container
*
/*
bla
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdShutdownServer
(
const
Command_ShutdownServer
&
/*cmd*/
,
Bla
Container
*
/*
bla
*/
)
{
return
RespFunctionNotAllowed
;
}
ResponseCode
cmdUpdateServerMessage
(
const
Command_UpdateServerMessage
&
/*cmd*/
,
Bla
Container
*
/*
bla
*/
)
{
return
RespFunctionNotAllowed
;
}
protected:
bool
getCompressionSupport
()
const
{
return
false
;
}
public:
...
...
@@ -32,7 +32,7 @@ public:
signals:
void
itemToClient
(
ProtocolItem
*
item
);
public
slots
:
void
itemFromClient
(
ProtocolItem
*
item
);
void
itemFromClient
(
const
CommandContainer
&
item
);
};
#endif
\ No newline at end of file
cockatrice/src/phasestoolbar.cpp
View file @
f115342e
...
...
@@ -105,22 +105,16 @@ PhasesToolbar::PhasesToolbar(QGraphicsItem *parent)
connect
(
aDrawCard
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actDrawCard
()));
PhaseButton
*
untapButton
=
new
PhaseButton
(
"untap"
,
this
,
aUntapAll
);
// untapButton->setShortcut(QKeySequence("F5"));
PhaseButton
*
upkeepButton
=
new
PhaseButton
(
"upkeep"
,
this
);
PhaseButton
*
drawButton
=
new
PhaseButton
(
"draw"
,
this
,
aDrawCard
);
// drawButton->setShortcut(QKeySequence("F6"));
PhaseButton
*
main1Button
=
new
PhaseButton
(
"main1"
,
this
);
// main1Button->setShortcut(QKeySequence("F7"));
PhaseButton
*
combatStartButton
=
new
PhaseButton
(
"combat_start"
,
this
);
// combatStartButton->setShortcut(QKeySequence("F8"));
PhaseButton
*
combatAttackersButton
=
new
PhaseButton
(
"combat_attackers"
,
this
);
PhaseButton
*
combatBlockersButton
=
new
PhaseButton
(
"combat_blockers"
,
this
);
PhaseButton
*
combatDamageButton
=
new
PhaseButton
(
"combat_damage"
,
this
);
PhaseButton
*
combatEndButton
=
new
PhaseButton
(
"combat_end"
,
this
);
PhaseButton
*
main2Button
=
new
PhaseButton
(
"main2"
,
this
);
// main2Button->setShortcut(QKeySequence("F9"));
PhaseButton
*
cleanupButton
=
new
PhaseButton
(
"cleanup"
,
this
);
// cleanupButton->setShortcut(QKeySequence("F10"));
buttonList
<<
untapButton
<<
upkeepButton
<<
drawButton
<<
main1Button
<<
combatStartButton
<<
combatAttackersButton
<<
combatBlockersButton
<<
combatDamageButton
<<
combatEndButton
...
...
cockatrice/src/player.cpp
View file @
f115342e
...
...
@@ -1420,11 +1420,6 @@ void Player::sendGameCommand(const google::protobuf::Message &command)
static_cast
<
TabGame
*>
(
parent
())
->
sendGameCommand
(
command
,
id
);
}
void
Player
::
sendCommandContainer
(
CommandContainer
&
cont
)
{
static_cast
<
TabGame
*>
(
parent
())
->
sendCommandContainer
(
cont
,
id
);
}
void
Player
::
sendGameCommand
(
PendingCommand
*
pend
)
{
static_cast
<
TabGame
*>
(
parent
())
->
sendGameCommand
(
pend
,
id
);
...
...
cockatrice/src/player.h
View file @
f115342e
...
...
@@ -261,7 +261,6 @@ public:
PendingCommand
*
prepareGameCommand
(
const
QList
<
const
::
google
::
protobuf
::
Message
*
>
&
cmdList
);
void
sendGameCommand
(
PendingCommand
*
pend
);
void
sendGameCommand
(
const
google
::
protobuf
::
Message
&
command
);
void
sendCommandContainer
(
CommandContainer
&
cont
);
};
#endif
cockatrice/src/tab_deck_storage.cpp
View file @
f115342e
...
...
@@ -143,17 +143,17 @@ void TabDeckStorage::actUpload()
QString
filePath
=
localDirModel
->
filePath
(
curLeft
);
QFile
deckFile
(
filePath
);
QFileInfo
deckFileInfo
(
deckFile
);
DeckList
*
deck
=
new
DeckList
;
if
(
!
deck
->
loadFromFile
(
filePath
,
DeckList
::
CockatriceFormat
))
DeckList
deck
;
if
(
!
deck
.
loadFromFile
(
filePath
,
DeckList
::
CockatriceFormat
))
return
;
if
(
deck
->
getName
().
isEmpty
())
{
if
(
deck
.
getName
().
isEmpty
())
{
bool
ok
;
QString
deckName
=
QInputDialog
::
getText
(
this
,
tr
(
"Enter deck name"
),
tr
(
"This decklist does not have a name.
\n
Please enter a name:"
),
QLineEdit
::
Normal
,
deckFileInfo
.
completeBaseName
(),
&
ok
);
if
(
!
ok
)
return
;
if
(
deckName
.
isEmpty
())
deckName
=
tr
(
"Unnamed deck"
);
deck
->
setName
(
deckName
);
deck
.
setName
(
deckName
);
}
QString
targetPath
;
...
...
@@ -163,10 +163,14 @@ void TabDeckStorage::actUpload()
if
(
!
dynamic_cast
<
RemoteDeckList_TreeModel
::
DirectoryNode
*>
(
curRight
))
curRight
=
curRight
->
getParent
();
targetPath
=
dynamic_cast
<
RemoteDeckList_TreeModel
::
DirectoryNode
*>
(
curRight
)
->
getPath
();
// Command_DeckUpload *command = new Command_DeckUpload(deck, targetPath);
// connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(uploadFinished(ProtocolResponse *)));
// client->sendCommand(command);
Command_DeckUpload
cmd
;
cmd
.
set_path
(
targetPath
.
toStdString
());
cmd
.
set_deck_list
(
deck
.
writeToString_Native
().
toStdString
());
PendingCommand
*
pend
=
client
->
prepareSessionCommand
(
cmd
);
connect
(
pend
,
SIGNAL
(
finished
(
ProtocolResponse
*
)),
this
,
SLOT
(
uploadFinished
(
ProtocolResponse
*
)));
client
->
sendCommand
(
pend
);
}
void
TabDeckStorage
::
uploadFinished
(
ProtocolResponse
*
r
)
...
...
@@ -174,9 +178,9 @@ void TabDeckStorage::uploadFinished(ProtocolResponse *r)
Response_DeckUpload
*
resp
=
qobject_cast
<
Response_DeckUpload
*>
(
r
);
if
(
!
resp
)
return
;
//
Command_DeckUpload
*
cmd = static_cast<Command_DeckUpload
*>(sender(
));
//
//
serverDirView->addFileToTree(resp->getFile(), serverDirView->getNodeByPath(
cmd->getP
ath()));
const
Command_DeckUpload
&
cmd
=
static_cast
<
const
Command_DeckUpload
&>
(
static_cast
<
PendingCommand
*>
(
sender
())
->
getCommandContainer
().
session_command
(
0
).
GetExtension
(
Command_DeckUpload
::
ext
));
serverDirView
->
addFileToTree
(
resp
->
getFile
(),
serverDirView
->
getNodeByPath
(
QString
::
fromStdString
(
cmd
.
p
ath
()))
)
;
}
void
TabDeckStorage
::
actOpenRemoteDeck
()
...
...
@@ -184,10 +188,13 @@ void TabDeckStorage::actOpenRemoteDeck()
RemoteDeckList_TreeModel
::
FileNode
*
curRight
=
dynamic_cast
<
RemoteDeckList_TreeModel
::
FileNode
*>
(
serverDirView
->
getCurrentItem
());
if
(
!
curRight
)
return
;
// Command_DeckDownload *command = new Command_DeckDownload(curRight->getId());
// connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(openRemoteDeckFinished(ProtocolResponse *)));
// client->sendCommand(command);
Command_DeckDownload
cmd
;
cmd
.
set_deck_id
(
curRight
->
getId
());
PendingCommand
*
pend
=
client
->
prepareSessionCommand
(
cmd
);
connect
(
pend
,
SIGNAL
(
finished
(
ProtocolResponse
*
)),
this
,
SLOT
(
openRemoteDeckFinished
(
ProtocolResponse
*
)));
client
->
sendCommand
(
pend
);
}
void
TabDeckStorage
::
openRemoteDeckFinished
(
ProtocolResponse
*
r
)
...
...
@@ -217,11 +224,14 @@ void TabDeckStorage::actDownload()
if
(
!
curRight
)
return
;
filePath
+=
QString
(
"/deck_%1.cod"
).
arg
(
curRight
->
getId
());
// Command_DeckDownload *command = new Command_DeckDownload(curRight->getId());
// command->setExtraData(filePath);
// connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(downloadFinished(ProtocolResponse *)));
// client->sendCommand(command);
Command_DeckDownload
cmd
;
cmd
.
set_deck_id
(
curRight
->
getId
());
PendingCommand
*
pend
=
client
->
prepareSessionCommand
(
cmd
);
pend
->
setExtraData
(
filePath
);
connect
(
pend
,
SIGNAL
(
finished
(
ProtocolResponse
*
)),
this
,
SLOT
(
downloadFinished
(
ProtocolResponse
*
)));
client
->
sendCommand
(
pend
);
}
void
TabDeckStorage
::
downloadFinished
(
ProtocolResponse
*
r
)
...
...
@@ -229,10 +239,10 @@ void TabDeckStorage::downloadFinished(ProtocolResponse *r)
Response_DeckDownload
*
resp
=
qobject_cast
<
Response_DeckDownload
*>
(
r
);
if
(
!
resp
)
return
;
// Command_DeckDownload *cmd = static_cast<Command_DeckDownload *>(sender());
//
//
QString filePath =
cm
d->getExtraData().toString();
//
resp->getDeck()->saveToFile(filePath, DeckList::CockatriceFormat);
PendingCommand
*
pend
=
static_cast
<
PendingCommand
*>
(
sender
());
QString
filePath
=
pen
d
->
getExtraData
().
toString
();
resp
->
getDeck
()
->
saveToFile
(
filePath
,
DeckList
::
CockatriceFormat
);
}
void
TabDeckStorage
::
actNewFolder
()
...
...
@@ -263,9 +273,9 @@ void TabDeckStorage::newFolderFinished(ResponseCode resp)
{
if
(
resp
!=
RespOk
)
return
;
//
Command_DeckNewDir
*
cmd = static_cast<Command_DeckNewDir
*>(sender(
));
//
serverDirView->addFolderToTree(
cmd->getDirN
ame(), serverDirView->getNodeByPath(
cmd->getP
ath()));
const
Command_DeckNewDir
&
cmd
=
static_cast
<
const
Command_DeckNewDir
&>
(
static_cast
<
PendingCommand
*>
(
sender
())
->
getCommandContainer
().
session_command
(
0
).
GetExtension
(
Command_DeckNewDir
::
ext
));
serverDirView
->
addFolderToTree
(
QString
::
fromStdString
(
cmd
.
dir_n
ame
()
)
,
serverDirView
->
getNodeByPath
(
QString
::
fromStdString
(
cmd
.
p
ath
()))
)
;
}
void
TabDeckStorage
::
actDelete
()
...
...
@@ -282,28 +292,35 @@ void TabDeckStorage::actDelete()
Command_DeckDelDir
cmd
;
cmd
.
set_path
(
path
.
toStdString
());
pend
=
client
->
prepareSessionCommand
(
cmd
);
connect
(
pend
,
SIGNAL
(
finished
(
ResponseCode
)),
this
,
SLOT
(
deleteFolderFinished
(
ResponseCode
)));
}
else
{
Command_DeckDel
cmd
;
cmd
.
set_deck_id
(
dynamic_cast
<
RemoteDeckList_TreeModel
::
FileNode
*>
(
curRight
)
->
getId
());
pend
=
client
->
prepareSessionCommand
(
cmd
);
connect
(
pend
,
SIGNAL
(
finished
(
ResponseCode
)),
this
,
SLOT
(
deleteDeckFinished
(
ResponseCode
)));
}
connect
(
pend
,
SIGNAL
(
finished
(
ResponseCode
)),
this
,
SLOT
(
deleteFinished
(
ResponseCode
)));
client
->
sendCommand
(
pend
);
}
void
TabDeckStorage
::
deleteFinished
(
ResponseCode
resp
)
void
TabDeckStorage
::
delete
Deck
Finished
(
ResponseCode
resp
)
{
if
(
resp
!=
RespOk
)
return
;
const
Command_DeckDel
&
cmd
=
static_cast
<
const
Command_DeckDel
&>
(
static_cast
<
PendingCommand
*>
(
sender
())
->
getCommandContainer
().
session_command
(
0
).
GetExtension
(
Command_DeckDel
::
ext
));
RemoteDeckList_TreeModel
::
Node
*
toDelete
=
serverDirView
->
getNodeById
(
cmd
.
deck_id
());
if
(
toDelete
)
serverDirView
->
removeNode
(
toDelete
);
}
RemoteDeckList_TreeModel
::
Node
*
toDelete
=
0
;
// Command_DeckDelDir *cmdDelDir = qobject_cast<Command_DeckDelDir *>(sender());
// if (cmdDelDir)
// toDelete = serverDirView->getNodeByPath(cmdDelDir->getPath());
// else
// toDelete = serverDirView->getNodeById(static_cast<Command_DeckDel *>(sender())->getDeckId());
void
TabDeckStorage
::
deleteFolderFinished
(
ResponseCode
resp
)
{
if
(
resp
!=
RespOk
)
return
;
const
Command_DeckDelDir
&
cmd
=
static_cast
<
const
Command_DeckDelDir
&>
(
static_cast
<
PendingCommand
*>
(
sender
())
->
getCommandContainer
().
session_command
(
0
).
GetExtension
(
Command_DeckDelDir
::
ext
));
RemoteDeckList_TreeModel
::
Node
*
toDelete
=
serverDirView
->
getNodeByPath
(
QString
::
fromStdString
(
cmd
.
path
()));
if
(
toDelete
)
serverDirView
->
removeNode
(
toDelete
);
}
cockatrice/src/tab_deck_storage.h
View file @
f115342e
...
...
@@ -43,7 +43,8 @@ private slots:
void
newFolderFinished
(
ResponseCode
resp
);
void
actDelete
();
void
deleteFinished
(
ResponseCode
resp
);
void
deleteFolderFinished
(
ResponseCode
resp
);
void
deleteDeckFinished
(
ResponseCode
resp
);
public:
TabDeckStorage
(
TabSupervisor
*
_tabSupervisor
,
AbstractClient
*
_client
);
void
retranslateUi
();
...
...
cockatrice/src/tab_game.cpp
View file @
f115342e
...
...
@@ -156,7 +156,7 @@ void DeckViewContainer::readyStart()
{
Command_ReadyStart
cmd
;
cmd
.
set_ready
(
!
readyStartButton
->
getReadyStart
());
static_cast
<
TabGame
*>
(
parent
())
->
sendGameCommand
(
cmd
);
static_cast
<
TabGame
*>
(
parent
())
->
sendGameCommand
(
cmd
,
playerId
);
}
void
DeckViewContainer
::
sideboardPlanChanged
()
...
...
@@ -165,7 +165,7 @@ void DeckViewContainer::sideboardPlanChanged()
QList
<
MoveCardToZone
*>
newPlan
=
deckView
->
getSideboardPlan
();
for
(
int
i
=
0
;
i
<
newPlan
.
size
();
++
i
)
cmd
.
add_move_list
()
->
CopyFrom
(
newPlan
[
i
]
->
toPB
());
static_cast
<
TabGame
*>
(
parent
())
->
sendGameCommand
(
cmd
);
static_cast
<
TabGame
*>
(
parent
())
->
sendGameCommand
(
cmd
,
playerId
);
}
void
DeckViewContainer
::
setReadyStart
(
bool
ready
)
...
...
@@ -509,12 +509,6 @@ void TabGame::sendGameCommand(const google::protobuf::Message &command, int play
client
->
sendCommand
(
prepareGameCommand
(
command
));
}
void
TabGame
::
sendCommandContainer
(
CommandContainer
&
cont
,
int
playerId
)
{
cont
.
set_game_id
(
gameId
);
getClientForPlayer
(
playerId
)
->
sendCommand
(
cont
);
}
PendingCommand
*
TabGame
::
prepareGameCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
)
{
CommandContainer
cont
;
...
...
cockatrice/src/tab_game.h
View file @
f115342e
...
...
@@ -183,7 +183,6 @@ public:
public
slots
:
void
sendGameCommand
(
PendingCommand
*
pend
,
int
playerId
=
-
1
);
void
sendGameCommand
(
const
::
google
::
protobuf
::
Message
&
command
,
int
playerId
=
-
1
);
void
sendCommandContainer
(
CommandContainer
&
cont
,
int
playerId
=
-
1
);
};
#endif
cockatrice/src/tab_room.cpp
View file @
f115342e
...
...
@@ -171,11 +171,7 @@ void TabRoom::processSayEvent(Event_RoomSay *event)
PendingCommand
*
TabRoom
::
prepareRoomCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
)
{
CommandContainer
cont
;
RoomCommand
*
c
=
cont
.
add_room_command
();
cont
.
set_room_id
(
roomId
);
c
->
GetReflection
()
->
MutableMessage
(
c
,
cmd
.
GetDescriptor
()
->
FindExtensionByName
(
"ext"
))
->
CopyFrom
(
cmd
);
return
new
PendingCommand
(
cont
);
return
client
->
prepareRoomCommand
(
cmd
,
roomId
);
}
void
TabRoom
::
sendRoomCommand
(
PendingCommand
*
pend
)
...
...
cockatrice/src/tab_supervisor.cpp
View file @
f115342e
...
...
@@ -249,9 +249,9 @@ void TabSupervisor::localGameJoined(Event_GameJoined *event)
setCurrentWidget
(
tab
);
for
(
int
i
=
1
;
i
<
localClients
.
size
();
++
i
)
{
//
Command_JoinGame
*
cmd
= new Command_JoinGame(0, event->getGameId())
;
// localClients[i]->sendCommand(cmd
);
// XXX
Command_JoinGame
cmd
;
cmd
.
set_game_id
(
event
->
getGameId
()
);
localClients
[
i
]
->
sendCommand
(
localClients
[
i
]
->
prepareRoomCommand
(
cmd
,
0
));
}
}
...
...
cockatrice/src/tab_supervisor.h
View file @
f115342e
...
...
@@ -60,6 +60,7 @@ public:
int
getGameCount
()
const
{
return
gameTabs
.
size
();
}
TabUserLists
*
getUserListsTab
()
const
{
return
tabUserLists
;
}
ServerInfo_User
*
getUserInfo
()
const
{
return
userInfo
;
}
const
QMap
<
int
,
TabRoom
*>
&
getRoomTabs
()
const
{
return
roomTabs
;
}
bool
getAdminLocked
()
const
;
int
getUserLevel
()
const
;
signals:
...
...
cockatrice/src/userlist.cpp
View file @
f115342e
...
...
@@ -296,10 +296,10 @@ void UserList::userClicked(QTreeWidgetItem *item, int /*column*/)
void
UserList
::
gamesOfUserReceived
(
ProtocolResponse
*
resp
)
{
//Command_GetGamesOfUser *command = static_cast<Command_GetGamesOfUser *>(sender());
Response_GetGamesOfUser
*
response
=
qobject_cast
<
Response_GetGamesOfUser
*>
(
resp
);
if
(
!
response
)
return
;
const
Command_GetGamesOfUser
&
cmd
=
static_cast
<
const
Command_GetGamesOfUser
&>
(
static_cast
<
PendingCommand
*>
(
sender
())
->
getCommandContainer
().
session_command
(
0
).
GetExtension
(
Command_GetGamesOfUser
::
ext
));
QMap
<
int
,
GameTypeMap
>
gameTypeMap
;
QMap
<
int
,
QString
>
roomMap
;
...
...
@@ -318,7 +318,7 @@ void UserList::gamesOfUserReceived(ProtocolResponse *resp)
for
(
int
i
=
0
;
i
<
gameList
.
size
();
++
i
)
selector
->
processGameInfo
(
gameList
[
i
]);
//
selector->setWindowTitle(tr("%1's games").arg(
command->getU
ser
N
ame()));
selector
->
setWindowTitle
(
tr
(
"%1's games"
).
arg
(
QString
::
fromStdString
(
cmd
.
u
ser
_n
ame
()))
)
;
selector
->
setAttribute
(
Qt
::
WA_DeleteOnClose
);
selector
->
show
();
}
...
...
cockatrice/src/window_main.cpp
View file @
f115342e
...
...
@@ -36,6 +36,8 @@
#include
"localserverinterface.h"
#include
"localclient.h"
#include
"pb/room_commands.pb.h"
const
QString
MainWindow
::
appName
=
"Cockatrice"
;
void
MainWindow
::
updateTabMenu
(
QMenu
*
menu
)
...
...
@@ -134,8 +136,9 @@ void MainWindow::actSinglePlayer()
}
tabSupervisor
->
startLocal
(
localClients
);
// Command_CreateGame *createCommand = new Command_CreateGame(0, QString(), QString(), numberPlayers, QList<GameTypeId *>(), false, false, false, false);
// mainClient->sendCommand(createCommand);
Command_CreateGame
createCommand
;
createCommand
.
set_max_players
(
numberPlayers
);
mainClient
->
sendCommand
(
mainClient
->
prepareRoomCommand
(
createCommand
,
0
));
}
void
MainWindow
::
localGameEnded
()
...
...
common/protocol.cpp
View file @
f115342e
...
...
@@ -28,18 +28,10 @@ void ProtocolItem::initializeHash()
registerSerializableItem
(
"player_ping"
,
ServerInfo_PlayerPing
::
newItem
);
registerSerializableItem
(
"file"
,
DeckList_File
::
newItem
);
registerSerializableItem
(
"directory"
,
DeckList_Directory
::
newItem
);
// registerSerializableItem("card_to_move", CardToMove::newItem);
registerSerializableItem
(
"game_type_id"
,
GameTypeId
::
newItem
);
// registerSerializableItem("containercmd", CommandContainer::newItem);
registerSerializableItem
(
"containergame_event"
,
GameEventContainer
::
newItem
);
/*
registerSerializableItem("cmdcreate_game", Command_CreateGame::newItem);
registerSerializableItem("cmddeck_upload", Command_DeckUpload::newItem);
registerSerializableItem("cmddeck_select", Command_DeckSelect::newItem);
registerSerializableItem("cmdset_sideboard_plan", Command_SetSideboardPlan::newItem);
registerSerializableItem("cmdmove_card", Command_MoveCard::newItem);
*/
registerSerializableItem
(
"resp"
,
ProtocolResponse
::
newItem
);
ProtocolResponse
::
initializeHash
();
registerSerializableItem
(
"respjoin_room"
,
Response_JoinRoom
::
newItem
);
...
...
@@ -105,41 +97,6 @@ void TopLevelProtocolItem::writeElement(QXmlStreamWriter * /*xml*/)
{
}
/*
int CommandContainer::lastCmdId = 0;
Command::Command(const QString &_itemName)
: ProtocolItem("cmd", _itemName)
{
}
void Command::processResponse(ProtocolResponse *response)
{
emit finished(response);
emit finished(response->getResponseCode());
}
CommandContainer::CommandContainer(const QList<Command *> &_commandList, int _cmdId)
: ProtocolItem("container", "cmd"), ticks(0), resp(0), gameEventQueuePublic(0), gameEventQueueOmniscient(0), gameEventQueuePrivate(0), privatePlayerId(-1)
{
if (_cmdId == -1)
_cmdId = lastCmdId++;
insertItem(new SerializableItem_Int("cmd_id", _cmdId));
for (int i = 0; i < _commandList.size(); ++i)
itemList.append(_commandList[i]);
}
void CommandContainer::processResponse(ProtocolResponse *response)
{
emit finished(response);
emit finished(response->getResponseCode());
const QList<Command *> &cmdList = getCommandList();
for (int i = 0; i < cmdList.size(); ++i)
cmdList[i]->processResponse(response);
}
*/
BlaContainer
::
BlaContainer
()
:
ProtocolItem
(
"container"
,
"cmd"
),
resp
(
0
),
gameEventQueuePublic
(
0
),
gameEventQueueOmniscient
(
0
),
gameEventQueuePrivate
(
0
),
privatePlayerId
(
-
1
)
{
...
...
@@ -178,77 +135,7 @@ void BlaContainer::enqueueGameEventPrivate(GameEvent *event, int gameId, int pla
if
(
context
)
gameEventQueuePrivate
->
setContext
(
context
);
}
/*
Command_CreateGame::Command_CreateGame(int _roomId, const QString &_description, const QString &_password, int _maxPlayers, const QList<GameTypeId *> &_gameTypes, bool _onlyBuddies, bool _onlyRegistered, bool _spectatorsAllowed, bool _spectatorsNeedPassword, bool _spectatorsCanTalk, bool _spectatorsSeeEverything)
: RoomCommand("create_game", _roomId)
{
insertItem(new SerializableItem_String("description", _description));
insertItem(new SerializableItem_String("password", _password));
insertItem(new SerializableItem_Int("max_players", _maxPlayers));
insertItem(new SerializableItem_Bool("only_buddies", _onlyBuddies));
insertItem(new SerializableItem_Bool("only_registered", _onlyRegistered));
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));
for (int i = 0; i < _gameTypes.size(); ++i)
itemList.append(_gameTypes[i]);
}
Command_DeckUpload::Command_DeckUpload(DeckList *_deck, const QString &_path)
: Command("deck_upload")
{
insertItem(new SerializableItem_String("path", _path));
if (!_deck)
_deck = new DeckList;
insertItem(_deck);
}
DeckList *Command_DeckUpload::getDeck() const
{
return static_cast<DeckList *>(itemMap.value("cockatrice_deck"));
}
Command_DeckSelect::Command_DeckSelect(int _gameId, DeckList *_deck, int _deckId)
: GameCommand("deck_select", _gameId)
{
insertItem(new SerializableItem_Int("deck_id", _deckId));
if (!_deck)
_deck = new DeckList;
insertItem(_deck);
}
DeckList *Command_DeckSelect::getDeck() const
{
return static_cast<DeckList *>(itemMap.value("cockatrice_deck"));
}
Command_SetSideboardPlan::Command_SetSideboardPlan(int _gameId, const QList<MoveCardToZone *> &_moveList)
: GameCommand("set_sideboard_plan", _gameId)
{
for (int i = 0; i < _moveList.size(); ++i)
itemList.append(_moveList[i]);
}
QList<MoveCardToZone *> Command_SetSideboardPlan::getMoveList() const
{
return typecastItemList<MoveCardToZone *>();
}
Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, const QList<CardToMove *> &_cards, int _targetPlayerId, const QString &_targetZone, int _x, int _y)
: GameCommand("move_card", _gameId)
{
insertItem(new SerializableItem_String("start_zone", _startZone));
insertItem(new SerializableItem_Int("target_player_id", _targetPlayerId));
insertItem(new SerializableItem_String("target_zone", _targetZone));
insertItem(new SerializableItem_Int("x", _x));
insertItem(new SerializableItem_Int("y", _y));
for (int i = 0; i < _cards.size(); ++i)
itemList.append(_cards[i]);
}
*/
QHash
<
QString
,
ResponseCode
>
ProtocolResponse
::
responseHash
;
ProtocolResponse
::
ProtocolResponse
(
int
_cmdId
,
ResponseCode
_responseCode
,
const
QString
&
_itemName
)
...
...
common/protocol.h
View file @
f115342e
...
...
@@ -91,21 +91,7 @@ public:
// ----------------
// --- COMMANDS ---
// ----------------
/*
class Command : public ProtocolItem {
Q_OBJECT
signals:
void finished(ProtocolResponse *response);
void finished(ResponseCode response);
private:
QVariant extraData;
public:
Command(const QString &_itemName = QString());
void setExtraData(const QVariant &_extraData) { extraData = _extraData; }
QVariant getExtraData() const { return extraData; }
void processResponse(ProtocolResponse *response);
};
*/
class
BlaContainer
:
public
ProtocolItem
{
Q_OBJECT
private:
...
...
@@ -132,91 +118,7 @@ public:
void
enqueueGameEventPrivate
(
GameEvent
*
event
,
int
gameId
,
int
playerId
=
-
1
,
GameEventContext
*
context
=
0
);
int
getPrivatePlayerId
()
const
{
return
privatePlayerId
;
}
};
/*
class RoomCommand : public Command {
Q_OBJECT
public:
RoomCommand(const QString &_cmdName, int _roomId)
: Command(_cmdName)
{
insertItem(new SerializableItem_Int("room_id", _roomId));
}
int getRoomId() const { return static_cast<SerializableItem_Int *>(itemMap.value("room_id"))->getData(); }
};
class GameCommand : public Command {
Q_OBJECT
public:
GameCommand(const QString &_cmdName, int _gameId)
: Command(_cmdName)
{
insertItem(new SerializableItem_Int("game_id", _gameId));
}
int getGameId() const { return static_cast<SerializableItem_Int *>(itemMap.value("game_id"))->getData(); }
void setGameId(int _gameId) { static_cast<SerializableItem_Int *>(itemMap.value("game_id"))->setData(_gameId); }
};
class ModeratorCommand : public Command {
Q_OBJECT
public:
ModeratorCommand(const QString &_cmdName)
: Command(_cmdName)
{
}
};
class AdminCommand : public Command {
Q_OBJECT
public:
AdminCommand(const QString &_cmdName)
: Command(_cmdName)
{
}
};
class Command_DeckUpload : public Command {
Q_OBJECT
public:
Command_DeckUpload(DeckList *_deck = 0, const QString &_path = QString());
static SerializableItem *newItem() { return new Command_DeckUpload; }
int getItemId() const { return ItemId_Command_DeckUpload; }
DeckList *getDeck() const;
QString getPath() const { return static_cast<SerializableItem_String *>(itemMap.value("path"))->getData(); }
};
class Command_DeckSelect : public GameCommand {
Q_OBJECT
public:
Command_DeckSelect(int _gameId = -1, DeckList *_deck = 0, int _deckId = -1);
static SerializableItem *newItem() { return new Command_DeckSelect; }
int getItemId() const { return ItemId_Command_DeckSelect; }
DeckList *getDeck() const;
int getDeckId() const { return static_cast<SerializableItem_Int *>(itemMap.value("deck_id"))->getData(); }
};
class Command_SetSideboardPlan : public GameCommand {
Q_OBJECT
public:
Command_SetSideboardPlan(int _gameId = -1, const QList<MoveCardToZone *> &_moveList = QList<MoveCardToZone *>());
static SerializableItem *newItem() { return new Command_SetSideboardPlan; }
int getItemId() const { return ItemId_Command_SetSideboardPlan; }
QList<MoveCardToZone *> getMoveList() const;
};
class Command_MoveCard : public GameCommand {
Q_OBJECT
public:
Command_MoveCard(int _gameId = -1, const QString &_startZone = QString(), const QList<CardToMove *> &_cards = QList<CardToMove *>(), int _targetPlayerId = -1, const QString &_targetZone = QString(), int _x = -1, int _y = -1);
QString getStartZone() const { return static_cast<SerializableItem_String *>(itemMap.value("start_zone"))->getData(); }
QList<CardToMove *> getCards() const { return typecastItemList<CardToMove *>(); }
int getTargetPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("target_player_id"))->getData(); }
QString getTargetZone() const { return static_cast<SerializableItem_String *>(itemMap.value("target_zone"))->getData(); }
int getX() const { return static_cast<SerializableItem_Int *>(itemMap.value("x"))->getData(); }
int getY() const { return static_cast<SerializableItem_Int *>(itemMap.value("y"))->getData(); }
static SerializableItem *newItem() { return new Command_MoveCard; }
int getItemId() const { return ItemId_Command_MoveCard; }
};
*/
// -----------------
// --- RESPONSES ---
// -----------------
...
...
@@ -231,6 +133,7 @@ public:
static
void
initializeHash
();
static
SerializableItem
*
newItem
()
{
return
new
ProtocolResponse
;
}
int
getCmdId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"cmd_id"
))
->
getData
();
}
void
setCmdId
(
int
_cmdId
)
{
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"cmd_id"
))
->
setData
(
_cmdId
);
}
ResponseCode
getResponseCode
()
const
{
return
responseHash
.
value
(
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"response_code"
))
->
getData
(),
RespOk
);
}
};
...
...
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