From 6d2680d7ecd5125404a7903e5527b93b69da5656 Mon Sep 17 00:00:00 2001 From: SandPoot Date: Wed, 2 Feb 2022 12:31:20 -0300 Subject: [PATCH] Update files --- .../mob/living/simple_animal/bot/bot.dm | 122 +++--- .../mob/living/simple_animal/bot/cleanbot.dm | 56 ++- .../mob/living/simple_animal/bot/ed209bot.dm | 75 ++-- .../mob/living/simple_animal/bot/firebot.dm | 40 +- .../mob/living/simple_animal/bot/floorbot.dm | 72 ++-- .../mob/living/simple_animal/bot/honkbot.dm | 18 - .../mob/living/simple_animal/bot/medbot.dm | 123 +++--- .../mob/living/simple_animal/bot/mulebot.dm | 50 --- .../mob/living/simple_animal/bot/secbot.dm | 63 +--- tgui/packages/tgui/interfaces/SimpleBot.tsx | 351 ++++++++++++++++++ 10 files changed, 565 insertions(+), 405 deletions(-) create mode 100644 tgui/packages/tgui/interfaces/SimpleBot.tsx diff --git a/code/modules/mob/living/simple_animal/bot/bot.dm b/code/modules/mob/living/simple_animal/bot/bot.dm index bc8c3fed87..ca9ca75e6c 100644 --- a/code/modules/mob/living/simple_animal/bot/bot.dm +++ b/code/modules/mob/living/simple_animal/bot/bot.dm @@ -292,18 +292,21 @@ /mob/living/simple_animal/bot/on_attack_hand(mob/living/carbon/human/H) if(H.a_intent == INTENT_HELP) - interact(H) + ui_interact(H) else return ..() /mob/living/simple_animal/bot/attack_ai(mob/user) if(!topic_denied(user)) - interact(user) + ui_interact(user) else to_chat(user, "[src]'s interface is not responding!") -/mob/living/simple_animal/bot/interact(mob/user) - show_controls(user) +/mob/living/simple_animal/bot/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "SimpleBot", name) + ui.open() /mob/living/simple_animal/bot/attackby(obj/item/W, mob/user, params) if(W.tool_behaviour == TOOL_SCREWDRIVER) @@ -795,56 +798,48 @@ Pass a positive integer as an argument to override a bot's default speed. else // no path, so calculate new one calc_summon_path() -/mob/living/simple_animal/bot/Bump(M as mob|obj) //Leave no door unopened! +// Variables sent to TGUI +/mob/living/simple_animal/bot/ui_data(mob/user) + var/list/data = list() + data["can_hack"] = (issilicon(user) || IsAdminGhost(user)) + data["custom_controls"] = list() + data["emagged"] = emagged + data["locked"] = locked + data["pai"] = list() + data["settings"] = list() + if(!locked || issilicon(user) || IsAdminGhost(user)) + data["pai"]["allow_pai"] = allow_pai + data["pai"]["card_inserted"] = paicard + data["settings"]["airplane_mode"] = remote_disabled + data["settings"]["maintenance_lock"] = !open + data["settings"]["power"] = on + data["settings"]["patrol_station"] = auto_patrol + return data + +// Actions received from TGUI +/mob/living/simple_animal/bot/ui_act(action, params) . = ..() - if((istype(M, /obj/machinery/door/airlock) || istype(M, /obj/machinery/door/window)) && (!isnull(access_card))) - var/obj/machinery/door/D = M - if(D.check_access(access_card)) - D.open() - frustration = 0 - -/mob/living/simple_animal/bot/proc/show_controls(mob/M) - users |= M - var/dat = "" - dat = get_controls(M) - var/datum/browser/popup = new(M,window_id,window_name,350,600) - popup.set_content(dat) - popup.open(use_onclose = 0) - onclose(M,window_id,ref=src) - return - -/mob/living/simple_animal/bot/proc/update_controls() - for(var/mob/M in users) - show_controls(M) - -/mob/living/simple_animal/bot/proc/get_controls(mob/M) - return "PROTOBOT - NOT FOR USE" - -/mob/living/simple_animal/bot/Topic(href, href_list) - //No ..() to prevent strip panel showing up - Todo: make that saner - if(href_list["close"])// HUE HUE - if(usr in users) - users.Remove(usr) - return TRUE - - if(topic_denied(usr)) - to_chat(usr, "[src]'s interface is not responding!") - return TRUE - add_fingerprint(usr) - - if((href_list["power"]) && (bot_core.allowed(usr) || !locked)) - if(on) - turn_off() - else - turn_on() - - switch(href_list["operation"]) + if(.) + return + if(!hasSiliconAccessInArea(usr) && !IsAdminGhost(usr) && !(bot_core.allowed(usr) || !locked)) + to_chat(usr, span_warning("Access denied.")) + return + if(action == "lock") + locked = !locked + if(locked && !(issilicon(usr) || IsAdminGhost(usr))) + return + switch(action) + if("power") + on = !on + update_appearance() + if("maintenance") + open = !open if("patrol") if(!hasSiliconAccessInArea(usr) && !IsAdminGhost(usr) && !(bot_core.allowed(usr) || !locked)) return TRUE auto_patrol = !auto_patrol bot_reset() - if("remote") + if("airplane") remote_disabled = !remote_disabled if("hack") if(!hasSiliconAccessInArea(usr) && !IsAdminGhost(usr)) @@ -865,11 +860,11 @@ Pass a positive integer as an argument to override a bot's default speed. hacked = FALSE to_chat(usr, "[text_dehack]") bot_reset() - if("ejectpai") + if("eject_pai") if(paicard && (!locked || hasSiliconAccessInArea(usr) || IsAdminGhost(usr))) to_chat(usr, "You eject [paicard] from [bot_name]") ejectpai(usr) - update_controls() + return /mob/living/simple_animal/bot/update_icon_state() icon_state = "[initial(icon_state)][on]" @@ -897,33 +892,6 @@ Pass a positive integer as an argument to override a bot's default speed. return TRUE return FALSE -/mob/living/simple_animal/bot/proc/hack(mob/user) - var/hack - if(hasSiliconAccessInArea(user) || IsAdminGhost(user)) //Allows silicons or admins to toggle the emag status of a bot. - hack += "[emagged == 2 ? "Software compromised! Unit may exhibit dangerous or erratic behavior." : "Unit operating normally. Release safety lock?"]
" - hack += "Harm Prevention Safety System: [emagged ? "DANGER" : "Engaged"]
" - else if(!locked) //Humans with access can use this option to hide a bot from the AI's remote control panel and PDA control. - hack += "Remote network control radio: [remote_disabled ? "Disconnected" : "Connected"]
" - return hack - -/mob/living/simple_animal/bot/proc/showpai(mob/user) - var/eject = "" - if((!locked || hasSiliconAccessInArea(usr) || IsAdminGhost(usr))) - if(paicard || allow_pai) - eject += "Personality card status: " - if(paicard) - if(client) - eject += "Active" - else - eject += "Inactive" - else if(!allow_pai || key) - eject += "Unavailable" - else - eject += "Not inserted" - eject += "
" - eject += "
" - return eject - /mob/living/simple_animal/bot/proc/insertpai(mob/user, obj/item/paicard/card) if(paicard) to_chat(user, "A [paicard] is already inserted!") diff --git a/code/modules/mob/living/simple_animal/bot/cleanbot.dm b/code/modules/mob/living/simple_animal/bot/cleanbot.dm index 5b812086c8..c683267a58 100644 --- a/code/modules/mob/living/simple_animal/bot/cleanbot.dm +++ b/code/modules/mob/living/simple_animal/bot/cleanbot.dm @@ -443,37 +443,33 @@ /obj/machinery/bot_core/cleanbot req_one_access = list(ACCESS_JANITOR, ACCESS_ROBOTICS) -/mob/living/simple_animal/bot/cleanbot/get_controls(mob/user) - var/dat - dat += hack(user) - dat += showpai(user) - dat += text({" -Status: [on ? "On" : "Off"]
-Behaviour controls are [locked ? "locked" : "unlocked"]
-Maintenance panel panel is [open ? "opened" : "closed"]"}) - if(!locked || issilicon(user)|| IsAdminGhost(user)) - dat += "
Clean Blood: [blood ? "Yes" : "No"]" - dat += "
Clean Trash: [trash ? "Yes" : "No"]" - dat += "
Clean Graffiti: [drawn ? "Yes" : "No"]" - dat += "
Exterminate Pests: [pests ? "Yes" : "No"]" - dat += "

Patrol Station: [auto_patrol ? "Yes" : "No"]" - return dat +// Variables sent to TGUI +/mob/living/simple_animal/bot/cleanbot/ui_data(mob/user) + var/list/data = ..() -/mob/living/simple_animal/bot/cleanbot/Topic(href, href_list) - if(..()) - return 1 - if(href_list["operation"]) - switch(href_list["operation"]) - if("blood") - blood = !blood - if("pests") - pests = !pests - if("trash") - trash = !trash - if("drawn") - drawn = !drawn - get_targets() - update_controls() + if(!locked || issilicon(user)|| IsAdminGhost(user)) + data["custom_controls"]["clean_blood"] = blood + data["custom_controls"]["clean_trash"] = trash + data["custom_controls"]["clean_graffiti"] = drawn + data["custom_controls"]["pest_control"] = pests + return data + +// Actions received from TGUI +/mob/living/simple_animal/bot/cleanbot/ui_act(action, params) + . = ..() + if(. || !hasSiliconAccessInArea(usr) && !IsAdminGhost(usr) && !(bot_core.allowed(usr) || !locked)) + return TRUE + switch(action) + if("clean_blood") + blood = !blood + if("pest_control") + pests = !pests + if("clean_trash") + trash = !trash + if("clean_graffiti") + drawn = !drawn + get_targets() + return /obj/machinery/bot_core/cleanbot/medbay req_one_access = list(ACCESS_JANITOR, ACCESS_ROBOTICS, ACCESS_MEDICAL) diff --git a/code/modules/mob/living/simple_animal/bot/ed209bot.dm b/code/modules/mob/living/simple_animal/bot/ed209bot.dm index 604a72b43e..c3ae3898dd 100644 --- a/code/modules/mob/living/simple_animal/bot/ed209bot.dm +++ b/code/modules/mob/living/simple_animal/bot/ed209bot.dm @@ -96,64 +96,45 @@ text_dehack = "You restore [name]'s combat inhibitor." text_dehack_fail = "[name] ignores your attempts to restrict him!" -/mob/living/simple_animal/bot/ed209/get_controls(mob/user) - var/dat - dat += hack(user) - dat += showpai(user) - dat += text({" -Security Unit v2.6 controls

-Status: []
-Behaviour controls are [locked ? "locked" : "unlocked"]
-Maintenance panel panel is [open ? "opened" : "closed"]
"}, - -"[on ? "On" : "Off"]" ) - +// Variables sent to TGUI +/mob/living/simple_animal/bot/ed209/ui_data(mob/user) + var/list/data = ..() if(!locked || hasSiliconAccessInArea(user)|| IsAdminGhost(user)) if(!lasercolor) - dat += text({"
-Arrest Unidentifiable Persons: []
-Arrest for Unauthorized Weapons: []
-Arrest for Warrant: []
-
-Operating Mode: []
-Report Arrests[]
-Auto Patrol[]"}, + data["custom_controls"]["check_id"] = idcheck + data["custom_controls"]["check_weapons"] = weaponscheck + data["custom_controls"]["check_warrants"] = check_records + data["custom_controls"]["handcuff_targets"] = !arrest_type + data["custom_controls"]["arrest_alert"] = declare_arrests + return data -"[idcheck ? "Yes" : "No"]", -"[weaponscheck ? "Yes" : "No"]", -"[check_records ? "Yes" : "No"]", -"[arrest_type ? "Detain" : "Arrest"]", -"[declare_arrests ? "Yes" : "No"]", -"[auto_patrol ? "On" : "Off"]" ) - - return dat - -/mob/living/simple_animal/bot/ed209/Topic(href, href_list) +// Actions received from TGUI +/mob/living/simple_animal/bot/ed209/ui_act(action, params) if(lasercolor && ishuman(usr)) var/mob/living/carbon/human/H = usr - if((lasercolor == "b") && (istype(H.wear_suit, /obj/item/clothing/suit/redtag)))//Opposing team cannot operate it - return - else if((lasercolor == "r") && (istype(H.wear_suit, /obj/item/clothing/suit/bluetag))) - return - if(..()) - return 1 + switch(lasercolor) //Opposing team cannot operate it + if("b") + if(istype(H.wear_suit, /obj/item/clothing/suit/redtag)) + return TRUE + if("r") + if(istype(H.wear_suit, /obj/item/clothing/suit/bluetag)) + return TRUE + . = ..() + if(. || !hasSiliconAccessInArea(usr) && !IsAdminGhost(usr) && !(bot_core.allowed(usr) || !locked)) + return TRUE - switch(href_list["operation"]) - if("idcheck") + switch(action) + if("check_id") idcheck = !idcheck - update_controls() - if("weaponscheck") + if("check_weapons") weaponscheck = !weaponscheck - update_controls() - if("ignorerec") + if("check_warrants") check_records = !check_records - update_controls() - if("switchmode") + if("handcuff_targets") arrest_type = !arrest_type - update_controls() - if("declarearrests") + if("arrest_alert") declare_arrests = !declare_arrests - update_controls() + return /mob/living/simple_animal/bot/ed209/proc/judgement_criteria() var/final = FALSE diff --git a/code/modules/mob/living/simple_animal/bot/firebot.dm b/code/modules/mob/living/simple_animal/bot/firebot.dm index d0e969dc4e..66d1955502 100644 --- a/code/modules/mob/living/simple_animal/bot/firebot.dm +++ b/code/modules/mob/living/simple_animal/bot/firebot.dm @@ -102,23 +102,6 @@ text_dehack = "You detect errors in [name] and reset his programming." text_dehack_fail = "[name] is not responding to reset commands!" -/mob/living/simple_animal/bot/firebot/get_controls(mob/user) - var/dat - dat += hack(user) - dat += showpai(user) - dat += "Mobile Fire Extinguisher v1.0

" - dat += "Status: [on ? "On" : "Off"]
" - dat += "Maintenance panel panel is [open ? "opened" : "closed"]
" - - dat += "Behaviour controls are [locked ? "locked" : "unlocked"]
" - if(!locked || hasSiliconAccessInArea(user) || IsAdminGhost(user)) - dat += "Extinguish Fires: [extinguish_fires ? "Yes" : "No"]
" - dat += "Extinguish People: [extinguish_people ? "Yes" : "No"]
" - dat += "Patrol Station: [auto_patrol ? "Yes" : "No"]
" - dat += "Stationary Mode: [stationary_mode ? "Yes" : "No"]
" - - return dat - /mob/living/simple_animal/bot/firebot/emag_act(mob/user) . = ..() if(emagged == 1) @@ -138,20 +121,29 @@ internal_ext.max_water = INFINITY internal_ext.refill() -/mob/living/simple_animal/bot/firebot/Topic(href, href_list) - if(..()) - return TRUE +// Variables sent to TGUI +/mob/living/simple_animal/bot/firebot/ui_data(mob/user) + var/list/data = ..() + if(!locked || issilicon(user) || IsAdminGhost(user)) + data["custom_controls"]["extinguish_fires"] = extinguish_fires + data["custom_controls"]["extinguish_people"] = extinguish_people + data["custom_controls"]["stationary_mode"] = stationary_mode + return data - switch(href_list["operation"]) +// Actions received from TGUI +/mob/living/simple_animal/bot/firebot/ui_act(action, params) + . = ..() + if(. || !hasSiliconAccessInArea(usr) && !IsAdminGhost(usr) && !(bot_core.allowed(usr) || !locked)) + return TRUE + switch(action) if("extinguish_fires") extinguish_fires = !extinguish_fires if("extinguish_people") extinguish_people = !extinguish_people if("stationary_mode") stationary_mode = !stationary_mode - - update_controls() - update_icon() + update_appearance() + return /mob/living/simple_animal/bot/firebot/proc/is_burning(atom/target) if(ismob(target)) diff --git a/code/modules/mob/living/simple_animal/bot/floorbot.dm b/code/modules/mob/living/simple_animal/bot/floorbot.dm index a67642f8ca..5f0075aaa2 100644 --- a/code/modules/mob/living/simple_animal/bot/floorbot.dm +++ b/code/modules/mob/living/simple_animal/bot/floorbot.dm @@ -71,36 +71,6 @@ text_dehack = "You detect errors in [name] and reset his programming." text_dehack_fail = "[name] is not responding to reset commands!" -/mob/living/simple_animal/bot/floorbot/get_controls(mob/user) - var/dat - dat += hack(user) - dat += showpai(user) - dat += "Floor Repairer Controls v1.1

" - dat += "Status: [on ? "On" : "Off"]
" - dat += "Maintenance panel panel is [open ? "opened" : "closed"]
" - dat += "Special tiles: " - if(specialtiles) - dat += "Loaded \[[specialtiles]/[maxtiles]\]
" - else - dat += "None Loaded
" - - dat += "Behaviour controls are [locked ? "locked" : "unlocked"]
" - if(!locked || hasSiliconAccessInArea(user) || IsAdminGhost(user)) - dat += "Add tiles to new hull plating: [autotile ? "Yes" : "No"]
" - dat += "Place floor tiles: [placetiles ? "Yes" : "No"]
" - dat += "Replace existing floor tiles with custom tiles: [replacetiles ? "Yes" : "No"]
" - dat += "Repair damaged tiles and platings: [fixfloors ? "Yes" : "No"]
" - dat += "Traction Magnets: [anchored ? "Engaged" : "Disengaged"]
" - dat += "Patrol Station: [auto_patrol ? "Yes" : "No"]
" - var/bmode - if(targetdirection) - bmode = dir2text(targetdirection) - else - bmode = "disabled" - dat += "Line Mode : [bmode]
" - - return dat - /mob/living/simple_animal/bot/floorbot/attackby(obj/item/W , mob/user, params) if(istype(W, /obj/item/stack/tile/plasteel)) to_chat(user, "The floorbot can produce normal tiles itself.") @@ -161,26 +131,44 @@ if(user) to_chat(user, "[src] buzzes and beeps.") -/mob/living/simple_animal/bot/floorbot/Topic(href, href_list) - if(..()) - return 1 +// Variables sent to TGUI +/mob/living/simple_animal/bot/floorbot/ui_data(mob/user) + var/list/data = ..() + if(!locked || issilicon(user) || IsAdminGhost(user)) + data["custom_controls"]["tile_hull"] = autotile + data["custom_controls"]["place_tiles"] = placetiles + data["custom_controls"]["place_custom"] = replacetiles + data["custom_controls"]["repair_damage"] = fixfloors + data["custom_controls"]["traction_magnets"] = anchored + data["custom_controls"]["tile_stack"] = 0 + data["custom_controls"]["line_mode"] = FALSE + if(specialtiles) + data["custom_controls"]["tile_stack"] = specialtiles + if(targetdirection) + data["custom_controls"]["line_mode"] = dir2text(targetdirection) + return data - switch(href_list["operation"]) - if("replace") +// Actions received from TGUI +/mob/living/simple_animal/bot/floorbot/ui_act(action, params) + . = ..() + if(. || !hasSiliconAccessInArea(usr) && !IsAdminGhost(usr) && !(bot_core.allowed(usr) || !locked)) + return TRUE + switch(action) + if("place_custom") replacetiles = !replacetiles - if("place") + if("place_tiles") placetiles = !placetiles - if("fix") + if("repair_damage") fixfloors = !fixfloors - if("autotile") + if("tile_hull") autotile = !autotile - if("anchor") + if("traction_magnets") anchored = !anchored - if("eject") + if("eject_tiles") if(specialtiles && tiletype != null) empty_tiles() - if("linemode") + if("line_mode") var/setdir = input("Select construction direction:") as null|anything in list("north","east","south","west","disable") switch(setdir) if("north") @@ -193,7 +181,7 @@ targetdirection = 8 if("disable") targetdirection = null - update_controls() + return /mob/living/simple_animal/bot/floorbot/proc/empty_tiles() new tiletype(drop_location(), specialtiles) diff --git a/code/modules/mob/living/simple_animal/bot/honkbot.dm b/code/modules/mob/living/simple_animal/bot/honkbot.dm index 9625d2b084..eb415b9bb5 100644 --- a/code/modules/mob/living/simple_animal/bot/honkbot.dm +++ b/code/modules/mob/living/simple_animal/bot/honkbot.dm @@ -78,24 +78,6 @@ text_dehack = "You reboot [name] and restore the sound control system." text_dehack_fail = "[name] refuses to accept your authority!" -/mob/living/simple_animal/bot/honkbot/get_controls(mob/user) - var/dat - dat += hack(user) - dat += showpai(user) - dat += text({" -Honkomatic Bike Horn Unit v1.0.7 controls

-Status: []
-Behaviour controls are [locked ? "locked" : "unlocked"]
-Maintenance panel panel is [open ? "opened" : "closed"]"}, - -"[on ? "On" : "Off"]" ) - - if(!locked || hasSiliconAccessInArea(user) || IsAdminGhost(user)) - dat += text({"
Auto Patrol: []"}, - -"[auto_patrol ? "On" : "Off"]" ) - return dat - /mob/living/simple_animal/bot/honkbot/proc/judgement_criteria() var/final = NONE if(check_records) diff --git a/code/modules/mob/living/simple_animal/bot/medbot.dm b/code/modules/mob/living/simple_animal/bot/medbot.dm index b343328e7f..e00adfd8e8 100644 --- a/code/modules/mob/living/simple_animal/bot/medbot.dm +++ b/code/modules/mob/living/simple_animal/bot/medbot.dm @@ -155,87 +155,63 @@ /mob/living/simple_animal/bot/medbot/attack_paw(mob/user) return attack_hand(user) -/mob/living/simple_animal/bot/medbot/get_controls(mob/user) - var/dat - dat += hack(user) - dat += showpai(user) - dat += "Medical Unit Controls v1.1

" - dat += "Status: [on ? "On" : "Off"]
" - dat += "Maintenance panel panel is [open ? "opened" : "closed"]
" - dat += "Beaker: " +// Variables sent to TGUI +/mob/living/simple_animal/bot/medbot/ui_data(mob/user) + var/list/data = ..() if(reagent_glass) - dat += "Loaded \[[reagent_glass.reagents.total_volume]/[reagent_glass.reagents.maximum_volume]\]" - else - dat += "None Loaded" - dat += "
Behaviour controls are [locked ? "locked" : "unlocked"]
" + data["custom_controls"]["beaker"] = reagent_glass + data["custom_contrlos"]["reagents"] = "[reagent_glass.reagents.total_volume]/[reagent_glass.reagents.maximum_volume]" if(!locked || hasSiliconAccessInArea(user) || IsAdminGhost(user)) - dat += "Healing Threshold: " - dat += "-- " - dat += "- " - dat += "[heal_threshold] " - dat += "+ " - dat += "++" - dat += "
" + data["custom_controls"]["injection_amount"] = injection_amount + data["custom_controls"]["use_beaker"] = use_beaker + data["custom_controls"]["treat_virus"] = treat_virus + data["custom_controls"]["heal_threshold"] = heal_threshold + data["custom_controls"]["speaker"] = !shut_up + data["custom_controls"]["crit_alerts"] = declare_crit + data["custom_controls"]["stationary_mode"] = stationary_mode + return data - dat += "Injection Level: " - dat += "- " - dat += "[injection_amount] " - dat += "+ " - dat += "
" +// Actions received from TGUI +/mob/living/simple_animal/bot/medbot/ui_act(action, params) + . = ..() + if(. || !hasSiliconAccessInArea(usr) && !IsAdminGhost(usr) && !(bot_core.allowed(usr) || !locked)) + return TRUE + switch(action) + if("heal_threshold") + var/adjust_num = round(text2num(params["threshold"])) + heal_threshold = adjust_num + if(heal_threshold < 5) + heal_threshold = 5 + if(heal_threshold > 75) + heal_threshold = 75 - dat += "Reagent Source: " - dat += "[use_beaker ? "Loaded Beaker (When available)" : "Internal Synthesizer"]
" + if("injection_amount") + var/adjust_num = round(text2num(params["amount"])) + injection_amount = adjust_num + if(injection_amount < 1) + injection_amount = 1 + if(injection_amount > 15) + injection_amount = 15 - dat += "Treat Viral Infections: [treat_virus ? "Yes" : "No"]
" - dat += "The speaker switch is [shut_up ? "off" : "on"]. Toggle
" - dat += "Critical Patient Alerts: [declare_crit ? "Yes" : "No"]
" - dat += "Patrol Station: [auto_patrol ? "Yes" : "No"]
" - dat += "Stationary Mode: [stationary_mode ? "Yes" : "No"]
" + if("use_beaker") + use_beaker = !use_beaker - return dat + if("eject") + if(!isnull(reagent_glass)) + reagent_glass.forceMove(drop_location()) + reagent_glass = null -/mob/living/simple_animal/bot/medbot/Topic(href, href_list) - if(..()) - return 1 + if("speaker") + shut_up = !shut_up + if("crit_alerts") + declare_crit = !declare_crit + if("stationary_mode") + stationary_mode = !stationary_mode + path = list() + update_appearance() - if(href_list["adj_threshold"]) - var/adjust_num = text2num(href_list["adj_threshold"]) - heal_threshold += adjust_num - if(heal_threshold < 5) - heal_threshold = 5 - if(heal_threshold > 75) - heal_threshold = 75 - - else if(href_list["adj_inject"]) - var/adjust_num = text2num(href_list["adj_inject"]) - injection_amount += adjust_num - if(injection_amount < 5) - injection_amount = 5 - if(injection_amount > 15) - injection_amount = 15 - - else if(href_list["use_beaker"]) - use_beaker = !use_beaker - - else if(href_list["eject"] && (!isnull(reagent_glass))) - reagent_glass.forceMove(drop_location()) - reagent_glass = null - - else if(href_list["togglevoice"]) - shut_up = !shut_up - - else if(href_list["critalerts"]) - declare_crit = !declare_crit - - else if(href_list["stationary"]) - stationary_mode = !stationary_mode - path = list() - update_icon() - - else if(href_list["virus"]) - treat_virus = !treat_virus - - update_controls() + if("virus") + treat_virus = !treat_virus return /mob/living/simple_animal/bot/medbot/attackby(obj/item/W as obj, mob/user as mob, params) @@ -251,7 +227,6 @@ reagent_glass = W to_chat(user, "You insert [W].") - show_controls(user) else if(istype(W, /obj/item/reagent_containers/syringe/piercing)) if(bot_core.allowed(user) && open && !(upgrades & UPGRADE_MEDICAL_PIERERCING)) diff --git a/code/modules/mob/living/simple_animal/bot/mulebot.dm b/code/modules/mob/living/simple_animal/bot/mulebot.dm index 077e31062a..dcb5e5f237 100644 --- a/code/modules/mob/living/simple_animal/bot/mulebot.dm +++ b/code/modules/mob/living/simple_animal/bot/mulebot.dm @@ -276,56 +276,6 @@ if("ejectpai") ejectpairemote(user) -// TODO: remove this; PDAs currently depend on it -/mob/living/simple_animal/bot/mulebot/get_controls(mob/user) - var/ai = hasSiliconAccessInArea(user) - var/dat - dat += "

Multiple Utility Load Effector Mk. V

" - dat += "ID: [id]
" - dat += "Power: [on ? "On" : "Off"]
" - dat += "

Status

" - dat += "
" - switch(mode) - if(BOT_IDLE) - dat += "Ready" - if(BOT_DELIVER) - dat += "[mode_name[BOT_DELIVER]]" - if(BOT_GO_HOME) - dat += "[mode_name[BOT_GO_HOME]]" - if(BOT_BLOCKED) - dat += "[mode_name[BOT_BLOCKED]]" - if(BOT_NAV,BOT_WAIT_FOR_NAV) - dat += "[mode_name[BOT_NAV]]" - if(BOT_NO_ROUTE) - dat += "[mode_name[BOT_NO_ROUTE]]" - dat += "
" - - dat += "Current Load: [load ? load.name : "none"]
" - dat += "Destination: [!destination ? "none" : destination]
" - dat += "Power level: [cell ? cell.percent() : 0]%" - - if(locked && !ai && !IsAdminGhost(user)) - dat += " 
Controls are locked
Unlock Controls" - else - dat += " 
Controls are unlocked
Lock Controls

" - - dat += "Toggle Power
" - dat += "Stop
" - dat += "Proceed
" - dat += "Return to Home
" - dat += "Set Destination
" - dat += "Set Bot ID
" - dat += "Set Home
" - dat += "Toggle Auto Return Home ([auto_return ? "On":"Off"])
" - dat += "Toggle Auto Pickup Crate ([auto_pickup ? "On":"Off"])
" - dat += "Toggle Delivery Reporting ([report_delivery ? "On" : "Off"])
" - if(load) - dat += "Unload Now
" - dat += "
The maintenance hatch is closed.
" - - return dat - - // returns true if the bot has power /mob/living/simple_animal/bot/mulebot/proc/has_power() return !open && cell && cell.charge > 0 && (!wires.is_cut(WIRE_POWER1) && !wires.is_cut(WIRE_POWER2)) diff --git a/code/modules/mob/living/simple_animal/bot/secbot.dm b/code/modules/mob/living/simple_animal/bot/secbot.dm index 8bb30a11a6..c3ab805d62 100644 --- a/code/modules/mob/living/simple_animal/bot/secbot.dm +++ b/code/modules/mob/living/simple_animal/bot/secbot.dm @@ -209,57 +209,34 @@ text_dehack = "You reboot [name] and restore the target identification." text_dehack_fail = "[name] refuses to accept your authority!" -/mob/living/simple_animal/bot/secbot/get_controls(mob/user) - var/dat - dat += hack(user) - dat += showpai(user) - dat += text({" -Securitron v1.6 controls

-Status: []
-Behaviour controls are [locked ? "locked" : "unlocked"]
-Maintenance panel panel is [open ? "opened" : "closed"]"}, - -"[on ? "On" : "Off"]" ) - +// Variables sent to TGUI +/mob/living/simple_animal/bot/secbot/ui_data(mob/user) + var/list/data = ..() if(!locked || hasSiliconAccessInArea(user) || IsAdminGhost(user)) - dat += text({"
-Arrest Unidentifiable Persons: []
-Arrest for Unauthorized Weapons: []
-Arrest for Warrant: []
-Operating Mode: []
-Report Arrests[]
-Auto Patrol: []"}, + data["custom_controls"]["check_id"] = idcheck + data["custom_controls"]["check_weapons"] = weaponscheck + data["custom_controls"]["check_warrants"] = check_records + data["custom_controls"]["handcuff_targets"] = !arrest_type + data["custom_controls"]["arrest_alert"] = declare_arrests + return data -"[idcheck ? "Yes" : "No"]", -"[weaponscheck ? "Yes" : "No"]", -"[check_records ? "Yes" : "No"]", -"[arrest_type ? "Detain" : "Arrest"]", -"[declare_arrests ? "Yes" : "No"]", -"[auto_patrol ? "On" : "Off"]" ) - - return dat - -/mob/living/simple_animal/bot/secbot/Topic(href, href_list) - if(..()) - return 1 - if(!hasSiliconAccessInArea(usr) && !IsAdminGhost(usr) && !(bot_core.allowed(usr) || !locked)) +// Actions received from TGUI +/mob/living/simple_animal/bot/secbot/ui_act(action, params) + . = ..() + if(. || !hasSiliconAccessInArea(usr) && !IsAdminGhost(usr) && !(bot_core.allowed(usr) || !locked)) return TRUE - switch(href_list["operation"]) - if("idcheck") + switch(action) + if("check_id") idcheck = !idcheck - update_controls() - if("weaponscheck") + if("check_weapons") weaponscheck = !weaponscheck - update_controls() - if("ignorerec") + if("check_warrants") check_records = !check_records - update_controls() - if("switchmode") + if("handcuff_targets") arrest_type = !arrest_type - update_controls() - if("declarearrests") + if("arrest_alert") declare_arrests = !declare_arrests - update_controls() + return /mob/living/simple_animal/bot/secbot/proc/retaliate(mob/living/carbon/human/H) var/judgement_criteria = judgement_criteria() diff --git a/tgui/packages/tgui/interfaces/SimpleBot.tsx b/tgui/packages/tgui/interfaces/SimpleBot.tsx new file mode 100644 index 0000000000..b5cfce4be7 --- /dev/null +++ b/tgui/packages/tgui/interfaces/SimpleBot.tsx @@ -0,0 +1,351 @@ +import { multiline } from '../../common/string'; +import { useBackend } from '../backend'; +import { Button, Icon, LabeledControls, NoticeBox, Section, Slider, Stack, Tooltip } from '../components'; +import { Window } from '../layouts'; + +type SimpleBotContext = { + can_hack: number; + locked: number; + emagged: number; + pai: Pai; + settings: Settings; + custom_controls: Controls; +}; + +type Pai = { + allow_pai: number; + card_inserted: number; +}; + +type Settings = { + power: number; + airplane_mode: number; + maintenance_lock: number; + patrol_station: number; +}; + +type Controls = { + [Control: string]: [Value: number]; +}; + +export const SimpleBot = (_, context) => { + const { data } = useBackend(context); + const { can_hack, locked } = data; + const access = (!locked || can_hack); + + return ( + + + + +
}> + {!access + ? (Locked!) + : ()} +
+
+ {access && ( + +
+ +
+
+ )} +
+
+
+ ); +}; + +/** Creates a lock button at the top of the controls */ +const TabDisplay = (_, context) => { + const { act, data } = useBackend(context); + const { can_hack, locked, pai } = data; + const { allow_pai } = pai; + + return ( + <> + {!!can_hack && } + {!!allow_pai && } + + + ); +}; + +/** If user is a bad silicon, they can press this button to hack the bot */ +const HackButton = (_, context) => { + const { act, data } = useBackend(context); + const { can_hack, emagged } = data; + + return ( + + ); +}; + +/** Creates a button indicating PAI status and offers the eject action */ +const PaiButton = (_, context) => { + const { act, data } = useBackend(context); + const { card_inserted } = data.pai; + + if (!card_inserted) { + return ( + + ); + } else { + return ( + + ); + } +}; + +/** Displays the bot's standard settings: Power, patrol, etc. */ +const SettingsDisplay = (_, context) => { + const { act, data } = useBackend(context); + const { settings } = data; + const { airplane_mode, patrol_station, power, maintenance_lock } = settings; + + return ( + + + + act('power')} + /> + + + + + act('airplane')} + /> + + + + + act('patrol')} + /> + + + + + act('maintenance')} + /> + + + + ); +}; + +/** Iterates over custom controls. + * Calls the helper to identify which button to use. + */ +const ControlsDisplay = (_, context) => { + const { data } = useBackend(context); + const { custom_controls } = data; + + return ( + + {Object.entries(custom_controls).map((control) => { + return ( + + letter.toUpperCase())}> + + + ); + })} + + ); +}; + +/** Helper function which identifies which button to create. + * Might need some fine tuning if you are using more advanced controls. + */ +const ControlHelper = (props, context) => { + const { act } = useBackend(context); + const { control } = props; + if (control[0] === 'sync_tech') { + /** Control is for sync - this is medbot specific */ + return ; + } else if (control[0] === 'heal_threshold') { + /** Control is a threshold - this is medbot specific */ + return ; + } else if (control[0] === 'injection_amount') { + /** Control is for injection - this is medbot specific */ + return ; + } else if (control[0] === 'tile_stack') { + return ; + } else if (control[0] === 'line_mode') { + return ; + } else { + /** Control is a boolean of some type */ + return ( + act(control[0])} + /> + ); + } +}; + +/** Small button to sync medbots with research. */ +const MedbotSync = (_, context) => { + const { act } = useBackend(context); + + return ( + + act('sync_tech')} + /> + + ); +}; + +/** Slider button for medbot injection thresholds */ +const InjectionThreshold = (props, context) => { + const { act } = useBackend(context); + const { control } = props; + + return ( + + act(control[0], { amount: value })} + /> + + ); +}; + +/** Slider button for medbot healing thresholds */ +const MedbotThreshold = (props, context) => { + const { act } = useBackend(context); + const { control } = props; + + return ( + + act(control[0], { threshold: value })} + /> + + ); +}; + +/** Tile stacks for floorbots - shows number and eject button */ +const FloorbotTiles = (props, context) => { + const { act } = useBackend(context); + const { control } = props; + + return ( + + ); +}; + +/** Direction indicator for floorbot when line mode is chosen. */ +const FloorbotLine = (props, context) => { + const { act } = useBackend(context); + const { control } = props; + + return ( + + act('line_mode')} + size={!control[1] ? 2 : 1.5}> + {' '} + {control[1] ? control[1].toString().charAt(0).toUpperCase() : ''} + + + ); +};