Create Component Library (#43)

* Move src under playlet-lib

* Update configuration

* Update script

* Update script

* Working version

* Vs code config WIP

* Package lock sync

* Lint fix

* Fix images

* Reuse config files

* Kind of a working setup

* Lock node version

* Rename scripts to tools

* Fix build scripts, lib url system

* Lint fix

* rale

* Fix args and web server

* Load fallbacks and build script cleanups

* Remove unused method

* no message

* no message

* Remove generic message field

* Lint fix

* no message

* Use loading indicator on main app

* Add playlet lib version to settings

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
Brahim Hadricheandgithub-action linter authored and GitHub committed 2023-01-29 16:50:28 -05:00
1 parent 90df81df4b
commit 9d8a3d1cea
156 files changed
+3341 -213

No files matched your search

@@ -0,0 +1,103 @@
function Init() as void
m.top.backgroundColor = "0x242424FF"
m.top.backgroundURI = ""
m.loadingIndicator = m.top.findNode("LoadingIndicator")
m.loadingIndicator.visible = true
m.global.addFields({
loadingIndicator: m.loadingIndicator
})
m.playletLibUrls = GetPlayletLibUrls()
m.playletLibUrlIndex = 0
LoadPlayletLib()
end function
function GetPlayletLibUrls() as object
github = { type: "github", link: ReadManifestValue("playlet_lib_remote_url") }
embedded = { type: "embedded", link: ReadManifestValue("playlet_lib_embedded_url") }
registry = { type: "registry", link: ReadRegistryKey("playlet_lib_url", "Playlet") }
if IsDebugMode()
return [embedded]
end if
urls = []
if registry.link <> invalid
urls.Push(registry)
end if
urls.push(github)
urls.push(embedded)
return urls
end function
function LoadPlayletLib() as void
if m.playletLibUrlIndex >= m.playletLibUrls.Count()
m.loadingIndicator.visible = false
ShowPlayletLibLoadErrorDialog()
return
end if
RemoveComponentLibrary()
m.lib = m.top.getScene().createChild("ComponentLibrary")
m.lib.observeField("loadStatus", "OnLoadStatusChanged")
uri = m.playletLibUrls[m.playletLibUrlIndex].link
?"Loading Playlet lib from " uri
m.lib.uri = uri
end function
function OnLoadStatusChanged() as void
uri = m.playletLibUrls[m.playletLibUrlIndex].link
if m.lib.loadStatus = "ready"
RemoveComponentLibrary()
?"Playlet lib loaded from " uri
scene = m.top.getScene()
container = scene.findNode("MainSceneContainer")
container.createChild("PlayletLib:MainScene")
return
end if
if m.lib.loadStatus = "failed"
?"Playlet lib failed to load from " uri
if m.playletLibUrls[m.playletLibUrlIndex].type = "registry"
' Delete library url from registry since it failed
DeleteRegistryKey("playlet_lib_url", "Playlet")
end if
' Try next url
m.playletLibUrlIndex += 1
LoadPlayletLib()
end if
end function
function RemoveComponentLibrary() as void
if m.lib = invalid
return
end if
scene = m.top.getScene()
scene.removeChild(m.lib)
m.lib = invalid
end function
function ShowPlayletLibLoadErrorDialog()
message = [
"Could not load Playlet component library from any of the following urls:",
]
bulletText = []
for each url in m.playletLibUrls
bulletText.push("[" + url.type + "] " + url.link)
end for
bottomText = [
"Please restart Playlet.",
"If the problem persist, contact Playlet authors."
]
ShowErrorDialog(message, bulletText, bottomText)
end function
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="BootstrapScene" extends="Scene">
<interface>
<field id="exitChannel" type="bool" alwaysNotify="true" />
<field id="launchArgs" type="assocarray" />
<field id="inputArgs" type="assocarray" />
</interface>
<script type="text/brightscript" uri="pkg:/source/Dialog.bs" />
<script type="text/brightscript" uri="pkg:/source/Manifest.bs" />
<script type="text/brightscript" uri="pkg:/source/Registry.bs" />
<children>
<Group id="MainSceneContainer"/>
<LoadingIndicator id="LoadingIndicator" />
</children>
</component>
@@ -0,0 +1,26 @@
function Init()
m.busySpinner = m.top.findNode("busySpinner")
m.busyspinner.poster.width = 150
m.busyspinner.poster.height = 150
m.busyspinner.poster.observeField("loadStatus", "PositionSpinner")
m.busySpinner.poster.uri = "pkg:/images/spinner.png"
m.top.observeField("visible", "OnVisibleChange")
end function
function PositionSpinner()
if m.busyspinner.poster.loadStatus = "ready"
centerx = (1280 - m.busyspinner.poster.width) / 2
centery = (720 - m.busyspinner.poster.height) / 2
m.busyspinner.translation = [centerx, centery]
m.busyspinner.visible = true
end if
end function
function OnVisibleChange()
m.busyspinner.visible = m.top.visible
if m.busyspinner.visible
m.busyspinner.control = "start"
else
m.busyspinner.control = "stop"
end if
end function
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="LoadingIndicator" extends="Group">
<children>
<Rectangle
width="1280"
height="720"
color="#000000"
opacity="0.5">
<BusySpinner
id="busySpinner"
inheritParentOpacity="false"
spinInterval="1" />
</Rectangle>
</children>
</component>