mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
Merge branch 'Global-asset' into 'Bleeding-Edge'
Global Asset Cache. This is my attempt to fix login lag. Resources sent to clients via `browse_rsc()`, most commonly at `/client/New()`, these resources include stylesheets, images, javascript files, ... and other things used in UIs. All these files get sent by our BYOND code in an instant, except that it takes BYOND goddamn ages to get them to the client them. What this MR attempts to do is send files when they are first needed, instead of when the client first logs in. The way it works: "Assets", things that get sent to the client somewhere, are stored in a global cache, the `asset_cache`, this is an assoc list with the key being the filename on the client and the assoc value being the actual thing that gets sent, it can be anything supported by `browse_rsc()`. Clients are stored with a list of resources they SHOULD have, this list DOES NOT persist between rounds or even client reconnections, as that would be unsafe. When a UI (or anything in general) needs an asset, it will call `send_asset(client, asset name)`, this will send the asset and mark it as sent for that client, but only if it isn't already sent. This works, except the issue is, `winset()` and `output()` don't get affected by the browse queue, as the HTML interface module uses these, there are issues because the UI opens before the resources arrive at the client. ~~Working on a fix for the issue, probably a `sleep()` to imitate the "lag"~~ See merge request !120
This commit is contained in:
@@ -11,11 +11,13 @@
|
||||
. = ..()
|
||||
head += "<link rel='stylesheet' type='text/css' href='RCD.css'>"
|
||||
|
||||
/datum/html_interface/rcd/sendResources(var/client/client)
|
||||
. = ..()
|
||||
client << browse_rsc('RCD.css')
|
||||
/datum/html_interface/rcd/registerResources()
|
||||
register_asset("RCD.css", 'RCD.css')
|
||||
|
||||
//Send the icons.
|
||||
for(var/path in typesof(/datum/rcd_schematic) - /datum/rcd_schematic)
|
||||
var/datum/rcd_schematic/C = new path()
|
||||
C.send_icons(client)
|
||||
C.register_assets()
|
||||
|
||||
/datum/html_interface/rcd/sendAssets(var/client/client)
|
||||
. = send_asset(client, "RCD.css")
|
||||
@@ -7,7 +7,10 @@
|
||||
src.head = src.head + "<link rel=\"stylesheet\" type=\"text/css\" href=\"cards.css\" />"
|
||||
src.updateLayout("<div id=\"headbar\"></div><div class=\"wrapper\"><table><tr><td style=\"vertical-align: middle;\"><div id=\"hand\"></div></td></tr></table></div>")
|
||||
|
||||
/datum/html_interface/cards/sendResources(client/client)
|
||||
. = ..() // we need the default resources
|
||||
/datum/html_interface/cards/registerResources()
|
||||
register_asset("cards.css", 'cards.css')
|
||||
|
||||
client << browse_rsc('cards.css')
|
||||
/datum/html_interface/cards/sendAssets(var/client/client)
|
||||
..()
|
||||
|
||||
send_asset(client, "cards.css")
|
||||
@@ -130,14 +130,13 @@ mob/verb/test()
|
||||
/datum/html_interface/proc/specificRenderTitle(datum/html_interface_client/hclient, ignore_cache = FALSE)
|
||||
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/datum/html_interface/proc/specificRenderTitle() called tick#: [world.time]")
|
||||
|
||||
/datum/html_interface/proc/sendResources(client/client)
|
||||
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\datum/html_interface/proc/sendResources() called tick#: [world.time]")
|
||||
client << browse_rsc('jquery.min.js')
|
||||
client << browse_rsc('bootstrap.min.js')
|
||||
client << browse_rsc('bootstrap.min.css')
|
||||
client << browse_rsc('html_interface.css')
|
||||
client << browse_rsc('html_interface.js')
|
||||
client << browse_rsc('html_interface_icons.css')
|
||||
/datum/html_interface/proc/registerResources()
|
||||
register_asset("jquery.min.js", 'jquery.min.js')
|
||||
register_asset("bootstrap.min.js", 'bootstrap.min.js')
|
||||
register_asset("bootstrap.min.css", 'bootstrap.min.css')
|
||||
register_asset("html_interface.css", 'html_interface.css')
|
||||
register_asset("html_interface.js", 'html_interface.js')
|
||||
register_asset("html_interface_icons.css", 'html_interface_icons.css')
|
||||
|
||||
/datum/html_interface/proc/createWindow(datum/html_interface_client/hclient)
|
||||
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/datum/html_interface/proc/createWindow() called tick#: [world.time]")
|
||||
@@ -155,6 +154,16 @@ mob/verb/test()
|
||||
|
||||
winset(hclient.client, "browser_\ref[src].browser", list2params(list("parent" = "browser_\ref[src]", "type" = "browser", "pos" = "0,0", "size" = "[width]x[height]", "anchor1" = "0,0", "anchor2" = "100,100", "use-title" = "true", "auto-format" = "false")))
|
||||
|
||||
sendAssets(hclient.client)
|
||||
|
||||
/datum/html_interface/proc/sendAssets(var/client/client)
|
||||
send_asset(client, "jquery.min.js")
|
||||
send_asset(client, "bootstrap.min.js")
|
||||
send_asset(client, "bootstrap.min.css")
|
||||
send_asset(client, "html_interface.css")
|
||||
send_asset(client, "html_interface.js")
|
||||
send_asset(client, "html_interface_icons.css")
|
||||
|
||||
/* * Public API */
|
||||
/datum/html_interface/proc/getTitle()
|
||||
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/datum/html_interface/proc/getTitle() called tick#: [world.time]")
|
||||
|
||||
@@ -29,12 +29,19 @@ The client is optional and may be a /mob, /client or /html_interface_client obje
|
||||
// Update the title in our custom header (in addition to default functionality)
|
||||
winset(hclient.client, "browser_\ref[src].uiTitle", list2params(list("text" = "[src.title]")))
|
||||
|
||||
/datum/html_interface/nanotrasen/sendResources(client/client)
|
||||
. = ..() // we need the default resources
|
||||
/datum/html_interface/nanotrasen/registerResources()
|
||||
..()
|
||||
|
||||
client << browse_rsc('uiBg.png')
|
||||
client << browse_rsc('uiBgcenter.png')
|
||||
client << browse_rsc('nanotrasen.css')
|
||||
register_asset("uiBg.png", 'uiBg.png')
|
||||
register_asset("uiBgcenter.png", 'uiBgcenter.png')
|
||||
register_asset("nanotrasen.css", 'nanotrasen.css')
|
||||
|
||||
/datum/html_interface/nanotrasen/sendAssets(var/client/client)
|
||||
..()
|
||||
|
||||
send_asset(client, "uiBg.png")
|
||||
send_asset(client, "uiBgcenter.png")
|
||||
send_asset(client, "nanotrasen.css")
|
||||
|
||||
/datum/html_interface/nanotrasen/createWindow(datum/html_interface_client/hclient)
|
||||
. = ..() // we want the default window
|
||||
|
||||
@@ -5,11 +5,17 @@ var/global/datum/controller/vote/vote = new()
|
||||
#define VOTE_SCREEN_HEIGHT 400
|
||||
|
||||
|
||||
/datum/html_interface/nanotrasen/sendResources(client/C)
|
||||
/datum/html_interface/nanotrasen/registerResources()
|
||||
. = ..()
|
||||
|
||||
register_asset("voting.js", 'voting.js')
|
||||
register_asset("voting.css", 'voting.css')
|
||||
|
||||
/datum/html_interface/nanotrasen/sendAssets(var/client/client)
|
||||
..()
|
||||
C << browse_rsc('voting.js')
|
||||
C << browse_rsc('voting.css')
|
||||
return
|
||||
|
||||
send_asset(client, "voting.js")
|
||||
send_asset(client, "voting.css")
|
||||
|
||||
/datum/html_interface/nanotrasen/Topic(href, href_list[])
|
||||
..()
|
||||
|
||||
Reference in New Issue
Block a user