diff --git a/code/game/jobs/access_datum.dm b/code/game/jobs/access_datum.dm index 32773362a01..d5d9e201392 100644 --- a/code/game/jobs/access_datum.dm +++ b/code/game/jobs/access_datum.dm @@ -493,6 +493,7 @@ var/const/access_pilot = 67 /var/const/access_syndicate = 150//General Syndicate Access /datum/access/syndicate id = access_syndicate + desc = "Syndicate" access_type = ACCESS_TYPE_SYNDICATE /******* @@ -507,11 +508,13 @@ var/const/access_pilot = 67 /var/const/access_crate_cash = 200 /datum/access/crate_cash id = access_crate_cash + desc = "Crate cash" access_type = ACCESS_TYPE_NONE /var/const/access_trader = 160//General Beruang Trader Access /datum/access/trader id = access_trader + desc = "Trader" access_type = ACCESS_TYPE_PRIVATE /var/const/access_alien = 300 // For things like crashed ships. diff --git a/code/modules/admin/modify_robot.dm b/code/modules/admin/modify_robot.dm index 69bce786798..c02457152f6 100644 --- a/code/modules/admin/modify_robot.dm +++ b/code/modules/admin/modify_robot.dm @@ -53,17 +53,13 @@ .["target"]["side"] = icon2base64(get_flat_icon(target,dir=WEST,no_anim=TRUE)) .["target"]["side_alt"] = icon2base64(get_flat_icon(target,dir=EAST,no_anim=TRUE)) .["target"]["back"] = icon2base64(get_flat_icon(target,dir=NORTH,no_anim=TRUE)) - var/list/target_items = list() - for(var/obj/item in target.module.modules) - target_items += list(list("name" = item.name, "ref" = "\ref[item]", "icon" = icon2html(item, user, sourceonly=TRUE), "desc" = item.desc)) - .["target"]["modules"] = target_items + .["target"]["modules"] = get_target_items(user) var/list/module_options = list() for(var/module in robot_modules) module_options += module .["model_options"] = module_options // Data for the upgrade options .["target"] += get_upgrades() - var/obj/item/weapon/gun/energy/kinetic_accelerator/kin = locate() in target.module.modules if(kin) .["target"]["pka"] += get_pka(kin) @@ -77,29 +73,21 @@ .["target"]["radio_channels"] = radio_channels .["target"]["availalbe_channels"] = availalbe_channels // Components - var/list/components = list() - for(var/entry in target.components) - var/datum/robot_component/C = target.components[entry] - components += list(list("name" = C.name, "ref" = "\ref[C]", "brute_damage" = C.brute_damage, "electronics_damage" = C.electronics_damage, "max_damage" = C.max_damage, "installed" = C.installed, "exists" = (C.wrapped ? TRUE : FALSE))) - .["target"]["components"] = components + .["target"]["components"] = get_components() .["cell"] = target.cell?.name - var/list/cell_options = list() - for(var/cell in typesof(/obj/item/weapon/cell)) - var/obj/item/weapon/cell/C = cell - if(initial(C.name) == "power cell") - continue - if(ispath(C, /obj/item/weapon/cell/standin)) - continue - if(ispath(C, /obj/item/weapon/cell/device)) - continue - if(ispath(C, /obj/item/weapon/cell/mech)) - continue - if(cell_options[initial(C.name)]) // empty cells are defined after normal cells! - continue - cell_options += list(initial(C.name) = list("path" = "[C]", "charge" = initial(C.maxcharge), "max_charge" = initial(C.maxcharge), "charge_amount" = initial(C.charge_amount) , "self_charge" = initial(C.self_recharge))) // our cells do not have their charge predefined, they do it on init, so both maaxcharge for now - .["cell_options"] = cell_options + .["cell_options"] = get_cells() // Access - //.["target"]["id_icon"] = icon2html(target.idcard, user, sourceonly=TRUE) + .["id_icon"] = icon2html(target.idcard, user, sourceonly=TRUE) + var/list/active_access = list() + for(var/access in target.idcard?.GetAccess()) + active_access += list(list("id" = access, "name" = get_access_desc(access))) + .["target"]["active_access"] = active_access + var/list/access_options = list() + for(var/datum/access/acc) + if(acc.id in target.idcard?.GetAccess()) + continue + access_options += list(list("id" = acc.id, "name" = acc.desc)) + .["access_options"] = access_options // Section for source data for the module we might want to salvage if(source) .["source"] += get_module_source(user) @@ -348,6 +336,32 @@ if(istype(C, /datum/robot_component/cell)) target.cell = null return TRUE + if("add_access") + target.idcard.access += text2num(params["access"]) + return TRUE + if("rem_access") + target.idcard.access -= text2num(params["access"]) + return TRUE + if("add_centcom") + target.idcard.access |= get_all_centcom_access() + return TRUE + if("rem_centcom") + target.idcard.access -= get_all_centcom_access() + return TRUE + if("add_station") + target.idcard.access |= get_all_station_access() + target.idcard.access |= access_synth + return TRUE + if("rem_station") + target.idcard.access -= get_all_station_access() + target.idcard.access -= access_synth + return TRUE + +/datum/eventkit/modify_robot/proc/get_target_items(var/mob/user) + var/list/target_items = list() + for(var/obj/item in target.module.modules) + target_items += list(list("name" = item.name, "ref" = "\ref[item]", "icon" = icon2html(item, user, sourceonly=TRUE), "desc" = item.desc)) + return target_items /datum/eventkit/modify_robot/proc/get_module_source(var/mob/user) var/list/source_list = list() @@ -452,3 +466,27 @@ pka["capacity"] = kin.get_remaining_mod_capacity() pka["max_capacity"] = kin.max_mod_capacity return pka + +/datum/eventkit/modify_robot/proc/get_cells() + var/list/cell_options = list() + for(var/cell in typesof(/obj/item/weapon/cell)) + var/obj/item/weapon/cell/C = cell + if(initial(C.name) == "power cell") + continue + if(ispath(C, /obj/item/weapon/cell/standin)) + continue + if(ispath(C, /obj/item/weapon/cell/device)) + continue + if(ispath(C, /obj/item/weapon/cell/mech)) + continue + if(cell_options[initial(C.name)]) // empty cells are defined after normal cells! + continue + cell_options += list(initial(C.name) = list("path" = "[C]", "charge" = initial(C.maxcharge), "max_charge" = initial(C.maxcharge), "charge_amount" = initial(C.charge_amount) , "self_charge" = initial(C.self_recharge))) // our cells do not have their charge predefined, they do it on init, so both maaxcharge for now + return cell_options + +/datum/eventkit/modify_robot/proc/get_components() + var/list/components = list() + for(var/entry in target.components) + var/datum/robot_component/C = target.components[entry] + components += list(list("name" = C.name, "ref" = "\ref[C]", "brute_damage" = C.brute_damage, "electronics_damage" = C.electronics_damage, "max_damage" = C.max_damage, "installed" = C.installed, "exists" = (C.wrapped ? TRUE : FALSE))) + return components diff --git a/tgui/packages/tgui/interfaces/ModifyRobot/ModifyRobotTabs/ModifyRobotAccess.tsx b/tgui/packages/tgui/interfaces/ModifyRobot/ModifyRobotTabs/ModifyRobotAccess.tsx new file mode 100644 index 00000000000..4c61e67f0d3 --- /dev/null +++ b/tgui/packages/tgui/interfaces/ModifyRobot/ModifyRobotTabs/ModifyRobotAccess.tsx @@ -0,0 +1,180 @@ +import { capitalize } from 'common/string'; +import { useState } from 'react'; +import { useBackend } from 'tgui/backend'; +import { + Button, + Divider, + Flex, + Icon, + Image, + Input, + Section, + Stack, +} from 'tgui/components'; + +import { NoSpriteWarning } from '../components'; +import { prepareSearch } from '../functions'; +import { Access, Target } from '../types'; + +export const ModifyRobotAccess = (props: { + target: Target; + tab_icon: string; + all_access: Access[]; +}) => { + const { act } = useBackend(); + const { target, tab_icon, all_access } = props; + const [searchAccessAll, setSearchAccessAll] = useState(''); + const [searchAccessActive, setSearchAccessActive] = useState(''); + + return ( + <> + {!target.active && } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; + +const AccessSection = (props: { + title: string; + searchText: string; + onSearchText: Function; + access: Access[]; + action: string; + buttonColor: string; + buttonIcon: string; +}) => { + const { act } = useBackend(); + const { + title, + searchText, + onSearchText, + access, + action, + buttonColor, + buttonIcon, + } = props; + return ( +
+ onSearchText(value)} + /> + + + + {prepareSearch(access, searchText).map((acc, i) => { + return ( + + ); + })} + + +
+ ); +}; diff --git a/tgui/packages/tgui/interfaces/ModifyRobot/ModifyRobotTabs/ModifyRobotComponent.tsx b/tgui/packages/tgui/interfaces/ModifyRobot/ModifyRobotTabs/ModifyRobotComponent.tsx index 109854f090d..fd644c429c1 100644 --- a/tgui/packages/tgui/interfaces/ModifyRobot/ModifyRobotTabs/ModifyRobotComponent.tsx +++ b/tgui/packages/tgui/interfaces/ModifyRobot/ModifyRobotTabs/ModifyRobotComponent.tsx @@ -35,7 +35,7 @@ export const ModifyRobotComponent = (props: { <> {!target.active && } - + - + -