Restricting Access to Toolbar Menu

Is there a way to restrict access to a Toolbar Menu?
If its via the "Global property to disable this button when “true”, how would I write that in terms of player side?

If your goal is to have a button that’s only accessible to a certain player side, it would be better to put that button on a map window/player hand that’s restricted to the player side. There’s no easy way to restrict a button that’s attached to a generally-accessible map by player side.

Thanks for replying.
Yes, that is my goal. I thought of it after I’d created & populated the sub-windows so I’m being lazy & don’t want to have to redo the 4-5 map-windows/ side that the Toolbar Menus operate. I’ve been trying to take advantage of the “Disable” feature of the Toolbar Menu but can’t seem to find a property expression that works (i.e. playerSide==“allied”…$playerSide$==“axis”…).

I think you can achieve this but you might find it is alot of effort and there may be simpler solutions. The components in a “disable” by playerside solution would be:-

  1. A set of Global Option Checkbox properties on a blank tab; one for each PlayerSide. These are the true/false properties that you will use to disable buttons based on PlayerSide. e.g. isAllied, isAxis etc. Initial values will all be checked (ie “true” - so, buttons disabled).

  2. Intercepting the “Retire or Change Side” button and inserting logic (Global Hotkeys etc) that will force an evaluation of each of those special properties against each of the available PlayerSides… e.g. {PlayerSide==“allied”}, whenever a player joins a game, retires or changes side.

I’m pretty sure this can’t work due to the asynchronous nature of VASSAL. At any particular point in time, the button has to be either enabled (for everyone) or disabled (for everyone). There is no way to disable it only for one player, as far as I can tell, as long as it’s on a public window. The proper solution is the one I mentioned above, put the button on a window that’s already restricted to the right player. A nasty, hacky, solution would be to use a piece on the actual map with an Action Button trait that ignores the “wrong” player(s) pressing it.

The exception would be if the game has very clearly defined turns, and the module always “knows” whose turn it is; then the button could be disabled when a specific player’s turn starts, and enabled again when the next turn starts. That won’t prevent players clicking it when it’s not actually their turn, but you could include logic to ignore such clicks. A lot of work for very little gain.

Thanks. It’s not a “do or die” mechanic in the module and as I mentioned I’m closer to submitting the module than I am to starting the module. So will leave it for a future “revamp” of the mod. Thx CC

1 Like

Thx for your help in clarifying this. CC

1 Like

Unless there’s something peculiar about buttons, the key is Global Option properties because the value of these is not sync’d. Therefore, allowing a user/instance specific view. Certainly this works for any other traits that evaluate properties.