Page 1 of 1

Setting up a dev environment in Eclipse.

PostPosted: 13 Oct 2013, 09:56
by Lodici
Hi,

Following the instructions on the wiki I have managed to import the source code into Eclipse (Juno) and have successfully run the "Run As -> Ant Build" on the "build.xml" file.

But when I try to run "MagicMain.java" it falls over with the error as shown in the attachment (sorry, it would not let me post the content directly since I am too new).

Any help would be very much appreciated.

- Lodici

Re: Setting up a dev environment in Eclipse.

PostPosted: 13 Oct 2013, 12:19
by melvin
Hi Lodici, welcome to Magarena development :D

I think that is because the program can't find the scripts, you may have to pass an additional VM argument to tell it where is the release folder, the one the contains the README.txt file. The program looks in the Magarena/scripts subfolder of the release folder to find the card scripts.

On the command line that would be a "java -Dmagarena.dir=<path to release folder> ...". On Eclipse, in the laucher configuration there should be an arguments tab. Under VM arguments add a "-Dmagarena.dir=D:\_DATA\Java\eclipse\magdev\Magarena\Magarena\release" (I'm guessing the path based on the error in error.txt)

Re: Setting up a dev environment in Eclipse.

PostPosted: 13 Oct 2013, 12:46
by Lodici
Thanks, melvin. I followed your instructions and added the VM setting and it does appear to have got a bit further but it now falls over with another error about not being able to read "Abandoned_Outpost.txt" - please see attached screen shot. Thanks again for your help.

- Lodici

Re: Setting up a dev environment in Eclipse.

PostPosted: 13 Oct 2013, 12:53
by melvin
If you look further down, the problem is in IconImages:153. We assume you're running the jar, it appears you're trying to run the MagicMain class directly, that mode of running is not supported as some of the resources are loaded from the jar such as some of the icons.

Suggestion is to configure the launcher to run the jar in release/Magarena.jar.

Re: Setting up a dev environment in Eclipse.

PostPosted: 13 Oct 2013, 13:02
by Lodici
Oh :o - does that mean it is not possible to step through the code in debug mode? I find this mode is really helpful when trying to learn new code.

-Lodici

Re: Setting up a dev environment in Eclipse.

PostPosted: 13 Oct 2013, 13:14
by melvin
Should be possible to debug using the jar as well, see http://stackoverflow.com/questions/1732 ... a-jar-file

Re: Setting up a dev environment in Eclipse.

PostPosted: 13 Oct 2013, 14:05
by Lodici
Ok, thanks for the link.

- Lodici

Re: Setting up a dev environment in Eclipse.

PostPosted: 17 Oct 2013, 13:22
by Lodici
Well I got there in the end I think and can now debug and step through the code - thanks for the link Melvin, adding a reference to the JAR in the release directory did the trick. And removing launch4j from the build path (it had errors preventing a debug build). And adding a reference to the Groovy library (downloaded when running build.xml for the first time using Ant). And learning yet another VCS! :)

I have recently come to Magarena having used Forge for a while but found myself becoming frustrated with its vastness and poor AI. The fact is I find Magarena much more streamlined and focused towards playing quick duels against a seemingly stronger AI opponent. Plus it has stats. And undo!

I have some experience with Java and a bit of spare time so would like to help out if I can. I tend to find something as I play and then have a bit of a hack at the code to see if I can bend it to my will. To which end I would like to offer my first contribution - a new option that lets you open a card image popup using the mousewheel instead of the auto-delayed popup. Please see attached which contains two patches and a combined diff (I am not sure which is required).

Hope this is useful.

- Lodici

Re: Setting up a dev environment in Eclipse.

PostPosted: 17 Oct 2013, 13:40
by ember hauler
Lodici wrote:The fact is I find Magarena much more streamlined and focused towards playing quick duels against a seemingly stronger AI opponent. Plus it has stats. And undo!
I cannot agree more, Lodici.
I've tried several Magic software apps and this far Magarena shows most promising AI with a nice bundle of useful features. I believe that's the strongest point behind this software, and developers should invest more time into AI evolution.

Lodici wrote:I have some experience with Java and a bit of spare time so would like to help out if I can.
This is wonderful! Being quite far from programming these days, I found myself a small niche with card scripting. I'm sure that by adding more talented people we could develop many more features and make Magarena even better.

Re: Setting up a dev environment in Eclipse.

PostPosted: 18 Oct 2013, 08:46
by melvin
Lodici wrote:To which end I would like to offer my first contribution - a new option that lets you open a card image popup using the mousewheel instead of the auto-delayed popup. Please see attached which contains two patches and a combined diff (I am not sure which is required).
Thanks for this contribution! This is a nice option, sometimes the auto popup can be a bit annoying.

Your patch include some changes made by eclipse automatically when it saves your changed files, such as changing from four spaces to tab (we use spaces). This makes it hard to figure out where are the actual functional changes.

Could you generate a new unified diff without these other non functional changes? The diff should be quite small and only show the lines you've changed.

Re: Setting up a dev environment in Eclipse.

PostPosted: 18 Oct 2013, 13:04
by Lodici
melvin wrote:Could you generate a new unified diff without these other non functional changes? The diff should be quite small and only show the lines you've changed.
Please find attached a revised unified diff that was created after setting the following Eclipse options -

Updated Eclipse Save Actions so that
- Organize Imports is switched off.
- Correct Indentation is switched off
- Remove unused imports is switched on.
- Remove trailing white spaces on all lines is switched on.

and updated the Code Style Formatter profile so that Indentation now uses spaces instead of tabs.

- Lodici

Re: Setting up a dev environment in Eclipse.

PostPosted: 18 Oct 2013, 14:28
by melvin
Awesome, took a quick look and it is clear where the changes are now. Will review the code and merge into master, should be in time for October's release.