mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-02 19:43:55 -07:00
local mode is working again
This commit is contained in:
parent
38e4781624
commit
f115342e47
24 changed files with 340 additions and 555 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
room->sendRoomCommand(pend);
|
||||
r->sendRoomCommand(pend);
|
||||
|
||||
if (createButton)
|
||||
createButton->setEnabled(false);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,17 +10,17 @@ class LocalServerInterface : public Server_ProtocolHandler
|
|||
Q_OBJECT
|
||||
private:
|
||||
DeckList *getDeckFromDatabase(int /*deckId*/) { return 0; }
|
||||
ResponseCode cmdAddToList(const Command_AddToList & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdRemoveFromList(const Command_RemoveFromList & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckList(const Command_DeckList & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckNewDir(const Command_DeckNewDir & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDelDir(const Command_DeckDelDir & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDel(const Command_DeckDel & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckUpload(const Command_DeckUpload & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDownload(const Command_DeckDownload & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdBanFromServer(const Command_BanFromServer & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdShutdownServer(const Command_ShutdownServer & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdUpdateServerMessage(const Command_UpdateServerMessage & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdAddToList(const Command_AddToList & /*cmd*/, BlaContainer * /*bla*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdRemoveFromList(const Command_RemoveFromList & /*cmd*/, BlaContainer * /*bla*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckList(const Command_DeckList & /*cmd*/, BlaContainer * /*bla*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckNewDir(const Command_DeckNewDir & /*cmd*/, BlaContainer * /*bla*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDelDir(const Command_DeckDelDir & /*cmd*/, BlaContainer * /*bla*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDel(const Command_DeckDel & /*cmd*/, BlaContainer * /*bla*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckUpload(const Command_DeckUpload & /*cmd*/, BlaContainer * /*bla*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDownload(const Command_DeckDownload & /*cmd*/, BlaContainer * /*bla*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdBanFromServer(const Command_BanFromServer & /*cmd*/, BlaContainer * /*bla*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdShutdownServer(const Command_ShutdownServer & /*cmd*/, BlaContainer * /*bla*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdUpdateServerMessage(const Command_UpdateServerMessage & /*cmd*/, BlaContainer * /*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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.\nPlease 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->getPath()));
|
||||
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.path())));
|
||||
}
|
||||
|
||||
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 = cmd->getExtraData().toString();
|
||||
// resp->getDeck()->saveToFile(filePath, DeckList::CockatriceFormat);
|
||||
|
||||
PendingCommand *pend = static_cast<PendingCommand *>(sender());
|
||||
QString filePath = pend->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->getDirName(), serverDirView->getNodeByPath(cmd->getPath()));
|
||||
|
||||
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_name()), serverDirView->getNodeByPath(QString::fromStdString(cmd.path())));
|
||||
}
|
||||
|
||||
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::deleteDeckFinished(ResponseCode resp)
|
||||
{
|
||||
if (resp != RespOk)
|
||||
return;
|
||||
|
||||
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());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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->getUserName()));
|
||||
selector->setWindowTitle(tr("%1's games").arg(QString::fromStdString(cmd.user_name())));
|
||||
selector->setAttribute(Qt::WA_DeleteOnClose);
|
||||
selector->show();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue