From 27903691caa17cdc611535381b271ebe13de01ca Mon Sep 17 00:00:00 2001 From: SabreML <57483089+SabreML@users.noreply.github.com> Date: Mon, 9 Nov 2020 00:34:13 +0000 Subject: [PATCH] Adds radial menus --- code/_onclick/hud/radial.dm | 10 +++-- code/game/gamemodes/cult/cult_structures.dm | 13 ++++--- code/game/gamemodes/wizard/soulstone.dm | 43 +++++++++++---------- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/code/_onclick/hud/radial.dm b/code/_onclick/hud/radial.dm index c8ef4c344b1..be06559b858 100644 --- a/code/_onclick/hud/radial.dm +++ b/code/_onclick/hud/radial.dm @@ -256,8 +256,10 @@ GLOBAL_LIST_EMPTY(radial_menus) if(current_user) current_user.images -= menu_holder -/datum/radial_menu/proc/wait() - while (current_user && !finished && !selected_choice) +/datum/radial_menu/proc/wait(mob/user, atom/anchor, require_near = FALSE) + while(current_user && !finished && !selected_choice) + if(require_near && !user.Adjacent(anchor)) + return if(custom_check_callback && next_check < world.time) if(!custom_check_callback.Invoke()) return @@ -275,7 +277,7 @@ GLOBAL_LIST_EMPTY(radial_menus) 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 */ -/proc/show_radial_menu(mob/user, atom/anchor, list/choices, uniqueid, radius, datum/callback/custom_check) +/proc/show_radial_menu(mob/user, atom/anchor, list/choices, uniqueid, radius, datum/callback/custom_check, require_near = FALSE) if(!user || !anchor || !length(choices)) return if(!uniqueid) @@ -294,7 +296,7 @@ GLOBAL_LIST_EMPTY(radial_menus) menu.check_screen_border(user) //Do what's needed to make it look good near borders or on hud menu.set_choices(choices) menu.show_to(user) - menu.wait() + menu.wait(user, anchor, require_near) var/answer = menu.selected_choice qdel(menu) GLOB.radial_menus -= uniqueid diff --git a/code/game/gamemodes/cult/cult_structures.dm b/code/game/gamemodes/cult/cult_structures.dm index 2127a897385..ce5db00f0bf 100644 --- a/code/game/gamemodes/cult/cult_structures.dm +++ b/code/game/gamemodes/cult/cult_structures.dm @@ -80,12 +80,15 @@ if(cooldowntime > world.time) to_chat(user, "The magic in [src] is weak, it will be ready to use again in [get_ETA()].") return - var/choice = input(user, selection_prompt, selection_title) as null|anything in choosable_items - var/pickedtype = choosable_items[choice] - if(pickedtype && Adjacent(user) && src && !QDELETED(src) && !user.incapacitated() && cooldowntime <= world.time) + + var/choice = show_radial_menu(user, src, choosable_items, require_near = TRUE) + var/picked_type = choosable_items[choice] + if(!QDELETED(src) && picked_type && Adjacent(user) && !user.incapacitated() && cooldowntime <= world.time) cooldowntime = world.time + creation_delay - var/obj/item/N = new pickedtype(get_turf(src)) - to_chat(user, replacetext("[creation_message]", "%ITEM%", "[N.name]")) + var/obj/O = new picked_type + if(istype(O, /obj/structure) || !user.put_in_hands(O)) + O.forceMove(get_turf(src)) + to_chat(user, replacetext("[creation_message]", "%ITEM%", "[O.name]")) /** * Returns the cooldown time in minutes and seconds diff --git a/code/game/gamemodes/wizard/soulstone.dm b/code/game/gamemodes/wizard/soulstone.dm index d01c68c6ff2..4a93eb9e717 100644 --- a/code/game/gamemodes/wizard/soulstone.dm +++ b/code/game/gamemodes/wizard/soulstone.dm @@ -306,29 +306,32 @@ if("CONSTRUCT") var/obj/structure/constructshell/shell = target var/mob/living/simple_animal/shade/shade = locate() in src + var/list/construct_types = list("Juggernaut" = /mob/living/simple_animal/hostile/construct/armoured, + "Wraith" = /mob/living/simple_animal/hostile/construct/wraith, + "Artificer" = /mob/living/simple_animal/hostile/construct/builder) + /// Custom construct icons for different cults + var/list/construct_icons = list("Juggernaut" = image(icon = 'icons/mob/mob.dmi', icon_state = SSticker.cultdat.get_icon("juggernaut")), + "Wraith" = image(icon = 'icons/mob/mob.dmi', icon_state = SSticker.cultdat.get_icon("wraith")), + "Artificer" = image(icon = 'icons/mob/mob.dmi', icon_state = SSticker.cultdat.get_icon("builder"))) + if(shade) - var/construct_class = alert(user, "Please choose which type of construct you wish to create.", null, "Juggernaut", "Wraith", "Artificer") - if(shell.active) - return // Don't want two people doing it at once - shell.active = TRUE - switch(construct_class) - if("Juggernaut") - var/mob/living/simple_animal/hostile/construct/armoured/C = new(shell.loc) - C.init_construct(shade, src, shell) - to_chat(C, "You are a Juggernaut. Though slow, your shell can withstand extreme punishment, create shield walls and even deflect energy weapons, and rip apart enemies and walls alike.") - - if("Wraith") - var/mob/living/simple_animal/hostile/construct/wraith/C = new(shell.loc) - C.init_construct(shade, src, shell) - to_chat(C, "You are a Wraith. Though relatively fragile, you are fast, deadly, and even able to phase through walls.") - - if("Artificer") - var/mob/living/simple_animal/hostile/construct/builder/C = new(shell.loc) - C.init_construct(shade, src, shell) - to_chat(C, "You are an Artificer. You are incredibly weak and fragile, but you are able to construct fortifications, use magic missile, repair allied constructs (by clicking on them), and most important of all create new constructs (Use your Artificer spell to summon a new construct shell and Summon Soulstone to create a new soulstone).") + var/construct_choice = show_radial_menu(user, shell, construct_icons, custom_check = CALLBACK(src, .proc/radial_check, user), require_near = TRUE) + var/picked_class = construct_types[construct_choice] + if((picked_class && !QDELETED(shell) && !QDELETED(src)) && user.Adjacent(shell) && !user.incapacitated() && radial_check(user)) + var/mob/living/simple_animal/hostile/construct/C = new picked_class(shell.loc) + C.init_construct(shade, src, shell) + to_chat(C, C.playstyle_string) else to_chat(user, "Creation failed!: The soul stone is empty! Go kill someone!") - return + +/obj/item/soulstone/proc/radial_check(mob/user) + if(!ishuman(user)) // Should never happen, but just in case + return FALSE + + var/mob/living/carbon/human/H = user + if(!H.is_in_hands(src)) // Not holding the soulstone + return FALSE + return TRUE /mob/living/simple_animal/hostile/construct/proc/init_construct(mob/living/simple_animal/shade/shade, obj/item/soulstone/SS, obj/structure/constructshell/shell) if(shade.mind)