Ports Hover Overlays (#8870)

* HUD Overlay

* finishes up the port

* fixes
This commit is contained in:
Geeves
2020-05-19 00:28:23 +02:00
committed by GitHub
parent d7231e6ee5
commit 3ec99c8d64
13 changed files with 144 additions and 45 deletions
+7 -2
View File
@@ -28,6 +28,7 @@
inv_box.layer = SCREEN_LAYER
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
@@ -155,7 +156,8 @@
using.alpha = ui_alpha
src.adding += using
inv_box = new /obj/screen/inventory()
inv_box = new /obj/screen/inventory/hand()
inv_box.hud = src
inv_box.name = BP_R_HAND
inv_box.icon = ui_style
inv_box.icon_state = "r_hand_inactive"
@@ -170,7 +172,8 @@
src.r_hand_hud_object = inv_box
src.adding += inv_box
inv_box = new /obj/screen/inventory()
inv_box = new /obj/screen/inventory/hand()
inv_box.hud = src
inv_box.name = BP_L_HAND
inv_box.icon = ui_style
inv_box.icon_state = "l_hand_inactive"
@@ -192,6 +195,7 @@
using.layer = SCREEN_LAYER
using.color = ui_color
using.alpha = ui_alpha
using.hud = src
src.adding += using
using = new /obj/screen/inventory()
@@ -202,6 +206,7 @@
using.layer = SCREEN_LAYER
using.color = ui_color
using.alpha = ui_alpha
using.hud = src
src.adding += using
if(hud_data.has_resist)
+115 -33
View File
@@ -12,6 +12,7 @@
layer = SCREEN_LAYER
unacidable = 1
var/obj/master = null //A reference to the object in the slot. Grabs or items, generally.
var/datum/hud/hud = null // A reference to the owner HUD, if any.
appearance_flags = NO_CLIENT_COLOR
/obj/screen/Destroy(force = FALSE)
@@ -29,8 +30,34 @@
/obj/screen/inventory
var/slot_id //The indentifier for the slot. It has nothing to do with ID cards.
var/slot_id //The identifier 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"
@@ -101,77 +128,115 @@
icon_state = "zone_sel"
screen_loc = ui_zonesel
var/selecting = BP_CHEST
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 = 0
alpha = 128
anchored = TRUE
layer = SCREEN_LAYER + 0.1
/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_CHEST
return BP_CHEST
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 = BP_MOUTH
return BP_MOUTH
if(26) //Eyeline, eyes are on 15 and 17
if(icon_x in 14 to 18)
selecting = BP_EYES
return BP_EYES
if(25 to 27)
if(icon_x in 15 to 17)
selecting = BP_EYES
return BP_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()
cut_overlays()
add_overlay(image('icons/mob/zone_sel.dmi', "[selecting]"))
selecting_appearance = mutable_appearance('icons/mob/zone_sel.dmi', "[selecting]")
add_overlay(selecting_appearance)
/obj/screen/Click(location, control, params)
if(!usr) return 1
@@ -338,3 +403,20 @@
usr.m_intent = "run"
update_move_icon(usr)
// Hand slots are special to handle the handcuffs overlay
/obj/screen/inventory/hand
var/image/handcuff_overlay
/obj/screen/inventory/hand/update_icon()
..()
if(!hud)
return
if(!handcuff_overlay)
var/state = (hud.l_hand_hud_object == src) ? "l_hand_hud_handcuffs" : "r_hand_hud_handcuffs"
handcuff_overlay = image("icon"='icons/mob/screen_gen.dmi', "icon_state" = state)
overlays.Cut()
if(hud.mymob && iscarbon(hud.mymob))
var/mob/living/carbon/C = hud.mymob
if(C.handcuffed)
overlays |= handcuff_overlay
@@ -62,7 +62,7 @@
..()
update_icon()
/obj/item/material/twohanded/mob_can_equip(M as mob, slot)
/obj/item/material/twohanded/mob_can_equip(M, slot, disable_warning = FALSE)
//Cannot equip wielded items.
if(wielded)
to_chat(M, "<span class='warning'>Unwield the [base_name] first!</span>")
@@ -27,7 +27,7 @@
allow_quick_empty = TRUE
empty_delay = 0.5 SECOND
/obj/item/storage/backpack/mob_can_equip(M as mob, slot)
/obj/item/storage/backpack/mob_can_equip(M as mob, slot, disable_warning = FALSE)
//if we can't equip the item anyway, don't bother with species_restricted (cuts down on spam)
if (!..())
@@ -17,7 +17,7 @@
/obj/item/storage/internal/attack_hand()
return //make sure this is never picked up
/obj/item/storage/internal/mob_can_equip()
/obj/item/storage/internal/mob_can_equip(M, slot, disable_warning = FALSE)
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.
+2 -2
View File
@@ -57,7 +57,7 @@
return 0
//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 = FALSE)
//if we can't equip the item anyway, don't bother with species_restricted (cuts down on spam)
if (!..())
@@ -381,7 +381,7 @@
species_restricted -= "Vaurca"
return
/obj/item/clothing/gloves/mob_can_equip(mob/user, slot)
/obj/item/clothing/gloves/mob_can_equip(mob/user, slot, disable_warning = FALSE)
var/mob/living/carbon/human/H = user
if(slot && slot == slot_gloves)
if(istype(H.gloves, /obj/item/clothing/ring))
+1 -1
View File
@@ -9,7 +9,7 @@
siemens_coefficient = 0.35
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)
+1 -1
View File
@@ -56,7 +56,7 @@
else
return 0
/obj/item/clothing/shoes/magboots/mob_can_equip(mob/user)
/obj/item/clothing/shoes/magboots/mob_can_equip(mob/user, slot, disable_warning = FALSE)
var/mob/living/carbon/human/H = user
if(H.shoes)
+1 -1
View File
@@ -106,7 +106,7 @@
item_state = initial(item_state)
update_held_icon()
/obj/item/pickaxe/mob_can_equip(M, slot)
/obj/item/pickaxe/mob_can_equip(M, slot, disable_warning = FALSE)
//Cannot equip wielded items.
if(wielded)
to_chat(M, SPAN_WARNING("Unwield the [initial(name)] first!"))
@@ -1056,6 +1056,11 @@ There are several things that need to be remembered:
if(hud_used)
hud_used.hidden_inventory_update() //Updates the screenloc of the items on the 'other' inventory bar
//update whether handcuffs appears on our hud.
/mob/living/carbon/proc/update_hud_handcuffed()
if(hud_used && hud_used.l_hand_hud_object && hud_used.r_hand_hud_object)
hud_used.l_hand_hud_object.update_icon()
hud_used.r_hand_hud_object.update_icon()
/mob/living/carbon/human/update_inv_handcuffed(var/update_icons=1)
if (QDELING(src))
@@ -1077,6 +1082,7 @@ There are several things that need to be remembered:
else
overlays_raw[HANDCUFF_LAYER] = null
update_hud_handcuffed()
if(update_icons)
update_icons()
+2 -2
View File
@@ -748,8 +748,8 @@
if (!QDELETED(src))
qdel(src)
/obj/item/offhand/mob_can_equip(var/mob/M, slot)
return FALSE
/obj/item/offhand/mob_can_equip(var/mob/M, slot, disable_warning = FALSE)
return FALSE
/obj/item/gun/Destroy()
if (istype(pin))
+6
View File
@@ -0,0 +1,6 @@
author: Geeves
delete-after: True
changes:
- rscadd: "Ported inventory slot and zone select hover overlays from Polaris."
Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B