Skip to content

Conversation

@svenviktorm
Copy link

@svenviktorm svenviktorm commented Oct 7, 2025

Requirements for Contributing a Bug Fix or Enhancement

  • Fill out the template below. Any pull request that does not include enough information to be reviewed in timely manner will result in a request for you to update the pull request
    and possibly closure of the pull request if it is not provided after this request.
  • After you create the pull request, all status checks must pass before a maintainer will review your contribution.

Identify the Bug or Feature request

resolves #2326

Description of the Change

The stored value of Token bars is separated into its shown value and a hidden value which is restored when the bar is set to visible. This is done by adding an additional value in the Token state map with the original bar name with a suffix added currently "StoredValue". Also a check has been added to when bars/states are added/updated in campaign properties so the names do not clash with the new hidden value.

The bar sliders in the Token popup editor and Token editor have been updated to handle the hidden values, I have not made it so that you can edit them while hidden is checked.

Example:
bar "Health" has value 0.8,
setBarVisible("Health", 0) is called upon the Token which sets "HealthStoredValue" to 0.8 and "Health" to null inside the Token status map making the health bar invisible.
setBar("Health", 0.3) is called setting "HealthStoredValue" to 0.3 not revealing the bar
setBarVisible("Health", 1) is called, setting "Health" to 0.3 making the bar visible
setBar("Health",0.9) is called setting both "Health" and "HealthStoredValue" to 0.9 updating the bar

The reason I have implemented this change in the rather crude way of having two instances of each bar stored in the states map is because then nothing has to be changed in how Token behaves and therefore TokenDTO and a lot more does not need to be changed. If the suffix "StoredValue" needs to be switched out it can be changed in TokenBarFunction.java.

Possible Drawbacks

If a state or bar has the name of another state or bar (not two bars) but with the hidden value suffix (currently "StoredValue") that may cause them to be entangled, having one state / bar affecting the other. This should only be possible if an old Token is imported with a clashing bar or state name since it should not be possible to add a clashing state / bar.

Another possible side-effect is from any part of the program which use the keys from the State in Token.Java or getStatePropertyNames() or similar, now that part of the code will get duplicate results of every bar.

Backwards compatibility will be affected since setBarVisible(), setBar() and getBar() all have changed functionality.
setBar() can't be used to set a bar as visible,
getBar() can't be used to figure out if a bar is visible
and setBarVisible() don't reset/remove the bar's value.

Documentation Notes

The wiki page about setBar and setBarVisible needs to be changed if this request is accepted, i don't know how to do that myself. getBar does not need to be updated.

Release Notes

  • Fixed an issue where a change in visibility of a bar reset the value.

This change is Reviewable

svenviktorm and others added 3 commits October 7, 2025 02:01
@github-actions github-actions bot added the bug label Oct 7, 2025
@kwvanderlinde kwvanderlinde moved this from Todo to Awaiting-Review in MapTool 1.19 Oct 8, 2025
@cwisniew
Copy link
Member

cwisniew commented Oct 9, 2025

Backwards compatibility will be affected since setBarVisible(), setBar() and getBar() all have changed functionality. setBar() can't be used to set a bar as visible, getBar() can't be used to figure out if a bar is visible and setBarVisible() don't reset/remove the bar's value.

The general rule is don't break macro functions compatability without a VERY good reason, so this change would need to be adjusted to keep the existing behaviour for the macro functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Awaiting-Review

Development

Successfully merging this pull request may close these issues.

Toggling bar visibility resets the bar

2 participants