This is my code contribution.
There's a "gameletter" function that acts differently if the list is sorted by name or manufacturer (returns the first letter), by category (returns the main category) or by year (returns the decade in the form 198x).
There is a routine in the on_transition section that, when transitioning to a new list, dynamically builds a table of "sort items" that are letters or years or categories according to the sort order, and changes it every time so the list is always consistent with the sort order. A small tweak can be done to space each "section" proportionally to the number of games in that slot but if there are few games then the category name will not fit, so I let it out
function gameletter( offset ) {
if (fe.filters.len() > 0){
if (fe.filters[fe.list.filter_index].sort_by == Info.Year){
local s = fe.game_info( Info.Year, offset )
s = s.slice (0,3)+"x"
return s
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Manufacturer){
local s = fe.game_info( Info.Manufacturer, offset )
return s.slice(0,1)
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Category){
local s = fe.game_info( Info.Category, offset )
if (s == "") return "?"
s = split( s, "/" )
return strip(s[0])
}
else {
local s = fe.game_info( Info.Title, offset )
if (s.find("The ") == 0) s = s.slice(4,s.len())
local s2 = s.slice(0,1)
if ("1234567890".find (s2) != null ){
s2="#"
}
return s2
}
}
}
local flw = fe.layout.width
local flh = fe.layout.height
local gamename = fe.add_text("[Title]\n[SortValue]",0,0,flw,flh/10)
gamename.charsize = gamename.height*0.25
local accent = fe.add_text ("[!gameletter]",0,flh*0.5,flw,flh*0.25)
accent.charsize = flh*0.25
local keys = null
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var, ttime ) {
if (ttype == Transition.ToNewSelection){
local l1 = gameletter(0)
local l2 = gameletter(var)
if (l1 != l2){
keys [l1].alpha = 128
keys [l2].alpha = 255
}
}
if (ttype == Transition.ToNewList){
local tableorder = []
local tableletter = {}
for (local i = 0 ; i < fe.list.size ; i++){
local s = (gameletter (i-fe.list.index))
try { tableletter[s]++ }
catch (err) {
tableletter[s] <- 1
tableorder.push (s)
}
}
keys = {}
local i = 0
local x0 = 0
foreach (key in tableorder){
local key_obj = fe.add_text(key,x0,flh*0.5,flw/tableorder.len(),50)
key_obj.charsize = 50
key_obj.alpha = ((tableletter[key] > 0) ? 128 : 0)
key_obj.set_bg_rgb (100+50*(i%2),100+50*(i%2),100+50*(i%2))
i++
x0 = x0 + flw/tableorder.len()
keys[key] <- key_obj
}
keys [gameletter(0)].alpha = 255
}
}