From 8ed2380cee6cffa735dc50125909cab5a941feb6 Mon Sep 17 00:00:00 2001 From: GinjaNinja32 Date: Thu, 28 May 2015 22:55:46 +0100 Subject: [PATCH] Fixes #6077 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. --- code/modules/nano/nanomanager.dm | 13 +++++++------ code/modules/nano/nanoui.dm | 12 ++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/code/modules/nano/nanomanager.dm b/code/modules/nano/nanomanager.dm index 2a89779e92..f6325fd4f7 100644 --- a/code/modules/nano/nanomanager.dm +++ b/code/modules/nano/nanomanager.dm @@ -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 diff --git a/code/modules/nano/nanoui.dm b/code/modules/nano/nanoui.dm index ffc6208f39..eb7489b6e1 100644 --- a/code/modules/nano/nanoui.dm +++ b/code/modules/nano/nanoui.dm @@ -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 *