// RCON REMOTE CONTROL CONSOLE // // Last Change 1.1.2015 by Atlantis // // Allows remote operation of electrical systems on station (SMESs and Breaker Boxes) /obj/machinery/computer/rcon name = "\improper RCON console" desc = "Console used to remotely control machinery on the station." icon = 'icons/obj/computer.dmi' icon_state = "ai-fixer" circuit = /obj/item/weapon/circuitboard/rcon_console req_one_access = list(access_engine) var/current_tag = null var/list/known_SMESs = null var/list/known_breakers = null // Allows you to hide specific parts of the UI var/hide_SMES = 0 var/hide_SMES_details = 0 var/hide_breakers = 0 // Proc: attack_hand() // Parameters: 1 (user - Person which clicked this computer) // Description: Opens UI of this machine. /obj/machinery/computer/rcon/attack_hand(var/mob/user as mob) ..() ui_interact(user) // Proc: ui_interact() // Parameters: 4 (standard NanoUI parameters) // Description: Uses dark magic (NanoUI) to render this machine's UI /obj/machinery/computer/rcon/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) FindDevices() // Update our devices list var/data[0] // SMES DATA (simplified view) var/list/smeslist[0] for(var/obj/machinery/power/smes/buildable/SMES in known_SMESs) smeslist.Add(list(list( "charge" = round(SMES.Percentage()), "input_set" = SMES.input_attempt, "input_val" = round(SMES.input_level), "output_set" = SMES.output_attempt, "output_val" = round(SMES.output_level), "output_load" = round(SMES.output_used), "RCON_tag" = SMES.RCon_tag ))) data["smes_info"] = sortByKey(smeslist, "RCON_tag") // BREAKER DATA (simplified view) var/list/breakerlist[0] for(var/obj/machinery/power/breakerbox/BR in known_breakers) breakerlist.Add(list(list( "RCON_tag" = BR.RCon_tag, "enabled" = BR.on ))) data["breaker_info"] = breakerlist data["hide_smes"] = hide_SMES data["hide_smes_details"] = hide_SMES_details data["hide_breakers"] = hide_breakers ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) if (!ui) ui = new(user, src, ui_key, "rcon.tmpl", "RCON Console", 600, 400) ui.set_initial_data(data) ui.open() ui.set_auto_update(1) // Proc: Topic() // Parameters: 2 (href, href_list - allows us to process UI clicks) // Description: Allows us to process UI clicks, which are relayed in form of hrefs. /obj/machinery/computer/rcon/Topic(href, href_list) if(href_list["smes_in_toggle"]) var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(href_list["smes_in_toggle"]) if(SMES) SMES.toggle_input() if(href_list["smes_out_toggle"]) var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(href_list["smes_out_toggle"]) if(SMES) SMES.toggle_output() if(href_list["smes_in_set"]) var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(href_list["smes_in_set"]) if(SMES) var/inputset = input(usr, "Enter new input level (0-[SMES.input_level_max])", "SMES Input Power Control") as num SMES.set_input(inputset) if(href_list["smes_out_set"]) var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(href_list["smes_out_set"]) if(SMES) var/outputset = input(usr, "Enter new output level (0-[SMES.output_level_max])", "SMES Input Power Control") as num SMES.set_output(outputset) if(href_list["toggle_breaker"]) var/obj/machinery/power/breakerbox/toggle = null for(var/obj/machinery/power/breakerbox/breaker in known_breakers) if(breaker.RCon_tag == href_list["toggle_breaker"]) toggle = breaker if(toggle) if(toggle.update_locked) usr << "The breaker box was recently toggled. Please wait before toggling it again." else toggle.auto_toggle() if(href_list["hide_smes"]) hide_SMES = !hide_SMES if(href_list["hide_smes_details"]) hide_SMES_details = !hide_SMES_details if(href_list["hide_breakers"]) hide_breakers = !hide_breakers // Proc: GetSMESByTag() // Parameters: 1 (tag - RCON tag of SMES we want to look up) // Description: Looks up and returns SMES which has matching RCON tag /obj/machinery/computer/rcon/proc/GetSMESByTag(var/tag) if(!tag) return for(var/obj/machinery/power/smes/buildable/S in known_SMESs) if(S.RCon_tag == tag) return S // Proc: FindDevices() // Parameters: None // Description: Refreshes local list of known devices. /obj/machinery/computer/rcon/proc/FindDevices() known_SMESs = new /list() for(var/obj/machinery/power/smes/buildable/SMES in machines) if(SMES.RCon_tag && (SMES.RCon_tag != "NO_TAG") && SMES.RCon) known_SMESs.Add(SMES) known_breakers = new /list() for(var/obj/machinery/power/breakerbox/breaker in machines) if(breaker.RCon_tag != "NO_TAG") known_breakers.Add(breaker)