mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-20 03:25:49 +01:00
91660824fa
* initial commit (broken)
* load the html
* fix this
* Fix various issues with browser statpanel
* Fix Alt Clicking opening up a window and Add back some object verbs to the browser stat panel
* Optimize stat panel and fix guardian verbs
* Restyles Stat Panel, Adds Subpanel Sub-Categories
* Use better layout for verbs in stat panel
* Updates statpanel verb widths to be more dynamic at higher screen resolutions.
* Adjust stat panel grid item widths and breakpoints
* refactors statpanel to use tgui API
* CI moment
* more CI
* this stupid thing
* Apply suggestions from code review
Co-authored-by: GDN <96800819+GDNgit@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
* Update code/modules/client/client_procs.dm
* ci fix
* emergency mc debug view
* temp revert some code change suggestions due to massive runtiming
* proper atom click topic implementation
* optimise
* mob clicking in stat panels work
* yeet spell tab thingy
* yeet simple stat panel pref
* allow insertion of html into MC tab content
* tidy up status tab
* Apply suggestions from code review
* fix this
* fix CI
* oops
* fix index runtime
* fixes MC tab showing up for mentors, fixes runtime
* safeties!
* Return of theme support
* more fixes
* fix view range pref, tidy prefs tab
* Remove old stat panel from themes
* fixes
* make sure verbs don't go missing
* fix ooc/looc breaking
* Revert "make sure verbs don't go missing"
This reverts commit 7d07ad45ed.
* fix this properly
* fix stat panel hitting rate limiters
* fix borg status tab
* Object Window Niceties
* Adds file cycling for icon2base64
* optimizes icon2html() for icon files known to be in the rsc at compile time
* CI moment
* remove dupe emergency shuttle timers
* more robust verb updates
* statpanel tweaks
* zip archived changelog to avoid search results
* optimise
* fix mentor chat wonkyness when disabled
* debug log moment
* i am very smart
* reintroduce this because it was needed
* better time listings
* less jank
* stops telling admins they arent mentors
* returns MC tab pref for admins
* Update code/controllers/subsystem/SSstatpanel.dm
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
* lewcc
* OD typemaker prep
---------
Co-authored-by: GDN <96800819+GDNgit@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Co-authored-by: Aylong <alexanderkitsa@gmail.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
162 lines
6.7 KiB
Plaintext
162 lines
6.7 KiB
Plaintext
/// When sending mutiple assets, how many before we give the client a quaint little sending resources message
|
|
#define ASSET_CACHE_TELL_CLIENT_AMOUNT 8
|
|
|
|
/// Base browse_rsc asset transport
|
|
/datum/asset_transport
|
|
var/name = "Simple browse_rsc asset transport"
|
|
var/static/list/preload
|
|
/// Don't mutate the filename of assets when sending via browse_rsc.
|
|
/// This is to make it easier to debug issues with assets, and allow server operators to bypass issues that make it to production.
|
|
/// If turning this on fixes asset issues, something isn't using SSassets.transport.get_asset_url and the asset isn't marked legacy, fix one of those.
|
|
var/dont_mutate_filenames = FALSE
|
|
|
|
/// Initialize - Called when SSassets initializes.
|
|
/datum/asset_transport/proc/Initialize(list/assets)
|
|
preload = assets.Copy()
|
|
Load()
|
|
|
|
/// 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(!GLOB.configuration.asset_cache.asset_simple_preload)
|
|
return
|
|
for(var/client/C as anything in GLOB.clients)
|
|
addtimer(CALLBACK(src, PROC_REF(send_assets_slow), C, preload), 1 SECONDS)
|
|
|
|
|
|
/**
|
|
* Register a browser asset with the asset cache system.
|
|
* returns a /datum/asset_cache_item.
|
|
* mutiple calls to register the same asset under the same asset_name return the same datum.
|
|
*
|
|
* Arguments:
|
|
* * asset_name - the identifier of the asset.
|
|
* * asset - the actual asset file (or an asset_cache_item datum).
|
|
* * file_hash - optional, a hash of the contents of the asset files contents. used so asset_cache_item doesnt have to hash it again
|
|
* * dmi_file_path - optional, means that the given asset is from the rsc and thus we dont need to do some expensive operations
|
|
*/
|
|
/datum/asset_transport/proc/register_asset(asset_name, asset, file_hash, dmi_file_path)
|
|
var/datum/asset_cache_item/ACI = asset
|
|
if(!istype(ACI))
|
|
ACI = new(asset_name, asset, file_hash, dmi_file_path)
|
|
if(!ACI || !ACI.hash)
|
|
CRASH("ERROR: Invalid asset: [asset_name]:[asset]:[ACI]")
|
|
if(SSassets.cache[asset_name])
|
|
var/datum/asset_cache_item/OACI = SSassets.cache[asset_name]
|
|
OACI.legacy = ACI.legacy = (ACI.legacy|OACI.legacy)
|
|
OACI.namespace_parent = ACI.namespace_parent = (ACI.namespace_parent | OACI.namespace_parent)
|
|
OACI.namespace = OACI.namespace || ACI.namespace
|
|
if(OACI.hash != ACI.hash)
|
|
var/error_msg = "ERROR: new asset added to the asset cache with the same name as another asset: [asset_name] existing asset hash: [OACI.hash] new asset hash:[ACI.hash]"
|
|
stack_trace(error_msg)
|
|
log_debug(error_msg)
|
|
else
|
|
if(length(ACI.namespace))
|
|
return ACI
|
|
return OACI
|
|
|
|
SSassets.cache[asset_name] = ACI
|
|
return ACI
|
|
|
|
|
|
/// Returns a url for a given asset.
|
|
/// asset_name - Name of the asset.
|
|
/// asset_cache_item - asset cache item datum for the asset, optional, overrides asset_name
|
|
/datum/asset_transport/proc/get_asset_url(asset_name, datum/asset_cache_item/asset_cache_item)
|
|
if(!istype(asset_cache_item))
|
|
asset_cache_item = SSassets.cache[asset_name]
|
|
// To ensure code that breaks on cdns breaks in local testing, we only
|
|
// use the normal filename on legacy assets and name space assets.
|
|
var/keep_local_name = dont_mutate_filenames \
|
|
|| asset_cache_item.legacy \
|
|
|| asset_cache_item.keep_local_name \
|
|
|| (asset_cache_item.namespace && !asset_cache_item.namespace_parent)
|
|
if(keep_local_name)
|
|
return url_encode(asset_cache_item.name)
|
|
return url_encode("asset.[asset_cache_item.hash][asset_cache_item.ext]")
|
|
|
|
|
|
/// Sends a list of browser assets to a client
|
|
/// client - a client or mob
|
|
/// asset_list - A list of asset filenames to be sent to the client. Can optionally be assoicated with the asset's asset_cache_item datum.
|
|
/// Returns TRUE if any assets were sent.
|
|
/datum/asset_transport/proc/send_assets(client/client, list/asset_list)
|
|
if(!istype(client))
|
|
if(ismob(client))
|
|
var/mob/M = client
|
|
if(M.client)
|
|
client = M.client
|
|
else //no stacktrace because this will mainly happen because the client went away
|
|
return
|
|
else
|
|
CRASH("Invalid argument: client: `[client]`")
|
|
if(!islist(asset_list))
|
|
asset_list = list(asset_list)
|
|
var/list/unreceived = list()
|
|
|
|
for(var/asset_name in asset_list)
|
|
var/datum/asset_cache_item/ACI = asset_list[asset_name]
|
|
if(!istype(ACI) && !(ACI = SSassets.cache[asset_name]))
|
|
log_debug("ERROR: can't send asset `[asset_name]`: unregistered or invalid state: `[ACI]`")
|
|
continue
|
|
var/asset_file = ACI.resource
|
|
if(!asset_file)
|
|
log_debug("ERROR: can't send asset `[asset_name]`: invalid registered resource: `[ACI.resource]`")
|
|
continue
|
|
|
|
var/asset_hash = ACI.hash
|
|
var/new_asset_name = asset_name
|
|
var/keep_local_name = dont_mutate_filenames \
|
|
|| ACI.legacy \
|
|
|| ACI.keep_local_name \
|
|
|| (ACI.namespace && !ACI.namespace_parent)
|
|
if(!keep_local_name)
|
|
new_asset_name = "asset.[ACI.hash][ACI.ext]"
|
|
if(client.sent_assets[new_asset_name] == asset_hash)
|
|
// Un-comment below to debug asset sending (This will spam logs so do not enable normally)
|
|
// log_debug("Skipping send of `[asset_name]` (as `[new_asset_name]`) for `[client]` because it already exists in the client's sent_assets list")
|
|
continue
|
|
unreceived[asset_name] = ACI
|
|
|
|
if(length(unreceived))
|
|
if(length(unreceived) >= ASSET_CACHE_TELL_CLIENT_AMOUNT)
|
|
to_chat(client, "Sending Resources...")
|
|
|
|
for(var/asset_name in unreceived)
|
|
var/new_asset_name = asset_name
|
|
var/datum/asset_cache_item/ACI = unreceived[asset_name]
|
|
var/keep_local_name = dont_mutate_filenames \
|
|
|| ACI.legacy \
|
|
|| ACI.keep_local_name \
|
|
|| (ACI.namespace && !ACI.namespace_parent)
|
|
if(!keep_local_name)
|
|
new_asset_name = "asset.[ACI.hash][ACI.ext]"
|
|
// Un-comment below to debug asset sending (This will spam logs so do not enable normally)
|
|
// log_debug("Sending asset `[asset_name]` to client `[client]` as `[new_asset_name]`")
|
|
client << browse_rsc(ACI.resource, new_asset_name)
|
|
|
|
client.sent_assets[new_asset_name] = ACI.hash
|
|
|
|
addtimer(CALLBACK(client, /client/proc/asset_cache_update_json), 1 SECONDS, TIMER_UNIQUE|TIMER_OVERRIDE)
|
|
return TRUE
|
|
return FALSE
|
|
|
|
|
|
/// Precache files without clogging up the browse() queue, used for passively sending files on connection start.
|
|
/datum/asset_transport/proc/send_assets_slow(client/client, list/files, filerate = 6)
|
|
var/startingfilerate = filerate
|
|
for(var/file in files)
|
|
if(!client)
|
|
break
|
|
if(send_assets(client, file))
|
|
if(!(--filerate))
|
|
filerate = startingfilerate
|
|
client.browse_queue_flush()
|
|
stoplag(0) //queuing calls like this too quickly can cause issues in some client versions
|
|
|
|
/// Check the config is valid to load this transport
|
|
/// Returns TRUE or FALSE
|
|
/datum/asset_transport/proc/validate_config(log = TRUE)
|
|
return TRUE
|
|
|
|
#undef ASSET_CACHE_TELL_CLIENT_AMOUNT
|