Input Fixes

This commit is contained in:
Casey
2022-06-21 06:14:03 -04:00
committed by Darlantan
parent 02f2cb90c5
commit 5788a26593
37 changed files with 1941 additions and 14 deletions

View File

@@ -10,7 +10,15 @@
* * timeout - The timeout of the alert, after which the modal will close and qdel itself. Set to zero for no timeout.
* * autofocus - The bool that controls if this alert should grab window focus.
*/
<<<<<<< refs/remotes/Upstream/master:code/modules/tgui_input/alert.dm
/proc/tgui_alert(mob/user, message = "", title, list/buttons = list("Ok"), timeout = 0, autofocus = TRUE)
=======
<<<<<<< HEAD:code/modules/tgui/tgui_alert.dm
/proc/tgui_alert(mob/user, message = null, title = null, list/buttons = list("Ok"), timeout = 0)
=======
/proc/tgui_alert(mob/user, message = "", title, list/buttons = list("Ok"), timeout = 0, autofocus = TRUE, strict_byond = FALSE)
>>>>>>> 9f14866f07... Merge pull request #13135 from ItsSelis/tgui-input-framework-hotfix:code/modules/tgui_input/alert.dm
>>>>>>> Input Fixes:code/modules/tgui/tgui_alert.dm
if (istext(buttons))
stack_trace("tgui_alert() received text for buttons instead of list")
return
@@ -25,19 +33,33 @@
user = client.mob
else
return
<<<<<<< refs/remotes/Upstream/master:code/modules/tgui_input/alert.dm
=======
<<<<<<< HEAD:code/modules/tgui/tgui_alert.dm
var/datum/tgui_alert/alert = new(user, message, title, buttons, timeout)
=======
>>>>>>> Input Fixes:code/modules/tgui/tgui_alert.dm
// A gentle nudge - you should not be using TGUI alert for anything other than a simple message.
if(length(buttons) > 3)
log_tgui(user, "Error: TGUI Alert initiated with too many buttons. Use a list.", "TguiAlert")
return tgui_input_list(user, message, title, buttons, timeout, autofocus)
// Client does NOT have tgui_input on: Returns regular input
<<<<<<< refs/remotes/Upstream/master:code/modules/tgui_input/alert.dm
if(!usr.client.prefs.tgui_input_mode)
=======
if(!usr.client.prefs.tgui_input_mode || strict_byond)
>>>>>>> Input Fixes:code/modules/tgui/tgui_alert.dm
if(length(buttons) == 2)
return alert(user, message, title, buttons[1], buttons[2])
if(length(buttons) == 3)
return alert(user, message, title, buttons[1], buttons[2], buttons[3])
var/datum/tgui_alert/alert = new(user, message, title, buttons, timeout, autofocus)
<<<<<<< refs/remotes/Upstream/master:code/modules/tgui_input/alert.dm
=======
>>>>>>> 9f14866f07... Merge pull request #13135 from ItsSelis/tgui-input-framework-hotfix:code/modules/tgui_input/alert.dm
>>>>>>> Input Fixes:code/modules/tgui/tgui_alert.dm
alert.tgui_interact(user)
alert.wait()
if (alert)

View File

@@ -15,7 +15,11 @@
* * timeout - The timeout of the number input, after which the modal will close and qdel itself. Set to zero for no timeout.
* * round_value - whether the inputted number is rounded down into an integer.
*/
<<<<<<< refs/remotes/Upstream/master
/proc/tgui_input_number(mob/user, message, title = "Number Input", default = 0, max_value = 10000, min_value = 0, timeout = 0, round_value = TRUE)
=======
/proc/tgui_input_number(mob/user, message, title = "Number Input", default = 0, max_value = INFINITY, min_value = -INFINITY, timeout = 0, round_value = FALSE)
>>>>>>> Input Fixes
if (!user)
user = usr
if (!istype(user))
@@ -135,7 +139,12 @@
if("submit")
if(!isnum(params["entry"]))
CRASH("A non number was input into tgui input number by [usr]")
<<<<<<< refs/remotes/Upstream/master
var/choice = round_value ? round(params["entry"]) : params["entry"]
=======
//var/choice = round_value ? round(params["entry"]) : params["entry"]
var/choice = params["entry"]
>>>>>>> Input Fixes
if(choice > max_value)
CRASH("A number greater than the max value was input into tgui input number by [usr]")
if(choice < min_value)
@@ -163,8 +172,14 @@
* * default - The default value pre-populated in the input box.
* * callback - The callback to be invoked when a choice is made.
* * timeout - The timeout of the input box, after which the menu will close and qdel itself. Set to zero for no timeout.
<<<<<<< refs/remotes/Upstream/master
*/
/proc/tgui_input_number_async(mob/user, message, title, default, datum/callback/callback, timeout = 60 SECONDS)
=======
* * round_value - whether the inputted number is rounded down into an integer.
*/
/proc/tgui_input_number_async(mob/user, message, title, default, datum/callback/callback, timeout = 60 SECONDS, round_value = FALSE)
>>>>>>> Input Fixes
if (istext(user))
stack_trace("tgui_input_num_async() received text for user instead of mob")
return
@@ -176,7 +191,11 @@
user = client.mob
else
return
<<<<<<< refs/remotes/Upstream/master
var/datum/tgui_input_number/async/input = new(user, message, title, default, callback, timeout)
=======
var/datum/tgui_input_number/async/input = new(user, message, title, default, callback, timeout, round_value)
>>>>>>> Input Fixes
input.tgui_interact(user)
/**
@@ -188,8 +207,13 @@
/// The callback to be invoked by the tgui_text_input upon having a choice made.
var/datum/callback/callback
<<<<<<< refs/remotes/Upstream/master
/datum/tgui_input_number/async/New(mob/user, message, title, default, callback, timeout)
..(user, title, message, default, timeout)
=======
/datum/tgui_input_number/async/New(mob/user, message, title, default, callback, timeout, round_value)
..(user, title, message, default, timeout, round_value)
>>>>>>> Input Fixes
src.callback = callback
/datum/tgui_input_number/async/Destroy(force, ...)

View File

@@ -10,12 +10,20 @@
* * message - The content of the text input, shown in the body of the TGUI window.
* * title - The title of the text input modal, shown on the top of the TGUI window.
* * default - The default (or current) value, shown as a placeholder.
<<<<<<< refs/remotes/Upstream/master
* * max_length - Specifies a max length for input. MAX_MESSAGE_LEN is default (1024)
=======
* * max_length - Specifies a max length for input. MAX_MESSAGE_LEN is default (4096)
>>>>>>> Input Fixes
* * 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.
*/
<<<<<<< refs/remotes/Upstream/master
/proc/tgui_input_text(mob/user, message = "", title = "Text Input", default, max_length = MAX_MESSAGE_LEN, multiline = FALSE, encode = FALSE, timeout = 0)
=======
/proc/tgui_input_text(mob/user, message = "", title = "Text Input", default, max_length = INFINITY, multiline = FALSE, encode = FALSE, timeout = 0, prevent_enter = FALSE)
>>>>>>> Input Fixes
if (istext(user))
stack_trace("tgui_input_text() received text for user instead of mob")
return
@@ -39,7 +47,11 @@
return input(user, message, title, default) as message|null
else
return input(user, message, title, default) as text|null
<<<<<<< refs/remotes/Upstream/master
var/datum/tgui_input_text/text_input = new(user, message, title, default, max_length, multiline, encode, timeout)
=======
var/datum/tgui_input_text/text_input = new(user, message, title, default, max_length, multiline, encode, timeout, prevent_enter)
>>>>>>> Input Fixes
text_input.tgui_interact(user)
text_input.wait()
if (text_input)
@@ -74,7 +86,13 @@
/// The title of the TGUI window
var/title
<<<<<<< refs/remotes/Upstream/master
/datum/tgui_input_text/New(mob/user, message, title, default, max_length, multiline, encode, timeout)
=======
var/prevent_enter
/datum/tgui_input_text/New(mob/user, message, title, default, max_length, multiline, encode, timeout, prevent_enter)
>>>>>>> Input Fixes
src.default = default
src.encode = encode
src.max_length = max_length
@@ -85,6 +103,10 @@
src.timeout = timeout
start_time = world.time
QDEL_IN(src, timeout)
<<<<<<< refs/remotes/Upstream/master
=======
src.prevent_enter = prevent_enter
>>>>>>> Input Fixes
/datum/tgui_input_text/Destroy(force, ...)
SStgui.close_uis(src)
@@ -120,6 +142,10 @@
data["placeholder"] = default // Default is a reserved keyword
data["swapped_buttons"] = !usr.client.prefs.tgui_swapped_buttons
data["title"] = title
<<<<<<< refs/remotes/Upstream/master
=======
data["prevent_enter"] = prevent_enter
>>>>>>> Input Fixes
return data
/datum/tgui_input_text/tgui_data(mob/user)