mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Ported tg asset cache
This commit is contained in:
committed by
Arokha Sieyes
parent
d5b820fc58
commit
22c85075f4
17
code/controllers/subsystems/assets.dm
Normal file
17
code/controllers/subsystems/assets.dm
Normal file
@@ -0,0 +1,17 @@
|
||||
SUBSYSTEM_DEF(assets)
|
||||
name = "Assets"
|
||||
init_order = INIT_ORDER_ASSETS
|
||||
flags = SS_NO_FIRE
|
||||
var/list/cache = list()
|
||||
var/list/preload = list()
|
||||
|
||||
/datum/controller/subsystem/assets/Initialize(timeofday)
|
||||
for(var/type in typesof(/datum/asset) - list(/datum/asset, /datum/asset/simple))
|
||||
var/datum/asset/A = new type()
|
||||
A.register()
|
||||
|
||||
preload = cache.Copy() //don't preload assets generated during the round
|
||||
|
||||
for(var/client/C in GLOB.clients)
|
||||
addtimer(CALLBACK(GLOBAL_PROC, .proc/getFilesSlow, C, preload, FALSE), 10)
|
||||
return ..()
|
||||
@@ -24,7 +24,7 @@ SUBSYSTEM_DEF(nanoui)
|
||||
for(var/filename in filenames)
|
||||
if(copytext(filename, length(filename)) != "/") // filenames which end in "/" are actually directories, which we want to ignore
|
||||
if(fexists(path + filename))
|
||||
asset_files.Add(fcopy_rsc(path + filename)) // add this file to asset_files for sending to clients when they connect
|
||||
asset_files[filename] = fcopy_rsc(path + filename) // add this file to asset_files for sending to clients when they connect
|
||||
.=..()
|
||||
for(var/i in GLOB.clients)
|
||||
send_resources(i)
|
||||
@@ -49,5 +49,4 @@ SUBSYSTEM_DEF(nanoui)
|
||||
/datum/controller/subsystem/nanoui/proc/send_resources(client)
|
||||
if(!subsystem_initialized)
|
||||
return
|
||||
for(var/file in asset_files)
|
||||
client << browse_rsc(file) // send the file to the client
|
||||
getFilesSlow(client, asset_files)
|
||||
Reference in New Issue
Block a user