Relays are done!

This commit is contained in:
AffectedArc07
2020-05-16 12:11:15 +01:00
parent 693921e337
commit 18f1eb4b23
5 changed files with 220 additions and 569 deletions
+20 -3
View File
@@ -121,7 +121,7 @@
// Now the actual UI stuff
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "tcomms_core.tmpl", "Telecommunications Core", 900, 525)
ui = new(user, src, ui_key, "tcomms_core.tmpl", "Telecommunications Core", 900, 600)
ui.open()
ui.set_auto_update(1)
@@ -132,7 +132,8 @@
// Only send NTTC settings if were on the right tab. This saves on sending overhead.
if(ui_tab == UI_TAB_CONFIG)
// Z-level list
// Z-level list. Note that this will also show sectors with hidden relay links, but you cant see the relays themselves
// This allows the crew to realise that sectors have hidden relays
data["sectors_available"] = "Count: [length(reachable_zlevels)] | List: [jointext(reachable_zlevels, " ")]"
// Toggles
data["active"] = active
@@ -143,6 +144,8 @@
// Strings
data["nttc_setting_language"] = nttc.setting_language
data["nttc_job_indicator_type"] = nttc.job_indicator_type
// Network ID
data["network_id"] = network_id
if(ui_tab == UI_TAB_LINKS)
data["link_password"] = link_password
@@ -228,6 +231,13 @@
if(href_list["export"])
usr << browse(nttc.nttc_serialize(), "window=save_nttc")
// Set network ID
if(href_list["network_id"])
var/new_id = input(usr, "Please enter a new network ID", "Network ID", network_id)
log_action(usr, "renamed core with ID [network_id] to [new_id]")
to_chat(usr, "<span class='notice'>Device ID changed from <b>[network_id]</b> to <b>[new_id]</b>.</span>")
network_id = new_id
if(ui_tab == UI_TAB_LINKS)
if(href_list["unlink"])
var/obj/machinery/tcomms/relay/R = locate(href_list["unlink"])
@@ -239,7 +249,14 @@
else
to_chat(usr, "<span class='alert'><b>ERROR:</b> Relay not found. Please file an issue report.</span>")
// Try to speed-update the UI
if(href_list["change_password"])
var/new_password = input(usr, "Please enter a new password","New Password", link_password)
log_action(usr, "has changed the password on core with ID [network_id] from [link_password] to [new_password]")
to_chat(usr, "<span class='notice'>Successfully changed password from <b>[link_password]</b> to <b>[new_password]</b>.</span>")
link_password = new_password
// Hack to speed update the nanoUI
SSnanoui.update_uis(src)
#undef UI_TAB_CONFIG
+81
View File
@@ -94,3 +94,84 @@
..()
if(linked_core)
linked_core.refresh_zlevels()
//////////////
// UI STUFF //
//////////////
/obj/machinery/tcomms/relay/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "tcomms_relay.tmpl", "Telecommunications Relay", 600, 400)
ui.open()
ui.set_auto_update(1)
/obj/machinery/tcomms/relay/ui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.default_state)
var/data[0]
// Are we on or not
data["active"] = active
// What is our network ID
data["network_id"] = network_id
// Are we linked
data["linked"] = linked
// Is the link hidden
data["hidden_link"] = hidden_link
// Only send linked tab stuff if we are linked. This saves on sending overhead.
if(linked)
data["linked_core_id"] = linked_core.network_id
data["linked_core_addr"] = "\ref[linked_core]"
else
for(var/obj/machinery/tcomms/core/C in GLOB.tcomms_machines)
data["entries"] += list(list("addr" = "\ref[C]", "net_id" = C.network_id, "sector" = C.loc.z))
return data
/obj/machinery/tcomms/relay/Topic(href, href_list)
// Check against href exploits
if(..())
return
// All the toggle on/offs go here
if(href_list["toggle_active"])
active = !active
update_icon()
// Set network ID
if(href_list["network_id"])
var/new_id = input(usr, "Please enter a new network ID", "Network ID", network_id)
log_action(usr, "renamed core with ID [network_id] to [new_id]")
to_chat(usr, "<span class='notice'>Device ID changed from <b>[network_id]</b> to <b>[new_id]</b>.</span>")
network_id = new_id
if(linked)
// Only do these hrefs if we are linked to prevent bugs/exploits
if(href_list["toggle_hidden_link"])
hidden_link = !hidden_link
log_action(usr, "Modified hidden link for [network_id] (Now [hidden_link])")
if(href_list["unlink"])
var/choice = alert(usr, "Are you SURE you want to unlink this relay?\nYou wont be able to re-link without the core password", "Unlink","Yes","No")
if(choice == "Yes")
log_action(usr, "Unlinked [network_id] from [linked_core.network_id]")
Reset()
else
// You should only be able to link if its not linked, to prevent weirdness
if(href_list["link"])
var/obj/machinery/tcomms/core/C = locate(href_list["link"])
if(istype(C, /obj/machinery/tcomms/core))
var/user_pass = input(usr, "Please enter core password","Password Entry")
// Check the password
if(user_pass == C.link_password)
AddLink(C)
to_chat(usr, "<span class='notice'>Successfully linked to <b>[C.network_id]</b>.</span>")
else
to_chat(usr, "<span class='alert'><b>ERROR:</b> Password incorrect.</span>")
else
to_chat(usr, "<span class='alert'><b>ERROR:</b> Core not found. Please file an issue report.</span>")
// Hack to speed update the nanoUI
SSnanoui.update_uis(src)
-562
View File
@@ -1,562 +0,0 @@
#define JOB_STYLE_1 "Name (Job)"
#define JOB_STYLE_2 "Name - Job"
#define JOB_STYLE_3 "\[Job\] Name"
#define JOB_STYLE_4 "(Job) Name"
// Custom Implementations for NTTC
/* NTTC Configuration Datum
* This is an abstract handler for the configuration loadout. It's set up like this both for ease of transfering in and out of the UI
* as well as allowing users to save and load configurations.
*/
/datum/nttc_configuration
var/regex/word_blacklist = new("(<iframe|<embed|<script|<svg|<canvas|<video|<audio|onload)", "i") // Blacklist of naughties
// ALL OF THE JOB CRAP
// Dict of all jobs and their department color classes
var/all_jobs = list(
// AI
"AI" = "airadio",
"Android" = "airadio",
"Cyborg" = "airadio",
"Personal AI" = "airadio",
"Robot" = "airadio",
// Civilian + Varients
"Assistant" = "radio",
"Businessman" = "radio",
"Civilian" = "radio",
"Tourist" = "radio",
"Trader" = "radio",
// Command (Solo command, not department heads)
"Blueshield" = "comradio",
"Captain" = "comradio",
"Head of Personnel" = "comradio",
"Nanotrasen Representative" = "comradio",
// Engineeering
"Atmospheric Technician" = "engradio",
"Chief Engineer" = "engradio",
"Electrician" = "engradio",
"Engine Technician" = "engradio",
"Life Support Specialist" = "engradio",
"Maintenance Technician" = "engradio",
"Mechanic" = "engradio",
"Station Engineer" = "engradio",
// ERT
"Emergency Response Team Engineer" = "dsquadradio", // I know this says deathsquad but the class for responseteam is neon green. No.
"Emergency Response Team Leader" = "dsquadradio",
"Emergency Response Team Medic" = "dsquadradio",
"Emergency Response Team Member" = "dsquadradio",
"Emergency Response Team Officer" = "dsquadradio",
// Medical
"Chemist" = "medradio",
"Chief Medical Officer" = "medradio",
"Coroner" = "medradio",
"Medical Doctor" = "medradio",
"Microbiologist" = "medradio",
"Nurse" = "medradio",
"Paramedic" = "medradio",
"Pharmacologist" = "medradio",
"Pharmacist" = "medradio",
"Psychiatrist" = "medradio",
"Psychologist" = "medradio",
"Surgeon" = "medradio",
"Therapist" = "medradio",
"Virologist" = "medradio",
// Science
"Anomalist" = "sciradio",
"Biomechanical Engineer" = "sciradio",
"Chemical Researcher" = "sciradio",
"Geneticist" = "sciradio",
"Mechatronic Engineer" = "sciradio",
"Plasma Researcher" = "sciradio",
"Research Director" = "sciradio",
"Roboticist" = "sciradio",
"Scientist" = "sciradio",
"Xenoarcheologist" = "sciradio",
"Xenobiologist" = "sciradio",
// Security
"Brig Physician" = "secradio",
"Detective" = "secradio",
"Forensic Technician" = "secradio",
"Head of Security" = "secradio",
"Human Resources Agent" = "secradio",
"Internal Affairs Agent" = "secradio",
"Magistrate" = "secradio",
"Security Officer" = "secradio",
"Security Pod Pilot" = "secradio",
"Warden" = "secradio",
// Supply
"Quartermaster" = "supradio",
"Cargo Technician" = "supradio",
"Shaft Miner" = "supradio",
"Spelunker" = "supradio",
// Service
"Barber" = "srvradio",
"Bartender" = "srvradio",
"Beautician" = "srvradio",
"Botanical Researcher" = "srvradio",
"Botanist" = "srvradio",
"Butcher" = "srvradio",
"Chaplain" = "srvradio",
"Chef" = "srvradio",
"Clown" = "srvradio",
"Cook" = "srvradio",
"Culinary Artist" = "srvradio",
"Custodial Technician" = "srvradio",
"Hair Stylist" = "srvradio",
"Hydroponicist" = "srvradio",
"Janitor" = "srvradio",
"Journalist" = "srvradio",
"Librarian" = "srvradio",
"Mime" = "srvradio",
)
// Just command members
var/heads = list("Captain", "Head of Personnel", "Nanotrasen Representative", "Blueshield", "Chief Engineer", "Chief Medical Officer", "Research Director", "Head of Security", "Magistrate", "AI")
// Just ERT
var/ert_jobs = list("Emergency Response Team Officer", "Emergency Response Team Engineer", "Emergency Response Team Medic", "Emergency Response Team Leader", "Emergency Response Team Member")
// Defined so code compiles and incase someone has a non-standard job
var/job_class = "radio"
// NOW FOR ACTUAL TOGGLES
/* Simple Toggles */
var/toggle_activated = TRUE
var/toggle_jobs = FALSE
var/toggle_job_color = FALSE
var/toggle_name_color = FALSE
var/toggle_timecode = FALSE
var/toggle_command_bold = FALSE
// Hack section
var/toggle_gibberish = FALSE
var/toggle_honk = FALSE
/* Strings */
var/setting_language = null
var/job_indicator_type = null
/* Tables */
// var/list/regex = list()
/* Arrays */
var/list/firewall = list()
/* Meta stuff */
// These variables requires the source computer to be hacked in order to change
var/list/requires_unlock = list(
"firewall" = TRUE,
"toggle_gibberish" = TRUE,
"toggle_honk" = TRUE,
)
// This is used to sanitize topic data
// var/list/tables = list("regex")
var/list/arrays = list("firewall")
// This tells the datum what is safe to serialize and what's not. It also applies to deserialization.
var/list/to_serialize = list(
"toggle_activated",
"toggle_jobs",
"toggle_job_color",
"toggle_name_color",
"job_indicator_type",
"toggle_timecode",
"toggle_command_bold",
"toggle_gibberish",
"toggle_honk",
"setting_language",
// "regex",
"firewall"
)
// This is used for sanitization.
var/list/serialize_sanitize = list(
"toggle_activated" = "bool",
"toggle_jobs" = "bool",
"toggle_job_color" = "bool",
"toggle_name_color" = "bool",
"job_indicator_type" = "string",
"toggle_timecode" = "bool",
"toggle_command_bold" = "bool",
"toggle_gibberish" = "bool",
"toggle_honk" = "bool",
"setting_language" = "string",
// "regex" = "table",
"firewall" = "array"
)
// These are the job card styles
var/list/job_card_styles = list(
JOB_STYLE_1, JOB_STYLE_2, JOB_STYLE_3, JOB_STYLE_4
)
// Used to determine what languages are allowable for conversion. Generated during runtime.
var/list/valid_languages = list("--DISABLE--")
/datum/nttc_configuration/proc/reset()
/* Simple Toggles */
toggle_activated = initial(toggle_activated)
toggle_jobs = initial(toggle_jobs)
toggle_job_color = initial(toggle_job_color)
toggle_name_color = initial(toggle_name_color)
toggle_timecode = initial(toggle_timecode)
toggle_command_bold = initial(toggle_command_bold)
// Hack section
toggle_gibberish = initial(toggle_gibberish)
toggle_honk = initial(toggle_honk)
/* Strings */
setting_language = initial(setting_language)
job_indicator_type = initial(job_indicator_type)
/* Tables */
// regex = list()
/* Arrays */
firewall = list()
/datum/nttc_configuration/proc/update_languages()
for(var/language in GLOB.all_languages)
var/datum/language/L = GLOB.all_languages[language]
if(L.flags & HIVEMIND)
continue
valid_languages[language] = TRUE
// I'd use serialize() but it's used by another system. This converts the configuration into a JSON string.
/datum/nttc_configuration/proc/nttc_serialize()
. = list()
for(var/variable in to_serialize)
.[variable] = vars[variable]
. = json_encode(.)
// This loads a configuration from a JSON string.
// Fucking broken as shit, someone help me fix this.
/datum/nttc_configuration/proc/nttc_deserialize(text, obj/machinery/computer/telecomms/traffic/source, var/ckey)
if(word_blacklist.Find(text)) //uh oh, they tried to be naughty
message_admins("<span class='danger'>EXPLOIT WARNING: </span> [ckey] attempted to upload an NTTC configuration containing JS abusable tags!")
log_admin("EXPLOIT WARNING: [ckey] attempted to upload an NTTC configuration containing JS abusable tags")
return FALSE
var/list/var_list = json_decode(text)
for(var/variable in var_list)
if(variable in to_serialize) // Don't just accept any random vars jesus christ!
if(requires_unlock[variable] && (source && !source.unlocked))
continue
var/sanitize_method = serialize_sanitize[variable]
var/variable_value = var_list[variable]
variable_value = nttc_sanitize(variable_value, sanitize_method)
if(variable_value != null)
vars[variable] = variable_value
return TRUE
// Sanitizing user input. Don't blindly trust the JSON.
/datum/nttc_configuration/proc/nttc_sanitize(variable, sanitize_method)
if(!sanitize_method)
return null
switch(sanitize_method)
if("bool")
return variable ? TRUE : FALSE
// if("table", "array")
if("array")
if(!islist(variable))
return list()
// Insert html filtering for the regexes here if you're boring
var/newlist = json_decode(html_decode(json_encode(variable)))
if(!islist(newlist))
return null
return newlist
if("string")
return "[variable]"
return variable
// Primary signal modification. This is where all of the variables behavior are actually implemented.
/datum/nttc_configuration/proc/modify_signal(datum/signal/signal)
// Servers are deliberately turned off. Mark every signal as rejected.
if(!toggle_activated)
signal.data["reject"] = TRUE
return
// Firewall
// This must happen before anything else modifies the signal ["name"].
if(islist(firewall) && firewall.len > 0)
if(firewall.Find(signal.data["name"]))
signal.data["reject"] = 1
// All job and coloring shit
if(toggle_job_color || toggle_name_color)
var/job = signal.data["job"]
job_class = all_jobs[job]
if(toggle_name_color)
var/new_name = "<span class=\"[job_class]\">" + signal.data["name"] + "</span>"
signal.data["name"] = new_name
signal.data["realname"] = new_name // this is required because the broadcaster uses this directly if the speaker doesn't have a voice changer on
if(toggle_jobs)
var/new_name = ""
var/job = signal.data["job"]
if(job in ert_jobs)
job = "ERT"
if(toggle_job_color)
switch(job_indicator_type)
if(JOB_STYLE_1)
new_name = signal.data["name"] + " <span class=\"[job_class]\">([job])</span> "
if(JOB_STYLE_2)
new_name = signal.data["name"] + " - <span class=\"[job_class]\">[job]</span> "
if(JOB_STYLE_3)
new_name = "<span class=\"[job_class]\"><small>\[[job]\]</small></span> " + signal.data["name"] + " "
if(JOB_STYLE_4)
new_name = "<span class=[job_class]>([job])</span> " + signal.data["name"] + " "
else
switch(job_indicator_type)
if(JOB_STYLE_1)
new_name = signal.data["name"] + " ([job]) "
if(JOB_STYLE_2)
new_name = signal.data["name"] + " - [job] "
if(JOB_STYLE_3)
new_name = "<small>\[[job]\]</small> " + signal.data["name"] + " "
if(JOB_STYLE_4)
new_name = "([job]) " + signal.data["name"] + " "
signal.data["name"] = new_name
signal.data["realname"] = new_name // this is required because the broadcaster uses this directly if the speaker doesn't have a voice changer on
// Add the current station time like a time code.
if(toggle_timecode)
var/new_name = "\[[station_time_timestamp()]] " + signal.data["name"]
signal.data["name"] = new_name
signal.data["realname"] = new_name // this is required because the broadcaster uses this directly if the speaker doesn't have a voice changer on
// This is hacky stuff for multilingual messages...
var/list/message_pieces = signal.data["message"]
// Makes heads of staff bold
if(toggle_command_bold)
var/job = signal.data["job"]
if((job in ert_jobs) || (job in heads))
for(var/datum/multilingual_say_piece/S in message_pieces)
S.message = "<b>[capitalize(S.message)]</b>" // This only capitalizes the first word
// Hacks!
// Censor dat shit like nobody's business
if(toggle_gibberish)
Gibberish_all(message_pieces, 80)
// Replace everything with HONK!
if(toggle_honk)
var/list/split = splittext(signal.data["message"], " ")
var/honklength = split.len
var/new_message = ""
for(var/i in 1 to honklength)
new_message += pick("HoNK!", "HONK", "HOOOoONK", "HONKHONK!", "HoNnnkKK!!!", "HOOOOOOOOOOONK!!!!11!", "henk!") + " "
signal.data["message"] = message_to_multilingual(new_message)
// Language Conversion
if(setting_language && valid_languages[setting_language])
if(setting_language == "--DISABLE--")
setting_language = null
else
for(var/datum/multilingual_say_piece/S in message_pieces)
if(S.speaking != GLOB.all_languages["Noise"]) // check if they are emoting, these do not need to be translated
S.speaking = GLOB.all_languages[setting_language]
// Regex replacements
// if(islist(regex) && regex.len > 0)
// for(var/datum/multilingual_say_piece/S in message_pieces)
// var/new_message = S.message
// for(var/reg in regex)
// var/replacePattern = pencode_to_html(regex[reg])
// var/regex/start = regex("[reg]", "gi")
// new_message = start.Replace(new_message, replacePattern)
// S.message = new_message
// Make sure the message is valid after we tinkered with it, otherwise reject it
if(signal.data["message"] == "" || !signal.data["message"])
signal.data["reject"] = 1
/datum/nttc_configuration/Topic(mob/user, href_list, window_id, obj/machinery/computer/telecomms/traffic/source)
// Toggles
if(href_list["toggle"])
var/var_to_toggle = href_list["toggle"]
if(requires_unlock[var_to_toggle] && !source.unlocked)
return
if(!(var_to_toggle in to_serialize))
return
vars[var_to_toggle] = !vars[var_to_toggle]
log_action(user, "toggled NTTC variable [var_to_toggle] [vars[var_to_toggle] ? "on" : "off"]")
// Job Format
if(href_list["setting_job_card_style"])
var/card_style = input(user, "Pick a job card format.", "Job Card Format") as null|anything in job_card_styles
if(!card_style)
return
job_indicator_type = card_style
to_chat(user, "<span class='notice'>Jobs will now have the style of [card_style].</span>")
log_action(user, "has set NTTC job card format to [card_style]", TRUE)
// Strings
if(href_list["setting_language"])
var/new_language = input(user, "Pick a language to convert messages to.", "Language Conversion") as null|anything in valid_languages
if(!new_language)
return
if(new_language == "--DISABLE--")
setting_language = null
to_chat(user, "<span class='notice'>Language conversion disabled.</span>")
else
setting_language = new_language
to_chat(user, "<span class='notice'>Messages will now be converted to [new_language].</span>")
log_action(user, new_language == "--DISABLE--" ? "disabled NTTC language conversion" : "set NTTC language conversion to [new_language]", TRUE)
// Tables
// if(href_list["create_row"])
// if(href_list["table"] && href_list["table"] in tables)
// if(requires_unlock[href_list["table"]] && !source.unlocked)
// return
// var/new_key = clean_input(user, "Provide a key for the new row.", "New Row")
// if(!new_key)
// return
// var/new_value = clean_input(user, "Provide a new value for the key [new_key]", "New Row")
// if(new_value == null)
// return
// if(word_blacklist.Find(new_value)) //uh oh, they tried to be naughty
// message_admins("<span class='danger'>EXPLOIT WARNING: </span> [user.ckey] attempted to add a NTTC regex row containing JS abusable tags!")
// log_admin("EXPLOIT WARNING: [user.ckey] attempted to add a NTTC regex row containing JS abusable tags")
// to_chat(user, "<span class='biggerdanger'>ERROR: Regex contained bad strings. Upload cancelled.</span>")
// return
// var/list/table = vars[href_list["table"]]
// table[new_key] = new_value
// to_chat(user, "<span class='notice'>Added row [new_key] -> [new_value].</span>")
// log_action(user, "updated [href_list["table"]] - new row [new_key] -> [new_value]")
// if(href_list["delete_row"])
// if(href_list["table"] && href_list["table"] in tables)
// if(requires_unlock[href_list["table"]] && !source.unlocked)
// return
// var/list/table = vars[href_list["table"]]
// table.Remove(href_list["delete_row"])
// to_chat(user, "<span class='warning'>Removed row [href_list["delete_row"]] from [href_list["table"]]</span>")
// log_action(user, "updated [href_list["table"]] - removed row [href_list["delete_row"]]")
// Arrays
if(href_list["create_item"])
if(href_list["array"] && (href_list["array"] in arrays))
if(requires_unlock[href_list["array"]] && !source.unlocked)
return
var/new_value = clean_input(user, "Provide a value for the new index.", "New Index")
if(new_value == null)
return
var/list/array = vars[href_list["array"]]
array.Add(new_value)
to_chat(user, "<span class='notice'>Added row [new_value].</span>")
log_action(user, "updated [href_list["array"]] - new value [new_value]", TRUE)
if(href_list["delete_item"])
if(href_list["array"] && (href_list["array"] in arrays))
if(requires_unlock[href_list["array"]] && !source.unlocked)
return
var/list/array = vars[href_list["array"]]
array.Remove(href_list["delete_item"])
to_chat(user, "<span class='warning'>Removed [href_list["delete_item"]] from [href_list["array"]]</span>")
log_action(user, "updated [href_list["array"]] - removed [href_list["delete_item"]]")
// Spit out the serialized config to the user
if(href_list["save_config"])
user << browse(nttc_serialize(), "window=save_nttc")
if(href_list["load_config"])
var/json = input(user, "Provide configuration JSON below.", "Load Config", nttc_serialize()) as message
if(nttc_deserialize(json, source, user.ckey))
log_action(user, "has uploaded a NTTC JSON configuration: [ADMIN_SHOWDETAILS("Show", json)]", TRUE)
user << output(list2params(list(nttc_serialize())), "[window_id].browser:updateConfig")
/datum/nttc_configuration/proc/log_action(user, msg, adminmsg = FALSE)
log_game("NTTC: [key_name(user)] [msg]")
log_investigate("[key_name(user)] [msg]", "ntsl")
if(adminmsg)
message_admins("[key_name_admin(user)] [msg]")
/* Asset datum for the UI */
/datum/asset/simple/nttc
assets = list(
"bundle.css" = 'html/nttc/dist/bundle.css',
"bundle.js" = 'html/nttc/dist/bundle.js',
"tab_home.html" = 'html/nttc/dist/tab_home.html',
"tab_hack.html" = 'html/nttc/dist/tab_hack.html',
"tab_filtering.html" = 'html/nttc/dist/tab_filtering.html',
"tab_firewall.html" = 'html/nttc/dist/tab_firewall.html',
// "tab_regex.html" = 'html/nttc/dist/tab_regex.html',
"uiTitleFluff.png" = 'html/nttc/dist/uiTitleFluff.png'
)
/* Custom subtype of /datum/browser that behaves as we want for our project */
/datum/browser/nttc
var/initial_config // Initial NTTC configuration
/datum/browser/nttc/New(nuser, nwindow_id, ntitle = 0, nwidth = 0, nheight = 0, var/atom/nref = null, nttc_config)
. = ..()
initial_config = nttc_config
// Prevent all stylesheets from being added, we have our own CSS that's bundled with gulp
/datum/browser/nttc/add_stylesheet()
return
// No header, we're running a fully complete .html file
/datum/browser/nttc/get_header()
return
// We inject a little code at the bottom of the file, similar to NanoUI, but more limited.
// This code is used for delivering live updates of config changes & allowing the UI to provide Topic data.
/datum/browser/nttc/get_footer()
var/byondSrc = "byond://?src=[ref.UID()];"
var/dat = "<script type='text/javascript'>"
dat += "window.byondSrc = '[byondSrc]';"
dat += "window.originalConfig = '[html_encode(initial_config)]';"
dat += "window.updateConfig = function(config) { window.config = JSON.parse(config); window.reload_tab() };"
dat += "</script>"
return dat
//// NTTC PC ////
/obj/machinery/computer/telecomms/traffic
name = "telecommunications traffic control"
light_color = LIGHT_COLOR_DARKGREEN
req_access = list(ACCESS_TCOMSAT)
circuit = /obj/item/circuitboard/comm_traffic
// NTTC
var/window_id // mostly used to let the configuration datum update the user's UI
var/unlocked = FALSE
/obj/machinery/computer/telecomms/traffic/multitool_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
unlocked = !unlocked
to_chat(user, "<span class='notice'>This computer is now [unlocked ? "<span class='good'>Unlocked</span>" : "<span class='bad'>Locked</span>"]. Reopen the UI to see the difference.</span>")
/obj/machinery/computer/telecomms/traffic/attack_hand(mob/user)
interact(user)
/obj/machinery/computer/telecomms/traffic/interact(mob/user)
if(stat & (BROKEN|NOPOWER))
return 0
/*
if(GLOB.nttc_config.valid_languages.len == 1)
GLOB.nttc_config.update_languages() // this is silly but it has to be done because NTTC inits before languages do
var/datum/asset/assets = get_asset_datum(/datum/asset/simple/nttc)
assets.send(user)
var/dat = file2text("html/nttc/dist/index.html")
if(unlocked)
dat += "\n<script type='text/javascript'>window.secretsunlocked = true;</script>"
var/datum/browser/nttc/nt_browser = new(user, name, "NTTC", 720, 480, src, GLOB.nttc_config.nttc_serialize())
nt_browser.set_content(dat)
nt_browser.open()
window_id = nt_browser.window_id
*/
/obj/machinery/computer/telecomms/traffic/Topic(href, href_list)
if(..())
return 1
var/mob/user = usr
if(!istype(user) || !user.client)
return 0
//GLOB.nttc_config.Topic(user, href_list, window_id, src)
+12 -4
View File
@@ -70,6 +70,14 @@
{{:helper.link(data.nttc_setting_language ? data.nttc_setting_language : 'Unset', 'globe', {'nttc_setting_language' : 1}, null, data.nttc_setting_language ? 'selected' : null)}}
</div>
</div>
<div class="item">
<div class="itemLabel">
Network ID:
</div>
<div class="itemContent">
{{:helper.link(data.network_id ? data.network_id : 'Unset', 'server', {'network_id' : 1}, null, data.network_id ? 'selected' : null)}}
</div>
</div>
<h3>Maintenance</h3>
{{:helper.link('Import Configuration', 'sign-in', {'import' : 1})}}
{{:helper.link('Export Configuration', 'sign-out', {'export' : 1})}}
@@ -95,7 +103,7 @@
Link Password:
</div>
<div class="itemContent">
{{:data.link_password}}
{{:helper.link(data.link_password ? data.link_password : 'Unset', 'lock', {'change_password' : 1}, null, data.link_password ? 'selected' : null)}}
</div>
</div>
<br>
@@ -125,7 +133,7 @@
<td style={{:value.status_color}}>{{:value.status ? 'Active' : 'Error'}}</td>
<td>{{:helper.link('Unlink', 'unlink', {'unlink' : value.addr}, null, 'infoButton')}}</td>
</tr>
{{/for}}
</tbody>
</table>
{{/for}}
</tbody>
</table>
{{/if}}
+107
View File
@@ -0,0 +1,107 @@
<h1>Relay Configuration</h1>
<div class="item">
<div class="itemLabel">
Device Active:
</div>
<div class="itemContent">
{{:helper.link(data.active ? 'Enabled' : 'Disabled', 'power-off', {'toggle_active' : 1}, null, data.active ? 'selected' : '')}}
</div>
</div>
<div class="item">
<div class="itemLabel">
Network ID:
</div>
<div class="itemContent">
{{:helper.link(data.network_id ? data.network_id : 'Unset', 'pencil', {'network_id' : 1}, null, data.network_id ? 'selected' : null)}}
</div>
</div>
<div class="item">
<div class="itemLabel">
Link Status:
</div>
<div class="itemContent">
{{if data.linked}}
<span class="good">Linked</span>
{{else}}
<span class="bad">Unlinked</span>
{{/if}}
</div>
</div>
{{if data.linked}}
<div class="item">
<div class="itemLabel">
Linked Core ID:
</div>
<div class="itemContent">
{{:data.linked_core_id}}
</div>
</div>
<div class="item">
<div class="itemLabel">
Linked Core Address:
</div>
<div class="itemContent">
{{:data.linked_core_addr}}
</div>
</div>
<div class="item">
<div class="itemLabel">
Hidden Link:
</div>
<div class="itemContent">
{{:helper.link(data.hidden_link ? 'Yes' : 'No', 'eye-slash', {'toggle_hidden_link' : 1}, null, data.hidden_link ? 'selected' : null)}}
</div>
</div>
<div class="item">
<div class="itemLabel">
Unlink:
</div>
<div class="itemContent">
{{:helper.link('Unlink', 'unlink', {'unlink' : 1}, null, 'redButton')}}
</div>
</div>
{{else}}
<style>
table {
border-collapse: collapse;
}
table,
td,
th {
border: 1px solid #ffffff;
}
.infoButton {
background: none;
border: none;
}
</style>
<h3>Please select a Core to link to</h3>
<table style='width: 100%; text-align: center; background-color: #272727;'>
<colgroup>
<col span="1" style="width: 40%;">
<col span="1" style="width: 40%;">
<col span="1" style="width: 10%;">
<col span="1" style="width: 10%;">
</colgroup>
<thead>
<tr>
<th>Network Address</th>
<th>Network ID</th>
<th>Sector</th>
<th>Link</th>
</tr>
</thead>
<tbody>
{{for data.entries}}
<tr>
<td>{{:value.addr}}</td>
<td>{{:value.net_id}}</td>
<td>{{:value.sector}}</td>
<td>{{:helper.link('Link', 'link', {'link' : value.addr}, null, 'infoButton')}}</td>
</tr>
{{/for}}
</tbody>
</table>
{{/if}}