New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add sliders to settings #14469
base: master
Are you sure you want to change the base?
add sliders to settings #14469
Conversation
local value = core.settings:get(setting.name) or setting.default | ||
local scrollbar_value = value/(setting.max - setting.min)*steps - setting.min | ||
|
||
self.resettable = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.resettable = true | |
self.resettable = core.settings:has(setting.name) |
local raw_value = core.explode_scrollbar_event(fields[setting.name]).value | ||
local value = (raw_value/steps) * (setting.max - setting.min) + setting.min | ||
core.settings:set(setting.name, tostring(value)) | ||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value should only be changed if the scrollbar is modified.
local raw_value = core.explode_scrollbar_event(fields[setting.name]).value | |
local value = (raw_value/steps) * (setting.max - setting.min) + setting.min | |
core.settings:set(setting.name, tostring(value)) | |
return false | |
local event = core.explode_scrollbar_event(fields[setting.name]) | |
if event.type ~= "CHG" then | |
return false | |
end | |
local raw_value = event.value | |
local value = (raw_value/steps) * (setting.max - setting.min) + setting.min | |
core.settings:set(setting.name, tostring(value)) | |
return true |
Edit: kotek pointed out in Discord that this somehow breaks mouse dragging.
steps) | ||
local scrollbar_formspec = ("scrollbar[0,0.5;%f,0.4;horizontal;%s;%f]"):format( | ||
avail_w - 1, setting.name, scrollbar_value) | ||
local formspec = setting_label..scrollbar_options..scrollbar_formspec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: Why not use table.concat
? That would make sense if you want to add more (e.g. value display/input box) to this field.
Your feature (which is great, imho) uses |
A compact, short information about PR for easier understanding:
To do
This PR is a
Work in Progress/ Ready for Review.How to test