mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-10 15:45:05 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
105 lines
4.1 KiB
Plaintext
105 lines
4.1 KiB
Plaintext
PROCESSING_SUBSYSTEM_DEF(greyscale)
|
|
name = "Greyscale"
|
|
ss_flags = SS_BACKGROUND
|
|
wait = 3 SECONDS
|
|
init_stage = INITSTAGE_EARLY
|
|
var/list/datum/greyscale_config/configurations = list()
|
|
var/list/datum/greyscale_layer/layer_types = list()
|
|
#ifdef USE_RUSTG_ICONFORGE_GAGS
|
|
/// Cache containing a list of [UID (config path + colors)] -> [DMI file / RSC object] in the tmp directory from iconforge
|
|
var/list/gags_cache = list()
|
|
#endif
|
|
|
|
/datum/controller/subsystem/processing/greyscale/Initialize()
|
|
for(var/datum/greyscale_layer/greyscale_layer as anything in subtypesof(/datum/greyscale_layer))
|
|
layer_types[initial(greyscale_layer.layer_type)] = greyscale_layer
|
|
|
|
for(var/greyscale_type in subtypesof(/datum/greyscale_config))
|
|
var/datum/greyscale_config/config = new greyscale_type()
|
|
configurations["[greyscale_type]"] = config
|
|
|
|
// We do this after all the types have been loaded into the listing so reference layers don't care about init order
|
|
for(var/greyscale_type in configurations)
|
|
CHECK_TICK
|
|
var/datum/greyscale_config/config = configurations[greyscale_type]
|
|
config.Refresh()
|
|
|
|
#ifdef USE_RUSTG_ICONFORGE_GAGS
|
|
var/list/job_ids = list()
|
|
#endif
|
|
|
|
// This final verification step is for things that need other greyscale configurations to be finished loading
|
|
for(var/greyscale_type in configurations)
|
|
CHECK_TICK
|
|
var/datum/greyscale_config/config = configurations[greyscale_type]
|
|
config.CrossVerify()
|
|
#ifdef USE_RUSTG_ICONFORGE_GAGS
|
|
job_ids += rustg_iconforge_load_gags_config_async(greyscale_type, config.raw_json_string, config.string_icon_file)
|
|
|
|
UNTIL(jobs_completed(job_ids))
|
|
#endif
|
|
|
|
return SS_INIT_SUCCESS
|
|
|
|
#ifdef USE_RUSTG_ICONFORGE_GAGS
|
|
/datum/controller/subsystem/processing/greyscale/proc/jobs_completed(list/job_ids)
|
|
for(var/job in job_ids)
|
|
var/result = rustg_iconforge_check(job)
|
|
if(result == RUSTG_JOB_NO_RESULTS_YET)
|
|
return FALSE
|
|
if(result != "OK")
|
|
stack_trace("Error during rustg_iconforge_load_gags_config job: [result]")
|
|
job_ids -= job
|
|
return TRUE
|
|
#endif
|
|
|
|
/datum/controller/subsystem/processing/greyscale/proc/RefreshConfigsFromFile()
|
|
for(var/i in configurations)
|
|
configurations[i].Refresh(TRUE)
|
|
|
|
/datum/controller/subsystem/processing/greyscale/proc/GetColoredIconByType(type, list/colors)
|
|
if(!ispath(type, /datum/greyscale_config))
|
|
CRASH("An invalid greyscale configuration was given to `GetColoredIconByType()`: [type]")
|
|
if(!initialized)
|
|
CRASH("GetColoredIconByType() called before greyscale subsystem initialized!")
|
|
type = "[type]"
|
|
if(istype(colors)) // It's the color list format
|
|
colors = colors.Join()
|
|
else if(!istext(colors))
|
|
CRASH("Invalid colors were given to `GetColoredIconByType()`: [colors]")
|
|
#ifdef USE_RUSTG_ICONFORGE_GAGS
|
|
var/uid = "[replacetext(replacetext(type, "/datum/greyscale_config/", ""), "/", "-")]-[colors]"
|
|
var/cached_file = gags_cache[uid]
|
|
if(cached_file)
|
|
return cached_file
|
|
var/output_path = "tmp/gags/icons/gags-[uid].dmi"
|
|
var/iconforge_output = rustg_iconforge_gags(type, colors, output_path)
|
|
// Handle errors from IconForge
|
|
if(iconforge_output != "OK")
|
|
CRASH(iconforge_output)
|
|
// We'll just explicitly do fcopy_rsc here, so the game doesn't have to do it again later from the cached file.
|
|
var/rsc_gags_icon = fcopy_rsc(file(output_path))
|
|
gags_cache[uid] = rsc_gags_icon
|
|
return rsc_gags_icon
|
|
#else
|
|
return configurations[type].Generate(colors)
|
|
#endif
|
|
|
|
/datum/controller/subsystem/processing/greyscale/proc/GetColoredIconByTypeUniversalIcon(type, list/colors, target_icon_state)
|
|
if(!ispath(type, /datum/greyscale_config))
|
|
CRASH("An invalid greyscale configuration was given to `GetColoredIconByTypeUniversalIcon()`: [type]")
|
|
type = "[type]"
|
|
if(istype(colors)) // It's the color list format
|
|
colors = colors.Join()
|
|
else if(!istext(colors))
|
|
CRASH("Invalid colors were given to `GetColoredIconByTypeUniversalIcon()`: [colors]")
|
|
return configurations[type].GenerateUniversalIcon(colors, target_icon_state)
|
|
|
|
/datum/controller/subsystem/processing/greyscale/proc/ParseColorString(color_string)
|
|
. = list()
|
|
var/list/split_colors = splittext(color_string, "#")
|
|
for(var/color in 2 to length(split_colors))
|
|
. += "#[split_colors[color]]"
|
|
|
|
#undef USE_RUSTG_ICONFORGE_GAGS
|