Create account / Log in

Adding a Custom Class

Discussion area for the development team.

Moderators: Tim M, uckelman

Re: Adding a Custom Class

Postby drimmer » November 20th, 2019, 7:33 pm

Malnorma wrote:As zgrose said, but the exact name of the class (package + class name) should match the directory structure too. You can't pick the name afterwards without changing the source.

So if you have:
Code: Select all
package WingLeader;
class Buttons { ... }

then you need to use the path WingLeader/Buttons.class


Thanks for your continuing help on this. I had to step away from it for a few days and work on some other stuff. But I hope to crunch this problem now.

I have added the Buttons.java file to my module using 7-Zip.

When I show the properties for Buttons.java, I get the following:

Name: WingLeader\
Path: C:\Users\dougr_000\Documents\Programming Documents\almodule\WL v4 LAYER TEST.zip

When I look within the Buttons.java file, I see

package WingLeader;

import VASSAL.build.AbstractConfigurable;
import VASSAL.build.Buildable;
import VASSAL.build.GameModule;
. . . .

That all seems to line up properly.

When I rename the .zip file to .vmod and then try and edit the module in VASSAL, I continue to get a file not found error relating to buttons.class.

I have now tried taking a compiled version of Buttons, named Buttons.class, and adding that directly to the .vmod file using 7-Zip.

Again, it all appears to have the right path and names, but I get the same class not found error.

What other information would be helpful to you?
Doug
drimmer
 
Posts: 31
Joined: May 21st, 2014, 4:48 pm

Re: Adding a Custom Class

Postby Malnorma » November 20th, 2019, 11:46 pm

It's not clear to me if you've included the folder in the zip file, but you do need to - put your Buttons.class file in a folder called WingLeader, and then drag the WingLeader folder to the module in 7-zip.
Malnorma
 
Posts: 124
Joined: October 14th, 2015, 9:26 am

Re: Adding a Custom Class

Postby drimmer » November 21st, 2019, 3:47 pm

Malnorma wrote:It's not clear to me if you've included the folder in the zip file, but you do need to - put your Buttons.class file in a folder called WingLeader, and then drag the WingLeader folder to the module in 7-zip.


Yes, I had done. I created the folder WingLeader in 7-Zip then dragged Buttons.class into the folder in 7-Zip.

7zip.PNG
7zip.PNG (25.13 KiB) Viewed 2687 times
Doug
drimmer
 
Posts: 31
Joined: May 21st, 2014, 4:48 pm

Re: Adding a Custom Class

Postby Malnorma » November 21st, 2019, 11:48 pm

OK, all good - so in the Vassal editor, when you right-click and choose to add custom class, you enter "WingLeader.Buttons" and it complains that it can't find the class? If so, would you be willing to make the vmod file available to download temporarily?
Malnorma
 
Posts: 124
Joined: October 14th, 2015, 9:26 am

Re: Adding a Custom Class

Postby drimmer » November 22nd, 2019, 8:34 pm

Malnorma wrote:OK, all good - so in the Vassal editor, when you right-click and choose to add custom class, you enter "WingLeader.Buttons" and it complains that it can't find the class? If so, would you be willing to make the vmod file available to download temporarily?


Yes, whether I use WingLeader.Buttons or WingLeader.Buttons.class or WingLeader/Buttons.class, I get the same message.

Happy to share the .vmod. How best to make it available?

Here is a link to the .vmod in dropbox: https://www.dropbox.com/s/s84s7mjo9xese ... .vmod?dl=0

You should be able to download it from there.
Doug
drimmer
 
Posts: 31
Joined: May 21st, 2014, 4:48 pm

Re: Adding a Custom Class

Postby Malnorma » November 23rd, 2019, 9:23 am

So, going forward you don't need to include Buttons.java in the folder. It doesn't hurt, but won't achieve anything either. But since you did, I noticed that it contains some additional class definitions. I believe when you compile this file, there will be other class files generated - you probably need to include these files in that folder as well. Any file that starts with Buttons and ends in .class; I think there should be three of them besides the one already included.
Malnorma
 
Posts: 124
Joined: October 14th, 2015, 9:26 am

Re: Adding a Custom Class

Postby drimmer » November 23rd, 2019, 5:18 pm

Thanks for this. I appreciate your help.

Added all the versions of Buttons to the .vmod file with 7-Zip. No change. Same error.

When I drag and drop Buttons into the .vmod file, are there any properties or settings that might be getting in the way?
Doug
drimmer
 
Posts: 31
Joined: May 21st, 2014, 4:48 pm

Re: Adding a Custom Class

Postby Malnorma » November 23rd, 2019, 9:14 pm

Could you upload that version of the vmod to dropbox as well? I tried compiling the java file here and adding the class files to the module, and was able to add WingLeader.Buttons successfully (I don't think the class is working quite right yet, but I was able to add the custom class and it did something to the toolbar).

There were five total class files in the WingLeader folder:
Buttons$1.class
Buttons$2.class
Buttons$HideMarkers.class
Buttons$HideTargets.class
Buttons.class
Malnorma
 
Posts: 124
Joined: October 14th, 2015, 9:26 am

Re: Adding a Custom Class

Postby drimmer » November 27th, 2019, 4:12 am

Malnorma wrote:Could you upload that version of the vmod to dropbox as well? I tried compiling the java file here and adding the class files to the module, and was able to add WingLeader.Buttons successfully (I don't think the class is working quite right yet, but I was able to add the custom class and it did something to the toolbar).

There were five total class files in the WingLeader folder:
Buttons$1.class
Buttons$2.class
Buttons$HideMarkers.class
Buttons$HideTargets.class
Buttons.class


Here is the link to the .vmod with all of the different Buttons classes included. https://www.dropbox.com/s/s84s7mjo9xese ... .vmod?dl=0

I am glad that you could add the custom class. I have been trying to add it to the Main Map window. Is that where I should be adding it?

You are right it is probably not working perfectly yet - and indeed it is supposed to add two buttons to the toolbar.

Thanks!
Doug
drimmer
 
Posts: 31
Joined: May 21st, 2014, 4:48 pm

Re: Adding a Custom Class

Postby Malnorma » November 27th, 2019, 8:10 am

Maybe that's the difference - I was adding it to the root node. That works without an error, but if I try to add it to the Main Map node instead, I get a casting error. Either way, it appears the class is at least loading correctly.

Screen Shot 2019-11-27 at 21.05.00.png
Screen Shot 2019-11-27 at 21.05.00.png (77.25 KiB) Viewed 2568 times

Screen Shot 2019-11-27 at 21.05.10.png
Screen Shot 2019-11-27 at 21.05.10.png (44.31 KiB) Viewed 2568 times

Screen Shot 2019-11-27 at 21.05.14.png
Screen Shot 2019-11-27 at 21.05.14.png (27.66 KiB) Viewed 2568 times
Malnorma
 
Posts: 124
Joined: October 14th, 2015, 9:26 am

Re: Adding a Custom Class

Postby drimmer » November 27th, 2019, 4:36 pm

Malnorma wrote:Maybe that's the difference - I was adding it to the root node. That works without an error, but if I try to add it to the Main Map node instead, I get a casting error. Either way, it appears the class is at least loading correctly.

Screen Shot 2019-11-27 at 21.05.00.png

Screen Shot 2019-11-27 at 21.05.10.png

Screen Shot 2019-11-27 at 21.05.14.png


OK. When I add it to the root mode it works!! Damn, I am sure that I had tried that before. Perhaps that was before I added all the versions of Buttons classes. Anyway, thanks so much for sticking with me on this. Now, I just have to get the class doing what it is supposed to do.

A million thanks.

Doug
Doug
drimmer
 
Posts: 31
Joined: May 21st, 2014, 4:48 pm

Previous

Return to Developers

Who is online

Users browsing this forum: No registered users and 2 guests