Make search sort options work
This commit is contained in:
parent
3658f0b77f
commit
7195d59c95
44
components/options-data.xml
Normal file
44
components/options-data.xml
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<component name="OptionsData" extends="ContentNode">
|
||||
<interface>
|
||||
<field id="base_title" type="string" />
|
||||
<field id="choices" type="stringarray" />
|
||||
<field id="config_key" type="string" />
|
||||
<field id="value_index" type="integer" />
|
||||
<field id="value" type="string" onChange="update_title" />
|
||||
<function name="cycle" />
|
||||
</interface>
|
||||
<script type="text/brightscript" uri="pkg:/source/config.brs" />
|
||||
<script type="text/brightscript">
|
||||
<![CDATA[
|
||||
sub init()
|
||||
m.top.value_index = 0
|
||||
end sub
|
||||
|
||||
sub update_title()
|
||||
for i=0 to m.top.choices.count() - 1
|
||||
if m.top.choices[i] = m.top.value
|
||||
m.top.value_index = i
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
m.top.title = m.top.base_title + ": " + m.top.value
|
||||
|
||||
print m.top.value_index
|
||||
end sub
|
||||
|
||||
sub cycle()
|
||||
max_opt = m.top.choices.count()
|
||||
i = m.top.value_index + 1
|
||||
while i >= max_opt
|
||||
i = i - max_opt
|
||||
end while
|
||||
|
||||
m.top.value_index = i
|
||||
m.top.value = m.top.choices[m.top.value_index]
|
||||
|
||||
set_user_setting(m.top.config_key, m.top.value)
|
||||
end sub
|
||||
]]>
|
||||
</script>
|
||||
</component>
|
|
@ -40,8 +40,7 @@
|
|||
options = m.top.options
|
||||
row = m.top.findNode("fieldList")
|
||||
|
||||
row.removeChildren(row.getChildren(-1, 0))
|
||||
|
||||
row.clear()
|
||||
row.appendChildren(options)
|
||||
end sub
|
||||
|
||||
|
@ -52,6 +51,11 @@
|
|||
m.top.visible = false
|
||||
m.top.escape = true
|
||||
return true
|
||||
else if key = "OK"
|
||||
list = m.top.findNode("panelList")
|
||||
data = list.content.getChild(list.itemFocused)
|
||||
data.callFunc("cycle")
|
||||
return true
|
||||
end if
|
||||
|
||||
return false
|
||||
|
|
|
@ -171,16 +171,24 @@ sub ShowMovieOptions(library)
|
|||
sidepanel = scene.findNode("options")
|
||||
movie_options = [
|
||||
{"title": "Sort Field",
|
||||
"base_title": "Sort Field",
|
||||
"key": "movie_sort_field",
|
||||
"values": ["blah", "this", "that"]},
|
||||
"default": "DateCreated",
|
||||
"values": ["DateCreated", "PremiereDate", "SortName"]},
|
||||
{"title": "Sort Order",
|
||||
"base_title": "Sort Order",
|
||||
"key": "movie_sort_order",
|
||||
"values": ["blah", "this", "that"]}
|
||||
"default": "Descending",
|
||||
"values": ["Descending", "Ascending"]}
|
||||
]
|
||||
new_options = []
|
||||
for each opt in movie_options
|
||||
o = CreateObject("roSGNode", "ContentNode")
|
||||
o = CreateObject("roSGNode", "OptionsData")
|
||||
o.title = opt.title
|
||||
o.choices = opt.values
|
||||
o.base_title = opt.base_title
|
||||
o.config_key = opt.key
|
||||
o.value = get_user_setting(opt.key, opt.default)
|
||||
new_options.append([o])
|
||||
end for
|
||||
sidepanel.options = new_options
|
||||
|
|
Loading…
Reference in New Issue
Block a user