violin-suzutsuki / LinoriaLib

MIT License
51 stars 315 forks source link

Better Round Function (Slightly breaking change) #26

Closed TerminalVibes closed 1 year ago

TerminalVibes commented 1 year ago

Allows the user to round to the nearest Slider.Rounding, (ex: Rounds down to the nearest 0.2, 10, 200, 4000, etc)

It also doesn't encounter the math.round issue where there's a trailing epsilon, which can make the number appear ugly. (Such as 12.00000003)

You might want another config to account for this however, I don't think people loadstring past commits, which means they'll get the breaking changes immediately. I think all you need to do is modify the Slider.Rounding value based on the config and it will be all set.

violin-suzutsuki commented 1 year ago

this is probably how rounding should have worked from the start, but i don't want to break any existing scripts using the UI library. will merge at some point but will lock functionality behind a RoundingMethod variable or something that people can set inside their CreateWindow call

TerminalVibes commented 1 year ago

Yeah, the change is pretty breaking and would probably break most sliders on previous scripts. I feel like Example.lua should have a comment about fetching the library from a previous commit and etc to prevent breaking changes.

violin-suzutsuki commented 1 year ago

closing this PR for now - will add this functionality to the dev branch but put it behind 'AddSnapSlider' - which is just a slider where the slider bar 'snaps' at set intervals