Including external Java library into a module extension

Hello.

I am trying to write an extension to the module RPG Tactical whose aim is to load of external images as boards at startup.

The rationale of this extension is twofold:

We would like to load PDF files (character sheets) as boards with counters, and currently vassal does not support pdf inport.
My DM would like to avoid having to edit and send an extension each time he uses a pre-made encounter map (like an image file).

My first step was to try to export a JAR and include the extension metadata files. However, when trying to access the external classes, I get the exception:
Caused by: java.io.FileNotFoundException: ‘org/apache/pdfbox/pdmodel/PDDocument.class’ not found in [PathSnipped]\VassalEngine\Modules\RPG Tactical\RPGTactical.v1.0.0.vmod
I find it kind of odd that Vassal looks for the library in the original Module instead of in its extension (RPG Tactical\RPGTactical.v1.0.0_ext\CharSheet.jar)

I have been wondering at the possibility of creating a plugin, by inheriting from Plugin or ModulePlugin. However, it took me a while to gather that plugins must have extension metadata in their archive, which makes me fear that the behaviour will be the same.

I am getting sleepy and I haven’t thoroughly investigated this last option.

Has anyone got any advice on how to properly include the libraries I need without modifying vassal or the original module?

Thus spake Calsir:

Hello.

I am trying to write an extension to the module RPG Tactical whose aim
is to load of external images as boards at startup.

The rationale of this extension is twofold:

We would like to load PDF files (character sheets) as boards with
counters, and currently vassal does not support pdf inport.
My DM would like to avoid having to edit and send an extension each time
he uses a pre-made encounter map (like an image file).

VASSAL 4 will support PDFs. (In fact, the V4 demo already supports
PDFs.) That doesn’t help you right now, but it gives you an idea of
the future.

My first step was to try to export a JAR and include the extension
metadata files. However, when trying to access the external classes, I
get the exception:
Caused by: java.io.FileNotFoundException:
‘org/apache/pdfbox/pdmodel/PDDocument.class’ not found in
[PathSnipped]\VassalEngine\Modules\RPG Tactical\RPGTactical.v1.0.0.vmod
I find it kind of odd that Vassal looks for the library in the original
Module instead of in its extension (RPG
Tactical\RPGTactical.v1.0.0_ext\CharSheet.jar)

I have been wondering at the possibility of creating a plugin, by
inheriting from Plugin or ModulePlugin. However, it took me a while to
gather that plugins must have extension metadata in their archive, which
makes me fear that the behaviour will be the same.

I am getting sleepy and I haven’t thoroughly investigated this last
option.

Has anyone got any advice on how to properly include the libraries I
need without modifying vassal or the original module?

So, to be clear, what you’re wanting to do is put a JAR inside your
module extension?


J.

Hi Joel.

Yes, basically I would like to include a jar in an extension, so that I can use the functionalities from external libraries without modifying the parent module or redeploying a custom version of Vassal.

That being said, my gaming group and I will fall back to converting the pdfs to supported image formats. I was able to subclass VASSAL.build.module.map.boardPicker.Board and all the image utilities so that I can now load map board images directly from a subdirectory of the Vassal configuration directory. Do you think that such a function could be useful in Vassal in general?

Thus spake Calsir:

Hi Joel.

Yes, basically I would like to include a jar in an extension, so that I
can use the functionalities from external libraries without modifying
the parent module or redeploying a custom version of Vassal.

You could get this to work without modifying VASSAL if you put the
contents of the JAR into the module extension, instead of the JAR
itself.

That being said, my gaming group and I will fall back to converting the
pdfs to supported image formats. I was able to subclass
VASSAL.build.module.map.boardPicker.Board and all the image utilities so
that I can now load map board images directly from a subdirectory of the
Vassal configuration directory. Do you think that such a function could
be useful in Vassal in general?

VASL does something kind of like this already for its mapboards.

Can you explain a bit more the use case?


J.

Hello.

Good point about the jar content.

Let me elaborate on the usecase I am currently implementing. Our Game Master would to use the tons of free maps that are available on the internet instead of creating one-shot maps that are used and discarded. Instead of creating an extension each time and enabling it in the module manager, he asked me to see if it was possible to put the map in a folder and have vassal load it at module startup as a game board and add it to the board picker before game creation.

Each map would have to come with a configuration file so that a square grid with the proper configuration can be layed upon the board with the correct offsets.

This usecase is similar to the one I first described (loading a character sheet as a board) except for the part that a grid is needed.

What I did to implement this functionality was subclassing the Board class so that I could use an image file that was not included in the module/extension DataArchive.

Then I slap on the Board a SquareGrid with some default values that can be overridden in a simple configuration file.

Thus spake Calsir:

Hello.

Good point about the jar content.

Let me elaborate on the usecase I am currently implementing. Our Game
Master would to use the tons of free maps that are available on the
internet instead of creating one-shot maps that are used and discarded.
Instead of creating an extension each time and enabling it in the module
manager, he asked me to see if it was possible to put the map in a
folder and have vassal load it at module startup as a game board and add
it to the board picker before game creation.

How would the users get the maps in this scenario?


J.

Hi.

The files will have to be present on each user’s system at module load, unless some method of actually pushing the maps on the different machines at game synchronization is found. I read that data transfer is foreseen in the future (through jabber). However, I play with a group of friends, and I was thinking about using a file sharing service like DropBox as we do not consider the maps as sensitive data.

Thus spake Calsir:

“uckelman” wrote:

Thus spake Calsir:

How would the users get the maps in this scenario?

Hi.

The files will have to be present on each user’s system at module load,
unless some method of actually pushing the maps on the different
machines at game synchronization is found. I read that data transfer is
foreseen in the future (through jabber). However, I play with a group of
friends, and I was thinking about using a file sharing service like
DropBox as we do not consider the maps as sensitive data.

Why not put the files into the module extension, then, if all of the
players need them?


J.

Hi Joel.

Actually, I was just showing my DM how to create an extension with a map, and he agrees that it is a better procedure since he needs to define the grid upon it, and since we discovered the useful “set grid” functionality.

However, for loading the character sheets as boards, since we have a few character sheets, each with a few pages, I prefer load it programmatically.