Updates nanomanager's handling of opening UIs so that it can be called multiple times, changes force_open to simply ignore that the UI is open and try to open it again. Causes a slight flicker if the UI is open, but the window does not move or change size.
This commit is contained in:
GinjaNinja32
2015-05-28 22:55:46 +01:00
parent 2b1271d633
commit 8ed2380cee
2 changed files with 19 additions and 6 deletions
+7 -6
View File
@@ -55,8 +55,9 @@
ui.push_data(data)
return ui
else
//testing("nanomanager/try_update_ui mob [user.name] [src_object:name] [ui_key] [force_open] - forcing opening of ui")
ui.close()
ui.reinitialise(new_initial_data=data)
return ui
return null
/**
@@ -164,10 +165,10 @@
else if (isnull(open_uis[src_object_key][ui.ui_key]) || !istype(open_uis[src_object_key][ui.ui_key], /list))
open_uis[src_object_key][ui.ui_key] = list();
ui.user.open_uis.Add(ui)
ui.user.open_uis |= ui
var/list/uis = open_uis[src_object_key][ui.ui_key]
uis.Add(ui)
processing_uis.Add(ui)
uis |= ui
processing_uis |= ui
//testing("nanomanager/ui_opened mob [ui.user.name] [ui.src_object:name] [ui.ui_key] - user.open_uis [ui.user.open_uis.len] | uis [uis.len] | processing_uis [processing_uis.len]")
/**
@@ -220,7 +221,7 @@
*/
/datum/nanomanager/proc/user_transferred(var/mob/oldMob, var/mob/newMob)
//testing("nanomanager/user_transferred from mob [oldMob.name] to mob [newMob.name]")
if (!oldMob || isnull(oldMob.open_uis) || !istype(oldMob.open_uis, /list) || open_uis.len == 0)
if (!oldMob || isnull(oldMob.open_uis) || !istype(oldMob.open_uis, /list) || open_uis.len == 0)
//testing("nanomanager/user_transferred mob [oldMob.name] has no open uis")
return 0 // has no open uis
+12
View File
@@ -407,6 +407,18 @@ nanoui is used to open and update nano browser uis
//onclose(user, window_id)
nanomanager.ui_opened(src)
/**
* Reinitialise this UI, potentially with a different template and/or initial data
*
* @return nothing
*/
/datum/nanoui/proc/reinitialise(template, new_initial_data)
if(template)
add_template("main", template)
if(new_initial_data)
set_initial_data(new_initial_data)
open()
/**
* Close this UI
*