mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 19:47:46 -07:00
added deck hashing
This commit is contained in:
parent
963e8f0d90
commit
0bb4ef8bb8
31 changed files with 4867 additions and 4831 deletions
|
|
@ -17,6 +17,7 @@ DeckListModel::DeckListModel(QObject *parent)
|
|||
{
|
||||
deckList = new DeckList;
|
||||
connect(deckList, SIGNAL(deckLoaded()), this, SLOT(rebuildTree()));
|
||||
connect(deckList, SIGNAL(deckHashChanged()), this, SIGNAL(deckHashChanged()));
|
||||
root = new InnerDecklistNode;
|
||||
}
|
||||
|
||||
|
|
@ -194,6 +195,7 @@ bool DeckListModel::setData(const QModelIndex &index, const QVariant &value, int
|
|||
default: return false;
|
||||
}
|
||||
emitRecursiveUpdates(index);
|
||||
deckList->updateDeckHash();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -310,6 +312,8 @@ void DeckListModel::setDeckList(DeckList *_deck)
|
|||
{
|
||||
delete deckList;
|
||||
deckList = _deck;
|
||||
connect(deckList, SIGNAL(deckLoaded()), this, SLOT(rebuildTree()));
|
||||
connect(deckList, SIGNAL(deckHashChanged()), this, SIGNAL(deckHashChanged()));
|
||||
rebuildTree();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ private slots:
|
|||
void rebuildTree();
|
||||
public slots:
|
||||
void printDeckList(QPrinter *printer);
|
||||
signals:
|
||||
void deckHashChanged();
|
||||
public:
|
||||
DeckListModel(QObject *parent = 0);
|
||||
~DeckListModel();
|
||||
|
|
|
|||
|
|
@ -58,19 +58,12 @@ void MessageLogWidget::logLeaveSpectator(QString name)
|
|||
appendHtml(tr("%1 is not watching the game any more.").arg(sanitizeHtml(name)));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logDeckSelect(Player *player, int deckId)
|
||||
void MessageLogWidget::logDeckSelect(Player *player, QString deckHash)
|
||||
{
|
||||
if (deckId == -1) {
|
||||
if (isFemale(player))
|
||||
appendHtml(tr("%1 has loaded a local deck.", "female").arg(sanitizeHtml(player->getName())));
|
||||
else
|
||||
appendHtml(tr("%1 has loaded a local deck.", "male").arg(sanitizeHtml(player->getName())));
|
||||
} else {
|
||||
if (isFemale(player))
|
||||
appendHtml(tr("%1 has loaded deck #%2.", "female").arg(sanitizeHtml(player->getName())).arg(deckId));
|
||||
else
|
||||
appendHtml(tr("%1 has loaded deck #%2.", "male").arg(sanitizeHtml(player->getName())).arg(deckId));
|
||||
}
|
||||
if (isFemale(player))
|
||||
appendHtml(tr("%1 has loaded a deck (%2).", "female").arg(sanitizeHtml(player->getName())).arg(deckHash));
|
||||
else
|
||||
appendHtml(tr("%1 has loaded a deck (%2).", "male").arg(sanitizeHtml(player->getName())).arg(deckHash));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logReadyStart(Player *player)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public slots:
|
|||
void logGameClosed();
|
||||
void logJoinSpectator(QString name);
|
||||
void logLeaveSpectator(QString name);
|
||||
void logDeckSelect(Player *player, int deckId);
|
||||
void logDeckSelect(Player *player, QString deckHash);
|
||||
void logReadyStart(Player *player);
|
||||
void logNotReadyStart(Player *player);
|
||||
void logConcede(Player *player);
|
||||
|
|
|
|||
|
|
@ -98,15 +98,7 @@ void PlayerListWidget::updatePlayerProperties(ServerInfo_PlayerProperties *prop)
|
|||
player->setIcon(4, QIcon(CountryPixmapGenerator::generatePixmap(12, prop->getUserInfo()->getCountry())));
|
||||
player->setData(4, Qt::UserRole, prop->getUserInfo()->getName());
|
||||
player->setData(4, Qt::UserRole + 1, prop->getPlayerId());
|
||||
|
||||
QString deckText;
|
||||
if (!prop->getSpectator())
|
||||
switch (prop->getDeckId()) {
|
||||
case -2: deckText = QString(); break;
|
||||
case -1: deckText = tr("local deck"); break;
|
||||
default: deckText = tr("deck #%1").arg(prop->getDeckId());
|
||||
}
|
||||
player->setText(5, deckText);
|
||||
player->setText(5, prop->getDeckHash());
|
||||
}
|
||||
|
||||
void PlayerListWidget::removePlayer(int playerId)
|
||||
|
|
|
|||
|
|
@ -620,7 +620,7 @@ void TabGame::eventPlayerPropertiesChanged(Event_PlayerPropertiesChanged *event,
|
|||
|
||||
break;
|
||||
}
|
||||
case ItemId_Context_DeckSelect: messageLog->logDeckSelect(player, static_cast<Context_DeckSelect *>(context)->getDeckId()); break;
|
||||
case ItemId_Context_DeckSelect: messageLog->logDeckSelect(player, static_cast<Context_DeckSelect *>(context)->getDeckHash()); break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
|||
middleFrame->addLayout(verticalToolBarLayout);
|
||||
|
||||
deckModel = new DeckListModel(this);
|
||||
connect(deckModel, SIGNAL(deckHashChanged()), this, SLOT(updateHash()));
|
||||
deckView = new QTreeView();
|
||||
deckView->setModel(deckModel);
|
||||
deckView->setUniformRowHeights(true);
|
||||
|
|
@ -114,6 +115,8 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
|||
commentsEdit->setMaximumHeight(70);
|
||||
commentsLabel->setBuddy(commentsEdit);
|
||||
connect(commentsEdit, SIGNAL(textChanged()), this, SLOT(updateComments()));
|
||||
QLabel *hashLabel1 = new QLabel(tr("Hash:"));
|
||||
hashLabel = new QLabel;
|
||||
|
||||
QGridLayout *grid = new QGridLayout;
|
||||
grid->addWidget(nameLabel, 0, 0);
|
||||
|
|
@ -121,6 +124,9 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
|||
|
||||
grid->addWidget(commentsLabel, 1, 0);
|
||||
grid->addWidget(commentsEdit, 1, 1);
|
||||
|
||||
grid->addWidget(hashLabel1, 2, 0);
|
||||
grid->addWidget(hashLabel, 2, 1);
|
||||
|
||||
// Update price
|
||||
aUpdatePrices = new QAction(tr("&Update prices"), this);
|
||||
|
|
@ -140,10 +146,9 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
|||
deckToolbarLayout->addWidget(deckToolBar);
|
||||
deckToolbarLayout->addStretch();
|
||||
|
||||
|
||||
QVBoxLayout *rightFrame = new QVBoxLayout;
|
||||
rightFrame->addLayout(grid);
|
||||
rightFrame->addWidget(deckView);
|
||||
rightFrame->addWidget(deckView, 10);
|
||||
rightFrame->addLayout(deckToolbarLayout);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
|
|
@ -230,6 +235,7 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
|||
verticalToolBar->addAction(aRemoveCard);
|
||||
verticalToolBar->addAction(aIncrement);
|
||||
verticalToolBar->addAction(aDecrement);
|
||||
verticalToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
|
||||
dlgCardSearch = new DlgCardSearch(this);
|
||||
|
||||
|
|
@ -273,6 +279,11 @@ void WndDeckEditor::updateSearch(const QString &search)
|
|||
databaseView->selectionModel()->setCurrentIndex(databaseDisplayModel->index(0, 0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||
}
|
||||
|
||||
void WndDeckEditor::updateHash()
|
||||
{
|
||||
hashLabel->setText(deckModel->getDeckList()->getDeckHash());
|
||||
}
|
||||
|
||||
bool WndDeckEditor::confirmClose()
|
||||
{
|
||||
if (isWindowModified()) {
|
||||
|
|
@ -305,6 +316,7 @@ void WndDeckEditor::actNewDeck()
|
|||
nameEdit->setText(QString());
|
||||
commentsEdit->setText(QString());
|
||||
lastFileName = QString();
|
||||
setWindowModified(false);
|
||||
}
|
||||
|
||||
void WndDeckEditor::actLoadDeck()
|
||||
|
|
@ -506,6 +518,7 @@ void WndDeckEditor::setDeck(DeckList *_deck, const QString &_lastFileName, DeckL
|
|||
lastFileFormat = _lastFileFormat;
|
||||
nameEdit->setText(_deck->getName());
|
||||
commentsEdit->setText(_deck->getComments());
|
||||
updateHash();
|
||||
deckModel->sort(1);
|
||||
deckView->expandAll();
|
||||
setWindowModified(false);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ class QTableView;
|
|||
class CardInfoWidget;
|
||||
class QTextEdit;
|
||||
class DlgCardSearch;
|
||||
class QLabel;
|
||||
|
||||
class SearchLineEdit : public QLineEdit {
|
||||
private:
|
||||
|
|
@ -30,6 +31,7 @@ class WndDeckEditor : public QMainWindow {
|
|||
private slots:
|
||||
void updateName(const QString &name);
|
||||
void updateComments();
|
||||
void updateHash();
|
||||
void updateCardInfoLeft(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void updateCardInfoRight(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void updateSearch(const QString &search);
|
||||
|
|
@ -72,6 +74,7 @@ private:
|
|||
SearchLineEdit *searchEdit;
|
||||
QLineEdit *nameEdit;
|
||||
QTextEdit *commentsEdit;
|
||||
QLabel *hashLabel;
|
||||
DlgCardSearch *dlgCardSearch;
|
||||
|
||||
QMenu *deckMenu, *dbMenu;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue