[MIRROR] Fixes numeric prefs not working with TGUI dropdowns that might return a string instead of a number [MDB IGNORE] (#9317)

* Fixes numeric prefs not working with TGUI dropdowns that might return a string instead of a number (#62653)

* Fixes numeric prefs not working with TGUI dropdowns that might return a string instead of a number

Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>
This commit is contained in:
SkyratBot
2021-11-08 22:56:20 +00:00
committed by GitHub
parent 45ad3f5e6e
commit 554703cdda
@@ -498,6 +498,8 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
abstract_type = /datum/preference/numeric
/datum/preference/numeric/deserialize(input, datum/preferences/preferences)
if(istext(input)) // Sometimes TGUI will return a string instead of a number, so we take that into account.
input = text2num(input) // Worst case, it's null, it'll just use create_default_value()
return sanitize_float(input, minimum, maximum, step, create_default_value())
/datum/preference/numeric/serialize(input)