From b9c03fe3f1cec5c26aac4bc8aa00bc2c6d6d3ec4 Mon Sep 17 00:00:00 2001 From: Atermonera Date: Mon, 11 May 2020 16:51:12 -0700 Subject: [PATCH 1/2] Port Hover Inventory and Body Indicators --- code/_onclick/hud/screen_objects.dm | 53 +++++++++++ .../objects/items/weapons/storage/internal.dm | 93 +++++++++++++++++++ 2 files changed, 146 insertions(+) diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index ab6985bdbdc..d451060c7fc 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -35,6 +35,7 @@ /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. +<<<<<<< HEAD /obj/screen/inventory/MouseEntered() ..() @@ -62,6 +63,35 @@ else item_overlay.color = "#00ff00" +======= + +/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" + +>>>>>>> eb8ad57... Merge pull request #7135 from Rykka-Stormheart/shep-dev-hover-overlays object_overlays += item_overlay add_overlay(object_overlays) @@ -142,6 +172,8 @@ if(isobserver(usr)) return +<<<<<<< HEAD +======= var/list/PL = params2list(params) var/icon_x = text2num(PL["icon-x"]) var/icon_y = text2num(PL["icon-y"]) @@ -154,6 +186,24 @@ /obj/screen/zone_sel/MouseEntered(location, control, params) MouseMove(location, control, params) +/obj/screen/zone_sel/MouseMove(location, control, params) + if(isobserver(usr)) + return + +>>>>>>> eb8ad57... Merge pull request #7135 from Rykka-Stormheart/shep-dev-hover-overlays + 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) +<<<<<<< HEAD + 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 @@ -163,6 +213,9 @@ var/icon_y = text2num(PL["icon-y"]) var/choice = get_zone_at(icon_x, icon_y) +======= + +>>>>>>> eb8ad57... Merge pull request #7135 from Rykka-Stormheart/shep-dev-hover-overlays if(hovering_choice == choice) return vis_contents -= hover_overlays_cache[hovering_choice] diff --git a/code/game/objects/items/weapons/storage/internal.dm b/code/game/objects/items/weapons/storage/internal.dm index 00d6f79402a..b4415a5342e 100644 --- a/code/game/objects/items/weapons/storage/internal.dm +++ b/code/game/objects/items/weapons/storage/internal.dm @@ -1,3 +1,4 @@ +<<<<<<< HEAD //A storage item intended to be used by other items to provide storage functionality. //Types that use this should consider overriding emp_act() and hear_talk(), unless they shield their contents somehow. /obj/item/weapon/storage/internal @@ -88,3 +89,95 @@ /obj/item/weapon/storage/internal/Adjacent(var/atom/neighbor) return master_item.Adjacent(neighbor) +======= +//A storage item intended to be used by other items to provide storage functionality. +//Types that use this should consider overriding emp_act() and hear_talk(), unless they shield their contents somehow. +/obj/item/weapon/storage/internal + preserve_item = 1 + var/obj/item/master_item + +/obj/item/weapon/storage/internal/New(obj/item/MI) + master_item = MI + loc = master_item + name = master_item.name + verbs -= /obj/item/verb/verb_pickup //make sure this is never picked up. + ..() + +/obj/item/weapon/storage/internal/Destroy() + master_item = null + . = ..() + +/obj/item/weapon/storage/internal/attack_hand() + return //make sure this is never picked up + +/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. +//These procs are completely optional, it is up to the master item to decide when it's storage get's opened by calling open() +//However they are helpful for allowing the master item to pretend it is a storage item itself. +//If you are using these you will probably want to override attackby() as well. +//See /obj/item/clothing/suit/storage for an example. + +//items that use internal storage have the option of calling this to emulate default storage MouseDrop behaviour. +//returns 1 if the master item's parent's MouseDrop() should be called, 0 otherwise. It's strange, but no other way of +//doing it without the ability to call another proc's parent, really. +/obj/item/weapon/storage/internal/proc/handle_mousedrop(mob/user as mob, obj/over_object as obj) + if (ishuman(user) || issmall(user)) //so monkeys can take off their backpacks -- Urist + + if (istype(user.loc,/obj/mecha)) // stops inventory actions in a mech + return 0 + + if(over_object == user && Adjacent(user)) // this must come before the screen objects only block + src.open(user) + return 0 + + if (!( istype(over_object, /obj/screen) )) + return 1 + + //makes sure master_item is equipped before putting it in hand, so that we can't drag it into our hand from miles away. + //there's got to be a better way of doing this... + if (!(master_item.loc == user) || (master_item.loc && master_item.loc.loc == user)) + return 0 + + if (!( user.restrained() ) && !( user.stat )) + switch(over_object.name) + if("r_hand") + user.unEquip(master_item) + user.put_in_r_hand(master_item) + if("l_hand") + user.unEquip(master_item) + user.put_in_l_hand(master_item) + master_item.add_fingerprint(user) + return 0 + return 0 + +//items that use internal storage have the option of calling this to emulate default storage attack_hand behaviour. +//returns 1 if the master item's parent's attack_hand() should be called, 0 otherwise. +//It's strange, but no other way of doing it without the ability to call another proc's parent, really. +/obj/item/weapon/storage/internal/proc/handle_attack_hand(mob/user as mob) + + if(ishuman(user)) + var/mob/living/carbon/human/H = user + if(H.l_store == master_item && !H.get_active_hand()) //Prevents opening if it's in a pocket. + H.put_in_hands(master_item) + H.l_store = null + return 0 + if(H.r_store == master_item && !H.get_active_hand()) + H.put_in_hands(master_item) + H.r_store = null + return 0 + + src.add_fingerprint(user) + if (master_item.loc == user) + src.open(user) + return 0 + + for(var/mob/M in range(1, master_item.loc)) + if (M.s_active == src) + src.close(M) + return 1 + +/obj/item/weapon/storage/internal/Adjacent(var/atom/neighbor) + return master_item.Adjacent(neighbor) +>>>>>>> eb8ad57... Merge pull request #7135 from Rykka-Stormheart/shep-dev-hover-overlays From f380f13c10ba1e243595708e315eeeae17057632 Mon Sep 17 00:00:00 2001 From: Aronai Sieyes Date: Mon, 11 May 2020 21:51:21 -0400 Subject: [PATCH 2/2] Fix whitespace merge --- code/_onclick/hud/screen_objects.dm | 53 ----------- .../objects/items/weapons/storage/internal.dm | 93 ------------------- 2 files changed, 146 deletions(-) diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index d451060c7fc..ab6985bdbdc 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -35,7 +35,6 @@ /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. -<<<<<<< HEAD /obj/screen/inventory/MouseEntered() ..() @@ -63,35 +62,6 @@ else item_overlay.color = "#00ff00" -======= - -/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" - ->>>>>>> eb8ad57... Merge pull request #7135 from Rykka-Stormheart/shep-dev-hover-overlays object_overlays += item_overlay add_overlay(object_overlays) @@ -172,8 +142,6 @@ if(isobserver(usr)) return -<<<<<<< HEAD -======= var/list/PL = params2list(params) var/icon_x = text2num(PL["icon-x"]) var/icon_y = text2num(PL["icon-y"]) @@ -186,24 +154,6 @@ /obj/screen/zone_sel/MouseEntered(location, control, params) MouseMove(location, control, params) -/obj/screen/zone_sel/MouseMove(location, control, params) - if(isobserver(usr)) - return - ->>>>>>> eb8ad57... Merge pull request #7135 from Rykka-Stormheart/shep-dev-hover-overlays - 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) -<<<<<<< HEAD - 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 @@ -213,9 +163,6 @@ var/icon_y = text2num(PL["icon-y"]) var/choice = get_zone_at(icon_x, icon_y) -======= - ->>>>>>> eb8ad57... Merge pull request #7135 from Rykka-Stormheart/shep-dev-hover-overlays if(hovering_choice == choice) return vis_contents -= hover_overlays_cache[hovering_choice] diff --git a/code/game/objects/items/weapons/storage/internal.dm b/code/game/objects/items/weapons/storage/internal.dm index b4415a5342e..ddb7e873e69 100644 --- a/code/game/objects/items/weapons/storage/internal.dm +++ b/code/game/objects/items/weapons/storage/internal.dm @@ -1,95 +1,3 @@ -<<<<<<< HEAD -//A storage item intended to be used by other items to provide storage functionality. -//Types that use this should consider overriding emp_act() and hear_talk(), unless they shield their contents somehow. -/obj/item/weapon/storage/internal - preserve_item = 1 - var/obj/item/master_item - -/obj/item/weapon/storage/internal/New(obj/item/MI) - master_item = MI - loc = master_item - //name = master_item.name //VOREStation Removal - verbs -= /obj/item/verb/verb_pickup //make sure this is never picked up. - ..() - -/obj/item/weapon/storage/internal/Destroy() - master_item = null - . = ..() - -/obj/item/weapon/storage/internal/attack_hand() - return //make sure this is never picked up - -/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. -//These procs are completely optional, it is up to the master item to decide when it's storage get's opened by calling open() -//However they are helpful for allowing the master item to pretend it is a storage item itself. -//If you are using these you will probably want to override attackby() as well. -//See /obj/item/clothing/suit/storage for an example. - -//items that use internal storage have the option of calling this to emulate default storage MouseDrop behaviour. -//returns 1 if the master item's parent's MouseDrop() should be called, 0 otherwise. It's strange, but no other way of -//doing it without the ability to call another proc's parent, really. -/obj/item/weapon/storage/internal/proc/handle_mousedrop(mob/user as mob, obj/over_object as obj) - if (ishuman(user) || issmall(user)) //so monkeys can take off their backpacks -- Urist - - if (istype(user.loc,/obj/mecha)) // stops inventory actions in a mech - return 0 - - if(over_object == user && Adjacent(user)) // this must come before the screen objects only block - src.open(user) - return 0 - - if (!( istype(over_object, /obj/screen) )) - return 1 - - //makes sure master_item is equipped before putting it in hand, so that we can't drag it into our hand from miles away. - //there's got to be a better way of doing this... - if (!(master_item.loc == user) || (master_item.loc && master_item.loc.loc == user)) - return 0 - - if (!( user.restrained() ) && !( user.stat )) - switch(over_object.name) - if("r_hand") - user.unEquip(master_item) - user.put_in_r_hand(master_item) - if("l_hand") - user.unEquip(master_item) - user.put_in_l_hand(master_item) - master_item.add_fingerprint(user) - return 0 - return 0 - -//items that use internal storage have the option of calling this to emulate default storage attack_hand behaviour. -//returns 1 if the master item's parent's attack_hand() should be called, 0 otherwise. -//It's strange, but no other way of doing it without the ability to call another proc's parent, really. -/obj/item/weapon/storage/internal/proc/handle_attack_hand(mob/user as mob) - - if(ishuman(user)) - var/mob/living/carbon/human/H = user - if(H.l_store == master_item && !H.get_active_hand()) //Prevents opening if it's in a pocket. - H.put_in_hands(master_item) - H.l_store = null - return 0 - if(H.r_store == master_item && !H.get_active_hand()) - H.put_in_hands(master_item) - H.r_store = null - return 0 - - src.add_fingerprint(user) - if (master_item.loc == user) - src.open(user) - return 0 - - for(var/mob/M in range(1, master_item.loc)) - if (M.s_active == src) - src.close(M) - return 1 - -/obj/item/weapon/storage/internal/Adjacent(var/atom/neighbor) - return master_item.Adjacent(neighbor) -======= //A storage item intended to be used by other items to provide storage functionality. //Types that use this should consider overriding emp_act() and hear_talk(), unless they shield their contents somehow. /obj/item/weapon/storage/internal @@ -180,4 +88,3 @@ /obj/item/weapon/storage/internal/Adjacent(var/atom/neighbor) return master_item.Adjacent(neighbor) ->>>>>>> eb8ad57... Merge pull request #7135 from Rykka-Stormheart/shep-dev-hover-overlays