supertriodo / Arena-Tracker

Arena Tracker is a deck tracker that gives you a lot of extra info while playing Hearthstone.
GNU General Public License v2.0
293 stars 33 forks source link

Build on OS X #1

Closed thibaudgg closed 9 years ago

thibaudgg commented 9 years ago

Hey,

I tried to build your project on OS X (10.10.5) with QT Creator 3.5 and opencv 2.4.12 (installed with HomeBrew) but when I try to build I got this issue:

:-1: error: opencv development package not found

I added already /usr/local/bin in PATH on Project Build Environment and opencv is listed via pkg-config:

pkg-config --list-all | grep opencv
opencv              OpenCV - Open Source Computer Vision Library

What am I missing?

screen shot 2015-09-25 at 13 33 20

Thanks for your help!

supertriodo commented 9 years ago

I don't see anything wrong. It seem as it is not listed in pkgconfig but as you checked is already there.

thibaudgg commented 9 years ago

Hey thanks for the answer!

So following this solution, I added to QT_CONFIG -= no-pkg-config to the .pro file and was able to build (yeah!) but after I got a lot of weird stuff:

screen shot 2015-09-25 at 15 15 55

Do you plan do provide an OS X build app at some point? :smile:

supertriodo commented 9 years ago

There is some kind of problem with the #defines I have created in deckcard.h for the different colors used.

Do you know c++ to touch a little of code? Try removing the #define for the colors and change the color name every time the compiler complains for the expression at the rigth of the #define. There is no much I can do without a mac to try it out. In Linux everything compiles without a warning.

About the mac os binary question, I would like to make one but apple has put a lot of effort to make sure nobody without a mac can do it...

thibaudgg commented 9 years ago

Thanks that was really helpful.

So I change colors definition like that:

#define GREEN QColor(200,250,200)
#define LIMEGREEN QColor(50,205,50)
#define RED QColor(255,0,0)
#define YELLOW QColor(255,255,0)
#define WHITE QColor(255,255,255)
#define BLACK QColor(0,0,0)
#define BLUE QColor(0,191,255)
#define VIOLET QColor(186,85,211)
#define ORANGE QColor(255,165,0)
#define TRANSPARENT QColor(0,0,0,0)
#define CARD_SIZE QSize(218,35)

And was able to build & run once I modified the /Users/Thibaud/Qt/5.5/clang_64/mkspecs/macx-clang/qmake.conf with QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.10 here, yeah!

So after launching the app from the build dir (and move the HSCards folder to the build dir) I was able to start a new Arena from the menu (after having pick the Paladin in Hearthstone) but now I got that endlessly in the app log pane:

File: ERROR:Saving card image to disk. Make sure HSCards dir is in the same place as the exe.

I've updated the permissions on the build folder & the HSCardsfolder just in case but it doesn't fix it. Any other ideas?

Thanks again!

PS: Should I launch the Hearthstone app in full screen?

supertriodo commented 9 years ago

Ok, great!

Did You choose hero in ArenaTracker for the draft and ArenaTracker helped you through the draft with hearthArena rankings?

If the answer is I chose the hero but ArenaTracker didn't help me with the drafting, then HSCards wasn't found. Try what I say in the rest of the message. If the answer is I chose the hero and ArenaTracker helped me with the draft, then HSCards was found and there is some kind of weird problem with writting new files in that dir for the images of the cards.

That's a common error. It means the app cannot find HSCard dir that should be in the same place the executable is. But you already know this from what I have read in your comment.

If you run the app from qt creator the executable is run from a build dir (different from where the sources are). You have to make sure wherever the binary is the HSCards dir have to be. Try to find the binary. Checking your first screenshot I can see your build dir where the binary will be is: USER/Downloads/build-ArenaTracker-Desktop_Qt_5_5_0_clang_64bits_release/ Move HSCards there.

Another thing to take into account: If you create a shortcut to the binary in your desktop then you will have to have an HSCards dir in your desktop too. To make things more clear HSCards have to be in the context from which the app was launched.

PS: You can launch hs in fullscreen or windowed as you wish. But if you choose fullscreen you won't be able to see ArenaTracker unless you have it in another monitor.

thibaudgg commented 9 years ago

Did You choose hero in ArenaTracker for the draft and ArenaTracker helped you through the draft with hearthArena rankings?

I tried, but each time I got the same issue with the HSCards dir.

If you run the app from qt creator the executable is run from a build dir (different from where the sources are). You have to make sure wherever the binary is the HSCards dir have to be. Try to find the binary. Checking your first screenshot I can see your build dir where the binary will be is: USER/Downloads/build-ArenaTracker-Desktop_Qt_5_5_0_clang_64bits_release/ Move HSCards there.

It's exactly what I did. I moved HSCards to the build folder and launched the ArenaTracker.app from there. But I still got the issue. :'(

My folder structure:

screen shot 2015-09-26 at 15 19 25

Would it be possible to check the presence of the folder and create it if not already present? Any other ideas? :smile:

Thanks, I think we're almost there!

supertriodo commented 9 years ago

I could create the dir but you should still have to move those 2 png files inside.

Try adding those 4 last lines to the first function of mainwindow.cpp so it looks like the following:

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent, Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint),
    ui(new Ui::MainWindow)
{
    QFontDatabase::addApplicationFont(":Fonts/hsFont.ttf");
    ui->setupUi(this);

    webUploader = NULL;//NULL indica que estamos leyendo el old log (primera lectura)
    atLogFile = NULL;
    isMainWindow = true;
    otherWindow = NULL;

    createLogFile();
    readSettings();
    completeUI();
    initCardsJson();

    createCardDownloader();
    createSecretsHandler();
    createDeckHandler();
    createDraftHandler();
    createEnemyHandHandler();
    createArenaHandler();
    createGameWatcher();
    createLogLoader();

    QFileInfo dir("./HSCards");
    if(!dir.isDir())        pLog("Settings: HSCards found on " + dir.absolutePath() + " is not a directory.");
    else if(dir.exists())   pLog("Settings: HSCards dir found on " + dir.absolutePath());
    else                    pLog("Settings: HSCards dir not found on " + dir.absolutePath() + " Move the directory there.");
}

I guess the code is pretty much self explanatory :) It will add a message in log tab with the result and will show the absolute path where the dir should be found. If the path is correct and HSCards is already there I can write more tests for writing image files.

P.S: Can you post the text of log tab after running the app? P.S2: You don't need to play arena to test the app. If you have the last code (I commit it on 24 sept), it also works in constructed, tavern brawl or solo play.

thibaudgg commented 9 years ago

Interesting, so I get: Settings: HSCards found on / is not a directory. and the message is the same if I have the directory or not in the app folder. It's weird as there's no HSCard found on / (not writable on OS X). Is the ./HSCards link cross-platform?

supertriodo commented 9 years ago

Try:

    QFileInfo dir("HSCards");

    if(!dir.isDir())        pLog("Settings: " + dir.absoluteFilePath() + " is not a directory.");
    else if(dir.exists())   pLog("Settings: HSCards dir found on " + dir.absoluteFilePath());
    else                    pLog("Settings: HSCards dir not found on " + dir.absoluteFilePath() + " Move the directory there.");

It will probably work.

thibaudgg commented 9 years ago

Mmm still not Settings: /HSCards is not a directory., the full log:

File: ERROR:Creating Arena Tracker log on disk. Make sure HSCards dir is in the same place as the exe.
Settings: Path Player.log: /Users/Thibaud/Library/Logs/Unity/Player.log
Settings: Path log.config: /Users/Thibaud/Library/Preferences/Blizzard/Hearthstone/log.config
Log: Log found.
Settings: /HSCards is not a directory.
Log: New game.
Log: New game.
Log: New game.
Web: Arena mastery sign up success.

Maybe the application path need to set somewhere else?

thibaudgg commented 9 years ago

If I create this dir on /HSCards I get Settings: HSCards dir found on /HSCards but if I try to launch an arena File: ERROR:Saving card image to disk. Make sure HSCards dir is in the same place as the exe.... so dir(...) seems to access the root folder (/), not what we want right?

supertriodo commented 9 years ago

The context where the app is run should be the directory where the .app is. But somehow, the context is the root folder. Let me ask google and search a little.

supertriodo commented 9 years ago

Try adding at the bottom:

pLog("Settings: Current path: " + QDir::currentPath());
pLog("Settings: Application path: " + QCoreApplication::applicationDirPath());

There seems to be a bug with some MAC versions https://forum.qt.io/topic/33440/qdir-currentpath-osx-10-9-mavericks-bug/4

thibaudgg commented 9 years ago

I get:

Settings: Current path: /
Settings: Application path: /Users/Thibaud/Downloads/build-ArenaTracker-Desktop_Qt_5_5_0_clang_64bit-Release/ArenaTracker.app/Contents/MacOS

So as mentioned in the forum, the following should return the dir of the App:

@QDir dir = QCoreApplication::applicationDirPath();
dir.cdUp();
dir.cdUp();
supertriodo commented 9 years ago

Yes. Well we did it XD.

Before I make the proper changes, try:

QDir dir = QCoreApplication::applicationDirPath();
dir.cdUp();
dir.cdUp();
dir.cdUp();
pLog("Settings: Application path: " +  dir.absolutePath());

I think we need 3 cdUps to get to the dir where the binary is.

I'll make the changes in the code and I will commit them. I'll tell you when is ready. Probably tomorrow.

thibaudgg commented 9 years ago

Yup 3 ups seems to work: Settings: Application path: /Users/Thibaud/Downloads/build-ArenaTracker-Desktop_Qt_5_5_0_clang_64bit-Release.

PS: I just rename dir to dir2 as dir was already define as QFileInfo.

supertriodo commented 9 years ago

Ok, great, I'll tell you when the changes are done.

supertriodo commented 9 years ago

Done. Download the latest code and see if everything works. (You will have to change the #define again).

thibaudgg commented 9 years ago

@supertriodo awesome it works, I was able to do an Arena draft without entering manually each card name, awesome! :heart_eyes:

PR open with all changes required!

supertriodo commented 9 years ago

Great, thanks for making the process easier for next mac users :)

If you find something you would like to see different or think of any nice feature for the app. Share it in ArenaTracker reddit or here.

Also if at some point you feel brave enough to make a static compilation in mac I'd add it to the releases.

Welcome aboard!

ovidiusoft commented 8 years ago

Anyone who successfully built on Mac cares to share the build?

thibaudgg commented 8 years ago

@ovidiusoft sure, you can give a try to https://dl.dropboxusercontent.com/u/5668347/ArenaTracker.zip

supertriodo commented 8 years ago

I don't think that will work without making a static compiled binary with qt and opencv included.

I mean you still will have to compile it after installing opencv and qt.

thibaudgg commented 8 years ago

@supertriodo

I tried to rebuild from master and I got the following error:

screen shot 2015-12-09 at 20 10 09

supertriodo commented 8 years ago

Strange we already solved the color macros problem...

thibaudgg commented 8 years ago

@supertriodo yup :-/

supertriodo commented 8 years ago

Are you sure you have the latest code? I don't see that line in arenahandler.cpp:306

supertriodo commented 8 years ago

It's the exact same line as in the first screenshot you send me:

https://cloud.githubusercontent.com/assets/1322/10101329/578ae208-6398-11e5-9380-225a0f9bc12a.png

It seems like you are compiling a very old version that doesn't have the MACROS of color in deckcard.h fixed

thibaudgg commented 8 years ago

@supertriodo correct, sorry my fork wasn't updated from this repo. Your master still works fine for me!

supertriodo commented 8 years ago

Great