57 lines
2.1 KiB
Plaintext
57 lines
2.1 KiB
Plaintext
import "pkg:/source/utils/Locale.bs"
|
|
|
|
namespace DialogUtils
|
|
function ShowDialog(message as dynamic, title as string, large = false as boolean) as object
|
|
return ShowDialogButtons(message, title, [Tr(Locale.Buttons.OK)], large)
|
|
end function
|
|
|
|
function ShowDialogButtons(message as dynamic, title as string, buttons as object, large = false as boolean) as object
|
|
dialog = CreateObject("roSGNode", "SimpleDialog")
|
|
if GetInterface(message, "ifArray") = invalid
|
|
message = message.Tokenize(`\n`).ToArray()
|
|
end if
|
|
dialog.message = message
|
|
dialog.title = title
|
|
dialog.buttons = buttons
|
|
if large
|
|
if m._deviceDisplayWidth = invalid
|
|
deviceInfo = CreateObject("roDeviceInfo")
|
|
displaySize = deviceInfo.GetDisplaySize()
|
|
m._deviceDisplayWidth = displaySize.w
|
|
end if
|
|
dialog.width = m._deviceDisplayWidth - 100
|
|
end if
|
|
m.top.getScene().dialog = dialog
|
|
return dialog
|
|
end function
|
|
|
|
function ShowTimedDialogButtons(message as dynamic, title as string, buttons as object, defaultButton as integer, timeoutSeconds as integer, large = false as boolean) as object
|
|
dialog = CreateObject("roSGNode", "TimedDialog")
|
|
if GetInterface(message, "ifArray") = invalid
|
|
message = message.Tokenize(`\n`).ToArray()
|
|
end if
|
|
dialog.message = message
|
|
dialog.title = title
|
|
dialog.actualButtons = buttons
|
|
|
|
if large
|
|
if m._deviceDisplayWidth = invalid
|
|
deviceInfo = CreateObject("roDeviceInfo")
|
|
displaySize = deviceInfo.GetDisplaySize()
|
|
m._deviceDisplayWidth = displaySize.w
|
|
end if
|
|
dialog.width = m._deviceDisplayWidth - 100
|
|
end if
|
|
|
|
dialog.defaultButtonIndex = defaultButton
|
|
dialog.defaultActionTimeoutSeconds = timeoutSeconds
|
|
dialog.startCountdown = true
|
|
|
|
m.top.getScene().dialog = dialog
|
|
|
|
dialog.focusDefaultButton = true
|
|
|
|
return dialog
|
|
end function
|
|
end namespace
|