Create default movie view setting

This commit is contained in:
1hitsong 2022-12-19 21:03:35 -05:00
parent 303014d9c3
commit 545c91ef58
4 changed files with 58 additions and 11 deletions

View File

@ -128,13 +128,9 @@ sub loadInitialItems()
m.view = get_user_setting("display." + m.top.parentItem.Id + ".landing") m.view = get_user_setting("display." + m.top.parentItem.Id + ".landing")
sortAscendingStr = get_user_setting("display." + m.top.parentItem.Id + ".sortAscending") sortAscendingStr = get_user_setting("display." + m.top.parentItem.Id + ".sortAscending")
' If user has not set a preferred view for this folder ' If user has not set a preferred view for this folder, check if they've set a default view
if not isValid(m.view) if not isValid(m.view)
' Check if user has set a preferred view for the parent folder m.view = get_user_setting("itemgrid.movieDefaultView")
if isValid(m.top.parentItem.parentfolder)
print "Not View Set, Use Default"
m.view = get_user_setting("display." + m.top.parentItem.parentfolder + ".view")
end if
end if end if
if not isValid(m.sortField) then m.sortField = "SortName" if not isValid(m.sortField) then m.sortField = "SortName"
@ -196,12 +192,12 @@ sub loadInitialItems()
m.infoGroup.visible = false m.infoGroup.visible = false
else if LCase(m.options.view) = "moviesgrid" or LCase(m.view) = "moviesgrid" else if LCase(m.options.view) = "moviesgrid" or LCase(m.view) = "moviesgrid"
m.itemGrid.translation = "[96, 60]" m.itemGrid.translation = "[96, 60]"
m.itemGrid.itemSize = "[230, 350]"
m.itemGrid.rowHeights = "[350]"
m.top.showItemTitles = true
m.itemGrid.numRows = "3" m.itemGrid.numRows = "3"
m.selectedMovieOverview.visible = false m.selectedMovieOverview.visible = false
m.infoGroup.visible = false m.infoGroup.visible = false
m.itemGrid.itemSize = "[230, 350]"
m.itemGrid.rowHeights = "[350]"
m.top.showItemTitles = true
else if m.options.view = "Genres" or m.view = "Genres" else if m.options.view = "Genres" or m.view = "Genres"
m.loadItemsTask.StudioIds = m.top.parentItem.Id m.loadItemsTask.StudioIds = m.top.parentItem.Id
m.loadItemsTask.view = "Genres" m.loadItemsTask.view = "Genres"

View File

@ -13,6 +13,8 @@ sub init()
m.boolSetting = m.top.findNode("boolSetting") m.boolSetting = m.top.findNode("boolSetting")
m.integerSetting = m.top.findNode("integerSetting") m.integerSetting = m.top.findNode("integerSetting")
m.radioSetting = m.top.findNode("radioSetting")
m.integerSetting.observeField("submit", "onKeyGridSubmit") m.integerSetting.observeField("submit", "onKeyGridSubmit")
m.integerSetting.observeField("escape", "onKeyGridEscape") m.integerSetting.observeField("escape", "onKeyGridEscape")
@ -21,6 +23,7 @@ sub init()
m.settingsMenu.observeField("itemSelected", "settingSelected") m.settingsMenu.observeField("itemSelected", "settingSelected")
m.boolSetting.observeField("checkedItem", "boolSettingChanged") m.boolSetting.observeField("checkedItem", "boolSettingChanged")
m.radioSetting.observeField("checkedItem", "radioSettingChanged")
' Load Configuration Tree ' Load Configuration Tree
m.configTree = GetConfigTree() m.configTree = GetConfigTree()
@ -40,7 +43,6 @@ sub onKeyGridEscape()
end sub end sub
sub LoadMenu(configSection) sub LoadMenu(configSection)
if configSection.children = invalid if configSection.children = invalid
' Load parent menu ' Load parent menu
m.userLocation.pop() m.userLocation.pop()
@ -81,6 +83,7 @@ sub settingFocused()
' Hide Settings ' Hide Settings
m.boolSetting.visible = false m.boolSetting.visible = false
m.integerSetting.visible = false m.integerSetting.visible = false
m.radioSetting.visible = false
if selectedSetting.type = invalid if selectedSetting.type = invalid
return return
@ -99,6 +102,26 @@ sub settingFocused()
m.integerSetting.text = integerValue m.integerSetting.text = integerValue
end if end if
m.integerSetting.visible = true m.integerSetting.visible = true
else if LCase(selectedSetting.type) = "radio"
selectedValue = get_user_setting(selectedSetting.settingName, selectedSetting.default)
radioContent = CreateObject("roSGNode", "ContentNode")
itemIndex = 0
for each item in m.userLocation.peek().children[m.settingsMenu.itemFocused].options
listItem = radioContent.CreateChild("ContentNode")
listItem.title = tr(item.title)
listItem.id = item.id
if selectedValue = item.id
m.radioSetting.checkedItem = itemIndex
end if
itemIndex++
end for
m.radioSetting.content = radioContent
m.radioSetting.visible = true
else else
print "Unknown setting type " + selectedSetting.type print "Unknown setting type " + selectedSetting.type
end if end if
@ -117,6 +140,9 @@ sub settingSelected()
if selectedItem.type = "integer" if selectedItem.type = "integer"
m.integerSetting.setFocus(true) m.integerSetting.setFocus(true)
end if end if
if (selectedItem.type) = "radio"
m.radioSetting.setFocus(true)
end if
else if selectedItem.children <> invalid and selectedItem.children.Count() > 0 ' Show sub menu else if selectedItem.children <> invalid and selectedItem.children.Count() > 0 ' Show sub menu
LoadMenu(selectedItem) LoadMenu(selectedItem)
m.settingsMenu.setFocus(true) m.settingsMenu.setFocus(true)
@ -139,9 +165,13 @@ sub boolSettingChanged()
else else
set_user_setting(selectedSetting.settingName, "false") set_user_setting(selectedSetting.settingName, "false")
end if end if
end sub end sub
sub radioSettingChanged()
if m.radioSetting.focusedChild = invalid then return
selectedSetting = m.userLocation.peek().children[m.settingsMenu.itemFocused]
set_user_setting(selectedSetting.settingName, m.radioSetting.content.getChild(m.radioSetting.checkedItem).id)
end sub
function onKeyEvent(key as string, press as boolean) as boolean function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false if not press then return false
@ -152,6 +182,9 @@ function onKeyEvent(key as string, press as boolean) as boolean
else if (key = "back" or key = "left") and m.settingDetail.focusedChild <> invalid else if (key = "back" or key = "left") and m.settingDetail.focusedChild <> invalid
m.settingsMenu.setFocus(true) m.settingsMenu.setFocus(true)
return true return true
else if (key = "back" or key = "left") and m.radioSetting.hasFocus()
m.settingsMenu.setFocus(true)
return true
end if end if
if key = "right" if key = "right"

View File

@ -31,6 +31,7 @@
</RadioButtonList> </RadioButtonList>
</LayoutGroup> </LayoutGroup>
<RadioButtonList id="radioSetting" translation="[900, 450]" inheritParentTransform="false" vertFocusAnimationStyle="floatingFocus" />
<intkeyboard_integerKeyboard translation="[900, 520]" id="integerSetting" maxLength="3" domain="numeric" visible="false" /> <intkeyboard_integerKeyboard translation="[900, 520]" id="integerSetting" maxLength="3" domain="numeric" visible="false" />
</children> </children>

View File

@ -147,6 +147,23 @@
"settingName": "itemgrid.reset", "settingName": "itemgrid.reset",
"type": "bool", "type": "bool",
"default": "true" "default": "true"
},
{
"title": "Movie Library Default View",
"description": "Default view for Movie Libraries.",
"settingName": "itemgrid.movieDefaultView",
"type": "radio",
"default": "movies",
"options": [
{
"title": "Movies (Presentation)",
"id": "Movies"
},
{
"title": "Movies (Grid)",
"id": "MoviesGrid"
}
]
} }
] ]
} }