From 3d1a54e1296b71f5ca173a4af0a4e8c378dc154d Mon Sep 17 00:00:00 2001 From: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Date: Mon, 24 Mar 2025 15:01:43 +0100 Subject: [PATCH] Moves material item insertion to right click for material containers (#90188) ## About The Pull Request Inserting material (i.e. made from a material, but not a material sheet/stack) items into material containers/remotes (ore silos, autolathes, protolathes, etc) now uses right click instead of left click. You still insert sheets using left click. ## Why It's Good For The Game Its super easy to end up having your guns (which are made out of iron) or armor (also made out of armor) or disks (also made out of iron) eaten by an autolathe as you try to click a table next to it. This should resolve players' frustrations while keeping material item insertion an option via right clicking. ## Changelog :cl: qol: Moved material item insertion to right click for material containers /:cl: --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- .../components/material/material_container.dm | 26 ++++++++++++++----- .../components/material/remote_materials.dm | 19 +++++++++----- code/game/machinery/autolathe.dm | 2 +- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/code/datums/components/material/material_container.dm b/code/datums/components/material/material_container.dm index 7f2a6b05a30..3774d655f42 100644 --- a/code/datums/components/material/material_container.dm +++ b/code/datums/components/material/material_container.dm @@ -81,6 +81,7 @@ if(!(mat_container_flags & MATCONTAINER_NO_INSERT)) //to insert stuff into the container RegisterSignal(atom_target, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(on_item_insert)) + RegisterSignal(atom_target, COMSIG_ATOM_ITEM_INTERACTION_SECONDARY, PROC_REF(on_secondary_insert)) //screen tips for inserting items atom_target.flags_1 |= HAS_CONTEXTUAL_SCREENTIPS_1 @@ -98,6 +99,7 @@ if(!(mat_container_flags & MATCONTAINER_NO_INSERT)) signals += COMSIG_ATOM_ITEM_INTERACTION + signals += COMSIG_ATOM_ITEM_INTERACTION_SECONDARY signals += COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM if(mat_container_flags & MATCONTAINER_EXAMINE) signals += COMSIG_ATOM_EXAMINE @@ -130,8 +132,9 @@ if(old_flags & MATCONTAINER_NO_INSERT && !(mat_container_flags & MATCONTAINER_NO_INSERT)) RegisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(on_item_insert)) + RegisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION_SECONDARY, PROC_REF(on_secondary_insert)) else if(!(old_flags & MATCONTAINER_NO_INSERT) && mat_container_flags & MATCONTAINER_NO_INSERT) - UnregisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION) + UnregisterSignal(parent, list(COMSIG_ATOM_ITEM_INTERACTION, COMSIG_ATOM_ITEM_INTERACTION_SECONDARY)) /** * 3 Types of Procs @@ -485,21 +488,28 @@ if(!QDELETED(deleting)) //deleting parents also delete their children so we check qdel(deleting) -/// Proc that allows players to fill the parent with mats -/datum/component/material_container/proc/on_item_insert(datum/source, mob/living/user, obj/item/weapon, list/modifiers) +/datum/component/material_container/proc/on_item_insert(datum/source, mob/living/user, obj/item/weapon) SIGNAL_HANDLER + // Don't insert material items with left click + if (isstack(weapon)) + return attempt_insert(user, weapon) +/datum/component/material_container/proc/on_secondary_insert(datum/source, mob/living/user, obj/item/weapon) + SIGNAL_HANDLER + return attempt_insert(user, weapon) + +/// Proc that allows players to fill the parent with mats +/datum/component/material_container/proc/attempt_insert(mob/living/user, obj/item/weapon) //Allows you to attack the machine with iron sheets for e.g. if(!(mat_container_flags & MATCONTAINER_ANY_INTENT) && user.combat_mode) return - if(ismachinery(source)) - var/obj/machinery/machine = source + if(ismachinery(parent)) + var/obj/machinery/machine = parent if(machine.machine_stat || machine.panel_open) return user_insert(weapon, user) - return ITEM_INTERACT_SUCCESS //=============================================================================================== @@ -777,7 +787,9 @@ continue return NONE - context[SCREENTIP_CONTEXT_LMB] = "Insert" + if (isstack(held_item)) + context[SCREENTIP_CONTEXT_LMB] = "Insert stack" + context[SCREENTIP_CONTEXT_RMB] = "Insert" return CONTEXTUAL_SCREENTIP_SET diff --git a/code/datums/components/material/remote_materials.dm b/code/datums/components/material/remote_materials.dm index d8eb0dc060c..9f23de90d34 100644 --- a/code/datums/components/material/remote_materials.dm +++ b/code/datums/components/material/remote_materials.dm @@ -67,6 +67,7 @@ handles linking back and forth. mat_container = silo.materials if(!(mat_container_flags & MATCONTAINER_NO_INSERT)) RegisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(on_item_insert)) + RegisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION_SECONDARY, PROC_REF(on_secondary_insert)) if (!mat_container && allow_standalone) _MakeLocal() @@ -124,7 +125,7 @@ handles linking back and forth. if (QDELETED(old_silo) || silo != old_silo) return - UnregisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION) + UnregisterSignal(parent, list(COMSIG_ATOM_ITEM_INTERACTION, COMSIG_ATOM_ITEM_INTERACTION_SECONDARY)) silo.ore_connected_machines -= src silo = null mat_container = null @@ -164,22 +165,28 @@ handles linking back and forth. mat_container = new_container if(!(mat_container_flags & MATCONTAINER_NO_INSERT)) RegisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(on_item_insert)) + RegisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION_SECONDARY, PROC_REF(on_secondary_insert)) to_chat(user, span_notice("You connect [parent] to [silo] from the multitool's buffer.")) return ITEM_INTERACT_SUCCESS -///Insert mats into silo /datum/component/remote_materials/proc/on_item_insert(datum/source, mob/living/user, obj/item/target) SIGNAL_HANDLER + // Only insert stacks with left click + if(isstack(target)) + return attempt_insert(user, target) - //Allows you to attack the machine with iron sheets for e.g. +/datum/component/remote_materials/proc/on_secondary_insert(datum/source, mob/living/user, obj/item/target) + SIGNAL_HANDLER + return attempt_insert(user, target) + +/// Insert mats into silo +/datum/component/remote_materials/proc/attempt_insert(mob/living/user, obj/item/target) if(!(mat_container_flags & MATCONTAINER_ANY_INTENT) && user.combat_mode) return if(silo) mat_container.user_insert(target, user, parent) - - return ITEM_INTERACT_SUCCESS - + return ITEM_INTERACT_SUCCESS /** * Checks if the param silo is in the same level as this components parent i.e. connected machine, rcd, etc diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index a8acd5a370e..2f5d5a49073 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -80,7 +80,7 @@ return NONE if(held_item.tool_behaviour == TOOL_SCREWDRIVER) - context[SCREENTIP_CONTEXT_RMB] = "[panel_open ? "Close" : "Open"] Panel" + context[SCREENTIP_CONTEXT_LMB] = "[panel_open ? "Close" : "Open"] Panel" return CONTEXTUAL_SCREENTIP_SET if(panel_open && held_item.tool_behaviour == TOOL_CROWBAR)