commit bbc5d1c070242dbfbc577bbf49477d90c7d83618
parent 612ddacc901f682fc6736d3a1670d0e0dc9734a8
Author: Brian C. Lane <bcl@brianlane.com>
Date: Sun, 13 Nov 2022 09:36:58 -0800
Setup basic control flow for SetupServerDialog
The MainScene->Init starts the SetupServerDialog, which accepts the
user's input and places it into the dialog's serverurl field. An
observer on this field runs MainScene->OnSetupServerURL when it is
changed by the dialog.
OnSetupServerURL then copies to the MainScene's serverurl field. This
triggers an observer which starts the MainLoaderTask, and sets the
serveruri field of the task.
This is just a skeleton to make sure the control flow is working right.
Diffstat:
7 files changed, 61 insertions(+), 61 deletions(-)
diff --git a/HMS/components/MainLoaderTask.brs b/HMS/components/MainLoaderTask.brs
@@ -11,5 +11,6 @@ end sub
' GetContent is executed when m.contentTask.control = "run" from MainScene
sub GetContent()
print "MainLoaderTask->GetContent()"
+ print m.top.serverurl
end sub
diff --git a/HMS/components/MainLoaderTask.xml b/HMS/components/MainLoaderTask.xml
@@ -3,6 +3,7 @@
<script type="text/brightscript" uri="MainLoaderTask.brs" />
<interface>
+ <field id="serverurl" type="uri" />
<field id="content" type="node" />
</interface>
</component>
diff --git a/HMS/components/MainScene.brs b/HMS/components/MainScene.brs
@@ -4,8 +4,9 @@
'********************************************************************
sub Init()
print "MainScene->Init()"
+ m.top.ObserveField("serverurl", "RunContentTask")
- RunContentTask()
+ RunSetupServerDialog()
end sub
@@ -14,6 +15,7 @@ sub RunContentTask()
print "MainScene->RunContentTask()"
m.contentTask = CreateObject("roSGNode", "MainLoaderTask")
+ m.contentTask.serverurl = m.top.serverurl
m.contentTask.ObserveField("content", "OnMainContentLoaded")
m.contentTask.control = "run"
end sub
@@ -25,3 +27,18 @@ sub OnMainContentLoaded()
' m.loadingIndicator.visible = false
' m.GridScreen.content = m.contentTask.content
end sub
+
+sub RunSetupServerDialog()
+ print "MainScene->RunSetupServerDialog()"
+ m.serverDialog = createObject("roSGNode", "SetupServerDialog")
+ m.serverDialog.ObserveField("serverurl", "OnSetupServerURL")
+ m.top.dialog = m.serverDialog
+end sub
+
+sub OnSetupServerURL()
+ print "MainScene->OnSetupServerURL()"
+ print m.serverDialog.serverurl
+
+ ' pretend it was ok
+ m.top.serverurl = m.serverDialog.serverurl
+end sub
diff --git a/HMS/components/MainScene.xml b/HMS/components/MainScene.xml
@@ -2,6 +2,10 @@
<component name="MainScene" extends="Scene" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
<script type="text/brightscript" uri="MainScene.brs" />
+ <interface>
+ <field id="serverurl" type="uri" onChange="RunLoaderTask" />
+ <field id="keystore" type="bool" />
+ </interface>
<children>
<Label text="Hello World!" />
</children>
diff --git a/HMS/components/SetupServerDialog.brs b/HMS/components/SetupServerDialog.brs
@@ -0,0 +1,27 @@
+function init()
+ print "SetupServerDialog->Init()"
+
+' m.top.width = 1800
+ m.top.title = "Setup HMS Server URL"
+ m.top.message = ["Enter server name or IP address"]
+ m.top.buttons = ["OK"]
+
+ m.top.observeFieldScoped("buttonSelected", "dismissDialog")
+ m.top.observeFieldScoped("text", "textChanged")
+
+ m.top.observeFieldScoped("wasClosed", "wasClosedChanged")
+end function
+
+sub wasClosedChanged()
+ print "Example StandardKeyboardDialog Closed"
+ print "FINAL TEXT: "; m.top.text
+ m.top.serverurl = m.top.text
+end sub
+
+sub textChanged()
+ print "ENTERED TEXT: "; m.top.text
+end sub
+
+sub dismissDialog()
+ m.top.close = true
+end sub
diff --git a/HMS/components/SetupServerDialog.xml b/HMS/components/SetupServerDialog.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<component name="SetupServerDialog" extends="StandardKeyboardDialog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
+ <script type="text/brightscript" uri="SetupServerDialog.brs" />
+
+ <interface>
+ <field id="serverurl" type="uri" />
+ </interface>
+ <children>
+ </children>
+</component>
diff --git a/HMS/components/setupserver.xml b/HMS/components/setupserver.xml
@@ -1,60 +0,0 @@
-<?xml version = "1.0" encoding = "utf-8" ?>
-<component name = "SetupServer" extends = "Scene" initialFocus = "getServerName" >
- <script type = "text/brightscript" >
- <![CDATA[
- sub init()
- m.top.backgroundURI = "pkg:/images/rsgde_bg_hd.jpg"
-
- m.kbd = m.top.findNode("getServerName")
-
- rect = m.kbd.boundingRect()
- centerx = (1280 - rect.width) / 2
- centery = (720 - rect.height) / 2
- m.kbd.translation = [ centerx, centery ]
-
- m.finishedButton = m.top.findNode("finished")
- rect = m.finishedButton.boundingRect()
- m.finishedButton.translation = [1280 - rect.width, 720 - rect.height]
- m.finishedButton.ObserveField("buttonSelected", "onFinishPressed")
-
- m.top.setFocus(true)
- print "Running fucking server setup dialog"
- end sub
-
- sub onFinishedPressed()
- print "finish button pressed"
- print "server name is "; m.kbd.text
- end sub
-
- function onKeyEvent(key as String, press as Boolean) as Boolean
- handled = false
-
- print key
- print m.finishedButton.hasFocus()
- print press
- print m.kbd.text
- print
-
- if press
- if key = "down" and not m.finishedButton.hasFocus()
- m.finishedButton.setFocus(true)
- handled = true
- else if key = "up" and not m.kbd.hasFocus()
- m.kbd.setFocus(true)
- handled = true
- else if key = "OK" and m.finishedButton.hasFocus()
- print "OK was pressed on finished"
- print "server name is "; m.kbd.text
- end if
- end if
-
- return handled
- end function
- ]]>
- </script>
-
- <children >
- <Keyboard id = "getServerName" />
- <Button id="finished" text="Finished" showFocusFootprint="true" />
- </children>
-</component>