diff --git a/BGAnimations/ScreenSelectMusic overlay/SortMenu/SortMenu_InputHandler.lua b/BGAnimations/ScreenSelectMusic overlay/SortMenu/SortMenu_InputHandler.lua index 0e607dbd4..b0b678b37 100644 --- a/BGAnimations/ScreenSelectMusic overlay/SortMenu/SortMenu_InputHandler.lua +++ b/BGAnimations/ScreenSelectMusic overlay/SortMenu/SortMenu_InputHandler.lua @@ -22,8 +22,14 @@ local input = function(event) MESSAGEMAN:Broadcast('Sort', { order = focus.sort_by }) MESSAGEMAN:Broadcast('ResetHeaderText') overlay:queuecommand("DirectInputToEngine") - - -- the player wants to change modes, for example from ITG to FA+ + elseif focus.kind == "Playlist" then + local path = THEME:GetPathO("", "Playlists/" .. focus.new_overlay .. ".txt") + SONGMAN:SetPreferredSongs(path, --[[isAbsolute=]]true); + if SONGMAN:GetPreferredSortSongs() then + overlay:queuecommand("DirectInputToEngine") + SCREENMAN:GetTopScreen():GetMusicWheel():ChangeSort("SortOrder_Preferred") + end + -- the player wants to change modes, for example from ITG to FA+ elseif focus.kind == "ChangeMode" then SL.Global.GameMode = focus.change for player in ivalues(GAMESTATE:GetHumanPlayers()) do diff --git a/BGAnimations/ScreenSelectMusic overlay/SortMenu/WheelItemMT.lua b/BGAnimations/ScreenSelectMusic overlay/SortMenu/WheelItemMT.lua index 31042d836..6d513684e 100644 --- a/BGAnimations/ScreenSelectMusic overlay/SortMenu/WheelItemMT.lua +++ b/BGAnimations/ScreenSelectMusic overlay/SortMenu/WheelItemMT.lua @@ -82,7 +82,7 @@ return { end local toptext = self.kind ~= "" and THEME:GetString("ScreenSelectMusic", self.kind) or "" - local bottomtext = THEME:GetString(self.kind == "ChangeMode" and "ScreenSelectPlayMode" or "ScreenSelectMusic", info[2]) + local bottomtext = self.kind == "Playlist" and info[2] or THEME:GetString(self.kind == "ChangeMode" and "ScreenSelectPlayMode" or "ScreenSelectMusic", info[2]) self.top_text:settext(toptext) self.bottom_text:settext(bottomtext) diff --git a/BGAnimations/ScreenSelectMusic overlay/SortMenu/default.lua b/BGAnimations/ScreenSelectMusic overlay/SortMenu/default.lua index f2922b548..3d53567a8 100644 --- a/BGAnimations/ScreenSelectMusic overlay/SortMenu/default.lua +++ b/BGAnimations/ScreenSelectMusic overlay/SortMenu/default.lua @@ -188,14 +188,35 @@ local function AddPlayerSortOptions() local player_sort_options = {} for player in ivalues(GAMESTATE:GetHumanPlayers()) do if PROFILEMAN:IsPersistentProfile(player) then - SM("Adding player sort options") table.insert(player_sort_options, {"SortBy", "Top" .. ToEnumShortString(player) .. "Grades"}) - table.insert(player_sort_options, {"SortBy", "Recent" .. ToEnumShortString(player) .. "Played"}) end end return player_sort_options end +local function AddPlaylists() + local player_sort_options = {} + -- Get the name of every file in the Other/Playlists directory + local files = FILEMAN:GetDirListing(THEME:GetCurrentThemeDirectory().."Other/Playlists/") + -- Add each file to the wheel options + for i=1, #files do + local file = files[i] + if file:match("%.txt$") then + local playlist = file:gsub("%.txt$", "") + table.insert(player_sort_options, {{"Playlist", playlist}}) + end + end + + for player in ivalues(GAMESTATE:GetHumanPlayers()) do + local path = getFavoritesPath(player) + if FILEMAN:DoesFileExist(path) then + table.insert(player_sort_options, {{"MixTape", "Preferred"}}) + break + end + end + + return player_sort_options +end local function GetChangeableStyles(style) local available_styles = {} -- Allow players to switch from single to double and from double to single @@ -245,7 +266,8 @@ local wheel_options = { -- Conditions: -- These determine whether or not the option will be displayed. -- For instance: { {"SortBy", "Group"}, GAMESTATE:IsCourseMode() } will only display the Group option in CourseMode. - -- You can use any Lua expression that returns a boolean value here. + -- You can use any Lua expression that equates to a boolean value here. + -- Alternatively, you may provide a function that returns a boolean value for more complex and timely conditions. -- Submenus: -- We can create categories within the SortMenu by providing a table as the second element @@ -274,9 +296,9 @@ local wheel_options = { {"", "CategoryAdvanced"}, { { {"FeelingSalty", "TestInput"}, GAMESTATE:IsEventMode() }, - { {"HardTime", "PracticeMode"}, GAMESTATE:IsEventMode() and GAMESTATE:GetCurrentSong() ~= nil and ThemePrefs.Get("KeyboardFeatures")}, + { {"HardTime", "PracticeMode"}, function() return GAMESTATE:IsEventMode() and GAMESTATE:GetCurrentSong() ~= nil and ThemePrefs.Get("KeyboardFeatures") end }, { {"TakeABreather", "LoadNewSongs"} }, - { {"NeedMoreRam", "ViewDownloads"}, DownloadsExist() }, + { {"NeedMoreRam", "ViewDownloads"}, DownloadsExist }, { {"WhereforeArtThou", "SongSearch"}, not GAMESTATE:IsCourseMode() and ThemePrefs.Get("KeyboardFeatures") }, { {"NextPlease", "SwitchProfile"}, ThemePrefs.Get("AllowScreenSelectProfile") }, { {"SetSummaryText", "SetSummary"}, SL.Global.Stages.PlayedThisGame > 0 }, @@ -288,6 +310,10 @@ local wheel_options = { GetChangeableStyles(style), } }, + { + {"", "CategoryPlaylists"}, + AddPlaylists() + }, { {"SortBy", "Group"} }, { {"SortBy", "Title"} }, { {"SortBy", "Recent"} }, @@ -299,9 +325,9 @@ local wheel_options = { -- It's technically not possible to reach the sort menu in Casual Mode, but juuust in case let's still -- include the check. { {"ChangeMode", "Casual"}, SL.Global.Stages.PlayedThisGame == 0 and SL.Global.GameMode ~= "Casual" }, - { {"ImLovinIt", "AddFavorite"}, GAMESTATE:GetCurrentSong() ~= nil }, + { {"ImLovinIt", "AddFavorite"}, function() return GAMESTATE:GetCurrentSong() ~= nil end}, AddFavorites(), - { {"GrooveStats", "Leaderboard"}, IsServiceAllowed(SL.GrooveStats.Leaderboard) and GAMESTATE:GetCurrentSong() ~= nil }, + { {"GrooveStats", "Leaderboard"}, function() return IsServiceAllowed(SL.GrooveStats.Leaderboard) and GAMESTATE:GetCurrentSong() ~= nil end }, } @@ -331,7 +357,11 @@ local t = Def.ActorFrame { local sub_options = {} for j=1, #option[2] do local sub_option = option[2][j] - if sub_option[2] == nil or sub_option[2] == true then + if type(sub_option[2]) == "function" then + if sub_option[2]() then + table.insert(filtered_wheel_options, sub_option[1]) + end + elseif sub_option[2] == nil or sub_option[2] == true then table.insert(filtered_wheel_options, sub_option[1]) end end @@ -428,13 +458,21 @@ local t = Def.ActorFrame { local sub_options = {} for j=1, #option[2] do local sub_option = option[2][j] - if sub_option[2] == nil or sub_option[2] == true then + if type(sub_option[2]) == "function" then + if sub_option[2]() then + table.insert(sub_options, sub_option) + end + elseif sub_option[2] == nil or sub_option[2] == true then table.insert(sub_options, sub_option) end end if #sub_options > 0 then table.insert(filtered_wheel_options, {option[1][1], option[1][2]}) end + elseif type(option[2]) == "function" then + if option[2]() then + table.insert(filtered_wheel_options, {option[1][1], option[1][2]}) + end elseif option[2] == nil or option[2] == true then table.insert(filtered_wheel_options, {option[1][1], option[1][2]}) end diff --git a/Languages/en.ini b/Languages/en.ini index 1c72b02b7..a970f3c12 100644 --- a/Languages/en.ini +++ b/Languages/en.ini @@ -137,6 +137,8 @@ CategorySorts=Sorts... #CategoryModes=Modes... CategoryStyles=Styles... CategoryAdvanced=Options... +CategoryPlaylists=Playlists... +Playlist=Playlist # SortMenu choices # SortMenu "Sort By" choices