Fix dialog not closing on load failure

This commit is contained in:
Brahim Hadriche committed 2024-01-24 16:29:22 -05:00
1 parent b1a373f98d
commit d9b8aaa222
2 files changed
+34 -41

No files matched your search

@@ -109,5 +109,5 @@ function ShowPlayletLibLoadErrorDialog()
"If the problem persist, contact Playlet authors."
]
Dialog.ShowError(message, bulletText, bottomText)
DialogShowError(message, bulletText, bottomText)
end function
+33 -40
View File
@@ -1,45 +1,38 @@
namespace Dialog
function DialogShowError(message as object, bulletText as object, bottomMessage as object)
' Note: dialog can be null since StandardMessageDialog is only available on 10.0 and later
msgDialog = CreateObject("roSGNode", "StandardMessageDialog")
DialogSetPalette(msgDialog)
msgDialog.message = message
msgDialog.bulletText = bulletText
msgDialog.bottomMessage = bottomMessage
msgDialog.title = "Error loading Playlet"
msgDialog.buttons = ["Exit"]
function ShowError(message as object, bulletText as object, bottomMessage as object)
' Note: dialog can be null since StandardMessageDialog is only available on 10.0 and later
msgDialog = CreateObject("roSGNode", "StandardMessageDialog")
SetPalette(msgDialog)
msgDialog.message = message
msgDialog.bulletText = bulletText
msgDialog.bottomMessage = bottomMessage
msgDialog.title = "Error loading Playlet"
msgDialog.buttons = ["Exit"]
' bs:disable-next-line NO_OBSERVE_STRING_CALLBACK
msgDialog.observeField("buttonSelected", "DialogOnButtonSelected")
' bs:disable-next-line NO_OBSERVE_STRING_CALLBACK
msgDialog.observeField("wasClosed", "DialogOnClosed")
' bs:disable-next-line NO_OBSERVE_STRING_CALLBACK
msgDialog.observeField("buttonSelected", "OnButtonSelected")
' bs:disable-next-line NO_OBSERVE_STRING_CALLBACK
msgDialog.observeField("wasClosed", "OnDialogClosed")
m.top.getScene().dialog = msgDialog
end function
m.top.getScene().dialog = msgDialog
end function
function DialogSetPalette(msgDialog as object)
palette = createObject("roSGNode", "RSGPalette")
palette.colors = {
DialogBackgroundColor: "#242424FF"
DialogFocusColor: "#CECECEFF"
DialogFocusItemColor: "#202020FF"
DialogSecondaryTextColor: "#DBDBDBFF"
DialogSecondaryItemColor: "#FF1C30FF"
DialogTextColor: "#DBDBDBFF"
}
msgDialog.palette = palette
end function
function SetPalette(msgDialog as object)
palette = createObject("roSGNode", "RSGPalette")
palette.colors = {
DialogBackgroundColor: "#242424FF"
DialogFocusColor: "#CECECEFF"
DialogFocusItemColor: "#202020FF"
DialogSecondaryTextColor: "#DBDBDBFF"
DialogSecondaryItemColor: "#FF1C30FF"
DialogTextColor: "#DBDBDBFF"
}
msgDialog.palette = palette
end function
function OnButtonSelected()
m.top.getScene().dialog.close = true
end function
function OnDialogClosed()
' TODO:P1 throw an exception to cause a crash report to be generated
' Should include which playlet lib failed to load
m.top.getScene().exitChannel = true
end function
end namespace
function DialogOnButtonSelected()
m.top.getScene().dialog.close = true
end function
function DialogOnClosed()
m.top.getScene().exitChannel = true
end function