Adding new items to .vsav file

In VASL we use a number of preferences to save user choices about window layout, feature availablility, etc.

However, there are some choices that we make that are scenario-specific, such as playing a Night scenario. In particular we use shaders to denote a number of visibility conditions: Night, Fog, Dust, etc.

We don’t want these to persist from session to session, rather we want them to persist from one playing of a game to another. It would seem that that logical way to store this information and use it when re-opening a specific scenario file, would be to store it in the .VSAV file.

Is there a way to do this? Is there a better option than using the .vsav file?

TIA

Doug

Have you taken a look at the Scenario Options feature, new in v3.7 ?

Thanks for the reply.

I am currently using 3.7.13. The Scenario Options feature is greyed out under all circumstances that I have tried: with a saved game open, after starting a new game, with no game open.

How and when should I be able to access it?

I have explored this a bit more and see from the reference manual that the Scenario Options menu item will be grayed out until a Scenario Property is defined.

As per the 3.7 Reference Manual, I try to create a Folder entitled Scenario Properties under Global Properties. However, VASSAL will not accept this. When created, the Scenario Properties item shows above Global Properties in the Editor tree and is an item not a folder and therefore I cannot add a specific Scenario Property to it.

I am hopeful that you can point out what I am doing wrong as I think this could be just what we need.

If I were to sucessfully add a Night checkbox, and a game was saved with this option selected, that would mean that the next time the game file was opened, the Night shader would be on?

Thanks.

1 Like

If you were creating a standard folder, that won’t work. I can see where confusion might arise but Scenario Options is actually a special folder (fyi: @Brent_Easton). Try this instead:

  1. Right click on the Global Properties component.
  2. Select the option as shown in this screen shot:

That will create the Scenario Options “folder”. Right click on that to add the options.

Yes.

Thanks!

I was clicking on Global Options not Global Properties. Duh!

OK, now I have to delve into how to get the Scenario Options to work and link to toolbar functionality that turns shaders on/off and varies their impacts on DR, etc. It appears, at first glance at the Reference Manuals. That I am going to have to replace our existing toolbar buttons with other buttons. Does that sound right?

Anyway, you have gotten me on track. Thanks very much. I had totally missed this new feature in 3.7 and I look forward to thinking of other ways to use it.

Making some progress but not all the way there yet.

We have a custom toolbar button that toggles on and off a Night shader, using the F9 hotkey.

There is a custom code class that works with the button:

public class ASLNightMapShader extends MapShader{
private final GlobalProperty globalNightLevel = new GlobalProperty();
public ASLNightMapShader() {
super();
shadingVisible = false;
globalNightLevel.setPropertyName(“night”);
globalNightLevel.setAttribute(“initialValue”, String.valueOf(shadingVisible));
GameModule gm = GameModule.getGameModule();
gm.addMutableProperty(“night”, globalNightLevel);
}

@Override
protected void toggleShading() {
this.boardClip=null;
super.toggleShading();
GameModule.getGameModule().getChatter().send("Night is " + (shadingVisible ? “” : "not ") + “in effect.” );
globalNightLevel.setAttribute(“initialValue”, String.valueOf(shadingVisible));
}
}

So the value of NightShader is stored as a global property.

I want to turn this into a scenario property.

I can create the Scenario Properties Options Tabs under Global Properties and I can then add a Checkbox Scenario Property to the Tabs. I set the Send Hotkey on Change to “F9”.

Now for the first time when I save this and open a game (still within VASSAL.Editor, the Scenario Options menu item is not greyed out and I can open the Scenario Properties Options Tab window and see the Night tab and can toggle the property on/off. However, the shader does not appear/hide in response to the toggle.

If I click on the Night button or press F9 the Night Shader toggles accordingly.

I need to link the Scenario Property with the Global Property, or have it replace the Global Property. Any thoughts about how to do this?

I just noticed under the Main Map Window in VASSAL.Editor there is a Night[Map Shader] item that defines the specifics of the shader colour and opacity, etc. How do I link this to my Scenario Property?

Thanks.

Each Scenario Property should automatically also be a Global Property; so, you should be able to simply delete the original Global Property and the new Scenario Property will transparently replace it.

You may find the Scenario Properties reference page helpful.

I have tried to delete the original Global Property as you suggest with no change in behaviour.

I can open a new game (with no Night shading) and use the Scenario Options Tab to apply the Night shader, which I see visibly change the Map.

However, if I save the game, close out VASL and VASSAL, and then restart them and open the saved game, the Night shader does not persist.

Thanks for the help.

Perhaps the custom code is running when the game opens and resetting the value of the Global Property? Or maybe, re-establishing the GP with an “off” value.

If you want to have Scenario Options set the NightShader property up then any custom code to do with changing that value should be removed, I suggest - at least, when the scenario is opened for the first time.

Somewhat stabbing in the dark here, I hope this helps.

Thanks for the reply.

I thought I had eliminated any of the custom code that might have been resetting the shader value at startup. Went back and doublechecked. Found one or two more instances but not joy. Still no shader when starting a saved game (saved with shader active).

Our custom code for the night shader extends the VASSAL class MapShader. If I disable all the code in the custom class, MapShader gets called at startup and it sets the attribute “startsOn” to false.

If I remove the VASL custom class entirely, then there is no night shader defined in the module and there is nothing to turn on.

It appears that MapShader is going to determine whether or not the shader is active when I start the module. I then open a saved game with, supposedly the shader set to on but that doesn’t seem to override the startup setting? Is that how MapShader is built to work?

I am sure I am just messing something up here.

I’ve not got much knowledge of MapShader. Maybe @Brent_Easton or someone else with the knowledge can chip in at this point.