#! rockbox/tagbrowser/2.0
# ^ Version header must be the first line of every file

# Tag Browser configuration file, do not edit as changes will be lost!
# Instead, copy this file to "/.rockbox/tagnavi_user.config" and edit
# that, so your changes will not be overwritten automatically.
#
# If you only want to add menus and don't need to modify the default
# ones, you can edit "/.rockbox/tagnavi_custom.config" instead, which
# is included by this file and will not be overwritten automatically.
#
# Please note that modifying any menu labels/titles may result in them
# not being translated or voiced.

# Basic format declarations
%format "fmt_title"       "%s - %02d:%02d (%s)" basename Lm Ls filename ? title == "[Untagged]"
%format "fmt_title"       "%d.%02d. %s - %02d:%02d" discnum tracknum title Lm Ls ? discnum > "0"
%format "fmt_title"       "%02d. %s - %02d:%02d" tracknum title Lm Ls ? tracknum > "0"
%format "fmt_title"       "%s - %02d:%02d" title Lm Ls
%format "fmt_alphanum_title" "%s - %02d:%02d" title Lm Ls
%format "fmt_mostplayed" "%2d|%3d %s (%s)" playcount autoscore title canonicalartist %sort = "inverse" %limit = "100"
%format "fmt_lastplayed"  "%06d%s - %s" lastplayed canonicalartist title %sort = "inverse" %limit = "99" %strip = "6"
%format "fmt_forgotten"  "%06d%s - %s" lastplayed canonicalartist title %limit = "99" %strip = "6"
%format "fmt_best_tracks" "%02d. %s (%3d)" tracknum title autoscore
%format "fmt_score"       "(%3d) %s-%s" autoscore title canonicalartist
%format "fmt_rating"       "(%2d) %s-%s" rating title canonicalartist %sort = "inverse"

# Include our custom menu
%include "/.rockbox/tagnavi_custom.config"

#
# === Begin of "First Letter" sub menus
#

# Define the First Letter Artist sub menu
%byfirstletter "custom_albumartist" "Album Artists by First Letter" "albumartist"
# Define the First Letter Artist sub menu
%byfirstletter "custom_artist" "Artists by First Letter" "canonicalartist"
# Define the First Letter album sub menu
%byfirstletter "custom_album" "Albums by First Letter" "album"
# Define the First Letter track sub menu
%byfirstletter "custom_track" "Tracks by First Letter" "title"

# ^ An empy line ends the menu

# Define the First Letter sub menu
%menu_start "a2z" "By First Letter..."
"Album Artists" ==> "custom_albumartist"
"Artists" ==> "custom_artist"
"Albums" ==> "custom_album"
"Tracks" ==> "custom_track"

#
# === Begin of "Search by..." sub menu
#

# Define the search sub menu
%menu_start "search" "Search by..."
"Artist" -> canonicalartist ? canonicalartist ~ "" -> album -> title = "fmt_title"
"Album Artist" -> albumartist ? albumartist ~ "" -> album -> title = "fmt_title"
"Album" -> album ? album ~ "" -> title = "fmt_title"
"Title" -> title = "fmt_title" ? title ~ ""
"Albums by Year" -> album ? year = "" -> title = "fmt_title"
"Albums between Years" -> album ? year >= "" & year <= "" -> title = "fmt_title"
"Artists between Years" -> canonicalartist ? year >= "" & year <= "" -> album -> title = "fmt_title"
"Filename" -> filename ? filename ~ ""
"Score" -> title = "fmt_score" ? autoscore > ""
"User Rating" -> title = "fmt_rating" ? rating > ""
"Comment" -> album ? comment ~ "" -> title = "fmt_title"

# Define the "Same as currently played track" sub menu
%menu_start "same" "Same as currently played track"
"Directory" -> title ? filename ^ "#directory#"
"Title" -> title = "fmt_title" ? title = "#title#"
"Artist" -> album ? artist = "#artist#" | artist = "#albumartist#" | albumartist = "#artist#" | albumartist = "#albumartist#" -> title  = "fmt_title"
"Album" -> title = "fmt_title" ? album = "#album#"
"Composer" -> title = "fmt_title" ? composer = "#composer#"

# Define the runtime sub menu
%menu_start "runtime" "Playback History"
"Most played (Plays|Score)" -> title = "fmt_mostplayed" ? playcount > "0"
"Recently played tracks" -> title = "fmt_lastplayed" ? playcount > "0"
"Never played tracks" -> canonicalartist ? playcount == "0" -> album -> title = "fmt_title"
"Favourite artists" -> canonicalartist ? playcount > "3" & autoscore > "85" -> album -> title = "fmt_best_tracks"
"Favourite albums" -> album ? playcount > "3" & autoscore > "85" -> title = "fmt_best_tracks"
"Recent favourites" -> title = "fmt_lastplayed" ? playcount > "3" & autoscore > "85"
"New favourites" -> canonicalartist ? playcount <= "3" & autoscore > "85" -> album -> title = "fmt_best_tracks"
"Forgotten favourites" -> title = "fmt_forgotten" ? playcount > "3" & autoscore > "85"

# Define track submenu
%menu_start "track" "Tracks by"
"Filename" -> basename
"Title" -> title
"Title (with track duration)" -> title = "fmt_alphanum_title"

#
# === Begin of main menu
#

# Define the title of the main menu
%menu_start "main" "Database"
"Album Artist" -> albumartist   -> album  -> title = "fmt_title"
"Artist"   -> canonicalartist   -> album  -> title = "fmt_title"
"Album"    -> album    -> title = "fmt_title"
"Genre"    -> genre    -> canonicalartist -> album -> title = "fmt_title"
"Year"     -> year ? year > "0" -> canonicalartist -> album -> title = "fmt_title"
"Composer" -> composer -> album -> title = "fmt_title"
"First Letter" ==> "a2z"
"Tracks by"   ==> "track"
"Shuffle Songs" ~> title = "fmt_title"
"Search" ==> "search"
"User Rating" -> rating -> title = "fmt_title"
"Recently Added" -> album ? entryage < "4" & commitid > "0" -> title = "fmt_title"
"Playback History" ==> "runtime"
"Same as currently played track" ==> "same"
"Custom menu"  ==> "custom"

# And finally set main menu as our root menu
%root_menu "main"
