From 61ff2cbbce3cc22eb95f21c2ff702a002d0f613d Mon Sep 17 00:00:00 2001 From: Rykka Date: Sun, 10 May 2020 08:09:24 -0400 Subject: [PATCH] Earlyport Hover Inventory and Body Indicators The body zone selector now indicates which body part you are about to select when hovered over, and the hover inventory indicator basically shows where you are trying to put an item, and then shows an item ghost in red or green, giving visual feedback as to if that item will go in the slot or not. Gifs of this in action: ![https://i.imgur.com/MTi7Kpn.gif](https://i.imgur.com/MTi7Kpn.gif) Body Selection parts. ![https://i.imgur.com/KbLqWKy.gif](https://i.imgur.com/KbLqWKy.gif) Inventory Icon Overlays! Credit goes to @ShadowLarkens for original port to Paradise and assistance with port. --- code/_onclick/hud/human.dm | 3 + code/_onclick/hud/screen_objects.dm | 135 +++++++++++++----- .../objects/items/weapons/storage/internal.dm | 2 +- code/modules/clothing/clothing.dm | 2 +- code/modules/clothing/gloves/arm_guards.dm | 2 +- code/modules/clothing/gloves/gauntlets.dm | 2 +- code/modules/clothing/masks/monitor.dm | 2 +- code/modules/clothing/shoes/magboots.dm | 2 +- code/modules/clothing/suits/armor.dm | 2 +- 9 files changed, 111 insertions(+), 41 deletions(-) diff --git a/code/_onclick/hud/human.dm b/code/_onclick/hud/human.dm index b372ec6882..5877e49b92 100644 --- a/code/_onclick/hud/human.dm +++ b/code/_onclick/hud/human.dm @@ -28,6 +28,7 @@ inv_box.icon = ui_style inv_box.color = ui_color inv_box.alpha = ui_alpha + inv_box.hud = src var/list/slot_data = hud_data.gear[gear_slot] inv_box.name = gear_slot @@ -192,6 +193,7 @@ using.screen_loc = ui_swaphand1 using.color = ui_color using.alpha = ui_alpha + using.hud = src src.adding += using using = new /obj/screen/inventory() @@ -201,6 +203,7 @@ using.screen_loc = ui_swaphand2 using.color = ui_color using.alpha = ui_alpha + using.hud = src src.adding += using if(hud_data.has_resist) diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index f9e8506108..aede02fc1d 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -31,7 +31,36 @@ /obj/screen/inventory var/slot_id //The indentifier for the slot. It has nothing to do with ID cards. + var/list/object_overlays = list() // Required for inventory/screen overlays. +/obj/screen/inventory/MouseEntered() + ..() + add_overlays() + +/obj/screen/inventory/MouseExited() + ..() + cut_overlay(object_overlays) + object_overlays.Cut() + +/obj/screen/inventory/proc/add_overlays() + var/mob/user = hud.mymob + + if(hud && user && slot_id) + var/obj/item/holding = user.get_active_hand() + + if(!holding || user.get_equipped_item(slot_id)) + return + + var/image/item_overlay = image(holding) + item_overlay.alpha = 92 + + if(!holding.mob_can_equip(user, slot_id, disable_warning = TRUE)) + item_overlay.color = "#ff0000" + else + item_overlay.color = "#00ff00" + + object_overlays += item_overlay + add_overlay(object_overlays) /obj/screen/close name = "close" @@ -102,78 +131,116 @@ icon_state = "zone_sel" screen_loc = ui_zonesel var/selecting = BP_TORSO + var/static/list/hover_overlays_cache = list() + var/hovering_choice + var/mutable_appearance/selecting_appearance /obj/screen/zone_sel/Click(location, control,params) + if(isobserver(usr)) + return + var/list/PL = params2list(params) var/icon_x = text2num(PL["icon-x"]) var/icon_y = text2num(PL["icon-y"]) - var/old_selecting = selecting //We're only going to update_icon() if there's been a change + var/choice = get_zone_at(icon_x, icon_y) + if(!choice) + return 1 + return set_selected_zone(choice, usr) + +/obj/screen/zone_sel/MouseEntered(location, control, params) + MouseMove(location, control, params) + +/obj/screen/zone_sel/MouseMove(location, control, params) + if(isobserver(usr)) + return + + var/list/PL = params2list(params) + var/icon_x = text2num(PL["icon-x"]) + var/icon_y = text2num(PL["icon-y"]) + var/choice = get_zone_at(icon_x, icon_y) + + if(hovering_choice == choice) + return + vis_contents -= hover_overlays_cache[hovering_choice] + hovering_choice = choice + + var/obj/effect/overlay/zone_sel/overlay_object = hover_overlays_cache[choice] + if(!overlay_object) + overlay_object = new + overlay_object.icon_state = "[choice]" + hover_overlays_cache[choice] = overlay_object + vis_contents += overlay_object + + +/obj/effect/overlay/zone_sel + icon = 'icons/mob/zone_sel.dmi' + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + alpha = 128 + anchored = TRUE + layer = LAYER_HUD_ABOVE + plane = PLANE_PLAYER_HUD_ABOVE + +/obj/screen/zone_sel/MouseExited(location, control, params) + if(!isobserver(usr) && hovering_choice) + vis_contents -= hover_overlays_cache[hovering_choice] + hovering_choice = null + +/obj/screen/zone_sel/proc/get_zone_at(icon_x, icon_y) switch(icon_y) if(1 to 3) //Feet switch(icon_x) if(10 to 15) - selecting = BP_R_FOOT + return BP_R_FOOT if(17 to 22) - selecting = BP_L_FOOT - else - return 1 + return BP_L_FOOT if(4 to 9) //Legs switch(icon_x) if(10 to 15) - selecting = BP_R_LEG + return BP_R_LEG if(17 to 22) - selecting = BP_L_LEG - else - return 1 + return BP_L_LEG if(10 to 13) //Hands and groin switch(icon_x) if(8 to 11) - selecting = BP_R_HAND + return BP_R_HAND if(12 to 20) - selecting = BP_GROIN + return BP_GROIN if(21 to 24) - selecting = BP_L_HAND - else - return 1 + return BP_L_HAND if(14 to 22) //Chest and arms to shoulders switch(icon_x) if(8 to 11) - selecting = BP_R_ARM + return BP_R_ARM if(12 to 20) - selecting = BP_TORSO + return BP_TORSO if(21 to 24) - selecting = BP_L_ARM - else - return 1 + return BP_L_ARM if(23 to 30) //Head, but we need to check for eye or mouth if(icon_x in 12 to 20) - selecting = BP_HEAD switch(icon_y) if(23 to 24) if(icon_x in 15 to 17) - selecting = O_MOUTH + return O_MOUTH if(26) //Eyeline, eyes are on 15 and 17 if(icon_x in 14 to 18) - selecting = O_EYES + return O_EYES if(25 to 27) if(icon_x in 15 to 17) - selecting = O_EYES + return O_EYES + return BP_HEAD - if(old_selecting != selecting) - update_icon() - return 1 - -/obj/screen/zone_sel/proc/set_selected_zone(bodypart) - var/old_selecting = selecting - selecting = bodypart - if(old_selecting != selecting) +/obj/screen/zone_sel/proc/set_selected_zone(choice, mob/user) + if(isobserver(user)) + return + if(choice != selecting) + selecting = choice update_icon() /obj/screen/zone_sel/update_icon() - overlays.Cut() - overlays += image('icons/mob/zone_sel.dmi', "[selecting]") - + cut_overlay(selecting_appearance) + selecting_appearance = mutable_appearance('icons/mob/zone_sel.dmi', "[selecting]") + add_overlay(selecting_appearance) /obj/screen/Click(location, control, params) if(!usr) return 1 diff --git a/code/game/objects/items/weapons/storage/internal.dm b/code/game/objects/items/weapons/storage/internal.dm index 6fbbedf069..ddb7e873e6 100644 --- a/code/game/objects/items/weapons/storage/internal.dm +++ b/code/game/objects/items/weapons/storage/internal.dm @@ -18,7 +18,7 @@ /obj/item/weapon/storage/internal/attack_hand() return //make sure this is never picked up -/obj/item/weapon/storage/internal/mob_can_equip() +/obj/item/weapon/storage/internal/mob_can_equip(M as mob, slot, disable_warning = 0) return 0 //make sure this is never picked up //Helper procs to cleanly implement internal storages - storage items that provide inventory slots for other items. diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index 628547ab45..2bb6022180 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -59,7 +59,7 @@ user.recalculate_vis() //BS12: Species-restricted clothing check. -/obj/item/clothing/mob_can_equip(M as mob, slot) +/obj/item/clothing/mob_can_equip(M as mob, slot, disable_warning = 0) //if we can't equip the item anyway, don't bother with species_restricted (cuts down on spam) if (!..()) diff --git a/code/modules/clothing/gloves/arm_guards.dm b/code/modules/clothing/gloves/arm_guards.dm index 558f855545..791bb0a10b 100644 --- a/code/modules/clothing/gloves/arm_guards.dm +++ b/code/modules/clothing/gloves/arm_guards.dm @@ -7,7 +7,7 @@ w_class = ITEMSIZE_NORMAL drop_sound = 'sound/items/drop/metalshield.ogg' -/obj/item/clothing/gloves/arm_guard/mob_can_equip(var/mob/living/carbon/human/H, slot) +/obj/item/clothing/gloves/arm_guard/mob_can_equip(var/mob/living/carbon/human/H, slot, disable_warning = 0) if(..()) //This will only run if no other problems occured when equiping. if(H.wear_suit) if(H.wear_suit.body_parts_covered & ARMS) diff --git a/code/modules/clothing/gloves/gauntlets.dm b/code/modules/clothing/gloves/gauntlets.dm index 8807fb93ad..eb5d05c909 100644 --- a/code/modules/clothing/gloves/gauntlets.dm +++ b/code/modules/clothing/gloves/gauntlets.dm @@ -14,7 +14,7 @@ punch_force = 5 var/obj/item/clothing/gloves/gloves = null //Undergloves -/obj/item/clothing/gloves/gauntlets/mob_can_equip(mob/user) +/obj/item/clothing/gloves/gauntlets/mob_can_equip(mob/user, slot, disable_warning = 0) var/mob/living/carbon/human/H = user if(H.gloves) gloves = H.gloves diff --git a/code/modules/clothing/masks/monitor.dm b/code/modules/clothing/masks/monitor.dm index 230f224d09..be337c9067 100644 --- a/code/modules/clothing/masks/monitor.dm +++ b/code/modules/clothing/masks/monitor.dm @@ -33,7 +33,7 @@ canremove = 1 return ..() -/obj/item/clothing/mask/monitor/mob_can_equip(var/mob/living/carbon/human/user, var/slot) +/obj/item/clothing/mask/monitor/mob_can_equip(var/mob/living/carbon/human/user, var/slot, disable_warning = FALSE) if (!..()) return 0 if(istype(user)) diff --git a/code/modules/clothing/shoes/magboots.dm b/code/modules/clothing/shoes/magboots.dm index 57b8a0911a..816c5052fc 100644 --- a/code/modules/clothing/shoes/magboots.dm +++ b/code/modules/clothing/shoes/magboots.dm @@ -42,7 +42,7 @@ user.update_inv_shoes() //so our mob-overlays update user.update_action_buttons() -/obj/item/clothing/shoes/magboots/mob_can_equip(mob/user, slot) +/obj/item/clothing/shoes/magboots/mob_can_equip(mob/user, slot, disable_warning = FALSE) var/mob/living/carbon/human/H = user if(H.shoes) diff --git a/code/modules/clothing/suits/armor.dm b/code/modules/clothing/suits/armor.dm index 691f53de5a..3920ddd636 100644 --- a/code/modules/clothing/suits/armor.dm +++ b/code/modules/clothing/suits/armor.dm @@ -520,7 +520,7 @@ |ACCESSORY_SLOT_ARMOR_M) blood_overlay_type = "armor" -/obj/item/clothing/suit/armor/pcarrier/mob_can_equip(var/mob/living/carbon/human/H, slot) +/obj/item/clothing/suit/armor/pcarrier/mob_can_equip(var/mob/living/carbon/human/H, slot, disable_warning = FALSE) if(..()) //This will only run if no other problems occured when equiping. if(H.gloves) if(H.gloves.body_parts_covered & ARMS)