diff --git a/code/game/objects/items/devices/paicard.dm b/code/game/objects/items/devices/paicard.dm index 906a02a0609..4be5a573e25 100644 --- a/code/game/objects/items/devices/paicard.dm +++ b/code/game/objects/items/devices/paicard.dm @@ -6,6 +6,7 @@ w_class = ITEMSIZE_SMALL slot_flags = SLOT_BELT origin_tech = list(TECH_DATA = 2) + var/list/installed_encryptionkeys = list() var/obj/item/device/radio/radio var/looking_for_personality = 0 var/mob/living/silicon/pai/pai @@ -47,7 +48,51 @@ /obj/item/device/paicard/attackby(obj/item/C as obj, mob/user as mob) if(istype(C, /obj/item/card/id)) scan_ID(C, user) + else if(istype(C, /obj/item/device/encryptionkey)) + if(length(installed_encryptionkeys) > 2) + to_chat(user, SPAN_WARNING("\The [src] already has the full number of possible encryption keys installed!")) + return + var/obj/item/device/encryptionkey/EK = C + var/added_channels = FALSE + for(var/thing in (EK.channels | EK.additional_channels)) + if(!radio.channels[thing]) + added_channels = TRUE + break + if(added_channels) + installed_encryptionkeys += EK + user.drop_from_inventory(EK, src) + user.visible_message("[user] slides \the [EK] into \the [src]'s encryption key slot.", SPAN_NOTICE("You slide \the [EK] into \the [src]'s encryption key slot, granting it access to the radio channels.")) + recalculateChannels() + if(pai) + to_chat(pai, SPAN_NOTICE("You now have access to these radio channels: [english_list(radio.channels)].")) + else + to_chat(user, SPAN_WARNING("\The [src] would not gain any new channels from \the [EK].")) + else if(C.isscrewdriver()) + if(!length(installed_encryptionkeys)) + to_chat(user, SPAN_WARNING("There are no installed encryption keys to remove!")) + return + user.visible_message("[user] uses \the [C] to pop the encryption key[length(installed_encryptionkeys) > 1 ? "s" : ""] out of \the [src].", SPAN_NOTICE("You use \the [C] to pop the encryption key[length(installed_encryptionkeys) > 1 ? "s" : ""] out of \the [src].")) + for(var/key in installed_encryptionkeys) + var/obj/item/device/encryptionkey/EK = key + EK.forceMove(get_turf(src)) + installed_encryptionkeys -= EK + recalculateChannels() +/obj/item/device/paicard/proc/recalculateChannels() + radio.channels = list() + + for(var/keyslot in installed_encryptionkeys) + var/obj/item/device/encryptionkey/EK = keyslot + for(var/ch_name in (EK.channels | EK.additional_channels)) + radio.channels[ch_name] = radio.FREQ_LISTENING + + for(var/ch_name in radio.channels) + if(!SSradio) + sleep(30) // Waiting for the SSradio to be created. + if(!SSradio) + radio.name = "broken radio headset" + return + radio.secure_radio_connections[ch_name] = SSradio.add_object(radio, radiochannels[ch_name], RADIO_CHAT) //This proc is called when the user scans their ID on the pAI card. //It registers their ID and copies their access to the pai, allowing it to use airlocks the owner can diff --git a/code/modules/modular_computers/file_system/programs/pai/radio.dm b/code/modules/modular_computers/file_system/programs/pai/radio.dm index a8a7f4f07b3..ecfbe356324 100644 --- a/code/modules/modular_computers/file_system/programs/pai/radio.dm +++ b/code/modules/modular_computers/file_system/programs/pai/radio.dm @@ -10,11 +10,11 @@ /datum/computer_file/program/pai_radio/ui_interact(mob/user) var/datum/vueui/ui = SSvueui.get_open_ui(user, src) if (!ui) - ui = new /datum/vueui/modularcomputer(user, src, "mcomputer-pai-radio", 400, 150, "pAI Radio Configuration") + ui = new /datum/vueui/modularcomputer(user, src, "mcomputer-pai-radio", 450, 400, "pAI Radio Configuration") ui.open() /datum/computer_file/program/pai_radio/vueui_transfer(oldobj) - SSvueui.transfer_uis(oldobj, src, "mcomputer-pai-radio", 400, 150, "pAI Radio Configuration") + SSvueui.transfer_uis(oldobj, src, "mcomputer-pai-radio", 450, 400, "pAI Radio Configuration") return TRUE // Gaters data for ui @@ -25,7 +25,6 @@ var/headerdata = get_header_data(data["_PC"]) if(headerdata) data["_PC"] = headerdata - . = data if(!istype(computer, /obj/item/modular_computer/silicon)) return @@ -34,14 +33,20 @@ return var/mob/living/silicon/pai/host = true_computer.computer_host - VUEUI_SET_CHECK(data["listening"], host.radio.broadcasting, ., data) - VUEUI_SET_CHECK(data["frequency"], format_frequency(host.radio.frequency), ., data) + data["listening"] = host.radio.broadcasting + data["frequency"] = format_frequency(host.radio.frequency) - LAZYINITLIST(data["channels"]) + var/list/pai_channels = list() for(var/ch_name in host.radio.channels) - var/ch_stat = host.radio.channels[ch_name] - VUEUI_SET_CHECK(data["channels"][ch_name], !!(ch_stat & host.radio.FREQ_LISTENING), ., data) - + var/list/channel_info = list( + "name" = ch_name, + "listening" = (host.radio.channels[ch_name] & host.radio.FREQ_LISTENING) + ) + pai_channels[++pai_channels.len] = channel_info + data["channels"] = pai_channels + + return data + /datum/computer_file/program/pai_radio/Topic(href, href_list) . = ..() diff --git a/html/changelogs/geeves-pai_encryption_keys.yml b/html/changelogs/geeves-pai_encryption_keys.yml new file mode 100644 index 00000000000..ac44d8205db --- /dev/null +++ b/html/changelogs/geeves-pai_encryption_keys.yml @@ -0,0 +1,7 @@ +author: Geeves + +delete-after: True + +changes: + - rscadd: "Clicking on a folded up pAI with an encryption key now slots the key into the pAI card, granting it access to those radio channels." + - rscadd: "You can remove pAI encryption keys by using a screwdriver on them." \ No newline at end of file diff --git a/vueui/src/components/view/mcomputer/pai/radio.vue b/vueui/src/components/view/mcomputer/pai/radio.vue index 279533bc258..a2ff774a6cc 100644 --- a/vueui/src/components/view/mcomputer/pai/radio.vue +++ b/vueui/src/components/view/mcomputer/pai/radio.vue @@ -12,14 +12,15 @@ + ++ - +
+ On Off