Merge remote-tracking branch 'upstream/master'

This commit is contained in:
woogerboy21 2014-07-01 10:23:50 -04:00
commit ba1e1d33d8
35 changed files with 311 additions and 170 deletions

10
.travis.yml Normal file
View file

@ -0,0 +1,10 @@
language: cpp
os:
- linux
- osx
compiler:
- gcc
- clang
script: mkdir build && cd build && cmake .. -DWITH_SERVER=1 && make
install: ./travis-dependencies.sh
cache: apt

View file

@ -59,7 +59,7 @@ IF(MSVC)
ELSEIF (CMAKE_COMPILER_IS_GNUCXX) ELSEIF (CMAKE_COMPILER_IS_GNUCXX)
# linux/gcc, bsd/gcc, windows/mingw # linux/gcc, bsd/gcc, windows/mingw
set(CMAKE_CXX_FLAGS_RELEASE "-s -O2") set(CMAKE_CXX_FLAGS_RELEASE "-s -O2")
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -O0") set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -O0 -Wall -Wextra -pedantic -Werror -Wcast-align -Wmissing-declarations -Winline -Wno-long-long -Wno-error=extra -Wno-error=unused-parameter -Wno-inline -Wno-error=delete-non-virtual-dtor -Wno-error=sign-compare -Wno-error=reorder -Wno-error=missing-declarations")
ELSE() ELSE()
# other: osx/llvm, bsd/llvm # other: osx/llvm, bsd/llvm
set(CMAKE_CXX_FLAGS_RELEASE "-O2") set(CMAKE_CXX_FLAGS_RELEASE "-O2")
@ -79,11 +79,51 @@ set(CMAKE_AUTOMOC TRUE)
# Find other needed libraries # Find other needed libraries
FIND_PACKAGE(Protobuf REQUIRED) FIND_PACKAGE(Protobuf REQUIRED)
# Package builder
set(CPACK_PACKAGE_CONTACT "Daenyth+github@gmail.com")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR "Cockatrice Development Team")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
if(UNIX)
if(APPLE)
set(CPACK_GENERATOR DragNDrop ${CPACK_GENERATOR})
set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_FORMAT "UDBZ")
set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}")
set(CPACK_SYSTEM_NAME "OSX")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/cockatrice/resources/appicon.icns")
else()
# linux
set(CPACK_GENERATOR DEB ${CPACK_GENERATOR})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}/${PROJECT_VERSION}")
set(CPACK_STRIP_FILES "bin/${PROJECT_NAME}")
set(CPACK_SOURCE_STRIP_FILES "")
endif()
elseif(WIN32)
set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}\\\\${PROJECT_VERSION}")
set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\${PROJECT_NAME}.exe")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
set(CPACK_NSIS_HELP_LINK "https://github.com/Daenyth/Cockatrice")
set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/Daenyth/Cockatrice")
set(CPACK_NSIS_CONTACT "Daenyth+github@gmail.com")
set(CPACK_NSIS_MODIFY_PATH ON)
endif()
include(CPack)
# Compile servatrice (default off) # Compile servatrice (default off)
option(WITH_SERVER "build servatrice" OFF) option(WITH_SERVER "build servatrice" OFF)
add_subdirectory(common) add_subdirectory(common)
if(WITH_SERVER) if(WITH_SERVER)
add_subdirectory(servatrice) add_subdirectory(servatrice)
SET(CPACK_INSTALL_CMAKE_PROJECTS "servatrice;servatrice;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS})
endif() endif()
# Compile cockatrice (default on) # Compile cockatrice (default on)
@ -92,10 +132,12 @@ if(WITH_CLIENT)
add_subdirectory(cockatrice) add_subdirectory(cockatrice)
add_subdirectory(sounds) add_subdirectory(sounds)
add_subdirectory(zonebg) add_subdirectory(zonebg)
SET(CPACK_INSTALL_CMAKE_PROJECTS "cockatrice;cockatrice;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS})
endif() endif()
# Compile oracle (default on) # Compile oracle (default on)
option(WITH_ORACLE "build oracle" ON) option(WITH_ORACLE "build oracle" ON)
if(WITH_ORACLE) if(WITH_ORACLE)
add_subdirectory(oracle) add_subdirectory(oracle)
SET(CPACK_INSTALL_CMAKE_PROJECTS "release/oracle.app;oracle;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS})
endif() endif()

View file

@ -1,5 +1,7 @@
# Cockatrice # Cockatrice
[![Build Status](https://travis-ci.org/Daenyth/Cockatrice.svg?branch=master)](https://travis-ci.org/Daenyth/Cockatrice)
Cockatrice is an open-source multiplatform software for playing card games, Cockatrice is an open-source multiplatform software for playing card games,
such as Magic: The Gathering, over a network. It is fully client-server based such as Magic: The Gathering, over a network. It is fully client-server based
to prevent any kind of cheating, though it supports single-player games without to prevent any kind of cheating, though it supports single-player games without

View file

@ -126,6 +126,7 @@ if(APPLE)
ENDIF(APPLE) ENDIF(APPLE)
if (NOT QT_QTMULTIMEDIA_FOUND) if (NOT QT_QTMULTIMEDIA_FOUND)
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
FIND_PACKAGE(QtMobility REQUIRED) FIND_PACKAGE(QtMobility REQUIRED)
endif (NOT QT_QTMULTIMEDIA_FOUND) endif (NOT QT_QTMULTIMEDIA_FOUND)
@ -183,8 +184,9 @@ add_custom_command(
) )
if(APPLE) if(APPLE)
set(plugin_dest_dir ./cockatrice.app/Contents/Plugins) # these needs to be relative to CMAKE_INSTALL_PREFIX
set(qtconf_dest_dir ./cockatrice.app/Contents/Resources) set(plugin_dest_dir cockatrice.app/Contents/Plugins)
set(qtconf_dest_dir cockatrice.app/Contents/Resources)
# note: no codecs in qt5 # note: no codecs in qt5
# note: phonon_backend => mediaservice # note: phonon_backend => mediaservice
@ -199,13 +201,16 @@ if(APPLE)
endif() endif()
install(CODE " install(CODE "
file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins\") Plugins = Plugins
" COMPONENT Runtime) Translations = Resources/translations
Data = Resources\")
" COMPONENT Runtime)
install(CODE " install(CODE "
file(GLOB_RECURSE QTPLUGINS file(GLOB_RECURSE QTPLUGINS
\"${plugin_dest_dir}/*.dylib\") \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\")
set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
" COMPONENT Runtime) " COMPONENT Runtime)

View file

@ -31,7 +31,7 @@ enum ClientStatus {
StatusConnecting, StatusConnecting,
StatusAwaitingWelcome, StatusAwaitingWelcome,
StatusLoggingIn, StatusLoggingIn,
StatusLoggedIn, StatusLoggedIn
}; };
class AbstractClient : public QObject { class AbstractClient : public QObject {

View file

@ -14,6 +14,7 @@ enum GraphicsItemType {
class AbstractGraphicsItem : public QObject, public QGraphicsItem { class AbstractGraphicsItem : public QObject, public QGraphicsItem {
Q_OBJECT Q_OBJECT
Q_INTERFACES(QGraphicsItem)
protected: protected:
void paintNumberEllipse(int number, int radius, const QColor &color, int position, int count, QPainter *painter); void paintNumberEllipse(int number, int radius, const QColor &color, int position, int count, QPainter *painter);
public: public:

View file

@ -16,13 +16,7 @@
const int CardDatabase::versionNeeded = 3; const int CardDatabase::versionNeeded = 3;
CardSet::CardSet(const QString &_shortName, const QString &_longName) static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set)
: shortName(_shortName), longName(_longName)
{
updateSortKey();
}
QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set)
{ {
xml.writeStartElement("set"); xml.writeStartElement("set");
xml.writeTextElement("name", set->getShortName()); xml.writeTextElement("name", set->getShortName());
@ -32,6 +26,24 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardSet *set)
return xml; return xml;
} }
CardSet::CardSet(const QString &_shortName, const QString &_longName)
: shortName(_shortName), longName(_longName)
{
updateSortKey();
}
QString CardSet::getCorrectedShortName() const
{
// Because windows is horrible.
QSet<QString> invalidFileNames;
invalidFileNames << "CON" << "PRN" << "AUX" << "NUL" << "COM1" << "COM2" <<
"COM3" << "COM4" << "COM5" << "COM6" << "COM7" << "COM8" << "COM9" <<
"LPT1" << "LPT2" << "LPT3" << "LPT4" << "LPT5" << "LPT6" << "LPT7" <<
"LPT8" << "LPT9";
return invalidFileNames.contains(shortName) ? shortName + "_" : shortName;
}
void CardSet::setSortKey(unsigned int _sortKey) void CardSet::setSortKey(unsigned int _sortKey)
{ {
sortKey = _sortKey; sortKey = _sortKey;
@ -132,7 +144,7 @@ void PictureLoader::processLoadQueue()
} }
continue; continue;
} }
emit imageLoaded(ptl.getCard(), image); emit imageLoaded(ptl.getCard(), image);
} }
} }
@ -169,13 +181,17 @@ void PictureLoader::startNextPicDownload()
QUrl url(picUrl); QUrl url(picUrl);
QNetworkRequest req(url); QNetworkRequest req(url);
qDebug() << "starting picture download:" << req.url(); qDebug() << "starting picture download:" << cardBeingDownloaded.getCard()->getName() << "Url:" << req.url();
networkManager->get(req); networkManager->get(req);
} }
void PictureLoader::picDownloadFinished(QNetworkReply *reply) void PictureLoader::picDownloadFinished(QNetworkReply *reply)
{ {
QString picsPath = _picsPath; QString picsPath = _picsPath;
if (reply->error()) {
qDebug() << "Download failed:" << reply->errorString();
}
const QByteArray &picData = reply->readAll(); const QByteArray &picData = reply->readAll();
QImage testImage; QImage testImage;
if (testImage.loadFromData(picData)) { if (testImage.loadFromData(picData)) {
@ -189,17 +205,17 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
QDir dir(QString(picsPath + "/downloadedPics")); QDir dir(QString(picsPath + "/downloadedPics"));
dir.mkdir(cardBeingDownloaded.getSetName()); dir.mkdir(cardBeingDownloaded.getSetName());
} }
QString suffix; QString suffix;
if (!cardBeingDownloaded.getStripped()) if (!cardBeingDownloaded.getStripped())
suffix = ".full"; suffix = ".full";
QFile newPic(picsPath + "/downloadedPics/" + cardBeingDownloaded.getSetName() + "/" + cardBeingDownloaded.getCard()->getCorrectedName() + suffix + ".jpg"); QFile newPic(picsPath + "/downloadedPics/" + cardBeingDownloaded.getSetName() + "/" + cardBeingDownloaded.getCard()->getCorrectedName() + suffix + ".jpg");
if (!newPic.open(QIODevice::WriteOnly)) if (!newPic.open(QIODevice::WriteOnly))
return; return;
newPic.write(picData); newPic.write(picData);
newPic.close(); newPic.close();
emit imageLoaded(cardBeingDownloaded.getCard(), testImage); emit imageLoaded(cardBeingDownloaded.getCard(), testImage);
} else if (cardBeingDownloaded.getHq()) { } else if (cardBeingDownloaded.getHq()) {
qDebug() << "HQ: received invalid picture. URL:" << reply->request().url(); qDebug() << "HQ: received invalid picture. URL:" << reply->request().url();
@ -216,7 +232,7 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
} else } else
emit imageLoaded(cardBeingDownloaded.getCard(), QImage()); emit imageLoaded(cardBeingDownloaded.getCard(), QImage());
} }
reply->deleteLater(); reply->deleteLater();
startNextPicDownload(); startNextPicDownload();
} }
@ -224,7 +240,7 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
void PictureLoader::loadImage(CardInfo *card, bool stripped) void PictureLoader::loadImage(CardInfo *card, bool stripped)
{ {
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
loadQueue.append(PictureToLoad(card, stripped)); loadQueue.append(PictureToLoad(card, stripped));
emit startLoadQueue(); emit startLoadQueue();
} }
@ -259,18 +275,18 @@ CardInfo::CardInfo(CardDatabase *_db,
bool _cipt, bool _cipt,
int _tableRow, int _tableRow,
const SetList &_sets, const SetList &_sets,
QMap<QString, int> _muIds) MuidMap _muIds)
: db(_db), : db(_db),
name(_name), name(_name),
isToken(_isToken), isToken(_isToken),
sets(_sets), sets(_sets),
muIds(_muIds),
manacost(_manacost), manacost(_manacost),
cardtype(_cardtype), cardtype(_cardtype),
powtough(_powtough), powtough(_powtough),
text(_text), text(_text),
colors(_colors), colors(_colors),
loyalty(_loyalty), loyalty(_loyalty),
muIds(_muIds),
cipt(_cipt), cipt(_cipt),
tableRow(_tableRow), tableRow(_tableRow),
pixmap(NULL) pixmap(NULL)
@ -418,7 +434,7 @@ int CardInfo::getPreferredMuId()
return muIds[getPreferredSet()->getShortName()]; return muIds[getPreferredSet()->getShortName()];
} }
QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info) static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
{ {
xml.writeStartElement("card"); xml.writeStartElement("card");
xml.writeTextElement("name", info->getName()); xml.writeTextElement("name", info->getName());
@ -457,7 +473,7 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
} }
CardDatabase::CardDatabase(QObject *parent) CardDatabase::CardDatabase(QObject *parent)
: QObject(parent), loadStatus(NotLoaded), noCard(0) : QObject(parent), noCard(0), loadStatus(NotLoaded)
{ {
connect(settingsCache, SIGNAL(picsPathChanged()), this, SLOT(picsPathChanged())); connect(settingsCache, SIGNAL(picsPathChanged()), this, SLOT(picsPathChanged()));
connect(settingsCache, SIGNAL(cardDatabasePathChanged()), this, SLOT(loadCardDatabase())); connect(settingsCache, SIGNAL(cardDatabasePathChanged()), this, SLOT(loadCardDatabase()));
@ -594,7 +610,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
if (xml.name() == "card") { if (xml.name() == "card") {
QString name, manacost, type, pt, text; QString name, manacost, type, pt, text;
QStringList colors; QStringList colors;
QMap<QString, int> muids; MuidMap muids;
SetList sets; SetList sets;
int tableRow = 0; int tableRow = 0;
int loyalty = 0; int loyalty = 0;

View file

@ -20,12 +20,16 @@ class QNetworkRequest;
typedef QMap<QString, QString> QStringMap; typedef QMap<QString, QString> QStringMap;
// If we don't typedef this, CardInfo::CardInfo will refuse to compile on OS X < 10.9
typedef QMap<QString, int> MuidMap;
class CardSet : public QList<CardInfo *> { class CardSet : public QList<CardInfo *> {
private: private:
QString shortName, longName; QString shortName, longName;
unsigned int sortKey; unsigned int sortKey;
public: public:
CardSet(const QString &_shortName = QString(), const QString &_longName = QString()); CardSet(const QString &_shortName = QString(), const QString &_longName = QString());
QString getCorrectedShortName() const;
QString getShortName() const { return shortName; } QString getShortName() const { return shortName; }
QString getLongName() const { return longName; } QString getLongName() const { return longName; }
int getSortKey() const { return sortKey; } int getSortKey() const { return sortKey; }
@ -51,12 +55,10 @@ public:
PictureToLoad(CardInfo *_card = 0, bool _stripped = false, bool _hq = true); PictureToLoad(CardInfo *_card = 0, bool _stripped = false, bool _hq = true);
CardInfo *getCard() const { return card; } CardInfo *getCard() const { return card; }
bool getStripped() const { return stripped; } bool getStripped() const { return stripped; }
QString getSetName() const { return sortedSets[setIndex]->getShortName(); } QString getSetName() const { return sortedSets[setIndex]->getCorrectedShortName(); }
bool nextSet(); bool nextSet();
bool getHq() const { return hq; } bool getHq() const { return hq; }
void setHq(bool _hq) { hq = _hq; } void setHq(bool _hq) { hq = _hq; }
}; };
class PictureLoader : public QObject { class PictureLoader : public QObject {
@ -101,7 +103,7 @@ private:
QString text; QString text;
QStringList colors; QStringList colors;
int loyalty; int loyalty;
QMap<QString, int> muIds; MuidMap muIds;
bool cipt; bool cipt;
int tableRow; int tableRow;
QPixmap *pixmap; QPixmap *pixmap;
@ -119,7 +121,7 @@ public:
bool _cipt = false, bool _cipt = false,
int _tableRow = 0, int _tableRow = 0,
const SetList &_sets = SetList(), const SetList &_sets = SetList(),
QMap<QString, int> muids = QMap<QString, int>()); MuidMap muids = MuidMap());
~CardInfo(); ~CardInfo();
const QString &getName() const { return name; } const QString &getName() const { return name; }
bool getIsToken() const { return isToken; } bool getIsToken() const { return isToken; }

View file

@ -26,9 +26,9 @@ public:
}; };
private: private:
QString trm;
enum Type t; enum Type t;
enum Attr a; enum Attr a;
QString trm;
public: public:
CardFilter(QString term, Type type, Attr attr) : trm(term), t(type), a(attr) {}; CardFilter(QString term, Type type, Attr attr) : trm(term), t(type), a(attr) {};

View file

@ -1,5 +1,6 @@
#include <QStringList> #include <QStringList>
#include <QFile> #include <QFile>
#include <QDebug>
#include "deck_loader.h" #include "deck_loader.h"
#include "decklist.h" #include "decklist.h"
@ -44,18 +45,28 @@ bool DeckLoader::loadFromFile(const QString &fileName, FileFormat fmt)
QFile file(fileName); QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return false; return false;
bool result = false; bool result = false;
switch (fmt) { switch (fmt) {
case PlainTextFormat: result = loadFromFile_Plain(&file); break; case PlainTextFormat: result = loadFromFile_Plain(&file); break;
case CockatriceFormat: result = loadFromFile_Native(&file); break; case CockatriceFormat:
result = loadFromFile_Native(&file);
qDebug() << "Loaded from" << fileName << "-" << result;
if (!result) {
qDebug() << "Retying as plain format";
file.seek(0);
result = loadFromFile_Plain(&file);
fmt = PlainTextFormat;
}
break;
} }
if (result) { if (result) {
lastFileName = fileName; lastFileName = fileName;
lastFileFormat = fmt; lastFileFormat = fmt;
emit deckLoaded(); emit deckLoaded();
} }
qDebug() << "Deck was loaded -" << result;
return result; return result;
} }
@ -66,7 +77,7 @@ bool DeckLoader::loadFromRemote(const QString &nativeString, int remoteDeckId)
lastFileName = QString(); lastFileName = QString();
lastFileFormat = CockatriceFormat; lastFileFormat = CockatriceFormat;
lastRemoteDeckId = remoteDeckId; lastRemoteDeckId = remoteDeckId;
emit deckLoaded(); emit deckLoaded();
} }
return result; return result;

View file

@ -340,6 +340,9 @@ void DeckListModel::sort(int column, Qt::SortOrder order)
break; break;
case 2: case 2:
sortMethod = ByPrice; sortMethod = ByPrice;
break;
default:
sortMethod = ByName;
} }
root->setSortMethod(sortMethod); root->setSortMethod(sortMethod);
sortHelper(root, order); sortHelper(root, order);

View file

@ -66,7 +66,7 @@ public:
const CardFilter::Attr attr; const CardFilter::Attr attr;
LogicMap(CardFilter::Attr a, FilterTree *parent) LogicMap(CardFilter::Attr a, FilterTree *parent)
: attr(a), p(parent) {} : p(parent), attr(a) {}
const FilterItemList *findTypeList(CardFilter::Type type) const; const FilterItemList *findTypeList(CardFilter::Type type) const;
FilterItemList *typeList(CardFilter::Type type); FilterItemList *typeList(CardFilter::Type type);
FilterTreeNode *parent() const; FilterTreeNode *parent() const;
@ -81,7 +81,7 @@ public:
const CardFilter::Type type; const CardFilter::Type type;
FilterItemList(CardFilter::Type t, LogicMap *parent) FilterItemList(CardFilter::Type t, LogicMap *parent)
: type(t), p(parent) {} : p(parent), type(t) {}
CardFilter::Attr attr() const { return p->attr; } CardFilter::Attr attr() const { return p->attr; }
FilterTreeNode *parent() const { return p; } FilterTreeNode *parent() const { return p; }
int termIndex(const QString &term) const; int termIndex(const QString &term) const;

View file

@ -55,7 +55,7 @@ QString translationPath = TRANSLATION_PATH;
QString translationPath = QString(); QString translationPath = QString();
#endif #endif
void myMessageOutput(QtMsgType /*type*/, const char *msg) static void myMessageOutput(QtMsgType /*type*/, const char *msg)
{ {
QFile file("qdebug.txt"); QFile file("qdebug.txt");
file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text); file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
@ -88,15 +88,6 @@ int main(int argc, char *argv[])
if (app.arguments().contains("--debug-output")) if (app.arguments().contains("--debug-output"))
qInstallMsgHandler(myMessageOutput); qInstallMsgHandler(myMessageOutput);
#ifdef Q_OS_MAC
QDir baseDir(app.applicationDirPath());
baseDir.cdUp();
baseDir.cdUp();
baseDir.cdUp();
QDir pluginsDir = baseDir;
pluginsDir.cd("PlugIns");
app.addLibraryPath(pluginsDir.absolutePath());
#endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
app.addLibraryPath(app.applicationDirPath() + "/plugins"); app.addLibraryPath(app.applicationDirPath() + "/plugins");
#endif #endif
@ -108,11 +99,8 @@ int main(int argc, char *argv[])
if (translationPath.isEmpty()) { if (translationPath.isEmpty()) {
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
QDir translationsDir = baseDir; translationPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
translationsDir.cd("translations"); #elif defined(Q_OS_WIN)
translationPath = translationsDir.absolutePath();
#endif
#ifdef Q_OS_WIN
translationPath = app.applicationDirPath() + "/translations"; translationPath = app.applicationDirPath() + "/translations";
#endif #endif
} }
@ -145,6 +133,43 @@ int main(int argc, char *argv[])
QDir().mkpath(dataDir + "/pics"); QDir().mkpath(dataDir + "/pics");
settingsCache->setPicsPath(dataDir + "/pics"); settingsCache->setPicsPath(dataDir + "/pics");
} }
#ifdef Q_OS_MAC
if(settingsCache->getHandBgPath().isEmpty() &&
settingsCache->getStackBgPath().isEmpty() &&
settingsCache->getTableBgPath().isEmpty() &&
settingsCache->getPlayerBgPath().isEmpty())
{
QString srcDir = QLibraryInfo::location(QLibraryInfo::DataPath);
QString destDir = dataDir + "/zonebg";
QDir tmpDir(destDir);
if(!tmpDir.exists())
{
// try to install the default images for the current user and set the settigs value
settingsCache->copyPath(srcDir + "/zonebg", destDir);
settingsCache->setHandBgPath(destDir + "/fabric_green.png");
settingsCache->setStackBgPath(destDir + "/fabric_red.png");
settingsCache->setTableBgPath(destDir + "/fabric_blue.png");
settingsCache->setPlayerBgPath(destDir + "/fabric_gray.png");
}
}
if(settingsCache->getSoundPath().isEmpty())
{
QString srcDir = QLibraryInfo::location(QLibraryInfo::DataPath);
QString destDir = dataDir + "/sounds";
QDir tmpDir(destDir);
if(!tmpDir.exists())
{
// try to install the default sounds for the current user and set the settigs value
settingsCache->copyPath(srcDir + "/sounds", destDir);
settingsCache->setSoundPath(destDir);
}
}
#endif
if (!settingsValid() || db->getLoadStatus() != Ok) { if (!settingsValid() || db->getLoadStatus() != Ok) {
qDebug("main(): invalid settings or load status"); qDebug("main(): invalid settings or load status");
DlgSettings dlgSettings; DlgSettings dlgSettings;

View file

@ -13,4 +13,6 @@ extern QString translationPath;
void installNewTranslator(); void installNewTranslator();
bool settingsValid();
#endif #endif

View file

@ -86,12 +86,16 @@ void MessageLogWidget::logLeaveSpectator(QString name)
appendHtml(tr("%1 is not watching the game any more.").arg(sanitizeHtml(name))); appendHtml(tr("%1 is not watching the game any more.").arg(sanitizeHtml(name)));
} }
void MessageLogWidget::logDeckSelect(Player *player, QString deckHash) void MessageLogWidget::logDeckSelect(Player *player, QString deckHash, int sideboardSize)
{ {
if (isFemale(player)) const char* gender = isFemale(player) ? "female" : "male";
appendHtml(tr("%1 has loaded a deck (%2).", "female").arg(sanitizeHtml(player->getName())).arg(deckHash)); if (sideboardSize < 0)
appendHtml(tr("%1 has loaded a deck (%2).", gender).arg(sanitizeHtml(player->getName())).arg(deckHash));
else else
appendHtml(tr("%1 has loaded a deck (%2).", "male").arg(sanitizeHtml(player->getName())).arg(deckHash)); appendHtml(tr("%1 has loaded a deck with %2 sideboard cards (%3).", gender).
arg(sanitizeHtml(player->getName())).
arg(sideboardSize).
arg(deckHash));
} }
void MessageLogWidget::logReadyStart(Player *player) void MessageLogWidget::logReadyStart(Player *player)

View file

@ -48,7 +48,7 @@ public slots:
void logKicked(); void logKicked();
void logJoinSpectator(QString name); void logJoinSpectator(QString name);
void logLeaveSpectator(QString name); void logLeaveSpectator(QString name);
void logDeckSelect(Player *player, QString deckHash); void logDeckSelect(Player *player, QString deckHash, int sideboardSize);
void logReadyStart(Player *player); void logReadyStart(Player *player);
void logNotReadyStart(Player *player); void logNotReadyStart(Player *player);
void logSetSideboardLock(Player *player, bool locked); void logSetSideboardLock(Player *player, bool locked);

View file

@ -15,7 +15,7 @@ RemoteClient::RemoteClient(QObject *parent)
: AbstractClient(parent), timeRunning(0), lastDataReceived(0), messageInProgress(false), handshakeStarted(false), messageLength(0) : AbstractClient(parent), timeRunning(0), lastDataReceived(0), messageInProgress(false), handshakeStarted(false), messageLength(0)
{ {
timer = new QTimer(this); timer = new QTimer(this);
timer->setInterval(1000); timer->setInterval(9000);
connect(timer, SIGNAL(timeout()), this, SLOT(ping())); connect(timer, SIGNAL(timeout()), this, SLOT(ping()));
socket = new QTcpSocket(this); socket = new QTcpSocket(this);
@ -23,7 +23,7 @@ RemoteClient::RemoteClient(QObject *parent)
connect(socket, SIGNAL(connected()), this, SLOT(slotConnected())); connect(socket, SIGNAL(connected()), this, SLOT(slotConnected()));
connect(socket, SIGNAL(readyRead()), this, SLOT(readData())); connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError)));
connect(this, SIGNAL(serverIdentificationEventReceived(const Event_ServerIdentification &)), this, SLOT(processServerIdentificationEvent(const Event_ServerIdentification &))); connect(this, SIGNAL(serverIdentificationEventReceived(const Event_ServerIdentification &)), this, SLOT(processServerIdentificationEvent(const Event_ServerIdentification &)));
connect(this, SIGNAL(connectionClosedEventReceived(Event_ConnectionClosed)), this, SLOT(processConnectionClosedEvent(Event_ConnectionClosed))); connect(this, SIGNAL(connectionClosedEventReceived(Event_ConnectionClosed)), this, SLOT(processConnectionClosedEvent(Event_ConnectionClosed)));
connect(this, SIGNAL(sigConnectToServer(QString, unsigned int, QString, QString)), this, SLOT(doConnectToServer(QString, unsigned int, QString, QString))); connect(this, SIGNAL(sigConnectToServer(QString, unsigned int, QString, QString)), this, SLOT(doConnectToServer(QString, unsigned int, QString, QString)));
@ -47,12 +47,12 @@ void RemoteClient::slotConnected()
{ {
timeRunning = lastDataReceived = 0; timeRunning = lastDataReceived = 0;
timer->start(); timer->start();
// dirty hack to be compatible with v14 server // dirty hack to be compatible with v14 server
sendCommandContainer(CommandContainer()); sendCommandContainer(CommandContainer());
getNewCmdId(); getNewCmdId();
// end of hack // end of hack
setStatus(StatusAwaitingWelcome); setStatus(StatusAwaitingWelcome);
} }
@ -208,7 +208,7 @@ void RemoteClient::ping()
pend->deleteLater(); pend->deleteLater();
} }
} }
int maxTime = timeRunning - lastDataReceived; int maxTime = timeRunning - lastDataReceived;
emit maxPingTime(maxTime, maxTimeout); emit maxPingTime(maxTime, maxTimeout);
if (maxTime >= maxTimeout) { if (maxTime >= maxTimeout) {

View file

@ -1,5 +1,7 @@
#include "settingscache.h" #include "settingscache.h"
#include <QSettings> #include <QSettings>
#include <QDebug>
#include <QDir>
SettingsCache::SettingsCache() SettingsCache::SettingsCache()
{ {
@ -257,3 +259,31 @@ void SettingsCache::setMainWindowGeometry(const QByteArray &_mainWindowGeometry)
mainWindowGeometry = _mainWindowGeometry; mainWindowGeometry = _mainWindowGeometry;
settings->setValue("interface/main_window_geometry", mainWindowGeometry); settings->setValue("interface/main_window_geometry", mainWindowGeometry);
} }
void SettingsCache::copyPath(const QString &src, const QString &dst)
{
// test source && return if inexistent
QDir dir(src);
if (! dir.exists())
return;
// test destination && create if inexistent
QDir tmpDir(dst);
if (!tmpDir.exists())
{
tmpDir.setPath(QDir::rootPath());
if (!tmpDir.mkdir(dst) && !tmpDir.exists()) {
// TODO: this is probably not good.
qDebug() << "copyPath(): Failed to create dir: " << dst;
}
}
foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
QString dst_path = dst + QDir::separator() + d;
dir.mkpath(dst_path);
copyPath(src+ QDir::separator() + d, dst_path);
}
foreach (QString f, dir.entryList(QDir::Files)) {
QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f);
}
}

View file

@ -90,6 +90,7 @@ public:
bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; } bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; }
QString getPicUrl() const { return picUrl; } QString getPicUrl() const { return picUrl; }
QString getPicUrlHq() const { return picUrlHq; } QString getPicUrlHq() const { return picUrlHq; }
void copyPath(const QString &src, const QString &dst);
public slots: public slots:
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry); void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
void setLang(const QString &_lang); void setLang(const QString &_lang);

View file

@ -1012,7 +1012,10 @@ void TabGame::eventPlayerPropertiesChanged(const Event_PlayerPropertiesChanged &
break; break;
} }
case GameEventContext::DECK_SELECT: { case GameEventContext::DECK_SELECT: {
messageLog->logDeckSelect(player, QString::fromStdString(context.GetExtension(Context_DeckSelect::ext).deck_hash())); Context_DeckSelect deckSelect = context.GetExtension(Context_DeckSelect::ext);
messageLog->logDeckSelect(player,
QString::fromStdString(deckSelect.deck_hash()),
deckSelect.sideboard_size());
break; break;
} }
case GameEventContext::SET_SIDEBOARD_LOCK: { case GameEventContext::SET_SIDEBOARD_LOCK: {

View file

@ -2,6 +2,7 @@
#include <QTextStream> #include <QTextStream>
#include <QVariant> #include <QVariant>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QDebug>
#include "decklist.h" #include "decklist.h"
SideboardPlan::SideboardPlan(const QString &_name, const QList<MoveCard_ToZone> &_moveList) SideboardPlan::SideboardPlan(const QString &_name, const QList<MoveCard_ToZone> &_moveList)
@ -179,6 +180,7 @@ bool InnerDecklistNode::compare(AbstractDecklistNode *other) const
case 2: case 2:
return comparePrice(other); return comparePrice(other);
} }
return 0;
} }
bool InnerDecklistNode::compareNumber(AbstractDecklistNode *other) const bool InnerDecklistNode::compareNumber(AbstractDecklistNode *other) const
@ -225,6 +227,7 @@ bool AbstractDecklistCardNode::compare(AbstractDecklistNode *other) const
case ByPrice: case ByPrice:
return compareTotalPrice(other); return compareTotalPrice(other);
} }
return 0;
} }
bool AbstractDecklistCardNode::compareNumber(AbstractDecklistNode *other) const bool AbstractDecklistCardNode::compareNumber(AbstractDecklistNode *other) const
@ -350,6 +353,7 @@ DeckList::DeckList()
root = new InnerDecklistNode; root = new InnerDecklistNode;
} }
// TODO: http://qt-project.org/doc/qt-4.8/qobject.html#no-copy-constructor-or-assignment-operator
DeckList::DeckList(const DeckList &other) DeckList::DeckList(const DeckList &other)
: name(other.name), : name(other.name),
comments(other.comments), comments(other.comments),
@ -441,6 +445,11 @@ void DeckList::write(QXmlStreamWriter *xml)
bool DeckList::loadFromXml(QXmlStreamReader *xml) bool DeckList::loadFromXml(QXmlStreamReader *xml)
{ {
if (xml->error()) {
qDebug() << "Error loading deck from xml: " << xml->errorString();
return false;
}
cleanList(); cleanList();
while (!xml->atEnd()) { while (!xml->atEnd()) {
xml->readNext(); xml->readNext();
@ -455,6 +464,10 @@ bool DeckList::loadFromXml(QXmlStreamReader *xml)
} }
} }
updateDeckHash(); updateDeckHash();
if (xml->error()) {
qDebug() << "Error loading deck from xml: " << xml->errorString();
return false;
}
return true; return true;
} }
@ -477,8 +490,7 @@ QString DeckList::writeToString_Native()
bool DeckList::loadFromFile_Native(QIODevice *device) bool DeckList::loadFromFile_Native(QIODevice *device)
{ {
QXmlStreamReader xml(device); QXmlStreamReader xml(device);
loadFromXml(&xml); return loadFromXml(&xml);
return true;
} }
bool DeckList::saveToFile_Native(QIODevice *device) bool DeckList::saveToFile_Native(QIODevice *device)
@ -496,7 +508,7 @@ bool DeckList::saveToFile_Native(QIODevice *device)
bool DeckList::loadFromStream_Plain(QTextStream &in) bool DeckList::loadFromStream_Plain(QTextStream &in)
{ {
cleanList(); cleanList();
InnerDecklistNode *main = 0, *side = 0; InnerDecklistNode *main = 0, *side = 0;
bool inSideboard = false; bool inSideboard = false;
@ -530,7 +542,7 @@ 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 //Filter out post card name editions
rx.setPattern("\\|.*$"); rx.setPattern("\\|.*$");
line.remove(rx); line.remove(rx);
line = line.simplified(); line = line.simplified();
@ -543,10 +555,10 @@ bool DeckList::loadFromStream_Plain(QTextStream &in)
continue; continue;
QString cardName = line.mid(i + 1); QString cardName = line.mid(i + 1);
// Common differences between cockatrice's card names // Common differences between cockatrice's card names
// and what's commonly used in decklists // and what's commonly used in decklists
rx.setPattern(""); rx.setPattern("");
cardName.replace(rx, "'"); cardName.replace(rx, "'");
rx.setPattern("Æ"); rx.setPattern("Æ");
cardName.replace(rx, "AE"); cardName.replace(rx, "AE");
rx.setPattern("^Aether"); rx.setPattern("^Aether");
@ -621,12 +633,27 @@ QStringList DeckList::getCardList() const
return result.toList(); return result.toList();
} }
int DeckList::getSideboardSize() const
{
int size = 0;
for (int i = 0; i < root->size(); ++i) {
InnerDecklistNode *node = dynamic_cast<InnerDecklistNode *>(root->at(i));
if (node->getName() != "side")
continue;
for (int j = 0; j < node->size(); j++) {
DecklistCardNode *card = dynamic_cast<DecklistCardNode *>(node->at(j));
size += card->getNumber();
}
}
return size;
}
DecklistCardNode *DeckList::addCard(const QString &cardName, const QString &zoneName) DecklistCardNode *DeckList::addCard(const QString &cardName, const QString &zoneName)
{ {
InnerDecklistNode *zoneNode = dynamic_cast<InnerDecklistNode *>(root->findChild(zoneName)); InnerDecklistNode *zoneNode = dynamic_cast<InnerDecklistNode *>(root->findChild(zoneName));
if (!zoneNode) if (!zoneNode)
zoneNode = new InnerDecklistNode(zoneName, root); zoneNode = new InnerDecklistNode(zoneName, root);
DecklistCardNode *node = new DecklistCardNode(cardName, 1, zoneNode); DecklistCardNode *node = new DecklistCardNode(cardName, 1, zoneNode);
updateDeckHash(); updateDeckHash();
return node; return node;

View file

@ -160,7 +160,9 @@ public:
void cleanList(); void cleanList();
bool isEmpty() const { return root->isEmpty() && name.isEmpty() && comments.isEmpty() && sideboardPlans.isEmpty(); } bool isEmpty() const { return root->isEmpty() && name.isEmpty() && comments.isEmpty() && sideboardPlans.isEmpty(); }
QStringList getCardList() const; QStringList getCardList() const;
int getSideboardSize() const;
QString getDeckHash() const { return deckHash; } QString getDeckHash() const { return deckHash; }
void updateDeckHash(); void updateDeckHash();

View file

@ -1,8 +1,9 @@
import "game_event_context.proto"; import "game_event_context.proto";
message Context_DeckSelect { message Context_DeckSelect {
extend GameEventContext { extend GameEventContext {
optional Context_DeckSelect ext = 1002; optional Context_DeckSelect ext = 1002;
} }
optional string deck_hash = 1; optional string deck_hash = 1;
optional int32 sideboard_size = 2 [default = -1];
} }

View file

@ -657,6 +657,7 @@ Response::ResponseCode Server_Player::cmdDeckSelect(const Command_DeckSelect &cm
Context_DeckSelect context; Context_DeckSelect context;
context.set_deck_hash(deck->getDeckHash().toStdString()); context.set_deck_hash(deck->getDeckHash().toStdString());
context.set_sideboard_size(deck->getSideboardSize());
ges.setGameEventContext(context); ges.setGameEventContext(context);
Response_DeckDownload *re = new Response_DeckDownload; Response_DeckDownload *re = new Response_DeckDownload;

View file

@ -64,7 +64,7 @@ void GameEventStorage::sendToGame(Server_Game *game)
} }
ResponseContainer::ResponseContainer(int _cmdId) ResponseContainer::ResponseContainer(int _cmdId)
: responseExtension(0), cmdId(_cmdId) : cmdId(_cmdId), responseExtension(0)
{ {
} }

Binary file not shown.

View file

@ -1,7 +1,7 @@
!include "MUI2.nsh" !include "MUI2.nsh"
!include "FileFunc.nsh" !include "FileFunc.nsh"
!define /date TIMESTAMP "%Y%m%d" !define /date TIMESTAMP "%Y%m%d"
!searchparse /file ../build/cockatrice/version_string.cpp '= "' VERSION '";' !searchparse /file ../build/cockatrice/version_string.cpp '= "' VERSION '";'
Name "Cockatrice" Name "Cockatrice"
@ -52,7 +52,7 @@ Section "Application" SecApplication
SetOutPath "$INSTDIR\zonebg" SetOutPath "$INSTDIR\zonebg"
File /r ..\zonebg\*.* File /r ..\zonebg\*.*
SetOutPath "$INSTDIR\plugins" SetOutPath "$INSTDIR\plugins"
SetOutPath "$INSTDIR\plugins\codecs" SetOutPath "$INSTDIR\plugins\codecs"
File "${QTDIR}\plugins\codecs\qcncodecs4.dll" File "${QTDIR}\plugins\codecs\qcncodecs4.dll"
@ -67,7 +67,7 @@ Section "Application" SecApplication
SetOutPath "$INSTDIR\sounds" SetOutPath "$INSTDIR\sounds"
File /r ..\sounds\*.* File /r ..\sounds\*.*
SetOutPath "$INSTDIR\translations" SetOutPath "$INSTDIR\translations"
File /r ..\build\cockatrice\*.qm File /r ..\build\cockatrice\*.qm
@ -83,15 +83,15 @@ Section "Application" SecApplication
SectionEnd SectionEnd
Section "Update configuration" SecUpdateConfig Section "Update configuration" SecUpdateConfig
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$INSTDIR\cards.xml" WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$APPDATA\Cockatrice\cards.xml"
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$INSTDIR\decks" WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$APPDATA\Cockatrice\decks"
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$INSTDIR\pics" WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$APPDATA\Cockatrice\pics"
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$INSTDIR\sounds" WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$APPDATA\Cockatrice\sounds"
SectionEnd SectionEnd
Section "Start menu item" SecStartMenu Section "Start menu item" SecStartMenu
createDirectory "$SMPROGRAMS\Cockatrice" createDirectory "$SMPROGRAMS\Cockatrice"
createShortCut "$SMPROGRAMS\Cockatrice\Cockatrice.lnk" "$INSTDIR\cockatrice.exe" createShortCut "$SMPROGRAMS\Cockatrice\Cockatrice.lnk" "$INSTDIR\cockatrice.exe" '--debug-output'
createShortCut "$SMPROGRAMS\Cockatrice\Oracle.lnk" "$INSTDIR\oracle.exe" createShortCut "$SMPROGRAMS\Cockatrice\Oracle.lnk" "$INSTDIR\oracle.exe"
createShortCut "$SMPROGRAMS\Cockatrice\Usermanual.lnk" "$INSTDIR\Usermanual.pdf" createShortCut "$SMPROGRAMS\Cockatrice\Usermanual.lnk" "$INSTDIR\Usermanual.pdf"
SectionEnd SectionEnd
@ -115,7 +115,7 @@ SetShellVarContext all
Delete "$INSTDIR\QtMultimedia4.dll" Delete "$INSTDIR\QtMultimedia4.dll"
RMDir "$INSTDIR" RMDir "$INSTDIR"
RMDir /r "$SMPROGRAMS\Cockatrice" RMDir "$SMPROGRAMS\Cockatrice"
DeleteRegKey HKCU "Software\Cockatrice" DeleteRegKey HKCU "Software\Cockatrice"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice"

View file

@ -48,8 +48,9 @@ IF (NOT WIN32 AND NOT APPLE)
ENDIF (NOT WIN32 AND NOT APPLE) ENDIF (NOT WIN32 AND NOT APPLE)
if(APPLE) if(APPLE)
set(plugin_dest_dir ./oracle.app/Contents/Plugins) # these needs to be relative to CMAKE_INSTALL_PREFIX
set(qtconf_dest_dir ./oracle.app/Contents/Resources) set(plugin_dest_dir oracle.app/Contents/Plugins)
set(qtconf_dest_dir oracle.app/Contents/Resources)
# note: no codecs in qt5 # note: no codecs in qt5
# note: phonon_backend => mediaservice # note: phonon_backend => mediaservice
@ -64,13 +65,15 @@ if(APPLE)
endif() endif()
install(CODE " install(CODE "
file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins\") Plugins = Plugins
" COMPONENT Runtime) Translations = Resources/translations\")
" COMPONENT Runtime)
install(CODE " install(CODE "
file(GLOB_RECURSE QTPLUGINS file(GLOB_RECURSE QTPLUGINS
\"${plugin_dest_dir}/*.dylib\") \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\")
set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/oracle.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/oracle.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
" COMPONENT Runtime) " COMPONENT Runtime)

View file

@ -197,6 +197,11 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
cardText = map.contains("text") ? map.value("text").toString() : QString(""); cardText = map.contains("text") ? map.value("text").toString() : QString("");
cardId = map.contains("multiverseid") ? map.value("multiverseid").toInt() : 0; cardId = map.contains("multiverseid") ? map.value("multiverseid").toInt() : 0;
cardLoyalty = map.contains("loyalty") ? map.value("loyalty").toInt() : 0; cardLoyalty = map.contains("loyalty") ? map.value("loyalty").toInt() : 0;
// Distinguish Vanguard cards from regular cards of the same name.
if (map.value("layout") == "vanguard") {
cardName += " Avatar";
}
} }
CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, cardCost, cardType, cardPT, cardLoyalty, cardText.split("\n")); CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, cardCost, cardType, cardPT, cardLoyalty, cardText.split("\n"));

View file

@ -17,7 +17,7 @@ public:
bool getImport() const { return import; } bool getImport() const { return import; }
void setImport(bool _import) { import = _import; } void setImport(bool _import) { import = _import; }
SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, bool _import) SetToDownload(const QString &_shortName, const QString &_longName, const QVariant &_cards, bool _import)
: shortName(_shortName), longName(_longName), cards(_cards), import(_import) { } : shortName(_shortName), longName(_longName), import(_import), cards(_cards) { }
bool operator<(const SetToDownload &set) const { return longName.compare(set.longName, Qt::CaseInsensitive) < 0; } bool operator<(const SetToDownload &set) const { return longName.compare(set.longName, Qt::CaseInsensitive) < 0; }
}; };

View file

@ -1,67 +0,0 @@
#!/bin/sh
FRAMEWORKS="Core Gui Multimedia Network Svg Xml"
DATE=`date '+%Y%m%d'`
#QTDIR="/Users/brukie/QtSDK/Desktop/Qt/474/gcc"
QTLIB="/Users/brukie/qt_leopard/lib"
QTPLUGINS="/Users/brukie/qt_leopard/plugins"
PROTOBUF="/Users/brukie/protobuf_leopard"
DIR=cockatrice_mac_$DATE
if [ -d $DIR ]; then echo "delete old dir first"; exit 1; fi
mkdir $DIR
cp -R build/cockatrice/cockatrice.app $DIR
cp -R build/oracle/oracle.app $DIR
mkdir $DIR/Frameworks
cp -R sounds zonebg $DIR
mkdir $DIR/translations
cp build/cockatrice/*.qm $DIR/translations
cp -R $QTPLUGINS $DIR/PlugIns
for f in $FRAMEWORKS; do
cp -R $QTLIB/Qt"$f".framework $DIR/Frameworks
done
find $DIR/Frameworks -name '*debug*'|xargs -n 1 rm -f
find $DIR/Frameworks -name 'Headers'|xargs -n 1 rm -rf
find $DIR/PlugIns -name '*debug*'|xargs -n 1 rm -f
cp $PROTOBUF/lib/libprotobuf.7.dylib $DIR/Frameworks
cd $DIR
for f in $FRAMEWORKS; do
echo "Framework $f"
echo "step 1"
install_name_tool -id @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" Frameworks/Qt"$f".framework/Versions/4/Qt"$f"
for g in $FRAMEWORKS; do
install_name_tool -change $QTLIB/Qt"$f".framework/Versions/4/Qt"$f" @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" Frameworks/Qt"$g".framework/Versions/4/Qt"$g"
done
echo "step 2"
for g in cockatrice oracle; do
install_name_tool -change $QTLIB/Qt"$f".framework/Versions/4/Qt"$f" @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" "$g".app/Contents/MacOS/$g
done
echo "step 3"
for g in `find . -name '*.dylib'`; do
install_name_tool -change $QTLIB/Qt"$f".framework/Versions/4/Qt"$f" @executable_path/../../../Frameworks/Qt"$f".framework/Versions/4/Qt"$f" "$g"
done
done
install_name_tool -id @executable_path/../../../libprotobuf.7.dylib Frameworks/libprotobuf.7.dylib
install_name_tool -change $PROTOBUF/lib/libprotobuf.7.dylib @executable_path/../../../Frameworks/libprotobuf.7.dylib cockatrice.app/Contents/MacOS/cockatrice
cd ..
VOL=cockatrice_mac_${DATE}
DMG="tmp-$VOL.dmg"
SIZE=`du -sk $DIR | cut -f1`
SIZE=$((${SIZE}/1000+10))
hdiutil create "$DMG" -megabytes ${SIZE} -ov -type UDIF -fs HFS+ -volname "$VOL"
hdid "$DMG"
cp -R "${DIR}" "/Volumes/$VOL"
hdiutil detach "/Volumes/$VOL"
#osascript -e "tell application "Finder" to eject disk "$VOL"" &&
# convert to compressed image, delete temp image
rm -f "${VOL}.dmg"
hdiutil convert "$DMG" -format UDZO -o "${VOL}.dmg"
rm -f "$DMG"

View file

@ -55,8 +55,9 @@ elseif(WIN32)
endif() endif()
if(APPLE) if(APPLE)
set(plugin_dest_dir ./servatrice.app/Contents/Plugins) # these needs to be relative to CMAKE_INSTALL_PREFIX
set(qtconf_dest_dir ./servatrice.app/Contents/Resources) set(plugin_dest_dir servatrice.app/Contents/Plugins)
set(qtconf_dest_dir servatrice.app/Contents/Resources)
# note: no codecs in qt5 # note: no codecs in qt5
# note: phonon_backend => mediaservice # note: phonon_backend => mediaservice
@ -71,13 +72,15 @@ if(APPLE)
endif() endif()
install(CODE " install(CODE "
file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
Plugins = Plugins\") Plugins = Plugins
Translations = Resources/translations\")
" COMPONENT Runtime) " COMPONENT Runtime)
install(CODE " install(CODE "
file(GLOB_RECURSE QTPLUGINS file(GLOB_RECURSE QTPLUGINS
\"${plugin_dest_dir}/*.dylib\") \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\")
set(BU_CHMOD_BUNDLE_ITEMS ON)
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
" COMPONENT Runtime) " COMPONENT Runtime)

View file

@ -6,7 +6,7 @@ FILE(GLOB sounds "${CMAKE_CURRENT_SOURCE_DIR}/*.raw")
if(UNIX) if(UNIX)
if(APPLE) if(APPLE)
INSTALL(FILES ${sounds} DESTINATION sounds/) INSTALL(FILES ${sounds} DESTINATION cockatrice.app/Contents/Resources/sounds/)
else() else()
# Assume linux # Assume linux
INSTALL(FILES ${sounds} DESTINATION share/cockatrice/sounds/) INSTALL(FILES ${sounds} DESTINATION share/cockatrice/sounds/)

9
travis-dependencies.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
if [[ $TRAVIS_OS_NAME == "osx" ]] ; then
brew update
brew install qt cmake protobuf libgcrypt
else
sudo apt-get update -qq
sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev
fi

View file

@ -2,11 +2,11 @@
# #
# Installs default "zone background" files # Installs default "zone background" files
FILE(GLOB zonebg "${CMAKE_CURRENT_SOURCE_DIR}/*.*") FILE(GLOB zonebg "${CMAKE_CURRENT_SOURCE_DIR}/*.png" "${CMAKE_CURRENT_SOURCE_DIR}/*.jpg")
if(UNIX) if(UNIX)
if(APPLE) if(APPLE)
INSTALL(FILES ${zonebg} DESTINATION zonebg/) INSTALL(FILES ${zonebg} DESTINATION cockatrice.app/Contents/Resources/zonebg/)
else() else()
# Assume linux # Assume linux
INSTALL(FILES ${zonebg} DESTINATION share/cockatrice/zonebg/) INSTALL(FILES ${zonebg} DESTINATION share/cockatrice/zonebg/)