mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 00:04:48 -07:00
almost finished pre-game deck loading
This commit is contained in:
parent
8dcf81654e
commit
cf21528a69
16 changed files with 140 additions and 64 deletions
|
|
@ -12,6 +12,8 @@
|
|||
#include "zoneviewlayout.h"
|
||||
#include "deckview.h"
|
||||
#include "decklist.h"
|
||||
#include "deck_picturecacher.h"
|
||||
#include "protocol_items.h"
|
||||
#include "main.h"
|
||||
|
||||
TabGame::TabGame(Client *_client, int _gameId)
|
||||
|
|
@ -22,12 +24,17 @@ TabGame::TabGame(Client *_client, int _gameId)
|
|||
gameView = new GameView(scene);
|
||||
gameView->hide();
|
||||
|
||||
deckView = new DeckView;
|
||||
loadLocalButton = new QPushButton;
|
||||
loadRemoteButton = new QPushButton;
|
||||
|
||||
DeckList *foo = new DeckList;
|
||||
foo->loadFromFile("/home/brukie/cockatrice/decks/adfb.cod", DeckList::CockatriceFormat);
|
||||
deckView->setDeck(foo);
|
||||
// deckView->hide();
|
||||
QHBoxLayout *buttonHBox = new QHBoxLayout;
|
||||
buttonHBox->addWidget(loadLocalButton);
|
||||
buttonHBox->addWidget(loadRemoteButton);
|
||||
buttonHBox->addStretch();
|
||||
deckView = new DeckView;
|
||||
QVBoxLayout *deckViewLayout = new QVBoxLayout;
|
||||
deckViewLayout->addLayout(buttonHBox);
|
||||
deckViewLayout->addWidget(deckView);
|
||||
|
||||
cardInfo = new CardInfoWidget(db);
|
||||
messageLog = new MessageLogWidget;
|
||||
|
|
@ -50,13 +57,16 @@ TabGame::TabGame(Client *_client, int _gameId)
|
|||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->addWidget(phasesToolbar);
|
||||
mainLayout->addWidget(gameView, 10);
|
||||
mainLayout->addWidget(deckView, 10);
|
||||
mainLayout->addLayout(deckViewLayout, 10);
|
||||
mainLayout->addLayout(verticalLayout);
|
||||
|
||||
aCloseMostRecentZoneView = new QAction(this);
|
||||
connect(aCloseMostRecentZoneView, SIGNAL(triggered()), zoneLayout, SLOT(closeMostRecentZoneView()));
|
||||
addAction(aCloseMostRecentZoneView);
|
||||
|
||||
connect(loadLocalButton, SIGNAL(clicked()), this, SLOT(loadLocalDeck()));
|
||||
connect(loadRemoteButton, SIGNAL(clicked()), this, SLOT(loadRemoteDeck()));
|
||||
|
||||
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(actSay()));
|
||||
|
||||
// connect(client, SIGNAL(maxPingTime(int, int)), pingWidget, SLOT(setPercentage(int, int)));
|
||||
|
|
@ -81,6 +91,8 @@ TabGame::TabGame(Client *_client, int _gameId)
|
|||
|
||||
void TabGame::retranslateUi()
|
||||
{
|
||||
loadLocalButton->setText(tr("Load &local deck"));
|
||||
loadRemoteButton->setText(tr("Load deck from &server"));
|
||||
sayLabel->setText(tr("&Say:"));
|
||||
cardInfo->retranslateUi();
|
||||
// if (game)
|
||||
|
|
@ -94,3 +106,43 @@ void TabGame::processGameEvent(GameEvent *event)
|
|||
{
|
||||
// game->processGameEvent(event);
|
||||
}
|
||||
|
||||
void TabGame::loadLocalDeck()
|
||||
{
|
||||
QFileDialog dialog(this, tr("Load deck"));
|
||||
QSettings settings;
|
||||
dialog.setDirectory(settings.value("paths/decks").toString());
|
||||
dialog.setNameFilters(DeckList::fileNameFilters);
|
||||
if (!dialog.exec())
|
||||
return;
|
||||
|
||||
QString fileName = dialog.selectedFiles().at(0);
|
||||
DeckList::FileFormat fmt = DeckList::getFormatFromNameFilter(dialog.selectedNameFilter());
|
||||
DeckList *deck = new DeckList;
|
||||
if (!deck->loadFromFile(fileName, fmt)) {
|
||||
delete deck;
|
||||
// Error message
|
||||
return;
|
||||
}
|
||||
|
||||
Command_DeckSelect *cmd = new Command_DeckSelect(gameId, deck, -1);
|
||||
connect(cmd, SIGNAL(finished(ProtocolResponse *)), this, SLOT(deckSelectFinished(ProtocolResponse *)));
|
||||
client->sendCommand(cmd);
|
||||
}
|
||||
|
||||
void TabGame::loadRemoteDeck()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TabGame::deckSelectFinished(ProtocolResponse *r)
|
||||
{
|
||||
Response_DeckDownload *resp = qobject_cast<Response_DeckDownload *>(r);
|
||||
if (!resp)
|
||||
return;
|
||||
Command_DeckSelect *cmd = static_cast<Command_DeckSelect *>(sender());
|
||||
delete cmd->getDeck();
|
||||
|
||||
Deck_PictureCacher::cachePictures(resp->getDeck(), this);
|
||||
deckView->setDeck(resp->getDeck());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue