Merge branch 'master' into editor-redesign

Conflicts:
	cockatrice/src/carddatabasemodel.cpp
	cockatrice/src/carddatabasemodel.h
	cockatrice/src/decklistmodel.cpp
	cockatrice/src/decklistmodel.h
	cockatrice/src/tab_deck_editor.cpp
	cockatrice/src/tab_deck_editor.h
This commit is contained in:
sylvanbasilisk 2014-03-25 02:10:52 +00:00
commit 0770626270
152 changed files with 13862 additions and 13865 deletions

19
TODO.md
View file

@ -28,7 +28,6 @@ Note that "improve" and "write" always also means: "document and comment"
* Rename the picture filenames to something more meaningful. * Rename the picture filenames to something more meaningful.
* Create an index, lists of tables/figures/... * Create an index, lists of tables/figures/...
## Storage ## Storage
* Find a better place for sets.xml than doc. * Find a better place for sets.xml than doc.
@ -41,24 +40,6 @@ Note that "improve" and "write" always also means: "document and comment"
* Document everything!1!! * Document everything!1!!
* Coding guidelines * Coding guidelines
##Fix compile warnings
* (CMAKE_VERBOSE_MAKEFILE, compile with clang++), this could indicate missing program functionality:
```
cockatrice/src/abstractclient.cpp:72:12: warning: enumeration value 'SessionEvent_SessionEventType_SERVER_COMPLETE_LIST' not handled in switch [-Wswitch]
switch ((SessionEvent::SessionEventType) getPbExtension(event)) {
```
```
cockatrice/Cockatrice.VanNostrand/cockatrice/src/player.cpp:1725:12: warning: 4 enumeration values not handled in switch: 'cmMoveToTopLibrary', 'cmMoveToBottomLibrary', 'cmMoveToGraveyard'... [-Wswitch]
switch (static_cast<CardMenuActionType>(a->data().toInt())) {
```
```
cockatrice/src/cardzone.cpp:127:11: warning: enumeration values 'CaseTopCardsOfZone', 'CaseRevealZone', and 'CaseShuffleZone' not handled in switch [-Wswitch]
switch (gc) {
```
##Else ##Else
* Update SFMT library (http://www.math.sci.hiroshima-u.ac.jp/~m-mat@math.sci.hiroshima-u.ac.jp/MT/SFMT/) in common/sfmt and adapt common/rng_sfmt.cpp * Update SFMT library (http://www.math.sci.hiroshima-u.ac.jp/~m-mat@math.sci.hiroshima-u.ac.jp/MT/SFMT/) in common/sfmt and adapt common/rng_sfmt.cpp

View file

@ -82,6 +82,7 @@ void AbstractClient::processProtocolItem(const ServerMessage &item)
case SessionEvent::USER_LEFT: emit userLeftEventReceived(event.GetExtension(Event_UserLeft::ext)); break; case SessionEvent::USER_LEFT: emit userLeftEventReceived(event.GetExtension(Event_UserLeft::ext)); break;
case SessionEvent::GAME_JOINED: emit gameJoinedEventReceived(event.GetExtension(Event_GameJoined::ext)); break; case SessionEvent::GAME_JOINED: emit gameJoinedEventReceived(event.GetExtension(Event_GameJoined::ext)); break;
case SessionEvent::REPLAY_ADDED: emit replayAddedEventReceived(event.GetExtension(Event_ReplayAdded::ext)); break; case SessionEvent::REPLAY_ADDED: emit replayAddedEventReceived(event.GetExtension(Event_ReplayAdded::ext)); break;
default: break;
} }
break; break;
} }

View file

@ -118,7 +118,6 @@ CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
{ {
CardInfo const *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow); CardInfo const *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
if (((isToken == ShowTrue) && !info->getIsToken()) || ((isToken == ShowFalse) && info->getIsToken())) if (((isToken == ShowTrue) && !info->getIsToken()) || ((isToken == ShowFalse) && info->getIsToken()))
return false; return false;

View file

@ -143,6 +143,7 @@ QString CardZone::getTranslatedName(bool hisOwn, GrammaticalCase gc) const
? tr("his sideboard", "nominative, male owner") ? tr("his sideboard", "nominative, male owner")
: tr("%1's sideboard", "nominative, male owner").arg(ownerName) : tr("%1's sideboard", "nominative, male owner").arg(ownerName)
); );
default: break;
} }
return QString(); return QString();
} }

View file

@ -4,8 +4,7 @@
#include "decklist.h" #include "decklist.h"
const QStringList DeckLoader::fileNameFilters = QStringList() const QStringList DeckLoader::fileNameFilters = QStringList()
<< QObject::tr("Cockatrice decks (*.cod)") << QObject::tr("Common deck formats (*.cod *.dec *.mwDeck)")
<< QObject::tr("Plain text decks (*.dec *.mwDeck)")
<< QObject::tr("All files (*.*)"); << QObject::tr("All files (*.*)");
DeckLoader::DeckLoader() DeckLoader::DeckLoader()
@ -91,11 +90,10 @@ bool DeckLoader::saveToFile(const QString &fileName, FileFormat fmt)
return result; return result;
} }
DeckLoader::FileFormat DeckLoader::getFormatFromNameFilter(const QString &selectedNameFilter) DeckLoader::FileFormat DeckLoader::getFormatFromName(const QString &fileName)
{ {
switch (fileNameFilters.indexOf(selectedNameFilter)) { if (fileName.endsWith(".cod", Qt::CaseInsensitive)) {
case 0: return CockatriceFormat; return CockatriceFormat;
case 1: return PlainTextFormat;
} }
return PlainTextFormat; return PlainTextFormat;
} }

View file

@ -23,7 +23,7 @@ public:
FileFormat getLastFileFormat() const { return lastFileFormat; } FileFormat getLastFileFormat() const { return lastFileFormat; }
int getLastRemoteDeckId() const { return lastRemoteDeckId; } int getLastRemoteDeckId() const { return lastRemoteDeckId; }
static FileFormat getFormatFromNameFilter(const QString &selectedNameFilter); static FileFormat getFormatFromName(const QString &fileName);
bool loadFromFile(const QString &fileName, FileFormat fmt); bool loadFromFile(const QString &fileName, FileFormat fmt);
bool loadFromRemote(const QString &nativeString, int remoteDeckId); bool loadFromRemote(const QString &nativeString, int remoteDeckId);

View file

@ -45,7 +45,6 @@ public:
Qt::ItemFlags flags(const QModelIndex &index) const; Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role); bool setData(const QModelIndex &index, const QVariant &value, int role);
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
QModelIndex findCard(const QString &cardName, const QString &zoneName) const; QModelIndex findCard(const QString &cardName, const QString &zoneName) const;
QModelIndex addCard(const QString &cardName, const QString &zoneName); QModelIndex addCard(const QString &cardName, const QString &zoneName);
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);

View file

@ -1514,8 +1514,8 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
CardInfo *ci = c->getInfo(); CardInfo *ci = c->getInfo();
if ((!settingsCache->getPlayToStack() && ci->getTableRow() == 3) || if ((!settingsCache->getPlayToStack() && ci->getTableRow() == 3) ||
(settingsCache->getPlayToStack() && ci->getTableRow() != 0) && ((settingsCache->getPlayToStack() && ci->getTableRow() != 0) &&
c->getZone()->getName().toStdString() != "stack") { c->getZone()->getName().toStdString() != "stack")) {
cmd.set_target_zone("stack"); cmd.set_target_zone("stack");
cmd.set_x(0); cmd.set_x(0);
cmd.set_y(0); cmd.set_y(0);
@ -1784,6 +1784,7 @@ void Player::cardMenuAction()
commandList.append(cmd); commandList.append(cmd);
break; break;
} }
default: break;
} }
} }
else { else {

View file

@ -54,6 +54,7 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
searchLabel = new QLabel(); searchLabel = new QLabel();
searchEdit = new SearchLineEdit; searchEdit = new SearchLineEdit;
searchLabel->setBuddy(searchEdit); searchLabel->setBuddy(searchEdit);
searchKeySignals.filterDelete(false); searchKeySignals.filterDelete(false);
searchEdit->installEventFilter(&searchKeySignals); searchEdit->installEventFilter(&searchKeySignals);
connect(searchEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &))); connect(searchEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &)));
@ -96,7 +97,6 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
connect(&dbViewKeySignals, SIGNAL(onLeft()), this, SLOT(actDecrementCard())); connect(&dbViewKeySignals, SIGNAL(onLeft()), this, SLOT(actDecrementCard()));
connect(&dbViewKeySignals, SIGNAL(onCtrlLeft()), this, SLOT(actDecrementCardFromSideboard())); connect(&dbViewKeySignals, SIGNAL(onCtrlLeft()), this, SLOT(actDecrementCardFromSideboard()));
connect(&dbViewKeySignals, SIGNAL(onCtrlEnter()), this, SLOT(actAddCardToSideboard())); connect(&dbViewKeySignals, SIGNAL(onCtrlEnter()), this, SLOT(actAddCardToSideboard()));
searchEdit->setTreeView(databaseView); searchEdit->setTreeView(databaseView);
QVBoxLayout *leftFrame = new QVBoxLayout; QVBoxLayout *leftFrame = new QVBoxLayout;
@ -414,7 +414,7 @@ void TabDeckEditor::actLoadDeck()
return; return;
QString fileName = dialog.selectedFiles().at(0); QString fileName = dialog.selectedFiles().at(0);
DeckLoader::FileFormat fmt = DeckLoader::getFormatFromNameFilter(dialog.selectedNameFilter()); DeckLoader::FileFormat fmt = DeckLoader::getFormatFromName(fileName);
DeckLoader *l = new DeckLoader; DeckLoader *l = new DeckLoader;
if (l->loadFromFile(fileName, fmt)) if (l->loadFromFile(fileName, fmt))
@ -467,7 +467,7 @@ bool TabDeckEditor::actSaveDeckAs()
return false; return false;
QString fileName = dialog.selectedFiles().at(0); QString fileName = dialog.selectedFiles().at(0);
DeckLoader::FileFormat fmt = DeckLoader::getFormatFromNameFilter(dialog.selectedNameFilter()); DeckLoader::FileFormat fmt = DeckLoader::getFormatFromName(fileName);
if (!deckModel->getDeckList()->saveToFile(fileName, fmt)) { if (!deckModel->getDeckList()->saveToFile(fileName, fmt)) {
QMessageBox::critical(this, tr("Error"), tr("The deck could not be saved.\nPlease check that the directory is writable and try again.")); QMessageBox::critical(this, tr("Error"), tr("The deck could not be saved.\nPlease check that the directory is writable and try again."));
@ -561,7 +561,6 @@ void TabDeckEditor::addCardHelper(QString zoneName)
QModelIndex newCardIndex = deckModel->addCard(info->getName(), zoneName); QModelIndex newCardIndex = deckModel->addCard(info->getName(), zoneName);
recursiveExpand(newCardIndex); recursiveExpand(newCardIndex);
deckView->setCurrentIndex(newCardIndex); deckView->setCurrentIndex(newCardIndex);
setModified(true); setModified(true);
} }

View file

@ -79,6 +79,7 @@ private:
CardDatabaseDisplayModel *databaseDisplayModel; CardDatabaseDisplayModel *databaseDisplayModel;
DeckListModel *deckModel; DeckListModel *deckModel;
QTreeView *databaseView; QTreeView *databaseView;
KeySignals dbViewKeySignals; KeySignals dbViewKeySignals;
QTreeView *deckView; QTreeView *deckView;
KeySignals deckViewKeySignals; KeySignals deckViewKeySignals;
@ -86,6 +87,7 @@ private:
QLabel *searchLabel; QLabel *searchLabel;
SearchLineEdit *searchEdit; SearchLineEdit *searchEdit;
KeySignals searchKeySignals; KeySignals searchKeySignals;
QLabel *nameLabel; QLabel *nameLabel;
QLineEdit *nameEdit; QLineEdit *nameEdit;
QLabel *commentsLabel; QLabel *commentsLabel;

View file

@ -154,7 +154,7 @@ void DeckViewContainer::loadLocalDeck()
return; return;
QString fileName = dialog.selectedFiles().at(0); QString fileName = dialog.selectedFiles().at(0);
DeckLoader::FileFormat fmt = DeckLoader::getFormatFromNameFilter(dialog.selectedNameFilter()); DeckLoader::FileFormat fmt = DeckLoader::getFormatFromName(fileName);
DeckLoader deck; DeckLoader deck;
if (!deck.loadFromFile(fileName, fmt)) { if (!deck.loadFromFile(fileName, fmt)) {
QMessageBox::critical(this, tr("Error"), tr("The selected file could not be loaded.")); QMessageBox::critical(this, tr("Error"), tr("The selected file could not be loaded."));

View file

@ -80,6 +80,7 @@ TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent)
{ {
tabChangedIcon = new QIcon(":/resources/icon_tab_changed.svg"); tabChangedIcon = new QIcon(":/resources/icon_tab_changed.svg");
setElideMode(Qt::ElideRight); setElideMode(Qt::ElideRight);
setMovable(true);
setIconSize(QSize(15, 15)); setIconSize(QSize(15, 15));
connect(this, SIGNAL(currentChanged(int)), this, SLOT(updateCurrent(int))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(updateCurrent(int)));

View file

@ -48,5 +48,9 @@ INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
add_library(cockatrice_common ${common_SOURCES} ${common_HEADERS_MOC}) add_library(cockatrice_common ${common_SOURCES} ${common_HEADERS_MOC})
# Without this check, Linux will put -pthread out of order in link.txt and build will fail
if (UNIX)
target_link_libraries(cockatrice_common cockatrice_protocol pthread)
else (UNIX)
target_link_libraries(cockatrice_common cockatrice_protocol) target_link_libraries(cockatrice_common cockatrice_protocol)
endif (UNIX)

View file

@ -449,8 +449,12 @@ bool DeckList::loadFromStream_Plain(QTextStream &in)
line.remove(rx); line.remove(rx);
rx.setPattern("\\(.*\\)"); rx.setPattern("\\(.*\\)");
line.remove(rx); line.remove(rx);
//Filter out post card name editions
rx.setPattern("\\|.*$");
line.remove(rx);
line = line.simplified(); line = line.simplified();
int i = line.indexOf(' '); int i = line.indexOf(' ');
bool ok; bool ok;
int number = line.left(i).toInt(&ok); int number = line.left(i).toInt(&ok);

Binary file not shown.

View file

@ -195,7 +195,7 @@ Start the oracle.exe (the installer does this automatically) and let it generate
Congratulations, you may now use Cockatrice! Congratulations, you may now use Cockatrice!
\subsubsection{Linux and BSD} \subsubsection{Linux and BSD}
The following procedures have been tested with Debian Wheezy, Fedora 18 and FreeBSD 9.1. The following procedures have been tested with Debian Wheezy, Fedora 18, XUbuntu 13.10, FreeBSD 9.1 and 10.0.
If you use Gentoo with KDE you have the needed prerequisites and may continue with downloading the source. If you use Gentoo with KDE you have the needed prerequisites and may continue with downloading the source.
If you use Bodhi or Arch Linux (AUR) or another distribution that includes Cockatrice, you might install Cockatrice from the default packages -- though the package might be old, If you use Bodhi or Arch Linux (AUR) or another distribution that includes Cockatrice, you might install Cockatrice from the default packages -- though the package might be old,
so you probably should continue with this howto. so you probably should continue with this howto.
@ -204,10 +204,11 @@ Before you install new software, you should update your system. The following in
\begin{enumerate} \begin{enumerate}
\item You need to install the build tools and dependencies. This varies between the Linux distributions. \item You need to install the build tools and dependencies. This varies between the Linux distributions.
\begin{description} \begin{description}
\item[Debian, Ubuntu and spin-offs] \shellcmd{sudo apt-get install build-essential git libqt4-dev qtmobility-dev libprotobuf-dev protobuf-compiler cmake} \item[Debian, Ubuntu and spin-offs] \shellcmd{sudo apt-get install build-essential git libqt4-dev qtmobility-dev libprotobuf-dev protobuf-compiler cmake} (see note below regarding pthread)
\item[Fedora] \shellcmd{sudo yum groupinstall "Development Tools"\\ \item[Fedora] \shellcmd{sudo yum groupinstall "Development Tools"\\
yum install qt-devel qt-mobility-devel protobuf-devel protobuf-compiler cmake} yum install qt-devel qt-mobility-devel protobuf-devel protobuf-compiler cmake}
\item[FreeBSD] \shellcmd{pkg\_add -r qt4 qt4-linguist qt4-moc qt4-qmake qt4-rcc qt4-uic git cmake protobuf} \item[FreeBSD 9] \shellcmd{pkg\_add -r qt4 qt4-linguist qt4-moc qt4-qmake qt4-rcc qt4-uic git cmake protobuf}
\item[FreeBSD 10] \shellcmd{pkg install qt4 qt4-linguist qt4-moc qt4-qmake qt4-rcc qt4-uic git cmake protobuf}
\end{description} \end{description}
\item Download the sources from github via \\ \shellcmd{cd\\ git clone https://github.com/Daenyth/Cockatrice.git} \item Download the sources from github via \\ \shellcmd{cd\\ git clone https://github.com/Daenyth/Cockatrice.git}
\item To compile the sources, change into the newly created directory, create a build directory and invoke cmake:\\ \item To compile the sources, change into the newly created directory, create a build directory and invoke cmake:\\
@ -216,10 +217,12 @@ mkdir build \\
cd build \\ cd build \\
cmake ..\\ cmake ..\\
make}\\ make}\\
If you have some issues with pthread\_* add 'pthread' to the ``target\_link\_libraries'' entry in the \shellcmd{CMakeFiles.txt} in \shellcmd{Cockatrice/common}. \begin{framed}
If you have linking errors with pthread\_* add 'pthread' to the ``target\_link\_libraries'' entry in the \shellcmd{CMakeFiles.txt} in \shellcmd{Cockatrice/common}, e.g. for Xubuntu, then continue the make process.
\end{framed}
\item You may install the program into the directory \shellcmd{/usr/local} by typing \shellcmd{sudo make install} but you should also be able to start \item You may install the program into the directory \shellcmd{/usr/local} by typing \shellcmd{sudo make install} but you should also be able to start
cockatrice and the oracle from the build directory. cockatrice and the oracle from the build directory.
\item Before you start Cockatrice for the first time, run \shellcmd{oracle -dlsets} and download available cards, denn run \shellcmd{cockatrice}. \item Before you start Cockatrice for the first time, run \shellcmd{oracle -dlsets} and download available cards, then run \shellcmd{cockatrice}.
The default paths for decks, pics, cards and tokens are located in \\ \shellcmd{/home/<user>/.local/share/data/Cockatrice/Cockatrice}. The default paths for decks, pics, cards and tokens are located in \\ \shellcmd{/home/<user>/.local/share/data/Cockatrice/Cockatrice}.
\end{enumerate} \end{enumerate}
@ -233,6 +236,10 @@ The compilation works like already written above, but instead of invoking \shell
\item If you want to build the server, use:\\ \shellcmd{cmake -DWITH\_SERVER=1 ..} \item If you want to build the server, use:\\ \shellcmd{cmake -DWITH\_SERVER=1 ..}
\item If you want to build the server, but not the client, use:\\ \shellcmd{cmake -DWITH\_SERVER=1 -DWITHOUT\_CLIENT=1 ..} \item If you want to build the server, but not the client, use:\\ \shellcmd{cmake -DWITH\_SERVER=1 -DWITHOUT\_CLIENT=1 ..}
\end{itemize} \end{itemize}
Further, the server has a dependency on libgcrypt, so you need to install it as well:
\begin{description}
\item[FreeBSD 10] \shellcmd{pkg install libgcrypt}
\end{description}
There is more information on compiling and running Servatrice on CentOS 6 in chapter \ref{servatrice} on page \pageref{servatrice}. There is more information on compiling and running Servatrice on CentOS 6 in chapter \ref{servatrice} on page \pageref{servatrice}.
\section{Downloading Card Database Using the Oracle} \section{Downloading Card Database Using the Oracle}