Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ports TGUI bot menus #11378

Merged
merged 11 commits into from
Sep 22, 2024
70 changes: 29 additions & 41 deletions code/modules/mob/living/simple_animal/bot/atmosbot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -313,47 +313,35 @@
to_check_turfs |= adjacent_turf
return null

/mob/living/simple_animal/bot/atmosbot/get_controls(mob/user)
var/dat
dat += hack(user)
dat += showpai(user)
dat += "<tt><b>Atmospheric Stabilizer Controls v1.1</b></tt><br><br>"
dat += "Status: <a href='?src=[REF(src)];power=1'>[on ? "On" : "Off"]</a><br>"
dat += "Maintenance panel panel is [open ? "opened" : "closed"]<br>"
if(!locked || issilicon(user) || IsAdminGhost(user))
dat += "Breach Pressure: <a href='?src=[REF(src)];set_breach_pressure=1'>[breached_pressure]</a><br>"
dat += "Temperature Control: <a href='?src=[REF(src)];toggle_temp_control=1'>[temperature_control?"Enabled":"Disabled"]</a><br>"
dat += "Temperature Target: <a href='?src=[REF(src)];set_ideal_temperature=[ideal_temperature]'>[ideal_temperature]K</a><br>"
dat += "Gas Scrubbing Controls<br>"
for(var/gas_id in gasses)
var/gas_enabled = gasses[gas_id]
dat += "[GLOB.gas_data.names[gas_id]]: <a href='?src=[REF(src)];toggle_gas=[gas_id]'>[gas_enabled?"Scrubbing":"Not Scrubbing"]</a><br>"
dat += "Patrol Station: <A href='?src=[REF(src)];operation=patrol'>[auto_patrol ? "Yes" : "No"]</A><BR>"
return dat

/mob/living/simple_animal/bot/atmosbot/Topic(href, href_list)
if(..())
return TRUE

if(href_list["set_breach_pressure"])
var/new_breach_pressure = input(usr, "Pressure to scan for breaches at? (0 to 100)", "Breach Pressure") as num
if(!isnum(new_breach_pressure) || new_breach_pressure < 0 || new_breach_pressure > 100)
return
breached_pressure = new_breach_pressure
else if(href_list["toggle_temp_control"])
temperature_control = temperature_control ? FALSE : TRUE
else if(href_list["toggle_gas"])
var/gas_id = href_list["toggle_gas"]
for(var/G in gasses)
if("[G]" == gas_id)
gasses[G] = gasses[G] ? FALSE : TRUE
else if(href_list["set_ideal_temperature"])
var/new_temp = input(usr, "Set Target Temperature ([T0C]K to [T20C + 20]K)", "Target Temperature") as num
if(!isnum(new_temp) || new_temp < T0C || new_temp > T20C + 20)
return
ideal_temperature = new_temp

update_controls()
/mob/living/simple_animal/bot/atmosbot/ui_data(mob/user)
var/list/data = ..()
if (!locked || issilicon(user) || IsAdminGhost(user))
data["custom_controls"]["breach_pressure"] = breached_pressure
data["custom_controls"]["temperature_control"] = temperature_control
data["custom_controls"]["ideal_temperature"] = ideal_temperature
data["custom_controls"]["scrub_gasses"] = gasses
return data

/mob/living/simple_animal/bot/atmosbot/ui_act(action, params)
. = ..()
if(. || (locked && !usr.has_unlimited_silicon_privilege))
return
switch(action)
if("breach_pressure")
var/adjust_num = round(text2num(params["pressure"]))
adjust_num = clamp(adjust_num, 0, 100)
breached_pressure = adjust_num
if("temperature_control")
temperature_control = !temperature_control
if("ideal_temperature")
var/adjust_num = round(text2num(params["temperature"]))
adjust_num = clamp(adjust_num, T0C, T20C + 20)
ideal_temperature = adjust_num
if("scrub_gasses")
var/id = params["id"]
for(var/gas_id in gasses)
if (gas_id == id)
gasses[id] = !gasses[id]
update_icon()

/mob/living/simple_animal/bot/atmosbot/update_icon()
Expand Down
85 changes: 81 additions & 4 deletions code/modules/mob/living/simple_animal/bot/bot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,22 @@

/mob/living/simple_animal/bot/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, "<span class='warning'>[src]'s interface is not responding!</span>")

/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.set_autoupdate(TRUE)
ui.open()

/mob/living/simple_animal/bot/proc/togglelock(mob/living/user)
if(bot_core.allowed(user) && !open && !emagged)
Expand Down Expand Up @@ -899,6 +903,79 @@ Pass a positive integer as an argument to override a bot's default speed.
D.open()
frustration = 0

/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"]["booting"] = booting
data["settings"]["patrol_station"] = auto_patrol
return data

// Actions received from TGUI
/mob/living/simple_animal/bot/ui_act(action, params)
. = ..()
if(.)
return
if(!bot_core.allowed(usr) && !usr.has_unlimited_silicon_privilege)
aramix273 marked this conversation as resolved.
Show resolved Hide resolved
to_chat(usr, "<span class='warning'>Access denied.</span>")
return
if(action == "lock")
locked = !locked
if(locked && !(issilicon(usr) || IsAdminGhost(usr)))
return
switch(action)
if("power")
if(bot_core.allowed(usr) || !locked)
if (on)
turn_off()
else
boot_up_sequence()
if("maintenance")
open = !open
if("patrol")
if(!issilicon(usr) && !IsAdminGhost(usr) && !(bot_core.allowed(usr) || !locked))
return TRUE
auto_patrol = !auto_patrol
bot_reset()
if("airplane")
remote_disabled = !remote_disabled
if("hack")
if(!issilicon(usr) && !IsAdminGhost(usr))
return TRUE
if(emagged != 2)
emagged = 2
hacked = TRUE
locked = TRUE
to_chat(usr, "<span class='warning'>[text_hack]</span>")
message_admins("Safety lock of [ADMIN_LOOKUPFLW(src)] was disabled by [ADMIN_LOOKUPFLW(usr)] in [ADMIN_VERBOSEJMP(src)]")
log_game("Safety lock of [src] was disabled by [key_name(usr)] in [AREACOORD(src)]")
bot_reset()
else if(!hacked)
to_chat(usr, "<span class='boldannounce'>[text_dehack_fail]</span>")
else
emagged = FALSE
hacked = FALSE
to_chat(usr, "<span class='notice'>[text_dehack]</span>")
log_game("Safety lock of [src] was re-enabled by [key_name(usr)] in [AREACOORD(src)]")
bot_reset()
if("eject_pai")
if(locked && !(issilicon(usr) || IsAdminGhost(usr)))
return
if(paicard)
to_chat(usr, "<span class='notice'>You eject [paicard] from [bot_name]</span>")
ejectpai(usr)
//update_controls()

/mob/living/simple_animal/bot/proc/show_controls(mob/M)
users |= M
var/dat = ""
Expand Down
55 changes: 23 additions & 32 deletions code/modules/mob/living/simple_animal/bot/cleanbot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -434,39 +434,30 @@
/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)
// missing bot program name here
dat += "<BR>Status: <A href='?src=[REF(src)];power=1'>[on ? "On" : "Off"]</A>"
dat += "<BR>Behaviour controls are [locked ? "locked" : "unlocked"]"
dat += "<BR>Maintenance panel panel is [open ? "opened" : "closed"]"

/mob/living/simple_animal/bot/cleanbot/ui_data(mob/user)
var/list/data = ..()
if(!locked || issilicon(user)|| IsAdminGhost(user))
dat += "<BR>Clean Blood: <A href='?src=[REF(src)];operation=blood'>[blood ? "Yes" : "No"]</A>"
dat += "<BR>Clean Trash: <A href='?src=[REF(src)];operation=trash'>[trash ? "Yes" : "No"]</A>"
dat += "<BR>Clean Graffiti: <A href='?src=[REF(src)];operation=drawn'>[drawn ? "Yes" : "No"]</A>"
dat += "<BR>Exterminate Pests: <A href='?src=[REF(src)];operation=pests'>[pests ? "Yes" : "No"]</A>"
dat += "<BR><BR>Patrol Station: <A href='?src=[REF(src)];operation=patrol'>[auto_patrol ? "Yes" : "No"]</A>"
return dat

/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()
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

/mob/living/simple_animal/bot/cleanbot/ui_act(action, params)
if (..())
return
if(!(bot_core.allowed(usr) || usr.has_unlimited_silicon_privilege) || locked)
return
switch(action)
if("clean_blood")
blood = !blood
if("clean_trash")
trash = !trash
if("clean_graffiti")
drawn = !drawn
if("pest_control")
pests = !pests
get_targets()

/obj/machinery/bot_core/cleanbot/medbay
req_one_access = list(ACCESS_JANITOR, ACCESS_ROBOTICS, ACCESS_MEDICAL)
50 changes: 18 additions & 32 deletions code/modules/mob/living/simple_animal/bot/ed209bot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -98,52 +98,38 @@
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 += "<TT><B>Security Unit v2.6 controls</B></TT><BR>"
dat += "<BR>Status: <A href='?src=[REF(src)];power=1'>[on ? "On" : "Off"]</A>"
dat += "<BR>Behaviour controls are [locked ? "locked" : "unlocked"]"
dat += "<BR>Maintenance panel panel is [open ? "opened" : "closed"]"

if(!locked || issilicon(user)|| IsAdminGhost(user))
/mob/living/simple_animal/bot/ed209/ui_data(mob/user)
var/list/data = ..()
if (!locked || issilicon(user) || IsAdminGhost(user))
if(!lasercolor)
dat += "<BR>"
dat += "<BR>Arrest Unidentifiable Persons: <A href='?src=[REF(src)];operation=idcheck'>[idcheck ? "Yes" : "No"]</A>"
dat += "<BR>Arrest for Unauthorized Weapons: <A href='?src=[REF(src)];operation=weaponscheck'>[weaponscheck ? "Yes" : "No"]</A>"
dat += "<BR>Arrest for Warrant: <A href='?src=[REF(src)];operation=ignorerec'>[check_records ? "Yes" : "No"]</A>"
dat += "<BR>Operating Mode: <A href='?src=[REF(src)];operation=switchmode'>[arrest_type ? "Detain" : "Arrest"]</A>"
dat += "<BR>Report Arrests <A href='?src=[REF(src)];operation=declarearrests'>[declare_arrests ? "Yes" : "No"]</A>"
dat += "<BR>Auto Patrol <A href='?src=[REF(src)];operation=patrol'>[auto_patrol ? "On" : "Off"]</A>"
return dat

/mob/living/simple_animal/bot/ed209/Topic(href, href_list)
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

/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
return

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()

/mob/living/simple_animal/bot/ed209/proc/judgment_criteria()
var/final = FALSE
Expand Down
32 changes: 11 additions & 21 deletions code/modules/mob/living/simple_animal/bot/firebot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,13 @@
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 += "<TT><B>Mobile Fire Extinguisher v1.0</B></TT><BR><BR>"
dat += "Status: <A href='?src=[REF(src)];power=1'>[on ? "On" : "Off"]</A><BR>"
dat += "Maintenance panel panel is [open ? "opened" : "closed"]<BR>"

dat += "Behaviour controls are [locked ? "locked" : "unlocked"]<BR>"
/mob/living/simple_animal/bot/firebot/ui_data(mob/user)
var/list/data = ..()
if(!locked || issilicon(user) || IsAdminGhost(user))
dat += "Extinguish Fires: <A href='?src=[REF(src)];operation=extinguish_fires'>[extinguish_fires ? "Yes" : "No"]</A><BR>"
dat += "Extinguish People: <A href='?src=[REF(src)];operation=extinguish_people'>[extinguish_people ? "Yes" : "No"]</A><BR>"
dat += "Patrol Station: <A href='?src=[REF(src)];operation=patrol'>[auto_patrol ? "Yes" : "No"]</A><BR>"
dat += "Stationary Mode: <a href='?src=[REF(src)];operation=stationary_mode'>[stationary_mode ? "Yes" : "No"]</a><br>"

return dat
data["custom_controls"]["extinguish_fires"] = extinguish_fires
data["custom_controls"]["extinguish_people"] = extinguish_people
data["custom_controls"]["stationary_mode"] = stationary_mode
return data

/mob/living/simple_animal/bot/firebot/on_emag(atom/target, mob/user)
..()
Expand All @@ -142,19 +133,18 @@
internal_ext.max_water = INFINITY
internal_ext.refill()

/mob/living/simple_animal/bot/firebot/Topic(href, href_list)
/mob/living/simple_animal/bot/firebot/ui_act(action, params)
if(..())
return TRUE

switch(href_list["operation"])
return
if(!(bot_core.allowed(usr) || usr.has_unlimited_silicon_privilege) || locked)
return
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()

/mob/living/simple_animal/bot/firebot/proc/is_burning(atom/target)
Expand Down
Loading
Loading