From 1052bc19ed205e005e47b1ed232c8ca9540ced45 Mon Sep 17 00:00:00 2001 From: Jeremiah <42397676+jlsnow301@users.noreply.github.com> Date: Sat, 11 Dec 2021 14:21:35 -0800 Subject: [PATCH] TGUI input box conversions 1 (#63313) --- code/controllers/subsystem/vote.dm | 6 ++-- code/datums/components/punchcooldown.dm | 2 +- code/datums/elements/spooky.dm | 2 +- code/game/machinery/computer/arena.dm | 2 +- code/game/machinery/computer/dna_console.dm | 2 +- code/game/machinery/newscaster.dm | 12 +++---- code/game/machinery/syndicatebomb.dm | 2 +- .../machinery/telecomms/computers/message.dm | 18 +++++----- .../telecomms/computers/telemonitor.dm | 14 +++----- code/game/objects/items/charter.dm | 6 ++-- code/game/objects/items/devices/PDA/PDA.dm | 2 +- code/game/objects/items/devices/paicard.dm | 2 +- .../objects/items/grenades/chem_grenade.dm | 2 +- code/game/objects/items/grenades/grenade.dm | 2 +- code/game/objects/items/stacks/stack.dm | 3 +- code/game/objects/structures/votingbox.dm | 2 +- code/modules/admin/admin_verbs.dm | 2 +- .../antagonists/_common/antag_datum.dm | 2 +- .../antagonists/brainwashing/brainwashing.dm | 4 +-- code/modules/antagonists/cult/cult_comms.dm | 2 +- code/modules/antagonists/nukeop/nukeop.dm | 2 +- code/modules/mob/living/carbon/human/human.dm | 10 +++--- .../living/simple_animal/bot/construction.dm | 2 +- .../mob/living/simple_animal/bot/mulebot.dm | 2 +- code/modules/paperwork/handlabeler.dm | 4 +-- code/modules/paperwork/paper.dm | 2 +- code/modules/spells/spell_types/telepathy.dm | 2 +- code/modules/surgery/advanced/brainwashing.dm | 2 +- code/modules/tgui/tgui_input_number.dm | 8 ++--- code/modules/tgui/tgui_input_text.dm | 33 ++++++++++++------- .../tgui/interfaces/NumberInputModal.tsx | 2 +- .../tgui/interfaces/TextInputModal.tsx | 2 +- 32 files changed, 81 insertions(+), 79 deletions(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 557fd5c6625..9a01436ef93 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -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 diff --git a/code/datums/components/punchcooldown.dm b/code/datums/components/punchcooldown.dm index 386ad61dd57..1a3b9bb515c 100644 --- a/code/datums/components/punchcooldown.dm +++ b/code/datums/components/punchcooldown.dm @@ -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) diff --git a/code/datums/elements/spooky.dm b/code/datums/elements/spooky.dm index 3643bac10db..6e25889ec8a 100644 --- a/code/datums/elements/spooky.dm +++ b/code/datums/elements/spooky.dm @@ -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) diff --git a/code/game/machinery/computer/arena.dm b/code/game/machinery/computer/arena.dm index c6867d5814d..78f6b335ddb 100644 --- a/code/game/machinery/computer/arena.dm +++ b/code/game/machinery/computer/arena.dm @@ -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) diff --git a/code/game/machinery/computer/dna_console.dm b/code/game/machinery/computer/dna_console.dm index 0b97690e678..d27962329dd 100644 --- a/code/game/machinery/computer/dna_console.dm +++ b/code/game/machinery/computer/dna_console.dm @@ -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 diff --git a/code/game/machinery/newscaster.dm b/code/game/machinery/newscaster.dm index a0ed9ddd7d7..6f511a66b52 100644 --- a/code/game/machinery/newscaster.dm +++ b/code/game/machinery/newscaster.dm @@ -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)) diff --git a/code/game/machinery/syndicatebomb.dm b/code/game/machinery/syndicatebomb.dm index 116d0d6b345..efe36a291e1 100644 --- a/code/game/machinery/syndicatebomb.dm +++ b/code/game/machinery/syndicatebomb.dm @@ -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 diff --git a/code/game/machinery/telecomms/computers/message.dm b/code/game/machinery/telecomms/computers/message.dm index a3652af2851..c3e1b8cc2a3 100644 --- a/code/game/machinery/telecomms/computers/message.dm +++ b/code/game/machinery/telecomms/computers/message.dm @@ -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") diff --git a/code/game/machinery/telecomms/computers/telemonitor.dm b/code/game/machinery/telecomms/computers/telemonitor.dm index 1ac63752b12..cc92e41b15b 100644 --- a/code/game/machinery/telecomms/computers/telemonitor.dm +++ b/code/game/machinery/telecomms/computers/telemonitor.dm @@ -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 = "- FAILED: NETWORK TAG STRING TOO LENGHTLY -" - - else - network = newnet - screen = 0 - machinelist = list() - temp = "- NEW NETWORK TAG SET IN ADDRESS \[[network]\] -" + network = newnet + screen = 0 + machinelist = list() + temp = "- NEW NETWORK TAG SET IN ADDRESS \[[network]\] -" updateUsrDialog() return diff --git a/code/game/objects/items/charter.dm b/code/game/objects/items/charter.dm index 3558aa5d637..eafa2ace8b2 100644 --- a/code/game/objects/items/charter.dm +++ b/code/game/objects/items/charter.dm @@ -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.")) diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index c11329674aa..b82f05d80e1 100644 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -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 diff --git a/code/game/objects/items/devices/paicard.dm b/code/game/objects/items/devices/paicard.dm index 32e6db7dbc1..beee288737e 100644 --- a/code/game/objects/items/devices/paicard.dm +++ b/code/game/objects/items/devices/paicard.dm @@ -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") diff --git a/code/game/objects/items/grenades/chem_grenade.dm b/code/game/objects/items/grenades/chem_grenade.dm index 3f53cea31f3..cdda65adf68 100644 --- a/code/game/objects/items/grenades/chem_grenade.dm +++ b/code/game/objects/items/grenades/chem_grenade.dm @@ -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) diff --git a/code/game/objects/items/grenades/grenade.dm b/code/game/objects/items/grenades/grenade.dm index 46d566f6630..6d6e54d877a 100644 --- a/code/game/objects/items/grenades/grenade.dm +++ b/code/game/objects/items/grenades/grenade.dm @@ -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)].")) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index e2f5f9ebcd7..191d9286b75 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -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 diff --git a/code/game/objects/structures/votingbox.dm b/code/game/objects/structures/votingbox.dm index c2261e733d1..abfa7c7ca7f 100644 --- a/code/game/objects/structures/votingbox.dm +++ b/code/game/objects/structures/votingbox.dm @@ -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 diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 79c231ec5de..afe03698bfb 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -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) diff --git a/code/modules/antagonists/_common/antag_datum.dm b/code/modules/antagonists/_common/antag_datum.dm index 033a804337d..33e54080b56 100644 --- a/code/modules/antagonists/_common/antag_datum.dm +++ b/code/modules/antagonists/_common/antag_datum.dm @@ -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 diff --git a/code/modules/antagonists/brainwashing/brainwashing.dm b/code/modules/antagonists/brainwashing/brainwashing.dm index 3b79c5886a3..66bbb22f503 100644 --- a/code/modules/antagonists/brainwashing/brainwashing.dm +++ b/code/modules/antagonists/brainwashing/brainwashing.dm @@ -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 diff --git a/code/modules/antagonists/cult/cult_comms.dm b/code/modules/antagonists/cult/cult_comms.dm index e0ddc7b66d9..25d38de519b 100644 --- a/code/modules/antagonists/cult/cult_comms.dm +++ b/code/modules/antagonists/cult/cult_comms.dm @@ -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 diff --git a/code/modules/antagonists/nukeop/nukeop.dm b/code/modules/antagonists/nukeop/nukeop.dm index 94234545b8e..660da61aad5 100644 --- a/code/modules/antagonists/nukeop/nukeop.dm +++ b/code/modules/antagonists/nukeop/nukeop.dm @@ -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 diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 788f73eda06..6e2806bed9a 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -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()) diff --git a/code/modules/mob/living/simple_animal/bot/construction.dm b/code/modules/mob/living/simple_animal/bot/construction.dm index e38bb95de9d..cbd36c2eab1 100644 --- a/code/modules/mob/living/simple_animal/bot/construction.dm +++ b/code/modules/mob/living/simple_animal/bot/construction.dm @@ -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) diff --git a/code/modules/mob/living/simple_animal/bot/mulebot.dm b/code/modules/mob/living/simple_animal/bot/mulebot.dm index 23726de39bc..33e3e0970d2 100644 --- a/code/modules/mob/living/simple_animal/bot/mulebot.dm +++ b/code/modules/mob/living/simple_animal/bot/mulebot.dm @@ -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) diff --git a/code/modules/paperwork/handlabeler.dm b/code/modules/paperwork/handlabeler.dm index 243006f9c8c..94ff618a963 100644 --- a/code/modules/paperwork/handlabeler.dm +++ b/code/modules/paperwork/handlabeler.dm @@ -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 diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index 7243ff0d6e8..04696687156 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -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) diff --git a/code/modules/spells/spell_types/telepathy.dm b/code/modules/spells/spell_types/telepathy.dm index 054d91f9f6a..5424d64ecaa 100644 --- a/code/modules/spells/spell_types/telepathy.dm +++ b/code/modules/spells/spell_types/telepathy.dm @@ -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 diff --git a/code/modules/surgery/advanced/brainwashing.dm b/code/modules/surgery/advanced/brainwashing.dm index d85839d0b70..7728b04b7fa 100644 --- a/code/modules/surgery/advanced/brainwashing.dm +++ b/code/modules/surgery/advanced/brainwashing.dm @@ -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]..."), diff --git a/code/modules/tgui/tgui_input_number.dm b/code/modules/tgui/tgui_input_number.dm index 5550d99f22e..cdf1b7a9d52 100644 --- a/code/modules/tgui/tgui_input_number.dm +++ b/code/modules/tgui/tgui_input_number.dm @@ -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) diff --git a/code/modules/tgui/tgui_input_text.dm b/code/modules/tgui/tgui_input_text.dm index b09ab68b82a..aabef0aa787 100644 --- a/code/modules/tgui/tgui_input_text.dm +++ b/code/modules/tgui/tgui_input_text.dm @@ -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, ...) diff --git a/tgui/packages/tgui/interfaces/NumberInputModal.tsx b/tgui/packages/tgui/interfaces/NumberInputModal.tsx index 6728f3c9be7..a5411eb1b8c 100644 --- a/tgui/packages/tgui/interfaces/NumberInputModal.tsx +++ b/tgui/packages/tgui/interfaces/NumberInputModal.tsx @@ -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 ( diff --git a/tgui/packages/tgui/interfaces/TextInputModal.tsx b/tgui/packages/tgui/interfaces/TextInputModal.tsx index 7b5f782d8b1..d20319b34bd 100644 --- a/tgui/packages/tgui/interfaces/TextInputModal.tsx +++ b/tgui/packages/tgui/interfaces/TextInputModal.tsx @@ -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 (