Dev player rewrite (#883)

This commit is contained in:
Brahim Hadriche authored and GitHub committed 2026-06-10 19:01:21 -04:00
1 parent 8c11272b92
commit 1ba454cdab
80 files changed
+8405 -921

No files matched your search

@@ -0,0 +1,46 @@
import "pkg:/source/utils/Types.bs"
' Renders purely from `mode`:
' none -> hidden, spinner stopped.
' loading -> title/secondary-title overlay + spinner (first load).
' buffering -> spinner alone (mid-stream rebuffer).
enum SpinnerMode
None = 0
Loading = 1
Buffering = 2
end enum
function Init()
m.loadingGroup = m.top.findNode("loadingTitleArea")
m.spinner = m.top.findNode("spinner")
' blendColor lives on the BusySpinner's poster child, not the spinner node.
if m.spinner <> invalid and m.spinner.poster <> invalid
m.spinner.poster.blendColor = "#FF1C30FF"
end if
m.top.ObserveField("mode", FuncName(OnMode))
OnMode()
end function
function OnMode() as void
mode = m.top.mode
if mode = SpinnerMode.Loading
m.loadingGroup.visible = true
ShowSpinner(true)
else if mode = SpinnerMode.Buffering
m.loadingGroup.visible = false
ShowSpinner(true)
else
m.loadingGroup.visible = false
ShowSpinner(false)
end if
end function
function ShowSpinner(on as boolean) as void
m.spinner.visible = on
if on
m.spinner.control = "start"
else
m.spinner.control = "stop"
end if
end function
@@ -0,0 +1,60 @@
' LoadBufferSpinner @SGNode suite — instantiates JUST the spinner, sets `mode` (+ title/secondaryTitle), and asserts
' the right subtree renders: loading = title overlay + spinning spinner; buffering = spinner alone (no title);
' none = everything hidden + spinner stopped.
namespace Tests
@SGNode("LoadBufferSpinner")
@suite
class LoadBufferSpinnerTests extends Rooibos.BaseTestSuite
protected override function beforeEach()
m.top.mode = SpinnerMode.None
end function
@describe("LoadBufferSpinner — mode projection")
@it("loading shows the title overlay + the spinner")
function _()
m.top.title = "Rick Astley"
m.top.secondaryTitle = "RickAstleyVEVO"
m.top.mode = SpinnerMode.Loading
m.assertTrue(m.top.findNode("loadingTitleArea").visible)
spinner = m.top.findNode("spinner")
m.assertTrue(spinner.visible)
m.assertEqual(spinner.control, "start")
' title/secondary title pass through (aliased).
m.assertEqual(m.top.findNode("loadingTitleLabel").text, "Rick Astley")
m.assertEqual(m.top.findNode("loadingSecondaryTitleLabel").text, "RickAstleyVEVO")
end function
@it("buffering shows the spinner alone (no title overlay)")
function _()
m.top.mode = SpinnerMode.Buffering
m.assertFalse(m.top.findNode("loadingTitleArea").visible)
spinner = m.top.findNode("spinner")
m.assertTrue(spinner.visible)
m.assertEqual(spinner.control, "start")
end function
@it("none hides everything and stops the spinner")
function _()
m.top.mode = SpinnerMode.Loading ' show first
m.top.mode = SpinnerMode.None
m.assertFalse(m.top.findNode("loadingTitleArea").visible)
spinner = m.top.findNode("spinner")
m.assertFalse(spinner.visible)
m.assertEqual(spinner.control, "stop")
end function
@it("tints the spinner red")
function _()
spinner = m.top.findNode("spinner")
' blendColor reads back as a signed 32-bit Integer; coerce expected to the same Integer type.
expected% = (&hFF1C30FF and &hFFFFFFFF)
m.assertEqual(spinner.poster.blendColor, expected%)
end function
end class
end namespace
@@ -0,0 +1,26 @@
<component name="LoadBufferSpinner" extends="Group">
<!-- Two modes: first-load overlay (title + spinner) and mid-stream buffering (spinner alone). -->
<interface>
<field id="mode" type="integer" value="0" /> <!-- 0=none 1=loading 2=buffering -->
<field id="title" type="string" alias="loadingTitleLabel.text" />
<field id="secondaryTitle" type="string" alias="loadingSecondaryTitleLabel.text" />
</interface>
<children>
<!-- Title + secondary title overlay; shown only in loading mode. Static wrapped title (up to 3 lines),
matching the Chrome title area — a ScrollingLabel marquee would repaint continuously for the whole
load. -->
<LayoutGroup id="loadingTitleArea" translation="[68, 40]" layoutDirection="vert" itemSpacings="[5]" visible="false">
<Label id="loadingTitleLabel" width="900" wrap="true" maxLines="3"
color="0xFEFEFEFF" horizAlign="left">
<Font role="font" uri="font:BoldSystemFontFile" size="30" />
</Label>
<Label id="loadingSecondaryTitleLabel" width="900" height="26"
color="0xFEFEFEFF" horizAlign="left" vertAlign="top" wrap="false">
<Font role="font" uri="font:SystemFontFile" size="24" />
</Label>
</LayoutGroup>
<!-- Shared by both modes; translation centers the 80x80 spinner. -->
<BusySpinner id="spinner" translation="[600, 320]" visible="false" spinInterval="1"
uri="/RokuOS/Artwork/SceneGraph/FixedTheme/Base/FHD/Spinner_MH.webp" />
</children>
</component>