jf-roku/components/JFOverhang.bs

218 lines
6.0 KiB
Plaintext
Raw Normal View History

import "pkg:/source/utils/config.bs"
sub init()
2021-07-09 20:08:32 +00:00
m.top.id = "overhang"
m.top.translation = [54, 0]
m.leftGroup = m.top.findNode("overlayLeftGroup")
m.rightGroup = m.top.findNode("overlayRightGroup")
2021-07-09 20:08:32 +00:00
' hide seperators till they're needed
m.leftSeperator = m.top.findNode("overlayLeftSeperator")
m.leftSeperator.visible = "false"
2022-07-16 02:28:59 +00:00
m.rightSeperator = m.top.findNode("overlayRightSeperator")
2021-07-09 20:08:32 +00:00
' set font sizes
m.optionText = m.top.findNode("overlayOptionsText")
m.optionText.font.size = 20
m.optionStar = m.top.findNode("overlayOptionsStar")
m.optionStar.font.size = 58
' save node references
m.title = m.top.findNode("overlayTitle")
2022-07-16 02:28:59 +00:00
m.overlayRightGroup = m.top.findNode("overlayRightGroup")
m.overlayTimeGroup = m.top.findNode("overlayTimeGroup")
2022-09-19 23:34:36 +00:00
m.slideDownAnimation = m.top.findNode("slideDown")
m.slideUpAnimation = m.top.findNode("slideUp")
' show clock based on user setting
m.hideClock = m.global.session.user.settings["ui.design.hideclock"]
2022-07-16 02:28:59 +00:00
if not m.hideClock
' save node references
2022-10-29 11:27:01 +00:00
m.overlayHours = m.top.findNode("overlayHours")
m.overlayMinutes = m.top.findNode("overlayMinutes")
m.overlayMeridian = m.top.findNode("overlayMeridian")
m.overlayMeridian.font.size = 20
2022-07-16 02:28:59 +00:00
m.currentTimeTimer = m.top.findNode("currentTimeTimer")
' display current time
updateTime()
' start timer to update clock every minute
2022-07-16 02:28:59 +00:00
m.currentTimeTimer.control = "start"
m.currentTimeTimer.ObserveField("fire", "updateTime")
end if
setClockVisibility()
end sub
2020-02-26 22:55:47 +00:00
2022-09-19 23:34:36 +00:00
sub onVisibleChange()
if m.top.disableMoveAnimation
m.top.translation = [54, 0]
2022-09-19 23:34:36 +00:00
return
end if
if m.top.isVisible
m.slideDownAnimation.control = "start"
return
end if
m.slideUpAnimation.control = "start"
end sub
sub updateTitle()
2021-07-09 20:08:32 +00:00
if m.top.title <> ""
m.leftSeperator.visible = "true"
2021-07-09 20:08:32 +00:00
else
m.leftSeperator.visible = "false"
2021-07-09 20:08:32 +00:00
end if
m.title.text = m.top.title
2022-07-16 02:28:59 +00:00
if not m.hideClock
resetTime()
end if
end sub
2020-02-26 22:55:47 +00:00
2022-07-16 02:28:59 +00:00
sub setClockVisibility()
if m.hideClock
m.overlayRightGroup.removeChild(m.overlayTimeGroup)
end if
end sub
sub setRightSeperatorVisibility()
if m.hideClock
m.top.removeChild(m.rightSeperator)
return
end if
2021-07-09 20:08:32 +00:00
if m.top.currentUser <> ""
2022-07-16 02:28:59 +00:00
m.rightSeperator.visible = "true"
2021-07-09 20:08:32 +00:00
else
2022-07-16 02:28:59 +00:00
m.rightSeperator.visible = "false"
2021-07-09 20:08:32 +00:00
end if
2022-07-16 02:28:59 +00:00
end sub
sub updateUser()
setRightSeperatorVisibility()
2021-07-09 20:08:32 +00:00
user = m.top.findNode("overlayCurrentUser")
if isValid(user)
user.text = m.top.currentUser
end if
end sub
2020-02-26 22:55:47 +00:00
sub updateTime()
currentTime = CreateObject("roDateTime")
currentTime.ToLocalTime()
m.currentTimeTimer.duration = 60 - currentTime.GetSeconds()
m.currentHours = currentTime.GetHours()
m.currentMinutes = currentTime.GetMinutes()
2021-07-09 20:08:32 +00:00
updateTimeDisplay()
end sub
2020-02-26 22:55:47 +00:00
sub resetTime()
if m.hideClock then return
2021-07-09 20:08:32 +00:00
m.currentTimeTimer.control = "stop"
m.currentTimeTimer.control = "start"
2022-10-29 11:27:01 +00:00
updateTime()
end sub
2020-02-26 22:55:47 +00:00
sub updateTimeDisplay()
if m.global.device.clockFormat = "24h"
2022-10-29 11:27:01 +00:00
m.overlayMeridian.text = ""
2021-07-09 20:08:32 +00:00
if m.currentHours < 10
2022-10-29 11:27:01 +00:00
m.overlayHours.text = "0" + StrI(m.currentHours).trim()
2021-07-09 20:08:32 +00:00
else
2022-10-29 11:27:01 +00:00
m.overlayHours.text = m.currentHours
2021-07-09 20:08:32 +00:00
end if
2020-02-26 22:55:47 +00:00
else
2021-07-09 20:08:32 +00:00
if m.currentHours < 12
2022-10-29 11:27:01 +00:00
m.overlayMeridian.text = "AM"
2021-07-09 20:08:32 +00:00
if m.currentHours = 0
2022-10-29 11:27:01 +00:00
m.overlayHours.text = "12"
2021-07-09 20:08:32 +00:00
else
2022-10-29 11:27:01 +00:00
m.overlayHours.text = m.currentHours
2021-07-09 20:08:32 +00:00
end if
else
2022-10-29 11:27:01 +00:00
m.overlayMeridian.text = "PM"
2021-07-09 20:08:32 +00:00
if m.currentHours = 12
2022-10-29 11:27:01 +00:00
m.overlayHours.text = "12"
2021-07-09 20:08:32 +00:00
else
2022-10-29 11:27:01 +00:00
m.overlayHours.text = m.currentHours - 12
2021-07-09 20:08:32 +00:00
end if
end if
2020-02-26 22:55:47 +00:00
end if
2021-07-09 20:08:32 +00:00
if m.currentMinutes < 10
2022-10-29 11:27:01 +00:00
m.overlayMinutes.text = "0" + StrI(m.currentMinutes).trim()
2020-02-26 22:55:47 +00:00
else
2022-10-29 11:27:01 +00:00
m.overlayMinutes.text = m.currentMinutes
2020-02-26 22:55:47 +00:00
end if
end sub
2020-02-26 22:55:47 +00:00
sub updateOptions()
2021-07-09 20:08:32 +00:00
if m.top.showOptions = true
m.optionText.visible = true
m.optionStar.visible = true
2021-07-09 20:08:32 +00:00
else
m.optionText.visible = false
m.optionStar.visible = false
2021-07-09 20:08:32 +00:00
end if
2022-05-30 12:57:40 +00:00
end sub
' Ensure the Jellyfin logo is shown on the overhang.
sub showLogo()
scene = m.top.getScene()
logo = scene.findNode("overlayLogo")
leftSeperator = scene.findNode("overlayLeftSeperator")
if not isValid(leftSeperator)
seperator = createSeperator("overlayLeftSeperator")
m.leftGroup.insertChild(seperator, 0)
end if
if not isValid(logo)
posterLogo = createLogoPoster()
m.leftGroup.insertChild(posterLogo, 0)
end if
end sub
' Remove the Jellyfin logo from the overhang.
sub hideLogo()
scene = m.top.getScene()
logo = scene.findNode("overlayLogo")
leftSeperator = scene.findNode("overlayLeftSeperator")
if isValid(logo)
m.leftGroup.removeChild(logo)
end if
if isValid(leftSeperator)
m.leftGroup.removeChild(leftSeperator)
end if
end sub
' Ensure the current user is shown on the overhang.
sub showUser()
print "HELLO from showUser()"
scene = m.top.getScene()
currentUser = scene.findNode("overlayCurrentUser")
rightSeperator = scene.findNode("overlayRightSeperator")
if not isValid(rightSeperator)
seperator = createSeperator("overlayRightSeperator")
m.rightGroup.insertChild(seperator, 0)
end if
if not isValid(currentUser)
myUser = createOverhangUser()
myUser.text = m.top.currentUser
m.rightGroup.insertChild(myUser, 0)
end if
end sub
' Remove the Jellyfin logo from the overhang.
sub hideUser()
scene = m.top.getScene()
currentUser = scene.findNode("overlayCurrentUser")
rightSeperator = scene.findNode("overlayRightSeperator")
if isValid(currentUser)
m.rightGroup.removeChild(currentUser)
end if
if isValid(rightSeperator)
m.rightGroup.removeChild(rightSeperator)
end if
end sub