mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-13 09:05:11 +01:00
Accentuate the positive with **Personality**: A (soft) mood rework (#92941)
Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
This commit is contained in:
@@ -417,7 +417,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
return TRUE
|
||||
|
||||
/datum/preferences/proc/GetQuirkBalance()
|
||||
var/bal = 0
|
||||
var/bal = CONFIG_GET(number/default_quirk_points)
|
||||
for(var/V in all_quirks)
|
||||
var/datum/quirk/T = SSquirks.quirks[V]
|
||||
bal -= initial(T.value)
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/datum/preference_middleware/personality
|
||||
action_delegations = list(
|
||||
"handle_personality" = PROC_REF(handle_personality),
|
||||
"clear_personalities" = PROC_REF(clear_personalities),
|
||||
)
|
||||
|
||||
/datum/preference_middleware/personality/proc/handle_personality(list/params, mob/user)
|
||||
var/datum/personality/personality_type = text2path(params["personality_type"])
|
||||
if(!ispath(personality_type, /datum/personality))
|
||||
return FALSE
|
||||
|
||||
var/personality_key = initial(personality_type.savefile_key)
|
||||
var/list/personalities = preferences.read_preference(/datum/preference/personality)
|
||||
if(personality_key in personalities)
|
||||
LAZYREMOVE(personalities, personality_key)
|
||||
else
|
||||
if(LAZYLEN(personalities) >= CONFIG_GET(number/max_personalities))
|
||||
return TRUE
|
||||
if(SSpersonalities.is_incompatible(personalities, personality_type))
|
||||
return TRUE
|
||||
LAZYADD(personalities, personality_key)
|
||||
preferences.update_preference(GLOB.preference_entries[/datum/preference/personality], personalities)
|
||||
return TRUE
|
||||
|
||||
/datum/preference_middleware/personality/proc/clear_personalities(list/params, mob/user)
|
||||
preferences.update_preference(GLOB.preference_entries[/datum/preference/personality], null)
|
||||
return TRUE
|
||||
|
||||
/datum/preference_middleware/personality/get_constant_data()
|
||||
var/list/data = list()
|
||||
|
||||
data["personalities"] = list()
|
||||
for(var/datum/personality/personality_type as anything in SSpersonalities.personalities_by_type)
|
||||
var/datum/personality/personality = SSpersonalities.personalities_by_type[personality_type]
|
||||
data["personalities"] += list(list(
|
||||
"description" = personality.desc,
|
||||
"pos_gameplay_description" = personality.pos_gameplay_desc,
|
||||
"neg_gameplay_description" = personality.neg_gameplay_desc,
|
||||
"neut_gameplay_description" = personality.neut_gameplay_desc,
|
||||
"name" = personality.name,
|
||||
"path" = personality_type,
|
||||
"groups" = personality.groups,
|
||||
))
|
||||
|
||||
data["personality_incompatibilities"] = SSpersonalities.incompatibilities_by_group
|
||||
|
||||
return data
|
||||
|
||||
/datum/preference_middleware/personality/get_ui_static_data(mob/user)
|
||||
var/list/data = list()
|
||||
|
||||
var/max = CONFIG_GET(number/max_personalities)
|
||||
data["max_personalities"] = max >= length(SSpersonalities.personalities_by_type) ? -1 : max
|
||||
data["mood_enabled"] = !CONFIG_GET(flag/disable_human_mood)
|
||||
|
||||
return data
|
||||
|
||||
/datum/preference_middleware/personality/get_ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
|
||||
data["selected_personalities"] = list()
|
||||
for(var/personality_key in preferences.read_preference(/datum/preference/personality))
|
||||
var/datum/personality/personality = SSpersonalities.personalities_by_key[personality_key]
|
||||
data["selected_personalities"] += personality.type
|
||||
|
||||
return data
|
||||
@@ -49,6 +49,7 @@
|
||||
var/list/data = list()
|
||||
|
||||
data["selected_quirks"] = get_selected_quirks()
|
||||
data["default_quirk_balance"] = CONFIG_GET(number/default_quirk_points)
|
||||
data["species_disallowed_quirks"] = get_species_compatibility()
|
||||
|
||||
return data
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Replace a quirk with a personality
|
||||
*
|
||||
* If this is accompanied with removal of a quirk,
|
||||
* you don't need to worry about handling that here -
|
||||
* quirk sanitization happens AFTER migration
|
||||
*/
|
||||
/datum/preferences/proc/migrate_quirk_to_personality(quirk_to_migrate, datum/personality/new_typepath)
|
||||
ASSERT(istext(quirk_to_migrate) && ispath(new_typepath, /datum/personality))
|
||||
if(!(quirk_to_migrate in all_quirks))
|
||||
return
|
||||
var/list/personalities = read_preference(/datum/preference/personality)
|
||||
if(LAZYLEN(personalities) >= CONFIG_GET(number/max_personalities))
|
||||
return
|
||||
LAZYADD(personalities, initial(new_typepath.savefile_key))
|
||||
write_preference(GLOB.preference_entries[/datum/preference/personality], personalities)
|
||||
@@ -13,7 +13,7 @@
|
||||
/// You do not need to raise this if you are adding new values that have sane defaults.
|
||||
/// Only raise this value when changing the meaning/format/name/layout of an existing value
|
||||
/// where you would want the updater procs below to run
|
||||
#define SAVEFILE_VERSION_MAX 49
|
||||
#define SAVEFILE_VERSION_MAX 50
|
||||
|
||||
#define IS_DATA_OBSOLETE(version) (version == SAVE_DATA_OBSOLETE)
|
||||
#define SHOULD_UPDATE_DATA(version) (version >= SAVE_DATA_NO_ERROR && version < SAVEFILE_VERSION_MAX)
|
||||
@@ -137,6 +137,31 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
quirk_to_migrate = "Cyborg Pre-screened dogtag",
|
||||
new_typepath = /obj/item/clothing/accessory/dogtag/borg_ready,
|
||||
)
|
||||
if(current_version < 50)
|
||||
migrate_quirk_to_personality(
|
||||
quirk_to_migrate = "Extrovert",
|
||||
new_typepath = /datum/personality/extrovert,
|
||||
)
|
||||
migrate_quirk_to_personality(
|
||||
quirk_to_migrate = "Introvert",
|
||||
new_typepath = /datum/personality/introvert,
|
||||
)
|
||||
migrate_quirk_to_personality(
|
||||
quirk_to_migrate = "Bad Touch",
|
||||
new_typepath = /datum/personality/aloof,
|
||||
)
|
||||
migrate_quirk_to_personality(
|
||||
quirk_to_migrate = "Apathetic",
|
||||
new_typepath = /datum/personality/apathetic,
|
||||
)
|
||||
migrate_quirk_to_personality(
|
||||
quirk_to_migrate = "Snob",
|
||||
new_typepath = /datum/personality/snob,
|
||||
)
|
||||
migrate_quirk_to_personality(
|
||||
quirk_to_migrate = "Spiritual",
|
||||
new_typepath = /datum/personality/spiritual,
|
||||
)
|
||||
|
||||
/// checks through keybindings for outdated unbound keys and updates them
|
||||
/datum/preferences/proc/check_keybindings()
|
||||
|
||||
Reference in New Issue
Block a user