Advanced settings: Add range check for float type 6863/head
authorMuhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com>
Mon, 25 Dec 2017 15:11:27 +0000 (22:11 +0700)
committerparamat <mat.gregory@virginmedia.com>
Tue, 26 Dec 2017 21:55:58 +0000 (21:55 +0000)
builtin/mainmenu/dlg_settings_advanced.lua

index b784a295e954b3968f1619ebe37edfe3f8e25c2f..7d524eb8049a3ee2d465d6596bf81351ddcc7ba4 100644 (file)
@@ -752,6 +752,18 @@ local function handle_change_setting_buttons(this, fields)
                                core.update_formspec(this:get_formspec())
                                return true
                        end
+                       if setting.min and new_value < setting.min then
+                               this.data.error_message = fgettext_ne("The value must be at least $1.", setting.min)
+                               this.data.entered_text = fields["te_setting_value"]
+                               core.update_formspec(this:get_formspec())
+                               return true
+                       end
+                       if setting.max and new_value > setting.max then
+                               this.data.error_message = fgettext_ne("The value must not be larger than $1.", setting.max)
+                               this.data.entered_text = fields["te_setting_value"]
+                               core.update_formspec(this:get_formspec())
+                               return true
+                       end
                        core.settings:set(setting.name, new_value)
 
                elseif setting.type == "flags" then