Skip to content

Commit

Permalink
Merge pull request #4471 from MistakeNot4892/tweak/altclick
Browse files Browse the repository at this point in the history
Converts remaining AltClick overrides to alt interactions.
  • Loading branch information
out-of-phaze authored Sep 20, 2024
2 parents 96d23cc + 7075bd1 commit 70207bd
Show file tree
Hide file tree
Showing 33 changed files with 181 additions and 96 deletions.
6 changes: 4 additions & 2 deletions code/game/machinery/washing_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,16 @@
if(.)
return washer.operable() && !(washer.state & WASHER_STATE_RUNNING)

/decl/interaction_handler/start_washer/invoked(obj/machinery/washing_machine/washer, mob/user)
/decl/interaction_handler/start_washer/invoked(atom/target, mob/user, obj/item/prop)
var/obj/machinery/washing_machine/washer = target
return washer.start_washing(user)

/decl/interaction_handler/toggle_open/washing_machine
name = "Toggle detergent port"
expected_target_type = /obj/machinery/washing_machine

/decl/interaction_handler/toggle_open/washing_machine/invoked(obj/machinery/washing_machine/washer, mob/user)
/decl/interaction_handler/toggle_open/washing_machine/invoked(atom/target, mob/user, obj/item/prop)
var/obj/machinery/washing_machine/washer = target
return washer.toggle_detergent_port(user)

/obj/machinery/washing_machine/on_update_icon()
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/blades/folding.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
var/decl/interaction_handler/folding_knife/interaction = GET_DECL(/decl/interaction_handler/folding_knife)
if(!interaction.is_possible(src, user))
return FALSE
interaction.invoked(src, user)
interaction.invoked(src, user, user.get_active_held_item())
return TRUE

/obj/item/bladed/folding/proc/set_open(new_state, mob/user)
Expand Down Expand Up @@ -145,7 +145,7 @@
I.name = "Use as [tool_name]"
.[tool_mode] = I

/decl/interaction_handler/folding_knife/invoked(atom/target, mob/user)
/decl/interaction_handler/folding_knife/invoked(atom/target, mob/user, obj/item/prop)
var/obj/item/bladed/folding/folding_knife = target
var/chosen_option = show_radial_menu(user, user, get_radial_choices(folding_knife), radius = 42, use_labels = RADIAL_LABELS_OFFSET)
if(!chosen_option)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/gps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ var/global/list/all_gps_units = list()
name = "Toggle Tracking"
expected_target_type = /obj/item/gps

/decl/interaction_handler/gps_toggle/invoked(atom/target, mob/user)
/decl/interaction_handler/gps_toggle/invoked(atom/target, mob/user, obj/item/prop)
var/obj/item/gps/G = target
G.toggle_tracking(user)

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/doors/_door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
expected_target_type = /obj/structure/door
interaction_flags = INTERACTION_NEEDS_PHYSICAL_INTERACTION | INTERACTION_NEEDS_TURF

/decl/interaction_handler/knock_on_door/invoked(var/atom/target, var/mob/user)
/decl/interaction_handler/knock_on_door/invoked(atom/target, mob/user, obj/item/prop)
if(!istype(target) || !target.density)
return FALSE
user.do_attack_animation(src)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/extinguisher.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
name = "Open/Close"
expected_target_type = /obj/structure/extinguisher_cabinet

/decl/interaction_handler/extinguisher_cabinet_open/invoked(var/atom/target, var/mob/user)
/decl/interaction_handler/extinguisher_cabinet_open/invoked(atom/target, mob/user, obj/item/prop)
var/obj/structure/extinguisher_cabinet/C = target
C.opened = !C.opened
C.update_icon()
2 changes: 1 addition & 1 deletion code/game/objects/structures/fires.dm
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@
name = "Adjust Draught"
expected_target_type = /obj/structure/fire_source

/decl/interaction_handler/adjust_draught/invoked(atom/target, mob/user)
/decl/interaction_handler/adjust_draught/invoked(atom/target, mob/user, obj/item/prop)
var/obj/structure/fire_source/fire = target
if(fire.has_draught)
fire.adjust_draught(user)
Expand Down
47 changes: 30 additions & 17 deletions code/game/turfs/walls/wall_natural_ramps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,37 @@
if(!istype(support) || (destroying_self && support == src) || support.ramp_slope_direction)
neighbor.dismantle_turf(ramp_update = FALSE) // This will only occur on ramps, so no need to propagate to other ramps.

// TODO: convert to alt interaction.
/turf/wall/natural/AltClick(mob/user)

var/obj/item/P = user.get_active_held_item()
if(user.Adjacent(src) && IS_PICK(P) && HasAbove(z))

var/user_dir = get_dir(src, user)
if(!(user_dir in global.cardinal))
to_chat(user, SPAN_WARNING("You must be standing at a cardinal angle to create a ramp."))
return TRUE
/turf/wall/natural/get_alt_interactions(mob/user)
. = ..()
LAZYADD(., /decl/interaction_handler/drill_ramp)

var/turf/wall/natural/support = get_step(src, global.reverse_dir[user_dir])
if(!istype(support) || support.ramp_slope_direction)
to_chat(user, SPAN_WARNING("You cannot cut a ramp into a wall with no additional walls behind it."))
return TRUE
/decl/interaction_handler/drill_ramp
name = "Drill Ramp"
expected_target_type = /turf/wall/natural

if(P.do_tool_interaction(TOOL_PICK, user, src, 3 SECONDS, suffix_message = ", forming it into a ramp") && !ramp_slope_direction)
make_ramp(user, user_dir)
/decl/interaction_handler/drill_ramp/is_possible(atom/target, mob/user, obj/item/prop)
. = ..()
if(.)
if(!IS_PICK(prop))
return FALSE
var/turf/wall/natural/wall = target
if(!HasAbove(wall.z))
return FALSE
if(!user.Adjacent(target))
return FALSE
return TRUE

. = ..()
/decl/interaction_handler/drill_ramp/invoked(atom/target, mob/user, obj/item/prop)
var/turf/wall/natural/wall = target
var/user_dir = get_dir(wall, user)
if(!(user_dir in global.cardinal))
to_chat(user, SPAN_WARNING("You must be standing at a cardinal angle to create a ramp."))
return FALSE
var/turf/wall/natural/support = get_step(wall, global.reverse_dir[user_dir])
if(!istype(support) || support.ramp_slope_direction)
to_chat(user, SPAN_WARNING("You cannot cut a ramp into a wall with no additional walls behind it."))
return FALSE
if(prop.do_tool_interaction(TOOL_PICK, user, wall, 3 SECONDS, suffix_message = ", forming it into a ramp") && !wall.ramp_slope_direction)
wall.make_ramp(user, user_dir)
return TRUE
return FALSE
2 changes: 1 addition & 1 deletion code/modules/clothing/_clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@
name = "Set Sensors Level"
expected_target_type = /obj/item/clothing

/decl/interaction_handler/clothing_set_sensors/invoked(var/atom/target, var/mob/user)
/decl/interaction_handler/clothing_set_sensors/invoked(atom/target, mob/user, obj/item/prop)
var/obj/item/clothing/U = target
U.set_sensors(user)

2 changes: 1 addition & 1 deletion code/modules/clothing/clothing_state/_clothing_state.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@
expected_target_type = /obj/item/clothing
var/state_decl_type

/decl/interaction_handler/clothing_toggle/invoked(var/atom/target, var/mob/user)
/decl/interaction_handler/clothing_toggle/invoked(atom/target, mob/user, obj/item/prop)
var/decl/clothing_state_modifier/modifier = GET_DECL(state_decl_type)
call(target, modifier.toggle_verb)()
2 changes: 1 addition & 1 deletion code/modules/detectivework/microscope/_forensic_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@
name = "Remove Sample"
expected_target_type = /obj/machinery/forensic

/decl/interaction_handler/forensics_remove_sample/invoked(var/atom/target, var/mob/user)
/decl/interaction_handler/forensics_remove_sample/invoked(atom/target, mob/user, obj/item/prop)
var/obj/machinery/forensic/F = target
F.remove_sample(usr)
2 changes: 1 addition & 1 deletion code/modules/hydroponics/trays/tray.dm
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,6 @@
var/obj/machinery/portable_atmospherics/hydroponics/T = target
return T.mechanical

/decl/interaction_handler/hydroponics_close_lid/invoked(var/atom/target, var/mob/user)
/decl/interaction_handler/hydroponics_close_lid/invoked(atom/target, mob/user, obj/item/prop)
var/obj/machinery/portable_atmospherics/hydroponics/T = target
T.close_lid(user)
2 changes: 1 addition & 1 deletion code/modules/interactions/_interactions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@

return TRUE

/decl/interaction_handler/proc/invoked(var/atom/target, var/mob/user)
/decl/interaction_handler/proc/invoked(atom/target, mob/user, obj/item/prop)
SHOULD_CALL_PARENT(FALSE)
PRINT_STACK_TRACE("Alt interaction handler called with no invoked logic defined: [type]")
26 changes: 16 additions & 10 deletions code/modules/mechs/equipment/engineering.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,22 @@
var/current_mode = 0 //0 barrier, 1 bubble
var/shield_range = 2

// TODO: convert to alt interaction.
/obj/item/mech_equipment/atmos_shields/AltClick(mob/user)
if (owner?.hatch_closed && ((user in owner.pilots) || user == owner))
if (active)
to_chat(user, SPAN_WARNING("You cannot modify the projection mode while the shield is active."))
else
current_mode = !current_mode
to_chat(user, SPAN_NOTICE("You set the shields to [current_mode ? "bubble" : "barrier"] mode."))
return TRUE
return ..()
/obj/item/mech_equipment/atmos_shields/get_alt_interactions(mob/user)
. = ..()
LAZYADD(., /decl/interaction_handler/mech_equipment/adjust_atmos_shields)

/decl/interaction_handler/mech_equipment/adjust_atmos_shields
name = "Adjust Atmos Shields"
expected_target_type = /obj/item/mech_equipment/atmos_shields

/decl/interaction_handler/mech_equipment/adjust_atmos_shields/invoked(atom/target, mob/user, obj/item/prop)
var/obj/item/mech_equipment/atmos_shields/shields = target
if (shields.active)
to_chat(user, SPAN_WARNING("You cannot modify the projection mode while the shield is active."))
else
shields.current_mode = !shields.current_mode
to_chat(user, SPAN_NOTICE("You set the shields to [shields.current_mode ? "bubble" : "barrier"] mode."))
return TRUE

/obj/effect/mech_shield
name = "energy shield"
Expand Down
43 changes: 31 additions & 12 deletions code/modules/mechs/equipment/utility.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,9 @@
if(.)
drop_carrying(user, TRUE)

/obj/item/mech_equipment/clamp/AltClick(mob/user)
if(owner?.hatch_closed)
drop_carrying(user, FALSE)
return TRUE
return ..()
/obj/item/mech_equipment/clamp/get_alt_interactions(mob/user)
. = ..()
LAZYADD(., /decl/interaction_handler/mech_equipment/clamp)

/obj/item/mech_equipment/clamp/proc/drop_carrying(var/mob/user, var/choose_object)
if(!length(carrying))
Expand Down Expand Up @@ -195,6 +193,14 @@
carrying -= load
. = ..()

/decl/interaction_handler/mech_equipment/clamp
name = "Release Clamp"
expected_target_type = /obj/item/mech_equipment/clamp

/decl/interaction_handler/mech_equipment/clamp/invoked(atom/target, mob/user, obj/item/prop)
var/obj/item/mech_equipment/clamp/clamp = target
clamp.drop_carrying(user, FALSE)

// A lot of this is copied from floodlights.
/obj/item/mech_equipment/light
name = "floodlight"
Expand Down Expand Up @@ -620,13 +626,6 @@
else
activate()

/obj/item/mech_equipment/ionjets/AltClick(mob/user)
if(owner?.hatch_closed && ((user in owner.pilots) || user == owner) && active)
stabilizers = !stabilizers
to_chat(user, SPAN_NOTICE("You toggle the stabilizers [stabilizers ? "on" : "off"]"))
return TRUE
return ..()

/obj/item/mech_equipment/ionjets/proc/activate()
passive_power_use = activated_passive_power
ion_trail.start()
Expand Down Expand Up @@ -687,6 +686,26 @@
else
to_chat(user, SPAN_WARNING("You cannot slide there!"))

/obj/item/mech_equipment/ionjets/get_alt_interactions(mob/user)
. = ..()
LAZYADD(., /decl/interaction_handler/mech_equipment/ionjets)

/decl/interaction_handler/mech_equipment/ionjets
name = "Toggle Stabilizers"
expected_target_type = /obj/item/mech_equipment/ionjets

/decl/interaction_handler/mech_equipment/ionjets/is_possible(atom/target, mob/user, obj/item/prop)
. = ..()
if(.)
var/obj/item/mech_equipment/ionjets/jets = target
return jets.active

/decl/interaction_handler/mech_equipment/ionjets/invoked(atom/target, mob/user, obj/item/prop)
var/obj/item/mech_equipment/ionjets/jets = target
jets.stabilizers = !jets.stabilizers
to_chat(user, SPAN_NOTICE("You toggle the stabilizers [jets.stabilizers ? "on" : "off"]"))
return TRUE

//Exosuit camera
/datum/extension/network_device/camera/mech
expected_type = /obj/item/mech_equipment/camera
Expand Down
15 changes: 15 additions & 0 deletions code/modules/mechs/mech_interaction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,18 @@
if(hardpoints[h] == I)
return h
return 0

/decl/interaction_handler/mech_equipment
abstract_type = /decl/interaction_handler/mech_equipment
expected_target_type = /obj/item/mech_equipment
interaction_flags = 0 // Mech gear is a bit special, see is_possible() below.

/decl/interaction_handler/mech_equipment/is_possible(atom/target, mob/user, obj/item/prop)
. = ..()
if(.)
if(user.incapacitated())
return FALSE
var/obj/item/mech_equipment/gear = target
if(!gear.owner)
return FALSE
return gear.owner.hatch_closed && ((user in gear.owner.pilots) || user == gear.owner)
5 changes: 3 additions & 2 deletions code/modules/mining/ore_box.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,6 @@
/decl/interaction_handler/empty/ore_box/is_possible(obj/structure/ore_box/target, mob/user, obj/item/prop)
return ..() && target.total_ores > 0

/decl/interaction_handler/empty/ore_box/invoked(obj/structure/ore_box/target, mob/user)
target.empty_box(user)
/decl/interaction_handler/empty/ore_box/invoked(atom/target, mob/user, obj/item/prop)
var/obj/structure/ore_box/box = target
box.empty_box(user)
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@
/decl/interaction_handler/remove_pen/modular_computer/is_possible(obj/item/modular_computer/target, mob/user, obj/item/prop)
return ..() && target.stores_pen && target.stored_pen

/decl/interaction_handler/remove_pen/modular_computer/invoked(obj/item/modular_computer/target, mob/user, obj/item/prop)
target.remove_pen()
/decl/interaction_handler/remove_pen/modular_computer/invoked(atom/target, mob/user, obj/item/prop)
var/obj/item/modular_computer/computer = target
computer.remove_pen()

//
// Emergency Shutdown
Expand All @@ -187,8 +188,9 @@
var/datum/extension/assembly/modular_computer/assembly = get_extension(target, /datum/extension/assembly)
return !isnull(assembly) && assembly.enabled

/decl/interaction_handler/emergency_shutdown/invoked(obj/item/modular_computer/target, mob/user, obj/item/prop)
target.emergency_shutdown()
/decl/interaction_handler/emergency_shutdown/invoked(atom/target, mob/user, obj/item/prop)
var/obj/item/modular_computer/computer = target
computer.emergency_shutdown()

//
// Remove Charge-stick
Expand Down
2 changes: 1 addition & 1 deletion code/modules/multiz/mobile_ladder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@
name = "Fold Ladder"
expected_target_type = /obj/structure/ladder/mobile

/decl/interaction_handler/ladder_fold/invoked(var/atom/target, var/mob/user)
/decl/interaction_handler/ladder_fold/invoked(atom/target, mob/user, obj/item/prop)
var/obj/structure/ladder/mobile/L
L.fold(user)
5 changes: 3 additions & 2 deletions code/modules/paperwork/carbonpaper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@
name = "remove carbon-copy"
expected_target_type = /obj/item/paper/carbon

/decl/interaction_handler/carbon_paper_remove/invoked(obj/item/paper/carbon/target, mob/user)
target.remove_copy(user)
/decl/interaction_handler/carbon_paper_remove/invoked(atom/target, mob/user, obj/item/prop)
var/obj/item/paper/carbon/paper = target
paper.remove_copy(user)
25 changes: 21 additions & 4 deletions code/modules/paperwork/clipboard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@

return ..()

/obj/item/clipboard/AltClick(mob/user)
if(stored_pen)
remove_pen(user)

/obj/item/clipboard/attack_self(mob/user)
if(CanPhysicallyInteractWith(user, src))
interact(user)
Expand Down Expand Up @@ -194,6 +190,27 @@
else
close_browser(user, initial(name))

/obj/item/clipboard/get_alt_interactions(mob/user)
. = ..()
if(stored_pen)
LAZYADD(., /decl/interaction_handler/clipboard_remove_pen)

/decl/interaction_handler/clipboard_remove_pen
name = "Remove Pen"
expected_target_type = /obj/item/clipboard

/decl/interaction_handler/clipboard_remove_pen/is_possible(atom/target, mob/user, obj/item/prop)
. = ..()
if(.)
var/obj/item/clipboard/clipboard = target
return !!clipboard.stored_pen

/decl/interaction_handler/clipboard_remove_pen/invoked(atom/target, mob/user, obj/item/prop)
var/obj/item/clipboard/clipboard = target
if(clipboard.stored_pen)
clipboard.remove_pen(user)

// Subtypes below.
/obj/item/clipboard/ebony
material = /decl/material/solid/organic/wood/ebony

Expand Down
2 changes: 1 addition & 1 deletion code/modules/paperwork/paper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ var/global/datum/topic_state/default/paper_state/paper_topic_state = new
abstract_type = /decl/interaction_handler/scroll
expected_target_type = /obj/item/paper/scroll

/decl/interaction_handler/scroll/invoked(atom/target, mob/user)
/decl/interaction_handler/scroll/invoked(atom/target, mob/user, obj/item/prop)
var/obj/item/paper/scroll/scroll = target
// TODO: paper sound
scroll.furled = !scroll.furled
Expand Down
Loading

0 comments on commit 70207bd

Please sign in to comment.