lowercasing possible

This commit is contained in:
SandPoot
2023-10-05 21:24:13 -03:00
parent a105852042
commit ddf9827afb
2 changed files with 8 additions and 2 deletions
@@ -102,6 +102,8 @@
default = ""
abstract_type = /datum/config_entry/string
var/auto_trim = TRUE
/// whether the string will be lowercased on ValidateAndSet or not.
var/lowercase = FALSE
/datum/config_entry/string/vv_edit_var(var_name, var_value)
return var_name != NAMEOF(src, auto_trim) && ..()
@@ -110,6 +112,8 @@
if(!VASProcCallGuard(str_val))
return FALSE
config_entry_value = auto_trim ? trim(str_val) : str_val
if(lowercase)
config_entry_value = lowertext(config_entry_value)
return TRUE
/datum/config_entry/number
@@ -188,7 +192,8 @@
var/key_mode
var/value_mode
var/splitter = " "
var/lowercase = TRUE
/// whether the key names will be lowercased on ValidateAndSet or not.
var/lowercase_key = TRUE
/datum/config_entry/keyed_list/New()
. = ..()
@@ -206,7 +211,7 @@
if(key_pos || value_mode == VALUE_MODE_FLAG)
key_name = copytext(str_val, 1, key_pos)
if(lowercase)
if(lowercase_key)
key_name = lowertext(key_name)
if(key_pos)
key_value = copytext(str_val, key_pos + length(str_val[key_pos]))
@@ -8,6 +8,7 @@
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_TEXT
protection = CONFIG_ENTRY_LOCKED
lowercase_key = FALSE // The names of the servers are proper nouns. Also required for the cross_comms_name config to work.
/datum/config_entry/keyed_list/cross_server/ValidateAndSet(str_val)
. = ..()