Simplifies/refactors the "Add reagent" verb in VV (#22862)

* Adds an "Enter ID" option to reagent adding

* Adds a cancel option to selecting reagent ID
This commit is contained in:
Xhuis
2017-01-11 12:47:54 +13:00
committed by oranges
parent 2d1033ab52
commit 33a8e486f5
+17 -3
View File
@@ -52,13 +52,13 @@
var/refid = "\ref[D]"
var/icon/sprite
var/hash
var/type = /list
if (!islist)
type = D.type
if(istype(D,/atom))
var/atom/AT = D
if(AT.icon && AT.icon_state)
@@ -850,8 +850,22 @@
A.create_reagents(amount)
if(A.reagents)
var/chosen_id
var/list/reagent_options = sortList(chemical_reagents_list)
var/chosen_id = input(usr, "Choose a reagent to add.", "Choose a reagent.") in reagent_options|null
switch(alert(usr, "Choose a method.", "Add Reagents", "Enter ID", "Choose ID"))
if("Enter ID")
var/valid_id
while(!valid_id)
chosen_id = stripped_input(usr, "Enter the ID of the reagent you want to add.")
if(!chosen_id) //Get me out of here!
break
for(var/ID in reagent_options)
if(ID == chosen_id)
valid_id = 1
if(!valid_id)
usr << "<span class='warning'>A reagent with that ID doesn't exist!</span>"
if("Choose ID")
chosen_id = input(usr, "Choose a reagent to add.", "Choose a reagent.") as null|anything in reagent_options
if(chosen_id)
var/amount = input(usr, "Choose the amount to add.", "Choose the amount.", A.reagents.maximum_volume) as num
if(amount)