mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 06:00:16 +01:00
TGUI input box conversions 2 (#63395)
More text inputs converted to tgui, TGUI text and number input now more sanely handles ENTER key being pressed, you can now press anywhere in the window to enter the input. TGUI text input now considers placeholder text for the default valid state. IE, if there is default text you can press enter immediately without having to rewrite it just to recheck validity. Fixes: useSharedState => useLocalState. not only was sharedstate not needed but it opened up the ui to vulnerabilities
This commit is contained in:
@@ -169,7 +169,7 @@ AI MODULES
|
||||
lawpos = 4
|
||||
|
||||
/obj/item/ai_module/supplied/safeguard/attack_self(mob/user)
|
||||
var/targName = stripped_input(user, "Please enter the subject to safeguard.", "Safeguard who?", user.name,MAX_NAME_LEN)
|
||||
var/targName = tgui_input_text(user, "Subject to safeguard.", "Safeguard", user.name, MAX_NAME_LEN)
|
||||
if(!targName)
|
||||
return
|
||||
targetName = targName
|
||||
@@ -195,7 +195,7 @@ AI MODULES
|
||||
laws = list("Only SUBJECT is human.")
|
||||
|
||||
/obj/item/ai_module/zeroth/onehuman/attack_self(mob/user)
|
||||
var/targName = stripped_input(user, "Please enter the subject who is the only human.", "Who?", user.real_name,MAX_NAME_LEN)
|
||||
var/targName = tgui_input_text(user, "Enter the subject who is the only human.", "One Human", user.real_name, MAX_NAME_LEN)
|
||||
if(!targName)
|
||||
return
|
||||
targetName = targName
|
||||
@@ -255,7 +255,7 @@ AI MODULES
|
||||
return
|
||||
newpos = 15
|
||||
lawpos = min(newpos, 50)
|
||||
var/targName = stripped_input(user, "Please enter a new law for the AI.", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len))
|
||||
var/targName = tgui_input_text(user, "Enter a new law for the AI.", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len), TRUE)
|
||||
if(!targName)
|
||||
return
|
||||
if(is_ic_filtered(targName))
|
||||
@@ -386,7 +386,7 @@ AI MODULES
|
||||
var/subject = "human being"
|
||||
|
||||
/obj/item/ai_module/core/full/asimov/attack_self(mob/user as mob)
|
||||
var/targName = stripped_input(user, "Please enter a new subject that asimov is concerned with.", "Asimov to whom?", subject, MAX_NAME_LEN)
|
||||
var/targName = tgui_input_text(user, "Enter a new subject that Asimov is concerned with.", "Asimov", subject, MAX_NAME_LEN)
|
||||
if(!targName)
|
||||
return
|
||||
subject = targName
|
||||
@@ -468,7 +468,7 @@ AI MODULES
|
||||
laws = list("")
|
||||
|
||||
/obj/item/ai_module/core/freeformcore/attack_self(mob/user)
|
||||
var/targName = stripped_input(user, "Please enter a new core law for the AI.", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len))
|
||||
var/targName = tgui_input_text(user, "Enter a new core law for the AI.", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len), TRUE)
|
||||
if(!targName)
|
||||
return
|
||||
if(is_ic_filtered(targName))
|
||||
@@ -496,7 +496,7 @@ AI MODULES
|
||||
laws = list("")
|
||||
|
||||
/obj/item/ai_module/syndicate/attack_self(mob/user)
|
||||
var/targName = stripped_input(user, "Please enter a new law for the AI.", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len))
|
||||
var/targName = tgui_input_text(user, "Enter a new law for the AI", "Freeform Law Entry", laws[1], CONFIG_GET(number/max_law_len), TRUE)
|
||||
if(!targName)
|
||||
return
|
||||
if(is_ic_filtered(targName)) // not even the syndicate can uwu
|
||||
|
||||
@@ -190,7 +190,7 @@
|
||||
/obj/item/areaeditor/proc/edit_area()
|
||||
var/area/A = get_area(usr)
|
||||
var/prevname = "[A.name]"
|
||||
var/str = stripped_input(usr,"New area name:", "Area Creation", "", MAX_NAME_LEN)
|
||||
var/str = tgui_input_text(usr, "New area name", "Area Creation", max_length = MAX_NAME_LEN)
|
||||
if(!str || !length(str) || str==prevname) //cancel
|
||||
return
|
||||
if(length(str) > 50)
|
||||
|
||||
@@ -649,7 +649,7 @@ GLOBAL_LIST_EMPTY(PDAs)
|
||||
if("Clear")//Clears messages
|
||||
tnote = null
|
||||
if("Ringtone")
|
||||
var/t = stripped_input(U, "Please enter new ringtone", name, ttone, 20)
|
||||
var/t = tgui_input_text(U, "Enter a new ringtone", "PDA Ringtone", ttone, 20)
|
||||
if(in_range(src, U) && loc == U && t)
|
||||
if(SEND_SIGNAL(src, COMSIG_PDA_CHANGE_RINGTONE, U, t) & COMPONENT_STOP_RINGTONE_CHANGE)
|
||||
U << browse(null, "window=pda")
|
||||
@@ -767,7 +767,7 @@ GLOBAL_LIST_EMPTY(PDAs)
|
||||
|
||||
|
||||
/obj/item/pda/proc/msg_input(mob/living/U = usr, rigged = FALSE)
|
||||
var/t = stripped_input(U, "Please enter message", name)
|
||||
var/t = tgui_input_text(U, "Enter a message", "PDA Messaging")
|
||||
if (!t || toff)
|
||||
return
|
||||
if(!U.canUseTopic(src, BE_CLOSE))
|
||||
|
||||
@@ -77,10 +77,10 @@
|
||||
return
|
||||
|
||||
var/original_host = host_pda
|
||||
var/fakename = sanitize_name(stripped_input(user, "Enter a name for the rigged message.", "Forge Message", null, MAX_NAME_LEN), allow_numbers = TRUE)
|
||||
var/fakename = sanitize_name(tgui_input_text(user, "Enter a name for the rigged message.", "Forge Message", max_length = MAX_NAME_LEN), allow_numbers = TRUE)
|
||||
if(!fakename || host_pda != original_host || !user.canUseTopic(host_pda, BE_CLOSE))
|
||||
return
|
||||
var/fakejob = sanitize_name(stripped_input(user, "Enter a job for the rigged message.", "Forge Message", null, MAX_NAME_LEN), allow_numbers = TRUE)
|
||||
var/fakejob = sanitize_name(tgui_input_text(user, "Enter a job for the rigged message.", "Forge Message", max_length = MAX_NAME_LEN), allow_numbers = TRUE)
|
||||
if(!fakejob || host_pda != original_host || !user.canUseTopic(host_pda, BE_CLOSE))
|
||||
return
|
||||
if(charges > 0 && host_pda.send_message(user, list(target), rigged = REF(user), fakename = fakename, fakejob = fakejob))
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
/obj/item/beacon/attackby(obj/item/W, mob/user)
|
||||
if(istype(W, /obj/item/pen)) // needed for things that use custom names like the locator
|
||||
var/new_name = stripped_input(user, "What would you like the name to be?")
|
||||
var/new_name = tgui_input_text(user, "What would you like the name to be?", "Beacon", max_length = MAX_NAME_LEN)
|
||||
if(!user.canUseTopic(src, BE_CLOSE))
|
||||
return
|
||||
if(new_name)
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
if(!user.is_literate())
|
||||
to_chat(user, span_notice("You scribble illegibly on the side of [src]!"))
|
||||
return
|
||||
var/new_name = stripped_input(user, "What would you like the label to be?", name, null)
|
||||
var/new_name = tgui_input_text(user, "What would you like the label to be?", name, max_length = MAX_NAME_LEN)
|
||||
if((user.get_active_held_item() != used_item) || !user.canUseTopic(src, BE_CLOSE))
|
||||
return
|
||||
if(new_name)
|
||||
|
||||
@@ -187,13 +187,13 @@
|
||||
var/objective = "Obey the law. Praise Nanotrasen."
|
||||
var/custom = FALSE
|
||||
|
||||
/obj/machinery/implantchair/brainwash/implant_action(mob/living/C,mob/user)
|
||||
/obj/machinery/implantchair/brainwash/implant_action(mob/living/C, mob/user)
|
||||
if(!istype(C) || !C.mind) // I don't know how this makes any sense for silicons but laws trump objectives anyway.
|
||||
return FALSE
|
||||
if(custom)
|
||||
if(!user || !user.Adjacent(src))
|
||||
return FALSE
|
||||
objective = stripped_input(usr,"What order do you want to imprint on [C]?","Enter the order","",120)
|
||||
objective = tgui_input_text(user, "What order do you want to imprint on [C]?", "Brainwashing", max_length = 120)
|
||||
message_admins("[ADMIN_LOOKUPFLW(user)] set brainwash machine objective to '[objective]'.")
|
||||
log_game("[key_name(user)] set brainwash machine objective to '[objective]'.")
|
||||
if(HAS_TRAIT(C, TRAIT_MINDSHIELD))
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
to_chat(user, span_notice("You prod at [src] with [I]!"))
|
||||
return
|
||||
|
||||
var/new_name = stripped_input(user, "What would you like the label to be?", name, null)
|
||||
var/new_name = tgui_input_text(user, "What would you like the label to be?", name, max_length = MAX_NAME_LEN)
|
||||
if(user.get_active_held_item() != I)
|
||||
return
|
||||
if(!user.canUseTopic(src, BE_CLOSE))
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
one_use = TRUE
|
||||
|
||||
/obj/item/borg/upgrade/rename/attack_self(mob/user)
|
||||
heldname = sanitize_name(stripped_input(user, "Enter new robot name", "Cyborg Reclassification", heldname, MAX_NAME_LEN), allow_numbers = TRUE)
|
||||
heldname = sanitize_name(tgui_input_text(user, "Enter new robot name", "Cyborg Reclassification", heldname, MAX_NAME_LEN), allow_numbers = TRUE)
|
||||
log_game("[key_name(user)] have set \"[heldname]\" as a name in a cyborg reclassification board at [loc_name(user)]")
|
||||
|
||||
/obj/item/borg/upgrade/rename/action(mob/living/silicon/robot/R, user = usr)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
if(!user.is_literate())
|
||||
to_chat(user, span_notice("You scribble illegibly on [src]!"))
|
||||
return
|
||||
var/txt = stripped_input(user, "What would you like to write on the sign?", "Sign Label", null , 30)
|
||||
var/txt = tgui_input_text(user, "What would you like to write on the sign?", "Sign Label", max_length = 30)
|
||||
if(txt && user.canUseTopic(src, BE_CLOSE))
|
||||
label = txt
|
||||
name = "[label] sign"
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
if(user.canUseTopic(src, BE_CLOSE))
|
||||
..()
|
||||
if(istype(user) && loc == user)
|
||||
var/input = stripped_input(user,"What do you want your war cry to be? You will shout it when you hit someone in melee.", ,"", 50)
|
||||
var/input = tgui_input_text(user, "What do you want your war cry to be? You will shout it when you hit someone in melee.", "War Cry", max_length = 50)
|
||||
if(input)
|
||||
src.war_cry = input
|
||||
|
||||
|
||||
@@ -1467,7 +1467,7 @@
|
||||
|
||||
//Add changing looks when i feel suicidal about making 20 inhands for these.
|
||||
/obj/item/toy/dummy/attack_self(mob/user)
|
||||
var/new_name = stripped_input(usr,"What would you like to name the dummy?","Input a name",doll_name,MAX_NAME_LEN)
|
||||
var/new_name = tgui_input_text(usr, "What would you like to name the dummy?", "Doll Name", doll_name, MAX_NAME_LEN)
|
||||
if(!new_name)
|
||||
return
|
||||
doll_name = new_name
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
return
|
||||
|
||||
to_chat(joe, span_notice("As you burn the picture, a nickname comes to mind..."))
|
||||
var/nickname = stripped_input(joe, "Pick a nickname", "Mafioso Nicknames", null, NICKNAME_CAP, TRUE)
|
||||
var/nickname = tgui_input_text(joe, "Pick a nickname", "Mafioso Nicknames", max_length = NICKNAME_CAP)
|
||||
nickname = reject_bad_name(nickname, allow_numbers = FALSE, max_length = NICKNAME_CAP, ascii_only = TRUE)
|
||||
if(!nickname)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user