mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 07:08:00 +01:00
Update NanoUI to use the asset_cache system
Also move a bunch of folders around.
This commit is contained in:
@@ -138,8 +138,7 @@ var/list/admin_verbs_debug = list(
|
||||
/client/proc/cmd_display_del_log,
|
||||
/client/proc/reset_latejoin_spawns,
|
||||
/client/proc/create_outfits,
|
||||
/client/proc/debug_huds,
|
||||
/client/proc/reload_nanoui_resources
|
||||
/client/proc/debug_huds
|
||||
)
|
||||
var/list/admin_verbs_possess = list(
|
||||
/proc/possess,
|
||||
@@ -278,6 +277,7 @@ var/list/admin_verbs_hideable = list(
|
||||
/client/proc/cmd_admin_grantfullaccess,
|
||||
/client/proc/cmd_admin_areatest,
|
||||
/client/proc/readmin,
|
||||
/client/proc/reload_nanoui_resources
|
||||
)
|
||||
if(holder)
|
||||
verbs.Remove(holder.rank.adds)
|
||||
|
||||
@@ -782,7 +782,12 @@ var/global/list/g_fancy_list_of_types = null
|
||||
set name = "Reload NanoUI Resources"
|
||||
set desc = "Force the client to redownload NanoUI Resources"
|
||||
|
||||
var/list/resources = SSnano.get_resources()
|
||||
|
||||
// Close open NanoUIs.
|
||||
SSnano.close_user_uis(usr)
|
||||
SSnano.send_resources(src, resources, force = 1)
|
||||
|
||||
// Re-load the assets.
|
||||
var/datum/asset/assets = get_asset_datum(/datum/asset/nanoui)
|
||||
assets.register()
|
||||
|
||||
// Clear the user's cache so they get resent.
|
||||
usr.client.cache = list()
|
||||
|
||||
@@ -161,6 +161,7 @@ var/intercom_range_display_status = 0
|
||||
src.verbs += /client/proc/cmd_show_at_list
|
||||
src.verbs += /client/proc/cmd_show_at_list
|
||||
src.verbs += /client/proc/manipulate_organs
|
||||
src.verbs += /client/proc/reload_nanoui_resources
|
||||
//src.verbs += /client/proc/cmd_admin_rejuvenate
|
||||
|
||||
feedback_add_details("admin_verb","mDV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
|
||||
@@ -204,3 +204,39 @@ proc/getFilesSlow(var/client/client, var/list/files, var/register_asset = TRUE)
|
||||
for(var/path in typesof(/datum/html_interface))
|
||||
var/datum/html_interface/hi = new path()
|
||||
hi.registerResources()
|
||||
|
||||
/datum/asset/nanoui
|
||||
var/list/common = list()
|
||||
|
||||
var/list/common_dirs = list(
|
||||
"nano/styles/",
|
||||
"nano/scripts/",
|
||||
"nano/images/",
|
||||
"nano/layouts/"
|
||||
)
|
||||
var/list/uncommon_dirs = list(
|
||||
"nano/interfaces/"
|
||||
)
|
||||
|
||||
/datum/asset/nanoui/register()
|
||||
// Crawl the directories to find files.
|
||||
for (var/path in common_dirs)
|
||||
var/list/filenames = flist(path)
|
||||
for(var/filename in filenames)
|
||||
if(copytext(filename, length(filename)) != "/") // Ignore directories.
|
||||
if(fexists(path + filename))
|
||||
common[filename] = fcopy_rsc(path + filename)
|
||||
register_asset(filename, common[filename])
|
||||
for (var/path in uncommon_dirs)
|
||||
var/list/filenames = flist(path)
|
||||
for(var/filename in filenames)
|
||||
if(copytext(filename, length(filename)) != "/") // Ignore directories.
|
||||
if(fexists(path + filename))
|
||||
register_asset(filename, fcopy_rsc(path + filename))
|
||||
|
||||
/datum/asset/nanoui/send(client, uncommon)
|
||||
if(!islist(uncommon))
|
||||
uncommon = list(uncommon)
|
||||
|
||||
send_asset_list(client, uncommon, FALSE)
|
||||
send_asset_list(client, common, TRUE)
|
||||
@@ -333,9 +333,5 @@ var/next_external_rsc = 0
|
||||
'html/browser/playeroptions.css',
|
||||
)
|
||||
spawn (10)
|
||||
//Send nanoui files to client
|
||||
SSnano.send_resources(src)
|
||||
|
||||
//Precache the client with all other assets slowly, so as to not block other browse() calls
|
||||
getFilesSlow(src, asset_cache, register_asset = FALSE)
|
||||
|
||||
|
||||
@@ -87,6 +87,9 @@
|
||||
|
||||
add_common_assets()
|
||||
|
||||
var/datum/asset/assets = get_asset_datum(/datum/asset/nanoui)
|
||||
assets.send(user, template)
|
||||
|
||||
/**
|
||||
* private
|
||||
*
|
||||
|
||||
@@ -229,48 +229,3 @@
|
||||
|
||||
oldMob.open_uis.Cut() // Clear the old list.
|
||||
return 1 // Let the caller know we did it.
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Generate the list of resources to be sent to clients.
|
||||
* fcopy the resources to make them available as rscs.
|
||||
*
|
||||
* return list The resource files.
|
||||
**/
|
||||
/datum/subsystem/nano/proc/get_resources()
|
||||
var/list/resources = list()
|
||||
// A list of folders to be sent.
|
||||
var/list/resource_dirs = list(\
|
||||
"nano/css/",\
|
||||
"nano/images/",\
|
||||
"nano/js/",\
|
||||
"nano/templates/"\
|
||||
)
|
||||
|
||||
// Crawl the directories to find files.
|
||||
for (var/path in resource_dirs)
|
||||
var/list/filenames = flist(path)
|
||||
for(var/filename in filenames)
|
||||
if(copytext(filename, length(filename)) != "/") // Ignore directories.
|
||||
if(fexists(path + filename))
|
||||
resources[filename] = fcopy_rsc(path + filename)
|
||||
|
||||
return resources
|
||||
|
||||
/**
|
||||
* public
|
||||
*
|
||||
* Send a list of resource files to the client.
|
||||
* Use the asset_cache system by default.
|
||||
*
|
||||
* required client The client recieving the resources.
|
||||
* optional resources The resources to be sent.
|
||||
* optional force Bypass the asset_cache system to force a redownload.
|
||||
**/
|
||||
/datum/subsystem/nano/proc/send_resources(client/client, list/resources = resource_files, force = 0)
|
||||
if (force)
|
||||
for(var/resource in resources)
|
||||
client << browse_rsc(resources[resource])
|
||||
else
|
||||
getFilesSlow(client, resources)
|
||||
|
||||
Reference in New Issue
Block a user