mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-09 06:06:00 +01:00
Fix multiple pref issues (#18083)
* fix tail alyering pref * . * . * . * . * - * return * fix that * write needs save after * urg * ban slot change mid round * - * . * properly save * . * queue to ss * read current * performance * . * . * bit better optimized * no resetsploit * this works at least but is it proper (#13) * this works at least but is it proper * Update changeling.dm * this too... * dont be private * fix asset ss --------- Co-authored-by: C.L. <killer65311@gmail.com>
This commit is contained in:
@@ -88,7 +88,7 @@
|
||||
lst.Insert(1, result)
|
||||
if(result in componentsubtypes)
|
||||
datumname = "component"
|
||||
target._AddComponent(lst, add_source)
|
||||
target._AddComponent(lst, add_source, TRUE)
|
||||
else
|
||||
datumname = "element"
|
||||
target._AddElement(lst)
|
||||
|
||||
@@ -317,8 +317,9 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
|
||||
return client?.prefs?.read_preference(preference_type)
|
||||
|
||||
/// Write a /datum/preference type and return its value directly to the json.
|
||||
/mob/proc/write_preference_directly(preference_type, preference_value)
|
||||
var/success = client?.prefs?.write_preference_by_type(preference_type, preference_value)
|
||||
/// Please use SScharacter_setup.queue_preferences_save(prefs) when you edit multiple at once and set direct_write to WRITE_PREF_MANUAL
|
||||
/mob/proc/write_preference_directly(preference_type, preference_value, write_mode = WRITE_PREF_INSTANT)
|
||||
var/success = client?.prefs?.write_preference_by_type(preference_type, preference_value, write_mode)
|
||||
if(success)
|
||||
client?.prefs?.value_cache[preference_type] = preference_value
|
||||
return success
|
||||
@@ -336,7 +337,7 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
|
||||
|
||||
/// Writes a value and saves to disk immediately
|
||||
/// Used by things that need to directly write to the player savefile things that aren't "really" prefs
|
||||
/datum/preferences/proc/write_preference_by_type(preference_type, preference_value)
|
||||
/datum/preferences/proc/write_preference_by_type(preference_type, preference_value, write_mode = WRITE_PREF_NORMAL)
|
||||
var/datum/preference/preference_entry = GLOB.preference_entries[preference_type]
|
||||
if(isnull(preference_entry))
|
||||
CRASH("Preference type `[preference_type]` is invalid!")
|
||||
@@ -344,7 +345,10 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
|
||||
if(!write_preference(preference_entry, preference_entry.pref_serialize(preference_value)))
|
||||
return
|
||||
|
||||
if(preference_entry.savefile_identifier == PREFERENCE_CHARACTER)
|
||||
if(write_mode == WRITE_PREF_MANUAL)
|
||||
return TRUE
|
||||
|
||||
if(preference_entry.savefile_identifier == PREFERENCE_CHARACTER && write_mode != WRITE_PREF_INSTANT)
|
||||
var/save_data = get_save_data_for_savefile_identifier(preference_entry.savefile_identifier)
|
||||
player_setup.save_character(save_data)
|
||||
else
|
||||
|
||||
@@ -213,16 +213,17 @@
|
||||
return 255 //no randomization here.
|
||||
|
||||
///Tail style.
|
||||
/datum/preference/numeric/human/tail_layering
|
||||
/datum/preference/choiced/human/tail_layering
|
||||
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
|
||||
savefile_identifier = PREFERENCE_CHARACTER
|
||||
savefile_key = "tail_layering"
|
||||
can_randomize = FALSE
|
||||
minimum = TAIL_UPPER_LAYER
|
||||
maximum = TAIL_UPPER_LAYER_HIGH
|
||||
|
||||
/datum/preference/numeric/human/tail_layering/create_default_value()
|
||||
return TAIL_UPPER_LAYER
|
||||
/datum/preference/choiced/human/tail_layering/init_possible_values()
|
||||
return assoc_to_keys(GLOB.tail_layer_options)
|
||||
|
||||
/datum/preference/numeric/human/tail_layering/apply_to_human(mob/living/carbon/human/target, value)
|
||||
target.tail_layering = value
|
||||
/datum/preference/choiced/human/tail_layering/create_default_value()
|
||||
return GLOB.tail_layer_options[2]
|
||||
|
||||
/datum/preference/choiced/human/tail_layering/apply_to_human(mob/living/carbon/human/target, value)
|
||||
target.tail_layering = GLOB.tail_layer_options[value]
|
||||
|
||||
@@ -136,6 +136,9 @@
|
||||
switch(action)
|
||||
// Basic actions
|
||||
if("load")
|
||||
if(!isnewplayer(ui.user))
|
||||
to_chat(ui.user, span_userdanger("You can't change your character slot while being in round."))
|
||||
return FALSE
|
||||
if(!IsGuestKey(ui.user.key))
|
||||
open_load_dialog(ui.user)
|
||||
. = TRUE
|
||||
@@ -152,6 +155,8 @@
|
||||
sanitize_preferences()
|
||||
. = TRUE
|
||||
if("resetslot")
|
||||
if(!isnewplayer(ui.user))
|
||||
to_chat(ui.user, span_userdanger("You can't change your character slot while being in round."))
|
||||
if("Yes" != tgui_alert(ui.user, "This will reset the current slot. Continue?", "Reset current slot?", list("No", "Yes")))
|
||||
return
|
||||
if("Yes" != tgui_alert(ui.user, "Are you completely sure that you want to reset this character slot?", "Reset current slot?", list("No", "Yes")))
|
||||
@@ -160,6 +165,8 @@
|
||||
sanitize_preferences()
|
||||
. = TRUE
|
||||
if("copy")
|
||||
if(!isnewplayer(ui.user))
|
||||
to_chat(ui.user, span_userdanger("You can't change your character slot while being in round."))
|
||||
if(!IsGuestKey(ui.user.key))
|
||||
open_copy_dialog(ui.user)
|
||||
. = TRUE
|
||||
@@ -192,7 +199,7 @@
|
||||
PMH.screen_loc = LAZYACCESS(preview_screen_locs, "PMH")
|
||||
|
||||
/datum/preferences/tgui_close(mob/user)
|
||||
// save_character()
|
||||
load_character()
|
||||
save_preferences()
|
||||
|
||||
/datum/preferences/proc/create_character_profiles()
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
usr.update_ui_style(UI_style_new, UI_style_alpha_new, UI_style_color_new)
|
||||
|
||||
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)
|
||||
usr.write_preference_directly(/datum/preference/choiced/ui_style, UI_style_new, WRITE_PREF_MANUAL)
|
||||
usr.write_preference_directly(/datum/preference/numeric/ui_style_alpha, UI_style_alpha_new, WRITE_PREF_MANUAL)
|
||||
usr.write_preference_directly(/datum/preference/color/ui_style_color, UI_style_color_new, WRITE_PREF_MANUAL)
|
||||
SScharacter_setup.queue_preferences_save(prefs)
|
||||
to_chat(src, "UI was saved")
|
||||
return
|
||||
|
||||
@@ -69,19 +69,14 @@
|
||||
set category = "IC.Game"
|
||||
set desc = "Switch tail layer to show below/above/between clothing or other things such as wings!."
|
||||
|
||||
var/input = tgui_input_list(src, "Select a tail layer.", "Set Tail Layer", list(SWITCH_TAIL_LAYER_UPPER, SWITCH_TAIL_LAYER_STANDARD, SWITCH_TAIL_LAYER_LOWER))
|
||||
if(isnull(input))
|
||||
var/input = tgui_input_list(src, "Select a tail layer.", "Set Tail Layer", GLOB.tail_layer_options, read_preference(/datum/preference/choiced/human/tail_layering))
|
||||
if(!input)
|
||||
return
|
||||
switch(input)
|
||||
if(SWITCH_TAIL_LAYER_UPPER)
|
||||
tail_layering = input
|
||||
write_preference_directly(/datum/preference/numeric/human/tail_layering, TAIL_UPPER_LAYER_HIGH)
|
||||
if(SWITCH_TAIL_LAYER_STANDARD)
|
||||
tail_layering = input
|
||||
write_preference_directly(/datum/preference/numeric/human/tail_layering, TAIL_UPPER_LAYER)
|
||||
if(SWITCH_TAIL_LAYER_LOWER)
|
||||
tail_layering = input
|
||||
write_preference_directly(/datum/preference/numeric/human/tail_layering, TAIL_UPPER_LAYER_LOW)
|
||||
var/tail_option = GLOB.tail_layer_options[input]
|
||||
if(!tail_option)
|
||||
return
|
||||
tail_layering = tail_option
|
||||
write_preference_directly(/datum/preference/choiced/human/tail_layering, input)
|
||||
|
||||
update_tail_showing()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user