From 9efa3e46861488bd428c1484b16bda338b18d30b Mon Sep 17 00:00:00 2001 From: Nick Bisby Date: Sat, 9 Mar 2019 14:08:34 -0600 Subject: [PATCH] Begin work for making variables sizes --- components/MovieItem.xml | 18 ++++--- components/MovieItemDetails.brs | 88 +++++++++++++++++++++++++++++++++ components/MovieItemDetails.xml | 72 ++------------------------- components/MovieList.xml | 28 ++++++++--- components/Movies.xml | 1 - manifest | 2 + 6 files changed, 126 insertions(+), 83 deletions(-) create mode 100644 components/MovieItemDetails.brs diff --git a/components/MovieItem.xml b/components/MovieItem.xml index 1dff2a69..23f432d5 100644 --- a/components/MovieItem.xml +++ b/components/MovieItem.xml @@ -3,15 +3,11 @@ @@ -22,7 +18,15 @@ sub Init() m.title = m.top.findNode("title") m.poster = m.top.findNode("moviePoster") - m.title.text = "Loading..." + + maxSize = m.top.getParent().itemSize + + m.poster.width = int(maxSize[0]) - 4 + m.poster.height = m.poster.width * 1.5 + + m.title.width = m.poster.width + m.title.height = int(maxSize[1]) - m.poster.height + m.title.translation = [0, m.poster.height] end sub function itemContentChanged() as void diff --git a/components/MovieItemDetails.brs b/components/MovieItemDetails.brs new file mode 100644 index 00000000..62d6a8a1 --- /dev/null +++ b/components/MovieItemDetails.brs @@ -0,0 +1,88 @@ +sub itemContentChanged() + itemData = m.top.itemJson + + m.top.findNode("moviePoster").uri = ImageURL(itemData.id) + + ' Handle all "As Is" fields + setFieldText("title", itemData.name) + setFieldText("releaseYear", itemData.productionYear) + setFieldText("officialRating", itemData.officialRating) + setFieldText("communityRating", str(itemData.communityRating)) + setFieldText("overview", itemData.overview) + + setFieldText("runtime", stri(getRuntime()) + " mins") + setFieldText("ends-at", "Ends at " + getEndTime()) + + if itemData.genres.count() > 0 + setFieldText("genres", itemData.genres.join(", ")) + end if + director = invalid + for each person in itemData.people + if person.type = "Director" + director = person.name + exit for + end if + end for + if director <> invalid + setFieldText("director", "Director: " + director) + end if + setFieldText("video_codec", "Video: " + itemData.mediaStreams[0].displayTitle) + setFieldText("audio_codec", "Audio: " + itemData.mediaStreams[1].displayTitle) + ' TODO - cmon now. these are buttons, not words + setFieldText("buttons", "Play, Delete, Watched, Favorite, ...") + if itemData.taglines.count() > 0 + setFieldText("tagline", itemData.taglines[0]) + end if +end sub + +sub setFieldText(field as string, value) + node = m.top.findNode(field) + if node = invalid then return + + node.text = value +end sub + +function getRuntime() as Integer + itemData = m.top.itemJson + + ' A tick is .1ms, so 1/10,000,000 for ticks to seconds, + ' then 1/60 for seconds to minutess... 1/600,000,000 + return round(itemData.RunTimeTicks / 600000000.0) +end function + +function getEndTime() as string + itemData = m.top.itemJson + + date = CreateObject("roDateTime") + duration_s = int(itemData.RunTimeTicks / 10000000.0) + date.fromSeconds(date.asSeconds() + duration_s) + date.toLocalTime() + hours = date.getHours() + meridian = "AM" + if hours = 0 + hours = 12 + meridian = "AM" + else if hours = 12 + hours = 12 + meridian = "PM" + else if hours > 12 + hours = hours - 12 + meridian = "PM" + end if + + return Substitute("{0}:{1} {2}", stri(hours), stri(date.getMinutes()), meridian) +end function + +function round(f as Float) as Integer + ' BrightScript only has a "floor" round + ' This compares floor to floor + 1 to find which is closer + m = int(f) + n = m + 1 + x = abs(f - m) + y = abs(f - n) + if y > x + return m + else + return n + end if +end function diff --git a/components/MovieItemDetails.xml b/components/MovieItemDetails.xml index 78a67ca4..ffdad905 100644 --- a/components/MovieItemDetails.xml +++ b/components/MovieItemDetails.xml @@ -1,7 +1,7 @@ - + @@ -30,79 +30,15 @@ diff --git a/components/MovieList.xml b/components/MovieList.xml index 5bd7dc80..b99a37c2 100644 --- a/components/MovieList.xml +++ b/components/MovieList.xml @@ -13,15 +13,29 @@ m.top.content = getData() m.top.numrows = 1 - m.top.rowSize = 4 + m.top.rowSize = 5 + + dimensions = m.top.getScene().currentDesignResolution + + border = 75 + m.top.translation = [border, border] + + textHeight = 50 + ' Do we decide width by rowSize, or rowSize by width... + itemWidth = (dimensions["width"] - border*2) / m.top.rowSize + itemHeight = itemWidth * 1.5 + textHeight m.top.visible = true - m.top.itemSize = [200 * 4 + 20 * 3, 400] - m.top.rowHeights = [400] - m.top.rowItemSize = [ [200, 400] ] - m.top.itemSpacing = [ 0, 50 ] - m.top.rowItemSpacing = [ [20, 0] ] - m.top.rowLabelOffset = [ [0, 30] ] + + ' size of the whole row + m.top.itemSize = [dimensions["width"] - border*2, itemHeight] + ' spacing between rows + m.top.itemSpacing = [ 0, 10 ] + + ' size of the item in the row + m.top.rowItemSize = [ itemWidth, itemHeight ] + ' spacing between items in a row + m.top.rowItemSpacing = [ 0, 0 ] m.top.rowFocusAnimationStyle = "floatingFocus" 'm.top.vertFocusAnimationStyle = "floatingFocus" diff --git a/components/Movies.xml b/components/Movies.xml index 57a66b72..54fb0969 100644 --- a/components/Movies.xml +++ b/components/Movies.xml @@ -4,7 +4,6 @@ diff --git a/manifest b/manifest index dbc82f5d..ab7c6d2f 100644 --- a/manifest +++ b/manifest @@ -17,5 +17,7 @@ splash_screen_sd=pkg:/images/splash-screen_sd.jpg splash_min_time=1500 +ui_resolutions=hd,fhd + screensaver_private=0 screensaver_title=Jellyfin