[READY] TGUI Input Collection (#23891)

* List Input refresh

* Modal Alerts

* Text Input

* Number Input

* Split Button

* Renaming

* Alert converts

* Text Input Conversion (Part 1)

And TextArea Autofocus + maxLength

* Text Input Conversion (Part 2)

* AAAAAAAAAAAAAAAAAAAA

* I'm FUCKED

* @GDNgit review changes

* "'" fixes

* Revert TGUI Alert from admin delete

* NumberInput Window size

* CRASH if empty list

* Update code/modules/tgui/tgui_input/list_input.dm

* TGUI Rebuild

* TGUI Rebuild

* Update code/modules/paperwork/faxmachine.dm

* _char

* compile

* Rebuild

---------

Co-authored-by: Aylong <69762909+Aylong220@users.noreply.github.com>
Co-authored-by: S34N <12197162+S34NW@users.noreply.github.com>
This commit is contained in:
Aylong
2024-02-19 11:55:01 +00:00
committed by GitHub
co-authored by Aylong S34N
parent 0d5986fc5c
commit ac5add482f
168 changed files with 2310 additions and 1066 deletions
+4 -10
View File
@@ -204,11 +204,8 @@
to_chat(usr, "<span class='warning'>Error! Please notify administration.</span>")
return area_created
var/list/turf/turfs = res
var/str = trim(stripped_input(usr,"New area name:", "Blueprint Editing", "", MAX_NAME_LEN))
if(!str || !length(str)) //cancel
return area_created
if(length(str) > 50)
to_chat(usr, "<span class='warning'>The given name is too long. The area remains undefined.</span>")
var/str = tgui_input_text(usr, "New area name:", "Blueprint Editing", max_length = MAX_NAME_LEN, encode = FALSE)
if(!str || !length(str)) // Cancel
return area_created
var/area/A = new
A.name = str
@@ -239,11 +236,8 @@
/obj/item/areaeditor/proc/edit_area()
var/area/A = get_area()
var/prevname = "[sanitize(A.name)]"
var/str = trim(stripped_input(usr,"New area name:", "Blueprint Editing", prevname, MAX_NAME_LEN))
if(!str || !length(str) || str==prevname) //cancel
return
if(length(str) > 50)
to_chat(usr, "<span class='warning'>The given name is too long. The area's name is unchanged.</span>")
var/str = tgui_input_text(usr, "New area name:", "Blueprint Editing", prevname, MAX_NAME_LEN, encode = FALSE)
if(!str || !length(str) || str == prevname) // Cancel
return
set_area_machinery_title(A,str,prevname)
A.name = str
+1 -1
View File
@@ -98,7 +98,7 @@
if(flush) // Don't doublewipe.
to_chat(user, "<span class='warning'>You are already wiping this AI!</span>")
return
var/confirm = alert("Are you sure you want to wipe this card's memory? This cannot be undone once started.", "Confirm Wipe", "Yes", "No")
var/confirm = tgui_alert(user, "Are you sure you want to wipe this card's memory? This cannot be undone once started.", "Confirm Wipe", list("Yes", "No"))
if(confirm == "Yes" && (ui_status(user, GLOB.inventory_state) == UI_INTERACTIVE)) // And make doubly sure they want to wipe (three total clicks)
msg_admin_attack("[key_name_admin(user)] wiped [key_name_admin(AI)] with \the [src].", ATKLOG_FEW)
add_attack_logs(user, AI, "Wiped with [src].")
+1 -4
View File
@@ -56,10 +56,7 @@
to_chat(user, "<span class='warning'>[src] needs to recharge!</span>")
return
var/message = input(user, "Shout a message:", "Megaphone") as text|null
if(!message)
return
message = sanitize(copytext(message, 1, MAX_MESSAGE_LEN))
var/message = tgui_input_text(user, "Shout a message:", "Megaphone")
if(!message)
return
message = capitalize(message)
+2 -2
View File
@@ -260,7 +260,7 @@
looking_for_personality = 1
GLOB.paiController.findPAI(src, usr)
if(href_list["wipe"])
var/confirm = input("Are you CERTAIN you wish to delete the current personality? This action cannot be undone.", "Personality Wipe") in list("Yes", "No")
var/confirm = tgui_alert(usr, "Are you certain you wish to delete the current personality? This action cannot be undone.", "Personality Wipe", list("No", "Yes"))
if(confirm == "Yes")
for(var/mob/M in src)
to_chat(M, "<font color = #ff0000><h2>You feel yourself slipping away from reality.</h2></font>")
@@ -281,7 +281,7 @@
if(2)
radio.ToggleReception()
if(href_list["setlaws"])
var/newlaws = sanitize(copytext(input("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.pai_laws) as message,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.pai_laws)
if(newlaws)
pai.pai_laws = newlaws
to_chat(pai, "Your supplemental directives have been updated. Your new directives are:")
@@ -278,7 +278,7 @@
to_chat(user, "<span class='notice'>The injector is empty!</span>")
return
used = TRUE // Set this BEFORE the popup to prevent people using the injector more than once.
var/choice = alert(user, "The injector is still unused. Do you wish to use it?", "Fireproofing injector", "Yes", "No")
var/choice = tgui_alert(user, "The injector is still unused. Do you wish to use it?", "Fireproofing injector", list("Yes", "No"))
if(choice == "No")
to_chat(user, "<span class='notice'>You decide against using [src].</span>")
used = FALSE
@@ -104,7 +104,10 @@
var/heldname = "default name"
/obj/item/borg/upgrade/rename/attack_self(mob/user)
heldname = stripped_input(user, "Enter new robot name", "Cyborg Reclassification", heldname, MAX_NAME_LEN)
var/new_heldname = tgui_input_text(user, "Enter new robot name", "Cyborg Reclassification", heldname, MAX_NAME_LEN)
if(!new_heldname)
return
heldname = new_heldname
/obj/item/borg/upgrade/rename/do_install(mob/living/silicon/robot/R)
if(!R.allow_rename)
@@ -320,7 +320,7 @@
if(affecting.status & ORGAN_SPLINTED)
to_chat(user, "<span class='danger'>[H]'s [limb] is already splinted!</span>")
if(alert(user, "Would you like to remove the splint from [H]'s [limb]?", "Splint removal.", "Yes", "No") == "Yes")
if(tgui_alert(user, "Would you like to remove the splint from [H]'s [limb]?", "Splint removal", list("Yes", "No")) == "Yes")
affecting.status &= ~ORGAN_SPLINTED
H.handle_splints()
to_chat(user, "<span class='notice'>You remove the splint from [H]'s [limb].</span>")
+1 -1
View File
@@ -348,7 +348,7 @@
//get amount from user
var/min = 0
var/max = get_amount()
var/stackmaterial = round(input(user, "How many sheets do you wish to take out of this stack? (Maximum: [max])") as null|num)
var/stackmaterial = tgui_input_number(user, "How many sheets do you wish to take out of this stack? (Max: [max])", "Stack Split", max_value = max)
if(stackmaterial == null || stackmaterial <= min || stackmaterial > get_amount())
return
if(!Adjacent(user, 1))
+27 -18
View File
@@ -116,8 +116,10 @@ AI MODULES
/obj/item/aiModule/safeguard/attack_self(mob/user as mob)
..()
var/targName = stripped_input(usr, "Please enter the name of the person to safeguard.", "Safeguard who?", user.name)
targetName = targName
var/new_targetName = tgui_input_text(user, "Please enter the name of the person to safeguard.", "Safeguard who?", user.name)
if(!new_targetName)
return
targetName = new_targetName
desc = "A 'safeguard' AI module: 'Safeguard [targetName]. Individuals that threaten [targetName] are not crew and must be eliminated.'"
/obj/item/aiModule/safeguard/install(obj/machinery/computer/C)
@@ -143,8 +145,10 @@ AI MODULES
/obj/item/aiModule/oneCrewMember/attack_self(mob/user as mob)
..()
var/targName = stripped_input(usr, "Please enter the name of the person who is the only crew.", "Who?", user.real_name)
targetName = targName
var/new_targetName = tgui_input_text(usr, "Please enter the name of the person who is the only crew.", "Who?", user.real_name)
if(!new_targetName)
return
targetName = new_targetName
desc = "A 'one crew' AI module: 'Only [targetName] is crew.'"
/obj/item/aiModule/oneCrewMember/install(obj/machinery/computer/C)
@@ -208,12 +212,15 @@ AI MODULES
/obj/item/aiModule/freeform/attack_self(mob/user as mob)
..()
var/new_lawpos = input("Please enter the priority for your new law. Can only write to law sectors 15 and above.", "Law Priority (15+)", lawpos) as num
if(new_lawpos < MIN_SUPPLIED_LAW_NUMBER) return
lawpos = min(new_lawpos, MAX_SUPPLIED_LAW_NUMBER)
var/newlaw = ""
var/targName = sanitize(copytext(input(usr, "Please enter a new law for the AI.", "Freeform Law Entry", newlaw),1,MAX_MESSAGE_LEN))
newFreeFormLaw = targName
var/new_lawpos = tgui_input_number(user, "Please enter the priority for your new law. Can only write to law sectors 15 and above.", "Law Priority", lawpos, MAX_SUPPLIED_LAW_NUMBER, MIN_SUPPLIED_LAW_NUMBER)
if(!new_lawpos || new_lawpos == lawpos)
return
lawpos = new_lawpos
var/new_targetName = tgui_input_text(user, "Please enter a new law for the AI.", "Freeform Law Entry")
if(!new_targetName)
return
newFreeFormLaw = new_targetName
desc = "A 'freeform' AI module: ([lawpos]) '[newFreeFormLaw]'"
/obj/item/aiModule/freeform/addAdditionalLaws(mob/living/silicon/ai/target, mob/sender)
@@ -406,10 +413,11 @@ AI MODULES
/obj/item/aiModule/freeformcore/attack_self(mob/user as mob)
..()
var/newlaw = ""
var/targName = stripped_input(usr, "Please enter a new core law for the AI.", "Freeform Law Entry", newlaw)
newFreeFormLaw = targName
desc = "A 'freeform' Core AI module: '[newFreeFormLaw]'"
var/new_targetName = tgui_input_text(usr, "Please enter a new core law for the AI.", "Freeform Law Entry")
if(!new_targetName)
return
newFreeFormLaw = new_targetName
desc = "A 'freeform' Core AI module: '[newFreeFormLaw]'"
/obj/item/aiModule/freeformcore/addAdditionalLaws(mob/living/silicon/ai/target, mob/sender)
..()
@@ -433,10 +441,11 @@ AI MODULES
/obj/item/aiModule/syndicate/attack_self(mob/user as mob)
..()
var/newlaw = ""
var/targName = stripped_input(usr, "Please enter a new law for the AI.", "Freeform Law Entry", newlaw,MAX_MESSAGE_LEN)
newFreeFormLaw = targName
desc = "A hacked AI law module: '[newFreeFormLaw]'"
var/new_targetName = tgui_input_text(usr, "Please enter a new law for the AI.", "Freeform Law Entry", max_length = MAX_MESSAGE_LEN)
if(!new_targetName)
return
newFreeFormLaw = new_targetName
desc = "A hacked AI law module: '[newFreeFormLaw]'"
/obj/item/aiModule/syndicate/transmitInstructions(mob/living/silicon/ai/target, mob/sender)
// ..() //We don't want this module reporting to the AI who dun it. --NEO
+22 -24
View File
@@ -366,13 +366,13 @@
/obj/item/card/id/syndicate/attack_self(mob/user as mob)
if(!src.registered_name)
var/t = reject_bad_name(input(user, "What name would you like to use on this card?", "Agent Card name", ishuman(user) ? user.real_name : user.name), TRUE)
var/t = reject_bad_name(tgui_input_text(user, "What name would you like to use on this card?", "Agent Card name", ishuman(user) ? user.real_name : user.name), TRUE)
if(!t)
to_chat(user, "<span class='warning'>Invalid name.</span>")
return
src.registered_name = t
var/u = sanitize(stripped_input(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than maintenance.", "Agent Card Job Assignment", "Agent", MAX_MESSAGE_LEN))
var/u = tgui_input_text(user, "What occupation would you like to put on this card?\nNote: This will not grant any access levels other than maintenance.", "Agent Card Job Assignment", "Agent", MAX_MESSAGE_LEN)
if(!u)
to_chat(user, "<span class='warning'>Invalid assignment.</span>")
src.registered_name = ""
@@ -385,14 +385,14 @@
if(!registered_user)
registered_user = user.mind.current
switch(alert(user,"Would you like to display \the [src] or edit it?","Choose","Show","Edit"))
switch(tgui_alert(user, "Would you like to display [src] or edit it?", "Choose", list("Show", "Edit")))
if("Show")
return ..()
if("Edit")
switch(tgui_input_list(user, "What would you like to edit on [src]?", "Agent ID", list("Name", "Photo", "Appearance", "Sex", "Age", "Occupation", "Money Account", "Blood Type", "DNA Hash", "Fingerprint Hash", "Reset Access", "Delete Card Information")))
if("Name")
var/new_name = reject_bad_name(input(user,"What name would you like to put on this card?","Agent Card Name", ishuman(user) ? user.real_name : user.name), TRUE)
if(!Adjacent(user))
var/new_name = reject_bad_name(tgui_input_text(user, "What name would you like to put on this card?", "Agent Card Name", ishuman(user) ? user.real_name : user.name), TRUE)
if(!Adjacent(user) || !new_name)
return
src.registered_name = new_name
UpdateName()
@@ -465,9 +465,7 @@
"ERT_paranormal",
)
var/choice = tgui_input_list(user, "Select the appearance for this card.", "Agent Card Appearance", appearances)
if(!Adjacent(user))
return
if(!choice)
if(!Adjacent(user) || !choice)
return
icon_state = choice
switch(choice)
@@ -488,8 +486,8 @@
to_chat(usr, "<span class='notice'>Appearance changed to [choice].</span>")
if("Sex")
var/new_sex = sanitize(stripped_input(user,"What sex would you like to put on this card?","Agent Card Sex", ishuman(user) ? capitalize(user.gender) : "Male", MAX_MESSAGE_LEN))
if(!Adjacent(user))
var/new_sex = tgui_input_text(user,"What sex would you like to put on this card?", "Agent Card Sex", ishuman(user) ? capitalize(user.gender) : "Male")
if(!Adjacent(user) || !new_sex)
return
sex = new_sex
to_chat(user, "<span class='notice'>Sex changed to [new_sex].</span>")
@@ -500,8 +498,8 @@
if(ishuman(user))
var/mob/living/carbon/human/H = user
default = H.age
var/new_age = sanitize(input(user,"What age would you like to be written on this card?","Agent Card Age", default) as text)
if(!Adjacent(user))
var/new_age = tgui_input_number(user, "What age would you like to be written on this card?", "Agent Card Age", default, 300, 17)
if(!Adjacent(user) || !new_age)
return
age = new_age
to_chat(user, "<span class='notice'>Age changed to [new_age].</span>")
@@ -524,11 +522,11 @@
var/new_job = "Assistant"
if(department == "Custom")
new_job = sanitize(stripped_input(user,"Choose a custom job title:","Agent Card Occupation", "Assistant", MAX_MESSAGE_LEN))
new_job = tgui_input_text(user, "Choose a custom job title:", "Agent Card Occupation", "Assistant")
else if(department != "Assistant" && !isnull(departments[department]))
new_job = tgui_input_list(user, "What job would you like to put on this card?\nChanging occupation will not grant or remove any access levels.", "Agent Card Occupation", departments[department])
if(!Adjacent(user))
if(!Adjacent(user) || !new_job)
return
assignment = new_job
to_chat(user, "<span class='notice'>Occupation changed to [new_job].</span>")
@@ -536,8 +534,8 @@
RebuildHTML()
if("Money Account")
var/new_account = input(user,"What money account would you like to link to this card?","Agent Card Account",12345) as num
if(!Adjacent(user))
var/new_account = tgui_input_number(user, "What money account would you like to link to this card?", "Agent Card Account", 12345)
if(!Adjacent(user) || !new_account)
return
associated_account_number = new_account
to_chat(user, "<span class='notice'>Linked money account changed to [new_account].</span>")
@@ -549,8 +547,8 @@
if(H.dna)
default = H.dna.blood_type
var/new_blood_type = sanitize(input(user,"What blood type would you like to be written on this card?","Agent Card Blood Type",default) as text)
if(!Adjacent(user))
var/new_blood_type = tgui_input_text(user, "What blood type would you like to be written on this card?", "Agent Card Blood Type", default)
if(!Adjacent(user) || !new_blood_type)
return
blood_type = new_blood_type
to_chat(user, "<span class='notice'>Blood type changed to [new_blood_type].</span>")
@@ -563,8 +561,8 @@
if(H.dna)
default = H.dna.unique_enzymes
var/new_dna_hash = sanitize(input(user,"What DNA hash would you like to be written on this card?","Agent Card DNA Hash",default) as text)
if(!Adjacent(user))
var/new_dna_hash = tgui_input_text(user, "What DNA hash would you like to be written on this card?", "Agent Card DNA Hash", default)
if(!Adjacent(user) || !new_dna_hash)
return
dna_hash = new_dna_hash
to_chat(user, "<span class='notice'>DNA hash changed to [new_dna_hash].</span>")
@@ -577,21 +575,21 @@
if(H.dna)
default = md5(H.dna.uni_identity)
var/new_fingerprint_hash = sanitize(input(user,"What fingerprint hash would you like to be written on this card?","Agent Card Fingerprint Hash",default) as text)
if(!Adjacent(user))
var/new_fingerprint_hash = tgui_input_text(user, "What fingerprint hash would you like to be written on this card?", "Agent Card Fingerprint Hash", default)
if(!Adjacent(user) || !new_fingerprint_hash)
return
fingerprint_hash = new_fingerprint_hash
to_chat(user, "<span class='notice'>Fingerprint hash changed to [new_fingerprint_hash].</span>")
RebuildHTML()
if("Reset Access")
var/response = alert(user, "Are you sure you want to reset access saved on the card?","Reset Access", "No", "Yes")
var/response = tgui_alert(user, "Are you sure you want to reset access saved on the card?", "Reset Access", list("No", "Yes"))
if(response == "Yes")
access = initial_access.Copy() // Initial() doesn't work on lists
to_chat(user, "<span class='notice'>Card access reset.</span>")
if("Delete Card Information")
var/response = alert(user, "Are you sure you want to delete all information saved on the card?","Delete Card Information", "No", "Yes")
var/response = tgui_alert(user, "Are you sure you want to delete all information saved on the card?", "Delete Card Information", list("No", "Yes"))
if(response == "Yes")
name = initial(name)
registered_name = initial(registered_name)
@@ -305,8 +305,7 @@
S.name = name
S.ckey = theghost.ckey
dust_if_respawnable(theghost)
var/input = stripped_input(S, "What are you named?", null, "", MAX_NAME_LEN)
var/input = tgui_input_text(S, "What are you named?", "Change Name", max_length = MAX_NAME_LEN)
if(src && input)
name = input
S.real_name = input
@@ -14,11 +14,12 @@
/obj/item/picket_sign/attackby(obj/item/W, mob/user, params)
if(is_pen(W) || istype(W, /obj/item/toy/crayon))
var/txt = stripped_input(user, "What would you like to write on the sign?", "Sign Label", null , 30)
if(txt)
label = txt
src.name = "[label] sign"
desc = "It reads: [label]"
var/txt = tgui_input_text(user, "What would you like to write on the sign?", "Sign Label", max_length = 30)
if(!txt)
return
label = txt
src.name = "[label] sign"
desc = "It reads: [label]"
..()
/obj/item/picket_sign/attack_self(mob/living/carbon/human/user)
@@ -65,7 +65,7 @@
/obj/item/storage/backpack/holding/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/storage/backpack/holding))
var/response = alert(user, "This creates a singularity, destroying you and much of the station. Are you SURE?","IMMINENT DEATH!", "No", "Yes")
var/response = tgui_alert(user, "This creates a singularity, destroying you and much of the station. Are you SURE?", "IMMINENT DEATH!", list("No", "Yes"))
if(response == "Yes")
user.visible_message("<span class='warning'>[user] grins as [user.p_they()] begin[user.p_s()] to put a Bag of Holding into a Bag of Holding!</span>", "<span class='warning'>You begin to put the Bag of Holding into the Bag of Holding!</span>")
if(do_after(user, 30, target=src))
@@ -123,7 +123,7 @@
if(isfloorturf(over_object))
if(get_turf(M) != T)
return // Can only empty containers onto the floor under you
if(alert(M, "Empty [src] onto [T]?", "Confirm", "Yes", "No") != "Yes")
if(tgui_alert(M, "Empty [src] onto [T]?", "Confirm", list("Yes", "No")) != "Yes")
return
if(!(M && over_object && length(contents) && loc == M && !M.stat && !M.restrained() && !HAS_TRAIT(M, TRAIT_HANDS_BLOCKED) && get_turf(M) == T))
return // Something happened while the player was thinking
@@ -37,7 +37,7 @@
if(by_hand)
for(var/obj/O in src)
if(O.density)
var/response = alert(usr, "This crate has been packed with bluespace compression, an item inside won't fit back inside. Are you sure you want to open it?","Bluespace Compression Warning", "Yes", "No")
var/response = tgui_alert(usr, "This crate has been packed with bluespace compression, an item inside won't fit back inside. Are you sure you want to open it?", "Bluespace Compression Warning", list("Yes", "No"))
if(response == "No" || !Adjacent(usr))
return FALSE
break
@@ -22,8 +22,7 @@
/obj/structure/ninjatele/attack_hand(mob/user as mob)
if(user.mind.special_role=="Ninja")
switch(alert("Phase Jaunt relay primed, target locked as [station_name()], initiate VOID-shift translocation? (Warning! Internals required!)",,"Yes","No"))
switch(tgui_alert(user, "Phase Jaunt relay primed, target locked as [station_name()], initiate VOID-shift translocation? (Warning! Internals required!)", "Void Shift", list("Yes", "No")))
if("Yes")
if(user.z != src.z)
return
@@ -55,7 +54,7 @@
/obj/structure/respawner/attack_ghost(mob/dead/observer/user)
if(check_rights(R_EVENT))
var/outfit_pick = alert(user, "Do you want to pick an outfit or respawn?", "Pick an Outfit?", "Pick outfit", "Respawn", "Cancel")
var/outfit_pick = tgui_alert(user, "Do you want to pick an outfit or respawn?", "Pick an Outfit?", list("Pick outfit", "Respawn", "Cancel"))
if(outfit_pick == "Cancel")
return
if(outfit_pick == "Pick outfit")
@@ -70,7 +69,7 @@
selected_outfit = new_outfit
return
var/response = alert(user, "Are you sure you want to spawn here?\n(If you do this, you won't be able to be cloned!)", "Respawn?", "Yes", "No")
var/response = tgui_alert(user, "Are you sure you want to spawn here?\n(If you do this, you won't be able to be cloned!)", "Respawn?", list("Yes", "No"))
if(response == "Yes")
var/turf/respawner_location = get_turf(src)
if(!respawner_location) // gotta check it still exists, else you'll get sent to nullspace
+1 -1
View File
@@ -147,7 +147,7 @@ GLOBAL_LIST_EMPTY(safes)
return TRUE
if(drill && !broken)
switch(alert("What would you like to do?", "Thermal Drill", "Turn [drill_timer ? "Off" : "On"]", "Remove Drill", "Cancel"))
switch(tgui_alert(user, "What would you like to do?", "Thermal Drill", list("Turn [drill_timer ? "Off" : "On"]", "Remove Drill", "Cancel")))
if("Turn On")
if(do_after(user, 2 SECONDS, target = src))
drill_timer = addtimer(CALLBACK(src, PROC_REF(drill_open)), time_to_drill, TIMER_STOPPABLE)