-
Notifications
You must be signed in to change notification settings - Fork 2k
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
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.
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.
Reason why mouse dragging stops working is that after returning true
GUI gets regenerated and this probably causes scrollbar to lose focus.
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.
normally regenerating the GUI doesn't make scrollbars loose focus, but for some minetest reason it does in the main menu
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.
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.
Rest of code in this file also does this so I guess it's better for consistency.
Your feature (which is great, imho) uses |
Feel free to reopen if you start working on this again |
A compact, short information about PR for easier understanding:
To do
This PR is a
Work in Progress/ Ready for Review.How to test