I don’t understand why you’re using JarURLConnection
.
If you’re trying to get a list of files from an extension, you must use DataArchive.getArchive().getFiles()
. That’s the only reliable way to do it, given how extensions are implemented.
I don’t understand why you’re using JarURLConnection
.
If you’re trying to get a list of files from an extension, you must use DataArchive.getArchive().getFiles()
. That’s the only reliable way to do it, given how extensions are implemented.
I’m also not sure why you need to list the files in your extension. Don’t you know what they are? Surely the list of files in the completed extension will be fixed?
uckelman, now, I’m using a text file to list the folders I need to track. Gave up JarURLConnection. Anyway, I was not being able to list my extension files using DataArchive.getArchive().getFiles(). It was returning only a list of files on the module jar. It wasn’t listing the files in my extension jar. Maybe I was doing something wrong, but I really wasn’t able to make them show up.
Brent, I know what I have in my folders. The problem is that I must randomize from which folder I’ll be reading the animation for the dice. I have 32 different animations (more than 200Mb in animations), so that preloading all of them would take too much memory. Each animation has a version for each 6 results of a 6 sided die and a version for red and white dice. A have a group of 5 animations in which the die hesitates between two results to create some thrill. Yet, I need them to present rarely in order to not exaggerate the phenomena. Here comes the problem. Each of those have more than one version for the same result. Something like 1_2 or 6_2, which means that the animation hesitates between those two numbers. Since I have more than one 2 result for the same animation I must randomize those and since I don’t have all animation for all possible such combinations, I must verify which animations I have available. So, I can’t point to a 4_2 folder if that folder if that folder doesn’t exits. I have put all existent folder on a txt file and I’m creating an index from it. It seems to be working well.
That sounds like what I am doing with my Font work for 3.8. I want to be able to change and update what fonts I install into Vassal, so I set up a yaml file with the config which lists all the files.I read the config file, than process the individual specified font files as needs.
I’m almost done with my Animated Dice extension. It took me a lot of time to deal with some bugs and have it running in a stable way. Yet, there is a last thing I have to do, but I can’t figure how. I have to check if the opponent player has the extension installed and trigger the animation in his computer too, if so.
I though about using Global Properties to do that, so that a change event would trigger the animation only if the opponent has the extension installed, exempting me from having to check if he has the extension installed; if he hasn’t he would only get the chat report. Yet, I notice that Global Property class has no firePropertyChange call and I can’t figure out how to trigger the PropertyChange method from within my code.
What is the best solution to send an instruction to an opposing player if he has the extension installed in his computer?
You always communicate between clients using Commands and CommandEncoders,
The way to do it is to have the Extension define a Custom Command and install a custom CommandEncoder in addTo(). As part of the Commands you generate and send as part of your DiceRoll, you include your new AnimatedDiceRollCommand (containing the animation details) that is passed to GameModule.getGameModule.sendAndLog().
At the other end, a client that has the extension installed will recognize the AnimatedDiceRollCommand and decode and execute, A client that does not have the extension installed will see all the other Commands that make up the roll (Report and GP settings), but will not recognize the AnimatedDiceRollCommand and will ignore it.
Thanks Brent. Nice to have a direction. I was even able to wrap the Global Property in a custom property and use firePropertyChange to trigger the change event, but it really doesn’t seem the right way to do it.
Brent and uckelman, I have finished (there is only one detail left) my extension and since you both have guided me through to this point, your opinion, if you have the time available, would be welcome.
I think it is a worthy dice extension for games using two 6 sided dice. It is heavier than most extensions or modules, since it uses pre-rendered images, but for today standards, it isn’t prohibitive, I think.
Here is a link with a test module and the extension:
I have tested it in two other modules (Vasl and OCS) and it worked ok. Here comes the missing detail. For some reason, in Vasl, the html message sent to the chatter doesn’t show, formatted or not. In OCS, which hasn’t its Global Settings configured for HTML, it is displaying properly, since I used a Quick Colors character. But I wasn’t able to make it display in Vasl.
The extension allows for one or two dice rolls. The left button will display the animation and the right button is for a quick roll, without animation. In both cases, if the button is kept pressed, the mouse movement will “shuffle” the initial random value, for those who like to think they are influencing their own luck. Speed, position on screen, sounds etc can be changed in preferences.
It took me a long time to make it stable (I was getting NullPointerException due to more than one thread manipulating pieces on the board and some memory leaks), but now it seems the problems are gone. I configured a bot that ran more than 2 days in a row without crashing or increasing memory usage, but I wasn’t able to test it to exhaustion alone. As said earlier, I’m not a developer and I knew nothing about the vassal framework before beginning, so a lot of things must have better and easier ways to be accomplished, but at least it is working as planned and I learned a lot while doing it.
You should absolutely not do that. Anything that results in the UI being updated must be done on the Event Dispatch Thread.
I noticed. All piece placement and deletion was removed from other threads.