diff --git a/code/__DEFINES/hud.dm b/code/__DEFINES/hud.dm index d00c7ac066e..bed1a6b24ac 100644 --- a/code/__DEFINES/hud.dm +++ b/code/__DEFINES/hud.dm @@ -86,7 +86,6 @@ #define HUD_CYBORG_HANDS "cyborg_module" #define HUD_CYBORG_RADIO "cyborg_radio" #define HUD_CYBORG_DEATH "cyborg_death" -#define HUD_KEY_CYBORG_MODULE(slot) "cyborg_module:[slot]" #define HUD_AI_FLOOR_INDICATOR "ai_floor_indicator" #define HUD_AI_GO_UP "ai_go_up" diff --git a/code/_onclick/hud/alien.dm b/code/_onclick/hud/alien.dm index 72b17e7cecd..b1bd23a5301 100644 --- a/code/_onclick/hud/alien.dm +++ b/code/_onclick/hud/alien.dm @@ -31,16 +31,3 @@ if(!isalienqueen(mymob)) add_screen_object(/atom/movable/screen/alien/alien_queen_finder, HUD_ALIEN_QUEEN_FINDER, HUD_GROUP_INFO) - -/datum/hud/alien/persistent_inventory_update() - if(!mymob) - return - var/mob/living/carbon/alien/adult/H = mymob - if(hud_version != HUD_STYLE_NOHUD) - for(var/obj/item/I in H.held_items) - I.screen_loc = ui_hand_position(H.get_held_index_of_item(I)) - H.client.screen += I - else - for(var/obj/item/I in H.held_items) - I.screen_loc = null - H.client.screen -= I diff --git a/code/_onclick/hud/drones.dm b/code/_onclick/hud/drones.dm index e7694d5d660..98335985040 100644 --- a/code/_onclick/hud/drones.dm +++ b/code/_onclick/hud/drones.dm @@ -1,22 +1,5 @@ /datum/hud/dextrous/drone - inventory_slots = /datum/inventory_slot/drone - -/datum/hud/dextrous/drone/persistent_inventory_update() - if(!mymob) - return - var/mob/living/basic/drone/drone = mymob - - if(hud_shown) - if(!isnull(drone.internal_storage)) - drone.internal_storage.screen_loc = ui_drone_storage - drone.client.screen += drone.internal_storage - if(!isnull(drone.head)) - drone.head.screen_loc = ui_drone_head - drone.client.screen += drone.head - else - drone.internal_storage?.screen_loc = null - drone.head?.screen_loc = null - ..() + default_inventory_slots = /datum/inventory_slot/drone /datum/inventory_slot/drone abstract_type = /datum/inventory_slot/drone diff --git a/code/_onclick/hud/generic_dextrous.dm b/code/_onclick/hud/generic_dextrous.dm index a0faa532533..a8dad62d835 100644 --- a/code/_onclick/hud/generic_dextrous.dm +++ b/code/_onclick/hud/generic_dextrous.dm @@ -28,17 +28,3 @@ if(HAS_TRAIT(mymob, TRAIT_CAN_THROW_ITEMS)) add_screen_object(/atom/movable/screen/throw_catch, HUD_MOB_THROW, HUD_GROUP_HOTKEYS, ui_style, ui_drop_throw) - -/datum/hud/dextrous/persistent_inventory_update() - if(!mymob) - return - var/mob/living/owner = mymob - if(hud_version != HUD_STYLE_NOHUD) - for(var/obj/item/held in owner.held_items) - held.screen_loc = ui_hand_position(owner.get_held_index_of_item(held)) - owner.client.screen += held - return - - for(var/obj/item/held in owner.held_items) - held.screen_loc = null - owner.client.screen -= held diff --git a/code/_onclick/hud/guardian.dm b/code/_onclick/hud/guardian.dm index 18b1b985ccb..883cd5ff8ba 100644 --- a/code/_onclick/hud/guardian.dm +++ b/code/_onclick/hud/guardian.dm @@ -7,33 +7,15 @@ ///Dextrous subtype for only dextrous holoparasites. Can hold things hence the inventory slot. /datum/hud/dextrous/guardian - inventory_slots = list(/datum/inventory_slot/guardian_storage) + default_inventory_slots = list(/datum/inventory_slot/guardian_storage) give_health_doll = FALSE /datum/hud/dextrous/guardian/initialize_screen_objects() . = ..() add_screen_object(/atom/movable/screen/healths/guardian, HUD_MOB_HEALTH, HUD_GROUP_INFO) -/datum/hud/dextrous/guardian/persistent_inventory_update() - if(!mymob) - return - - if(!istype(mymob, /mob/living/basic/guardian/dextrous)) - return ..() - - var/mob/living/basic/guardian/dextrous/dex_guardian = mymob - if(hud_shown) - if(dex_guardian.internal_storage) - dex_guardian.internal_storage.screen_loc = ui_back - dex_guardian.client.screen += dex_guardian.internal_storage - else - if(dex_guardian.internal_storage) - dex_guardian.internal_storage.screen_loc = null - return ..() - /datum/inventory_slot/guardian_storage name = "internal storage" icon_state = "suit_storage" slot_id = ITEM_SLOT_DEX_STORAGE screen_loc = ui_back - diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index ca2c29b7c5e..1c7cc767e6f 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -74,15 +74,14 @@ GLOBAL_LIST_INIT(available_ui_styles, list( var/list/atom/movable/screen/screen_objects = list() /// List of screen objects by their screen group var/list/screen_groups[SCREEN_GROUP_AMT] - /// List of all inventory slot screen objects by their slot ID. Some slots are fake and will be missing from here! - var/list/inv_slots[SLOTS_AMT] - /// List of hand slot objects, kept separate from the rest of inventory as mobs can have varying amount of hands - var/list/atom/movable/screen/inventory/hand/hand_slots = null /// List of typepaths of /datum/inventory_slot which will be used to automatically create inventory slot UI elements /// If assigned a typepath instead of a list, it will instead use all valid subtypes of said typepath - /// Safe to change in initialize_screen_objects() but not later - var/list/inventory_slots = null + /// Can be changed in initialize_screen_objects() to add/remove slots + var/list/datum/inventory_slot/default_inventory_slots = null + /// Alist of slot_id -> inventory_slot datum of our slots + /// These are singletons, do not modify individual slots! + var/list/datum/inventory_slot/inventory_slots = alist() /// List of weakrefs to objects that we add to our screen that we don't expect to DO anything /// They typically use * in their render target. They exist solely so we can reuse them, @@ -100,8 +99,6 @@ GLOBAL_LIST_INIT(available_ui_styles, list( add_screen_object(/atom/movable/screen/palette_scroll/down, HUD_MOB_PALETTE_DOWN) add_screen_object(/atom/movable/screen/palette_scroll/up, HUD_MOB_PALETTE_UP) - hand_slots = list() - var/datum/plane_master_group/main/main_group = new(PLANE_GROUP_MAIN) main_group.attach_to(src) @@ -143,8 +140,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list( QDEL_LIST(floating_actions) screentip_text = null screen_groups = null - inv_slots.Cut() - hand_slots.Cut() + inventory_slots.Cut() QDEL_LIST_ASSOC_VAL(screen_objects) QDEL_LIST_ASSOC_VAL(master_groups) QDEL_LIST_ASSOC_VAL(plane_master_controllers) @@ -361,6 +357,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list( screenmob.client.screen += group_hotkeys if (length(group_info)) screenmob.client.screen += group_info + // Do not show open storages to viewers, they get their own storage UIs if (length(group_storage) && viewmob == mymob) screenmob.client.screen += group_storage @@ -376,8 +373,10 @@ GLOBAL_LIST_INIT(available_ui_styles, list( screenmob.client.screen += group_info // Hands are apart of the static group but still should be presetn in the reduced mode - for (var/atom/movable/screen/hand in hand_slots) - screenmob.client.screen += hand + for (var/i in 1 to length(mymob.held_items)) + var/atom/movable/screen/hand = screen_objects[HUD_KEY_HAND_SLOT(i)] + if (hand) + screenmob.client.screen += hand if(action_intent) //move this to the alternative position, where zone_select usually is. @@ -387,7 +386,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list( hud_shown = FALSE hud_version = display_hud_version - persistent_inventory_update(screenmob) + inventory_update(screenmob) // Gives all of the actions the screenmob owes to their hud screenmob.update_action_buttons(TRUE) // Handles alerts - the things on the right side of the screen @@ -425,20 +424,30 @@ GLOBAL_LIST_INIT(available_ui_styles, list( if(!.) return var/mob/screenmob = viewmob || mymob - hidden_inventory_update(screenmob) + inventory_update(screenmob) /datum/hud/new_player/show_hud(version = 0, mob/viewmob) . = ..() if(.) show_station_trait_buttons() -/datum/hud/proc/hidden_inventory_update() - return - -/datum/hud/proc/persistent_inventory_update(mob/viewer) - if(!mymob) +/datum/hud/proc/inventory_update(mob/viewer) + if (isnull(mymob)) return + for (var/slot_id in inventory_slots) + var/datum/inventory_slot/slot = inventory_slots[slot_id] + if (!isnull(slot)) + slot.update_inventory_slot(src, mymob) + +/datum/hud/proc/update_inventory_slot(slot_id, ...) + if(isnull(mymob)) + return + var/datum/inventory_slot/slot = inventory_slots[slot_id] + if (!isnull(slot)) + var/list/slot_args = list(src, mymob) + args.Copy(2) + slot.update_inventory_slot(arglist(slot_args)) + /datum/hud/proc/update_ui_style(new_ui_style) // do nothing if overridden by a subtype or already on that style if (initial(ui_style) || ui_style == new_ui_style) @@ -481,8 +490,6 @@ GLOBAL_LIST_INIT(available_ui_styles, list( /// Rebuilds our mob's hand slot screen elements /datum/hud/proc/build_hand_slots(update_hud = FALSE) - QDEL_LIST(hand_slots) - hand_slots = new /list(length(mymob.held_items)) for(var/i in 1 to length(mymob.held_items)) var/atom/movable/screen/inventory/hand/hand_box = add_screen_object(/atom/movable/screen/inventory/hand, HUD_KEY_HAND_SLOT(i), HUD_GROUP_STATIC, ui_style, ui_hand_position(i)) @@ -490,7 +497,6 @@ GLOBAL_LIST_INIT(available_ui_styles, list( hand_box.icon_state = "hand_[mymob.held_index_to_dir(i)]" hand_box.held_index = i hand_box.update_appearance() - hand_slots[i] = hand_box var/num_of_swaps = 0 for(var/atom/movable/screen/swap_hand/swap_hands in screen_groups[HUD_GROUP_STATIC]) @@ -520,11 +526,11 @@ GLOBAL_LIST_INIT(available_ui_styles, list( /datum/hud/proc/update_locked_slots() return -/// Creates inventory slot screen elements based on our assigned inventory_slots +/// Creates inventory slot screen elements based on our assigned default_inventory_slots /datum/hud/proc/create_inventory_slots() - var/list/created_paths = inventory_slots - if (ispath(inventory_slots)) - created_paths = valid_subtypesof(inventory_slots) + var/list/created_paths = default_inventory_slots + if (ispath(created_paths)) + created_paths = valid_subtypesof(created_paths) for (var/datum/inventory_slot/slot_type as anything in created_paths) var/datum/inventory_slot/inv_slot = GLOB.inventory_slot_datums[slot_type] @@ -532,16 +538,11 @@ GLOBAL_LIST_INIT(available_ui_styles, list( stack_trace("[src] attempted to use an invalid inventory slot: [slot_type]") continue inv_slot.create_element(src) + inventory_slots[inv_slot.slot_id] = inv_slot - update_inventory_slots() - -/// Updates all of our inventory slots -/// Avoid calling directly in favor of specific update procs -/datum/hud/proc/update_inventory_slots() - for(var/atom/movable/screen/inventory/inv in screen_groups[HUD_GROUP_STATIC] + screen_groups[HUD_GROUP_TOGGLEABLE_INVENTORY]) - if(inv.slot_id) - inv_slots[TOBITSHIFT(inv.slot_id) + 1] = inv - inv.update_appearance() + // Lets add an abstract "hands" slot to ourselves for native handling + inventory_slots[ITEM_SLOT_HANDS] = GLOB.inventory_slot_datums[/datum/inventory_slot/hands] + inventory_update() /datum/hud/proc/position_action(atom/movable/screen/movable/action_button/button, position) // This is kinda a hack, I'm sorry. diff --git a/code/_onclick/hud/human.dm b/code/_onclick/hud/human.dm index 423132dad1a..cbe5403ea09 100644 --- a/code/_onclick/hud/human.dm +++ b/code/_onclick/hud/human.dm @@ -1,5 +1,5 @@ /datum/hud/human - inventory_slots = /datum/inventory_slot/human + default_inventory_slots = /datum/inventory_slot/human /datum/hud/human/initialize_screen_objects() . = ..() @@ -71,112 +71,6 @@ continue inv.alpha = (blocked_slots & inv.slot_id) ? 128 : initial(inv.alpha) -/datum/hud/human/hidden_inventory_update(mob/viewer) - if(!mymob) - return - var/mob/living/carbon/human/H = mymob - - var/mob/screenmob = viewer || H - - if(screenmob.hud_used.inventory_shown && screenmob.hud_used.hud_shown) - if(H.shoes) - H.shoes.screen_loc = ui_shoes - screenmob.client.screen += H.shoes - if(H.gloves) - H.gloves.screen_loc = ui_gloves - screenmob.client.screen += H.gloves - if(H.ears) - H.ears.screen_loc = ui_ears - screenmob.client.screen += H.ears - if(H.glasses) - H.glasses.screen_loc = ui_glasses - screenmob.client.screen += H.glasses - if(H.w_uniform) - H.w_uniform.screen_loc = ui_iclothing - screenmob.client.screen += H.w_uniform - if(H.wear_suit) - H.wear_suit.screen_loc = ui_oclothing - screenmob.client.screen += H.wear_suit - if(H.wear_mask) - H.wear_mask.screen_loc = ui_mask - screenmob.client.screen += H.wear_mask - if(H.wear_neck) - H.wear_neck.screen_loc = ui_neck - screenmob.client.screen += H.wear_neck - if(H.head) - H.head.screen_loc = ui_head - screenmob.client.screen += H.head - else - if(H.shoes) - screenmob.client.screen -= H.shoes - if(H.gloves) - screenmob.client.screen -= H.gloves - if(H.ears) - screenmob.client.screen -= H.ears - if(H.glasses) - screenmob.client.screen -= H.glasses - if(H.w_uniform) - screenmob.client.screen -= H.w_uniform - if(H.wear_suit) - screenmob.client.screen -= H.wear_suit - if(H.wear_mask) - screenmob.client.screen -= H.wear_mask - if(H.wear_neck) - screenmob.client.screen -= H.wear_neck - if(H.head) - screenmob.client.screen -= H.head - -/datum/hud/human/persistent_inventory_update(mob/viewer) - if(!mymob) - return - ..() - var/mob/living/carbon/human/H = mymob - - var/mob/screenmob = viewer || H - - if(screenmob.hud_used) - if(screenmob.hud_used.hud_shown) - if(H.s_store) - H.s_store.screen_loc = ui_sstore1 - screenmob.client.screen += H.s_store - if(H.wear_id) - H.wear_id.screen_loc = ui_id - screenmob.client.screen += H.wear_id - if(H.belt) - H.belt.screen_loc = ui_belt - screenmob.client.screen += H.belt - if(H.back) - H.back.screen_loc = ui_back - screenmob.client.screen += H.back - if(H.l_store) - H.l_store.screen_loc = ui_storage1 - screenmob.client.screen += H.l_store - if(H.r_store) - H.r_store.screen_loc = ui_storage2 - screenmob.client.screen += H.r_store - else - if(H.s_store) - screenmob.client.screen -= H.s_store - if(H.wear_id) - screenmob.client.screen -= H.wear_id - if(H.belt) - screenmob.client.screen -= H.belt - if(H.back) - screenmob.client.screen -= H.back - if(H.l_store) - screenmob.client.screen -= H.l_store - if(H.r_store) - screenmob.client.screen -= H.r_store - - if(hud_version != HUD_STYLE_NOHUD) - for(var/obj/item/I in H.held_items) - I.screen_loc = ui_hand_position(H.get_held_index_of_item(I)) - screenmob.client.screen += I - else - for(var/obj/item/I in H.held_items) - I.screen_loc = null - screenmob.client.screen -= I - /mob/living/carbon/human/verb/toggle_hotkey_verbs() set category = "OOC" set name = "Toggle hotkey buttons" diff --git a/code/_onclick/hud/inventory_slot.dm b/code/_onclick/hud/inventory_slot.dm index af3307be551..87efc517b7f 100644 --- a/code/_onclick/hud/inventory_slot.dm +++ b/code/_onclick/hud/inventory_slot.dm @@ -33,3 +33,62 @@ GLOBAL_LIST_INIT(inventory_slot_datums, initialize_inventory_slots()) inv_box.icon_full = icon_full inv_box.slot_id = slot_id return inv_box + +/// Returns the item held in this slot by hud's mymob +/datum/inventory_slot/proc/get_slot_item(mob/owner) + return owner.get_item_by_slot(slot_id) + +/// Returns a screen object for this slot for a particular hud datum +/datum/inventory_slot/proc/get_screen_slot(datum/hud/hud) + return hud.screen_objects[HUD_KEY_ITEM_SLOT(slot_id)] + +/// Update inventory slot visuals +/datum/inventory_slot/proc/update_inventory_slot(datum/hud/hud, mob/owner) + var/atom/movable/screen/inventory/slot = get_screen_slot(hud) + if (!slot) + return + + var/obj/item/slot_item = get_slot_item(owner) + update_slot_icon_contents(slot, slot_item) + +/// Updates the slot icon and its contents +/datum/inventory_slot/proc/update_slot_icon_contents(atom/movable/screen/inventory/slot, obj/item/slot_item) + slot.update_appearance(UPDATE_ICON) + if (!slot_item) + slot.vis_contents.Cut() + return + + if (slot_item in slot.vis_contents) + return + + // Reset pixel offsets in order to make it fit the box + slot_item.pixel_x = slot_item.base_pixel_x + slot_item.pixel_y = slot_item.base_pixel_y + slot.vis_contents += slot_item + +// Not a real inventory slot, but this is used as a generic abstraction for hand slot UI behaviors +/datum/inventory_slot/hands + slot_id = ITEM_SLOT_HANDS + +/datum/inventory_slot/hands/create_element(datum/hud/hud) + CRASH("[hud] attempted to call create_element on a behavior-only hands inventory slot datum!") + +/datum/inventory_slot/hands/get_slot_item(mob/owner, hand_index = 1) + return owner.held_items[hand_index] + +/datum/inventory_slot/hands/get_screen_slot(datum/hud/hud, hand_index = 1) + return hud.screen_objects[HUD_KEY_HAND_SLOT(hand_index)] + +/datum/inventory_slot/hands/update_inventory_slot(datum/hud/hud, mob/owner, hand_index = null) + // If no index was passed, update all hand slots + if (isnull(hand_index)) + for (var/i in 1 to length(owner.held_items)) + update_inventory_slot(hud, owner, i) + return + + var/atom/movable/screen/inventory/slot = get_screen_slot(hud, hand_index) + if (!slot) + return + + var/obj/item/slot_item = get_slot_item(owner, hand_index) + update_slot_icon_contents(slot, slot_item) diff --git a/code/_onclick/hud/robot.dm b/code/_onclick/hud/robot.dm index d1f9c632a97..fe8f1a1a125 100644 --- a/code/_onclick/hud/robot.dm +++ b/code/_onclick/hud/robot.dm @@ -10,8 +10,10 @@ add_screen_object(/atom/movable/screen/memories, HUD_MOB_MEMORIES, HUD_GROUP_STATIC, ui_style, ui_borg_memories_menu) add_screen_object(/atom/movable/screen/robot/radio, HUD_CYBORG_RADIO) + // Cyborg modules are their "hands", and use hand keys for ease of handling as they behave functionally the same + // Generic code can just typecheck for /atom/movable/screen/inventory/hud if it needs explicitly hands for (var/i in BORG_CHOOSE_MODULE_ONE to BORG_CHOOSE_MODULE_THREE) - var/atom/movable/screen/robot/module_slot/module = add_screen_object(/atom/movable/screen/robot/module_slot, HUD_KEY_CYBORG_MODULE(i)) + var/atom/movable/screen/robot/module_slot/module = add_screen_object(/atom/movable/screen/robot/module_slot, HUD_KEY_HAND_SLOT(i)) module.set_slot(i) add_screen_object(/atom/movable/screen/robot/lamp, HUD_CYBORG_LAMP) @@ -33,25 +35,3 @@ add_screen_object(/atom/movable/screen/healths/robot, HUD_MOB_HEALTH, HUD_GROUP_INFO) add_screen_object(/atom/movable/screen/pull, HUD_MOB_PULL, HUD_GROUP_HOTKEYS, ui_style, ui_borg_pull) - -/datum/hud/robot/persistent_inventory_update(mob/viewer) - if(!mymob) - return - var/mob/living/silicon/robot/R = mymob - - var/mob/screenmob = viewer || R - if(!screenmob.hud_used) - return - - if(!screenmob.hud_used.hud_shown) - for(var/obj/item/I in R.held_items) - screenmob.client.screen -= I - return - - for(var/i in 1 to length(R.held_items)) - var/obj/item/I = R.held_items[i] - if(!I) - continue - var/atom/movable/screen/robot/module_slot/slot = screen_objects[HUD_KEY_CYBORG_MODULE(i)] - I.screen_loc = slot.screen_loc - screenmob.client.screen += I diff --git a/code/_onclick/hud/screen_objects/action_button.dm b/code/_onclick/hud/screen_objects/action_button.dm index 0782aabd5c0..358e0850875 100644 --- a/code/_onclick/hud/screen_objects/action_button.dm +++ b/code/_onclick/hud/screen_objects/action_button.dm @@ -213,7 +213,7 @@ if(!hud_used || !client) return - if(hud_used.hud_shown != HUD_STYLE_STANDARD) + if(hud_used.hud_version != HUD_STYLE_STANDARD) return for(var/datum/action/action as anything in actions) diff --git a/code/_onclick/hud/screen_objects/alert.dm b/code/_onclick/hud/screen_objects/alert.dm index 6a79bf6b0e9..81241a03abb 100644 --- a/code/_onclick/hud/screen_objects/alert.dm +++ b/code/_onclick/hud/screen_objects/alert.dm @@ -1203,10 +1203,11 @@ if(!screenmob.client) return FALSE var/list/alerts = mymob.alerts - if(!hud_shown) + if(hud_version != HUD_STYLE_STANDARD) for(var/i in 1 to alerts.len) screenmob.client.screen -= alerts[alerts[i]] return TRUE + var/user_pref_hud = ui_style2icon(mymob.client?.prefs?.read_preference(/datum/preference/choiced/ui_style)) for(var/i in 1 to length(alerts)) var/atom/movable/screen/alert/alert = alerts[alerts[i]] diff --git a/code/_onclick/hud/screen_objects/human.dm b/code/_onclick/hud/screen_objects/human.dm index b69ceb2143e..c605c4c4ef1 100644 --- a/code/_onclick/hud/screen_objects/human.dm +++ b/code/_onclick/hud/screen_objects/human.dm @@ -23,7 +23,6 @@ usr.hud_used.inventory_shown = TRUE usr.client.screen += targetmob.hud_used.screen_groups[HUD_GROUP_TOGGLEABLE_INVENTORY] - targetmob.hud_used.hidden_inventory_update(usr) update_appearance() /atom/movable/screen/human/toggle/update_icon_state() diff --git a/code/_onclick/hud/screen_objects/radial.dm b/code/_onclick/hud/screen_objects/radial.dm index d960724f75b..ce8df3369a4 100644 --- a/code/_onclick/hud/screen_objects/radial.dm +++ b/code/_onclick/hud/screen_objects/radial.dm @@ -119,16 +119,34 @@ GLOBAL_LIST_EMPTY(radial_menus) //If we swap to vis_contens inventory these will need a redo /datum/radial_menu/proc/check_screen_border(mob/user) var/atom/movable/AM = anchor - if(!istype(AM) || !AM.screen_loc) + if(!istype(AM)) return - if(AM in user.client.screen) - if(hudfix_method) - anchor = user - else - py_shift = 32 - restrict_to_dir(NORTH) //I was going to parse screen loc here but that's more effort than it's worth. - else if(hudfix_method && AM.loc) - anchor = get_atom_on_turf(anchor) + + var/in_screen = AM.screen_loc && (AM in user.client.screen) + if (!in_screen) + var/list/check_locs = AM.vis_locs.Copy() + var/i = 1 + while (i <= length(check_locs)) + var/atom/movable/other_check = check_locs[i] + i += 1 + if (!istype(other_check)) + continue + if (other_check.screen_loc && (other_check in user.client.screen)) + in_screen = TRUE + break + check_locs |= other_check.vis_locs + + if(!in_screen) + if(hudfix_method && AM.loc) + anchor = get_atom_on_turf(anchor) + return + + if(hudfix_method) + anchor = user + return + + py_shift = 32 + restrict_to_dir(NORTH) //I was going to parse screen loc here but that's more effort than it's worth. //Sets defaults //These assume 45 deg min_angle diff --git a/code/_onclick/hud/screen_objects/screen_objects.dm b/code/_onclick/hud/screen_objects/screen_objects.dm index 84f71ea788a..11accd552f5 100644 --- a/code/_onclick/hud/screen_objects/screen_objects.dm +++ b/code/_onclick/hud/screen_objects/screen_objects.dm @@ -219,10 +219,13 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen) // I hate this place /atom/movable/screen/inventory/MouseEntered(location, control, params) . = ..() - add_overlays() + if (usr == hud?.mymob) + add_overlays() /atom/movable/screen/inventory/MouseExited() ..() + if (usr != hud?.mymob) + return cut_overlay(object_overlay) QDEL_NULL(object_overlay) diff --git a/code/datums/storage/storage_interface.dm b/code/datums/storage/storage_interface.dm index 1f358af00ef..2e42e34a6ea 100644 --- a/code/datums/storage/storage_interface.dm +++ b/code/datums/storage/storage_interface.dm @@ -112,7 +112,7 @@ for(var/obj/item as anything in storage_contents) item.mouse_opacity = MOUSE_OPACITY_OPAQUE - item.screen_loc = "[current_x]:[screen_pixel_x],[current_y]:[screen_pixel_y]" + item.screen_loc = "[current_x]:[screen_pixel_x + item.base_pixel_x],[current_y]:[screen_pixel_y + item.base_pixel_y]" if(parent_storage.numerical_stacking) item.maptext = storage_contents[item] SET_PLANE(item, ABOVE_HUD_PLANE, our_turf) diff --git a/code/modules/mob/living/basic/basic.dm b/code/modules/mob/living/basic/basic.dm index 4463ac48069..99735029110 100644 --- a/code/modules/mob/living/basic/basic.dm +++ b/code/modules/mob/living/basic/basic.dm @@ -308,17 +308,6 @@ if (.) update_held_items() -/mob/living/basic/update_held_items() - . = ..() - if(isnull(client) || isnull(hud_used) || hud_used.hud_version == HUD_STYLE_NOHUD) - return - var/turf/our_turf = get_turf(src) - for(var/obj/item/held in held_items) - var/index = get_held_index_of_item(held) - SET_PLANE(held, ABOVE_HUD_PLANE, our_turf) - held.screen_loc = ui_hand_position(index) - client.screen |= held - /mob/living/basic/get_body_temp_heat_damage_limit() return maximum_survivable_temperature diff --git a/code/modules/mob/living/basic/drone/inventory.dm b/code/modules/mob/living/basic/drone/inventory.dm index acacdb0e265..8253fafb98a 100644 --- a/code/modules/mob/living/basic/drone/inventory.dm +++ b/code/modules/mob/living/basic/drone/inventory.dm @@ -58,7 +58,7 @@ if(equipping.pulledby) equipping.pulledby.stop_pulling() - equipping.screen_loc = null // will get moved if inventory is visible + hud_used?.update_inventory_slot(slot) equipping.forceMove(src) //This has to come before has_equipped is called. SET_PLANE_EXPLICIT(equipping, ABOVE_HUD_PLANE, src) diff --git a/code/modules/mob/living/basic/drone/visuals_icons.dm b/code/modules/mob/living/basic/drone/visuals_icons.dm index 59952d8d249..3714c27deca 100644 --- a/code/modules/mob/living/basic/drone/visuals_icons.dm +++ b/code/modules/mob/living/basic/drone/visuals_icons.dm @@ -22,18 +22,13 @@ update_inv_internal_storage() /mob/living/basic/drone/proc/update_inv_internal_storage() - if(internal_storage && client && hud_used?.hud_shown) - internal_storage.screen_loc = ui_drone_storage - client.screen += internal_storage - + hud_used?.update_inventory_slot(ITEM_SLOT_DEX_STORAGE) /mob/living/basic/drone/update_worn_head() remove_overlay(DRONE_HEAD_LAYER) + hud_used?.update_inventory_slot(ITEM_SLOT_HEAD) if(head) - if(client && hud_used?.hud_shown) - head.screen_loc = ui_drone_head - client.screen += head var/used_head_icon = 'icons/mob/clothing/head/utility.dmi' if(istype(head, /obj/item/clothing/mask)) used_head_icon = 'icons/mob/clothing/mask.dmi' diff --git a/code/modules/mob/living/basic/guardian/guardian_types/dextrous.dm b/code/modules/mob/living/basic/guardian/guardian_types/dextrous.dm index fc4ec678837..b3d37a28e9e 100644 --- a/code/modules/mob/living/basic/guardian/guardian_types/dextrous.dm +++ b/code/modules/mob/living/basic/guardian/guardian_types/dextrous.dm @@ -92,7 +92,7 @@ if(equipping.pulledby) equipping.pulledby.stop_pulling() - equipping.screen_loc = null // will get moved if inventory is visible + hud_used?.update_inventory_slot(slot) equipping.forceMove(src) SET_PLANE_EXPLICIT(equipping, ABOVE_HUD_PLANE, src) @@ -106,10 +106,7 @@ return ITEM_SLOT_DEX_STORAGE /mob/living/basic/guardian/dextrous/proc/update_inv_internal_storage() - if(isnull(internal_storage) || isnull(client) || !hud_used?.hud_shown) - return - internal_storage.screen_loc = ui_back - client.screen += internal_storage + hud_used?.update_inventory_slot(ITEM_SLOT_DEX_STORAGE) /mob/living/basic/guardian/dextrous/regenerate_icons() update_inv_internal_storage() diff --git a/code/modules/mob/living/carbon/alien/adult/adult_update_icons.dm b/code/modules/mob/living/carbon/alien/adult/adult_update_icons.dm index c4531313769..e85dc79f20c 100644 --- a/code/modules/mob/living/carbon/alien/adult/adult_update_icons.dm +++ b/code/modules/mob/living/carbon/alien/adult/adult_update_icons.dm @@ -77,7 +77,6 @@ . = ..() remove_overlay(HANDS_LAYER) var/list/hands = list() - var/obj/item/l_hand = get_item_for_held_index(1) if(l_hand) var/itm_state = l_hand.inhand_icon_state diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index e2b93ca0271..c296696d348 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -715,7 +715,6 @@ clear_mood_event("handcuffed") update_mob_action_buttons() //some of our action buttons might be unusable when we're handcuffed. update_worn_handcuffs() - update_hud_handcuffed() /mob/living/carbon/revive(full_heal_flags = NONE, excess_healing = 0, force_grab_ghost = FALSE) if(excess_healing) diff --git a/code/modules/mob/living/carbon/carbon_update_icons.dm b/code/modules/mob/living/carbon/carbon_update_icons.dm index 07f8d0e89ed..7280ef782a1 100644 --- a/code/modules/mob/living/carbon/carbon_update_icons.dm +++ b/code/modules/mob/living/carbon/carbon_update_icons.dm @@ -253,19 +253,6 @@ /mob/living/carbon/proc/get_held_overlays() var/list/hands = list() for(var/obj/item/I in held_items) - if(client && hud_used && hud_used.hud_version != HUD_STYLE_NOHUD) - I.screen_loc = ui_hand_position(get_held_index_of_item(I)) - client.screen += I - if(length(observers)) - for(var/mob/dead/observe as anything in observers) - if(observe.client && observe.client.eye == src) - observe.client.screen += I - else - observers -= observe - if(!observers.len) - observers = null - break - var/icon_file = I.lefthand_file if(IS_RIGHT_INDEX(get_held_index_of_item(I))) icon_file = I.righthand_file @@ -334,45 +321,31 @@ /mob/living/carbon/update_worn_mask() remove_overlay(FACEMASK_LAYER) + hud_used?.update_inventory_slot(ITEM_SLOT_MASK) if(!get_bodypart(BODY_ZONE_HEAD)) //Decapitated return - if(client && hud_used?.inv_slots[TOBITSHIFT(ITEM_SLOT_MASK) + 1]) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_MASK) + 1] - inv.update_appearance() - - if(wear_mask) - if(!(obscured_slots & HIDEMASK)) - overlays_standing[FACEMASK_LAYER] = wear_mask.build_worn_icon(default_layer = FACEMASK_LAYER, default_icon_file = 'icons/mob/clothing/mask.dmi', bodyshape = bodyshape) - update_hud_wear_mask(wear_mask) + if(wear_mask && !(obscured_slots & HIDEMASK)) + overlays_standing[FACEMASK_LAYER] = wear_mask.build_worn_icon(default_layer = FACEMASK_LAYER, default_icon_file = 'icons/mob/clothing/mask.dmi') + overlays_standing[FACEMASK_LAYER] = wear_mask.build_worn_icon(default_layer = FACEMASK_LAYER, default_icon_file = 'icons/mob/clothing/mask.dmi', bodyshape = bodyshape) apply_overlay(FACEMASK_LAYER) /mob/living/carbon/update_worn_neck() remove_overlay(NECK_LAYER) + hud_used?.update_inventory_slot(ITEM_SLOT_NECK) - if(client && hud_used?.inv_slots[TOBITSHIFT(ITEM_SLOT_NECK) + 1]) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_NECK) + 1] - inv.update_appearance() - - if(wear_neck) - if(!(obscured_slots & HIDENECK)) - overlays_standing[NECK_LAYER] = wear_neck.build_worn_icon(default_layer = NECK_LAYER, default_icon_file = 'icons/mob/clothing/neck.dmi', bodyshape = bodyshape) - update_hud_neck(wear_neck) - + if(wear_neck && !(obscured_slots & HIDENECK)) + overlays_standing[NECK_LAYER] = wear_neck.build_worn_icon(default_layer = NECK_LAYER, default_icon_file = 'icons/mob/clothing/neck.dmi', bodyshape = bodyshape) apply_overlay(NECK_LAYER) /mob/living/carbon/update_worn_back() remove_overlay(BACK_LAYER) - - if(client && hud_used?.inv_slots[TOBITSHIFT(ITEM_SLOT_BACK) + 1]) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_BACK) + 1] - inv.update_appearance() + hud_used?.update_inventory_slot(ITEM_SLOT_BACK) if(back) overlays_standing[BACK_LAYER] = back.build_worn_icon(default_layer = BACK_LAYER, default_icon_file = 'icons/mob/clothing/back.dmi', bodyshape = bodyshape) - update_hud_back(back) apply_overlay(BACK_LAYER) @@ -389,24 +362,20 @@ /mob/living/carbon/update_worn_head() remove_overlay(HEAD_LAYER) + hud_used?.update_inventory_slot(ITEM_SLOT_HEAD) if(!get_bodypart(BODY_ZONE_HEAD)) //Decapitated return - if(client && hud_used?.inv_slots[TOBITSHIFT(ITEM_SLOT_HEAD) + 1]) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_HEAD) + 1] - inv.update_appearance() - - if(head) - if(!(obscured_slots & HIDEHEADGEAR)) - overlays_standing[HEAD_LAYER] = head.build_worn_icon(default_layer = HEAD_LAYER, default_icon_file = 'icons/mob/clothing/head/default.dmi', bodyshape = bodyshape) - update_hud_head(head) + if(head && !(obscured_slots & HIDEHEADGEAR)) + overlays_standing[HEAD_LAYER] = head.build_worn_icon(default_layer = HEAD_LAYER, default_icon_file = 'icons/mob/clothing/head/default.dmi', bodyshape = bodyshape) apply_overlay(HEAD_LAYER) /mob/living/carbon/update_worn_handcuffs() remove_overlay(HANDCUFF_LAYER) + hud_used?.update_inventory_slot(ITEM_SLOT_HANDS) if(handcuffed) var/mutable_appearance/handcuff_overlay = mutable_appearance('icons/mob/simple/mob.dmi', "handcuff1", -HANDCUFF_LAYER) if(handcuffed.blocks_emissive != EMISSIVE_BLOCK_NONE) @@ -418,30 +387,6 @@ //mob HUD updates for items in our inventory -//update whether handcuffs appears on our hud. -/mob/living/carbon/proc/update_hud_handcuffed() - if(!hud_used) - return - - for(var/atom/movable/screen/inventory/hand/hand in hud_used.hand_slots) - hand.update_appearance() - -//update whether our head item appears on our hud. -/mob/living/carbon/proc/update_hud_head(obj/item/I) - return - -//update whether our mask item appears on our hud. -/mob/living/carbon/proc/update_hud_wear_mask(obj/item/I) - return - -//update whether our neck item appears on our hud. -/mob/living/carbon/proc/update_hud_neck(obj/item/I) - return - -//update whether our back item appears on our hud. -/mob/living/carbon/proc/update_hud_back(obj/item/I) - return - /// Overlays for the worn overlay so you can overlay while you overlay /// eg: ammo counters, primed grenade flashing, etc. /// "icon_file" is used automatically for inhands etc. to make sure it gets the right inhand file diff --git a/code/modules/mob/living/carbon/human/human_update_icons.dm b/code/modules/mob/living/carbon/human/human_update_icons.dm index dce12788dec..e15594a8eec 100644 --- a/code/modules/mob/living/carbon/human/human_update_icons.dm +++ b/code/modules/mob/living/carbon/human/human_update_icons.dm @@ -75,15 +75,10 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_worn_undersuit() remove_overlay(UNIFORM_LAYER) - - if(client && hud_used) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_ICLOTHING) + 1] - inv.update_icon() + hud_used?.update_inventory_slot(ITEM_SLOT_ICLOTHING) if(istype(w_uniform, /obj/item/clothing/under)) var/obj/item/clothing/under/uniform = w_uniform - update_hud_uniform(uniform) - if(HAS_TRAIT(uniform, TRAIT_NO_WORN_ICON) || (obscured_slots & HIDEJUMPSUIT)) return @@ -131,16 +126,12 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_worn_id() remove_overlay(ID_LAYER) - - if(client && hud_used) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_ID) + 1] - inv.update_icon() + hud_used?.update_inventory_slot(ITEM_SLOT_ID) var/mutable_appearance/id_overlay = overlays_standing[ID_LAYER] if(wear_id) var/obj/item/worn_item = wear_id - update_hud_id(worn_item) if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON)) return @@ -161,10 +152,7 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_worn_gloves() remove_overlay(GLOVES_LAYER) - - if(client && hud_used && hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_GLOVES) + 1]) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_GLOVES) + 1] - inv.update_icon() + hud_used?.update_inventory_slot(ITEM_SLOT_GLOVES) //Bloody hands begin if(isnull(gloves)) @@ -186,8 +174,6 @@ There are several things that need to be remembered: // Bloody hands end var/obj/item/worn_item = gloves - update_hud_gloves(worn_item) - if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON) || (obscured_slots & HIDEGLOVES)) return @@ -222,19 +208,14 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_worn_glasses() remove_overlay(GLASSES_LAYER) + hud_used?.update_inventory_slot(ITEM_SLOT_EYES) var/obj/item/bodypart/head/my_head = get_bodypart(BODY_ZONE_HEAD) if(isnull(my_head)) //decapitated return - if(client && hud_used) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_EYES) + 1] - inv.update_icon() - if(glasses) var/obj/item/worn_item = glasses - update_hud_glasses(worn_item) - if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON) || (obscured_slots & HIDEEYES)) return @@ -248,19 +229,14 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_worn_ears() remove_overlay(EARS_LAYER) + hud_used?.update_inventory_slot(ITEM_SLOT_EARS) var/obj/item/bodypart/head/my_head = get_bodypart(BODY_ZONE_HEAD) if(isnull(my_head)) //decapitated return - if(client && hud_used) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_EARS) + 1] - inv.update_icon() - if(ears) var/obj/item/worn_item = ears - update_hud_ears(worn_item) - if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON) || (obscured_slots & HIDEEARS)) return @@ -273,14 +249,10 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_worn_neck() remove_overlay(NECK_LAYER) - - if(client && hud_used && hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_NECK) + 1]) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_NECK) + 1] - inv.update_icon() + hud_used?.update_inventory_slot(ITEM_SLOT_NECK) if(wear_neck) var/obj/item/worn_item = wear_neck - update_hud_neck(wear_neck) if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON) || (obscured_slots & HIDENECK)) return @@ -296,17 +268,13 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_worn_shoes() remove_overlay(SHOES_LAYER) + hud_used?.update_inventory_slot(ITEM_SLOT_FEET) if(num_legs < 2) return - if(client && hud_used) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_FEET) + 1] - inv.update_icon() - if(shoes) var/obj/item/worn_item = shoes - update_hud_shoes(worn_item) if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON) || (obscured_slots & HIDESHOES)) return @@ -333,15 +301,10 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_suit_storage() remove_overlay(SUIT_STORE_LAYER) - - if(client && hud_used) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_SUITSTORE) + 1] - inv.update_icon() + hud_used?.update_inventory_slot(ITEM_SLOT_SUITSTORE) if(s_store) var/obj/item/worn_item = s_store - update_hud_s_store(worn_item) - if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON) || (obscured_slots & HIDESUITSTORAGE)) return @@ -353,14 +316,10 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_worn_head() remove_overlay(HEAD_LAYER) - if(client && hud_used && hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_HEAD) + 1]) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_HEAD) + 1] - inv.update_icon() + hud_used?.update_inventory_slot(ITEM_SLOT_HEAD) if(head) var/obj/item/worn_item = head - update_hud_head(worn_item) - if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON) || (obscured_slots & HIDEHEADGEAR)) return @@ -375,15 +334,10 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_worn_belt() remove_overlay(BELT_LAYER) - - if(client && hud_used) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_BELT) + 1] - inv.update_icon() + hud_used?.update_inventory_slot(ITEM_SLOT_BELT) if(belt) var/obj/item/worn_item = belt - update_hud_belt(worn_item) - if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON) || (obscured_slots & HIDEBELT)) return @@ -398,14 +352,10 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_worn_oversuit() remove_overlay(SUIT_LAYER) - - if(client && hud_used) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_OCLOTHING) + 1] - inv.update_icon() + hud_used?.update_inventory_slot(ITEM_SLOT_OCLOTHING) if(wear_suit) var/obj/item/worn_item = wear_suit - update_hud_wear_suit(worn_item) if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON)) return @@ -420,41 +370,20 @@ There are several things that need to be remembered: apply_overlay(SUIT_LAYER) /mob/living/carbon/human/update_pockets() - if(client && hud_used) - var/atom/movable/screen/inventory/inv - - inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_LPOCKET) + 1] - inv.update_icon() - inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_RPOCKET) + 1] - inv.update_icon() - - if(l_store) - l_store.screen_loc = ui_storage1 - if(hud_used.hud_shown) - client.screen += l_store - update_observer_view(l_store) - - if(r_store) - r_store.screen_loc = ui_storage2 - if(hud_used.hud_shown) - client.screen += r_store - update_observer_view(r_store) + if (hud_used) + hud_used.update_inventory_slot(ITEM_SLOT_LPOCKET) + hud_used.update_inventory_slot(ITEM_SLOT_RPOCKET) /mob/living/carbon/human/update_worn_mask() remove_overlay(FACEMASK_LAYER) + hud_used?.update_inventory_slot(ITEM_SLOT_MASK) var/obj/item/bodypart/head/my_head = get_bodypart(BODY_ZONE_HEAD) if(isnull(my_head)) //Decapitated return - if(client && hud_used && hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_MASK) + 1]) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_MASK) + 1] - inv.update_icon() - if(wear_mask) var/obj/item/worn_item = wear_mask - update_hud_wear_mask(worn_item) - if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON) || (obscured_slots & HIDEMASK)) return @@ -468,15 +397,11 @@ There are several things that need to be remembered: /mob/living/carbon/human/update_worn_back() remove_overlay(BACK_LAYER) - - if(client && hud_used && hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_BACK) + 1]) - var/atom/movable/screen/inventory/inv = hud_used.inv_slots[TOBITSHIFT(ITEM_SLOT_BACK) + 1] - inv.update_icon() + hud_used?.update_inventory_slot(ITEM_SLOT_BACK) if(back) var/obj/item/worn_item = back var/mutable_appearance/back_overlay - update_hud_back(worn_item) if(HAS_TRAIT(worn_item, TRAIT_NO_WORN_ICON)) return @@ -493,23 +418,10 @@ There are several things that need to be remembered: apply_overlay(BACK_LAYER) /mob/living/carbon/human/get_held_overlays() + hud_used?.update_inventory_slot(ITEM_SLOT_HANDS) var/list/hands = list() for(var/obj/item/worn_item in held_items) var/held_index = get_held_index_of_item(worn_item) - if(client && hud_used && hud_used.hud_version != HUD_STYLE_NOHUD) - worn_item.screen_loc = ui_hand_position(held_index) - client.screen += worn_item - if(observers?.len) - for(var/M in observers) - var/mob/dead/observe = M - if(observe.client && observe.client.eye == src) - observe.client.screen += worn_item - else - observers -= observe - if(!observers.len) - observers = null - break - var/t_state = worn_item.inhand_icon_state if(!t_state) t_state = worn_item.icon_state @@ -638,90 +550,6 @@ There are several things that need to be remembered: out += overlays_standing[i] return out - -//human HUD updates for items in our inventory - -/mob/living/carbon/human/proc/update_hud_uniform(obj/item/worn_item) - worn_item.screen_loc = ui_iclothing - if((client && hud_used) && (hud_used.inventory_shown && hud_used.hud_shown)) - client.screen += worn_item - update_observer_view(worn_item,TRUE) - -/mob/living/carbon/human/proc/update_hud_id(obj/item/worn_item) - worn_item.screen_loc = ui_id - if((client && hud_used?.hud_shown)) - client.screen += worn_item - update_observer_view(worn_item) - -/mob/living/carbon/human/proc/update_hud_gloves(obj/item/worn_item) - worn_item.screen_loc = ui_gloves - if((client && hud_used) && (hud_used.inventory_shown && hud_used.hud_shown)) - client.screen += worn_item - update_observer_view(worn_item,TRUE) - -/mob/living/carbon/human/proc/update_hud_glasses(obj/item/worn_item) - worn_item.screen_loc = ui_glasses - if((client && hud_used) && (hud_used.inventory_shown && hud_used.hud_shown)) - client.screen += worn_item - update_observer_view(worn_item,TRUE) - -/mob/living/carbon/human/proc/update_hud_ears(obj/item/worn_item) - worn_item.screen_loc = ui_ears - if((client && hud_used) && (hud_used.inventory_shown && hud_used.hud_shown)) - client.screen += worn_item - update_observer_view(worn_item,TRUE) - -/mob/living/carbon/human/proc/update_hud_shoes(obj/item/worn_item) - worn_item.screen_loc = ui_shoes - if((client && hud_used) && (hud_used.inventory_shown && hud_used.hud_shown)) - client.screen += worn_item - update_observer_view(worn_item,TRUE) - -/mob/living/carbon/human/proc/update_hud_s_store(obj/item/worn_item) - worn_item.screen_loc = ui_sstore1 - if(client && hud_used?.hud_shown) - client.screen += worn_item - update_observer_view(worn_item,TRUE) - -/mob/living/carbon/human/proc/update_hud_wear_suit(obj/item/worn_item) - worn_item.screen_loc = ui_oclothing - if((client && hud_used) && (hud_used.inventory_shown && hud_used.hud_shown)) - client.screen += worn_item - update_observer_view(worn_item,TRUE) - -/mob/living/carbon/human/proc/update_hud_belt(obj/item/worn_item) - belt.screen_loc = ui_belt - if(client && hud_used?.hud_shown) - client.screen += worn_item - update_observer_view(worn_item,TRUE) - -/mob/living/carbon/human/update_hud_head(obj/item/worn_item) - worn_item.screen_loc = ui_head - if((client && hud_used) && (hud_used.inventory_shown && hud_used.hud_shown)) - client.screen += worn_item - update_observer_view(worn_item,TRUE) - -//update whether our mask item appears on our hud. -/mob/living/carbon/human/update_hud_wear_mask(obj/item/worn_item) - worn_item.screen_loc = ui_mask - if((client && hud_used) && (hud_used.inventory_shown && hud_used.hud_shown)) - client.screen += worn_item - update_observer_view(worn_item,TRUE) - -//update whether our neck item appears on our hud. -/mob/living/carbon/human/update_hud_neck(obj/item/worn_item) - worn_item.screen_loc = ui_neck - if((client && hud_used) && (hud_used.inventory_shown && hud_used.hud_shown)) - client.screen += worn_item - update_observer_view(worn_item,TRUE) - -//update whether our back item appears on our hud. -/mob/living/carbon/human/update_hud_back(obj/item/worn_item) - worn_item.screen_loc = ui_back - if(client && hud_used?.hud_shown) - client.screen += worn_item - update_observer_view(worn_item, inventory = TRUE) - /* Does everything in relation to building the /mutable_appearance used in the mob's overlays list covers: @@ -838,21 +666,6 @@ generate/load female uniform sprites matching all previously decided variables else //No offsets or Unwritten number of hands return list("x" = 0, "y" = 0)//Handle held offsets -/mob/living/carbon/human/proc/update_observer_view(obj/item/worn_item, inventory) - if(observers?.len) - for(var/M in observers) - var/mob/dead/observe = M - if(observe.client && observe.client.eye == src) - if(observe.hud_used) - if(inventory && !observe.hud_used.inventory_shown) - continue - observe.client.screen += worn_item - else - observers -= observe - if(!observers.len) - observers = null - break - /mob/living/carbon/human/update_body(is_creating = FALSE) remove_overlay(BODY_LAYER) diff --git a/code/modules/mob/living/carbon/inventory.dm b/code/modules/mob/living/carbon/inventory.dm index 1f761d9dfd2..fcf292496f2 100644 --- a/code/modules/mob/living/carbon/inventory.dm +++ b/code/modules/mob/living/carbon/inventory.dm @@ -112,8 +112,7 @@ if(equipping.pulledby) equipping.pulledby.stop_pulling() - equipping.screen_loc = null - client?.screen -= equipping + hud_used?.update_inventory_slot(slot) for(var/mob/dead/observe as anything in observers) observe.client?.screen -= equipping diff --git a/code/modules/mob/living/silicon/robot/inventory.dm b/code/modules/mob/living/silicon/robot/inventory.dm index ecab5e952ce..e5e3e6f867d 100644 --- a/code/modules/mob/living/silicon/robot/inventory.dm +++ b/code/modules/mob/living/silicon/robot/inventory.dm @@ -73,23 +73,6 @@ deselect_module(module_num) playsound_local(src, SFX_RUSTLE, 40, TRUE) -/mob/living/silicon/robot/update_held_items() - . = ..() - if(isnull(client) || isnull(hud_used) || hud_used.hud_version == HUD_STYLE_NOHUD) - return - - var/turf/our_turf = get_turf(src) - for (var/held_index in 1 to length(held_items)) - var/obj/item/held = held_items[held_index] - if (!held) - continue - SET_PLANE(held, ABOVE_HUD_PLANE, our_turf) - var/atom/movable/screen/robot/module_slot/slot = hud_used.screen_objects[HUD_KEY_CYBORG_MODULE(held_index)] - if (!slot) //?? - continue - held.screen_loc = slot.screen_loc - client.screen |= held - /mob/living/silicon/robot/put_in_hand_check(obj/item/item_equipping) return (item_equipping in model.modules) @@ -143,7 +126,7 @@ audible_message(span_warning("[src] sounds an alarm! \"SYSTEM ERROR: Module [module_num] OFFLINE.\"")) to_chat(src, span_userdanger("SYSTEM ERROR: Module [module_num] OFFLINE.")) - var/atom/movable/screen/robot/module_slot/module = hud_used?.screen_objects[HUD_KEY_CYBORG_MODULE(module_num)] + var/atom/movable/screen/robot/module_slot/module = hud_used?.screen_objects[HUD_KEY_HAND_SLOT(module_num)] if(module) module.icon_state = "[module.base_icon_state] +b" return TRUE @@ -188,7 +171,7 @@ disabled_modules &= ~BORG_MODULE_THREE_DISABLED to_chat(src, span_notice("ERROR CLEARED: Module [module_num] back online.")) - var/atom/movable/screen/robot/module_slot/module = hud_used?.screen_objects[HUD_KEY_CYBORG_MODULE(module_num)] + var/atom/movable/screen/robot/module_slot/module = hud_used?.screen_objects[HUD_KEY_HAND_SLOT(module_num)] if(module) module.icon_state = module.base_icon_state return TRUE @@ -270,7 +253,7 @@ if(is_invalid_module_number(module_num) || !held_items[module_num]) //If the slot number is invalid, or there's nothing there, we have nothing to equip return FALSE - var/atom/movable/screen/robot/module_slot/module = hud_used?.screen_objects[HUD_KEY_CYBORG_MODULE(module_num)] + var/atom/movable/screen/robot/module_slot/module = hud_used?.screen_objects[HUD_KEY_HAND_SLOT(module_num)] if(module && module_active != held_items[module_num]) module.icon_state = "[module.base_icon_state] +a" module_active = held_items[module_num] @@ -283,7 +266,7 @@ * * module_num - the slot number being de-selected */ /mob/living/silicon/robot/proc/deselect_module(module_num) - var/atom/movable/screen/robot/module_slot/module = hud_used?.screen_objects[HUD_KEY_CYBORG_MODULE(module_num)] + var/atom/movable/screen/robot/module_slot/module = hud_used?.screen_objects[HUD_KEY_HAND_SLOT(module_num)] if(module) module.icon_state = module.base_icon_state if(module_active) diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index c3bf4d072f3..20d211a699e 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -475,17 +475,6 @@ . = ..() update_held_items() -/mob/living/simple_animal/update_held_items() - . = ..() - if(!client || !hud_used || hud_used.hud_version == HUD_STYLE_NOHUD) - return - var/turf/our_turf = get_turf(src) - for(var/obj/item/I in held_items) - var/index = get_held_index_of_item(I) - SET_PLANE(I, ABOVE_HUD_PLANE, our_turf) - I.screen_loc = ui_hand_position(index) - client.screen |= I - //ANIMAL RIDING /mob/living/simple_animal/user_buckle_mob(mob/living/M, mob/user, check_loc = TRUE) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 4cbaa4ae6b0..09208558022 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -939,14 +939,8 @@ var/previous_index = active_hand_index active_hand_index = held_index - if(hud_used) - var/atom/movable/screen/inventory/hand/held_location - held_location = hud_used.hand_slots[previous_index] - if(!isnull(held_location)) - held_location.update_appearance() - held_location = hud_used.hand_slots[held_index] - if(!isnull(held_location)) - held_location.update_appearance() + hud_used?.update_inventory_slot(ITEM_SLOT_HANDS, previous_index) + hud_used?.update_inventory_slot(ITEM_SLOT_HANDS, held_index) return TRUE /mob/proc/activate_hand(selected_hand) diff --git a/code/modules/mob/mob_update_icons.dm b/code/modules/mob/mob_update_icons.dm index bbd617f97f7..11da749e89a 100644 --- a/code/modules/mob/mob_update_icons.dm +++ b/code/modules/mob/mob_update_icons.dm @@ -66,6 +66,7 @@ /mob/proc/update_held_items() SHOULD_CALL_PARENT(TRUE) SEND_SIGNAL(src, COMSIG_MOB_UPDATE_HELD_ITEMS) + hud_used?.update_inventory_slot(ITEM_SLOT_HANDS) ///Updates the mask overlay & HUD element. /mob/proc/update_worn_mask() diff --git a/code/modules/surgery/bodyparts/dismemberment.dm b/code/modules/surgery/bodyparts/dismemberment.dm index 4341530566f..acc1468e506 100644 --- a/code/modules/surgery/bodyparts/dismemberment.dm +++ b/code/modules/surgery/bodyparts/dismemberment.dm @@ -198,9 +198,7 @@ var/obj/item/lost_cuffs = arm_owner.handcuffed arm_owner.set_handcuffed(null) arm_owner.dropItemToGround(lost_cuffs, force = TRUE) - if(arm_owner.hud_used) - var/atom/movable/screen/inventory/hand/associated_hand = arm_owner.hud_used.hand_slots[held_index] - associated_hand?.update_appearance() + arm_owner.hud_used?.update_inventory_slot(ITEM_SLOT_HANDS, held_index) if(arm_owner.num_hands == 0) arm_owner.dropItemToGround(arm_owner.gloves, force = TRUE) arm_owner.update_worn_gloves() //to remove the bloody hands overlay diff --git a/code/modules/surgery/bodyparts/parts.dm b/code/modules/surgery/bodyparts/parts.dm index 1eee423e1a9..6c52f99300d 100644 --- a/code/modules/surgery/bodyparts/parts.dm +++ b/code/modules/surgery/bodyparts/parts.dm @@ -207,12 +207,7 @@ old_owner.on_lost_hand(src) if(interaction_modifier != 0 || click_cd_modifier != 1) old_owner.remove_status_effect(/datum/status_effect/arm_speed_penalty, held_index) - - if(!old_owner.hud_used) - return - - var/atom/movable/screen/inventory/hand/hand = old_owner.hud_used.hand_slots[held_index] - hand?.update_appearance() + old_owner.hud_used?.update_inventory_slot(ITEM_SLOT_HANDS, held_index) /// We need to add hand hud items and appearance, so do that here /obj/item/bodypart/arm/apply_ownership(mob/living/carbon/new_owner) @@ -226,12 +221,7 @@ new_owner.on_added_hand(src, held_index) if(interaction_modifier != 0 || click_cd_modifier != 1) new_owner.apply_status_effect(/datum/status_effect/arm_speed_penalty, held_index, interaction_modifier, click_cd_modifier) - - if(!new_owner.hud_used) - return - - var/atom/movable/screen/inventory/hand/hand = new_owner.hud_used.hand_slots[held_index] - hand?.update_appearance() + new_owner.hud_used?.update_inventory_slot(ITEM_SLOT_HANDS, held_index) /obj/item/bodypart/arm/set_disabled(new_disabled) . = ..() @@ -247,10 +237,7 @@ owner.dropItemToGround(owner.get_item_for_held_index(held_index)) else if(!bodypart_disabled) owner.set_usable_hands(owner.usable_hands + 1) - - if(owner.hud_used) - var/atom/movable/screen/inventory/hand/hand_screen_object = owner.hud_used.hand_slots[held_index] - hand_screen_object?.update_appearance() + owner.hud_used?.update_inventory_slot(ITEM_SLOT_HANDS, held_index) /obj/item/bodypart/arm/animate_atom_living(mob/living/owner) var/mob/living/basic/slapper = ..() diff --git a/code/modules/unit_tests/unequip_defib.dm b/code/modules/unit_tests/unequip_defib.dm index 910cf599af2..6af213dec12 100644 --- a/code/modules/unit_tests/unequip_defib.dm +++ b/code/modules/unit_tests/unequip_defib.dm @@ -12,7 +12,7 @@ usr = dummy // mouse drop still uses usr - defib.MouseDrop(dummy.hud_used.hand_slots[1]) + defib.MouseDrop(dummy.hud_used.screen_objects[HUD_KEY_HAND_SLOT(1)]) if(!dummy.is_holding(defib)) TEST_FAIL("The dummy failed to remove the defib from their back via mouse drop.")