Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added some mac specific paths to files

  • Loading branch information...
commit e2369190f350591a58a319cbdfd65aa221b66f3e 1 parent 4fd765b
@lamperi authored
View
3  src/Teambuilder/Teambuilder.pro
@@ -72,3 +72,6 @@ TRANSLATIONS = translation_de.ts \
translation_zh-cn.ts
RC_FILE = myapp.rc
RESOURCES +=
+macx {
+ LIBS += -framework CoreFoundation
+}
View
3  src/Teambuilder/basebattlewindow.cpp
@@ -264,6 +264,9 @@ void BaseBattleWindow::checkAndSaveLog()
n2 = n2.replace(c, ' ');
}
+ if(!QDir::home().exists(s.value("battle_logs_directory").toString())) {
+ QDir::home().mkpath(s.value("battle_logs_directory").toString());
+ }
QString file = s.value("battle_logs_directory").toString() + n1 + " vs " + n2 + "--" + QDate::currentDate().toString("dd MMMM yyyy")
+ " at " +QTime::currentTime().toString("hh'h'mm") + ".html";
QFile out (file);
View
21 src/Teambuilder/box.cpp
@@ -328,8 +328,15 @@ void PokemonBox::save()
slot.appendChild(pokemons[i]->poke->toXml());
}
}
-
- QFile out(QString("Boxes/Box %1.box").arg(QChar('A'+getNum())));
+#if defined(Q_OS_MAC)
+ QString boxpath = QString(QDir::homePath() + "/Library/Application Support/Pokemon Online/Boxes");
+ if(!QDir::home().exists(boxpath)) {
+ QDir::home().mkpath(boxpath);
+ }
+#else
+ QString boxpath = QString("Boxes");
+#endif
+ QFile out(QString(boxpath + "/Box %1.box").arg(QChar('A'+getNum())));
out.open(QIODevice::WriteOnly);
QTextStream str(&out);
doc.save(str,4);
@@ -339,7 +346,15 @@ void PokemonBox::load()
{
QDomDocument doc;
- QFile in(QString("Boxes/Box %1.box").arg(QChar('A'+getNum())));
+#if defined(Q_OS_MAC)
+ QString boxpath = QString(QDir::homePath() + "/Library/Application Support/Pokemon Online/Boxes");
+ if(!QDir::home().exists(boxpath)) {
+ QDir::home().mkpath(boxpath);
+ }
+#else
+ QString boxpath = QString("Boxes");
+#endif
+ QFile in(QString(boxpath + "/Box %1.box").arg(QChar('A'+getNum())));
in.open(QIODevice::ReadOnly);
if(!doc.setContent(&in))
View
17 src/Teambuilder/main.cpp
@@ -14,6 +14,12 @@
#include <iostream>
#include <ctime>
+#ifdef Q_OS_MACX
+#include <CoreFoundation/CFURL.h>
+#include <CoreFoundation/CFBundle.h>
+#endif
+
+
void myMessageOutput(QtMsgType type, const char *msg)
{
switch (type) {
@@ -39,6 +45,17 @@ int main(int argc, char *argv[])
freopen("stdout.txt", "a", stderr);
qInstallMsgHandler(myMessageOutput);
#endif
+#ifdef Q_OS_MACX
+ // On Mac, switch working directory to resources folder
+ CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
+ CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef, kCFURLPOSIXPathStyle);
+ QString path( CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding()) );
+ path += "/Contents/Resources";
+ QDir::setCurrent( path );
+ CFRelease(pluginRef);
+ CFRelease(macPath);
+#endif
+
srand(time(NULL));
try
{
View
8 src/Teambuilder/mainwindow.cpp
@@ -21,11 +21,15 @@ MainEngine::MainEngine() : displayer(0)
settings.setValue("stylesheet", "db/default.css");
}
-
+#ifdef Q_OS_MACX
+ setDefaultValue("team_location", QDir::homePath() + "/Documents/trainer.tp");
+ setDefaultValue("battle_logs_directory", QDir::homePath() + "/Documents/Pokemon-Online Logs/");
+#else
setDefaultValue("team_location", "Team/trainer.tp");
- setDefaultValue("save_battle_logs", false);
setDefaultValue("battle_logs_directory", "Logs/");
+#endif
setDefaultValue("battle_music_directory", "Music/Battle/");
+ setDefaultValue("save_battle_logs", false);
setDefaultValue("play_battle_music", false);
setDefaultValue("play_battle_sounds", false);
setDefaultValue("show_team",true);
Please sign in to comment.
Something went wrong with that request. Please try again.