Files
Bubberstation/code/modules/client/preferences/assets.dm
SkyratBot 124ddd7cca [MIRROR] tgui Preferences Menu + total rewrite of the preferences backend (#8153)
* tgui Preferences Menu + total rewrite of the preferences backend

* nah, we dont need to ping those people

* trying to remove the funny stuff

* unmodularizing this

* prefs reset

* this may need to be reverted, who knows

* okay, this part

* perhaps

* EEEEEEEEE

* unsanitary

* E

* Stage 1 + loadout system

* more fixes

* E

* I mean, it launches?

* More fixes and reorganisation

* E

* customisation code is spaget.

* disable ERP prefs

* Update erp_preferences.dm

* Update erp_preferences.dm

* E

* Slowly getting there

* It may be time for help :)

* tri...colors... help

* preferences now pass preferences

* Update dna.dm

* Fuck this man

* missing savefile return, set_species works, removed dumb stuff from updateappearance

* https://github.com/Skyrat-SS13/Skyrat-tg/pull/8199

* https://github.com/Skyrat-SS13/Skyrat-tg/pull/8224

* https://github.com/tgstation/tgstation/pull/61519

* https://github.com/Skyrat-SS13/Skyrat-tg/pull/8278

* e

* le butonAZARAK HELLO

* hhh

* Proper recognition where it's due, MrMelbert!

* EEEE

* examine block

* Better gen hit sounds from whitedream

* final loadout touches, more bug fixes im sure to come

* i said there would be bugfixes

* Update LoadoutManager.js

* Missing preferences in the html menu

* LIVE TESTING PHASE BABY

* Update LoadoutManager.js

* EEE

* LAUNCH TEST FIRE

* Update job.dm

* Update new_player.dm

* 50gb DAY ONE PATCH

* EEE

* Update preferences.dm

* buggle fixes

* Update examine.dm

* >LOOC starts on

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: jjpark-kb <55967837+jjpark-kb@users.noreply.github.com>
Co-authored-by: Gandalf <jzo123@hotmail.com>
Co-authored-by: Azarak <azarak10@gmail.com>
2021-09-23 00:40:37 +01:00

67 lines
2.1 KiB
Plaintext

/// Assets generated from `/datum/preference` icons
/datum/asset/spritesheet/preferences
name = "preferences"
early = TRUE
/datum/asset/spritesheet/preferences/register()
var/list/to_insert = list()
for (var/preference_key in GLOB.preference_entries_by_key)
var/datum/preference/choiced/preference = GLOB.preference_entries_by_key[preference_key]
if (!istype(preference))
continue
if (!preference.should_generate_icons)
continue
var/list/choices = preference.get_choices_serialized()
for (var/preference_value in choices)
var/create_icon_of = choices[preference_value]
var/icon/icon
var/icon_state
if (ispath(create_icon_of, /atom))
var/atom/atom_icon_source = create_icon_of
icon = initial(atom_icon_source.icon)
icon_state = initial(atom_icon_source.icon_state)
else if (isicon(create_icon_of))
icon = create_icon_of
else
CRASH("[create_icon_of] is an invalid preference value (from [preference_key]:[preference_value]).")
to_insert[preference.get_spritesheet_key(preference_value)] = list(icon, icon_state)
for (var/spritesheet_key in to_insert)
var/list/inserting = to_insert[spritesheet_key]
Insert(spritesheet_key, inserting[1], inserting[2])
return ..()
/// Returns the key that will be used in the spritesheet for a given value.
/datum/preference/proc/get_spritesheet_key(value)
return "[savefile_key]___[sanitize_css_class_name(value)]"
/// Sends information needed for shared details on individual preferences
/datum/asset/json/preferences
name = "preferences"
/datum/asset/json/preferences/generate()
var/list/preference_data = list()
for (var/middleware_type in subtypesof(/datum/preference_middleware))
var/datum/preference_middleware/middleware = new middleware_type
var/data = middleware.get_constant_data()
if (!isnull(data))
preference_data[middleware.key] = data
qdel(middleware)
for (var/preference_type in GLOB.preference_entries)
var/datum/preference/preference_entry = GLOB.preference_entries[preference_type]
var/data = preference_entry.compile_constant_data()
if (!isnull(data))
preference_data[preference_entry.savefile_key] = data
return preference_data