mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-19 03:55:11 +01:00
More standard tgui input conversions (#63464)
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* * 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 = MAX_MESSAGE_LEN, multiline = FALSE, encode = TRUE, timeout = 0)
|
||||
/proc/tgui_input_text(mob/user, message = "", title = "Text Input", default, max_length = MAX_MESSAGE_LEN, multiline = FALSE, encode = TRUE, timeout = 0)
|
||||
if (!user)
|
||||
user = usr
|
||||
if (!istype(user))
|
||||
@@ -24,7 +24,7 @@
|
||||
user = client.mob
|
||||
else
|
||||
return
|
||||
/// Client does NOT have tgui_input 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)
|
||||
@@ -54,7 +54,7 @@
|
||||
* * 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.
|
||||
*/
|
||||
/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 = 60 SECONDS)
|
||||
/proc/tgui_input_text_async(mob/user, message = "", title = "Text Input", default, max_length = MAX_MESSAGE_LEN, multiline = FALSE, encode = TRUE, datum/callback/callback, timeout = 60 SECONDS)
|
||||
if (!user)
|
||||
user = usr
|
||||
if (!istype(user))
|
||||
@@ -63,6 +63,15 @@
|
||||
user = client.mob
|
||||
else
|
||||
return
|
||||
// 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)
|
||||
return stripped_multiline_input(user, message, title, default, max_length)
|
||||
else
|
||||
return stripped_input(user, message, title, default, max_length)
|
||||
else
|
||||
return input(user, message, title, default)
|
||||
var/datum/tgui_input_text/async/text_input = new(user, message, title, default, max_length, multiline, encode, callback, timeout)
|
||||
text_input.ui_interact(user)
|
||||
|
||||
@@ -138,7 +147,7 @@
|
||||
"max_length" = max_length,
|
||||
"message" = message,
|
||||
"multiline" = multiline,
|
||||
"placeholder" = default, /// You cannot use default as a const
|
||||
"placeholder" = default, // You cannot use default as a const
|
||||
"preferences" = list(),
|
||||
"title" = title
|
||||
)
|
||||
@@ -179,7 +188,7 @@
|
||||
* An asynchronous version of tgui_input_text to be used with callbacks instead of waiting on user responses.
|
||||
*/
|
||||
/datum/tgui_input_text/async
|
||||
/// The callback to be invoked by the tgui_input_text upon having a choice made.
|
||||
// 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, encode, callback, timeout)
|
||||
|
||||
Reference in New Issue
Block a user