fix initialization of icontransition.#5387
Conversation
| showing_icons = false | ||
| drawIcons = true | ||
| elseif not showing_icons and testHeight > options.icontransitiontop.value + tolerance then | ||
| elseif (shouldInit or not showing_icons) and testHeight >= options.icontransitiontop.value + tolerance then |
There was a problem hiding this comment.
Note that here it's +tolerance and in the one above it's -tolerance so this will still fail to apply anything if testHeight happens to be within the tolerance bound
There was a problem hiding this comment.
The problem I have is sowing_icons is false (after switching from "Off" mode to "Dynamic") or nil (on initial widget load after /luaUI reload) and I have options.icontransitiontop maxed out. Since this code is written to toggle based on zoom height, the code never triggers for me once one of those two conditions is meet.
I have not had issues with the tolerances, thought I can see that could be a problem. I see 2 fixes for it.
- Remove tolerance altogether, as I don't think a dead zone of 50 really does much.
- Remove the tolerance for initial load only. If I do this, I think adding a setModeToDynamic function may be better, and just copy the logic over without the sowing_icons and tolerance.
which approach do you prefer?
There was a problem hiding this comment.
setModeToDynamic function sounds good.
| kp_timer = nil | ||
| current_mode = "Dynamic" | ||
| UpdateDynamic() | ||
| UpdateDynamic(true) |
There was a problem hiding this comment.
IMO instead of adding the bool param, do a manual check here without the tolerance bound.
Variables need to be set when widget initializes and when toggling back to dynamic mode. The Initialization is important after the game begins (
/luaUI reload).