TGUI input box conversions 1 (#63313)

This commit is contained in:
Jeremiah
2021-12-11 14:21:35 -08:00
committed by GitHub
parent f6d15afaa1
commit 1052bc19ed
32 changed files with 81 additions and 79 deletions
+3 -3
View File
@@ -188,14 +188,14 @@ SUBSYSTEM_DEF(vote)
for(var/valid_map in maps)
choices.Add(valid_map)
if("custom")
question = stripped_input(usr,"What is the vote for?")
question = tgui_input_text(usr, "What is the vote for?", "Custom Vote")
if(!question)
return FALSE
for(var/i in 1 to 10)
var/option = capitalize(stripped_input(usr,"Please enter an option or hit cancel to finish"))
var/option = tgui_input_text(usr, "Please enter an option or hit cancel to finish", "Options", max_length = MAX_NAME_LEN)
if(!option || mode || !usr.client)
break
choices.Add(option)
choices.Add(capitalize(option))
else
return FALSE
mode = vote_type
+1 -1
View File
@@ -26,7 +26,7 @@
INVOKE_ASYNC(src, .proc/do_changewarcry, user)
/datum/component/wearertargeting/punchcooldown/proc/do_changewarcry(mob/user)
var/input = stripped_input(user,"What do you want your battlecry to be? Max length of 6 characters.", ,"", 7)
var/input = tgui_input_text(user, "What do you want your battlecry to be?", "Battle Cry", max_length = 6)
if(!QDELETED(src) && !QDELETED(user) && !user.Adjacent(parent))
return
if(input)
+1 -1
View File
@@ -67,7 +67,7 @@
change_name(H) //time for a new name!
/datum/element/spooky/proc/change_name(mob/living/carbon/human/H)
var/t = sanitize_name(stripped_input(H, "Enter your new skeleton name", H.real_name, null, MAX_NAME_LEN))
var/t = sanitize_name(tgui_input_text(H, "Enter your new skeleton name", "Spookifier", H.real_name, MAX_NAME_LEN))
if(!t)
t = "spooky skeleton"
H.fully_replace_character_name(null, t)
+1 -1
View File
@@ -145,7 +145,7 @@
log_admin("[key_name(user)] uploaded new event arena: [friendly_name].")
/obj/machinery/computer/arena/proc/load_team(user,team)
var/rawteam = stripped_multiline_input(user,"Enter team list (ckeys separated by newline)")
var/rawteam = tgui_input_text(user, "Enter team list (ckeys separated by newline)", "Team List", multiline = TRUE)
for(var/i in splittext(rawteam,"\n"))
var/key = ckey(i)
if(!i)
+1 -1
View File
@@ -631,7 +631,7 @@
var/datum/mutation/human/target_mutation = get_mut_by_ref(bref, search_flags)
// Prompt for modifier string
var/new_sequence_input = input(usr, "Enter replacement sequence (or nothing to cancel)", "Replace inherent gene","")
var/new_sequence_input = tgui_input_text(usr, "Enter a replacement sequence", "Inherent Gene Replacement", 32, encode = FALSE)
// Drop out if the string is the wrong length
if(length(new_sequence_input) != 32)
return
+6 -6
View File
@@ -521,7 +521,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/newscaster/security_unit, 30)
usr.set_machine(src)
scan_user(usr)
if(href_list["set_channel_name"])
channel_name = stripped_input(usr, "Provide a Feed Channel Name", "Network Channel Handler", "", MAX_NAME_LEN)
channel_name = tgui_input_text(usr, "Provide a Feed Channel Name", "Network Channel Handler", max_length = MAX_NAME_LEN)
updateUsrDialog()
else if(href_list["set_channel_lock"])
c_locked = !c_locked
@@ -556,7 +556,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/newscaster/security_unit, 30)
channel_name = input(usr, "Choose receiving Feed Channel", "Network Channel Handler") in sort_list(available_channels)
updateUsrDialog()
else if(href_list["set_new_message"])
var/temp_message = trim(stripped_multiline_input(usr, "Write your Feed story", "Network Channel Handler", msg))
var/temp_message = tgui_input_text(usr, "Write your Feed story", "Network Channel Handler", msg, multiline = TRUE)
if(temp_message)
msg = temp_message
updateUsrDialog()
@@ -601,10 +601,10 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/newscaster/security_unit, 30)
screen = 14
updateUsrDialog()
else if(href_list["set_wanted_name"])
channel_name = stripped_input(usr, "Provide the name of the Wanted person", "Network Security Handler")
channel_name = tgui_input_text(usr, "Provide the name of the wanted person", "Network Security Handler", max_length = MAX_NAME_LEN)
updateUsrDialog()
else if(href_list["set_wanted_desc"])
msg = stripped_input(usr, "Provide a description of the Wanted person and any other details you deem important", "Network Security Handler")
msg = tgui_input_text(usr, "Provide a description of the wanted person and any other details you deem important", "Network Security Handler", multiline = TRUE)
updateUsrDialog()
else if(href_list["submit_wanted"])
var/input_param = text2num(href_list["submit_wanted"])
@@ -693,7 +693,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/newscaster/security_unit, 30)
updateUsrDialog()
else if(href_list["new_comment"])
var/datum/newscaster/feed_message/FM = locate(href_list["new_comment"]) in viewing_channel.messages
var/cominput = stripped_input(usr, "Write your message:", "New comment", null, 140)
var/cominput = tgui_input_text(usr, "Write your message", "New comment", max_length = 140, multiline = TRUE)
if(cominput)
scan_user(usr)
var/datum/newscaster/feed_comment/FC = new/datum/newscaster/feed_comment
@@ -1027,7 +1027,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/newscaster/security_unit, 30)
if(scribble_page == curr_page)
to_chat(user, span_warning("There's already a scribble in this page... You wouldn't want to make things too cluttered, would you?"))
else
var/s = stripped_input(user, "Write something", "Newspaper")
var/s = tgui_input_text(user, "Write something", "Newspaper")
if (!s)
return
if(!user.canUseTopic(src, BE_CLOSE))
+1 -1
View File
@@ -193,7 +193,7 @@
notify_ghosts("\A [src] has been activated at [get_area(src)]!", source = src, action = NOTIFY_ORBIT, flashwindow = FALSE, header = "Bomb Planted")
/obj/machinery/syndicatebomb/proc/settings(mob/user)
var/new_timer = input(user, "Please set the timer.", "Timer", "[timer_set]") as num|null
var/new_timer = tgui_input_number(user, "Set the timer", "Countdown", timer_set, maximum_timer, minimum_timer)
if (isnull(new_timer))
return
@@ -269,7 +269,7 @@
auth = FALSE
screen = MSG_MON_SCREEN_MAIN
else
var/dkey = trim(input(usr, "Please enter the decryption key.") as text|null)
var/dkey = tgui_input_text(usr, "Please enter the decryption key", "Telecomms Decryption")
if(dkey && dkey != "")
if(linkedServer.decryptkey == dkey)
auth = TRUE
@@ -289,7 +289,7 @@
message_servers += M
if(message_servers.len > 1)
linkedServer = input(usr, "Please select a server.", "Select a server.", null) as null|anything in message_servers
linkedServer = tgui_input_list(usr, "Please select a server", "Server Selection", message_servers)
message = span_alert("NOTICE: Server selected.")
else if(message_servers.len > 0)
linkedServer = message_servers[1]
@@ -323,14 +323,12 @@
if(LINKED_SERVER_NONRESPONSIVE)
message = noserver
else if(auth)
var/dkey = stripped_input(usr, "Please enter the decryption key.")
var/dkey = tgui_input_text(usr, "Please enter the decryption key", "Telecomms Decryption")
if(dkey && dkey != "")
if(linkedServer.decryptkey == dkey)
var/newkey = stripped_input(usr,"Please enter the new key (3 - 16 characters max):")
var/newkey = tgui_input_text(usr, "Please enter the new key (3 - 16 characters max)", "New Key", 16)
if(length(newkey) <= 3)
message = span_notice("NOTICE: Decryption key too short!")
else if(length(newkey) > 16)
message = span_notice("NOTICE: Decryption key too long!")
else if(newkey && newkey != "")
linkedServer.decryptkey = newkey
message = span_notice("NOTICE: Decryption key set.")
@@ -384,24 +382,24 @@
//Select Your Name
if("Sender")
customsender = stripped_input(usr, "Please enter the sender's name.") || customsender
customsender = tgui_input_text(usr, "Please enter the sender's name.", "Sender") || customsender
//Select Receiver
if("Recepient")
//Get out list of viable PDAs
var/list/obj/item/pda/sendPDAs = get_viewable_pdas()
if(GLOB.PDAs && GLOB.PDAs.len > 0)
customrecepient = input(usr, "Select a PDA from the list.") as null|anything in sendPDAs
customrecepient = tgui_input_list(usr, "Select a PDA from the list", "PDA Selection", sendPDAs)
else
customrecepient = null
//Enter custom job
if("RecJob")
customjob = stripped_input(usr, "Please enter the sender's job.") || customjob
customjob = tgui_input_text(usr, "Please enter the sender's job.", "Job") || customjob
//Enter message
if("Message")
custommessage = stripped_input(usr, "Please enter your message.") || custommessage
custommessage = tgui_input_text(usr, "Please enter your message.", "Message") || custommessage
//Send message
if("Send")
@@ -107,16 +107,12 @@
if(href_list["network"])
var/newnet = stripped_input(usr, "Which network do you want to view?", "Comm Monitor", network)
var/newnet = tgui_input_text(usr, "Which network do you want to view?", "Comm Monitor", network, 15)
if(newnet && ((usr in range(1, src)) || issilicon(usr)))
if(length(newnet) > 15)
temp = "<font color = #D70B00>- FAILED: NETWORK TAG STRING TOO LENGHTLY -</font color>"
else
network = newnet
screen = 0
machinelist = list()
temp = "<font color = #336699>- NEW NETWORK TAG SET IN ADDRESS \[[network]\] -</font color>"
network = newnet
screen = 0
machinelist = list()
temp = "<font color = #336699>- NEW NETWORK TAG SET IN ADDRESS \[[network]\] -</font color>"
updateUsrDialog()
return
+3 -3
View File
@@ -37,10 +37,10 @@
to_chat(user, span_warning("You're still waiting for approval from your employers about your proposed name change, it'd be best to wait for now."))
return
var/new_name = stripped_input(user, message="What do you want to name \
var/new_name = tgui_input_text(user, "What do you want to name \
[station_name()]? Keep in mind particularly terrible names may be \
rejected by your employers, while names using the standard format, \
will automatically be accepted.", max_length=MAX_CHARTER_LEN)
rejected by your employers, while names using the standard format \
will be accepted automatically.", "Station Name", max_length = MAX_CHARTER_LEN)
if(response_timer_id)
to_chat(user, span_warning("You're still waiting for approval from your employers about your proposed name change, it'd be best to wait for now."))
+1 -1
View File
@@ -630,7 +630,7 @@ GLOBAL_LIST_EMPTY(PDAs)
//NOTEKEEPER FUNCTIONS===================================
if ("Edit")
var/n = stripped_multiline_input(U, "Please enter message", name, note)
var/n = tgui_input_text(U, "Please enter message", name, note, multiline = TRUE)
if (in_range(src, U) && loc == U)
if (ui_mode == PDA_UI_NOTEKEEPER && n)
note = n
+1 -1
View File
@@ -134,7 +134,7 @@
to_chat(pai, span_notice("You have been bound to a new master."))
pai.emittersemicd = FALSE
if("set_laws")
var/newlaws = stripped_multiline_input(usr, "Enter any additional directives you would like your pAI personality to follow. Note that these directives will not override the personality's allegiance to its imprinted master. Conflicting directives will be ignored.", "pAI Directive Configuration", pai.laws.supplied[1], MAX_MESSAGE_LEN)
var/newlaws = tgui_input_text(usr, "Enter any additional directives you would like your pAI personality to follow. Note that these directives will not override the personality's allegiance to its imprinted master. Conflicting directives will be ignored.", "pAI Directive Configuration", pai.laws.supplied[1], MAX_MESSAGE_LEN, TRUE)
if(newlaws && pai)
pai.add_supplied_law(0,newlaws)
if("toggle_holo")
@@ -274,7 +274,7 @@
/obj/item/grenade/chem_grenade/adv_release/multitool_act(mob/living/user, obj/item/tool)
if (active)
return
var/newspread = text2num(stripped_input(user, "Please enter a new spread amount", name))
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)
+1 -1
View File
@@ -149,7 +149,7 @@
return ..()
if(weapon.tool_behaviour == TOOL_MULTITOOL)
var/newtime = text2num(stripped_input(user, "Please enter a new detonation time", name))
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)]."))
+1 -2
View File
@@ -516,8 +516,7 @@
if(is_zero_amount(delete_if_zero = TRUE))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
var/max = get_amount()
var/stackmaterial = round(input(user, "How many sheets do you wish to take out of this stack? (Maximum [max])", "Stack Split") as null|num)
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))
stackmaterial = min(max, stackmaterial)
if(stackmaterial == null || stackmaterial <= 0 || !user.canUseTopic(src, BE_CLOSE, NO_DEXTERITY, FALSE, !iscyborg(user)))
return SECONDARY_ATTACK_CONTINUE_CHAIN
+1 -1
View File
@@ -94,7 +94,7 @@
ui_interact(user)
/obj/structure/votebox/proc/set_description(mob/user)
var/new_description = stripped_multiline_input(user,"Enter new description","Vote Description",vote_description)
var/new_description = tgui_input_text(user, "Enter a new description", "Vote Description", vote_description, multiline = TRUE)
if(new_description)
vote_description = new_description
+1 -1
View File
@@ -691,7 +691,7 @@ GLOBAL_PROTECT(admin_verbs_hideable)
set category = "Admin.Events"
set name = "OSay"
set desc = "Makes an object say something."
var/message = input(usr, "What do you want the message to be?", "Make Sound") as text | null
var/message = tgui_input_text(usr, "What do you want the message to be?", "Make Sound", encode = FALSE)
if(!message)
return
O.say(message, sanitize = FALSE)
@@ -389,7 +389,7 @@ GLOBAL_LIST_EMPTY(antagonists)
return
/datum/antagonist/proc/edit_memory(mob/user)
var/new_memo = stripped_multiline_input(user, "Write new memory", "Memory", antag_memory, MAX_MESSAGE_LEN)
var/new_memo = tgui_input_text(user, "Write a new memory", "Antag Memory", antag_memory, multiline = TRUE)
if (isnull(new_memo))
return
antag_memory = new_memo
@@ -61,10 +61,10 @@
return
var/list/objectives = list()
do
var/objective = stripped_input(admin, "Add an objective, or leave empty to finish.", "Brainwashing", null, MAX_MESSAGE_LEN)
var/objective = tgui_input_text(admin, "Add an objective", "Brainwashing")
if(objective)
objectives += objective
while(tgui_alert(admin,"Add another objective?","More Brainwashing",list("Yes","No")) == "Yes")
while(tgui_alert(admin, "Add another objective?", "More Brainwashing", list("Yes","No")) == "Yes")
if(tgui_alert(admin,"Confirm Brainwashing?","Are you sure?",list("Yes","No")) == "No")
return
+1 -1
View File
@@ -17,7 +17,7 @@
button_icon_state = "cult_comms"
/datum/action/innate/cult/comm/Activate()
var/input = stripped_input(usr, "Please choose a message to tell to the other acolytes.", "Voice of Blood", "")
var/input = tgui_input_text(usr, "Message to tell to the other acolytes", "Voice of Blood")
if(!input || !IsAvailable())
return
+1 -1
View File
@@ -255,7 +255,7 @@
/datum/antagonist/nukeop/leader/proc/ask_name()
var/randomname = pick(GLOB.last_names)
var/newname = stripped_input(owner.current,"You are the nuke operative [title]. Please choose a last name for your family.", "Name change",randomname)
var/newname = tgui_input_text(owner.current, "You are the nuclear operative [title]. Please choose a last name for your family.", "Name change", randomname, MAX_NAME_LEN)
if (!newname)
newname = randomname
else
@@ -273,8 +273,8 @@
if(href_list["add_citation"])
var/maxFine = CONFIG_GET(number/maxfine)
var/t1 = stripped_input("Please input citation crime:", "Security HUD", "", null)
var/fine = FLOOR(input("Please input citation fine, up to [maxFine]:", "Security HUD", 50) as num|null, 1)
var/t1 = tgui_input_text(usr, "Citation crime", "Security HUD")
var/fine = FLOOR(tgui_input_number(usr, "Citation fine", "Security HUD", 50, max_value = maxFine), 1)
if(!R || !t1 || !fine || !allowed_access)
return
if(!H.canUseHUD())
@@ -305,7 +305,7 @@
return
if(href_list["add_crime"])
var/t1 = stripped_input("Please input crime name:", "Security HUD", "", null)
var/t1 = tgui_input_text(usr, "Crime name", "Security HUD")
if(!R || !t1 || !allowed_access)
return
if(!H.canUseHUD())
@@ -319,7 +319,7 @@
return
if(href_list["add_details"])
var/t1 = stripped_input(usr, "Please input crime details:", "Secure. records", "", null)
var/t1 = tgui_input_text(usr, "Crime details", "Security Records", multiline = TRUE)
if(!R || !t1 || !allowed_access)
return
if(!H.canUseHUD())
@@ -346,7 +346,7 @@
return
if(href_list["add_comment"])
var/t1 = stripped_multiline_input("Add Comment:", "Secure. records", null, null)
var/t1 = tgui_input_text(usr, "Add a comment", "Security Records", multiline = TRUE)
if (!R || !t1 || !allowed_access)
return
if(!H.canUseHUD())
@@ -17,7 +17,7 @@
return
/obj/item/bot_assembly/proc/rename_bot()
var/t = sanitize_name(stripped_input(usr, "Enter new robot name", name, created_name,MAX_NAME_LEN), allow_numbers = TRUE)
var/t = sanitize_name(tgui_input_text(usr, "Enter a new robot name", "Robot Rename", created_name, MAX_NAME_LEN), allow_numbers = TRUE)
if(!t)
return
if(!in_range(src, usr) && loc != usr)
@@ -316,7 +316,7 @@
if("setid")
var/new_id
if(pda)
new_id = stripped_input(user, "Enter ID:", name, id, MAX_NAME_LEN)
new_id = tgui_input_text(user, "Enter ID", "ID Assignment", id, MAX_NAME_LEN)
else
new_id = params["value"]
if(new_id)
+2 -2
View File
@@ -72,8 +72,8 @@
if(mode)
to_chat(user, span_notice("You turn on [src]."))
//Now let them chose the text.
var/str = reject_bad_text(stripped_input(user, "Label text?", "Set label","", MAX_NAME_LEN))
if(!str || !length(str))
var/str = reject_bad_text(tgui_input_text(user, "Label text", "Set Label", max_length = 64))
if(!str)
to_chat(user, span_warning("Invalid text!"))
return
label = str
+1 -1
View File
@@ -146,7 +146,7 @@
H.damageoverlaytemp = 9001
H.update_damage_hud()
return
var/n_name = stripped_input(usr, "What would you like to label the paper?", "Paper Labelling", null, MAX_NAME_LEN)
var/n_name = tgui_input_text(usr, "Enter a paper label", "Paper Labelling", max_length = MAX_NAME_LEN)
if(((loc == usr || istype(loc, /obj/item/clipboard)) && usr.stat == CONSCIOUS))
name = "paper[(n_name ? text("- '[n_name]'") : null)]"
add_fingerprint(usr)
+1 -1
View File
@@ -16,7 +16,7 @@
/obj/effect/proc_holder/spell/targeted/telepathy/cast(list/targets, mob/living/simple_animal/revenant/user = usr)
for(var/mob/living/M in targets)
var/msg = stripped_input(usr, "What do you wish to tell [M]?", null, "")
var/msg = tgui_input_text(user, "What do you wish to tell [M]?", "Telepathy")
if(!msg)
charge_counter = charge_max
return
@@ -36,7 +36,7 @@
var/objective
/datum/surgery_step/brainwash/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
objective = stripped_input(user, "Choose the objective to imprint on your victim's brain.", "Brainwashing", null, MAX_MESSAGE_LEN)
objective = tgui_input_text(user, "Choose the objective to imprint on your victim's brain", "Brainwashing")
if(!objective)
return -1
display_results(user, target, span_notice("You begin to brainwash [target]..."),
+4 -4
View File
@@ -23,9 +23,9 @@
user = client.mob
else
return
/// Client does NOT have tgui_fancy on: Returns regular input
/// Client does NOT have tgui_input on: Returns regular input
if(!user.client.prefs.read_preference(/datum/preference/toggle/tgui_input))
return input(user, message, title, default) as null | num
return input(user, message, title, default) as null|num
var/datum/tgui_input_number/numbox = new(user, message, title, default, max_value, min_value, timeout)
numbox.ui_interact(user)
numbox.wait()
@@ -147,9 +147,9 @@
return
switch(action)
if("submit")
if(max_value && (length(params["entry"]) > max_value))
if(max_value && (params["entry"] > max_value))
return FALSE
if(min_value && (length(params["entry"]) < min_value))
if(min_value && (params["entry"] < min_value))
return FALSE
set_entry(params["entry"])
SStgui.close_uis(src)
+21 -12
View File
@@ -10,11 +10,12 @@
* * message - The content of the textbox, shown in the body of the TGUI window.
* * title - The title of the textbox modal, shown on the top of the TGUI window.
* * default - The default (or current) value, shown as a placeholder.
* * max_length - Specifies a max length for input.
* * max_length - Specifies a max length for input. MAX_MESSAGE_LEN is default (1024)
* * multiline - Bool that determines if the input box is much larger. Good for large messages, laws, etc.
* * encode - Toggling this determines if input is filtered via html_encode. Setting this to FALSE gives raw input.
* * timeout - The timeout of the textbox, after which the modal will close and qdel itself. Set to zero for no timeout.
*/
/proc/tgui_input_text(mob/user, message = null, title = "Text Input", default = null, max_length = null, multiline = FALSE, timeout = 0)
/proc/tgui_input_text(mob/user, message = null, title = "Text Input", default = null, max_length = MAX_MESSAGE_LEN, multiline = FALSE, encode = TRUE, timeout = 0)
if (!user)
user = usr
if (!istype(user))
@@ -23,7 +24,7 @@
user = client.mob
else
return
/// Client does NOT have tgui_fancy on: Returns regular input
/// Client does NOT have tgui_input on: Returns regular input
if(!user.client.prefs.read_preference(/datum/preference/toggle/tgui_input))
if(max_length)
if(multiline)
@@ -32,7 +33,7 @@
return stripped_input(user, message, title, default, max_length)
else
return input(user, message, title, default)
var/datum/tgui_input_text/textbox = new(user, message, title, default, max_length, multiline, timeout)
var/datum/tgui_input_text/textbox = new(user, message, title, default, max_length, multiline, encode, timeout)
textbox.ui_interact(user)
textbox.wait()
if (textbox)
@@ -50,10 +51,11 @@
* * default - The default (or current) value, shown as a placeholder.
* * max_length - Specifies a max length for input.
* * multiline - Bool that determines if the input box is much larger. Good for large messages, laws, etc.
* * encode - If toggled, input is filtered via html_encode. Setting this to FALSE gives raw input.
* * callback - The callback to be invoked when a choice is made.
* * timeout - The timeout of the textbox, after which the modal will close and qdel itself. Disabled by default, can be set to seconds otherwise.
*/
/proc/tgui_input_text_async(mob/user, message = null, title = "Text Input", default = null, max_length = null, multiline = FALSE, datum/callback/callback, timeout = 0)
/proc/tgui_input_text_async(mob/user, message = null, title = "Text Input", default = null, max_length = null, multiline = FALSE, encode = TRUE, datum/callback/callback, timeout = 0)
if (!user)
user = usr
if (!istype(user))
@@ -62,7 +64,7 @@
user = client.mob
else
return
var/datum/tgui_input_text/async/textbox = new(user, message, title, default, max_length, multiline, callback, timeout)
var/datum/tgui_input_text/async/textbox = new(user, message, title, default, max_length, multiline, encode, callback, timeout)
textbox.ui_interact(user)
/**
@@ -76,6 +78,8 @@
var/closed
/// The default (or current) value, shown as a default.
var/default
/// Whether the input should be stripped using html_encode
var/encode
/// The entry that the user has return_typed in.
var/entry
/// The maximum length for text entry
@@ -92,8 +96,9 @@
var/title
/datum/tgui_input_text/New(mob/user, message, title, default, max_length, multiline, timeout)
/datum/tgui_input_text/New(mob/user, message, title, default, max_length, multiline, encode, timeout)
src.default = default
src.encode = encode
src.max_length = max_length
src.message = message
src.multiline = multiline
@@ -152,8 +157,11 @@
return
switch(action)
if("submit")
if(max_length && (length(params["entry"]) > max_length))
return FALSE
if(max_length)
if(length(params["entry"]) > max_length)
return FALSE
if(encode && (length(html_encode(params["entry"])) > max_length))
to_chat(usr, span_notice("Input uses special characters, thus reducing the maximum length."))
set_entry(params["entry"])
SStgui.close_uis(src)
return TRUE
@@ -163,7 +171,8 @@
return TRUE
/datum/tgui_input_text/proc/set_entry(entry)
src.entry = entry
var/converted_entry = encode ? html_encode(entry) : entry
src.entry = trim(converted_entry, max_length)
/**
* # async tgui_input_text
@@ -174,8 +183,8 @@
/// The callback to be invoked by the tgui_input_text upon having a choice made.
var/datum/callback/callback
/datum/tgui_input_text/async/New(mob/user, message, title, default, max_length, multiline, callback, timeout)
..(user, message, title, default, max_length, multiline, timeout)
/datum/tgui_input_text/async/New(mob/user, message, title, default, max_length, multiline, encode, callback, timeout)
..(user, message, title, default, max_length, multiline, encode, timeout)
src.callback = callback
/datum/tgui_input_text/async/Destroy(force, ...)
@@ -30,7 +30,7 @@ export const NumberInputModal = (_, context) => {
const defaultValidState = { isValid: true, error: null };
// Dynamically changes the window height based on the message.
const windowHeight
= 130 + Math.ceil(message.length / 5) + (large_buttons ? 5 : 0);
= 125 + Math.ceil(message?.length / 3) + (large_buttons ? 5 : 0);
return (
<Window title={title} width={270} height={windowHeight}>
@@ -41,7 +41,7 @@ export const TextInputModal = (_, context) => {
};
// Dynamically changes the window height based on the message.
const windowHeight
= 130 + Math.ceil(message.length / 5) + (multiline ? 75 : 0);
= 125 + Math.ceil(message?.length / 3) + (multiline ? 75 : 0);
return (
<Window title={title} width={325} height={windowHeight}>