diff --git a/cockatrice/cockatrice.pro b/cockatrice/cockatrice.pro index 6faeeff7..9e96e64c 100644 --- a/cockatrice/cockatrice.pro +++ b/cockatrice/cockatrice.pro @@ -118,4 +118,5 @@ win32 { macx { ICON = resources/appicon.icns CONFIG += x86 ppc + LIBS += -bind_at_load } diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index 4d162883..ae399f19 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -492,15 +492,19 @@ void CardDatabase::picDownloadChanged() } } -bool CardDatabase::loadCardDatabase() +bool CardDatabase::loadCardDatabase(const QString &path) { - QString cardDatabasePath = settingsCache->getCardDatabasePath(); - if (!cardDatabasePath.isEmpty()) - loadSuccess = loadFromFile(cardDatabasePath); + if (!path.isEmpty()) + loadSuccess = loadFromFile(path); else loadSuccess = false; return loadSuccess; } +bool CardDatabase::loadCardDatabase() +{ + return loadCardDatabase(settingsCache->getCardDatabasePath()); +} + QStringList CardDatabase::getAllColors() const { QSet colors; diff --git a/cockatrice/src/carddatabase.h b/cockatrice/src/carddatabase.h index 65fa44cd..ecb36f09 100644 --- a/cockatrice/src/carddatabase.h +++ b/cockatrice/src/carddatabase.h @@ -121,9 +121,10 @@ public: bool getLoadSuccess() const { return loadSuccess; } public slots: void clearPixmapCache(); + bool loadCardDatabase(const QString &path); + bool loadCardDatabase(); private slots: void picDownloadFinished(QNetworkReply *reply); - bool loadCardDatabase(); void picDownloadChanged(); }; diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index 2cb0e3f1..a8f4bdee 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -56,7 +56,18 @@ int main(int argc, char *argv[]) { // qInstallMsgHandler(myMessageOutput); QApplication app(argc, argv); +#ifdef Q_OS_MAC + QDir baseDir(app.applicationDirPath()); + baseDir.cdUp(); + QDir pluginsDir = baseDir; + pluginsDir.cd("PlugIns"); + app.addLibraryPath(pluginsDir.absolutePath()); + baseDir.cdUp(); + baseDir.cdUp(); +#endif +#ifdef Q_OS_WIN app.addLibraryPath(app.applicationDirPath() + "/plugins"); +#endif QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QCoreApplication::setOrganizationName("Cockatrice"); @@ -83,6 +94,15 @@ int main(int argc, char *argv[]) qsrand(QDateTime::currentDateTime().toTime_t()); bool startMainProgram = true; +#ifdef Q_OS_MAC + if (!db->getLoadSuccess()) + if (db->loadCardDatabase(baseDir.absolutePath() + "/cards.xml")) + settingsCache->setCardDatabasePath(baseDir.absolutePath() + "/cards.xml"); + if (!QDir(settingsCache->getDeckPath()).exists()) + settingsCache->setDeckPath(baseDir.absolutePath() + "/decks"); + if (!QDir(settingsCache->getPicsPath()).exists()) + settingsCache->setPicsPath(baseDir.absolutePath() + "/pics"); +#endif if (!db->getLoadSuccess() || !QDir(settingsCache->getDeckPath()).exists() || !QDir(settingsCache->getPicsPath()).exists()) { DlgSettings dlgSettings; dlgSettings.show(); diff --git a/oracle/oracle.pro b/oracle/oracle.pro index dcd3ea27..b42fd347 100644 --- a/oracle/oracle.pro +++ b/oracle/oracle.pro @@ -8,3 +8,8 @@ QT += network svg xml HEADERS += src/oracleimporter.h src/window_main.h ../cockatrice/src/carddatabase.h ../cockatrice/src/settingscache.h SOURCES += src/main.cpp src/oracleimporter.cpp src/window_main.cpp ../cockatrice/src/carddatabase.cpp ../cockatrice/src/settingscache.cpp + +macx { + CONFIG += x86 ppc + LIBS += -bind_at_load +} diff --git a/oracle/src/window_main.cpp b/oracle/src/window_main.cpp index de792192..4907cf3b 100644 --- a/oracle/src/window_main.cpp +++ b/oracle/src/window_main.cpp @@ -9,7 +9,13 @@ const QString WindowMain::defaultSetsUrl = QString("http://www.cockatrice.de/fil WindowMain::WindowMain(QWidget *parent) : QMainWindow(parent) { - importer = new OracleImporter(qApp->applicationDirPath(), this); + QDir dataDir(qApp->applicationDirPath()); +#ifdef Q_OS_MAC + dataDir.cdUp(); + dataDir.cdUp(); + dataDir.cdUp(); +#endif + importer = new OracleImporter(dataDir.absolutePath(), this); nam = new QNetworkAccessManager(this); checkBoxLayout = new QVBoxLayout;