Fixing reseting of bar when visibility is toggled. #5809
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements for Contributing a Bug Fix or Enhancement
and possibly closure of the pull request if it is not provided after this request.
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
This change is