diff --git a/code/game/objects/items/_inventory.dm b/code/game/objects/items/_inventory.dm index c5365d862f4..88906633f6c 100644 --- a/code/game/objects/items/_inventory.dm +++ b/code/game/objects/items/_inventory.dm @@ -53,6 +53,7 @@ equipped.forceMove(src) return FALSE + /obj/item/proc/equipped(mob/user, slot) equip_slot = slot if(user.pulling == src) @@ -72,6 +73,9 @@ update_light() if(flags & MOVE_NOTIFY) user.update_on_move |= src + if(action_button_name) + user.action_button_add(src) + /obj/item/proc/dropped(mob/user) GLOB.mob_unequipped_event.raise_event(user, src) @@ -84,6 +88,9 @@ if(overslot && is_held()) remove_overslot_contents(user) user.update_on_move -= src + if(action_button_name) + user.action_button_remove(src) + /obj/item/proc/remove_overslot_contents(mob/user) if(overslot_contents) @@ -92,7 +99,6 @@ overslot_contents = null - /obj/item/proc/mob_can_unequip(mob/M, slot, disable_warning = FALSE) if(!slot) return FALSE if(!M) return FALSE diff --git a/code/game/objects/items/devices/lighting/toggleable/flashlight.dm b/code/game/objects/items/devices/lighting/toggleable/flashlight.dm index d82d8b1cfd5..4287451346b 100644 --- a/code/game/objects/items/devices/lighting/toggleable/flashlight.dm +++ b/code/game/objects/items/devices/lighting/toggleable/flashlight.dm @@ -176,6 +176,7 @@ /obj/item/device/lighting/toggleable/flashlight/dropped(mob/user as mob) if(light_direction) set_dir(light_direction) + ..() /obj/item/device/lighting/toggleable/flashlight/afterattack(atom/A, mob/user) var/turf/T = get_turf(A) diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index e8f522d9fc8..dcb7213b3cd 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -80,14 +80,11 @@ handle_disabilities() // eye, ear, brain damages handle_status_effects() //all special effects, stunned, weakened, jitteryness, hallucination, sleeping, etc - handle_actions() - update_lying_buckled_and_verb_status() handle_regular_hud_updates() - /mob/living/proc/Life_Check_Light() if (HasMovementHandler(/datum/movement_handler/mob/transformation/)) return diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 66c620143ae..2c751aeeafa 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -431,52 +431,51 @@ /mob/living/proc/reagent_permeability() return 1 -/mob/living/proc/handle_actions() - //Pretty bad, i'd use picked/dropped instead but the parent calls in these are nonexistent - for(var/datum/action/A in actions) - if(A.CheckRemoval(src)) - A.Remove(src) - for(var/obj/item/I in src) - if(I.action_button_name) - if(!I.action) - if(I.action_button_is_hands_free) - I.action = new/datum/action/item_action/hands_free - else - I.action = new/datum/action/item_action - I.action.name = I.action_button_name - I.action.target = I - if(I.action_button_proc) - I.action.action_type = AB_ITEM_PROC - I.action.procname = I.action_button_proc - if(I.action_button_arguments) - I.action.arguments = I.action_button_arguments - I.action.Grant(src) +/mob/proc/action_button_add(obj/item/item) + return + +/mob/living/action_button_add(obj/item/item) + ASSERT(item) + if(!item.action_button_name) + return + + if(!item.action) + if(item.action_button_is_hands_free) + item.action = new/datum/action/item_action/hands_free + else + item.action = new/datum/action/item_action + item.action.name = item.action_button_name + item.action.target = item + if(item.action_button_proc) + item.action.action_type = AB_ITEM_PROC + item.action.procname = item.action_button_proc + if(item.action_button_arguments) + item.action.arguments = item.action_button_arguments + item.action.Grant(src) + + +/mob/proc/action_button_remove(obj/item/item) return +/mob/living/action_button_remove(obj/item/item) + ASSERT(item) + ASSERT(istype(item)) + if(item.action) + item.action.Remove(src) + else + for(var/datum/action/action in actions) + if(action.target == item) + action.Remove(src) + + /mob/living/update_action_buttons() if(!hud_used) return if(!client) return - //if(hud_used.hud_shown != 1) //Hud toggled to minimal - // return - - //client.screen -= hud_used.hide_actions_toggle for(var/datum/action/A in actions) if(A.button) client.screen -= A.button - /*if(hud_used.action_buttons_hidden) - if(!hud_used.hide_actions_toggle) - hud_used.hide_actions_toggle = new(hud_used) - hud_used.hide_actions_toggle.UpdateIcon() - - if(!hud_used.hide_actions_toggle.moved) - hud_used.hide_actions_toggle.screen_loc = hud_used.ButtonNumberToScreenCoords(1) - //hud_used.SetButtonCoords(hud_used.hide_actions_toggle,1) - - client.screen += hud_used.hide_actions_toggle - return -*/ var/button_number = 0 for(var/datum/action/A in actions) button_number++ @@ -495,13 +494,3 @@ if(!B.moved) B.screen_loc = hud_used.ButtonNumberToScreenCoords(button_number) - //hud_used.SetButtonCoords(B,button_number) - -// if(button_number > 0) - /*if(!hud_used.hide_actions_toggle) - hud_used.hide_actions_toggle = new(hud_used) - hud_used.hide_actions_toggle.InitialiseIcon(src) - if(!hud_used.hide_actions_toggle.moved) - hud_used.hide_actions_toggle.screen_loc = hud_used.ButtonNumberToScreenCoords(button_number+1) - //hud_used.SetButtonCoords(hud_used.hide_actions_toggle,button_number+1) - client.screen += hud_used.hide_actions_toggle*/ diff --git a/code/modules/mob/living/silicon/robot/life.dm b/code/modules/mob/living/silicon/robot/life.dm index f062d837c73..3fa80215c55 100644 --- a/code/modules/mob/living/silicon/robot/life.dm +++ b/code/modules/mob/living/silicon/robot/life.dm @@ -8,7 +8,6 @@ //Status updates, death etc. clamp_values() handle_regular_status_updates() - handle_actions() if(client) handle_regular_hud_updates() diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm index fe0cd69d45f..5a348461ba7 100644 --- a/code/modules/mob/login.dm +++ b/code/modules/mob/login.dm @@ -87,6 +87,7 @@ client.create_UI(src.type) add_click_catcher() + update_action_buttons() client.CAN_MOVE_DIAGONALLY = FALSE