mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-09 16:14:13 +00:00
Adds common filter input function (#31246)
* Adds common filter input function * Comment * 2 more places replaced in too * Mass delete in zone lines trimmed down now * Changing function on mass modifying vars * Reformats this to be more flexible * Cuts this down too * Loadout selection * Nicer to have this be a default value of 0, may as well sneakycode this now * Handling this in another PR anyways Co-authored-by: kanef <kanef9x@protonmail.com>
This commit is contained in:
@@ -133,6 +133,21 @@
|
||||
continue
|
||||
L.Cut(i,i+1)
|
||||
|
||||
/*
|
||||
* Returns a choice from an input list.
|
||||
* If only one thing is returned, just gives us that with no input list.
|
||||
*/
|
||||
/proc/filter_list_input(input_text, input_heading, var/list/matches)
|
||||
if(!matches.len)
|
||||
return
|
||||
if(matches.len==1)
|
||||
return matches[1]
|
||||
else
|
||||
var/chosen = input(input_text, input_heading, matches[1]) as null|anything in matches
|
||||
if(!chosen)
|
||||
return
|
||||
return chosen
|
||||
|
||||
/*
|
||||
* Returns list containing all the entries from first list that are not present in second.
|
||||
* If skiprep = 1, repeated elements are treated as one.
|
||||
|
||||
@@ -1321,19 +1321,10 @@ var/global/floorIsLava = 0
|
||||
|
||||
object = copytext(object, 1, variables_start)
|
||||
|
||||
var/list/matches = get_matching_types(object, /atom)
|
||||
|
||||
if(matches.len==0)
|
||||
var/chosen = filter_list_input("Select an atom type", "Spawn Atom", get_matching_types(object, /atom))
|
||||
if(!chosen)
|
||||
return
|
||||
|
||||
var/chosen
|
||||
if(matches.len==1)
|
||||
chosen = matches[1]
|
||||
else
|
||||
chosen = input("Select an atom type", "Spawn Atom", matches[1]) as null|anything in matches
|
||||
if(!chosen)
|
||||
return
|
||||
|
||||
//preloader is hooked to atom/New(), and is automatically disabled once it 'loads' an object
|
||||
_preloader.setup(varchanges, chosen)
|
||||
|
||||
|
||||
@@ -234,8 +234,7 @@ var/global/list/obj/effect/bmode/buildholder/buildmodeholders = list()
|
||||
if(isnull(partial_type))
|
||||
return
|
||||
|
||||
var/list/matches = get_matching_types(partial_type, /atom)
|
||||
objholder = input("Select type", "Typepath") as null|anything in matches
|
||||
objholder = filter_list_input("Select type", "Typepath", get_matching_types(partial_type, /atom))
|
||||
|
||||
if(!ispath(objholder))
|
||||
objholder = /obj/structure/closet
|
||||
|
||||
@@ -3972,8 +3972,7 @@
|
||||
if (!newname)
|
||||
newname = "Admin"
|
||||
var/choice = alert("Edit appearance on spawn?", "Admin", "Yes", "No")
|
||||
var/list/outfits = (typesof(/datum/outfit/) - /datum/outfit/ - /datum/outfit/striketeam/)
|
||||
var/outfit_type = input(usr,"Outfit Type","Equip Outfit","") as null|anything in outfits
|
||||
var/outfit_type = select_loadout()
|
||||
if(!outfit_type || !ispath(outfit_type))
|
||||
return
|
||||
var/turf/T = get_turf(usr)
|
||||
@@ -5814,18 +5813,7 @@
|
||||
z_del = new_limit
|
||||
if ("type") // Lifted from "spawn" code.
|
||||
var/object = input(usr, "Enter a typepath. It will be autocompleted.", "Setting the type to delete.") as null|text
|
||||
|
||||
var/list/matches = get_matching_types(object, /atom)
|
||||
|
||||
if(matches.len==0)
|
||||
to_chat(usr, "<span class='warning'>No typepaths found.</span>")
|
||||
return
|
||||
|
||||
var/chosen
|
||||
if(matches.len==1)
|
||||
chosen = matches[1]
|
||||
else
|
||||
chosen = input("Select an atom type", "Spawn Atom", matches[1]) as null|anything in matches
|
||||
var/chosen = filter_list_input("Select an atom type", "Spawn Atom", get_matching_types(object, /atom))
|
||||
if(!chosen)
|
||||
to_chat(usr, "<span class='warning'>No type chosen.</span>")
|
||||
return
|
||||
|
||||
@@ -1267,20 +1267,11 @@ var/global/blood_virus_spreading_disabled = 0
|
||||
object = copytext(object, 1, variables_start)
|
||||
|
||||
|
||||
var/list/matches = get_matching_types(object, /datum) - typesof(/turf, /area, /datum/admins) //Exclude non-movable atoms
|
||||
|
||||
if(matches.len == 0)
|
||||
to_chat(usr, "Unable to find any matches.")
|
||||
//Exclude non-movable atoms
|
||||
var/chosen = filter_list_input("Select a datum type", "Spawn Datum", get_matching_types(object, /datum) - typesof(/turf, /area, /datum/admins))
|
||||
if(!chosen)
|
||||
return
|
||||
|
||||
var/chosen
|
||||
if(matches.len == 1)
|
||||
chosen = matches[1]
|
||||
else
|
||||
chosen = input("Select a datum type", "Spawn Datum", matches[1]) as null|anything in matches
|
||||
if(!chosen)
|
||||
return
|
||||
|
||||
/*
|
||||
var/list/lst = list()
|
||||
var/argnum = input("Number of arguments","Number:",0) as num|null
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
return
|
||||
|
||||
if(istext(target_type))
|
||||
target_type = input("Select an object type to mass-modify", "Mass-editing") as null|anything in get_matching_types(target_type, /atom)
|
||||
target_type = filter_list_input("Select an object type to mass-modify", "Mass-editing", get_matching_types(target_type, /atom))
|
||||
|
||||
//get_vars_from_type() fails on turf and area objects. If you want to mass-edit a turf, you have to do it through the varedit window
|
||||
if(ispath(target_type, /atom) && !ispath(target_type, /atom/movable))
|
||||
|
||||
@@ -161,9 +161,7 @@ var/list/forbidden_varedit_object_types = list(
|
||||
|
||||
if(V_TYPE)
|
||||
var/partial_type = input("Enter type, or leave blank to see all types", window_title, "[old_value]") as text|null
|
||||
|
||||
var/list/matches = get_matching_types(partial_type, /datum)
|
||||
new_value = input("Select type", window_title) as null|anything in matches
|
||||
new_value = filter_list_input("Select type", window_title, get_matching_types(partial_type, /datum))
|
||||
|
||||
if(V_LIST_EMPTY)
|
||||
if (acceptsLists)
|
||||
|
||||
@@ -1094,8 +1094,7 @@ Traitors and the like can also be revived with the previous role mostly intact.
|
||||
delete_text = input(usr,"Delete stripped items?","Equip Outfit","") as null|anything in list("Yes","No")
|
||||
if(!delete_text)
|
||||
return
|
||||
var/list/outfits = (typesof(/datum/outfit/) - /datum/outfit/ - /datum/outfit/striketeam/)
|
||||
var/outfit_type = input(usr,"Outfit Type","Equip Outfit","") as null|anything in outfits
|
||||
var/outfit_type = select_loadout()
|
||||
if(!outfit_type || !ispath(outfit_type))
|
||||
return
|
||||
var/strip_items = FALSE
|
||||
@@ -1112,8 +1111,8 @@ Traitors and the like can also be revived with the previous role mostly intact.
|
||||
feedback_add_details("admin_verb","ELO") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
|
||||
/proc/select_loadout()
|
||||
var/list/outfits = (subtypesof(/datum/outfit/) - /datum/outfit/striketeam/)
|
||||
var/outfit_type = input(usr,"Outfit Type","Equip Outfit","") as null|anything in outfits
|
||||
var/object = input(usr, "Enter a typepath. It will be autocompleted.", "Equip Outfit") as null|text
|
||||
var/outfit_type = filter_list_input("Outfit Type","Equip Outfit", get_matching_types(object, /datum/outfit) - /datum/outfit/ - /datum/outfit/striketeam/)
|
||||
if(!outfit_type || !ispath(outfit_type))
|
||||
return
|
||||
return outfit_type
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
/datum/admins/proc/custom_strike_team(var/mob/user)
|
||||
|
||||
var/list/outfits = (typesof(/datum/outfit/) - /datum/outfit/ - /datum/outfit/striketeam/)
|
||||
var/outfit_type = input(user,"Outfit Type","Equip Outfit","") as null|anything in outfits
|
||||
var/outfit_type = select_loadout()
|
||||
var/datum/striketeam/custom/team = new /datum/striketeam/custom()
|
||||
team.outfit_datum = outfit_type
|
||||
if(outfit_type && ispath(outfit_type))
|
||||
team.outfit_datum = outfit_type
|
||||
team.trigger_strike(user)
|
||||
|
||||
@@ -308,8 +308,10 @@
|
||||
return new_frank
|
||||
|
||||
/mob/proc/Animalize()
|
||||
var/list/mobtypes = existing_typesof(/mob/living/simple_animal)
|
||||
var/mobpath = input("Which type of mob should [src] turn into?", "Choose a type") in mobtypes
|
||||
var/mobtext = input("Filter to a type name", "Choose a type") as text
|
||||
var/mobpath = filter_list_input("Which type of mob should [src] turn into?", "Choose a type", get_matching_types(mobtext, /mob/living/simple_animal))
|
||||
if(!mobpath)
|
||||
return
|
||||
if(!safe_animal(mobpath))
|
||||
to_chat(usr, "<span class='warning'>Sorry but this mob type is currently unavailable.</span>")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user