Updates per testing comments

Update intro code comments
Save msgNode to variable in main
Selecting subtitle moves cursor to OK button
Subtitle list moves with cursor instead of scrollbar
This commit is contained in:
1hitsong 2023-05-09 08:21:20 -04:00
parent fbbfe3eeca
commit 3b1207dc2f
4 changed files with 80 additions and 17 deletions

View File

@ -22,7 +22,8 @@ sub loadItems()
if m.global.queueManager.callFunc("getCurrentItem").startingPoint = 0
preRoll = GetIntroVideos(m.top.itemId)
if isValid(preRoll) and preRoll.TotalRecordCount > 0 and isValid(preRoll.items[0])
' Bypass joke pre-roll
' If an error is thrown in the Intros plugin, instead of passing the error they pass the entire rick roll music video.
' Bypass the music video and treat it as an error message
if lcase(preRoll.items[0].name) <> "rick roll'd"
m.global.queueManager.callFunc("push", m.global.queueManager.callFunc("getCurrentItem"))
m.top.itemId = preRoll.items[0].id

View File

@ -1,35 +1,96 @@
import "pkg:/source/utils/misc.brs"
sub init()
m.content = m.top.findNode("content")
m.top.observeField("contentData", "onContentDataChanged")
m.contentArea = m.top.findNode("contentArea")
m.radioOptions = m.top.findNode("radioOptions")
m.scrollBar = []
m.top.observeField("contentData", "onContentDataChanged")
m.top.observeFieldScoped("buttonSelected", "onButtonSelected")
m.radioOptions.observeField("focusedChild", "onItemFocused")
m.top.id = "OKDialog"
m.top.height = 900
m.top.title = "What's New?"
m.top.buttons = [tr("OK")]
end sub
' Event handler for when user selected a button
sub onButtonSelected()
if m.top.buttonSelected = 0
m.global.sceneManager.returnData = m.top.contentData.data[m.content.selectedIndex]
m.global.sceneManager.returnData = m.top.contentData.data[m.radioOptions.selectedIndex]
end if
end sub
' Event handler for when user's cursor highlights an option in the option list
sub onItemFocused()
focusedChild = m.radioOptions.focusedChild
if not isValid(focusedChild) then return
' We hide the scrollbar here because we must ensure not only that content has been loaded, but that Roku has drawn the popup
hideScrollBar()
' If a scrollbar is found, move the option list to the user's section
if m.scrollBar.count() <> 0
hightedButtonTranslation = m.radioOptions.focusedChild.translation
m.radioOptions.translation = [m.radioOptions.translation[0], -1 * hightedButtonTranslation[1]]
end if
end sub
' Hide the popup's scroll bar
sub hideScrollBar()
' If we haven't found the scrollbar node yet, try to find it now
if m.scrollBar.count() = 0
m.scrollBar = findNodeBySubtype(m.contentArea, "StdDlgScrollbar")
if m.scrollBar.count() = 0 or not isValid(m.scrollBar[0]) or not isValid(m.scrollBar[0].node)
return
end if
end if
' Don't waste time trying to hide it if it's already hidden
if not m.scrollBar[0].node.visible then return
m.scrollBar[0].node.visible = false
end sub
' Once user selected an item, move cursor down to OK button
sub onItemSelected()
buttonArea = findNodeBySubtype(m.top, "StdDlgButtonArea")
if buttonArea.count() <> 0 and isValid(buttonArea[0]) and isValid(buttonArea[0].node)
buttonArea[0].node.setFocus(true)
end if
end sub
sub onContentDataChanged()
i = 0
for each item in m.top.contentData.data
cardItem = m.content.CreateChild("StdDlgActionCardItem")
cardItem = m.radioOptions.CreateChild("StdDlgActionCardItem")
cardItem.iconType = "radiobutton"
cardItem.id = i
if isValid(item.selected)
m.content.selectedIndex = i
m.radioOptions.selectedIndex = i
end if
textLine = cardItem.CreateChild("SimpleLabel")
textLine.text = item.track.description
cardItem.observeField("selected", "onItemSelected")
i++
end for
end sub
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if key = "up"
' By default UP from the OK button is the scrollbar
' Instead, move the user to the option list
if not m.radioOptions.isinFocusChain()
m.radioOptions.setFocus(true)
return true
end if
end if
return false
end function

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<component name="RadioDialog" extends="StandardMessageDialog">
<component name="RadioDialog" extends="StandardMessageDialog" initialFocus="radioOptions">
<children>
<StdDlgContentArea>
<StdDlgItemGroup id="content" />
<StdDlgContentArea id="contentArea">
<StdDlgItemGroup id="radioOptions" />
</StdDlgContentArea>
</children>
<interface>

View File

@ -621,12 +621,13 @@ sub Main (args as dynamic) as void
end if
end if
else if isNodeEvent(msg, "dataReturned")
if isValid(msg.getRoSGNode()) and isValid(msg.getRoSGNode().returnData)
popupNode = msg.getRoSGNode()
if isValid(popupNode) and isValid(popupNode.returnData)
selectedItem = m.global.queueManager.callFunc("getHold")
m.global.queueManager.callFunc("clearHold")
if isValid(selectedItem) and selectedItem.count() > 0 and isValid(selectedItem[0])
if msg.getRoSGNode().returnData.indexselected = 0
if popupNode.returnData.indexselected = 0
'Resume video from resume point
startingPoint = 0
@ -640,19 +641,19 @@ sub Main (args as dynamic) as void
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("push", selectedItem[0])
m.global.queueManager.callFunc("playQueue")
else if msg.getRoSGNode().returnData.indexselected = 1
else if popupNode.returnData.indexselected = 1
'Start Over from beginning selected, set position to 0
selectedItem[0].startingPoint = 0
m.global.queueManager.callFunc("clear")
m.global.queueManager.callFunc("push", selectedItem[0])
m.global.queueManager.callFunc("playQueue")
else if msg.getRoSGNode().returnData.indexselected = 2
else if popupNode.returnData.indexselected = 2
' User chose Go to series
CreateSeriesDetailsGroup(selectedItem[0].json.SeriesId)
else if msg.getRoSGNode().returnData.indexselected = 3
else if popupNode.returnData.indexselected = 3
' User chose Go to season
CreateSeasonDetailsGroupByID(selectedItem[0].json.SeriesId, selectedItem[0].json.seasonID)
else if msg.getRoSGNode().returnData.indexselected = 4
else if popupNode.returnData.indexselected = 4
' User chose Go to episode
CreateMovieDetailsGroup(selectedItem[0])
end if