It is currently 16 Apr 2024, 14:59
   
Text Size

Setting up a dev environment in Eclipse.

Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins

Setting up a dev environment in Eclipse.

Postby Lodici » 13 Oct 2013, 09:56

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
Attachments
error.txt
(624 Bytes) Downloaded 284 times
User avatar
Lodici
Programmer
 
Posts: 399
Joined: 13 Oct 2013, 09:44
Has thanked: 29 times
Been thanked: 71 times

Re: Setting up a dev environment in Eclipse.

Postby melvin » 13 Oct 2013, 12:19

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)
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Setting up a dev environment in Eclipse.

Postby Lodici » 13 Oct 2013, 12:46

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
Attachments
Untitled.png
Last edited by Lodici on 13 Oct 2013, 13:05, edited 1 time in total.
User avatar
Lodici
Programmer
 
Posts: 399
Joined: 13 Oct 2013, 09:44
Has thanked: 29 times
Been thanked: 71 times

Re: Setting up a dev environment in Eclipse.

Postby melvin » 13 Oct 2013, 12:53

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.
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Setting up a dev environment in Eclipse.

Postby Lodici » 13 Oct 2013, 13:02

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
User avatar
Lodici
Programmer
 
Posts: 399
Joined: 13 Oct 2013, 09:44
Has thanked: 29 times
Been thanked: 71 times

Re: Setting up a dev environment in Eclipse.

Postby melvin » 13 Oct 2013, 13:14

Should be possible to debug using the jar as well, see http://stackoverflow.com/questions/1732 ... a-jar-file
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Setting up a dev environment in Eclipse.

Postby Lodici » 13 Oct 2013, 14:05

Ok, thanks for the link.

- Lodici
User avatar
Lodici
Programmer
 
Posts: 399
Joined: 13 Oct 2013, 09:44
Has thanked: 29 times
Been thanked: 71 times

Re: Setting up a dev environment in Eclipse.

Postby Lodici » 17 Oct 2013, 13:22

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
Attachments
_patch.zip
(33.4 KiB) Downloaded 267 times
User avatar
Lodici
Programmer
 
Posts: 399
Joined: 13 Oct 2013, 09:44
Has thanked: 29 times
Been thanked: 71 times

Re: Setting up a dev environment in Eclipse.

Postby ember hauler » 17 Oct 2013, 13:40

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.
ember hauler
 
Posts: 79
Joined: 14 Aug 2013, 08:13
Has thanked: 27 times
Been thanked: 14 times

Re: Setting up a dev environment in Eclipse.

Postby melvin » 18 Oct 2013, 08:46

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.
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Setting up a dev environment in Eclipse.

Postby Lodici » 18 Oct 2013, 13:04

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
Attachments
mousewheel_popup.diff.txt
(12.32 KiB) Downloaded 283 times
User avatar
Lodici
Programmer
 
Posts: 399
Joined: 13 Oct 2013, 09:44
Has thanked: 29 times
Been thanked: 71 times

Re: Setting up a dev environment in Eclipse.

Postby melvin » 18 Oct 2013, 14:28

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.
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times


Return to Magarena

Who is online

Users browsing this forum: No registered users and 22 guests


Who is online

In total there are 22 users online :: 0 registered, 0 hidden and 22 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 22 guests

Login Form