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

handheld t-rays have cable/pipe/blueprint toggles and unique ability icons #15740

Merged
merged 10 commits into from Sep 15, 2023
7 changes: 3 additions & 4 deletions code/WorkInProgress/AbilityItem.dm
Expand Up @@ -389,14 +389,13 @@
////////////////////////////////////////////////////////////

/obj/ability_button/tscanner_toggle
name = "Toggle T-Scanner"
name = "Toggle T-Ray Scanner"
icon_state = "lightoff" //TODO: make bespoke sprites for this I guess

execute_ability()
var/obj/item/device/t_scanner/J = the_item
J.AttackSelf(the_mob)
if(J.on) icon_state = "lighton"
else icon_state = "lightoff"
J.set_on(!J.on, the_mob) // only turns on/off
icon_state = J.on ? "lighton" : "lightoff"
..()

////////////////////////////////////////////////////////////
Expand Down
42 changes: 42 additions & 0 deletions code/modules/interface/multiContext/context_actions.dm
Expand Up @@ -1289,3 +1289,45 @@
return robospray in user
execute(var/obj/item/robospray/robospray, var/mob/user)
robospray.change_reagent(src.reagent_id, user)

/datum/contextAction/t_scanner
icon = 'icons/ui/context16x16.dmi'
close_clicked = TRUE
close_moved = FALSE
desc = ""

checkRequirements(var/obj/item/device/t_scanner/t_scanner, mob/user)
return t_scanner in user

active
name = "Turn on/off"
icon_state = "bulb"

execute(var/obj/item/device/t_scanner/t_scanner, mob/user)
t_scanner.set_on(!t_scanner.on)
var/obj/ability_button/tscanner_toggle/tscanner_button = locate(/obj/ability_button/tscanner_toggle) in t_scanner.ability_buttons
tscanner_button.icon_state = t_scanner.on ? "lighton" : "lightoff"

underfloor_cables
name = "Underfloor Power Cables"
desc = "Toggle showing power cables located under the floor."
icon_state = "cut"

execute(obj/item/device/t_scanner/t_scanner, mob/user)
t_scanner.set_underfloor_cables(!t_scanner.show_underfloor_cables, user)

underfloor_disposal_pipes
name = "Underfloor Disposal Pipes"
desc = "Toggle showing disposal pipes located under the floor."
icon_state = "weld"

execute(obj/item/device/t_scanner/t_scanner, mob/user)
t_scanner.set_underfloor_disposal_pipes(!t_scanner.show_underfloor_disposal_pipes, user)

blueprint_disposal_pipes
name = "Disposal Pipe Blueprints"
desc = "Toggle showing the original blueprints for disposal pipes."
icon_state = "cog"

execute(obj/item/device/t_scanner/t_scanner, mob/user)
t_scanner.set_blueprint_disposal_pipes(!t_scanner.show_blueprint_disposal_pipes, user)
44 changes: 38 additions & 6 deletions code/obj/item/device/scanners.dm
Expand Up @@ -16,9 +16,9 @@ TYPEINFO(/obj/item/device/t_scanner)

/obj/item/device/t_scanner
name = "T-ray scanner"
desc = "A terahertz-ray emitter and scanner used to detect underfloor objects such as cables and pipes."
desc = "A tuneable terahertz-ray emitter and scanner used to detect underfloor objects such as cables and pipes."
icon_state = "t-ray0"
var/on = 0
var/on = FALSE
flags = FPRINT | TABLEPASS
c_flags = ONBELT
w_class = W_CLASS_SMALL
Expand All @@ -29,6 +29,18 @@ TYPEINFO(/obj/item/device/t_scanner)
var/client/last_client = null
var/image/last_display = null
var/find_interesting = TRUE
var/list/setting_context_actions
contextLayout = new /datum/contextLayout/experimentalcircle
var/show_underfloor_cables = TRUE
var/show_underfloor_disposal_pipes = TRUE
var/show_blueprint_disposal_pipes = TRUE

New()
..()
setting_context_actions = list()
for(var/actionType in childrentypesof(/datum/contextAction/t_scanner)) //see context_actions.dm for those
var/datum/contextAction/t_scanner/action = new actionType(src)
setting_context_actions += action

proc/set_on(new_on, mob/user=null)
on = new_on
Expand All @@ -40,8 +52,23 @@ TYPEINFO(/obj/item/device/t_scanner)
else
processing_items |= src

proc/set_underfloor_cables(state, mob/user=null)
show_underfloor_cables = state
if(user)
boutput(user, "You switch [src] to [show_underfloor_cables ? "show" : "hide"] underfloor cables.")

proc/set_underfloor_disposal_pipes(state, mob/user=null)
show_underfloor_disposal_pipes = state
if(user)
boutput(user, "You switch [src] to [show_underfloor_disposal_pipes ? "show" : "hide"] underfloor disposal pipes.")

proc/set_blueprint_disposal_pipes(state, mob/user=null)
show_blueprint_disposal_pipes = state
if(user)
boutput(user, "You switch [src] to [show_blueprint_disposal_pipes ? "show" : "hide"] disposal pipe blueprints.")

attack_self(mob/user)
set_on(!on, user)
user.showContextActions(setting_context_actions, src, contextLayout)

afterattack(atom/A as mob|obj|turf|area, mob/user as mob)
if (istype(A, /turf))
Expand Down Expand Up @@ -100,7 +127,11 @@ TYPEINFO(/obj/item/device/t_scanner)
continue
else if(isobj(A))
var/obj/O = A
if(O.level == OVERFLOOR && !istype(O, /obj/disposalpipe)) // disposal pipes handled below
if (O.level == OVERFLOOR && !istype(O, /obj/disposalpipe))
continue // show unsecured pipes behind walls
if (!show_underfloor_cables && istype(O, /obj/cable))
continue
if (!show_underfloor_disposal_pipes && istype(O, /obj/disposalpipe))
continue
var/image/img = image(A.icon, icon_state=A.icon_state, dir=A.dir)
img.plane = PLANE_SCREEN_OVERLAYS
Expand All @@ -110,10 +141,10 @@ TYPEINFO(/obj/item/device/t_scanner)
img.appearance_flags = RESET_ALPHA | RESET_COLOR | PIXEL_SCALE
display.overlays += img

if (T.disposal_image)
if (show_blueprint_disposal_pipes && T.disposal_image)
display.overlays += T.disposal_image

if( length(display.overlays))
if(length(display.overlays))
display.plane = PLANE_SCREEN_OVERLAYS
display.pixel_x = (T.x - center.x) * 32
display.pixel_y = (T.y - center.y) * 32
Expand All @@ -134,6 +165,7 @@ TYPEINFO(/obj/item/device/t_scanner)

/obj/item/device/t_scanner/pda
name = "PDA T-ray scanner"
desc = "A terahertz-ray emitter and scanner used to detect underfloor objects such as cables and pipes."
find_interesting = FALSE

/*
Expand Down