Removing accessories from a jumpsuit is now a radial menu (#22696)

* accessory + helper

* elper

* okay, less insanity

* lewc review
This commit is contained in:
Contrabang
2023-10-22 13:00:18 -04:00
committed by GitHub
parent d5b70b6410
commit bec3ef912b
2 changed files with 50 additions and 5 deletions
+42
View File
@@ -309,4 +309,46 @@ GLOBAL_LIST_EMPTY(radial_menus)
GLOB.radial_menus -= uniqueid
return answer
/**
* Similar to show_radial_menu, but choices is a list of atoms, for which icons will be automatically generated.
* Supports multiple items of the same name, 2 soaps will become soap (1) and soap (2) to the user.
* Otherwise, has the exact same arguments as show_radial_menu
*/
/proc/radial_menu_helper(mob/user, atom/anchor, list/choices, uniqueid, radius, datum/callback/custom_check, require_near = FALSE)
var/list/duplicate_amount = list()
for(var/atom/atom in choices)
if(!duplicate_amount.Find(atom.name))
duplicate_amount[atom.name] = 0
else
duplicate_amount[atom.name]++
var/list/duplicate_indexes = duplicate_amount.Copy()
var/list/icon_state_choices = list()
var/list/return_choices = list()
for(var/atom/possible_atom in choices)
if(!istype(possible_atom))
stack_trace("radial_menu_helper was passed a non-atom (\"[possible_atom]\", [possible_atom.type]) as a choice")
continue
var/mutable_appearance/atom_appearance = new(possible_atom.appearance)
var/hover_outline_index = possible_atom.get_filter("hover_outline")
if(!isnull(hover_outline_index))
atom_appearance.filters.Cut(hover_outline_index, hover_outline_index + 1)
var/key = possible_atom.name
if(duplicate_amount[key])
var/number = duplicate_amount[key] - duplicate_indexes[key]
duplicate_indexes[key]--
key = "[key] ([number + 1])"
icon_state_choices[key] = atom_appearance
return_choices[key] = possible_atom
var/chosen_key = show_radial_menu(user, anchor, icon_state_choices, uniqueid, radius, custom_check, require_near)
if(!chosen_key)
return
return return_choices[chosen_key]
#undef ANIM_SPEED
+8 -5
View File
@@ -756,7 +756,7 @@
if(istype(I, /obj/item/clothing/accessory))
attach_accessory(I, user, TRUE)
if(accessories.len)
if(length(accessories))
for(var/obj/item/clothing/accessory/A in accessories)
A.attackby(I, user, params)
return TRUE
@@ -882,11 +882,14 @@
return
if(!Adjacent(usr))
return
if(!accessories.len)
if(!length(accessories))
return
var/obj/item/clothing/accessory/A
if(accessories.len > 1)
A = input("Select an accessory to remove from [src]") as null|anything in accessories
if(length(accessories) > 1)
var/pick = radial_menu_helper(usr, src, accessories, custom_check = FALSE, require_near = TRUE)
if(!pick)
return
A = pick
else
A = accessories[1]
remove_accessory(usr,A)
@@ -904,7 +907,7 @@
to_chat(user, "<span class='notice'>You remove [A] from [src].</span>")
/obj/item/clothing/under/emp_act(severity)
if(accessories.len)
if(length(accessories))
for(var/obj/item/clothing/accessory/A in accessories)
A.emp_act(severity)
..()