From ee5506cc40d292972638051bd605391bdade4144 Mon Sep 17 00:00:00 2001
From: AndroBetel <44546836+AndroBetel@users.noreply.github.com>
Date: Mon, 3 Jun 2024 19:46:46 +0300
Subject: [PATCH] accessory removal menu is now radial (#6274)
# About the pull request
title
# Explain why it's good for the game
easier to use and prettier, visual = good
# Testing Photographs and Procedure
Screenshots & Videos
![Screenshot_43](https://github.com/cmss13-devs/cmss13/assets/44546836/e195df49-f62e-4e9a-89e5-51d1562e9e11)
![Screenshot_44](https://github.com/cmss13-devs/cmss13/assets/44546836/17fc2f61-8be2-4579-a0b5-cbcbf64d5623)
# Changelog
:cl:
qol: Added radial menu to accessory removal
/:cl:
---------
Co-authored-by: Drathek <76988376+Drulikar@users.noreply.github.com>
---
code/modules/clothing/clothing_accessories.dm | 46 +++++++++++++------
.../living/carbon/human/human_stripping.dm | 17 ++++---
2 files changed, 40 insertions(+), 23 deletions(-)
diff --git a/code/modules/clothing/clothing_accessories.dm b/code/modules/clothing/clothing_accessories.dm
index a07e83db7381..9c253fcb0371 100644
--- a/code/modules/clothing/clothing_accessories.dm
+++ b/code/modules/clothing/clothing_accessories.dm
@@ -118,34 +118,52 @@
A.on_removed(user, src)
LAZYREMOVE(accessories, A)
+
+ var/any_removable = FALSE
+ for(var/obj/item/clothing/accessory/accessory in accessories)
+ if(accessory.removable)
+ any_removable = TRUE
+ break
+ if(!any_removable)
+ verbs -= /obj/item/clothing/proc/removetie_verb
+
update_clothing_icon()
/obj/item/clothing/proc/removetie_verb()
set name = "Remove Accessory"
set category = "Object"
set src in usr
- if(!isliving(usr))
+
+ remove_accessory(usr, pick_accessory_to_remove(usr, usr))
+
+/obj/item/clothing/proc/pick_accessory_to_remove(mob/user, mob/targetmob)
+ if(!isliving(user))
return
- if(usr.stat)
+ if(user.stat)
return
if(!LAZYLEN(accessories))
return
- var/obj/item/clothing/accessory/A
+ var/obj/item/clothing/accessory/accessory
var/list/removables = list()
+ var/list/choice_to_accessory = list()
for(var/obj/item/clothing/accessory/ass in accessories)
- if(ass.removable)
- removables |= ass
- if(LAZYLEN(accessories) > 1)
- A = tgui_input_list(usr, "Select an accessory to remove from [src]", "Remove accessory", removables)
+ if(!ass.removable)
+ continue
+ var/capitalized_name = capitalize_first_letters(ass.name)
+ removables[capitalized_name] = image(icon = ass.icon, icon_state = ass.icon_state)
+ choice_to_accessory[capitalized_name] = ass
+
+ if(LAZYLEN(removables) > 1)
+ var/use_radials = user.client.prefs?.no_radials_preference ? FALSE : TRUE
+ var/choice = use_radials ? show_radial_menu(user, targetmob, removables, require_near = FALSE) : tgui_input_list(user, "Select an accessory to remove from [src]", "Remove accessory", removables)
+ accessory = choice_to_accessory[choice]
else
- A = LAZYACCESS(accessories, 1)
- if(!usr.Adjacent(src))
- to_chat(usr, SPAN_WARNING("You're too far away!"))
+ accessory = choice_to_accessory[removables[1]]
+ if(!user.Adjacent(src))
+ to_chat(user, SPAN_WARNING("You're too far away!"))
return
- src.remove_accessory(usr,A)
- removables -= A
- if(!removables.len)
- verbs -= /obj/item/clothing/proc/removetie_verb
+
+ return accessory
/obj/item/clothing/emp_act(severity)
. = ..()
diff --git a/code/modules/mob/living/carbon/human/human_stripping.dm b/code/modules/mob/living/carbon/human/human_stripping.dm
index e346a0a7368b..210e5f266fe0 100644
--- a/code/modules/mob/living/carbon/human/human_stripping.dm
+++ b/code/modules/mob/living/carbon/human/human_stripping.dm
@@ -129,13 +129,12 @@ GLOBAL_LIST_INIT(strippable_human_items, create_strippable_list(list(
return
var/obj/item/clothing/under/uniform = sourcemob.w_uniform
- if(!LAZYLEN(uniform.accessories))
- return FALSE
- var/obj/item/clothing/accessory/accessory = LAZYACCESS(uniform.accessories, 1)
- if(LAZYLEN(uniform.accessories) > 1)
- accessory = tgui_input_list(user, "Select an accessory to remove from [uniform]", "Remove accessory", uniform.accessories)
- if(!istype(accessory))
+
+ var/obj/item/clothing/accessory/accessory = uniform.pick_accessory_to_remove(user, sourcemob)
+
+ if(!accessory)
return
+
sourcemob.attack_log += text("\[[time_stamp()]\] Has had their accessory ([accessory]) removed by [key_name(user)]")
user.attack_log += text("\[[time_stamp()]\] Attempted to remove [key_name(sourcemob)]'s' accessory ([accessory])")
if(istype(accessory, /obj/item/clothing/accessory/holobadge) || istype(accessory, /obj/item/clothing/accessory/medal))
@@ -231,11 +230,11 @@ GLOBAL_LIST_INIT(strippable_human_items, create_strippable_list(list(
if(tag.dogtag_taken)
to_chat(user, SPAN_WARNING("Someone's already taken [sourcemob]'s information tag."))
return
-
+
if(sourcemob.stat != DEAD)
to_chat(user, SPAN_WARNING("You can't take a dogtag's information tag while its owner is alive."))
return
-
+
to_chat(user, SPAN_NOTICE("You take [sourcemob]'s information tag, leaving the ID tag"))
tag.dogtag_taken = TRUE
tag.icon_state = "dogtag_taken"
@@ -244,7 +243,7 @@ GLOBAL_LIST_INIT(strippable_human_items, create_strippable_list(list(
newtag.fallen_assgns = list(tag.assignment)
newtag.fallen_blood_types = list(tag.blood_type)
user.put_in_hands(newtag)
-
+
/datum/strippable_item/mob_item_slot/belt