Add a ton of complicated component bits

This commit is contained in:
Nick Bisby 2019-02-03 20:57:52 -06:00
parent 2788440d42
commit 16594f2cae
No known key found for this signature in database
GPG Key ID: F6E0C4E6D0B5EB36
6 changed files with 100 additions and 8 deletions

29
components/LibItem.xml Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="LibItem" extends="Group">
<children>
<LayoutGroup layoutDirection="vert" vertAlignment="top" itemSpacings="20" translation="[0,0]" >
<Poster id="itemImage" translation="[0,0]" width="200" height="300" />
<Label id="itemText" horizAlign="center" translation="[0,0]" font="font:MediumSystemFont" width="196" height="65" />
</LayoutGroup>
</children>
<interface>
<field id="itemContent" type="node" onChange="itemContentChanged"/>
</interface>
<script type="text/brightscript">
<![CDATA[
sub Init()
m.itemImage = m.top.findNode("itemImage")
m.itemText = m.top.findNode("itemText")
m.itemText.text = "Loading..."
end sub
function itemContentChanged() as void
itemData = m.top.itemContent
m.itemImage.uri = itemData.posterUrl
m.itemText.text = itemData.labelText
end function
]]>
</script>
</component>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="LibItemData" extends="ContentNode">
<interface>
<field id="labelText" type="string" />
<field id="posterUrl" type="string" />
</interface>
</component>

16
components/Library.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="Library" extends="Scene">
<children>
<LibraryRow
id="LibrarySelect"
visible="true"
translation="[150,150]"
/>
</children>
<interface>
<field id="libRowItemSelected" type="intarray" alias="LibrarySelect.RowSelectedItem" />
<field id="library" type="string" />
</interface>
</component>

39
components/mainlist.xml Normal file
View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="LibraryRow" extends="RowList">
<interface>
<field id="RowSelectedItem" type="int" />
<field id="libname" type="string" />
</interface>
<script type="text/brightscript">
<![CDATA[
sub init()
m.top.itemComponentName = "LibItem"
m.top.numRows = 1
m.top.content = getData()
m.top.visible = true
m.top.itemSize = [200 * 3 + 20 * 2, 365]
m.top.rowHeights = [365]
m.top.rowItemSize = [ [200, 365], [200, 365], [200, 365] ]
m.top.itemSpacing = [ 0, 80 ]
m.top.rowItemSpacing = [ [20, 0] ]
m.top.rowLabelOffset = [ [0, 30] ]
m.top.rowFocusAnimationStyle = "floatingFocus"
m.top.showRowLabel = [true, true]
m.top.rowLabelColor="0xa0b033ff"
m.top.setfocus(true)
end sub
function getData()
data = CreateObject("roSGNode", "ContentNode")
row = data.CreateChild("ContentNode")
row.title = "Libraries"
for i=1 to 3
item = row.CreateChild("LibItemData")
item.posterUrl = "http://devtools.web.roku.com/samples/images/Landscape_1.jpg"
item.labelText = "Placeholder" + stri(i)
end for
return data
end function
]]>
</script>
</component>

View File

@ -1,3 +1,5 @@
' Functions for making requests to the API
function APIRequest(url as String, params={} as Object)
req = createObject("roUrlTransfer")

View File

@ -7,21 +7,20 @@ sub Main()
screen.setMessagePort(m.port)
'todo - pick the scene based on if we need a server already
first_scene = "ServerSelect"
first_scene = "Library"
'Create a scene and load a component'
m.scene = screen.CreateScene("VideoScene")
m.scene = screen.CreateScene(first_scene)
screen.show()
get_token(get_var("username"), get_var("password"))
libs = LibraryList().items
librow = m.scene.findNode("LibrarySelect")
'librow.GetRowListContent()
' For now, just play whatever is the first item in the list
' of the first folder
libs = LibraryList().items
items = ItemList(libs[0].Id).items
n = Rnd(10)
movie_id = items[n-1].Id
player = VideoPlayer(movie_id)
while(true)
msg = wait(0, m.port)