Skip to content

Commit

Permalink
handheld t-rays have cable/pipe/blueprint toggles (#15740)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgmzeta committed Sep 15, 2023
1 parent c672693 commit ffad733
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 15 deletions.
20 changes: 14 additions & 6 deletions code/WorkInProgress/AbilityItem.dm
Expand Up @@ -65,7 +65,16 @@
//S.icon = IC
spraybits += S

if (the_mob) playsound(the_mob, 'sound/effects/spray.ogg', 75, TRUE, 0)
/* // What the heck? This ran 8 times. Also the spraybits loop does the same exact thing below. commenting this out to prevent fluid duplication
SPAWN(0)
S.reagents.reaction(theturf, TOUCH)
for(var/atom/A in theturf)
if (istype(A,/obj/fluid)) continue
S.reagents.reaction(A, TOUCH, 0, 0)
*/

if (the_mob)
playsound(the_mob, 'sound/effects/spray.ogg', 75, TRUE, 0)
//E.reagents.clear_reagents()

sleep(0.5 SECONDS)
Expand Down Expand Up @@ -389,14 +398,13 @@
////////////////////////////////////////////////////////////

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

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
src.icon_state = J.on ? "tray_on" : "tray_off"
..()

////////////////////////////////////////////////////////////
Expand Down
48 changes: 48 additions & 0 deletions code/modules/interface/multiContext/context_actions.dm
Expand Up @@ -1289,3 +1289,51 @@
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'
icon_state = "dismiss"
close_clicked = TRUE
close_moved = FALSE
var/base_icon_state = ""

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

active
name = "Active"
desc = "Toggle T-ray scanner"
icon_state = "tray_scanner_off"
base_icon_state = "tray_scanner_"

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 ? "tray_on" : "tray_off"

underfloor_cables
name = "Cables"
desc = "Current underfloor cables"
icon_state = "tray_cable_on"
base_icon_state = "tray_cable_"

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 = "Disposal Pipes"
desc = "Current underfloor disposal pipes"
icon_state = "tray_pipes_on"
base_icon_state = "tray_pipes_"

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 = "Pipe Blueprints"
desc = "Original pipe blueprints"
icon_state = "tray_blueprint_on"
base_icon_state = "tray_blueprint_"

execute(obj/item/device/t_scanner/t_scanner, mob/user)
t_scanner.set_blueprint_disposal_pipes(!t_scanner.show_blueprint_disposal_pipes, user)
4 changes: 2 additions & 2 deletions code/obj/item/device/pda2/modules.dm
Expand Up @@ -244,7 +244,7 @@ TYPEINFO(/obj/item/device/pda_module)
scanner = new(src)

return_menu_badge()
var/text = "<a href='byond://?src=\ref[src];toggle=1'>[src.scanner.on ? "Disable" : "Enable"] T-Scanner</a>"
var/text = "<a href='byond://?src=\ref[src];toggle=1'>[src.scanner.on ? "Disable" : "Enable"] T-ray Scanner</a>"
return text

Topic(href, href_list)
Expand All @@ -270,7 +270,7 @@ TYPEINFO(/obj/item/device/pda_module)
scanner.set_on(FALSE)

/obj/ability_button/pda_tray_toggle
name = "Toggle PDA T-Scanner"
name = "Toggle PDA T-ray Scanner"
icon_state = "pda0"

execute_ability()
Expand Down
2 changes: 1 addition & 1 deletion code/obj/item/device/pda2/pda2.dm
Expand Up @@ -1176,7 +1176,7 @@ ThinkOS 7 comes with several useful applications built in, these include:<br>
<li>Messenger: Send messages between all enabled PDAs. Can also send the current file in the clipboard.</li>
<li>File Browser: Manage and execute programs in the internal drive or loaded cartridge.</li>
<li>Atmos Scanner: Using patented AirScan technology.</li>
<li>Modules: Light up your life with a flashlight, or see right through the floor with a T-Scanner! The choice is yours!</li>
<li>Modules: Light up your life with a flashlight, or see right through the floor with a T-ray Scanner! The choice is yours!</li>
</ul></i>
<b>To send a file with the messenger:</b><br>
Enter the file browser and copy the file you want to send. Now enter the messenger and select *send file*.<br>
Expand Down
57 changes: 51 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,19 +29,59 @@ TYPEINFO(/obj/item/device/t_scanner)
var/client/last_client = null
var/image/last_display = null
var/find_interesting = TRUE
var/list/datum/contextAction/actions = null
contextLayout = new /datum/contextLayout/experimentalcircle
var/show_underfloor_cables = TRUE
var/show_underfloor_disposal_pipes = TRUE
var/show_blueprint_disposal_pipes = TRUE

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

/// Update the inventory, ability, and context buttons
proc/set_on(new_on, mob/user=null)
on = new_on
set_icon_state("t-ray[on]")
for(var/datum/contextAction/t_scanner/action in src.actions)
if(istype(action, /datum/contextAction/t_scanner/active))
action.icon_state ="[action.base_icon_state][on ? "on" : "off"]"
if(user)
boutput(user, "You switch [src] [on ? "on" : "off"].")
if(!on)
hide_displays()
else
processing_items |= src

proc/set_underfloor_cables(state, mob/user=null)
show_underfloor_cables = state
for(var/datum/contextAction/t_scanner/action in src.actions)
if(istype(action, /datum/contextAction/t_scanner/underfloor_cables))
action.icon_state = "[action.base_icon_state][show_underfloor_cables ? "on" : "off"]"
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
for(var/datum/contextAction/t_scanner/action in src.actions)
if(istype(action, /datum/contextAction/t_scanner/underfloor_disposal_pipes))
action.icon_state = "[action.base_icon_state][show_underfloor_disposal_pipes ? "on" : "off"]"
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
for(var/datum/contextAction/t_scanner/action in src.actions)
if(istype(action, /datum/contextAction/t_scanner/blueprint_disposal_pipes))
action.icon_state = "[action.base_icon_state][show_blueprint_disposal_pipes ? "on" : "off"]"
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(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 +140,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 +154,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 +178,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
Binary file modified icons/misc/abilities.dmi
Binary file not shown.
Binary file modified icons/ui/context16x16.dmi
Binary file not shown.

0 comments on commit ffad733

Please sign in to comment.