diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index 8c12a503094..3b79e95ebd2 100755 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -485,6 +485,7 @@ var/global/list/obj/item/device/pda/PDAs = list() // When the UI is first opened this is the data it will use ui.set_initial_data(data) ui.open() + ui.set_auto_update(1) else // The UI is already open so push the new data to it ui.push_data(data) @@ -882,6 +883,9 @@ var/global/list/obj/item/device/pda/PDAs = list() if(L) L << "\icon[P] Message from [src.owner] ([ownjob]), \"[t]\" (Reply)" + nanomanager.update_user_uis(L, P) // Update the recieving user's PDA UI so that they can see the new message + + nanomanager.update_user_uis(U, P) // Update the sending user's PDA UI so that they can see the new message log_pda("[usr] (PDA: [src.name]) sent \"[t]\" to [P.name]") P.overlays.Cut() diff --git a/code/modules/nano/nanomanager.dm b/code/modules/nano/nanomanager.dm index 12b1e57c21c..96c38037a98 100644 --- a/code/modules/nano/nanomanager.dm +++ b/code/modules/nano/nanomanager.dm @@ -55,6 +55,49 @@ update_count++ return update_count + + /** + * Update /nanoui uis belonging to user + * + * @param user /mob The mob who owns the uis + * @param src_object /obj|/mob If src_object is provided, only update uis which are attached to src_object (optional) + * @param ui_key string If ui_key is provided, only update uis with a matching ui_key (optional) + * + * @return int The number of uis updated + */ +/datum/nanomanager/proc/update_user_uis(var/mob/user, src_object = null, ui_key = null) + if (isnull(user.open_uis) || !istype(user.open_uis, /list) || open_uis.len == 0) + return 0 // has no open uis + + var/update_count = 0 + for (var/datum/nanoui/ui in user.open_uis) + if ((isnull(src_object) || !isnull(src_object) && ui.src_object == src_object) && (isnull(ui_key) || !isnull(ui_key) && ui.ui_key == ui_key)) + ui.process(1) + update_count++ + + return update_count + + /** + * Close /nanoui uis belonging to user + * + * @param user /mob The mob who owns the uis + * @param src_object /obj|/mob If src_object is provided, only close uis which are attached to src_object (optional) + * @param ui_key string If ui_key is provided, only close uis with a matching ui_key (optional) + * + * @return int The number of uis closed + */ +/datum/nanomanager/proc/close_user_uis(var/mob/user, src_object = null, ui_key = null) + if (isnull(user.open_uis) || !istype(user.open_uis, /list) || open_uis.len == 0) + return 0 // has no open uis + + var/close_count = 0 + for (var/datum/nanoui/ui in user.open_uis) + if ((isnull(src_object) || !isnull(src_object) && ui.src_object == src_object) && (isnull(ui_key) || !isnull(ui_key) && ui.ui_key == ui_key)) + ui.close() + close_count++ + + return close_count + /** * Add a /nanoui ui to the list of open uis * This is called by the /nanoui open() proc diff --git a/nano/templates/pda.tmpl b/nano/templates/pda.tmpl index eb0432cf417..a4043578993 100644 --- a/nano/templates/pda.tmpl +++ b/nano/templates/pda.tmpl @@ -9,7 +9,7 @@ Used In File(s): \code\game\objects\items\devices\PDA\PDA.dm Functions:
- {^{:~link('Refresh', 'refresh', {'choice' : "Refresh"}, null, 'fixedLeft')}} + {^{:~link('Close', 'gear', {'choice' : "Close"}, null, 'fixedLeft')}} {^{if idInserted}} {^{:~link('Update PDA Info', 'eject', {'choice' : "UpdateInfo"}, null, 'fixedLeftWide')}} {{/if}} {^{if mode != 0}} {^{:~link('Return', 'arrowreturn-1-w', {'choice' : "Return"}, null, 'fixedLeft')}} {{/if}}