From 5b78f4719b8c52fa6114ae706b549bfb45d7ba74 Mon Sep 17 00:00:00 2001 From: Mars Date: Sat, 1 Dec 2018 13:03:00 +0100 Subject: [PATCH] Radial menu for arm implants. --- code/_onclick/hud/radial.dm | 20 +++++++-------- code/modules/surgery/organs/augments_arms.dm | 26 +++++++++++++++----- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/code/_onclick/hud/radial.dm b/code/_onclick/hud/radial.dm index cea30327af1..d0c0c29fe81 100644 --- a/code/_onclick/hud/radial.dm +++ b/code/_onclick/hud/radial.dm @@ -66,7 +66,7 @@ GLOBAL_LIST_EMPTY(radial_menus) var/max_elements var/pages = 1 var/current_page = 1 - + var/hudfix_method = TRUE //TRUE to change anchor to user, FALSE to shift by py_shift var/py_shift = 0 var/entry_animation = TRUE @@ -74,9 +74,9 @@ GLOBAL_LIST_EMPTY(radial_menus) //If we swap to vis_contens inventory these will need a redo /datum/radial_menu/proc/check_screen_border(mob/user) var/atom/movable/AM = anchor - if(!istype(AM) || !AM.screen_loc) + if(!istype(AM)) return - if(AM in user.client.screen) + if((AM in user.client.screen) || !AM.screen_loc) if(hudfix_method) anchor = user else @@ -84,7 +84,7 @@ GLOBAL_LIST_EMPTY(radial_menus) restrict_to_dir(NORTH) //I was going to parse screen loc here but that's more effort than it's worth. //Sets defaults -//These assume 45 deg min_angle +//These assume 45 deg min_angle /datum/radial_menu/proc/restrict_to_dir(dir) switch(dir) if(NORTH) @@ -105,7 +105,7 @@ GLOBAL_LIST_EMPTY(radial_menus) zone = ending_angle - starting_angle else zone = 360 - starting_angle + ending_angle - + max_elements = round(zone / min_angle) var/paged = max_elements < choices.len if(elements.len < max_elements) @@ -172,7 +172,7 @@ GLOBAL_LIST_EMPTY(radial_menus) else E.pixel_y = py E.pixel_x = px - + //Visuals E.alpha = 255 E.mouse_opacity = MOUSE_OPACITY_ICON @@ -192,7 +192,7 @@ GLOBAL_LIST_EMPTY(radial_menus) E.next_page = FALSE if(choices_icons[choice_id]) E.add_overlay(choices_icons[choice_id]) - + /datum/radial_menu/New() close_button = new close_button.parent = src @@ -230,7 +230,7 @@ GLOBAL_LIST_EMPTY(radial_menus) MA.layer = ABOVE_HUD_LAYER MA.appearance_flags |= RESET_TRANSFORM return MA - + /datum/radial_menu/proc/next_page() if(pages > 1) @@ -268,7 +268,7 @@ GLOBAL_LIST_EMPTY(radial_menus) . = ..() /* - Presents radial menu to user anchored to anchor (or user if the anchor is currently in users screen) + Presents radial menu to user anchored to anchor (or user if the anchor is currently in users screen) Choices should be a list where list keys are movables or text used for element names and return value and list values are movables/icons/images used for element icons */ @@ -297,4 +297,4 @@ GLOBAL_LIST_EMPTY(radial_menus) GLOB.radial_menus -= uniqueid return answer -#undef ANIM_SPEED \ No newline at end of file +#undef ANIM_SPEED diff --git a/code/modules/surgery/organs/augments_arms.dm b/code/modules/surgery/organs/augments_arms.dm index d9a572c1a0e..02c8005793b 100644 --- a/code/modules/surgery/organs/augments_arms.dm +++ b/code/modules/surgery/organs/augments_arms.dm @@ -133,14 +133,28 @@ holder = null if(contents.len == 1) Extend(contents[1]) - else // TODO: make it similar to borg's storage-like module selection - var/obj/item/choise = input("Activate which item?", "Arm Implant", null, null) as null|anything in items_list - if(owner && owner == usr && owner.stat != DEAD && (src in owner.internal_organs) && !holder && istype(choise) && (choise in contents)) - // This monster sanity check is a nice example of how bad input() is. - Extend(choise) + else + radial_menu(owner) else Retract() +/obj/item/organ/internal/cyberimp/arm/proc/check_menu(var/mob/user) + return (owner && owner == user && owner.stat != DEAD && (src in owner.internal_organs) && !holder) + +/obj/item/organ/internal/cyberimp/arm/proc/radial_menu(mob/user) + var/list/choices = list() + for(var/obj/I in items_list) + choices["[I.name]"] = image(icon = I.icon, icon_state = I.icon_state) + var/choice = show_radial_menu(user, src, choices, custom_check = CALLBACK(src, .proc/check_menu, user)) + if(!check_menu(user)) + return + var/obj/item/selected + for(var/obj/item in items_list) + if(item.name == choice) + selected = item + break + if(istype(selected) && (selected in contents)) + Extend(selected) /obj/item/organ/internal/cyberimp/arm/gun/emp_act(severity) if(emp_proof) @@ -339,4 +353,4 @@ name = "advanced mop implant" desc = "Advanced mop implant. Does what it says on the tin" // A better description - contents = newlist(/obj/item/mop/advanced) \ No newline at end of file + contents = newlist(/obj/item/mop/advanced)