fix samples (#17539)

* fix samples

* port that

* fix some things
This commit is contained in:
Kashargul
2025-04-17 13:57:19 +02:00
committed by GitHub
parent 07ff93be21
commit 6766d9b4c2
6 changed files with 48 additions and 14 deletions
@@ -318,7 +318,10 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
/// Write a /datum/preference type and return its value directly to the json.
/mob/proc/write_preference_directly(preference_type, preference_value)
return client?.prefs?.write_preference_by_type(preference_type, preference_value)
var/success = client?.prefs?.write_preference_by_type(preference_type, preference_value)
if(success)
client?.prefs?.value_cache[preference_type] = preference_value
return success
/// Set a /datum/preference entry.
/// Returns TRUE for a successful preference application.
+12 -6
View File
@@ -42,24 +42,30 @@ var/global/list/all_tooltip_styles = list(
if(!ishuman(usr))
if(!isrobot(usr))
to_chat(usr, span_warning("You must be a human or a robot to use this verb."))
to_chat(src, span_warning("You must be a human or a robot to use this verb."))
return
var/UI_style_new = tgui_input_list(usr, "Select a style. White is recommended for customization", "UI Style Choice", all_ui_styles)
var/current_style = prefs.read_preference(/datum/preference/choiced/ui_style)
var/current_alpha = prefs.read_preference(/datum/preference/numeric/ui_style_alpha)
var/current_color = prefs.read_preference(/datum/preference/color/ui_style_color)
var/UI_style_new = tgui_input_list(src, "Select a style. White is recommended for customization", "UI Style Choice", all_ui_styles, current_style)
if(!UI_style_new) return
var/UI_style_alpha_new = tgui_input_number(usr, "Select a new alpha (transparency) parameter for your UI, between 50 and 255", null, null, 255, 50)
var/UI_style_alpha_new = tgui_input_number(src, "Select a new alpha (transparency) parameter for your UI, between 50 and 255", null, current_alpha, 255, 50)
if(!UI_style_alpha_new || !(UI_style_alpha_new <= 255 && UI_style_alpha_new >= 50)) return
var/UI_style_color_new = tgui_color_picker(usr, "Choose your UI color. Dark colors are not recommended!")
var/UI_style_color_new = tgui_color_picker(src, "Choose your UI color. Dark colors are not recommended!", null, current_color)
if(!UI_style_color_new) return
//update UI
usr.update_ui_style(UI_style_new, UI_style_alpha_new, UI_style_color_new)
if(tgui_alert(usr, "Like it? Save changes?","Save?",list("Yes", "No")) == "Yes")
if(tgui_alert(src, "Like it? Save changes?","Save?",list("Yes", "No")) == "Yes")
usr.write_preference_directly(/datum/preference/choiced/ui_style, UI_style_new)
usr.write_preference_directly(/datum/preference/numeric/ui_style_alpha, UI_style_alpha_new)
usr.write_preference_directly(/datum/preference/color/ui_style_color, UI_style_color_new)
SScharacter_setup.queue_preferences_save(prefs)
to_chat(usr, "UI was saved")
to_chat(src, "UI was saved")
return
usr.update_ui_style(current_style, current_alpha, current_color)