More standard tgui input conversions (#63464)

This commit is contained in:
Jeremiah
2021-12-24 13:04:18 +02:00
committed by GitHub
parent 36e5fcadd3
commit dcab86ba2c
64 changed files with 246 additions and 215 deletions
+13 -11
View File
@@ -101,18 +101,20 @@
/obj/item/holochip/AltClick(mob/user)
if(!user.canUseTopic(src, BE_CLOSE, NO_DEXTERITY, FALSE, !iscyborg(user)))
return
var/split_amount = round(input(user,"How many credits do you want to extract from the holochip?") as null|num)
if(split_amount == null || split_amount <= 0 || !user.canUseTopic(src, BE_CLOSE, NO_DEXTERITY, FALSE, !iscyborg(user)))
var/split_amount = tgui_input_number(user, "How many credits do you want to extract from the holochip?", "Holochip")
if(isnull(split_amount))
return
else
var/new_credits = spend(split_amount, TRUE)
var/obj/item/holochip/H = new(user ? user : drop_location(), new_credits)
if(user)
if(!user.put_in_hands(H))
H.forceMove(user.drop_location())
add_fingerprint(user)
H.add_fingerprint(user)
to_chat(user, span_notice("You extract [split_amount] credits into a new holochip."))
if(!user.canUseTopic(src, BE_CLOSE, NO_DEXTERITY, FALSE, !iscyborg(user)))
return
split_amount = round(split_amount)
var/new_credits = spend(split_amount, TRUE)
var/obj/item/holochip/H = new(user ? user : drop_location(), new_credits)
if(user)
if(!user.put_in_hands(H))
H.forceMove(user.drop_location())
add_fingerprint(user)
H.add_fingerprint(user)
to_chat(user, span_notice("You extract [split_amount] credits into a new holochip."))
/obj/item/holochip/emp_act(severity)
. = ..()
@@ -274,13 +274,14 @@
/obj/item/grenade/chem_grenade/adv_release/multitool_act(mob/living/user, obj/item/tool)
if (active)
return
var/newspread = tgui_input_number(user, "Please enter a new spread amount", name)
if (newspread != null && user.canUseTopic(src, BE_CLOSE))
newspread = round(newspread)
unit_spread = clamp(newspread, 5, 100)
to_chat(user, span_notice("You set the time release to [unit_spread] units per detonation."))
if (newspread != unit_spread)
to_chat(user, span_notice("The new value is out of bounds. Minimum spread is 5 units, maximum is 100 units."))
var/newspread = tgui_input_number(user, "Please enter a new spread amount", "Grenade Spread", 5, 100, 5)
if(isnull(newspread))
return
if(!user.canUseTopic(src, BE_CLOSE))
return
newspread = round(newspread)
unit_spread = clamp(newspread, 5, 100)
to_chat(user, span_notice("You set the time release to [unit_spread] units per detonation."))
..()
/obj/item/grenade/chem_grenade/adv_release/detonate(mob/living/lanced_by)
+12 -9
View File
@@ -149,12 +149,17 @@
return ..()
if(weapon.tool_behaviour == TOOL_MULTITOOL)
var/newtime = tgui_input_number(user, "Please enter a new detonation time", name)
if (newtime != null && user.canUseTopic(src, BE_CLOSE))
if(change_det_time(newtime))
to_chat(user, span_notice("You modify the time delay. It's set for [DisplayTimeText(det_time)]."))
if (round(newtime * 10) != det_time)
to_chat(user, span_warning("The new value is out of bounds. The lowest possible time is 3 seconds and highest is 5 seconds. Instant detonations are also possible."))
var/newtime = tgui_input_list(user, "Please enter a new detonation time", "Detonation Timer", list("Instant", 3, 4, 5))
if (isnull(newtime))
return
if(!user.canUseTopic(src, BE_CLOSE))
return
if(newtime == "Instant" && change_det_time(0))
to_chat(user, span_notice("You modify the time delay. It's set to be instantaneous."))
return
newtime = round(newtime)
if(change_det_time(newtime))
to_chat(user, span_notice("You modify the time delay. It's set for [DisplayTimeText(det_time)]."))
return
else if(weapon.tool_behaviour == TOOL_SCREWDRIVER)
if(change_det_time())
@@ -162,9 +167,7 @@
/obj/item/grenade/proc/change_det_time(time) //Time uses real time.
. = TRUE
if(time != null)
if(time < 3)
time = 3
if(!isnull(time))
det_time = round(clamp(time * 10, 0, 5 SECONDS))
else
var/previous_time = det_time
+3 -1
View File
@@ -517,8 +517,10 @@
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
var/max = get_amount()
var/stackmaterial = round(tgui_input_number(user, "How many sheets do you wish to take out of this stack?", "Stack Split", max_value = max))
if(isnull(stackmaterial))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
stackmaterial = min(max, stackmaterial)
if(stackmaterial == null || stackmaterial <= 0 || !user.canUseTopic(src, BE_CLOSE, NO_DEXTERITY, FALSE, !iscyborg(user)))
if(stackmaterial <= 0 || !user.canUseTopic(src, BE_CLOSE, NO_DEXTERITY, FALSE, !iscyborg(user)))
return SECONDARY_ATTACK_CONTINUE_CHAIN
split_stack(user, stackmaterial)
to_chat(user, span_notice("You take [stackmaterial] sheets out of the stack."))