mirror of
https://github.com/CHOMPstation/CHOMPstation.git
synced 2026-08-22 11:36:38 +01:00
Merge pull request #3563 from Faerdan/dev
Removed delay when opening Nano UI windows
This commit is contained in:
@@ -246,7 +246,7 @@
|
||||
'nano/js/nano_update.js',
|
||||
'nano/js/nano_config.js',
|
||||
'nano/js/nano_base_helpers.js',
|
||||
'nano/css/common.css',
|
||||
'nano/css/shared.css',
|
||||
'nano/css/icons.css',
|
||||
'nano/templates/cryo.tmpl',
|
||||
'nano/images/uiBackground.png',
|
||||
|
||||
+47
-67
@@ -9,8 +9,8 @@
|
||||
var/atom/ref = null
|
||||
var/on_close_logic = 1
|
||||
var/window_options = "focus=0;can_close=1;can_minimize=1;can_maximize=0;can_resize=1;titlebar=1;" // window option is set using window_id
|
||||
var/stylesheets[0]
|
||||
var/scripts[0]
|
||||
var/list/stylesheets = list()
|
||||
var/list/scripts = list()
|
||||
var/templates[0]
|
||||
var/title_image
|
||||
var/head_elements
|
||||
@@ -23,13 +23,13 @@
|
||||
|
||||
|
||||
/datum/nanoui/New(nuser, nsrc_object, nui_key, ntemplate, ntitle = 0, nwidth = 0, nheight = 0, var/atom/nref = null)
|
||||
user = nuser
|
||||
user = nuser
|
||||
src_object = nsrc_object
|
||||
ui_key = nui_key
|
||||
window_id = "[ui_key]\ref[src_object]"
|
||||
|
||||
|
||||
add_template("main", ntemplate)
|
||||
|
||||
|
||||
if (ntitle)
|
||||
title = ntitle
|
||||
if (nwidth)
|
||||
@@ -37,27 +37,25 @@
|
||||
if (nheight)
|
||||
height = nheight
|
||||
if (nref)
|
||||
ref = nref
|
||||
|
||||
ref = nref
|
||||
|
||||
add_common_assets()
|
||||
|
||||
|
||||
/datum/nanoui/proc/add_common_assets()
|
||||
add_script("libraries", 'nano/js/libraries.min.js') // The jQuery library
|
||||
//add_script("jquery", 'nano/js/jquery.js') // The jQuery library
|
||||
//add_script("jsviews", 'nano/js/jsviews.js') // JSViews, for rendering templates
|
||||
add_script("nanoupdate", 'nano/js/nano_update.js') // The NanoUpdate JS, this is used to receive updates and apply them.
|
||||
add_script("nanoconfig", 'nano/js/nano_config.js') // The NanoUpdate JS, this is used to receive updates and apply them.
|
||||
add_script("nanobasehelpers", 'nano/js/nano_base_helpers.js') // The NanoBaseHelpers JS, this is used to set up template helpers which are common to all templates
|
||||
add_stylesheet("common", 'nano/css/common.css') // this CSS sheet is common to all UIs
|
||||
add_stylesheet("icons", 'nano/css/icons.css') // this CSS sheet is common to all UIs
|
||||
add_script("libraries.min.js") // The jQuery library
|
||||
add_script("nano_update.js") // The NanoUpdate JS, this is used to receive updates and apply them.
|
||||
add_script("nano_config.js") // The NanoUpdate JS, this is used to receive updates and apply them.
|
||||
add_script("nano_base_helpers.js") // The NanoBaseHelpers JS, this is used to set up template helpers which are common to all templates
|
||||
add_stylesheet("shared.css") // this CSS sheet is common to all UIs
|
||||
add_stylesheet("icons.css") // this CSS sheet is common to all UIs
|
||||
|
||||
/datum/nanoui/proc/set_status(state)
|
||||
if (state != status)
|
||||
status = state
|
||||
push_data(list(), 1) // Update the UI
|
||||
else
|
||||
else
|
||||
status = state
|
||||
|
||||
|
||||
/datum/nanoui/proc/set_auto_update(state = 1)
|
||||
is_auto_updating = state
|
||||
|
||||
@@ -73,11 +71,11 @@
|
||||
/datum/nanoui/proc/set_title_image(ntitle_image)
|
||||
//title_image = ntitle_image
|
||||
|
||||
/datum/nanoui/proc/add_stylesheet(name, file)
|
||||
stylesheets[name] = file
|
||||
/datum/nanoui/proc/add_stylesheet(file)
|
||||
stylesheets.Add(file)
|
||||
|
||||
/datum/nanoui/proc/add_script(name, file)
|
||||
scripts[name] = file
|
||||
/datum/nanoui/proc/add_script(file)
|
||||
scripts.Add(file)
|
||||
|
||||
/datum/nanoui/proc/add_template(name, file)
|
||||
templates[name] = file
|
||||
@@ -87,35 +85,21 @@
|
||||
|
||||
/datum/nanoui/proc/add_content(ncontent)
|
||||
content += ncontent
|
||||
|
||||
|
||||
/datum/nanoui/proc/use_on_close_logic(nsetting)
|
||||
on_close_logic = nsetting
|
||||
on_close_logic = nsetting
|
||||
|
||||
/datum/nanoui/proc/get_header()
|
||||
var/key
|
||||
var/filename
|
||||
|
||||
for (key in stylesheets)
|
||||
filename = "[ckey(key)].css"
|
||||
user << browse_rsc(stylesheets[key], filename)
|
||||
for (var/filename in stylesheets)
|
||||
head_content += "<link rel='stylesheet' type='text/css' href='[filename]'>"
|
||||
|
||||
user << browse_rsc('nano/images/uiBackground.png', "uiBackground.png")
|
||||
user << browse_rsc('nano/images/uiIcons16.png', "uiIcons16.png")
|
||||
user << browse_rsc('nano/images/uiIcons24.png', "uiIcons24.png")
|
||||
user << browse_rsc('nano/images/uiLinkPendingIcon.gif', "uiLinkPendingIcon.gif")
|
||||
user << browse_rsc('nano/images/uiNoticeBackground.jpg', "uiNoticeBackground.jpg")
|
||||
user << browse_rsc('nano/images/uiTitleFluff.png', "uiTitleFluff.png")
|
||||
|
||||
var/title_attributes = "id='uiTitle'"
|
||||
if (title_image)
|
||||
title_attributes = "id='uiTitle icon' style='background-image: url([title_image]);'"
|
||||
|
||||
var/templatel_data[0]
|
||||
for (key in templates)
|
||||
filename = "[ckey(key)].tmpl"
|
||||
user << browse_rsc(templates[key], filename)
|
||||
templatel_data[key] = filename;
|
||||
for (var/key in templates)
|
||||
templatel_data[key] = templates[key];
|
||||
|
||||
var/template_data_json = "{}" // An empty JSON object
|
||||
if (templatel_data.len > 0)
|
||||
@@ -136,7 +120,7 @@
|
||||
<body scroll=auto data-url-parameters='[url_parameters_json]' data-template-data='[template_data_json]' data-initial-data='[initial_data_json]'>
|
||||
<script type='text/javascript'>
|
||||
function receiveUpdateData(jsonString)
|
||||
{
|
||||
{
|
||||
// We need both jQuery and NanoUpdate to be able to recieve data
|
||||
if (typeof NanoUpdate != 'undefined' && typeof jQuery != 'undefined')
|
||||
{
|
||||
@@ -152,7 +136,7 @@
|
||||
if (typeof jQuery == 'undefined')
|
||||
{
|
||||
alert('jQuery not defined!');
|
||||
}
|
||||
}
|
||||
}
|
||||
// At the moment any data received before those libraries are loaded will be lost
|
||||
}
|
||||
@@ -163,15 +147,11 @@
|
||||
"}
|
||||
|
||||
/datum/nanoui/proc/get_footer()
|
||||
var/key
|
||||
var/filename
|
||||
var/scriptsContent = ""
|
||||
|
||||
for (key in scripts)
|
||||
filename = "[ckey(key)].js"
|
||||
user << browse_rsc(scripts[key], filename)
|
||||
|
||||
for (var/filename in scripts)
|
||||
scriptsContent += "<script type='text/javascript' src='[filename]'></script>"
|
||||
|
||||
|
||||
return {"
|
||||
[scriptsContent]
|
||||
</div>
|
||||
@@ -197,17 +177,17 @@
|
||||
|
||||
/datum/nanoui/proc/close()
|
||||
is_auto_updating = 0
|
||||
nanomanager.ui_closed(src)
|
||||
user << browse(null, "window=[window_id]")
|
||||
|
||||
nanomanager.ui_closed(src)
|
||||
user << browse(null, "window=[window_id]")
|
||||
|
||||
/datum/nanoui/proc/on_close_winset()
|
||||
if(!user.client)
|
||||
if(!user.client)
|
||||
world << "ERROR: No user.client!?"
|
||||
return
|
||||
var/params = "\ref[src]"
|
||||
|
||||
|
||||
winset(user, window_id, "on-close=\"nanoclose [params]\"")
|
||||
|
||||
|
||||
/datum/nanoui/proc/process(update = 0)
|
||||
var/dist = get_dist(src_object, user)
|
||||
if (dist <= 1)
|
||||
@@ -219,11 +199,11 @@
|
||||
return // don't auto update
|
||||
else
|
||||
close()
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
if (update || is_auto_updating)
|
||||
src_object.ui_interact(user, ui_key)
|
||||
|
||||
|
||||
/datum/nanoui/proc/modify_data(data)
|
||||
data["ui"] = list(
|
||||
"status" = status,
|
||||
@@ -231,14 +211,14 @@
|
||||
)
|
||||
//user << list2json(data)
|
||||
return data
|
||||
|
||||
|
||||
/datum/nanoui/proc/push_data(data, force_push = 0)
|
||||
if (!status && !force_push)
|
||||
user << "Cannot update UI, user out of range (status [status])"
|
||||
return
|
||||
|
||||
|
||||
data = modify_data(data)
|
||||
|
||||
|
||||
user << output(list2params(list(list2json(data))),"[window_id].browser:receiveUpdateData")
|
||||
on_close_winset()
|
||||
|
||||
@@ -247,13 +227,13 @@
|
||||
set name = "nanoclose" // no autocomplete on cmd line
|
||||
|
||||
//world << "world [src] looking for [uiref]"
|
||||
|
||||
var/datum/nanoui/ui = locate(uiref)
|
||||
|
||||
|
||||
var/datum/nanoui/ui = locate(uiref)
|
||||
|
||||
if (ui)
|
||||
//world << "[src] UI found [ui.window_id]"
|
||||
ui.close()
|
||||
|
||||
|
||||
if (ui.on_close_logic)
|
||||
if(ui.ref)
|
||||
var/href = "close=1"
|
||||
@@ -265,7 +245,7 @@
|
||||
// so just reset the user mob's machine var
|
||||
if(src && src.mob)
|
||||
//world << "[src] was [src.mob.machine], setting to null"
|
||||
src.mob.unset_machine()
|
||||
src.mob.unset_machine()
|
||||
else
|
||||
world << "[src] UI not found"
|
||||
return
|
||||
Reference in New Issue
Block a user