diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 2abfe0f4fc..95c5d63840 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -253,6 +253,7 @@ 'nano/templates/cryo.tmpl', 'nano/templates/geoscanner.tmpl', 'nano/templates/dna_modifier.tmpl', + 'nano/templates/telescience_console.tmpl', 'nano/images/uiBackground.png', 'nano/images/uiIcons16.png', 'nano/images/uiIcons24.png', diff --git a/code/modules/telesci/telesci_computer.dm b/code/modules/telesci/telesci_computer.dm index 03d41853a9..a42e617f1c 100644 --- a/code/modules/telesci/telesci_computer.dm +++ b/code/modules/telesci/telesci_computer.dm @@ -9,9 +9,9 @@ var/teles_left // How many teleports left until it becomes uncalibrated var/x_off // X offset var/y_off // Y offset - var/x_co // X coordinate - var/y_co // Y coordinate - var/z_co // Z coordinate + var/x_co = 1 // X coordinate + var/y_co = 1 // Y coordinate + var/z_co = 1 // Z coordinate /obj/machinery/computer/telescience/New() ..() @@ -35,29 +35,51 @@ icon_state = initial(icon_state) stat &= ~NOPOWER + /** + * The ui_interact proc is used to open and update Nano UIs + * If ui_interact is not used then the UI will not update correctly + * ui_interact is currently defined for /atom/movable + * + * @param user /mob The mob who is interacting with this ui + * @param ui_key string A string key to use for this ui. Allows for multiple unique uis on one obj/mob (defaut value "main") + * + * @return nothing + */ +/obj/machinery/computer/telescience/ui_interact(mob/user, ui_key = "main") + if(stat & (BROKEN|NOPOWER)) return + if(user.stat || user.restrained()) return + + // this is the data which will be sent to the ui + var/data[0] + data["coordx"] = x_co + data["coordy"] = y_co + data["coordz"] = z_co + + var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, ui_key) + if (!ui) + // the ui does not exist, so we'll create a new one + ui = new(user, src, ui_key, "telescience_console.tmpl", name, 380, 110) + // When the UI is first opened this is the data it will use + ui.set_initial_data(data) + ui.open() + else + // The UI is already open so push the new data to it + ui.push_data(data) + return + /obj/machinery/computer/telescience/attack_paw(mob/user) user << "You are too primitive to use this computer." return /obj/machinery/computer/telescience/attack_ai(mob/user) - src.attack_hand(user) + return src.attack_hand(user) -/obj/machinery/computer/telescience/attack_hand(mob/user) - if(..()) +/obj/machinery/computer/telescience/attack_hand(mob/user as mob) + if(stat & BROKEN) return - var/t = "" - t += "Set X" - t += "Set Y" - t += "Set Z" - t += "

Current set coordinates:" - t += "([x_co], [y_co], [z_co])" - t += "

Send" - t += " Receive" - t += "

Recalibrate" - var/datum/browser/popup = new(user, "telesci", name, 640, 480) - popup.set_content(t) - popup.open() - return + + ui_interact(user) + /obj/machinery/computer/telescience/proc/sparks() if(telepad) var/L = get_turf(E) @@ -66,6 +88,7 @@ s.start() else return + /obj/machinery/computer/telescience/proc/telefail() if(prob(50)) sparks() @@ -156,7 +179,7 @@ s.set_up(5, 1, telepad) s.start() flick("pad-beam", telepad) - user << " Teleport successful." + user << "Teleport successful." var/sparks = get_turf(target) var/datum/effect/effect/system/spark_spread/y = new /datum/effect/effect/system/spark_spread y.set_up(5, 1, sparks) @@ -174,20 +197,7 @@ /obj/machinery/computer/telescience/proc/teleport(mob/user) if(x_co == null || y_co == null || z_co == null) - user << " Error: set coordinates." - return - if(x_co < 1 || x_co > 255) - telefail() - user << " Error: X is less than 1 or greater than 255." - return - if(y_co < 1 || y_co > 255) - telefail() - user << " Error: Y is less than 1 or greater than 255." - return - if(z_co == 2 || z_co < 1 || z_co > 7) - telefail() - user << " Error: Z is less than 1, greater than 7, or equal to 2." - return + user << "Error: coordinates not set." if(teles_left > 0) teles_left -= 1 doteleport(user) @@ -197,32 +207,48 @@ return /obj/machinery/computer/telescience/Topic(href, href_list) - if(..()) - return + if(stat & (NOPOWER|BROKEN)) + return 0 + if(href_list["setx"]) var/new_x = input("Please input desired X coordinate.", name, x_co) as num - x_co = Clamp(new_x, 1, 9999) - return + if(new_x < 1 || new_x > 255) + usr << "Error: Invalid X coordinate." + else + x_co = new_x + return 1 + if(href_list["sety"]) var/new_y = input("Please input desired Y coordinate.", name, y_co) as num - y_co = Clamp(new_y, 1, 9999) - return + if(new_y < 1 || new_y > 255) + usr << "Error: Invalid Y coordinate." + else + y_co = new_y + return 1 + if(href_list["setz"]) var/new_z = input("Please input desired Z coordinate.", name, z_co) as num - z_co = Clamp(new_z, 1, 9999) - return + if(new_z == 2 || new_z < 1 || new_z > 7) + usr << "Error: Invalid Z coordinate." + else + z_co = new_z + return 1 + if(href_list["send"]) sending = 1 teleport(usr) - return + return 1 + if(href_list["receive"]) sending = 0 teleport(usr) - return + return 1 + if(href_list["recal"]) teles_left = rand(9,12) x_off = rand(-10,10) y_off = rand(-10,10) sparks() - usr << " Calibration successful." - return \ No newline at end of file + usr << "Calibration successful." + return 1 + return 0 \ No newline at end of file diff --git a/nano/templates/telescience_console.tmpl b/nano/templates/telescience_console.tmpl new file mode 100644 index 0000000000..ae92ed3e13 --- /dev/null +++ b/nano/templates/telescience_console.tmpl @@ -0,0 +1,20 @@ + +
+
Coordinates:
+
+ {^{:~link('X: ' + coordx, 'gear', {'setx': 1})}} + {^{:~link('Y: ' + coordy, 'gear', {'sety': 1})}} + {^{:~link('Z: ' + coordz, 'gear', {'setz': 1})}} +
+
+
+
Controls:
+
+ {^{:~link('Send', 'gear', {'send': 1}, null, (coordx != null && coordy != null && coordz != null) ? '' : 'disabled')}} + {^{:~link('Receive', 'gear', {'receive': 1}, null, (coordx != null && coordy != null && coordz != null) ? '' : 'disabled')}} + {^{:~link('Recalibrate', 'gear', {'recal': 1})}} +
+