From 06541aecc5e1b0f6129d005a958f355351f59cfd Mon Sep 17 00:00:00 2001 From: "Mark Aherne (Faerdan)" Date: Sun, 12 Jan 2014 15:30:25 +0000 Subject: [PATCH] NanoUI assets are now sent to the client automatically. * NanoUI now finds and sends it's assets to the client (css, images, javascript and templates). Part of my effort to make creating NanoUIs as simple as possible. This removes the need to add new NanoUI assets (such as templates) to the client send_resources proc. Conflicts: code/modules/client/client procs.dm code/modules/nano/nanomanager.dm --- code/modules/client/client procs.dm | 36 ++++------------------------- code/modules/nano/nanomanager.dm | 35 ++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 6e495a47c03..6d86a9441c1 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -280,38 +280,12 @@ //send resources to the client. It's here in its own proc so we can move it around easiliy if need be /client/proc/send_resources() -// preload_vox() +// preload_vox() //Causes long delays with initial start window and subsequent windows when first logged in. + + // Send NanoUI resources to this client + nanomanager.send_resources(src) + getFiles( - 'nano/js/libraries.min.js', - // 'nano/js/libraries/1-jquery.js', - // 'nano/js/libraries/2-jsrender.js', - // 'nano/js/libraries/3-jquery.timers.js', - 'nano/js/nano_update.js', - 'nano/js/nano_config.js', - 'nano/js/nano_base_helpers.js', - 'nano/css/shared.css', - 'nano/css/icons.css', - 'nano/templates/chem_dispenser.tmpl', - 'nano/templates/apc.tmpl', - 'nano/templates/cryo.tmpl', - 'nano/templates/dna_modifier.tmpl', - 'nano/templates/geoscanner.tmpl', - 'nano/templates/air_alarm.tmpl', - 'nano/templates/atmos_control.tmpl', - 'nano/templates/firealarm.tmpl', - 'nano/templates/vending.tmpl', - 'nano/templates/pda.tmpl', - 'nano/templates/smes.tmpl', - 'nano/templates/uplink.tmpl', - 'nano/images/uiBackground.png', - 'nano/images/uiBackground-Syndicate.png', - 'nano/images/uiIcons16.png', - 'nano/images/uiIcons24.png', - 'nano/images/uiLinkPendingIcon.gif', - 'nano/images/uiMaskBackground.png', - 'nano/images/uiNoticeBackground.jpg', - 'nano/images/uiTitleFluff.png', - 'nano/images/uiTitleFluff-Syndicate.png', 'html/search.js', 'html/panels.css', 'icons/pda_icons/pda_atmos.png', diff --git a/code/modules/nano/nanomanager.dm b/code/modules/nano/nanomanager.dm index b69818ca2b8..e28f45abe1c 100644 --- a/code/modules/nano/nanomanager.dm +++ b/code/modules/nano/nanomanager.dm @@ -29,11 +29,11 @@ { ui = get_open_ui(user, src_object, ui_key) } - if (!isnull(ui)) + if (!isnull(ui)) // The UI is already open so push the data to it ui.push_data(data) return ui - + return null /** @@ -203,3 +203,34 @@ oldMob.open_uis.Cut() return 1 // success + + /** + * Sends all nano assets to the client + * This is called on user login + * + * @param client /client The user's client + * + * @return nothing + */ + +#define NANO_CSS_PATH "nano/css/" +#define NANO_IMAGES_PATH "nano/images/" +#define NANO_JS_PATH "nano/js/" +#define NANO_TEMPLATES_PATH "nano/templates/" + +/datum/nanomanager/proc/send_resources(client) + var/list/css = flist(NANO_CSS_PATH) + var/list/images = flist(NANO_IMAGES_PATH) + var/list/js = flist(NANO_JS_PATH) + var/list/templates = flist(NANO_TEMPLATES_PATH) + + for(var/file in css) + client << browse_rsc(file(NANO_CSS_PATH + file)) + for(var/file in images) + client << browse_rsc(file(NANO_IMAGES_PATH + file)) + for(var/file in js) + client << browse_rsc(file(NANO_JS_PATH + file)) + for(var/file in templates) + client << browse_rsc(file(NANO_TEMPLATES_PATH + file)) + + return 1 // success