Configuration Controller (#7857)

This commit is contained in:
Selis
2024-04-05 07:44:20 +02:00
committed by GitHub
parent c542e3bac0
commit e1a987c25c
235 changed files with 3294 additions and 989 deletions

View File

@@ -61,7 +61,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
/// Returns whether or not the asset should attempt to read from cache
/datum/asset/proc/should_refresh()
return !cross_round_cachable || !config.cache_assets
return !cross_round_cachable || !CONFIG_GET(flag/cache_assets) // CHOMPEdit
/// Simply takes any generated file and saves it to the round-specific /logs folder. Useful for debugging potential issues with spritesheet generation/display.
/// Only called when the SAVE_SPRITESHEETS config option is uncommented.
@@ -180,7 +180,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
return
// If it's cached, may as well load it now, while the loading is cheap
if(config.cache_assets && cross_round_cachable)
if(CONFIG_GET(flag/cache_assets) && cross_round_cachable) // CHOMPEdit
load_immediately = TRUE
create_spritesheets()
@@ -209,12 +209,12 @@ GLOBAL_LIST_EMPTY(asset_datums)
text2file(generate_css(), file_directory)
SSassets.transport.register_asset(css_name, fcopy_rsc(file_directory))
if(config.save_spritesheets)
if(CONFIG_GET(flag/save_spritesheets)) // CHOMPEdit
save_to_logs(file_name = css_name, file_location = file_directory)
fdel(file_directory)
if (config.cache_assets && cross_round_cachable)
if (CONFIG_GET(flag/cache_assets) && cross_round_cachable) // CHOMPEdit
write_to_cache()
fully_generated = TRUE
// If we were ever in there, remove ourselves
@@ -267,7 +267,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
size[SPRSZ_STRIPPED] = icon(file_directory)
// this is useful here for determining if weird sprite issues (like having a white background) are a cause of what we're doing DM-side or not since we can see the full flattened thing at-a-glance.
if(config.save_spritesheets)
if(CONFIG_GET(flag/save_spritesheets)) // CHOMPEdit
save_to_logs(file_name = png_name, file_location = file_directory)
fdel(file_directory)
@@ -321,7 +321,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
rustg_file_write(replaced_css, replaced_css_filename)
SSassets.transport.register_asset(finalized_name, replaced_css_filename)
if(config.save_spritesheets)
if(CONFIG_GET(flag/save_spritesheets)) // CHOMPEdit
save_to_logs(file_name = finalized_name, file_location = replaced_css_filename)
fdel(replaced_css_filename)

View File

@@ -12,14 +12,14 @@
/// Called when the transport is loaded by the config controller, not called on the default transport unless it gets loaded by a config change.
/datum/asset_transport/proc/Load()
if (config.asset_simple_preload)
if (CONFIG_GET(flag/asset_simple_preload)) // CHOMPEdit
for(var/client/C in GLOB.clients)
addtimer(CALLBACK(src, PROC_REF(send_assets_slow), C, preload), 1 SECONDS)
/// Initialize - Called when SSassets initializes.
/datum/asset_transport/proc/Initialize(list/assets)
preload = assets.Copy()
if (!config.asset_simple_preload)
if (!CONFIG_GET(flag/asset_simple_preload)) // CHOMPEdit
return
for(var/client/C in GLOB.clients)
addtimer(CALLBACK(src, PROC_REF(send_assets_slow), C, preload), 1 SECONDS)

View File

@@ -25,7 +25,7 @@
/// Saves the asset to the webroot taking into account namespaces and hashes.
/datum/asset_transport/webroot/proc/save_asset_to_webroot(datum/asset_cache_item/ACI)
var/webroot = config.asset_cdn_webroot
var/webroot = CONFIG_GET(string/asset_cdn_webroot) // CHOMPEdit
var/newpath = "[webroot][get_asset_suffex(ACI)]"
if (fexists(newpath))
return
@@ -39,7 +39,7 @@
/datum/asset_transport/webroot/get_asset_url(asset_name, datum/asset_cache_item/asset_cache_item)
if (!istype(asset_cache_item))
asset_cache_item = SSassets.cache[asset_name]
var/url = config.asset_cdn_url //config loading will handle making sure this ends in a /
var/url = CONFIG_GET(string/asset_cdn_url) //config loading will handle making sure this ends in a / // CHOMPEdit
return "[url][get_asset_suffex(asset_cache_item)]"
/datum/asset_transport/webroot/proc/get_asset_suffex(datum/asset_cache_item/asset_cache_item)
@@ -76,11 +76,11 @@
return FALSE
/datum/asset_transport/webroot/validate_config(log = TRUE)
if (!config.asset_cdn_url)
if (!CONFIG_GET(string/asset_cdn_url)) // CHOMPEdit
if (log)
log_asset("ERROR: [type]: Invalid Config: ASSET_CDN_URL")
return FALSE
if (!config.asset_cdn_webroot)
if (!CONFIG_GET(string/asset_cdn_webroot)) // CHOMPEdit
if (log)
log_asset("ERROR: [type]: Invalid Config: ASSET_CDN_WEBROOT")
return FALSE