mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-13 16:13:49 +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:
@@ -49,7 +49,7 @@
|
||||
* Arguments:
|
||||
* * datum/P the parent datum this component reacts to signals from
|
||||
*/
|
||||
/datum/component/New(list/raw_args)
|
||||
/datum/component/New(list/raw_args, manual)
|
||||
parent = raw_args[1]
|
||||
var/list/arguments = raw_args.Copy(2)
|
||||
if(Initialize(arglist(arguments)) == COMPONENT_INCOMPATIBLE)
|
||||
@@ -58,6 +58,8 @@
|
||||
return
|
||||
|
||||
_JoinParent(parent)
|
||||
if(manual)
|
||||
lateload_pref_data()
|
||||
|
||||
/**
|
||||
* Called during component creation with the same arguments as in new excluding parent.
|
||||
@@ -310,7 +312,7 @@
|
||||
*
|
||||
* Properly handles duplicate situations based on the `dupe_mode` var
|
||||
*/
|
||||
/datum/proc/_AddComponent(list/raw_args, source)
|
||||
/datum/proc/_AddComponent(list/raw_args, source, manual)
|
||||
var/original_type = raw_args[1]
|
||||
var/datum/component/component_type = original_type
|
||||
|
||||
@@ -349,14 +351,14 @@
|
||||
switch(dupe_mode)
|
||||
if(COMPONENT_DUPE_UNIQUE)
|
||||
if(!new_component)
|
||||
new_component = new component_type(raw_args)
|
||||
new_component = new component_type(raw_args, manual)
|
||||
if(!QDELETED(new_component))
|
||||
old_component.InheritComponent(new_component, TRUE)
|
||||
QDEL_NULL(new_component)
|
||||
|
||||
if(COMPONENT_DUPE_HIGHLANDER)
|
||||
if(!new_component)
|
||||
new_component = new component_type(raw_args)
|
||||
new_component = new component_type(raw_args, manual)
|
||||
if(!QDELETED(new_component))
|
||||
new_component.InheritComponent(old_component, FALSE)
|
||||
QDEL_NULL(old_component)
|
||||
@@ -378,7 +380,7 @@
|
||||
return null
|
||||
|
||||
else if(!new_component)
|
||||
new_component = new component_type(raw_args) // There's a valid dupe mode but there's no old component, act like normal
|
||||
new_component = new component_type(raw_args, manual) // There's a valid dupe mode but there's no old component, act like normal
|
||||
|
||||
else if(dupe_mode == COMPONENT_DUPE_SELECTIVE)
|
||||
var/list/arguments = raw_args.Copy()
|
||||
@@ -390,19 +392,19 @@
|
||||
QDEL_NULL(new_component)
|
||||
break
|
||||
if(!new_component && make_new_component)
|
||||
new_component = new component_type(raw_args)
|
||||
new_component = new component_type(raw_args, manual)
|
||||
|
||||
else if(dupe_mode == COMPONENT_DUPE_SOURCES)
|
||||
new_component = new component_type(raw_args)
|
||||
new_component = new component_type(raw_args, manual)
|
||||
if(new_component.on_source_add(arglist(list(source) + raw_args.Copy(2))) == COMPONENT_INCOMPATIBLE)
|
||||
stack_trace("incompatible source added to a [new_component.type]. Args: [json_encode(raw_args)]")
|
||||
return null
|
||||
|
||||
else if(!new_component)
|
||||
new_component = new component_type(raw_args) // Dupes are allowed, act like normal
|
||||
new_component = new component_type(raw_args, manual) // Dupes are allowed, act like normal
|
||||
|
||||
if(!old_component && !QDELETED(new_component)) // Nothing related to duplicate components happened and the new component is healthy
|
||||
SEND_SIGNAL(src, COMSIG_COMPONENT_ADDED, new_component)
|
||||
SEND_SIGNAL(src, COMSIG_COMPONENT_ADDED, new_component, manual)
|
||||
return new_component
|
||||
|
||||
return old_component
|
||||
@@ -424,12 +426,13 @@
|
||||
*
|
||||
* Arguments:
|
||||
* * component_type The typepath of the component to create or return
|
||||
* * manual_load If we are manually adding this (post-spawn) or not.
|
||||
* * ... additional arguments to be passed when creating the component if it does not exist
|
||||
*/
|
||||
/datum/proc/_LoadComponent(list/arguments)
|
||||
/datum/proc/_LoadComponent(list/arguments, manual_load)
|
||||
. = GetComponent(arguments[1])
|
||||
if(!.)
|
||||
return _AddComponent(arguments)
|
||||
return _AddComponent(arguments, manual = manual_load)
|
||||
/**
|
||||
* Removes the component from parent, ends up with a null parent
|
||||
* Used as a helper proc by the component transfer proc, does not clean up the component like Destroy does
|
||||
@@ -495,3 +498,9 @@
|
||||
*/
|
||||
/datum/component/tgui_host()
|
||||
return parent
|
||||
|
||||
/**
|
||||
* Loads lateload data for the component. Things such as preferences, which aren't applied if not done at character-spawn. Must be defined per-component.
|
||||
*/
|
||||
/datum/component/proc/lateload_pref_data()
|
||||
return
|
||||
|
||||
@@ -155,7 +155,7 @@ var/list/datum/power/changeling/powerinstances = list()
|
||||
if(!mind)
|
||||
return
|
||||
//The current mob is made a changeling AND the mind is made a changeling.
|
||||
var/datum/component/antag/changeling/comp = LoadComponent(/datum/component/antag/changeling)
|
||||
var/datum/component/antag/changeling/comp = LoadComponent(/datum/component/antag/changeling, TRUE)
|
||||
mind.antag_holder.changeling = comp
|
||||
var/lesser_form = !ishuman(src)
|
||||
|
||||
@@ -423,10 +423,23 @@ var/list/datum/power/changeling/powerinstances = list()
|
||||
|
||||
|
||||
//Debug item. Here because during debugging I DO NOT want to have to open the player panel 5000 times.
|
||||
/obj/item/toy/katana/changeling_debug
|
||||
/obj/item/changeling_debug
|
||||
name = "Katana of the Changeling"
|
||||
desc = "A katana imbued with special powers. It is said that those who wield it will become a changeling."
|
||||
/obj/item/toy/katana/changeling_debug/attack_self(mob/user)
|
||||
icon = 'icons/obj/weapons.dmi'
|
||||
icon_state = "katana"
|
||||
item_state = "katana"
|
||||
item_icons = list(
|
||||
slot_l_hand_str = 'icons/mob/items/lefthand_material.dmi',
|
||||
slot_r_hand_str = 'icons/mob/items/righthand_material.dmi',
|
||||
)
|
||||
slot_flags = SLOT_BELT | SLOT_BACK
|
||||
force = 5
|
||||
throwforce = 5
|
||||
w_class = ITEMSIZE_NORMAL
|
||||
attack_verb = list("attacked", "slashed", "stabbed", "sliced")
|
||||
|
||||
/obj/item/changeling_debug/attack_self(mob/user)
|
||||
user.make_changeling()
|
||||
|
||||
///Changeling Panel
|
||||
|
||||
@@ -255,3 +255,13 @@
|
||||
to_chat(owner, span_danger("The VR systems cannot comprehend this power! This is useless to you!"))
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
///Gets late-load preferences for the shadekin component. Used when the component is applied post-spawn.
|
||||
/datum/component/shadekin/lateload_pref_data()
|
||||
if(owner.client)
|
||||
flicker_color = owner.read_preference(/datum/preference/color/living/flicker_color)
|
||||
flicker_time = owner.read_preference(/datum/preference/numeric/living/flicker_time)
|
||||
flicker_break_chance = owner.read_preference(/datum/preference/numeric/living/flicker_break_chance)
|
||||
flicker_distance = owner.read_preference(/datum/preference/numeric/living/flicker_distance)
|
||||
no_retreat = owner.read_preference(/datum/preference/toggle/living/dark_retreat_toggle)
|
||||
nutrition_energy_conversion = owner.read_preference(/datum/preference/toggle/living/shadekin_nutrition_conversion)
|
||||
|
||||
@@ -212,6 +212,9 @@
|
||||
|
||||
return data
|
||||
|
||||
/datum/component/shadekin/tgui_close(mob/user)
|
||||
SScharacter_setup.queue_preferences_save(user?.client?.prefs)
|
||||
. = ..()
|
||||
|
||||
/datum/component/shadekin/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
|
||||
if(..())
|
||||
@@ -224,14 +227,14 @@
|
||||
if(!isnum(new_time))
|
||||
return FALSE
|
||||
flicker_time = new_time
|
||||
ui.user.write_preference_directly(/datum/preference/numeric/living/flicker_time, new_time)
|
||||
ui.user.write_preference_directly(/datum/preference/numeric/living/flicker_time, new_time, WRITE_PREF_MANUAL)
|
||||
return TRUE
|
||||
if("adjust_color")
|
||||
var/set_new_color = tgui_color_picker(ui.user, "Select a color you wish the lights to flicker as (Default is #E0EFF0)", "Color Selector", flicker_color)
|
||||
if(!set_new_color)
|
||||
return FALSE
|
||||
flicker_color = set_new_color
|
||||
ui.user.write_preference_directly(/datum/preference/color/living/flicker_color, set_new_color)
|
||||
ui.user.write_preference_directly(/datum/preference/color/living/flicker_color, set_new_color, WRITE_PREF_MANUAL)
|
||||
return TRUE
|
||||
if("adjust_break")
|
||||
var/new_break_chance = text2num(params["val"])
|
||||
@@ -239,7 +242,7 @@
|
||||
if(!isnum(new_break_chance))
|
||||
return FALSE
|
||||
flicker_break_chance = new_break_chance
|
||||
ui.user.write_preference_directly(/datum/preference/numeric/living/flicker_break_chance, new_break_chance)
|
||||
ui.user.write_preference_directly(/datum/preference/numeric/living/flicker_break_chance, new_break_chance, WRITE_PREF_MANUAL)
|
||||
return TRUE
|
||||
if("adjust_distance")
|
||||
var/new_distance = text2num(params["val"])
|
||||
@@ -247,16 +250,16 @@
|
||||
if(!isnum(new_distance))
|
||||
return FALSE
|
||||
flicker_distance = new_distance
|
||||
ui.user.write_preference_directly(/datum/preference/numeric/living/flicker_distance, new_distance)
|
||||
ui.user.write_preference_directly(/datum/preference/numeric/living/flicker_distance, new_distance, WRITE_PREF_MANUAL)
|
||||
return TRUE
|
||||
if("toggle_retreat")
|
||||
var/new_retreat = !no_retreat
|
||||
no_retreat = !no_retreat
|
||||
ui.user.write_preference_directly(/datum/preference/toggle/living/dark_retreat_toggle, new_retreat)
|
||||
ui.user.write_preference_directly(/datum/preference/toggle/living/dark_retreat_toggle, new_retreat, WRITE_PREF_MANUAL)
|
||||
if("toggle_nutrition")
|
||||
var/new_retreat = !nutrition_energy_conversion
|
||||
nutrition_energy_conversion = !nutrition_energy_conversion
|
||||
ui.user.write_preference_directly(/datum/preference/toggle/living/shadekin_nutrition_conversion, new_retreat)
|
||||
ui.user.write_preference_directly(/datum/preference/toggle/living/shadekin_nutrition_conversion, new_retreat, WRITE_PREF_MANUAL)
|
||||
|
||||
/mob/living/proc/shadekin_control_panel()
|
||||
set name = "Shadekin Control Panel"
|
||||
|
||||
Reference in New Issue
Block a user