diff --git a/code/_onclick/hud/human.dm b/code/_onclick/hud/human.dm index 37a858d76699..b8b55b42c028 100644 --- a/code/_onclick/hud/human.dm +++ b/code/_onclick/hud/human.dm @@ -272,18 +272,14 @@ static_inventory += using /datum/hud/human/proc/draw_hand_equip(datum/custom_hud/ui_datum, ui_alpha, ui_color) - var/atom/movable/screen/using = new /atom/movable/screen() - using.name = "equip" - using.icon = ui_datum.ui_style_icon - using.icon_state = "act_equip" - using.screen_loc = ui_datum.ui_equip - using.layer = ABOVE_HUD_LAYER - using.plane = ABOVE_HUD_PLANE + var/atom/movable/screen/equip/equip_button = new() + equip_button.icon = ui_datum.ui_style_icon + equip_button.screen_loc = ui_datum.ui_equip if(ui_color) - using.color = ui_color + equip_button.color = ui_color if(ui_alpha) - using.alpha = ui_alpha - static_inventory += using + equip_button.alpha = ui_alpha + static_inventory += equip_button /datum/hud/human/proc/draw_oxygen(datum/custom_hud/ui_datum) oxygen_icon = new /atom/movable/screen/oxygen() @@ -312,38 +308,28 @@ infodisplay += locate_leader /datum/hud/human/proc/draw_gun_related(datum/custom_hud/ui_datum, ui_alpha) - use_attachment = new /atom/movable/screen() + use_attachment = new /atom/movable/screen/gun/attachment() use_attachment.icon = ui_datum.ui_style_icon - use_attachment.icon_state = "gun_attach" - use_attachment.name = "Activate weapon attachment" use_attachment.screen_loc = ui_datum.ui_gun_attachment static_inventory += use_attachment - toggle_raillight = new /atom/movable/screen() + toggle_raillight = new /atom/movable/screen/gun/rail_light() toggle_raillight.icon = ui_datum.ui_style_icon - toggle_raillight.icon_state = "gun_raillight" - toggle_raillight.name = "Toggle Rail Flashlight" toggle_raillight.screen_loc = ui_datum.ui_gun_railtoggle static_inventory += toggle_raillight - eject_mag = new /atom/movable/screen() + eject_mag = new /atom/movable/screen/gun/eject_magazine() eject_mag.icon = ui_datum.ui_style_icon - eject_mag.icon_state = "gun_loaded" - eject_mag.name = "Eject magazine" eject_mag.screen_loc = ui_datum.ui_gun_eject static_inventory += eject_mag - toggle_burst = new /atom/movable/screen() + toggle_burst = new /atom/movable/screen/gun/toggle_firemode() toggle_burst.icon = ui_datum.ui_style_icon - toggle_burst.icon_state = "gun_burst" - toggle_burst.name = "Toggle burst fire" toggle_burst.screen_loc = ui_datum.ui_gun_burst static_inventory += toggle_burst - unique_action = new /atom/movable/screen() + unique_action = new /atom/movable/screen/gun/unique_action() unique_action.icon = ui_datum.ui_style_icon - unique_action.icon_state = "gun_unique" - unique_action.name = "Use unique action" unique_action.screen_loc = ui_datum.ui_gun_unique static_inventory += unique_action diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index ed30ddaaec96..edf2d44a0714 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -213,54 +213,53 @@ update_icon(user) return 1 -/atom/movable/screen/clicked(mob/user, list/mods) - if(!user) - return TRUE +/atom/movable/screen/gun + /// The proc/verb which should be called on the gun. + var/gun_proc_ref - if(isobserver(user)) - return TRUE +/atom/movable/screen/gun/clicked(mob/user, list/mods) + . = ..() + if(.) + return + // If the user has a gun in their active hand, call `gun_proc_ref` on it. + var/obj/item/weapon/gun/held_item = user.get_held_item() + if(istype(held_item)) + INVOKE_ASYNC(held_item, gun_proc_ref) - switch(name) - if("equip") - if(ishuman(user)) - var/mob/living/carbon/human/human = user - human.quick_equip() - return 1 +/atom/movable/screen/gun/attachment + name = "Activate weapon attachment" + icon_state = "gun_attach" + gun_proc_ref = TYPE_VERB_REF(/obj/item/weapon/gun, activate_attachment_verb) - if("Reset Machine") - user.unset_interaction() - return 1 +/atom/movable/screen/gun/rail_light + name = "Toggle rail flashlight" + icon_state = "gun_raillight" + gun_proc_ref = TYPE_VERB_REF(/obj/item/weapon/gun, activate_rail_attachment_verb) - if("Activate weapon attachment") - var/obj/item/weapon/gun/held_item = user.get_held_item() - if(istype(held_item)) - held_item.activate_attachment_verb() - return 1 +/atom/movable/screen/gun/eject_magazine + name = "Eject magazine" + icon_state = "gun_loaded" + gun_proc_ref = TYPE_VERB_REF(/obj/item/weapon/gun, empty_mag) - if("Toggle Rail Flashlight") - var/obj/item/weapon/gun/held_item = user.get_held_item() - if(istype(held_item)) - held_item.activate_rail_attachment_verb() - return 1 +/atom/movable/screen/gun/toggle_firemode + name = "Toggle firemode" + icon_state = "gun_burst" + gun_proc_ref = TYPE_VERB_REF(/obj/item/weapon/gun, use_toggle_burst) - if("Eject magazine") - var/obj/item/weapon/gun/held_item = user.get_held_item() - if(istype(held_item)) - held_item.empty_mag() - return 1 +/atom/movable/screen/gun/unique_action + name = "Use unique action" + icon_state = "gun_unique" + gun_proc_ref = TYPE_VERB_REF(/obj/item/weapon/gun, use_unique_action) - if("Toggle burst fire") - var/obj/item/weapon/gun/held_item = user.get_held_item() - if(istype(held_item)) - held_item.use_toggle_burst() - return 1 - if("Use unique action") - var/obj/item/weapon/gun/held_item = user.get_held_item() - if(istype(held_item)) - held_item.use_unique_action() - return 1 - return 0 +/atom/movable/screen/clicked(mob/user, list/mods) + if(!user) + return TRUE + + if(isobserver(user)) + return TRUE + + return FALSE /atom/movable/screen/inventory/clicked(mob/user) @@ -587,6 +586,19 @@ vision_define = XENO_VISION_LEVEL_NO_NVG to_chat(owner, SPAN_NOTICE("Night vision mode switched to [vision_define].")) +/atom/movable/screen/equip + name = "equip" + icon_state = "act_equip" + layer = ABOVE_HUD_LAYER + plane = ABOVE_HUD_PLANE + +/atom/movable/screen/equip/clicked(mob/user) + . = ..() + if(. || !ishuman(user)) + return TRUE + var/mob/living/carbon/human/human_user = user + human_user.quick_equip() + /atom/movable/screen/bodytemp name = "body temperature" icon_state = "temp0"